我正在为 Raspberry Pi 3 进行裸机编程。我已经能够使用教程来闪烁灯,现在我正在尝试在 Rust 中做同样的事情。
我的项目包含以下文件:
main.rs
#![no_main]
#![no_std]
#![feature(global_asm)]
global_asm!(include_str!("start.s"));
#[panic_handler]
fn on_panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
}
start.s
.section .init
.global _start
.equ BASE, 0x3f200000 //Base address
.equ GPFSEL2, 0x08 //FSEL2 register offset
.equ GPSET0, 0x1c //GPSET0 register offset
.equ GPCLR0,0x28 //GPCLR0 register offset
.equ SET_BIT3, 0x08 //sets bit three b1000
.equ SET_BIT21, 0x200000 //sets bit 21
.equ COUNTER, 0xf0000
_start:
ldr x0, =BASE
ldr x1, =SET_BIT3
str x1, [x0, #GPFSEL2]
ldr x1, =SET_BIT21
str x1, [x0, #GPSET0]
当我为 aarch64-unknown-none 编译它时,我得到以下输出:
0000000000008000 <_start>:
8000: d2a7e400 mov x0, #0x3f200000 // #1059061760
8004: d2800101 mov x1, #0x8 // #8
8008: f9000401 str x1, [x0, #8]
800c: d2a00401 mov x1, #0x200000 // #2097152
8010: f801c001 stur x1, [x0, #28]
Disassembly of section .comment:
0000000000000000 <.comment>:
0: 6b6e694c .inst 0x6b6e694c ; undefined
4: 203a7265 .inst 0x203a7265 ; undefined
8: 20444c4c .inst 0x20444c4c ; undefined
c: 302e3231 adr x17, 5c651 <_start+0x54651>
10: Address 0x0000000000000010 is out of bounds.
然后我使用该aarch64-none-elf-objcopy --strip-all -O binary $(KERNEL_ELF) kernel.img
命令制作我复制到 SD 卡上的内核文件。
LED 不闪烁。是否有一个原因?如何进行故障排除?