Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Renesas RZ/A1 (ARM Cortex-A9) RTOS Demo
Including FreeRTOS+CLI and FreeRTOS+FAT SL
Using ARM (DS-5) and IAR embedded compilers
[RTOS Ports]


Renesas Chips

Introduction

This page documents a FreeRTOS demo application for the Renesas RZ/A1 embedded processor, which has an ARM Cortex-A9 core. Two projects are provided, allowing the demo to be built with both the IAR Embedded Workbench and ARM DS-5 embedded development tools. The demo targets the Renesas RZA1 RSK.

The demo uses:

  • The FreeRTOS Cortex-A9 kernel port for the ARM or IAR compiler (depending on the project file used)

  • Either the IAR Embedded Workbench or ARM DS-5 IDE (depending on the project file used)

  • The FreeRTOS+CLI command line interface. [Note the FreeRTOS+CLI license is different from the FreeRTOS kernel license]

  • The FreeRTOS+FAT SL ("S"uper "L"ean) DOS compatible FAT file system. [Note the FreeRTOS+FAT SL license is different from the FreeRTOS kernel license]


IMPORTANT! Notes on using the FreeRTOS Renesas RZ/A1 demo project

Please read all the following points before using this RTOS port.

  1. Source Code Organisation
  2. The Demo Application Functionality
  3. Build Instructions (for both Embedded Workbench and DS-5)
  4. RTOS Configuration and Usage Details
Also see the FAQ My application does not run, what could be wrong?, and the page that provides instruction on using FreeRTOS on ARM Cortex-A embedded processors.

Source Code Organisation

The FreeRTOS zip file contains source code for all the RTOS ports and all the RTOS demo applications. Only a small subset of these files are required by the Renesas RZ/A1 demo. The Source Code Organization page describes the structure of the FreeRTOS zip file download, and provides information on creating a new RTOS project.

The ARM DS-5 Eclipse project file is located in the FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5 directory.

The IAR Embedded Workbench project file is located in the FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/IAR" directory.

The DS-5 and IAR projects build the same RTOS demo application, and both include files that are contained in the /FreeRTOS-Plus directory (so the projects will not build if the /FreeRTOS-Plus directory has been deleted).



The Renesas RZ/A1 ARM Cortex-A9 Demo Application

Hardware and software set up

The demo presented on this page runs on the Renesas RZA1 RSK, but can easily be adapted to run on any development board that provides access to one UART and one digital output (preferably with an LED connected).
  • UART

    A UART is used for console IO, or a serial port loopback demo (depending on the build, see below). The download uses UART 2 for this purpose. If it is necessary to use a UART other than UART 2 then:

    • Modify the UART initialisation code contained in siochar.c to instead initialise whichever UART is to be used.
    • Modify the UART interrupt configuration, interrupt handling, and character output code located in serial.c to instead manage whichever UART is to be used.

  • LED digital output

    A digital output is used to toggle an LED. The download uses bit 10 of port 4 for this purpose. If it is necessary to use a different digital output then:

    • Edit the initialisation and management of the digital output code contained in LEDs.c to instead use whichever digital output is to be used.


Functionality

The behaviour of the demo is defined by the following two constants:
  • mainCREATE_SIMPLE_BLINKY_DEMO_ONLY:

    mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is defined in main.c.

    mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is used to switch between a very basic 'blinky' demo, and a comprehensive test and demo application.

  • mainINCLUDE_FAT_SL_DEMO:

    mainINCLUDE_FAT_SL_DEMO is defined in main_full.c.

    If mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0 then mainINCLUDE_FAT_SL_DEMO has no effect.

    If mainCREATE_SIMPLE_BLINKY_DEMO_ONLY and mainINCLUDE_FAT_SL_DEMO are both set to 1 then FreeRTOS+FAT SL is used to create a RAM disk, and FreeRTOS+CLI is used to provide a command line interface through a UART. The CLI provides access to the file system.

    If mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1 and mainINCLUDE_FAT_SL_DEMO is set to 0 then the UART is used to run the COM test standard demo task - and a loopback connector (connecting pins 2 and 3) must be fitted to the UART port.


Functionality with mainCREATE_SIMPLE_BLINKY_DEMO_ONLY set to 1

If mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1 then main() will call main_blinky().

main_blinky() creates a very simple demo that includes two tasks and one queue. One task repeatedly sends the value 100 to the other task through the queue. The receiving task toggles an LED each time it receives the message. The message is sent every 200 milliseconds, so the LED toggles every 200 milliseconds.


Functionality with mainCREATE_SIMPLE_BLINKY_DEMO_ONLY set to 0

If mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0 then main() will call main_full().

main_full() creates a comprehensive test and demo application that, when mainINCLUDE_FAT_SL_DEMO is also set to 1, demonstrates:

Using the RTOS CLI to access the FAT FS Connect to FreeRTOS+CLI though the UART using 115200 baud. Type 'help' in the CLI to see a list of the registered commands. Some commands are generic demonstrations, while others allow viewing and manipulation of the file system. This part of the demo is (at the time of writing) identical to that described on the FreeRTOS+FAT SL Win32 simulator demo page - where a video that shows the CLI being used can also be viewed.

Most of the other tasks created by the demo are from the set of standard demo tasks. These are used by all FreeRTOS demo applications, and have no specific functionality or purpose other than to demonstrate the FreeRTOS API being used and test the RTOS kernel port.

A 'check' task is also created. The check task periodically queries the standard demo tasks to ensure they are functioning as intended. The check task also toggles an LED to give a visual indication of the system status. If the LED toggles every 3 seconds then the check task has not discovered any problems with the executing demo. If the LED toggles every 200 milliseconds then the check task has discovered a problem in at least one task..



Build Instructions

Building and executing the demo application - IAR Embedded Workbench

Note that the IAR project references common files from both the /FreeRTOS-Plus and /FreeRTOS/Demo/Common directories, so the project will not compile if /FreeRTOS-Plus has been deleted.
  1. Open FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/IAR/RTOSDemo.eww from within the Embedded Workbench IDE.

  2. Open the project's main.c file, and set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to generate either the simple blinky demo, or the full test and demo application, as required.

  3. Select "Build All" from the IDE's "Project" menu.

  4. Ensure the target hardware is connected to the host computer using an appropriate debug interface (J-Link, I-Jet, etc.).

  5. Select "Options" from the IDE's "Project" menu. The options window will appear. In the options window first select the "Debugger" category, then ensure the "driver" setting is correct for your debugger connection (J-Link, I-Jet, etc.). Close the Options window when the setting is correct.

  6. Select "Download and Debug" from the IDE's "Project" window to download the built executable to the ARM Cortex-A9 and start a debug session.


Building and executing the demo application - DS-5

Note that the ARM DS-5 Eclipse project uses both virtual folders and links that reference files from both the /FreeRTOS-Plus and /FreeRTOS/Demo/Common directories. The [virtual] file structure viewed in the Eclipse project explorer will not therefore match the [actual] file structure viewed on the disk.
  1. Open DS-5 and either create a new workspace or select an existing workspace when prompted.

  2. Select "Import" from the IDE's "File" menu to bring up the import dialog box.

  3. In the Import dialog box, select "General->Existing Projects Into Workspace" then browse to and select the FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5 directory. A project called "FreeRTOS_Demo" will be visible.

  4. Ensure FreeRTOS_Demo is checked and that Copy Projects Into Workspace is not checked before clicking "Finish".

    Importing RTOS projects into ARM DS-5 Eclipse workspace
    Import FreeRTOS_Demo into the Eclipse workspace without copying it into the workspace.

  5. Open main.c and set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to generate either the simple blinky demo, or the full test and demo application, as required.

  6. Ensure the target hardware is connected to the host computer using an appropriate debug interface (D-Stream, U-Link, etc.).

  7. Select "Build All" from the IDE's "Project" menu.

  8. After the build completes, select "Debug Configurations..." from the IDE's "Debug" menu, and configure and run a debug configuration that is appropriate for your selected connection method (D-Stream, U-Link, etc.). The clickable screenshots below show a configuration that is using the D-Stream debugger.

    D-stream Cortex-A debug configuration D-stream Renesas RZ debug configuration Renesas debug using DS-5 from ARM
    Click Images to Enlarge



RTOS Configuration and Usage Details


FreeRTOS ARM Cortex-A port specific configuration

Attention please!: Refer to the the page that provides instruction on using FreeRTOS on ARM Cortex-A embedded processors, paying particular attention to the value and meaning of the configMAX_API_CALL_INTERRUPT_PRIORITY setting.

Configuration items specific to this demo are contained in FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/FreeRTOSConfig.h. The constants defined in this file can be edited to suit your application.


[Application Defined] Interrupt service routines

This demo uses drivers provided by Renesas to configure the interrupt controller, and install application defined interrupts. The Renesas drivers require interrupt service routines (ISRs) to accept a uint32_t parameter, although the parameter is not actually used and can be ignored. The required ISR prototype is therefore:

    void Interrupt_Handler( uint32_t ulUnusedParameter );
If an ISR causes a task of equal or higher priority than the currently executing task to leave the Blocked state then the ISR must request a context switch before the ISR exits. When this is done the interrupt will interrupt one RTOS task, but return to a different RTOS task.

The macros portYIELD_FROM_ISR() (or portEND_SWITCHING_ISR()) can be used to request a context switch from within an ISR. The following source code snippet is provided as an example. The example ISR uses a semaphore to synchronise with a task (not shown), and calls portYIELD_FROM_ISR() to ensure the interrupt returns directly to the task. (The function prvRXI_Handler() in the file serial.c provides another example.)

void Dummy_IRQHandler( uint32_t ulUnused )
{
long lHigherPriorityTaskWoken = pdFALSE;

    /* The parameter is not used. */
    ( void ) ulUnused;

    /* Clear the interrupt if necessary. */
    Dummy_ClearITPendingBit();

    /* This interrupt does nothing more than demonstrate how to synchronise a
    task with an interrupt.  A semaphore is used for this purpose.  Note
    lHigherPriorityTaskWoken is initialised to pdFALSE. */
    xSemaphoreGiveFromISR( xTestSemaphore, &lHigherPriorityTaskWoken );

    /* If there was a task that was blocked on the semaphore, and giving the
    semaphore caused the task to unblock, and the unblocked task has a priority
    higher than or equal to the currently Running task (the task that this
    interrupt interrupted), then lHigherPriorityTaskWoken will have been set to
    pdTRUE internally within xSemaphoreGiveFromISR().  Passing pdTRUE into the
    portYIELD_FROM_ISR() macro will result in a context switch being pended to
    ensure this interrupt returns directly to the unblocked, higher priority,
    task.  Passing pdFALSE into portYIELD_FROM_ISR() has no effect. */
    portYIELD_FROM_ISR( lHigherPriorityTaskWoken );
}

Only FreeRTOS API functions that end in "FromISR" can be called from an interrupt service routine - and then only if the priority of the interrupt is less than or equal to that set by the configMAX_API_CALL_INTERRUPT_PRIORITY configuration constant (meaning a numerically higher value).


Resources used by FreeRTOS

Information is provided on the Using FreeRTOS on ARM Cortex-A Embedded Processors page. This demo is configured to generate the tick interrupt from the OSTM0 peripheral.


Memory allocation

Source/Portable/MemMang/heap_4.c is included in the ARM Cortex-A demo application project to provide the memory allocation required by the RTOS kernel. Please refer to the Memory Management section of the API documentation for full information.


Miscellaneous

Note that vPortEndScheduler() has not been implemented.





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


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

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

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner