Some microcontrollers like ARM Cortex-M4 has a Memory Protection Unit – MPU (not to be confused with Math Processing Unit) that can be used to create protected regions. This way an application cannot access the area where the NuttX kernel is located.
These are the steps to get the NuttX running in Protected Mode on STM32F4Discovery board:
$ ./tools/configure.sh stm32f4discovery:nsh
$ make menuconfig
Build Setup —>
Build Host Platform (Windows) —> Linux
System Type —>
[*] MPU support
Build Setup —>
Build Configuration —>
Memory organization = NuttX protected build
Build Setup —>
Build Configuration —>
Pass one build directory = boards/arm/stm32/stm32f4discovery/kernel
Build Setup —>
Build Configuration —>
Beginning of user-space blob = 0x08020000
RTOS Features —>
-*- System call support —>
Number of reserved system calls = 8
$ make
$ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -c init -c “reset halt” -c “flash write_image erase nuttx.bin 0x08000000”
$ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -c init -c “reset halt” -c “flash write_image erase nuttx_user.bin 0x08020000”