Presentation is loading. Please wait.

Presentation is loading. Please wait.

Implementation of Embedded OS

Similar presentations


Presentation on theme: "Implementation of Embedded OS"— Presentation transcript:

1 Implementation of Embedded OS
Lab5 - FreeRTOS Porting / 14

2 Experimental Goal Understand the basic process of porting.
Port FreeRTOS to RPi 2. Understand some FreeRTOS implementations. / 14

3 Environment Host System Build System Target System Windows
Ubuntu (or above) 64-bit Target System Raspberry Pi 2 / 14

4 Software Required Host System Build System
PL2303 Driver PuTTY Build System GCC Cross-Compiler Targeting arm-none-eabi FreeRTOS port for Raspberry Pi Older Raspberry Pi firmware You may download them from IEOS Course Software. / 14

5 Hardware Checklist Raspberry Pi 2 Power supply
Micro SD card and card reader USB-TTL cable / 14

6 Introduction to Porting
In software engineering, porting is the process of adapting software so that an executable program can be created for a computing environment that is different from the one for which it was originally designed (e.g. different CPU, operating system, or third party library). Software is portable when the cost of porting it to a new platform is less than the cost of writing it from scratch. The lower the cost of porting software, relative to its implementation cost, the more portable it is said to be. / 14

7 Popular Embedded OS Architecture
OS porting only needs to modify OS Port layer for the target platform. Modify the hardware dependent codes, such as GPIO, memory mapping, or interrupt control. / 14

8 Introduction to FreeRTOS
Yet another real-time operating system Why choose FreeRTOS? Official introduction Unlike uCOSII which requires royalty payments for commercial use, FreeRTOS is distributed under a modified GPL. Source code is available here. Source code structure FreeRTOS suggests that the two directories FreeRTOS/Source/portable/your_compiler/your_architecture/ and FreeRTOS/Demo/your_platform/ form the port layer. / 14

9 FreeRTOS Port for Raspberry Pi
FreeRTOS has been officially ported to many platforms. Raspberry Pi series is not included, however. Lucky, there is a contributed port from third party. This port runs on Raspberry Pi 1 (BCM2835). We are going to modify it and make it run on Raspberry Pi 2 (BCM2836). Download and extract the source code of this port. Compare the code structure of this port and the official FreeRTOS ports. FreeRTOS/Source/portable/GCC/RaspberryPi/ and Demo/ form the port layer. Build script Makefile and linker script raspberrypi.ld are at the root of the archive. / 14

10 Control Flow According to the linker script, the program entry point is _start in Demo/startup.s. After doing some processor specific initializations, the control flow jumps to main() in Demo/main.c. In main(), a FreeRTOS kernel API xTaskCreate() is called twice to register two user-defined tasks task1() and task2(). Another FreeRTOS kernel API vTaskStartScheduler() is then called to start the two tasks. task1() and task2() perform their works periodically. Their periods are specified by a FreeRTOS kernel API vTaskDelay(). FreeRTOS kernel API reference can be found here. Their implementations can be found in the source code. / 14

11 Build Instructions Fix compiler version issue. Run % make directly.
The linker needs libgcc.a and libc.a to generate the final executable. Find their path and replace “/usr/lib/gcc/arm-none-eabi/4.7.4” and “/usr/arm- none-eabi/lib” in Makefile with their path. Run % make directly. kernel.img is the FreeRTOS image bootable by RPi firmware. Currently, this image is not able to run on RPi 2, since we have not modified the code. / 14

12 Porting to Raspberry Pi 2
Modify the source code. Refer to this article. (Hint: Modify all base addresses.) You may also want to add UART support for debugging purpose. Modify the build script. Specify target CPU for compiler and assembler. In dbuild.config.mk, replace “-march=armv6z” with “-mcpu=cortex-a7”, and add a line “ASFLAGS += - mcpu=cortex-a7”. If you add additional .c or .s files, specify corresponding .o files in objects.mk. / 14

13 Firmware Issue The behavior of Raspberry Pi firmware changes among versions. This FreeRTOS Raspberry Pi port only runs with RPi firmware of some older versions. It can not run with firmware , the firmware we have used so far. So, let’s use firmware instead. Backup your config.txt and FreeRTOS image. Format the boot partition. Put firmware /boot/* into boot partition. Restore your config.txt and FreeRTOS image. Note: Do not use “kernel.img” as the name of the image. / 14

14 Boot Successfully Note: In my task1() and task2(), I replace “SetGpio(16, 1)” and “SetGpio(16, 0)” with printing “task 1” and “task 2” respectively. / 14


Download ppt "Implementation of Embedded OS"

Similar presentations


Ads by Google