想写个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