0

In STM32F7, The code is running from the internal flash (default), we can read/write data from/to internal flash.

My problem is: I want to use external QSPI flash for my code execution (Memory mapped mode). Also during this mode, I would like to use the same QSPI flash for my data storage (ie. saving some settings) while code is executing in QSPI flash. But this is not possible since ST states that in its reference document (AN4760):

    In Memory-mapped mode the QUADSPI allows the access to the external 
memory for read operation through the memory mapped address region 
(from 0x9000 0000 to 0x9FFF FFFF) and allows the external memory to 
be seen just like an internal memory.

Is there any solution to my problem (write data to QSPI flash) without exiting from memory mapped mode?

Is it possible to partition QSPI flash into two parts? One is used for memory mapped mode and the other used as just read/write data into it.

Note: I don't want to jump from external flash to internal flash for write data, then jump to external flash again for executing the code.

Any help would be appreciated.

Thanks.

Fredrick Gauss
  • 5,126
  • 1
  • 28
  • 44
  • I had the same question once. As far as I know, it is not possible. However what is the issue to jump to another memory (RAM for example) to execute the programming sequence ? It is not very complicated to implement and rather efficient. – Guillaume Petitjean Aug 21 '20 at 12:41
  • @GuillaumePetitjean, do you mean an external SDRAM? – Fredrick Gauss Aug 22 '20 at 08:45
  • No, internal RAM. it is a common practice to locate some functions in RAM (for example to speed up the computation, or deal with Flash programming issues). – Guillaume Petitjean Aug 25 '20 at 06:38

4 Answers4

1

No it is not possible. FLASH memory, if was written before, has to be erased, then you need to enter the wirte mode and write the memory. FLASH memory is always slow to write.

The memory mapped mode is usually used to run the code from the QSPI flash, or to simplify the the read access.

0___________
  • 60,014
  • 4
  • 34
  • 74
0

I know this is an older post but for future reference:

You need to stop executing out of external flash to write to it. Maybe by copying a small code block to RAM or executing from internal flash. Then jump to executing that code. That code could disable the external flash from memory mapped mode, write your data to it and then switch it back to memory mapped mode. Obviously during this time you would need to disable any relevant interrupts and make sure there was no accesses to memory mapped flash. Also take special care not to erase and overwrite your code in external flash, unless you want to of course!

This is a similar process to writing to internal flash when you cannot execute from it while writing to it.

Ashley Duncan
  • 825
  • 1
  • 8
  • 22
  • Thanks for replying. But your last sentence made me think that you are pointing the situation is similar for internal and external. Although situation here completely different. – Fredrick Gauss Jun 14 '21 at 06:59
  • What I meant is you can use a similar process to update any flash you cannot execute from and write to at the same time. Relocate your flashing code into another block of executable memory be it ram or flash, then write to your target flash while executing from that block. – Ashley Duncan Jun 15 '21 at 07:23
  • I think you have a misunderstanding or oversight a point: When code is running in internal flash in one block let say A, you can modify another internal flash block let say B. This is not a case in the external flash. I mean, when code is running in external flash block let say X, you cannot modify another external flash block, let say Y without exiting memory mapped mode for the external flash completely. – Fredrick Gauss Jun 15 '21 at 11:51
  • That is not often the case. Only some micros allow writing to a different flash block while reading another. And any that do usually stall the cpu flash access while writing. Dual flash bank devices can read and write simultaneously. My point the whole time is that you need to stop executing out of your external flash while you write to it. Execute from somewhere else while writing to external flash. – Ashley Duncan Jun 16 '21 at 19:08
0

This is the reference manual.

Refer page no : 1064 In memory mapped mode - you have to abort/disable octo spi to write data.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 28 '23 at 04:56
-1

You can write to flash by writing to the quadspi registers. See qspi_write_cmd_addr_data() in https://github.com/micropython/micropython/blob/master/ports/stm32/qspi.c