assembly - How do I make an ARM source file into a kernel that the Raspberry Pi 3 B will run? -
i inspired this starfox fan game create game using arm assembly on raspberry pi. have looked @ this tutorial series better understanding of mailbox , frame buffer systems. no matter make/cmake use, cannot either of places run on startup because expected run on original raspberry pi. have looked @ valver's bare metal programming tutorial, raspberrypi.org bare metal forums, , countless output source files own c code understand how print graphics on screen , have gotten nowhere. have used x11 library in c code find output arm source file calls c functions (e.g. bl xopendisplay
). if try execute code given @ second link (making sure change base peripheral address 0x3f000000
, video core access 0xc0000000
) while raspbian running, segmentation faults.
i want have assembly source file (say, main.s
) , make binary (say, kernel7.img
or similar) run turn on raspberry pi 3 b.
yes, know making guis in high level languages easier, determined make game operate in arm assembly. here answers helpful in personal project:
- porting code first 2 links run on pi 3 upon startup, bearing in mind produce wrong binaries model.
- tools building custom os can inject assembly code needed, though i'm not sure how plausible is.
- resources learn how make guis in arm assembly can run on latest raspbian without creating segmentation faults or similar errors.
thank you!
baremetal right way go here. baking pi series fine lots of folks have started there, has issues in way. baremetal forum @ raspberrypi.org very good, there pinned thread lots of baremetal information , examples.
vectors.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
notmain.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); }
memmap
memory { ram : origin = 0x8000, length = 0x1000 } sections { .text : { *(.text*) } > ram .bss : { *(.bss*) } > ram }
build
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
on pi-zero remove config.txt, save or rename kernel.img , copy kernel.img , leds blink.
remove c code , branch main add project , there go...
the framebuffer video super easy, 1 mailbox handshake , have base address shove pixels into...
start pi-zero...for pi3 want in aarch32 mode may need config.txt do. part works same if not doing interrupts, if there plenty of baremetal examples show modifications...
Comments
Post a Comment