Technical topic: TASTE on MSP430 with FreeRTOS

From TASTE
Revision as of 11:04, 16 December 2019 by Kgrochowski (talk | contribs)
Jump to: navigation, search

This page describes how FreeRTOS support was added to TASTE.

Hardware Description

This article describes steps of adding support for MSP-430 platform using MSP43FR5969 processor [1] as example. The MSP430FR5969 LaunchPad Development Kit [2] was used for testing purposes.

Microcontroller's parameters:

  • 16-bit RISC architecture;
  • 16‑MHz Clock;
  • 64KB FRAM / 2KB SRAM.

On this very limited platform using PolyORB-HI-Ada or PolyORB-HI-C is impossible, due to memory requirements. In the next sections the different approach of code generation is described.

New execution platform

Add new platform Platform_MSP430_FreeRTOS to TASTE. Follow instructions from Technical topic: Add a new target platform to TASTE.

TBC

Source code generation for Concurrency View

The Concurrency View code is responsible for initialization of devices, drivers, threads and other structures. The created structures are responsible for passing information between functions and thread synchronization. Generally this code is generated by Ocarina. The generated code uses PolyORB-HI-Ada or PolyORB-HI-C as a middleware.

Kazoo templates for Concurrency View has parameters, which describes threads, mutexes, functions, etc. and relations between them. These parameters may be used to generate code without PolyORB-HI-Ada or PolyORB-HI-C. This section described this approach.

TBC

Mapping of TASTE structures

The threads will be mapped to FreeRTOS tasks [3]. FreeRTOS task is just a thread. It has own stack, priority and main function.

The communication and synchronization between tasks will be realised using queues and semaphores or mutexes [4].

Cyclic provided interfaces of functions will be implemented using software timers [5].

TBC

Gathering FreeRTOS source files

The FreeRTOS source files must be present in the partition source directory before compilation. There are two possible solutions:

  • embed FreeRTOS source files in kazoo templates;
  • create template that generates shell script, which copies requires FreeRTOS files from known location.

TBC

main.c

To generate this file, the new Concurrency View subdirectory should be created. This file is a entry point, the function main for partition on MSP430. This file should be responsible for intialization of FreeRTOS primitives like tasks and queues. The device drivers should be initialized here. The main.c should also contain all necessary functions and other structures, which are required by FreeRTOS.

TBC

Function wrappers

The wrappers around provided interfaces of the functions will be generated in files build/<node name>/<partition name>/freertos_interface.{c,h}. The responsibilities of wrapper function is:

  • acquire lock on mutex before calling the function if provided interface is protected if necessary;
  • send #Requests to other partitions.

As a base for templates following subdirectories will be used: pohic_wrappers_body and pohic_wrappers_header.

Requests

This file will be contains structures responsible for communication between other partitions. As a prototype for this template, the files request.c and request.h, currently generated by Ocarina, will be used.

TBC

Marshallers

This file will be contain function responsible for decoding and encoding #Requests. As a prototype for this template, the files marshallers.c and marshallers.h, currently generated by Ocarina will be used.

TBC

Subprograms

This file will be contain functions corresponding to subprograms for #Device drivers. As a prototype for this template, the files subprograms.c and subprograms.h, currently generated by Ocarina will be used.

TBC

Activity

This file will be contain activities like, waiting for events or queues and calling functions responsible for realization of provided interfaces. As a prototype for this template, the files activity.c and activity.h, currently generated by Ocarina will be used.

TBC

FreeRTOSConfig.h

To generate this file, the new concurrency_view subdirectory should be created.

The file FreeRTOSConfig.h contains configuration for FreeRTOS. This file defines a set of macros. Example macros are presented in table below:

Macro name Description
configTICK_RATE_HZ Used to configure tick frequency for scheduler
configMAX_PRIORITIES Used to configure max priority of the task
configGENERATE_RUN_TIME_STATS Used to enable or disable run time statistics
configTOTAL_HEAP_SIZE Used to configure total heap size
configMINIMAL_STACK_SIZE Uset to configure minimal stack size

Some macros, like configTICK_RATE_HZ, will be generated based on kazoo template parameters. FreeRTOSConfig.h will be used for tailoring FreeRTOS for TASTE purposes. For an example to disable coroutines following line will be added:

#define configUSE_CO_ROUTINES ( 0 )

Or to do not include FreeRTOS function to compilation to reduce memory usage:

#define INCLUDE_vTaskDelete ( 1 )

TBC

Modification in Makefiles and GNAT Project Manager files

The source code files generated by kazoo, should be compiled. For this purpose the kazoo template should be created based on existing template for other platform, e.g. c_pohi_gpr.

$ cd ~/tool-src/kazoo/templates/concurrency_view
$ cp -r c_pohi_gpr freertos_msp430_gpr

Within new subdirectory, the file partition.tmplt is the main file responsible for generation of .gpr file, but other files, like trigger.tmplt, should be changed. The generated file is responsible for building partition. The main modification in partition.tmplt is exclusion of PolyORB files from compilation and inclusion of source files generated for FreeRTOS partition. This file should also include FreeRTOS source files and source code for device drivers.

Another modification in this file is introduction of C compiler for MPS430 platform: msp430-elf-gcc.

TBC

Device drivers

The devices and their drivers are described in file ocarina_components.aadl. This file describes subprograms required by device drivers. The device drivers for MSP430 and FreeRTOS will be implemented independly using driver library for MSP430FR5969.

TBC