Page 1 of 1

Beagleboard bare metal "Hello world"

Posted: Fri Feb 03, 2012 7:44 pm
by rraf
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

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");
}
boot.asm

Code: Select all

.global start
start:
	ldr sp, =stack_bottom
	bl hello
	b .
linker.ld

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 = .;

}
Makefile

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
Any pointers?

Re: Beagleboard bare metal "Hello world"

Posted: Sat Feb 04, 2012 9:45 am
by brain
So, what happens? Compile error? Link error? Unexpected or no output?...

Re: Beagleboard bare metal "Hello world"

Posted: Sat Feb 04, 2012 10:48 am
by rraf
brain wrote:So, what happens? Compile error? Link error? Unexpected or no output?...
no output

Re: Beagleboard bare metal "Hello world"

Posted: Sat Feb 04, 2012 2:06 pm
by rraf
berkus wrote:Two differences between your code and mine (since you're unable to compare yourself, so there):

Missing while ((com_port->lsr & LSR_THRE) == 0);
And I do byte writes while you do full word writes.

Any or all of these may matter.
I've tried writing one char.
I've tried checking the status for the UART after every char.
I've also tried this http://hardwarefreak.wordpress.com/2011 ... xm-part-2/

Prints nothing.

Regards

Re: Beagleboard bare metal "Hello world"

Posted: Sat Feb 04, 2012 3:01 pm
by rraf
berkus wrote:Does it print anything when you start a different OS? Can you try mine? It certainly does print on my setup.
Yep I've ran Angstrom on the Beagleboard and the ASM example works, though can't get my C code running.

Code: Select all

.equ UART3.BASE,        0x49020000
start:
   ldr r0,=UART3.BASE
   mov r1,#'c'