我跟随剑桥大学计算机实验室的树莓派裸机程序编写教程编写树莓派3的裸机程序,工具是arm-none-eabi-as(YARGATO),makefile我用的他们的,本机操作系统Windows10,当我编译完成时,出现了图片中的故障,并且我将生成的kernel.img拷到SD卡上时竟无法点亮小灯。我的功能是实现在子函数里的,必须要把函数里的代码拿出来才能生效,不懂了?怀疑就是图片中的原因,求各位高手解答。附代码如下:
.arch armv6
.align 2
.globl _start
.section .init
_start:
b main
main:
mov sp,#0x8000
mov r0,#0x9
mov r1,#1
bl SetGpioFunction
mov r0,#0x9
mov r1,#1
bl SetGPIO
loop$:
b loop$
.globl SetGpioFunction @function
SetGpioFunction:
cmp r0,#0x28
cmpls r1,#0x7
movhi pc,lr
push {lr}
mov r2,r0
ldr r0,=0x3f200000
floop:
cmp r2,#0x9
subhi r2,#0xa
addhi r0,#0x4
bhi floop
add r2,r2,r2,lsl #1
lsl r1,r2
str r1,[r0]
pop {pc}
.globl SetGPIO @function
SetGPIO:
cmp r0,#0x28
movhi pc,lr
push {lr}
mov r2,r0
ldr r0,=0x3f200000
lsl r3,r2,#5
lsl r3,#2
add r0,r3
and r2,#0x1f
mov r3,#1
lsl r3,r2
cmp r1,#0
streq r3,[r0,#0x28]
strne r3,[r0,#0x1c]
pop {pc}
kernel.ld
/******************************************************************************
* kernel.ld
* by Alex Chadwick
*
* A linker script for generation of raspberry pi kernel images.
******************************************************************************/
SECTIONS {
/*
* First and formost we need the .init section, containing the code to
* be run first. We allow room for the ATAGs and stack and conform to
* the bootloader's expectation by putting this code at 0x8000.
*/
.init 0x8000 : {
*(.init)
}
/*
* Next we put the rest of the code.
*/
.text : {
*(.text)
}
/*
* Next we put the data.
*/
.data : {
*(.data)
}
/*
* Finally comes everything else. A fun trick here is to put all other
* sections into this section, which will be discarded by default.
*/
/DISCARD/ : {
*(*)
}
}