Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

C/OS-II Real Time Kernel Port For Cirrus Logic EP93xx Platform

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

10th International Conference on DEVELOPMENT AND APPLICATION SYSTEMS, Suceava, Romania, May 27-29, 2010

µC/OS-II Real Time Kernel Port for Cirrus


Logic EP93xx Platform
Eugen DODIU1, Adrian GRAUR2, Cristina N. GAITAN3, Vasile G. GAITAN4, Adrian M. GAITAN5
Stefan cel Mare University of Suceava
13,University Street, RO-720229 Suceava
1
edodiu@usv.ro, 2adriang@eed.usv.ro, 3gaitan@eed.usv.ro,
4
cristinag@eed.usv.ro, 5agaitan@stud.usv.ro

Abstract — Real-time systems are a key element for ƒ ROM-able. This OS was designed for embedded
applications where deadlines must be satisfied. The absence of systems and if using adequate development tools
a time constraint in a hard real-time system can cause severe it can be embedded as a part of the final product.
material damage or even life threatening scenarios. This is why
ƒ Scalable. The total amount of memory or the
the system designer’s task is to make proper selection of an
embedded operating system that can meet these demands. memory footprint can be modified from a
configuration file accordingly to the hardware
Index Terms — µC/OS-II, hard real-time/soft real-time, restraints.
embedded system, EP9302, real-time scheduling, operating ƒ Portable. The way the software structure is built
system allows easy porting to other architectures.
ƒ Preemptive. This means that µC/OS-II will
I. INTRODUCTION always run the highest priority task that is ready
This article presents the practical steps toward running to be executed.
Micriµm’s µC/OS-II real time kernel on a Cirrus Logic ƒ Deterministic. User knows how much CPU time
EP9302 processor. is spent for µC/OS-II system function execution.
Real-time systems are a bit different from the classical ƒ Interrupt Management. The kernel can manage
ones because they have to offer a certain response within a interrupts with up to 255 levels deep.
specified time period. In the case of real-time systems, ƒ Tasks Stacks. This feature allows using separate
correct execution of tasks will depend not only on the stacks with different sizes for each task thus
correctness of the results, but also on the time instance they permitting better footprint management.
are started. Unlike soft real-time where deadline miss is not All the above characteristics conclude that µC/OS-II is a
a major problem, missing a time constraint in a hard real- well built, robust and reliable operating system that can be
time system can lead to physical damage [1][1][2][2]. used in real-time embedded systems.
All these problems are satisfied with µC/OS-II as we
could see on other tested hardware architectures. Without II. HARDWARE ARCHITECTURE
any doubt, µC/OS-II is a very powerful product, since it was The test system uses Technologic System’s TS7300
certified by the Federal Aviation Administration to meet the development board [3][3]. This board was initially sold with
requirements of the RTCA DO-178B standard for software Linux preinstalled, but we decided to use it for µC/OS-II
used in avionics equipment. Our previous testing of this porting and testing, since the hardware platform allowed this
operating system on some embedded architectures (ARM 7, software change.
HCS12) here at Stefan cel Mare University of Suceava,
proved that µC/OS-II is the best choice for real-time
applications. This OS was born back in 1992, when engineer
Jean Labrosse, future founder of Micriµm Technologies
Corporation, began working on a real-time operating system
that was needed to satisfy strict timing requirements of one
of his projects. The latest stable version is 286 and can be
found on Micriµm's website along with the latest version,
µC/OS-III.
Applications such as cameras, avionics, high-end audio
equipment, engine controls, medical equipment, industrial
machines, have been using µC/OS-II for a long time now
with great success [2][2][1].
Latest distributions allow integration with other software
packages such as µC/TCP-IP, µC/GUI, µC/File System,
µC/USB, µC/CAN, µC/Modbus, µC/Bluetooth, for
obtaining greater scalability and performance [2][2][5].
It is important to mention just a few characteristics of this
Figure 1. Hardware organization of the test board [3][3].
real time kernel to observe its key features:

85
10th International Conference on DEVELOPMENT AND APPLICATION SYSTEMS, Suceava, Romania, May 27-29, 2010

Fig. 1 presents the hardware architecture of the TS-7300


test board [3][3][3]:
ƒ EP9302 Cirrus Logic Processor (ARM920T @
200MHz)
ƒ 32 Mbytes Samsung SDRAM K4S561632H
ƒ Peripherials: IO ports, USB port, JTAG, CAN,
USART, power connectors
ƒ Real time clock
ƒ Altera CycloneII FPGA for application
development
ƒ Altera MAX II CPLD companion chip
ƒ SD card storage
ƒ PC104 expansion slot
ƒ RS232 drivers
ƒ Serial FLASH memory for Linux bootloader.
Featuring a five stage pipeline consisting of fetch, decode,
execute, memory and write stages, the ARM920T 32 bit
architecture, delivers impressive performance with power
consumption under 2 Watts [3]. Trial results showed that
this ARM920T processor can produce impressive
throughput with over 309 Mbytes/s at 200MHz core clock
using block transfer STMIA instructions. ARM920T has the
following characteristics: ARM and Thumb instructions, 32 Figure 2. Logical evolution of the booting algorithm. [6] [6][6]
bit Advanced Micro-Controller Bus Architecture, 16 Kbyte
instruction and 16 Kbyte data cache, MMU for operating Our intention was not to modify the contents of the 25160
systems, TLB with 64 entries for data and instructions, EEPROM SPI memory that boots Linux from the compact
programmable page sizes, independent lockdown for TLB flash. This is why we decided to use the UART
entries. Activating all these characteristics can lead to very programming method. The absence of the EP9302 on-chip
good raw performance of the controller. flash memory implies reprogramming of the device every
There are a few integrated circuits that are not directly time a power off-on cycle is completed. Jumper 1 from the
addressable by the EP9302 processor. In most of the cases JTAG connector selects the loading via UART or SPI. In
this is done using the Altera MAX II glue-logic companion our case, the presence of a jumper on the first pair of pins
chip. The documentation of the board shows the mapped specifies that a serial download will be initiated. A number
addresses in the ARM9 physical address space. SD cards are of 2048 characters are expected to be received via the
also accessed via this companion chip. UART serial port by the on chip boot ROM. These
characters will be placed in the receive Ethernet buffer that
III. PROGRAMMING AND BOOTING PROCESS starts at address 0x80014000.
Since the 2K program received in buffer space is not
Cirrus Logic designed the EP9302 processor with enough to load and run the µC/OS-II kernel and application
multiple ways of booting. The JTAG connector has a dual tasks, we had to build our own boot loader whose only basic
function: it controls both the programming via JTAG for the function is the loading of the binary file in the SDRAM. The
CPLD devices and the boot mode of the EP9302 processor. Boot ROM utility leaves the UART 1 serial port configured
This connector cannot be used for EP9302 JTAG at 9600 baud, 1 bit stop, no parity, 8 data bits and opened for
programming since the JTAG pins of this device are not incoming data. After receiving the "< " the second
welded to it. If someone decides to perform a JTAG bootloader is sent to the system using a simple terminal
programming of the EP9302 processor on this test board application that has the possibility of sending data files.
there are a few operations that must completed. The tester Even if the effective code of the second loader is less then
must weld the JTAG_DIN (pin 78), JTAG_DOUT (pin 79), 2K, IAR Embedded Workbench will fill the remaining space
JTAG_CLK (pin 77), JTAG_TMS (pin 80) to the JTAG till 0xFFFF with 0x00. When the second bootloader starts,
connector. Since the processor has no on-chip flash the user the first action is to disable the external watchdog timer that
has to make an initialization file of the SDRAM chip that is built using the MAXII CPLD. This is done by first writing
will be executed prior to any application code. Only after the the feed register at address 0x23C00000 and then the
on-board Samsung memory will be initialized, the configuration register at adress 0x23800000. If these actions
application code will be downloaded and executed from the are not performed, the board will reset peridocally at 8
SDRAM. This sequence works fine with IAR Embedded seconds. Since we want to use the full computing power of
Workbench version 5.40.1 and JLink programmer with the ARM core, the caches are enabled by writing to CP15
hardware version 5.3. registers with dedicated MRC and MCR instructions. This
As mentioned before the JTAG connector controls the task is fulfilled when boosting the speed of the core up to
booting method of the processor (Fig.2). 200MHz using the following PLL parameters:

86
10th International Conference on DEVELOPMENT AND APPLICATION SYSTEMS, Suceava, Romania, May 27-29, 2010

PLL1_X1FBD = 21, PLL1_X2FBD = 31, PLL1_X2IPD =


24, P2L1_PS = 1. This gives an output frequency of
199.987200 MHz. The HCLK is POUT/2 and PCLK is
HCLK/2. Writing this configuration word in the apropriate
PLL config register folowed by 5 NOPs will restart the core
at its desired frequecy. The user can check if the PLL is
locked by reading a dedicated register. Next we decided to
raise the speed of the UART to 115200 for obtaining better
programing times. By doing so, a 64K image files is
downloaded in memory in less then 6 seconds. Before
jumping to the reception loop the SAMSUNG SDRAM
memory initializatin is performed. This is done in the
following steps:
1 -insert 200us start-up delay
2 -load EP9302 memory controller config register with
correct values: RAS-TO-CAS latency 3, CAS delay 3, 4
banks , 16 bit data width
3 - 200us delay is inserted
4 -GLConfig issue NOP commands
5 - 200us delay is inserted
6 - GLConfig – Precharge all comand
7 - Errata for E2 revision requires reading any adress of
all 4 banks of the memory in order to make the precharge
all command work. This is done by reading from adress
0x00000000,0x00200000,0x00400000 and 0x00600000.
8 -Refresh register timer is loaded with value 0xA
9 -20us delay is inserted
10 –GLConfig Mode register select Figure 3. Partial mapping of the Samsung K4S561632H SDRAM memory.
11 –Write configuration word with CAS = 2 (010), BL = 4 If the first memory bank is used alone, the hardware
(010) offset 9 by reading from adress 0x00006600. allows booting images of up to 4 Mbytes footprint. As
12 - Go to normal mode by writing the configuration shown in Table 1, the SDRAM memory domain is not a
register. contiguous space and this depends on the way the ARM
The reception is done by polling the FIFO full status flag. core addresses the external devices. In a Samsung
When the 16 byte depth FIFO is full, the processor copies K4S561632H SDRAM, memory the organization is as
all the data from the receive stack into the memory follows: 13 address lines are used for ROW addressing, 9
respecting the little endian organisation. When a 64K address lines are used for column addressing and 2 lines for
boundary is reached a jump to adress 0x00000000 is done bank selection. EP9302 has the following internal address
using a branch instruction. We had a few problems since the decoding scheme: A1-A8, A24, A25 for column selection,
memory chip U23 doesn’t have the correct notation on the A9-A22 row selection, A26, A27 bank selection[6]. For this
board. Instead of being mapped to domain 3 as the electrical hardware configuration the following address decoding is
schematic tells, our memory chip is adressed with SD_CS3 used: A1-A8, A24 for column selection, A9-A21 row
and is mapped to domain 1 that starts at adress 0x00000000. selection, A26, A27 for bank selection. EP9302 memory
It is probably that notations are swapped, but this is a minor controller allows swapping of bank selection lines A26 and
issue. A27 with A21 and A22. By doing so, the address space will
Table 1 shows the partial mapping of the Samsung only be divided in 4 banks, as can be seen in Table 2. Each
K4S561632H memory in domain 1. bank has now 8 Mbytes in size and the address space is less
TABLE I. ADRESS MAPING FOR SAMSUNG SDRAM divided. Fig. 4 shows the internal structure of the
Bank no. Adress range K4S561632H-TC/L75 Samsung memory, including row,
1 0x0000_0000 - 0x003F_FFFF column and bank addressing logic.
1 0x0100_0000 - 0x013F_FFFF
2 0x0400_0000 - 0x043F_FFFF TABLE II. ADRESS MAPING WITH SROMLL BIT SET TO 1.
Bank no. Adress range
2 0x0500_0000 - 0x053F_FFFF
1 0x0000_0000 - 0x007F_FFFF
3 0x0800_0000 - 0x083F_FFFF
2 0x0100_0000 - 0x017F_FFFF
3 0x0900_0000 - 0x093F_FFFF
3 0x0400_0000 - 0x047F_FFFF
4 0x0C00_0000- 0x0C3F_FFFF
4 0x0500_0000 - 0x057F_FFFF
4 0x0D00_0000 - 0x0D3F_FFFF

87
10th International Conference on DEVELOPMENT AND APPLICATION SYSTEMS, Suceava, Romania, May 27-29, 2010

value used in the os_cfg.h file. The starting task is also


responsible with interrupt configuration and system timer
starting. Since we expect to have full performance from this
system, the Vectored Interrupt Controller is set to execute
the functions that are for exception handler processing.

V. CONCLUSION
The paper presents the basic steps that need to be
performed for loading µC/OS-II on TS7300 development
board. This includes PLL configuration, cache activation
Figure 4. SDRAM Functional Block Diagram. and writing a bootloader that copies the image sent serially
to the SDRAM. For testing and development purpose the
IV. SOFTWARE CONFIGURATION UART serial download has been used. Using this system in
The second bootloader starts downloading into the an application requires adding a bigger EEPROM memory
memory from address 0x00000000. The memory domain 1 that can host the entire application code. An alternative
to which U24 is attached, starts from this address. Since all option can be the redesigning of hardware, so that stand-
available memory from the board is SDRAM, both code and alone flash memories can be used.
data segments will be placed in RAM starting from address Even though Technologic Systems TS7300 was initially
0x00 as can be seen in Listing 1. developed for use with Linux, we found that its real time
computing power comes to life when using true RT
define symbol __ICFEDIT_intvec_start__ = 0x0; operating systems such as µC/OS-II. Practical results of task
/*-Memory Regions-*/ switching times, interrupt latencies and jitter will be
define symbol __ICFEDIT_region_ROM_start__ = 0x80; presented in a future paper.
define symbol __ICFEDIT_region_ROM_end__ = 0x7FFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x8000;
define symbol __ICFEDIT_region_RAM_end__ = 0xFFFF; ACKNOWLEDGMENT
/*-Sizes-*/ We would like to thank Mr. Jean Labrosse for helping us
define symbol __ICFEDIT_size_cstack__ = 0x400; with porting µC/OS-II to Analog Devices ADuC7026 back
define symbol __ICFEDIT_size_svcstack__ = 0x400;
in 2005 and for optimizing system performance and memory
define symbol __ICFEDIT_size_irqstack__ = 0x200;
define symbol __ICFEDIT_size_fiqstack__ = 0x200; footprint for a few of our educational projects.
define symbol __ICFEDIT_size_undstack__ = 0x200;
define symbol __ICFEDIT_size_abtstack__ = 0x200; REFERENCES
define symbol __ICFEDIT_size_heap__ = 0x2000; [1] Cottet F., Delacroix J., Kaiser C., Mammeri Z., "Scheduling In Real-
Listing 1. ROM, RAM and stack memory usage. Time Systems, " John Wiley & Sons Ltd, England, 2002, pp 1-41.
[2] J. Labrosse, "MicroC/OS-II The Real Time Kernel ", 2nd Ed, CMP
IAR Embedded Workbench version 5.40.1 and 286 Books, 2002, pp. 20-150.
µC/OS-II source files were used for testing. Execution of the [3] Technologic Systems, TS7300 Manual Hardware and Software
Revision 1.5 Jul 2008
µC/OS-II binary image starts with the exception handlers [4] Technologic Systems, TS7300 Schematic 1 May 2006
and stack initialization sequence that are coded in file [5] http://www.micrium.com
cstartup.s. Control is next passed to the main function that [6] Cirrus Logic, EP93xx User Guide, September 2007
[7] IAR Embedded Workbench, ARM IAR Assembler- Reference Guide
contains the initialization of the system, AppStartTask [8] IAR Embedded Workbench, IDE User Guide
creation function and the function that actually starts the [9] http://www.cirrus.com EP9302 Rev E2 Silicon
system: OSStart(). Task switching is assured by configuring [10] Samsung Electronics, 256Mb H-die SDRAM Specification, Revision
1.0, October 2005
the timer 1 to generate periodic interrupts that launch the
scheduler. We set it to trigger with 1KHz frequency. This
value must be in correlation with the OS_TICKS_PER_SEC

88

You might also like