謝謝版主,在試用那個USB-boot前, 我想先用SD卡運行一遍自己的代碼, 再用USB-boot工具下載並運行自己的代碼,來檢查一下運行結果是否相同, 來判斷自己是否使用USB-boot正確。
測試代碼是點亮Cubieboard 2雙卡版上的LED1 和LED2。然而,從SD卡啟動時, 未能點亮兩個LED。代碼應該沒問題, 但反編繹時, 內容出現問題。
r1應該是儲存設定PH20和PH21引腳(控制LED1和LED2開關)的暫存器地址, 但反編內容顯示, 它把PC加上offset輸入進r1, PC加上offset的數值不等於設定引腳的暫存器地址。
請問那個地方出現問題? 我把代碼start.S, 反編內容和Makefile列出來,望高手指點,謝謝
start.S- .globl _start
- // I/O register base address 0x01C20800
- _start:
- // 设置PH_CFG2的bit[16:22],配置PH20,PH21引脚为输出功能
- ldr r1, =0x01C20904
- ldr r0, =0x00110000
- str r0, [r1]
- mov r2, #0x1000
- led_blink:
- // 设置PH_DAT的bit[20:21],使PH20,PH21引脚输出低电平,LED亮
- ldr r1, =0x01C2090C
- mov r0, #0
- str r0, [r1]
- // 延时
- bl delay
- // 设置PH_DAT的bit[20:21],使PH20,PH21引脚输出高电平,LED灭
- ldr r1, =0x01C2090C
- mov r0, #0x00f00000
- str r0, [r1]
- // 延时
- bl delay
- sub r2, r2, #1
- cmp r2,#0
- bne led_blink
- halt:
- b halt
- delay:
- mov r0, #0x100000
- delay_loop:
- cmp r0, #0
- sub r0, r0, #1
- bne delay_loop
- mov pc, lr
复制代码 反編繹內容
- led.elf: file format elf32-littlearm
- Disassembly of section .text:
- 00000000 <_start>:
- 0: e59f104c ldr r1, [pc, #76] ; 54 <delay_loop+0x10>
- 4: e3a00811 mov r0, #1114112 ; 0x110000
- 8: e5810000 str r0, [r1]
- c: e3a02a01 mov r2, #4096 ; 0x1000
- 00000010 <led_blink>:
- 10: e59f1040 ldr r1, [pc, #64] ; 58 <delay_loop+0x14>
- 14: e3a00000 mov r0, #0
- 18: e5810000 str r0, [r1]
- 1c: eb000007 bl 40 <delay>
- 20: e59f1030 ldr r1, [pc, #48] ; 58 <delay_loop+0x14>
- 24: e3a0060f mov r0, #15728640 ; 0xf00000
- 28: e5810000 str r0, [r1]
- 2c: eb000003 bl 40 <delay>
- 30: e2422001 sub r2, r2, #1
- 34: e3520000 cmp r2, #0
- 38: 1afffff4 bne 10 <led_blink>
- 0000003c <halt>:
- 3c: eafffffe b 3c <halt>
- 00000040 <delay>:
- 40: e3a00601 mov r0, #1048576 ; 0x100000
- 00000044 <delay_loop>:
- 44: e3500000 cmp r0, #0
- 48: e2400001 sub r0, r0, #1
- 4c: 1afffffc bne 44 <delay_loop>
- 50: e1a0f00e mov pc, lr
- 54: 01c20904 biceq r0, r2, r4, lsl #18
- 58: 01c2090c biceq r0, r2, ip, lsl #18
- Disassembly of section .ARM.attributes:
- 00000000 <.ARM.attributes>:
- 0: 00001e41 andeq r1, r0, r1, asr #28
- 4: 61656100 cmnvs r5, r0, lsl #2
- 8: 01006962 tsteq r0, r2, ror #18
- c: 00000014 andeq r0, r0, r4, lsl r0
- 10: 412d3705 teqmi sp, r5, lsl #14
- 14: 070a0600 streq r0, [sl, -r0, lsl #12]
- 18: 09010841 stmdbeq r1, {r0, r6, fp}
- 1c: Address 0x0000001c is out of bounds.
复制代码 Makefile- CROSS_COMPILE=arm-linux-gnueabihf-
- AS = $(CROSS_COMPILE)as
- LD = $(CROSS_COMPILE)ld
- CC = $(CROSS_COMPILE)gcc
- OBJCOPY = $(CROSS_COMPILE)objcopy
- OBJDUMP = $(CROSS_COMPILE)objdump
- led.bin: start.o
- $(LD) -Ttext 0x0 -o led.elf $^
- $(OBJCOPY) -O binary led.elf led.bin
- $(OBJDUMP) -D led.elf > led_elf.dis
-
- %.o : %.S
- $(CC) -o $@ $< -c
复制代码
|