Skip to main content
Associate
June 18, 2024
Solved

Nucleo F103RB run on startup

  • June 18, 2024
  • 6 replies
  • 4666 views

Hi,

I'm going to say that this is a really nooby question, however I cannot find the answer anywhere.
Background, I'm using a nucleo F103RB, and I've programmed it using CubeIDE. I can connect the board, debug and  run the program fine. The board is powered via Vin at the correct voltages, with JP1 disconnected and JP5 set to E5V.

I need to be able to run this program immediately after the board powers on, without a USB connection. How do I upload a release build of my program to it, because whenever I try using cubeprogrammer, it doesn't run the program after it has restarted. When I've tried dragging and dropping the .elf file in, it's given me a write error.

Thanks in advance for your help,

P

Best answer by PJW62

I've done some more testing, I need to trigger a reset after power on, best way of doing this is with a POR chip

6 replies

Andrew Neil
Super User
June 18, 2024

Once your code has been programmed into a microcontroller's Flash, it will always run whenever the microcontroller starts.

After programming with something like CubeProgrammer, you will need to disconnect the programmer, and may need to reset or power-cycle the board.

 


@PJW62 wrote:

When I've tried dragging and dropping the .elf file in, it's given me a write error.


I think you need to use the .bin file?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
PJW62Author
Associate
June 19, 2024

Both the .bin and .elf are the same file, .elf is what cubeIDE defaults to for me. I've checked and the file is loaded onto the flash, however it's still not running when the controller starts. Is there something I need to do to get it to launch from flash?

Andrew Neil
Super User
June 19, 2024

@PJW62 wrote:

Both the .bin and .elf are the same file


No, they're not: the .bin is a pure binary image of the code in memory; the .elf has a whole lot more "metadata" in it.

I doubt that the ST-Link has the capability to decode a .elf.

https://community.st.com/t5/stm32cubeide-mcus/difference-between-bin-hex-and-elf-file-and-their-sizes/m-p/91681/highlight/true#M2350

 


@PJW62 wrote:

it's still not running when the controller starts. Is there something I need to do to get it to launch from flash?


How do you know it's "not running" ?

As @Tesla DeLorean said, check that the ST-LINK is NOT holding the device in reset.

Add some LEDs to you can see if it's getting stuck in the Hard Fault handler, or some other error handler.

Check any other busy loops - make sure they have an exit timeout

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Tesla DeLorean
Guru
June 18, 2024

If externally powering, watch that the STM32 in the ST-LINK is NOT holding the device in reset, you can check the level of the NRST with a scope or meter, you can disconnect it from the Target MCU by way of a Solder Bridge (SB).

Schematics for the boards are under the "CAD Resources" of the product page, download and review.

 

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
PJW62Author
Associate
June 19, 2024

Everything is powered correctly, the board lights up but has the ST-Link waiting for connection. The clock is set up to come from the ST-Link. My code runs straight from a while loop in main after the peripheral initialisation.

I program the board via usb, set the jumpers to run via external power, then power it via my circuitry without usb connection, the board powers on, but does nothing except wait for connection. I plug USB back in and run the release code from cube IDE. The board powers and runs as expected.

If I check the storage in cube programmer it has the correct program in it.

Thanks

P

Andrew Neil
Super User
June 19, 2024

Does the ST-Link get powered-up in that state?


A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
PJW62Author
Associate
June 20, 2024

Yeah the ST-Link comes on and flashes Red while waiting for connection

PJW62Author
Associate
June 20, 2024

yeah it's getting a signal, I don't know if it's correct or not though

Andrew Neil
Super User
June 20, 2024

Is it the same in both the working & non-working cases?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
PJW62Author
Associate
June 20, 2024

Yeah

PJW62Author
Associate
June 20, 2024

I've just tried running it by dragging the .bin into the drive. This also didn't work. The only time it works is when it's been uploaded via STM32CubeIDE by pressing run. Any other time it is powered on, it doesn't run the code. Is there some sort of code CubeIDE sends to tell it to run, or something I need to put into my code to tell it to run on power on?

Thanks

PJW62AuthorBest answer
Associate
June 24, 2024

I've done some more testing, I need to trigger a reset after power on, best way of doing this is with a POR chip

Explorer
February 21, 2025

Hello I am pretty new to the stm32 board and i am having exact same issue my jp1 pin is disconnected and i cannot find the jp5 pin though, so basically how do I trigger reset, do i just press the black button on the board? I would be grateful if you could provide pictures of the board as well

 

UPDATE: I found the jp5 pin header after reading the data sheet it is the 3 pins below reset button.

to elaborate the issue more i have a code which reads analog input and then send a fitting pwm signal i have tested the code in the debugger and it works fine but as soon as I run the code(upload it i am using stm32cubeide) it works fine as well but after a power cycle i see no signs that code is executing. the power led keeps blinking i am powering the controller via Vin i have grounded and all installed correctly