Project Presentation

Report
PORTING FREERTOS TO MCB2140 BOARD
Ashwini Athalye
Sravya Kusam
Shruti Ponkshe
OVERVIEW
Introduction to RTOS
 FreeRTOS Internals
 Hardware/Software Details
 Implementation
 Breakdown of work
 Design Tradeoffs
 What would we have done differently

Goal: To port FreeRTOS v5.3.0 onto ARM7 MCB2140 board
WHAT IS AN RTOS?

A multi-tasking operating system catered for real-time
applications


Eg Flight control, streaming media decoders, microwave etc
What is the difference between a general OS and RTOS?

RTOS: Deterministic “timing”


General OS: Non-Deterministic “timing”


OS services consume only known and expected amount of time
Services can inject random delays and hence alter execution times
Key kernel component

Scheduler and scheduling policy
FREERTOS INTERNALS: BASIC BLOCKS

Scheduler




Scheduling Policy: Pre-emptive, priority based
RTOS Tick: Timer Interrupt to measure time in ticks
Idle task of lowest priority(0) created by scheduler
Tasks



Context: Each task executes within its own context (stack)
Priority: Processing time preference given to higher priority task
State:





Queues


Running: Currently Executing
Ready: Able to execute but higher/equal priority task running
Blocked: Waiting for temporal or external event (delay, semaphore)
Suspended: Explicitly suspended by scheduler
Inter-task and interrupt-task communication
Co-routines

Share single stack, implemented as idle hooks (lowest priority)
FREERTOS INTERNALS: CONTEXT SWITCHING

Saving context
The context can be saved by pushing processor registers onto
the task stack.
 Push R0-LR
 Push CSPR
 Copy stack pointer in kernel


Restoring context

The scheduler retrieves the stack pointer for the task then
POP's the context back into the correct processor registers
MCB2140 BOARD DETAILS (NXP LPC2148)
DEVELOPMENT ENVIRONMENT

Keil Development Tools


uVision v4.0 IDE
ARM compilation tools
ARM C/C++ compiler (armcc)
 ARM Macro Assembler (armasm)
 ARM Linker (armLink)


Flash Magic

Developed for NXP semiconductors to program on-chip flash
PORTING METHODOLOGY

Identify source code for closely related port


Identify development environment


LPC 21xx port for MCB 2100 board
MCB2140 manufactured by Keil
Study source code organization

Port-dependent


Port-independent


Successful compilation = nth attempt 
Testing




Allocate appropriate stack size, priority
Compile code


Config file: Processor frequency, stack direction and size, tick rate etc.
Task creation


Task, queues, co-routines
Make hardware related changes


Tick timer, ISR handling, Context switching
Single task
Multiple tasks
Co-routines
Debugging


Emulator, JTAG
Printf : requires UART to be setup
APPLICATION DEVELOPMENT
Implemented Monitor(as a task) to perform IAP
 IAP = In Application Programming


Performing erase and write operation on the on-chip flash
memory from the application code
IAP routine resides at 0x7FFFFFF0h, thumb code
 IAP commands






Blank check sectors
Erase sectors
Prepare sectors for write
Copy RAM to Flash
Compare
DEMO!
BREAKDOWN OF WORK

Common
Understanding source code
 Understanding Interrupts, serial port configuration


Sravya
Task and co-routine implementation
 Understanding IAP vs ISP


Shruti
Understanding/Setting up board
 IAP code


Ashwini
Compiling code
 UART configuration and Monitor code

DESIGN TRADEOFFS

Monitor can spawn IAP as a separate task

More complicated scheduling policy
WHAT WOULD WE DO DIFFERENTLY

Debugging:


Use JTAG, understand emulator
Application:

Design application for “Hard” real time task
POINTS TOGO

RTOS design and porting

Simplify Code

Embedding ASM in C


In-built functions may not work correctly 


compiler dependent syntax
We wrote our own functions- isdigit(), isspace() etc
Flash organization, sector layout
REFERENCES
www.freeRTOS.org
 www.wikipedia.com
 ARM Assembly Language Programming Guide
 LPC2148 Manual

QUESTIONS

similar documents