主题 : 请教编写bootloader问题 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 9057
精华: 0
发帖: 13
金钱: 95 两
威望: 37 点
综合积分: 26 分
注册时间: 2009-09-15
最后登录: 2015-09-15
楼主  发表于: 2009-10-05 10:47

 请教编写bootloader问题

想写个bootloader来加深一下理解但是刚开始就卡住了
下面是我写的bootloader的一小段代码,通过下面几个命令生成bin文件
arm-linux-as -o loader_hello.o loader_hello.S
arm-linux-ld -o loader_hello.elf loader_hello.o
arm-linux-objcopy -O binary loader_hello.elf loader_hello.bin
然后用supervivi的d选项下载,然后
sudo ~/bin/usb2ram 30000000 loader_hello.bin
下载完成后开发板的led不亮
是我的程序有问题还是操作有问题呀?

.equ GPBCON, 0x56000010
.equ GPBUP, 0x56000018
.equ GPBDAT, 0x56000014

.global _start

_start:
    /* 中断异常处理*/
    b reset
    ldr pc, undefined_instruction
    ldr pc, software_interrupt
    ldr pc, prefetch_abort
    ldr pc, data_abort
    ldr pc, not_used
    ldr pc, irq
    ldr pc, fiq

undefined_instruction:    .word handle_undefined
software_interrupt:    .word handle_swi
prefetch_abort:    .word handle_prefetchabort
data_abort:    .word handle_data_abort
not_used:    .word handle_not_used
irq:    .word handle_irq
fiq:    .word handle_fiq
    
handle_undefined:
handle_swi:
handle_prefetchabort:
handle_data_abort:
handle_not_used:
handle_irq:
handle_fiq:
    /* something to do*/

reset:
/*************************/
/* 设置cpu为svc32模式      */
/*     mrs r0, cpsr      */
/*     bic r0, r0,          */
/*************************/
    /*disable watch dog timer*/
    ldr r1, =0x53000000
    mov r2, #0x00
    str r2, [r1]
    
    /*disable all inerrupts*/
    mov r1, #0x4a000000
    mov r2, #0xffffffff
    str r2, [r1, #0x08]
    ldr r2, =0x7ff
    str r2, [r1,#0x1c]

    /*initialise system clock*/
    mov r1, #0x4c000000
    mvn r2, #0xff000000
    str r2,[r1, #0x00]
    
    /*1:2:4*/
    mov r1, #0x4c000000
    mov r2, #0x3
    str r2, [r1,#0x14]
    mrc p15, 0, r1, c1, c0, 0
    orr r1,r1, #0xc0000000
    mcr p15, 0, r1, c1, c0, 0
    /*now cpu clock is 400Mhz*/

    ldr r1, =0x4c000000
    ldr r2, =0x0005c011
    str r2, [r1, #0x04]
        
/*all led on*/
    ldr r1,=GPBCON
    ldr r2, =0x55aa
    str r2, [r1]
    ldr r1, =GPBUP
    mov r2, #0xff
    str r2, [r1]
    ldr r1, =GPBDAT
    mov r2, #0x00
    str r2, [r1]

1: b 1b
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2009-10-05 13:49
别浪费你的Jtag
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 9057
精华: 0
发帖: 13
金钱: 95 两
威望: 37 点
综合积分: 26 分
注册时间: 2009-09-15
最后登录: 2015-09-15
2楼  发表于: 2009-10-05 17:05
不会用JTAG,JTAG应该是需要并口吧,我的电脑没有并口
级别: 新手上路
UID: 1330
精华: 0
发帖: 39
金钱: 390 两
威望: 139 点
综合积分: 78 分
注册时间: 2008-08-18
最后登录: 2011-02-07
3楼  发表于: 2009-10-06 22:35
有USB转JTAG的。
级别: 新手上路
UID: 9057
精华: 0
发帖: 13
金钱: 95 两
威望: 37 点
综合积分: 26 分
注册时间: 2009-09-15
最后登录: 2015-09-15
4楼  发表于: 2009-10-07 10:49

 回 3楼(athurg) 的帖子

你用USB的jtag吗,推荐个牌子
买这个东西要注意些什么?
级别: 侠客
UID: 11182
精华: 0
发帖: 69
金钱: 350 两
威望: 70 点
综合积分: 138 分
注册时间: 2009-11-29
最后登录: 2011-11-27
5楼  发表于: 2009-12-19 15:58
好难啊 ,bootloader真难写,看网上改uboot的,一直没看懂呢

努力,
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
6楼  发表于: 2009-12-19 17:52

 回 5楼(圣斗士沙加) 的帖子

不要把bootloader看得很神秘,它本质上也就是个程序,都是用汇编或者C这样的编程语言写的。
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 11786
精华: 0
发帖: 13
金钱: 75 两
威望: 15 点
综合积分: 26 分
注册时间: 2009-12-21
最后登录: 2017-09-13
7楼  发表于: 2009-12-21 20:06