-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
stm32 OSPI flash driver enables XiP on external NOR flash #68597
Conversation
Running the sample to relocate code on the external NOR flash of the b_u585i_iot02a disco kit (also valid with stm32h7b3i_dk) :
|
a35b370
to
fc1761d
Compare
@FRASTM started to experience application freezing when it was started by the bootloader (BL). The H7 application freezes in the A solution is to set Everything worked fine before the introduction of Did you experience something like that on H7 while working on the XIP support? Note: what is interesting is that it works with |
Yes, I had some pb with the stm32h7 cache, on my side, for that, I changed the memory-attribute of the ext memory section diff --git a/dts/arm/st/h7/stm32h7.dtsi b/dts/arm/st/h7/stm32h7.dtsi
index 64ccfbf724..2351eb0e49 100644
--- a/dts/arm/st/h7/stm32h7.dtsi
+++ b/dts/arm/st/h7/stm32h7.dtsi
@@ -45,11 +45,12 @@
};
};
- quadspi_memory: memory@90000000 {
- compatible = "zephyr,memory-region", "mmio-sram";
- reg = <0x90000000 DT_SIZE_M(256)>;
- zephyr,memory-region = "QSPI";
- zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_EXTMEM) )>;
+ ext_memory: memory@90000000 {
+ compatible = "zephyr,memory-region";
+ reg = <0x90000000 DT_SIZE_M(64)>; /* 512 Mbits */
+ zephyr,memory-region = "EXTMEM";
+ /* The ATTR_MPU_EXTMEM attribut causing a MPU FAULT */
+ zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_IO) )>;
};
clocks { |
The issue in my case is not related to MPU. It can easily be observed with any region attribute. When
Eventually, when Bl jumps to the application and Zephyr calls @benediktibk shouldn't zephyr/arch/arm/core/cortex_m/scb.c Lines 116 to 146 in aef6588
be skipped if we are "chain loading"/booting Zephyr from a bootloader that enables d/i-caches? Just found ARM-software/CMSIS_5#620 and that is exactly what seems to happen. |
I don't think so, because the whole idea behind z_arm_init_arch_hw_at_boot is to get the system after after a bootloader into the same state as it is after a full reset. Starting from this then the caches are activated if they are enabled in the config of the actual application. The big question for me is why SCB_DisableDCache seems to get stuck, because it should be safe to call it at this point? From the documentation it is not completely clear if it is required to call SCB_CleanDCache beforehand, but it might be worth a try? |
@benediktibk the issues seems to come from ARM-software/CMSIS_5#620. Created #69789. |
ce5ed69
to
7556db5
Compare
rebase on db1a4a6 For flashing (west flash) the stm32h7b3i_dk disco kit, the #68377 is required, with boards/st/stm32h7b3i_dk/board.cmake configured to flash the external memory, with the external loader of the STM32CubeProgrammer, as runner.
Write and Erase operations are aborting the memorymap mode before executing in command mode. This is demonstrated with the samples/drivers/spi_flash executed on the b_u5885i_iot02a board when |
|
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.
Otherwise LGTM
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]>
Declare a sub-region of the whole ext_memory with attributes ATTR_MPU_IO so that XiP becomes possible on this external octo- NOR flash. Use the STM32CubeProgrammer runner with the external loader for flashing. Signed-off-by: Francois Ramu <[email protected]>
Declare a sub-region of the whole ext_memory with attributes ATTR_MPU_IO so that XiP becomes possible on this external octo- NOR flash. Use the STM32CubeProgrammer runner with the external loader for flashing. Signed-off-by: Francois Ramu <[email protected]>
Define the configuration to run the code_relocation application on the external memory octo flash of the stm32u585 or stm32h7b3i disco kit in XIP Signed-off-by: Francois Ramu <[email protected]>
fixing CI error |
@de-nordic Ready for you review |
With this PR the stm32u5 and stm32h7 target board with octo-NOR flash can configure this external flash to eXecute In Place
a sample code application stored on this external memory.
The ospi flash driver is configuring the external NOR in MemoryMapped mode at init so that code is XiP at the external NOR flash address.
This is demonstrated by the samples/application_development/code_relocation_nocopy/ running on the stm32u585 or stm32h7b3 disco kits.
For stm32h7 serie, this PR requires the #68593
and include a sub-region of the EXTMEM where code is executed in XiP where
zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_IO) )>;
For stm32u5 serie this PR requires the #68590
Requires the PR #68377 to flash correclty the code to the external flash with west command.
This PR is replacing the #61082