cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4: How to program MCU on-board flash from binary stored in external FLASH?

SKarl.3
Associate II

I have a design that uses and STM32L4 series MCU. The device will be hard to physically access, but has a serial connection to the 'outside' world on UART 4. The board also has a 4 Mbit flash connected to the MCU via (bit-banged) SPI.

When I need to update the FW in the MCU I'd like be able to send the binary file down the serial connection, store it in the external SPI flash, verify the download is good, and then copy flash the MCU FLASH so that the next boot up will be with the new FW.

Can someone please first verify if this is possible, and second point me to some resources on how to implement it?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

Yes, you can stage data in external memory, and subsequently pull that and write internal memory.

Would generally recommend making a small loader at the front of the internal flash which you never erase, it contains enough code to check the new app code, and then write it slightly deeper into internal flash. How much deeper depends on how tight the implementation is, but suspect the loader would take 16KB or less.

Things to have are some means to determining image size, and also a checksum or CRC for integrity checking.

STM32Cube_FW_L4_V1.17.2\Projects\NUCLEO-L432KC\Examples\FLASH\FLASH_EraseProgram

Seem to recall having posted L4 and L5 flashing code to the forum in recent weeks. Block sizes on the flash are relatively small and manageable.

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

View solution in original post

1 REPLY 1

Yes, you can stage data in external memory, and subsequently pull that and write internal memory.

Would generally recommend making a small loader at the front of the internal flash which you never erase, it contains enough code to check the new app code, and then write it slightly deeper into internal flash. How much deeper depends on how tight the implementation is, but suspect the loader would take 16KB or less.

Things to have are some means to determining image size, and also a checksum or CRC for integrity checking.

STM32Cube_FW_L4_V1.17.2\Projects\NUCLEO-L432KC\Examples\FLASH\FLASH_EraseProgram

Seem to recall having posted L4 and L5 flashing code to the forum in recent weeks. Block sizes on the flash are relatively small and manageable.

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