120 likes | 288 Views
Implementation of Embedded OS. Lab4 Porting μ C/OS-II. Goal. Learn how to port μ C/OS-II to the ARM platform. * source: www.arm.com. Environment. Host System Windows XP Build System VirtualBox + Ubuntu 8.04 Target System Creator XScale PXA270 Software
E N D
Implementation of Embedded OS Lab4 Porting μC/OS-II
Goal Learn how to port μC/OS-II to the ARM platform. / 12 * source: www.arm.com
Environment • Host System • Windows XP • Build System • VirtualBox + Ubuntu 8.04 • Target System • Creator XScale PXA270 • Software • The binary support package for PXA270. • The source codes of μC/OS-II. • The application note (AN-1011) for porting μC/OS-II. • You can download them from RSWiki IEOS Course Software / 12
μC/OS-II / 12 • μC/OS-II is a real-time operating system with the following features. • Highly portable • ROMable • Very scalable • Preemptive real-time • Multitasking • … • The source codes can be downloaded from the official website freely.
Porting Strategies (1/2) remaining unchanged Files that we should modify / 12 • μC/OS-II can be split into core and port. • To port μC/OS-II to the ARM architecture, we need to implement the ARM port. • A generic ARM port is included in the source archive on our course website. • We only need to modify timer-related functions. • The difference between μC/OS-II and μC/OS-III can be found in the user manual of μC/OS-III.
Porting Strategies (2/2) / 12 • There are four components should be considered first. • Memory • The very first step is to initialize the DRAM controller so that we can load executable images to the target board. • UART console • It is useful for debugging. • Interrupt • It enables us to handle asynchronous events from peripheral devices. • Timer • It will keep the scheduler running repeatedly. • The information about how to configure the components can be found in the datasheet of the microprocessor.
Directories and Files of μC/OS-II Source Codes / 12 • The source files are put in three different directories. • ./PXA270: port-specific • It contains files specific to the hardware platform. • OS_CPU.H: constants, macros, and types specific to the platform. • OS_CPU_C.C: C functions for scheduling and processor events. • OS_CPU_A.S: assembly codes for interrupt handling and context switching. • ./SOURCES: core • It contains files implementing the core functionality of μC/OS-II. • ./TEST: application-specific • It contains files specific to the application, i.e., the entry functions of user-defined tasks. • The detail information can be found in the application note.
Board Support Package (BSP) / 12 • A board support package contains the minimal codes supporting a specific OS for the given target board. • It usually has the following components. • Low-level initialization functions • A bootloader • OS startup functions • Device drivers • In lab4, we will use U-Boot to load μC/OS-II. • Hence, only the last two components are needed for porting μC/OS-II.
Lab Steps (1/3) / 12 • Modify uCOS-II/TEST/Makefile. • The toolchainprefix should be changed. • μC/OS-II should be compiled without using standard C library. • You can exclude the C library from linking with the gcc option “-nostdlib -lgcc”. • Modify source codes. • You might need to implement some C library functions, e.g., strncpy, strncmp, memcmp, etc. • Hints: • Please do not include any headers from Linux or the C library. • “NULL” is actually a macro expending to “((void*)0)”.
Lab Steps (2/3) / 12 • Try compiling the source codes. • You will get TEST.bin if the compilation is done successfully.
Lab Steps (3/3) / 12 • Add timer update function. • It should reprogram the timer to the next deadline when the timer interrupt occurs. • Hints: • when a timer interrupt occurs, the function “OSTimeTickHook” will be invoked. • The timer can be updated by invoking the function “Update_OSMR0” with an argument “p_irq_desc[IRQ_OST0].pVoid”. • Flash the kernel image. • The entry point of μC/OS-II is at 0xa1000000. • The image should be loaded to that address before execution. • Please use the command mkimage to create uImage for μC/OS-II as in lab2.
Lab Requirements / 12 Let U-Boot load and boot μC/OS-II automatically. The timer should be set correctly in μC/OS-II so that the tasks can run alternately.