微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c – 你好世界,裸机Beagleboard

我试图在我的Beagleboard-xm rev上运行一个“hello world”类型的程序. C,通过从程序集调用C puts函数.

到目前为止,我一直在用这个作为参考: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 / minicom相关信息:http://paste.ubuntu.com/829072/

任何指针?

原文地址:https://www.jb51.cc/c/114219.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐