Skip to main content
Visitor II
September 6, 2024
Question

Is it possible to overwrite the external flash memory from itself?

  • September 6, 2024
  • 3 replies
  • 1304 views

Hello everyone! I have a STM32H750VBT6 controller with external W25Q128 QSPI memory.

The bootloader starts from address 0x080000000, initializes the flash in memory mapping mode and starts the main program from 0x900000000.

There was a need to update the data in the external memory. Since the update must be done via Ethernet, this amount of code will not fit in the 128k flash. Question: is it possible to put the code that directly clears the memory and writes, for example, in the address 0x080100000 and use it there.

How to properly disable execution from SPI for the duration of work from the address 0x080100000, and then return to the same place from where the jump function was called.

Or will this not work?

Ext Flash RW.png

    This topic has been closed for replies.

    3 replies

    Graduate II
    September 6, 2024

    The memory mapping operation (XIP) can't operate concurrently with the slower "erase, wait, write, wait" operations.

    You need to QSPI Abort to break it back into command mode, and not call functions, interrupts, etc that dwell in the QSPI memory space. When done push in the memory mapped command template again.

    Alex777Author
    Visitor II
    September 6, 2024

    How can I interrupt the operation of spi if code is being executed from it? I tried calling SPI de-initialization and then calling the function at 0x0801XXXXX. After entering the function, the following command results in a HardFault.

    Graduate II
    September 6, 2024

    You'd need all the code, call-trees, interrupts to be in RAM or Internal Flash whilst you're interacting with the QSPI content.

    Super User
    September 7, 2024

    Since the update must be done via Ethernet, this amount of code will not fit in the 128k flash.

    128K is quite much. If the ethernet stuff is done properly & sparingly, it may very well fit in the 128K.

    The code to initialize QSPI flash is already there, adding some code to move the app image can fit too.

    H750 has a large internal RAM (at least 512K) that can be used for the ethernet and update code as well.

    In this 16Mbytes flash chip, do you have space to store the new image?

    Super User
    September 9, 2024

    Yes, should be possible. To prevent touching the flash area while it is erased, use MPU. But RAM occupied - this is a problem. Whenever you say "HardFault" be sure to investigate and find the actual reason (google...) then we can think of a solution.