分类: 嵌入式
2010-05-15 16:22:14
The Wind River's VxWorks Real Time operating system generally is used in the mid-to-high size embedded systems with the considerable hardware resources (a few megabytes of the RAM, networking, etc).
The VxWorks port for the LPC2106 ARM microprocessor shows an ability to use the VxWorks in the minimal configuration (a LPC2106 has 128 KBytes internal FLASH and 64 KBytes internal RAM).
A Tornado 2.2/VxWorks 5.5 for ARM has been used for the BSP (board support package) development and a test project.
1. Minimal configuration
In the file config.h (part of the LPC2106 BSP), all VxWorks's components, enabled in the system's file configAll.h, should be disabled. A Tornado's BSP/project creator automatically includes in the project minimal set of the components for the system (kernel) functionality (see the file prjComps.h in the test project directory):
/* minimal set of components - includes automatically*/
#define INCLUDE_DLL
#define INCLUDE_EXC_HANDLING
#define INCLUDE_EXC_TASK
#define INCLUDE_KERNEL
#define INCLUDE_MEMORY_CONFIG
#define INCLUDE_MEM_MGR_BASIC
#define INCLUDE_MSG_Q
#define INCLUDE_SEM_BINARY
#define INCLUDE_SYSCLK_INIT
#define INCLUDE_SYSHW_INIT
#define INCLUDE_SYS_START
#define INCLUDE_USER_APPL
#define INCLUDE_VXEVENTS
|
2. Memory map
A projects with the LPC2106 BSP use only the default_romResident build configuration (the system code are in the FLASH, a data segment is copied into the RAM)
A BSP's memory configuration is described in the files Makefile and config.h (both are in the LPC2106 BSP's directory):
- in the Makefile:
ROM_TEXT_ADRS = 00000000 # ROM entry address |
- in the config.h :
/*-------------- lpc2106base BSP configuration -----------------------*/ #undef ROOT_STACK_SIZE /* was 0x4000 */ #define ROOT_STACK_SIZE 0x800 |
3. Interrupts vectors
After the hardware reset, the LPC2106 starts from the address 0x0 (a FLASH first address). Other exceptions vectors are placed at the addresses 0x04 - 0x1C.
For the ARM architecture, a VxWorks expects that an exception pointers are placed (finally) at addreses 0x100-0x1C0 in the RAM.
To set an exceptions vectors in the RAM, the romInit() function (an entry point for the VxWorks in the ROM/FLASH; a file romInit.s in the BSP directory) contains an exceptions redirection code:
_romInit: |
In the file sysLib.c (the BSP's directory), the lpc2106IntVectSet() function is added to make a final exception vectors remapping. This function's call should be placed inside the sysHwInit() function (to initialize the CPU board hardware).
/* This is a VxWorks's internal interrupt handling routines prototypes */ extern void excEnterUndef(void); |
VxWorks has the own internal function to initialize exception vectors - excVecInit(). This function has been written on the assumption that a RAM (not a ROM) is placed at the address 0x0. Using this function in the LPC2106 BSP will crash a system.
A problem here (to avoid this function's using) is that the Tornado's BSP/project creator automatically includes this function into the usrInit() function (a file prjConfig.c; the project directory) after each rebuilding of the project.
A simple (and, probably, not the best) way to cancel this automatic including is to set as a comment name of the excVecInit() function in the file /target/config/comps/vxWorks/00vxWorks.cdf:
Component INCLUDE_EXC_HANDLING { NAME exception handling MODULES excArchLib.o INIT_RTN /* excVecInit (); */ HDR_FILES excLib.h } |
4. Interrupts controller
An interrupts controller's routines for the LPC2106 are very similar to the VxWorks's example /target/src/drv/intrCtl/ambaIntrCtl.c.
For the LPC2106,
- AMBA_INT_CSR_ENB (the "Enable Set" register) is a VICIntEnable register (address-0xFFFFF010)
- AMBA_INT_CSR_DIS (the "Enable Clear" register) is a VICIntEnClear register (address-0xFFFFF014)
- AMBA_INT_CSR_PEND (the "Interrupt Request" register) is a VICIRQStatus register (address-0xFFFFF000)
5. System Clocks
A VxWorks in the minimal configuration needs only the system clock. In the LPC2106 BSP, a Timer 0 is used as a system clock's interrupt source. In the sysClkInt() function the interrupt source should be cleared:
void sysClkInt (void) |
This is an example of the Timer 0 configuration (the sysClkEnable() function):
void sysClkEnable (void) |
6. User application
For the BSP's framework debugging, a very simple user task is used. This task performs just the LED blinking (the file usrAppInit.c in the project directory):
void tLEDBlink(void) |
7. FLASH and RAM using
For the test project (LPC2106 in ARM mode, VxWorks 5.5, Tornado 2.2 GNU (GCC 2.9) Compiler):
- The overall FLASH using is ~81 KBytes (no optimization), ~77 KBytes (optimization: 2)
- The RAM using (without the malloc() pool) is ~11 KBytes