This MPU Configurator generates C-Code to program the PMSAv7 Memory Protection Unit of Cortex-M0+, M3, M4 and M7 devices or the Secure and Non-Secure PMSAv8 Memory Protection Unit of Cortex-M23, M33, M52, M55 and M85. The generator is based on simple Excel functions and does not rely upon any macros or Active-X elements. The generated code is ouput of an Excel sheet and can easily be copied into your project by any editor of your joice. To configure the MPU you just need to include the copy-and-pasted include file and to call the generated inline function MPU_Init() from your project. Up to 16 Regions may be configured, but in the MPU_Init() function code is only executed for implemented regions to avoid unexpected mail function of the MPU.
The download is provided free of charge.
Please also refere to the copyright and liability warning in the header of the gernerated code.
PMSAv7: In the graphical MPU Configuration Sheet some additional hints are provided for convenience to ease the address calculation:
- The Region Base addresses are automatically aligned to their size. The colour of the input Start Address digits change to red in case of non proper alignment.
- The Region Limit Adress is calculated and displayed by adding the choosen size to the aligned Start Address.
- If a region is bigger or equal to 256 bytes and any subregion is disabled the start and limit addresses of the remaining enabled subreaginons are calculated and displayed.
PMSAv8: There are two independent Input Sheets provided
- CONFIG to configure the SECURE MPU and
- CONFIG_NS to configure the NON-SECURE MPU.
- For Controllers without Trust Zone. the NON-SECURE MPU can be ignored.
- The Attribution Indirection Registers may be provided with an optional name e.g. Flash or Int SRAM which are displayed in the pulldown menues of the MPU Regions to ease the selction of the proper attributions.
- The Region Base addresses are automatically aligned to 32 bytes. The colour of the input Start Address digits change to red in case of non proper alignment.
For both Excel file Variants two different types of ouput code is generated :
- Sheet CODE_KEIL: C-code including comments for the µVision/Keil editor, that allows a simple graphical editing in the project
- Sheet CODE: C-code without these comments for any other development environment
Example Output armv7m_mpu_config_keil.h
Example Output armv7m_mpu_config.h
Example Output armv8m_mpu_config_keil.h
Example Output armv8m_mpu_config.h
MPU Info
is a small C-module that prints out the current MPU configuration. Since many debuggers cannot display the current MPU configuration this small tool provided as a .c and .h file might help. Like the configurator, there are two versions available, one fpr armv7-M and one for armv8-M which will printout the secure and the non-dsecure MPU configuration in case Trust-Zone is available.
Please find here an Example main.c file to show case how to apply the tool:
#include "board.h" //depends on your environment
#include "armv7m_mpu_config.h" //resp. "armv8m_mpu_config.h"
#include "armv7m_mpu_info.h" //resp. "armv8m_mpu_info.h"
int main(void)
{
//
// initialize board
//
// check working printout
const char* str="Hello World :-)\r\n";
while(*str != '\0')
putchar(*str++);
MPU_Init();
MPU_Info();
// loop forever
while( 1)
{
}
}
Armv7-M Header File armv7m_mpu_info.h
Armv7-M C-Source armv7m_mpu_info.c
Armv8-M Header File armv8m_mpu_info.h
Armv8-M C-Source armv8m_mpu_info.c
Please leave a note for any comment, proposals or requests.
- Potential future extensions are planned for Task specific MPU Configurations for dynamic MPU switching during scheduling of Real Time Operating Systems
