cancel
Showing results for 
Search instead for 
Did you mean: 

Confusion about stlink and mbed (why do I need to upload via stlink for mbed to work)

MRobi
Associate II

I have been doing a lot of reading lately about the flashing process and bootloaders and not everything is clear.

The datasheet of my microcontroller says that it is stlink that enables mbed. I have confirmed that I have to upload via stlink in order for mbed to work. I uploaded an mbed program using stm32flash via uart and it didn't work. My question is why? Why does the way in which I upload firmware affect how it runs? Is there a workaround (a way to use mbed while uploading with stm32flash and uart)?

My next question has to do with the stlink firmware. As I understand it, the nucleo boards have the main microcontroller and an stm32f103cbt6 or similar for stlink. If I create a pcb and want mbed support, will I need to add this ic also? Will I need to flash stlink firmware onto it instead of the factory bootloader? Would this be doable for someone who has made pcbs in the past but is still not an expert?

Edit:

Looks like I had an error in my code and that's why flashing over uart didn't work with my mbed code. I have fixed the error and confirm that you can compile with mbed and upload over uart.

1 ACCEPTED SOLUTION

Accepted Solutions
RomainR.
ST Employee

Hi,

The ST-LINK/V2-1 is based on dedicated STM32F103CBT6, makes the STM32 Nucleo / Discovery boards Mbed Enabled.

When you plug in an mbed Microcontroller in to your PC using USB, it appears like a USB flash disk. This small disk is presented by the mbed Interface, and allows you to save ARM microcontroller binaries you want to run directly on to the mbed, without needing drivers. Note that when you save a binary file to the mbed disk, it is not immediately loaded in to the internal microcontroller FLASH memory.

By using STM32 Flash Loader, you are able to program the flash of you mcu application without using onboard STLink. You need to place mcu in bootloader mode (ie UART) The AN2606 (STM32 microcontroller system memory boot mode) describe the process for all STM32 familly.

I don't know the STM32 device you use, usually bootloader mode is enabled when Boot0 = VDD.

Then STM32 Flash Loader can talk with internal bootloader and allow erase or programming flash memory with .s19 or .bin or .hex file (.bin generated by Mbed compiler should work)

For a custom board with Mbed enabled, you have many possibilities:

  • Use a Nucleo board as external programmer (see Nucleo UM1724 Chapter6.2.4 Using ST-LINK/V2-1 to program and debug an external STM32 application)
  • By a STLinkV2 or V3 stand alone and implement a SWD connector on your pcb (for PA13, PA14, NRESET, VTARGET and GND)
  • Generate your .bin with Mbed compiler and use STM32 flash loader with serial bootloader

BR

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

6 REPLIES 6

The mbed mode is you dragging-and-dropping a .BIN file into the pseudo mass storage device.

stm32flash is NOT an ST application

ST has been poked on several occasions to provide an "ST-LINK OB" type chip where you can use a F103 or F723 to implement the on-board functionality, similar to those chips from ATMEL/MICROCHIP

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
RomainR.
ST Employee

Hi,

The ST-LINK/V2-1 is based on dedicated STM32F103CBT6, makes the STM32 Nucleo / Discovery boards Mbed Enabled.

When you plug in an mbed Microcontroller in to your PC using USB, it appears like a USB flash disk. This small disk is presented by the mbed Interface, and allows you to save ARM microcontroller binaries you want to run directly on to the mbed, without needing drivers. Note that when you save a binary file to the mbed disk, it is not immediately loaded in to the internal microcontroller FLASH memory.

By using STM32 Flash Loader, you are able to program the flash of you mcu application without using onboard STLink. You need to place mcu in bootloader mode (ie UART) The AN2606 (STM32 microcontroller system memory boot mode) describe the process for all STM32 familly.

I don't know the STM32 device you use, usually bootloader mode is enabled when Boot0 = VDD.

Then STM32 Flash Loader can talk with internal bootloader and allow erase or programming flash memory with .s19 or .bin or .hex file (.bin generated by Mbed compiler should work)

For a custom board with Mbed enabled, you have many possibilities:

  • Use a Nucleo board as external programmer (see Nucleo UM1724 Chapter6.2.4 Using ST-LINK/V2-1 to program and debug an external STM32 application)
  • By a STLinkV2 or V3 stand alone and implement a SWD connector on your pcb (for PA13, PA14, NRESET, VTARGET and GND)
  • Generate your .bin with Mbed compiler and use STM32 flash loader with serial bootloader

BR

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

RomainR.
ST Employee

You can

  • Use STM32CubeProgrammer which support usart programming with serial bootloader

https://www.st.com/en/development-tools/stm32cubeprog.html

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Thanks for the reply. If I understand correctly, they have been poked but have not done it?

Thanks for the reply. It is very informative. Is there any way to flash over uart without messing around with boot0? Maybe another bootloader?

Thanks for the reply. I have confirmed that stm32cubeprog works over uart. However, the board needs to be in the bootloader, correct? Is there any way to flash without messing with the boot0 pin? Maybe some bootloader that detects when it is being flashed over uart like how the default bootloader can be flashed over usb without boot0?