Chinaunix首页 | 论坛 | 博客
  • 博客访问: 360148
  • 博文数量: 135
  • 博客积分: 425
  • 博客等级: 下士
  • 技术积分: 599
  • 用 户 组: 普通用户
  • 注册时间: 2012-10-19 21:10
文章分类
文章存档

2014年(3)

2013年(79)

2012年(53)

分类: LINUX

2012-10-22 19:56:03



 
   当我们编译u-boot的时候会生成System.map文件,vim System.map,然后查找printf,可以发现printf在u-boot中的运行地址。我们可以利用这个printf打印字符串。
      下面是head.S,text.c和Makefile:
     
       head.S:

点击(此处)折叠或打开

  1. abc:
  2. mov ip,sp
  3. stmfd sp!,{fp, ip, lr, pc}
  4. sub fp, ip, #4
  5. bl test
  6. sub sp, fp, #12
  7. ldmfd sp, {fp, sp, pc}

text.c:

点击(此处)折叠或打开

  1. void (*show)(char *, ...) = 0x57e10660;

  2. void test(void)
  3. {

  4.     show("i love linux.\n");
  5. }

Makefile:
 

点击(此处)折叠或打开

  1. all:
  2. arm-linux-gcc -c head.S test.c
  3. arm-linux-ld -Ttext=0x64000000 -o head.elf led.o test.o
  4. arm-linux-objcopy -O binary head.elf head.bin
  5. cp head.bin /tftpboot
  6. clean:
  7. rm -rf *.elf *.bin *.o

操作方法:
kero > tftp 64000000 head.bin
ERROR: resetting DM9000 -> not responding
dm9000 i/o: 0x18000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 88:88:88:88:88:88
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.100; our IP address is 192.168.1.99
Filename 'led.bin'.
Load address: 0x64000000
Loading: ###
done
Bytes transferred = 32860 (805c hex)
kero > go 64000000
## Starting application at 0x64000000 ...
i love linux.
## Application terminated, rc = 0xE
kero >
阅读(2848) | 评论(0) | 转发(0) |
0

上一篇:ok6410开发板_uart_poll方式

下一篇:oops消息

给主人留下些什么吧!~~