Hello, World (bare, no libs yet)

Just an update to my previous post about building StrongARM tools under linux... As it turns out the "mysterious" file format the vxWorks boot loader expects is simply "coff-arm-little." After rebuilding the tools, I now have a "Hello, World" program which sends characters out the serial port. It does not use any library calls (e.g., printf). I am now in the process of getting the standard runtime libraries working. This way, I can use printf(). I'll let everyone know when this is working. In the meantime, in case anyone is interested, here's what I did to get it working: 1. Build the tools for arm-unknown-coff. I followed the steps in the CrossGCC FAQ online at http://www.objsw.com/CrossGCC/ and used GCC 2.95.2, binutils 2.9.1, and newlib 1.8.2. Before building the tools, I edited newlib-1.8.2/newlib/configure.host by commenting out both ARM_RDP_MONITOR and ARM_RDI_MONITOR. 2. Here is the program: *************************************************************************/ /* ** UART Definitions */ #define UART_SR 0x90003400 /* UART Status Register Address */ #define TXF 0x00000080 /* Transmit FIFO full bit */ #define RXR 0x00000010 /* Receive FIFO ready (not empty) */ #define UART_CR 0x90003800 /* UART Control Register Address */ #define XIE 0x00000100 /* Transmit interrupt enable bit */ #define RIE 0x00000010 /* Receive interrupt enable bit */ #define UART_DR 0x90003C00 /* UART Data Register Address */ /* ** Forward References */ static void noUartInts(void); static void putchar(int c); static void puts(char *s); static int getchar(void); /* ** Entry Point */ void __main(void) { int c; noUartInts(); puts("Hello, World!\n\r"); puts("\n\r"); puts("Enter characters to be echoed:\n\r"); while(1) { c = getchar(); if(c == '\r') { puts("\n\r"); } else { putchar(c); } } } /* ** Disable UART transmit/receive interrupts */ static void noUartInts(void) { volatile unsigned long *ptrCR; ptrCR = (volatile unsigned long *) UART_CR; *ptrCR &= ~(XIE | RIE); } /* ** Send a single character */ static void putchar(int c) { volatile unsigned long *ptrSR; volatile unsigned long *ptrDR; ptrSR = (volatile unsigned long *) UART_SR; while((*ptrSR & TXF) != 0) ; ptrDR = (volatile unsigned long *) UART_DR; *ptrDR = (unsigned long) c; } /* ** Send a null terminated string */ static void puts(char *s) { int c; while((c = *s++) != '\0') { putchar(c); } } /* ** Get a character */ static int getchar(void) { volatile unsigned long *ptrSR; volatile unsigned long *ptrDR; ptrSR = (volatile unsigned long *) UART_SR; while((*ptrSR & RXR) == 0) ; ptrDR = (volatile unsigned long *) UART_DR; return (int) *ptrDR; } /*************************************************************************/ 3. Here are the commands I used to compile the code: arm-unknown-coff-gcc -I. -nostartfiles -nodefaultlibs \ -fno-builtin -mcpu=strongarm110 -mapcs-32 -mno-sched-prolog \ -fvolatile -Wall -Wstrict-prototypes -O2 -c hw.c -o hw.o arm-unknown-coff-ld -o hw.coff hw.o -X -N -e ___main \ -Ttext 00001000 -Scott
participants (1)
-
Scott C. Karlin