-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
soc: nxp: imxrt: user defined mpu regions #75604
base: main
Are you sure you want to change the base?
soc: nxp: imxrt: user defined mpu regions #75604
Conversation
Option NXP_IMX_RT_USER_MPU_REGIONS exclude soc file mpu_regions.c and allow user define custom mpu_regions in custom file. Fixes zephyrproject-rtos#70920 Signed-off-by: Grixa Yrev <[email protected]>
9bc48a9
to
95f41e6
Compare
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.
While I understand the goal here, I'm not sure I agree with the approach. What prevents you from defining the MPU regions you need using the zephyr,memory-region
compatible and zephyr,memory-attr
property?
Is there a specific MPU region the IMX RT MPU regions file defines that you need removed?
@danieldegrasse, main trouble is checking of |
Ok- thank you for clarifying. Looking at that issue, I guess you would like to use an SRAM size that is not a multiple supported by the ARM MPU? Perhaps we could solve this by rounding the MPU region size up to the nearest supported size? Or would this not work for your use case? |
@danieldegrasse, rounding could solve main trouble probably, but MPU will not work correctly in this case, because start address should be rounded to region size, if i am not wrong. Now i use no MPU regions (all SDRAM configured as executable, readable and writeable RAM), but i want to use it in future. So i want to find flexible solution for my issue. |
So I think what I am unclear about is how removing the MPU definition file would solve your issue here. Either you don't use the MPU, or you enable the MPU and now you have some restrictions on the size/alignment of your SRAM region. Maybe it would help if you could provide an outline of a case where replacing the MPU file would allow you to accomplish something you currently cannot? |
@danieldegrasse, I want to set follow memory layout in prj.conf:
I have error "Unsupported sram size configuration" when i set CONFIG_SRAM_SIZE more than 16M and less than 32M. I have this error, even i switch off MPU:
This error is described in It is not MPU trouble, it is code trouble, |
Ok, thank you for this example, the issue is easier to follow now. So it seems like we just need to stop compiling the MPU regions file if diff --git a/soc/nxp/imxrt/CMakeLists.txt b/soc/nxp/imxrt/CMakeLists.txt
index ecdb894bfe3..09e90e87fa5 100644
--- a/soc/nxp/imxrt/CMakeLists.txt
+++ b/soc/nxp/imxrt/CMakeLists.txt
@@ -16,7 +16,7 @@ if(CONFIG_SOC_SERIES_IMXRT10XX OR CONFIG_SOC_SERIES_IMXRT11XX)
if(CONFIG_EXTERNAL_MEM_CONFIG_DATA)
set(boot_hdr_xmcd_data_section ".boot_hdr.xmcd_data")
endif()
- zephyr_sources(mpu_regions.c)
+ zephyr_sources_ifdef(CONFIG_ARM_MPU mpu_regions.c)
zephyr_linker_section_configure(
SECTION .rom_start
INPUT ".boot_hdr.conf" |
I think i should add this change to commit, but it is restricted solution. I want to use MPU in future, and i will have this error again. So I suggest to join your change and my change. |
I'm still unclear about the use case for the MPU on your side. Do you plan to only protect part of the region you use as SRAM? The reason I am hesitant to add a Kconfig to exclude the MPU file is because this MPU file effectively mirrors the one used for most ARM cores, plus an additional region. If you want to use an MPU in Zephyr on an ARMv7 platform, you will need SRAM regions aligned to the appropriate size boundaries. By adding a Kconfig to specifically exclude this for the iMX.RT series, it becomes possible to define MPU regions that don't fit the alignment requirements Zephyr MPU support is designed around on ARMv7. Is there a part of the Zephyr MPU support you are looking to use? If not, it truthfully seems to me like configuring the MPU directly and bypassing Zephyr is more logical. |
I plan to use usermode. But i don't have enough experience in it. May be you are right and it is unavailable with this memory layout. |
Option NXP_IMX_RT_USER_MPU_REGIONS exclude soc file mpu_regions.c and allow user define custom mpu_regions in custom file. Fixes #70920
For test this PR i use: