cancel
Showing results for 
Search instead for 
Did you mean: 

ST32F4xx custom bootloader in top sector of flash

childresss
Associate II
Posted on January 22, 2015 at 06:55

ST32F415 to be exact.

Boot ROM disabled by BOOT0 jumper.

I saw a product where a custom bootloader was flashed into sector 11 (highest in that chip). And a reset vectors to that bootloader.

User code goes in sector 0, 1, 2, 3...

I cannot find in the option byte docs how to do this.

Anyone know?

3 REPLIES 3
Posted on January 22, 2015 at 10:06

Hello Steve,

> I saw a product where a custom bootloader was flashed into sector 11 (highest in that chip).  And a reset vectors to that bootloader.

STM32F40x/STM32F41x - based?

> I cannot find in the option byte docs how to do this.

Because there is no such.

In the dual-FLASH-bank models such as the 'F42x/'F43x, the XL-density 'F1xx and maybe some others, you can boot into any of the banks; but AFAIK this is still not the topmost sector.

Jan

Posted on January 22, 2015 at 11:30

I saw a product where a custom bootloader was flashed into sector 11 (highest in that chip). And a reset vectors to that bootloader.

 

User code goes in sector 0, 1, 2, 3...

Citation required...

The only way I see that happening is if the first sector contains two words pointing at the same SP and PC as the vector table for the high image.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
childresss
Associate II
Posted on January 22, 2015 at 22:59

Ah, so there is no option bytes to change the reset vector to point to flash sector 11.

What I saw in the vendor's product was that sector 11 in the '415 was marked read-write protected.  That must have been where the vendor's boot code was located, since the ST ROM was disabled (BOOT0=1).

So the only way to power-on-jump to sector 11's boot code would have been that sector 0's vector table in flash has to properly exist and has a reset vector to jump to sector 11? Let's see, how can we assure that this sector 0 table is never erased? Well, if the vendor's bootloader in sector 11 always ensures that on each bootload, the sector 0 table's reset entry is set to point to sector 11 by the boot loader, no matter what is in the downloaded file (USB downloader, not SWD or JTAG, nor the ST ROM).

This works unless sector 0 doesn't get rewritten properly due to a power failure or some such.

Or, is there some way to force the sector 11 code to run I don't know of (option bytes can't do this on the '415; I think they can on higher numbered STM324xx chips - there's a programmable boot address in those, but not in the '415.)

Thanks in advance

steve

PS: reference is Mikroe mini-M4 board w/STM32415. Sector 11 pre-programmed to be a USB bootloader. Proprietary program on PC accepts an Intel .HEX and sends (binary?) to the bootloader in sector 11 via USB. Today, I chip-erase and so far use ST-Link to download/debug. Eventually I need a custom bootloader that uses new code stored in a certain area of the 1MB of flash, or in an external SPI flash memory chip.