cancel
Showing results for 
Search instead for 
Did you mean: 

STM32C011 System/Open Bootloader

starivore
Associate II

Hello,

I'm using an STM32C011 for a product we are developing, and I want to use ST's default System/OpenBootloader (via UART) that the virgin chips have on board. That way in production we don't have to download our custom bootloader, and we'll use the default one and reduce the production time. On our board in fact we have another microcontroller, and we plan on using that one to update STM32C0's firmware, without loading an additional custom bootloader on the STM32C011.

So, the first two questions that I would like to ask are:

1) Are all the microcontrollers equipped by default with your bootloader, or should we make a specific request while buying the chips?

2) Is the default bootloader loaded into the virgin chips called SystemBootloader or OpenBootloader? I'm having trouble to differentiate between them.

 

I found the documentation for the Open Bootloader on the documents AN2606 and AN3155 and also found the OpenBootloader source code on github. But I would like to ask another two questions:

1) Is there a place where I can download the binary of the bootloader that is loaded on virgin chips? In case I already flashed a microcontroller, is there a way to flash back the default bootloader? This would speed up significantly our development.

2) Is there an example of an implementation of the host device that communicates with the OpenBootloader (possibly via UART) available? I can certainly implement it from scratch having the documentation from AN3155, but if I have an example available we can speed up the development.

 

Thank you very much in advance.

Best regards,

Eduard

8 REPLIES 8

You can read the content of the ROM via the MCU, or STM32 Cube Programmer, etc

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

Thank you, that is true, I can read the flash of a virgin chip and save it. That way I can download the factory bootloader any time I need.

Do you perhaps know the answers for the other three questions?

1) Are all the microcontrollers equipped by default with your bootloader, or should we make a specific request while buying the chips?

2) Is the default bootloader loaded into the virgin chips called SystemBootloader or OpenBootloader? I'm having trouble to differentiate between them.

3) Is there an example of an implementation of the host device that communicates with the OpenBootloader (possibly via UART) available? I can certainly implement it from scratch having the documentation from AN3155, but if I have an example available we can speed up the development.

I'll let ST answer questions related to their STM32C0 implementation details.

The System Loader is blown into OTP, I don't think you have an opportunity to erase it or replace it.

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

1+2) AN2606 described the built-in bootloader, or system bootloader, or "system memory boot mode". This is stored in the chip's ROM and is always present. OpenBootloader is something else entirely.

3) I'm not aware of an implementation available, but it's pretty simple to implement. Examples probably exist.

If you feel a post has answered your question, please click "Accept as Solution".
Hagi
Associate II

If you want to use the System Bootloader, then first check this table

Hagi_0-1698687297759.png

You can find it at STM32C011 Reference Manual (https://www.st.com/resource/en/reference_manual/rm0490-stm32c0x1-advanced-armbased-32bit-mcus-stmicroelectronics.pdf)
So what it's saying here is that if you want to boot with Flash Memory, you must first guarantee that the configuration bits are as follow:
BOOT_LOCK = 0

nBOOT1 = 1

nBOOTSEL = 0

nBOOT0 = don't care, can be either 0 or 1

Then you can select which one (System or Main Flash) by toggling BOOT0 pin. But the default factory value for nBOOTSEL is not 0, it is 1. As for the other bits, they're fine at factory values.

Hagi_3-1698688924642.png

A good thing is that when the Main Flash is empty, the device defaults to booting from System Memory, but you must be aware that the first thing you must do is to clear the nBOOTSEL bit to 0, because if you don't do it and flash you application firmware to STM32C011, you won't be able to reflash/update it without using a programmer connected to SWDIO/SWCLK pins.

Hagi_4-1698689266928.png

 

Thank you very much for your detailed explanation. Right now, I'm trying to make my library work on a virgin device, so I'm erasing the memory from STM32CubeProgrammer so that the SystemBootloader starts automatically.

All the commands seem to work, but I have two problems:

1) If I erase the flash with 0x44 0xBB, 0xFFFF 0x00, then when I try to write the memory with 0x31 0xCE I don't get any response from the bootloader. Is it because the memory is already empty, or maybe the bootloader reboots?
2) If I don't erase, I'm able to write the memory up to 0x08000700. When I try to write (256bytes) at address 0x08000800 I get an NACK as soon as I send the address. I don't have any write protection, do you have any idea of why it could fail?

Maybe it's something related to the interval between operations. If you don't send a command (it could be a simple GetID), then the bootloader stop responding.
You can see some implementation examples at this repository: https://github.com/florisla/stm32loader

starivore
Associate II

Thank you for the suggestion.

It was a checksum problem in one of the packets, now it works. Both with a virgin chip and while updating an already programmed chip.

 

The only problem that I have left is that it requires a hardware reset (BOOT0 toggle) after the GO command. And I don't have access to the BOOT0 pin from the host microcontroller. I tried setting nBoot1=1 and nBoot_SEL=1 before the GO command, but it doesn't work and the GO command fails.

Do you have any suggestions? Can I do everything programmatically?