cancel
Showing results for 
Search instead for 
Did you mean: 

STM32C071 bootloader patterns and boot selector bits defaults

ebastler
Associate

Hello,

I am currently working on a small device with a C071GBU. This is the first time I am using a chip with shared pins (PA12/PA10 and PA11/PA9) as well as no dedicated single-function BOOT0 pin.

My PCB has very tight space constraints, so software debugger or programming pads are no option - everything must work via the USB port, from first time setup on.

If I understood the specsheet correctly ("Pins PA9 and PA10 can be remapped in place of pins PA11 and PA12 (default mapping), using SYSCFG_CFGR1 register"), PA12/PA11 are default (and not PA10/PA9), so a fresh chip out of the box can be used for USB DFU, am I correct in this assumption?

Then there is my next question - how does BOOT0 work? If I understand correctly, the boot selector bits decide whether PA14 is BOOT0, or whether a software bit is used. The patterns in AN2606 are as follows:

ebastler_0-1736035190580.png

What I do not understand - how are the defaults? As in, if I have a fresh chip directly from the factory, how is it set up? Will PA14 operate as BOOT0 out of the box, or is this something I have to manually set in a first-time-flash? If the flash memory is empty the chip should always default to entering the bootloader, so I can flash a firmware that sets the correct bits through USB, and from there on PA14 is BOOT0, correct? I am sorry for asking questions that may seem trivial - bootloader patterns have been confusing me before, and I would prefer a prototype that works at least well enough to test all important features. This is a personal project, so prototyping funds are limited.

Then I have one third and hopefully last question - If PA14 is set up as BOOT0, can it still be used as a regular GPIO once the chip booted from the program flash memory? Background: The PCB has a single button. If the user holds this button while plugging in the device, it should enter bootloader. Once the chip has booted successfully, this button is however supposed to be used as part of the user interface to interact with the PCB. If the button can work as BOOT0 during startup, and then PA14 as soon as the boot from internal flash is completed, it would simplify my design. My workaround would be to short PA14 to PA13, and use PA13 after startup.

Kind regards,
Moritz

1 REPLY 1
TDK
Guru

> What I do not understand - how are the defaults? 

The reference manual will provide the answers here. It lists "reset" values for registers, and "factory default" settings for option bytes.

PA11/PA12 are used until you remap them. This has to be done after powerup--it is a volatile setting.

TDK_0-1736041844930.png

PA14/BOOT0

 

Default option bytes are nBOOT0 = nBOOT1 = nBOOT_SEL = 1. But since the flash is empty, the USB bootloader will load the first time it's powered (third pattern in the table).

TDK_1-1736042069129.png

 

> If PA14 is set up as BOOT0, can it still be used as a regular GPIO once the chip booted from the program flash memory?

Yes. The only time BOOT0 is sampled is when NRST goes high. Doesn't matter what you do with it after that.

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