我想要得到一個'你好世界'類型的程序運行在我的Beagleboard-xm rev。 C,通過從程序集調用C puts
函數。你好世界,裸機Beagleboard
到目前爲止,我一直在使用這個作爲參考:http://wiki.osdev.org/ARM_Beagleboard
這裏是我到目前爲止,但沒有輸出。
的hello.c
volatile unsigned int * const UART3DR = (unsigned int *)0x49020000;
void puts(const char *s) {
while(*s != '\0') {
*UART3DR = (unsigned int)(*s);
s++;
}
}
void hello() {
puts("Hello, Beagleboard!\n");
}
boot.asm
.global start
start:
ldr sp, =stack_bottom
bl hello
b .
linker.ld
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文件
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
只需使用ASM文件中像這樣的作品。
.equ UART3.BASE, 0x49020000
start:
ldr r0,=UART3.BASE
mov r1,#'c'
這裏有一些的BeagleBoard /小型機相關信息:http://paste.ubuntu.com/829072/
任何指針? :)
我也試過
void hello() {
*UART3DR = 'c';
}
我使用的小型機,並通過YMODEM發送的文件,然後我試圖與運行:
go 0x80200000
硬件和軟件控制minicom中的流量關閉。
它的工作原理,謝謝。現在我需要弄清楚我做錯了什麼。這是第一塊代碼!= ASM,它實際上打印了一些東西。 – farnsworth 2012-02-05 11:26:43
如果有人對此有任何疑問,請參閱此處。我修改了Makefile CROSS_COMPILE = arm-none-linux-gnueabi,因爲我正在使用linux的codesourcery toolchain。使用loady通過ymodem加載文件,而de memmap有它的原點在0x82000000我去agead並運行它與去0x80200000即使您將原點設置爲0x82000000。 – farnsworth 2012-02-05 11:28:45
arm-none-linux-gnueabi和arm-none-eabi都來自codesourcery,如果你不做任何系統調用,那麼兩者都可以工作。據推測,如果你使用gcclib調用(使用除法或模或類似的東西),非linux版本會更好。 – 2012-02-05 11:52:51