cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4: Insert USB-Stick, power on and write internal and external flash?

awiernie
Senior II

We use STM32F479 for portable measurement device (with TouchGfX HMI, data is stored on quadspi flash also). We have a USB host interface where we can read and write data to an USB stick.

Now we would like to send an USB stick to the customer in order to make an update to both flash: internal flash and external quad spi.

The prefered solution would be that he inserts the usb stick, switches on the device and both the flash are overwritten by data on usb stick.

Is there already a solution for this, eventually by a third party?

Or is there a source which I could adapt?

4 REPLIES 4
Pavel A.
Evangelist III

It sounds like you want a bootloader with update functionality. Of course there are various 3rd party updaters. Google.

Basically the bootloader will check that the inserted USB stick contains update. If so it will rewrite the main firmware.

Else it will simply jump to the main firmware.

Dealing with external flash part will need customization.

-- pa

awiernie
Senior II

I have found one:

https://www.firmwaremodules.com/pages/bootloader

It seems to support usb drive but seems to need that half of external flash is free.

I have made an inquiry...

awiernie
Senior II

An alternative would be that I integrate an option into the current application in order to read the data from flash drive and store it into the second half of the external flash. Afterwards I cannot simply copy the flash, because I would copy over the programm counter I guess. So it would need some code in RAM which copies all the flash from the second half to the first half of externl quadspi and also to internal flash. Has anyone already used such a solution?

There are many ways to approach this.

Having an easy place to stage the new firmware and check it's integrity are helpful. Staging in QSPI is probably easier than USB MSC directly.

Best to split your code so you have a small loader that can recover the situation, and replace the Internal / External Application images. The size of the BSP to handle this via QSPI probably the smallest and most efficient path. Only delete the existing app if you have validated/viable replacement images.

The main application code also have a recovery method to pull the larger QSPI image from USB MSC when it determines the currently loaded version isn't in sync with the one on the flash stick.

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