zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.86k stars 6.62k forks source link

custom mpu regions for imxrt #70920

Closed GrixaYrev closed 5 days ago

GrixaYrev commented 7 months ago

File zephyr\soc\nxp\imxrt\mpu_regions.c is included to sources unconditionally. So i can't use SRAM size more than 16M and less than 32M, because error in zephyr\include\zephyr\arch\arm\cortex_m\arm_mpu_mem_cfg.h:72 is rised: "Unsupported sram size configuration".

I think additional Kconfig option need for exclude zephyr\soc\nxp\imxrt\mpu_regions.c from sources.

I use custom board based on iMX.RT1052 with external SDRAM. Part SDRAM used as FLASH (for bootloader and application), other space as RAM.

Version of Zephyr – 3.6.99 (SHA 0714052c74bfe4e74ae6fca705da4d7d66c92681)

prj.conf:

CONFIG_FLASH_SIZE=11264 
CONFIG_FLASH_BASE_ADDRESS=0x80100000
CONFIG_SRAM_SIZE=20480
CONFIG_SRAM_BASE_ADDRESS=0x80C00000
GrixaYrev commented 7 months ago

I suggest to add configuration option NXP_IMX_RT_USER_MPU_REGIONS to zephyr\soc\nxp\imxrt\Kconfig. I can prepare PR.

GrixaYrev commented 7 months ago

@teburd, @dleach02, what do you think about my suggestion?

dleach02 commented 5 months ago

@GrixaYrev, isn't the board level device tree entry for SDRAM with CONFIG_NXP_IMX_EXTERNAL_SDRAM supposed to handle this?

GrixaYrev commented 4 months ago

@dleach02, no, first two items of mpu_regions[] is included unconditional (file zephyr\soc\nxp\imxrt\mpu_regions.c):

    /* Region 0 */
    MPU_REGION_ENTRY("FLASH_0",
             CONFIG_FLASH_BASE_ADDRESS,
             REGION_FLASH_ATTR(REGION_FLASH_SIZE)),
    /* Region 1 */
    MPU_REGION_ENTRY("SRAM_0",
             CONFIG_SRAM_BASE_ADDRESS,
             REGION_RAM_ATTR(REGION_SRAM_SIZE)),

If i set CONFIG_FLASH_SIZE=11264 and CONFIG_SRAM_SIZE=20480 i have error message "Unsupported sram size configuration".

dleach02 commented 4 months ago

Please prepare a PR so I can route it appropriately for internal review.