Creating, building, loading and executing RedBoot binaries
Posted: Fri May 14, 2010 4:51 pm
To demonstrate the process of creating, building, loading, and executing of binaries from a RedBoot environment a sample program for turning on and off of EP9302 board's green and red LEDs will be used. This program, nor all the steps described below pretend to be a complete reference for building and executing RedBoot (or eCos) binaries.
First, we need to know the exact physical addresses of both LEDs. From EP93xx User's Guide we see that both LEDs are connected to PortE bits 1 and 0 (pp. 28-9 - 28-10). PortE Data Register is mapped to 0x80840020 and PortE Data Direction Register to 0x80840024 respectively. Now we are ready to write a really simple program that toggles the two LEDs continuously:
To build the program above we will use GNUARM toolchain. The exact commands used to compile and link the binary are given bellow:
This will produce leds.elf executable with the following file type:
Now we are ready to load and execute the binary on the EP9302 board. To do this we will use the capabilities of the RedBoot to load network files (using FTP, TFTP, or HTTP). Once we have an open RedBoot shell with correct TCP/IP configurations all we need to do is to execute the following commands (assuming that leds.elf binary file is available through URL: http://dsnet.tu-plovdiv.bg/leds.elf).
That's it. You should now see how both LEDs sequentially changes their state from on to off.
TODO: How to build binaries that returns control to RedBoot when finished.
First, we need to know the exact physical addresses of both LEDs. From EP93xx User's Guide we see that both LEDs are connected to PortE bits 1 and 0 (pp. 28-9 - 28-10). PortE Data Register is mapped to 0x80840020 and PortE Data Direction Register to 0x80840024 respectively. Now we are ready to write a really simple program that toggles the two LEDs continuously:
- Code: Select all
int main() {
unsigned char *portE_DDR;
unsigned char *portE_DR;
unsigned long delay = 1000000L;
unsigned long i;
int x = 0;
portE_DDR = (unsigned char *) 0x80840024;
portE_DR = (unsigned char *)0x80840020;
//printf("address is -> %0X",portE_DDR);
//return 1;
*portE_DDR |= 0x03;
*portE_DR = 0x03;
for(;;) {
for(i=0; i<delay; i++) { x = 123 + 542 * 123; };
*portE_DR = 0x02;
for(i=0; i<delay; i++) { x = 123 + 542 * 123; };
*portE_DR = 0x01;
}
return 0;
}
To build the program above we will use GNUARM toolchain. The exact commands used to compile and link the binary are given bellow:
- Code: Select all
# arm-elf-gcc -O0 -c leds.c
# arm-elf-ld -e main -o leds.elf leds.o
This will produce leds.elf executable with the following file type:
- Code: Select all
# file leds.elf
leds.exe: ELF 32-bit LSB executable, ARM, version 1, statically linked, not stripped
Now we are ready to load and execute the binary on the EP9302 board. To do this we will use the capabilities of the RedBoot to load network files (using FTP, TFTP, or HTTP). Once we have an open RedBoot shell with correct TCP/IP configurations all we need to do is to execute the following commands (assuming that leds.elf binary file is available through URL: http://dsnet.tu-plovdiv.bg/leds.elf).
- Code: Select all
RedBoot> load -h 192.168.32.51 -m http -b 0x00800000 /leds.elf
RedBoot> go 0x00800000
That's it. You should now see how both LEDs sequentially changes their state from on to off.
TODO: How to build binaries that returns control to RedBoot when finished.