Skip to main content
Graduate
April 29, 2021
Question

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

  • April 29, 2021
  • 3 replies
  • 847 views

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?

    This topic has been closed for replies.

    3 replies

    Super User
    April 30, 2021

    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

    awiernieAuthor
    Graduate
    May 1, 2021

    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...

    awiernieAuthor
    Graduate
    May 1, 2021

    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?

    Graduate II
    May 1, 2021

    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.