-
Notifications
You must be signed in to change notification settings - Fork 7.4k
drivers: stm32 qspi flash driver enables the MemoryMapped mode #61122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
855621a
to
8fed638
Compare
After running the samples/drivers/spi_flash, reading the quad NOR flash of the stm32h747_disco_m7 in MemoryMapped mode gives the
|
f974b15
to
d2614b1
Compare
The following west manifest projects have been modified in this Pull Request:
Note: This message is automatically posted and updated by the Manifest GitHub Action. |
7ba8369
to
ff00d31
Compare
rebase on e9dd938 |
REGION_RAM_ATTR(REGION_SRAM_SIZE)), | ||
MPU_REGION_ENTRY("QSPI", 0x90000000, | ||
REGION_EXTMEM_ATTR(REGION_256M)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the point of having it in stm32h7.dtsi
as RAM
and here as EXTMEM
?
Questioning out of curiosity.
ff00d31
to
0943bae
Compare
New version where the HAL is not changed thanks to direct access to the hqspi instance in the flash_stm32_qspi driver One common commit 8320167aecb8f74816714150099cf883df86ded0 with #61082 Add the memory region to map the external NOR flash Tested with the stm32h747i_disco_m7 disco board ; using a sample to demonstrate the read operation in memorymapped mode (no erase but writing a few bytes) : |
be66614
to
35e4044
Compare
drivers/flash/Kconfig.stm32
Outdated
@@ -70,4 +70,11 @@ config FLASH_STM32_BLOCK_REGISTERS | |||
registers improves system security, because flash content (or | |||
protection settings) can't be changed even when exploit was found. | |||
|
|||
config STM32_XIP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need some more explicit name for this option. Usual STM32 config on internal flash is XIP (CONFIG_XIP=y).
STM32_EXT_MEM_XIP, STM32_MEM_MAPPED, ...
drivers/flash/flash_stm32_qspi.c
Outdated
#ifdef CONFIG_STM32_XIP | ||
|
||
/* Function to return true if the quad-NOR flash is in MemoryMapped else false */ | ||
static bool qspi_is_memorymapped(const struct device *dev) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to HAL team, we should be able to use the HAL_GetStatus API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to HAL team, we should be able to use the HAL_GetStatus API.
Update: This won't work as HAL_GetStatus()
is based on driver internal variable (reset when switching from MCUBoot to Zephyr application), not hw setting. qspi_is_memorymapped
is indeed actually required.
Cannot read the QSPI flash correctly when the STM32CubeProgrammer gives |
ea43dbd
to
6ecb031
Compare
For the flash driver, the base address is the MCU internal flash address (usualyy 0x8000000). This PR gets the that address from the device tree node "st,stm32-nv-flash" instead of relying on the CONFIG_FLASH_BASE_ADDRESS which might differ when building for another flash memory. Signed-off-by: Francois Ramu <[email protected]>
This CONFIG_STM32_MEMMAP is for enabling the MemoryMapped mode on external octo or quad spi memory. In this case, the flash_stm32_read is done in mem map mode the flash_stm32_erase is not available. Signed-off-by: Francois Ramu <[email protected]>
Enable the MemoryMapped Mode for the stm32 octoFlash driver Configure the Flash in MemoryMapped to use in XiP mode. With this mode the erase and write are not supported. Address and size are given by the DTS register property. Signed-off-by: Francois Ramu <[email protected]>
This change is aborting the memoryMapped mode of the octo-flash before erasing or writing the NOR. Operations are performed in command mode. Reading is always performed in MemoryMapped mode (memcopy) Signed-off-by: Francois Ramu <[email protected]>
Enable the DCACHE1 in INCR burt mode to allow writing to the external NOR octoFlash when in MemoryMapped mode Signed-off-by: Francois Ramu <[email protected]>
Define the Device tree of the b_u585i_iot02a disco kit to access the external NOR octo-flash in MemoryMapped mode for XiP Signed-off-by: Francois Ramu <[email protected]>
Gives a sample to execute the little fs on external memory map (XiP) where the lfs1 partition is in internal mcu flash The application is built/linked/stored in the external NOR flash on slot1 partition. Signed-off-by: Francois Ramu <[email protected]>
Skip the PLL1 init if it is already running, this will avoid disabling the PLL when running after a jump from mcuboot Signed-off-by: Francois Ramu <[email protected]>
Define the MPU attribute to be ATTR_MPU_IO for the qspi region, starting at 0x90000000 of the stm32h7 serie. Signed-off-by: Francois Ramu <[email protected]>
Define the Device tree of the stm32h7b3i_dk disco board to access the external NOR octo-flash in MemoryMapped mode for XiP Set openocd runner for debugging. Signed-off-by: Francois Ramu <[email protected]>
Gives a sample to execute the little fs on external memory map (XiP) where the lfs1 partition is in internal mcu flash Signed-off-by: Francois Ramu <[email protected]>
Configures the external NOR Flash in MemoryMapped Mode, at the end of the NOR flash-controller initialization. Then reading/writing are performed in MemoryMapped mode with memcopy (and no more with command mode). In this mode: erasing is not supported anymore. The flash size and address are given by the DTS <reg> property. Signed-off-by: Francois Ramu <[email protected]>
25675b2
to
f2adc0b
Compare
Configure the quad-spi in DualFlash Mode when enabling the MemoryMapped then reading is possible with memcopy. Signed-off-by: Francois Ramu <[email protected]>
Define the Device tree of the stm32l496g_disco board or stm32h750b disco kit to access the external NOR quad-flash in MemoryMapped mode for XiP Signed-off-by: Francois Ramu <[email protected]>
Gives a sample to execute the little fs on external memory map (XiP) where the lfs1 partition is in internal mcu flash Signed-off-by: Francois Ramu <[email protected]>
f2adc0b
to
fc6dd45
Compare
The PR #68607 is now replacing this PR |
This PR is enabling the MemoryMapped to access the qua NOR flash at the end of the initialization.
With this configuration, the NOR flash access is done with memcopy in read or write
Note that the erase is not supported but writing is possible in MemoryMapped mode.
(It is not recommended to fill the memory with 0xFFFFFFFF)
"QSPI NOR devices are often used for read-only applications in memory mapped mode. And when the program instructions are executed directly from the flash memory, this is known as Execute in Place or XIP mode."
The drivers detects the CONFIG_STM32_MEMMAP flag to enable the MemoryMapped mode.
Requires PR #61082