Beagleboard bare metal "Hello world"
Posted: Fri Feb 03, 2012 7:44 pm
I have a Beagleboard-xm rev C which is what is used in this tutorial http://wiki.osdev.org/ARM_Beagleboard
I'm trying to use a c function to print a simple "Hello world", yet no success.
Here's what I have so far
hello.c
boot.asm
linker.ld
Makefile
Any pointers?
I'm trying to use a c function to print a simple "Hello world", yet no success.
Here's what I have so far
hello.c
Code: Select all
volatile unsigned int * const UART3DR = (unsigned int *)0x49020000;
void puts(const char *s) {
while(*s != '\0') { /* Loop until end of string */
*UART3DR = (unsigned int)(*s); /* Transmit char */
s++; /* Next char */
}
}
void hello() {
puts("Hello, Beagleboard!\n");
}
Code: Select all
.global start
start:
ldr sp, =stack_bottom
bl hello
b .
Code: Select all
ENTRY(start)
MEMORY
{
ram : ORIGIN = 0x80200000, LENGTH = 0x10000
}
SECTIONS
{
.hello : { hello.o(.text) } > ram
.text : { *(.text) } > ram
.data : { *(.data) } > ram
.bss : { *(.bss) } > ram
. = . + 0x5000; /* 4kB of stack memory */
stack_bottom = .;
}
Code: Select all
ARMGNU = arm-linux-gnueabi
AOPS = --warn --fatal-warnings
COPS = -Wall -Werror -O2 -nostdlib -nostartfiles -ffreestanding
boot.bin: boot.asm
$(ARMGNU)-as boot.asm -o boot.o
$(ARMGNU)-gcc-4.6 -c $(COPS) hello.c -o hello.o
$(ARMGNU)-ld -T linker.ld hello.o boot.o -o boot.elf
$(ARMGNU)-objdump -D boot.elf > boot.list
$(ARMGNU)-objcopy boot.elf -O srec boot.srec
$(ARMGNU)-objcopy boot.elf -O binary boot.bin