Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training


Extending number of MPU regions

Posted by hdtx on February 21, 2017

I'm using GCC on a Cortex-M4F (LPC43xx family).

I need more than the 3 configurable MPU regions for this port. I decided to do away with the privileged flash area because I don't need it (privileged background map is enabled and my unprivileged flash area does not reach there, so privileged accesses are enabled by default and unprivleged accesses are blocked).

What I did:

  • added the fourth area to all my task parameters (all tasks are created using xTaskCreateRestricted);
  • took out the lines setting portMPUREGIONBASEADDRESSREG and portMPUREGIONATTRIBUTE_REG for the privileged flash area in prvSetupMPU (mpu/port.c);
  • changed a few lines at the start of mpu/portmacro.h from ~~~ #define portUNPRIVILEGEDFLASHREGION ( 0UL ) #define portPRIVILEGEDFLASHREGION ( 1UL ) #define portPRIVILEGEDRAMREGION ( 2UL ) #define portGENERALPERIPHERALSREGION ( 3UL ) #define portSTACKREGION ( 4UL ) #define portFIRSTCONFIGURABLEREGION ( 5UL ) #define portLASTCONFIGURABLEREGION ( 7UL ) ~~~ to ~~~ #define portUNPRIVILEGEDFLASHREGION ( 0UL ) #define portPRIVILEGEDRAMREGION ( 1UL ) #define portGENERALPERIPHERALSREGION ( 2UL ) #define portSTACKREGION ( 3UL ) #define portFIRSTCONFIGURABLEREGION ( 4UL ) #define portLASTCONFIGURABLEREGION ( 7UL ) ~~~

What did not work: the fourth area is never set (whatever region I put there does not get activated).

I checked portNUMCONFIGURABLEREGIONS, it's obviously 4 instead of 3 now. I looked at the FreeRTOS code and the fourth region should be working, I have no idea why it's not. I appreciate any help.

Extending number of MPU regions

Posted by hdtx on February 21, 2017

Never mind, I found it... xPortPendSVHandler in mpu/port.c only swaps in 4 regions at most (including the stack region), so I added a few lines that fixed it. If anyone has the same problem, delete line 495 and add this in its place (assuming you defined the appropriate symbol): ~~~

	"	stmia r2!, {r4-r11}					\n" // original line
	"	stmia r2, {r4-r11}					\n" // don't update r2
	"	ldmia r1!, {r4-r5}					\n" // load 1 set of MPU regs
	"	stmia r2, {r4-r5}					\n" // write 1 set of MPU regs


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists