There are two aspects of porting eCos: porting to a new CPU (architectural porting) and porting to a new board with a CPU that is already supported (platform porting).
In this release of eCos we provide these brief notes on platform porting.
Another useful reference for porting to a new platform is the GNUPro documentation on gdb stubs, which can be found at http://www.cygnus.com/pubs/gnupro/3_GNUPro_Debugging_Tools/b_Debugging_with_GDB/gdbThe_GDB_remote_serial_protocol.html
For the purposes of this presentation, we will call the new target board myboard, and we will assume that it is closely related to the stdeval1 board (if the new board has an MN10300 CPU) or a jmr3904 board (if the new board has a TX39 CPU).
Now follow this sequence of steps, noting that all pathnames are relative to the directory in which eCos has been installed.
You should start by copying the entire directory packages/hal/mn10300/hal/v1_1/stdeval1 (or packages/hal/mips/hal/v1_1/jmr3904) to packages/hal/mn10300/v1_1/myboard (or packages/hal/mips/v1_1/myboard).
In the new directory change the names stdeval1.ld and stdeval1.S (or jmr3904.ld and jmr3904.S) to myboard.ld and myboard.S
The file packages/hal/mn10300/arch/v1_1/src/vectors.S (or packages/hal/mips/arch/v1_1/src/vectors.S) contains initialization code which is placed in the interrupt vectors for the particular CPU. It also contains the first level default vector service routines that save and restore state for both exceptions and interrupts.
Now for the MN10300 you should:
Make a copy of the following block of definitions:
#ifdef CYG_HAL_MN10300_STDEVAL1 .equ INIT_MEMCTR0,0x1200 # 2wait .equ INIT_MEMCTR1,0x0120 # 1wait-32bit- .equ INIT_MEMCTR2,0x0065 .equ INIT_DRAMCTR,0x0287 .equ INIT_REFCNT,0x00eb #endif |
Then change the #ifdef to say
#ifdef CYG_HAL_MN10300_MYBOARD |
and set the INIT_ values to the approapriate addresses for the memory controllers and other chips on myboard.
Look for the label _start: — the surrounding text should be:
##--------------------------------------------------- ## Startup code .text .globl _start _start: #if defined(CYG_HAL_MN10300_STDEVAL1) <code to set up memory controller> #endif |
Make a copy of the entire area between the #if ... and #endif inclusive, and change the #if ... line so that it reads
#if defined(CYG_HAL_MN10300_MYBOARD) <code to set up memory controller> #endif |
Optionally add or modify the memory setup code to match the memory installed on the platform.
For the TX39, instead, copy the area in which memory regions are set up; this is enclosed in the preprocessor statements
#ifdef CYG_HAL_MIPS_JMR3904 (set up controller according to where the memory is installed) #endif |
and change it to
#ifdef CYG_HAL_MIPS_MYBOARD (set up controller according to where the memory is installed) #endif |
The file packages/hal/mn10300/myboard/v1_1/src/hal_diag.c (or packages/hal/mips/myboard/v1_1/src/hal_diag.c) implements support for HAL diagnostic output. You should provide an implementation of diagnostic routines if you are not using on-chip devices for diagnostics, since the HAL already supports the on-chip devices.
The file packages/hal/mn10300/myboard/v1_1/src/PKGconf.mak (or packages/hal/mips/myboard/v1_1/src/PKGconf.mak) contains makefile targets for the given board. You should change occurrences of stdeval1 (or jmr3904) to say myboard.
The file packages/hal/mn10300/myboard/v1_1/src/myboard.ld (or packages/hal/mips/myboard/v1_1/src/myboard.ld) is the linker script for myboard. You should:
Optionally change the LOAD_BASE and DATA_BASE #defines at start of the ld script.
Place hal_vsr_table at an appropriate location.