Beagleboard bare metal "Hello world"

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
rraf
Posts: 4
Joined: Fri Feb 03, 2012 7:37 pm

Beagleboard bare metal "Hello world"

Post 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?
User avatar
brain
Member
Member
Posts: 234
Joined: Thu Nov 05, 2009 5:04 pm
Location: UK
Contact:

Re: Beagleboard bare metal "Hello world"

Post by brain »

So, what happens? Compile error? Link error? Unexpected or no output?...
rraf
Posts: 4
Joined: Fri Feb 03, 2012 7:37 pm

Re: Beagleboard bare metal "Hello world"

Post by rraf »

brain wrote:So, what happens? Compile error? Link error? Unexpected or no output?...
no output
rraf
Posts: 4
Joined: Fri Feb 03, 2012 7:37 pm

Re: Beagleboard bare metal "Hello world"

Post 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
rraf
Posts: 4
Joined: Fri Feb 03, 2012 7:37 pm

Re: Beagleboard bare metal "Hello world"

Post 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'
Post Reply