Other Parts Discussed in Thread: SYSBIOS
I'm aware of the r5_mpu.xs file used to configure the MPU and needed to be included in the sysbios.cfg in case of TI RTOS.
How can I do the same in FreeRTOS, is there a similar XDC based configuration file?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
In case of both baremetal & FreeRTOS applications MPU/Cache Settings for various memory regions are configured via CSL API’s during the C/C++ startup routine (_c_int00())
The global structure gCslR5MpuCfg can be modified to program the MPU as a part of the __mpu_init() function. This structure can be found in the below file.
pdk/packages/ti/csl/arch/r5/src/startup/startup.c
This is weak linked and hence declaring this in your application will override the startup.c configuration in the CSL.
extern const CSL_ArmR5MpuRegionCfg __attribute__((section(".startupData"))) __attribute__((weak)) gCslR5MpuCfg[CSL_ARM_R5F_MPU_REGIONS_MAX] = { { /* Region 0 configuration: complete 32 bit address space = 4Gbits */ .regionId = 0U, .enable = 1U, .baseAddr = 0x0U, .size = CSL_ARM_R5_MPU_REGION_SIZE_4GB, .subRegionEnable = CSL_ARM_R5_MPU_SUB_REGION_ENABLE_ALL, .exeNeverControl = 1U, .accessPermission = CSL_ARM_R5_ACC_PERM_PRIV_USR_RD_WR, .shareable = 0U, .cacheable = (uint32_t)FALSE, .cachePolicy = 0U, .memAttr = 0U, }, { /* Region 1 configuration: 128 bytes memory for exception vector execution */ .regionId = 1U, .enable = 1U, .baseAddr = 0x0U, .size = CSL_ARM_R5_MPU_REGION_SIZE_128B, .subRegionEnable = CSL_ARM_R5_MPU_SUB_REGION_ENABLE_ALL, .exeNeverControl = 0U, .accessPermission = CSL_ARM_R5_ACC_PERM_PRIV_USR_RD_WR, .shareable = 0U, .cacheable = (uint32_t)TRUE, .cachePolicy = CSL_ARM_R5_CACHE_POLICY_WB_WA, .memAttr = 0U, }, { /* Region 2 configuration: 1MB KB MCU MSRAM */ .regionId = 2U, .enable = 1U, .baseAddr = 0x41C00000, .size = CSL_ARM_R5_MPU_REGION_SIZE_512KB, #if defined (SOC_J721E) || defined (SOC_J7200) || defined (SOC_J721S2) || defined (SOC_AM62X) .size = CSL_ARM_R5_MPU_REGION_SIZE_1MB, #endif .subRegionEnable = CSL_ARM_R5_MPU_SUB_REGION_ENABLE_ALL, .exeNeverControl = 0U, .accessPermission = CSL_ARM_R5_ACC_PERM_PRIV_USR_RD_WR, .shareable = 0U, .cacheable = (uint32_t)TRUE, .cachePolicy = CSL_ARM_R5_CACHE_POLICY_WB_WA, .memAttr = 0U, }, { /* Region 3 configuration: 2 MB MCMS3 RAM */ .regionId = 3U, .enable = 1U, .baseAddr = 0x70000000, .size = CSL_ARM_R5_MPU_REGION_SIZE_2MB, #if defined (SOC_J721E) .size = CSL_ARM_R5_MPU_REGION_SIZE_8MB, #endif #if defined (SOC_J7200) .size = CSL_ARM_R5_MPU_REGION_SIZE_1MB, #endif #if defined (SOC_J721S2) .size = CSL_ARM_R5_MPU_REGION_SIZE_4MB, #endif #if defined (SOC_AM62X) .size = CSL_ARM_R5_MPU_REGION_SIZE_64KB, #endif .subRegionEnable = CSL_ARM_R5_MPU_SUB_REGION_ENABLE_ALL, .exeNeverControl = 0U, .accessPermission = CSL_ARM_R5_ACC_PERM_PRIV_USR_RD_WR, .shareable = 0U, .cacheable = (uint32_t)TRUE, .cachePolicy = CSL_ARM_R5_CACHE_POLICY_WB_WA, .memAttr = 0U, }, { /* Region 4 configuration: 2 GB DDR RAM */ .regionId = 4U, .enable = 1U, .baseAddr = 0x80000000, .size = CSL_ARM_R5_MPU_REGION_SIZE_2GB, .subRegionEnable = CSL_ARM_R5_MPU_SUB_REGION_ENABLE_ALL, .exeNeverControl = 0U, .accessPermission = CSL_ARM_R5_ACC_PERM_PRIV_USR_RD_WR, .shareable = 0U, .cacheable = (uint32_t)TRUE, .cachePolicy = CSL_ARM_R5_CACHE_POLICY_WB_WA, .memAttr = 0U, }, { /* Region 5 configuration: 32 KB BTCM */ /* Address of ATCM/BTCM are configured via MCU_SEC_MMR registers It can either be '0x0' or '0x41010000'. Application/Boot-loader shall take care this configurations and linker command file shall be in sync with this. For either of the above configurations, MPU configurations will not changes as both regions will have same set of permissions in almost all scenarios. Application can chose to overwrite this MPU configuration if needed. The same is true for the region corresponding to ATCM. */ .regionId = 5U, .enable = 1U, .baseAddr = 0x41010000, .size = CSL_ARM_R5_MPU_REGION_SIZE_32KB, .subRegionEnable = CSL_ARM_R5_MPU_SUB_REGION_ENABLE_ALL, .exeNeverControl = 0U, .accessPermission = CSL_ARM_R5_ACC_PERM_PRIV_USR_RD_WR, .shareable = 0U, .cacheable = (uint32_t)TRUE, .cachePolicy = CSL_ARM_R5_CACHE_POLICY_NON_CACHEABLE, .memAttr = 0U, }, { /* Region 7 configuration: 32 KB ATCM */ .regionId = 6U, .enable = 1U, .baseAddr = 0x0, .size = CSL_ARM_R5_MPU_REGION_SIZE_32KB, .subRegionEnable = CSL_ARM_R5_MPU_SUB_REGION_ENABLE_ALL, .exeNeverControl = 0U, .accessPermission = CSL_ARM_R5_ACC_PERM_PRIV_USR_RD_WR, .shareable = 0U, .cacheable = (uint32_t)TRUE, .cachePolicy = CSL_ARM_R5_CACHE_POLICY_NON_CACHEABLE, .memAttr = 0U, }, };
There are applications which define this structure locally, such as pdk/packages/ti/drv/ipc/examples/common/src/r5f_mpu_j721e_default.c
Regards
Karan