FreeRTOS-Kernel/portable/GCC
Gaurav-Aggarwal-AWS 334de5d8ab
Enable ARMv7-M MPU ports to place FreeRTOS kernel code outside of flash (#46)
Problem Description
-------------------
The current flash organization in ARMv7-M MPU ports looks as follows:

__FLASH_segment_start__ ------->+-----------+<----- __FLASH_segment_start__
                                |  Vector   |
                                |   Table   |
                                |     +     |
                                |   Kernel  |
                                |    Code   |
                                +-----------+<-----  __privileged_functions_end__
                                |           |
                                |           |
                                |           |
                                |   Other   |
                                |   Code    |
                                |           |
                                |           |
                                |           |
   __FLASH_segment_end__ ------>+-----------+

The FreeRTOS kernel sets up the following MPU regions:

* Unprivileged Code - __FLASH_segment_start__ to __FLASH_segment_end__.
* Privileged Code - __FLASH_segment_start__ to __privileged_functions_end__.

The above setup assumes that the FreeRTOS kernel code
(i.e. privileged_functions) is placed at the beginning of the flash and,
therefore, uses __FLASH_segment_start__ as the starting location of the
privileged code. This prevents a user from placing the FreeRTOS kernel
code outside of flash (say to an external RAM) and still have vector
table at the beginning of flash (which is many times a hardware
requirement).

Solution
--------
This commit addresses the above limitation by using a new variable
__privileged_functions_start__ as the starting location of the
privileged code. This enables users to place the FreeRTOS kernel code
wherever they choose.

The FreeRTOS kernel now sets up the following MPU regions:

* Unprivileged Code - __FLASH_segment_start__ to __FLASH_segment_end__.
* Privileged Code - __privileged_functions_start__ to __privileged_functions_end__.

As a result, a user can now place the kernel code to an external RAM. A
possible organization is:

                                 Flash              External RAM
                              +------------+        +-----------+<------ __privileged_functions_start__
                              |   Vector   |        |           |
                              |   Table    |        |           |
                              |            |        |           |
__FLASH_segment_start__ ----->+------------+        |   Kernel  |
                              |            |        |    Code   |
                              |            |        |           |
                              |            |        |           |
                              |            |        |           |
                              |   Other    |        |           |
                              |    Code    |        +-----------+<------ __privileged_functions_end__
                              |            |
                              |            |
                              |            |
  __FLASH_segment_end__ ----->+------------+

Note that the above configuration places the vector table in an unmapped
region. This is okay because we enable the background region, and so the
vector table will still be accessible to the privileged code and not
accessible to the unprivileged code (vector table is only needed by the
privileged code).

Backward Compatibility
----------------------
The FreeRTOS kernel code now uses a new variable, namely
__privileged_functions_start__, which needs to be exported from linker
script to indicate the starting location of the privileged code. All of
our existing demos already export this variable and therefore, they will
continue to work.

If a user has created a project which does not export this variable,
they will get a linker error for unresolved symbol
__privileged_functions_start__. They need to export a variable
__privileged_functions_start__ with the value equal to
__FLASH_segment_start__.

Issue
-----
https://sourceforge.net/p/freertos/feature-requests/56/

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
2020-04-06 15:51:40 -07:00
..
ARM7_AT91FR40008 version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
ARM7_AT91SAM7S version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
ARM7_LPC23xx version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
ARM7_LPC2000 version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
ARM_CA9 Cortex-A9 port: Adding stack alignment directive to assembly code 2020-03-13 12:19:31 -07:00
ARM_CA53_64_BIT version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
ARM_CM0 version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
ARM_CM3 version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
ARM_CM3_MPU Enable ARMv7-M MPU ports to place FreeRTOS kernel code outside of flash (#46) 2020-04-06 15:51:40 -07:00
ARM_CM4_MPU Enable ARMv7-M MPU ports to place FreeRTOS kernel code outside of flash (#46) 2020-04-06 15:51:40 -07:00
ARM_CM4F version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
ARM_CM7 version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
ARM_CM23 Add "Tickless Idle" support for ARMv8M ports (#29) 2020-03-16 10:50:49 -07:00
ARM_CM23_NTZ/non_secure Add "Tickless Idle" support for ARMv8M ports (#29) 2020-03-16 10:50:49 -07:00
ARM_CM33 Add "Tickless Idle" support for ARMv8M ports (#29) 2020-03-16 10:50:49 -07:00
ARM_CM33_NTZ/non_secure Add "Tickless Idle" support for ARMv8M ports (#29) 2020-03-16 10:50:49 -07:00
ARM_CR5 version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
ARM_CRx_No_GIC version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
ATMega323 version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
AVR32_UC3 version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
ColdFire_V2 version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
CORTUS_APS3 version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
H8S2329 version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
HCS12 version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
IA32_flat version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
MCF5235 Re-sync with upstream and stripping away none kernel related. 2020-02-10 13:45:57 -08:00
MicroBlaze version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
MicroBlazeV8 version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
MicroBlazeV9 version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
MSP430F449 version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
NiosII version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
PPC405_Xilinx version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
PPC440_Xilinx version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
RISC-V version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
RL78 version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
RX100 version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
RX600 version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
RX600v2 version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
STR75x version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00
TriCore_1782 version bump to v10.3.1 (#16) 2020-02-18 22:03:54 -08:00