I am lucky enough to have my RPi 2 already, & love the challenge of getting my code to work bare-metal on any new system...
I really want to get all my bare metal code already done for the original RPi, to work on the RPi2, and improve them etc.
e.g I have some fractal demos I would like optimize using the NEON instructions, then try to get that same code to work across all 4 cores =D
So I started with a simple blinking LED program:
Code: Select all
PERIPHERAL_BASE = $3F000000 ; Raspberry Pi 2 Peripheral Base Address GPBASE = $200000 ; $3F200000 GPFSEL1 = $4 ; $3F200004 GPSET0 = $1C ; $3F20001C GPCLR0 = $28 ; $3F200028 org $8000 mov r0,PERIPHERAL_BASE orr r0,GPBASE ; R0 = GPBASE ldr r1,[r0,GPFSEL1] ; R1 = GPFSEL1 mov r2,7 and r1,r2,lsl 18 ; &= 7 << 18 mov r2,1 orr r1,r2,lsl 18 ; |= 1 << 18 str r1,[r0,GPFSEL1] mov r2,r2,lsl 16 ; 1 << 16 Loop: str r2,[r0,GPSET0] mov r1,$100000 WaitA: subs r1,1 bne WaitA str r2,[r0,GPCLR0] mov r1,$100000 WaitB: subs r1,1 bne WaitB b Loop
Along with the latest bootcode.bin & start.elf files.
All I have changed is the Peripheral Base Address from $20000000 to $3F000000, but unfortuantly it does not work atm
I have some questions to ask, in case my understanding of ARM Cortex is not correct:
1. Do I need to change the origin "ORG $8000", e.g does the multi core ARM CPU start code from a different offset?
2. Have any of the GPIO register locations changed from the original locations?
3. Do I need any special config.txt or cmdline.txt options to get the RPi 2 to swing into action?
4. As the Peripheral Base Address has changed to $3F000000
does this mean the Raspberry Pi 2 can not access the whole 1GB region: $00000000..$40000000?
Any help would be much appreciated =D