Download FreeRTOS
 

Quality RTOS & Embedded Software

KERNEL
WHAT'S NEW
Simplifying Authenticated Cloud Connectivity for Any Device.
Designing an energy efficient and cloud-connected IoT solution with CoAP.
Introducing FreeRTOS Kernel version 11.0.0:
FreeRTOS Roadmap and Code Contribution process.
OPC-UA over TSN with FreeRTOS.

Upgrading From FreeRTOS V10.5.1 to V10.6.0

FreeRTOS V10.6.0 is a drop-in replacement for FreeRTOS V10.5.1 for all ports other than the ports with Memory Protection Unit (MPU) support. Follow the instructions below to upgrade an application using FreeRTOS MPU support from FreeRTOS V10.5.1 to V10.6.0.

Porting an Existing Application

FreeRTOS V10.6.0 introduces a new MPU wrapper. If you have an application which uses FreeRTOS MPU support, you have the following 2 options-

  1. Update to the new enhanced MPU wrapper [Recommended]
  2. Continue using the old MPU wrapper

1. Update to the new enhanced MPU wrapper [Recommended]

  1. Compile the following additional files in your project –
    1. portable/Common/mpu_wrappers_v2.c.
    2. mpu_wrappers_v2_asm.c or mpu_wrappers_v2_asm.S file in your portable/[Compiler]/[Architecture] directory.
  2. Define configUSE_MPU_WRAPPERS_V1 to 0 in your FreeRTOSConfig.h file or leave it undefined.
  3. Define configPROTECTED_KERNEL_OBJECT_POOL_SIZE to the total number of kernel objects (tasks, queues, semaphores, mutexes, timers, event groups, message buffers and stream buffers) in your application. The application will not be able to have more than configPROTECTED_KERNEL_OBJECT_POOL_SIZE kernel objects at any point of time.
  4. Define configSYSTEM_CALL_STACK_SIZE to the size of the system call stack in words. Each task has a statically allocated memory buffer of this size which is used as stack to execute system calls. For example, if configSYSTEM_CALL_STACK_SIZE is defined to 128 and there are 10 tasks in the application, the total amount of memory used for system call stacks is 128 * 10 = 1280 words.

2. Continue using the old MPU wrapper

  1. Define configUSE_MPU_WRAPPERS_V1 to 1 in your FreeRTOSConfig.h file.

Troubleshooting

  • I'm using the enhanced MPU wrapper and running out of memory.
    • You can try to tune the system call stack size using configSYSTEM_CALL_STACK_SIZE.
    • You can also try to reduce each task's stack size as the task context is no longer saved on the task stack.
  • I'm using the old MPU wrapper and running out of memory.
    • You can try to reduce each task's stack size as the task context is no longer saved on the task stack.
  • I'm getting a memory protection fault because the application uses a system call which is no longer available in the enhanced MPU wrapper. (See Changes in FreeRTOS version 10.6.0 on the Memory Protection Unit (MPU) Support page.)
    • Most of the removed system calls are for creation and deletion of the kernel objects. You can consider creating all the kernel objects before starting the scheduler and never deleting them.
    • If that's not possible, you can consider making the tasks involved in kernel object creation and deletion privileged.
    • If that doesn't work either, you can switch back to the old MPU wrapper by following the instructions under "2. Continue using the old MPU wrapper" above.
  • If you created a kernel object using the static creation API and used the static buffer's address as the object handle instead of the value returned from the API, it will no longer work. Example:

    #define QUEUE_LENGTH 10
    #define ITEM_SIZE sizeof( uint32_t )

    StaticQueue_t xQueueBuffer;
    uint8_t ucQueueStorage[ QUEUE_LENGTH * ITEM_SIZE ];

    xQueueCreate( QUEUE_LENGTH,
    ITEM_SIZE,
    &( ucQueueStorage[ 0 ] ),
    &xQueueBuffer );

    uint32_t valueToSend = 10;
    /* It is incorrect to use &xQueueBuffer as the queue handle. */
    xQueueSend( &xQueueBuffer, &( valueToSend ), pdMS_TO_TICKS( 10 ) );

    The correct way to do the above is –


    #define QUEUE_LENGTH 10
    #define ITEM_SIZE sizeof( uint32_t )

    StaticQueue_t xQueueBuffer;
    uint8_t ucQueueStorage[ QUEUE_LENGTH * ITEM_SIZE ];
    QueueHandle_t xQueueHandle;

    xQueueHandle = xQueueCreate( QUEUE_LENGTH,
    ITEM_SIZE,
    &( ucQueueStorage[ 0 ] ),
    &xQueueBuffer );

    uint32_t valueToSend = 10;
    /* Use the value returned from xQueueSend as the queue handle. */
    xQueueSend( xQueueHandle, &( valueToSend ), pdMS_TO_TICKS( 10 ) );
  • Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.