OK6410裸机hello,world程序,利用uboot中的printf函数。

本文参考http://blog.csdn.net/eagle_lzt/article/details/6364692编写

贴上自己写的程序做个笔记,大家可以用jlink,或者dnw下载程序。

飞凌提供的uboot源码在“OK6410A官方基础资料2G\Linux-3.0.1\uboot_sourcedode\uboot1.1.6_FORLINX_6410.tgz”中,解压找到system.map

打开搜索printf找到 printf的地址,如图所示。



hello.c:

void (*show)(char*,...) = 0xc7e114a8;

int main(void)
{
        show("hello.world!\n");
        show("hello.linux\n");
        return 0;
}


Makefile:

hello.bin:hello.o
        arm-linux-ld -Ttext 0x50008000 hello.o -o hello.elf
        arm-linux-objcopy -O binary hello.elf hello.bin
        arm-linux-objdump -d hello.elf > hello.dls

hello.o:hello.c
        arm-linux-gcc -c hello.c -o hello.o

clean:
        rm hello.bin hello.o hello.elf hello.dls


反汇编代码:

hello.elf:     file format elf32-littlearm

Disassembly of section .text:

50008000 <main>:
50008000:	e1a0c00d 	mov	ip, sp
50008004:	e92dd800 	push	{fp, ip, lr, pc}
50008008:	e24cb004 	sub	fp, ip, #4	; 0x4
5000800c:	e59f3034 	ldr	r3, [pc, #52]	; 50008048 <main+0x48>
50008010:	e5933000 	ldr	r3, [r3]
50008014:	e59f0030 	ldr	r0, [pc, #48]	; 5000804c <main+0x4c>
50008018:	e1a0e00f 	mov	lr, pc
5000801c:	e12fff13 	bx	r3
50008020:	e59f3020 	ldr	r3, [pc, #32]	; 50008048 <main+0x48>
50008024:	e5933000 	ldr	r3, [r3]
50008028:	e59f0020 	ldr	r0, [pc, #32]	; 50008050 <main+0x50>
5000802c:	e1a0e00f 	mov	lr, pc
50008030:	e12fff13 	bx	r3
50008034:	e3a03000 	mov	r3, #0	; 0x0
50008038:	e1a00003 	mov	r0, r3
5000803c:	e24bd00c 	sub	sp, fp, #12	; 0xc
50008040:	e89d6800 	ldm	sp, {fp, sp, lr}
50008044:	e12fff1e 	bx	lr
50008048:	50010074 	.word	0x50010074
5000804c:	50008054 	.word	0x50008054
50008050:	50008064 	.word	0x50008064


-----------------------------------------

下面的程序是C语言内嵌汇编输出CPSR的状态:

void (*show)(char*,...) = 0xc7e114a8;

int main(void)
{
        unsigned long cpsr;
        __asm__ __volatile__(
                "mrs %0,cpsr \n"
                : "=r"(cpsr)
        );

        show("CPSR = 0x%x\n",cpsr);
        return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值