向量。s
.globl _start
_start:
mov sp,#0x8000
bl notmain
hang: b hang
.globl PUT32
PUT32:
str r1,[r0]
bx lr
.globl GET32
GET32:
ldr r0,[r0]
bx lr
.globl dummy
dummy:
bx lr
诺曼。c
extern void PUT32 ( unsigned int, unsigned int );
extern unsigned int GET32 ( unsigned int );
extern void dummy ( unsigned int );
#define SYSTIMERCLO 0x20003004
#define GPFSEL3 0x2020000C
#define GPFSEL4 0x20200010
#define GPSET1 0x20200020
#define GPCLR1 0x2020002C
//0x01000000 17 seconds
//0x00400000 4 seconds
//#define TIMER_BIT 0x01000000
#define TIMER_BIT 0x00400000
int notmain ( void )
{
unsigned int ra;
ra=GET32(GPFSEL4);
ra&=~(7<<21);
ra|=1<<21;
PUT32(GPFSEL4,ra);
while(1)
{
PUT32(GPSET1,1<<(47-32));
while(1)
{
ra=GET32(SYSTIMERCLO);
if((ra&=TIMER_BIT)==TIMER_BIT) break;
}
PUT32(GPCLR1,1<<(47-32));
while(1)
{
ra=GET32(SYSTIMERCLO);
if((ra&=TIMER_BIT)==0) break;
}
}
return(0);
}
MEMORY
{
ram : ORIGIN = 0x8000, LENGTH = 0x1000
}
SECTIONS
{
.text : { *(.text*) } > ram
.bss : { *(.bss*) } > ram
}
建筑
arm-none-eabi-as --warn --fatal-warnings vectors.s -o vectors.o
arm-none-eabi-gcc -Wall -Werror -O2 -nostdlib -nostartfiles -ffreestanding -c notmain.c -o notmain.o
arm-none-eabi-ld vectors.o notmain.o -T memmap -o notmain.elf
arm-none-eabi-objdump -D notmain.elf > notmain.list
arm-none-eabi-objcopy notmain.elf -O binary kernel.img
在pi为零时,删除任何配置。txt,保存或重命名任何内核。img并复制此内核。img和LED将闪烁。
删除c代码并将其分支到主代码中,将其添加到项目中,就这样。。。
从pi零开始。。。对于pi3,您将希望处于aarch32模式,您可能需要配置。txt要做的事。如果你不做任何中断,它在很大程度上是一样的,如果你做了,那么有很多裸体的例子来向你展示修改。。。