wxs
Posts: 31
Joined: Wed Dec 04, 2019 9:01 am

gpio base address on RPi 4

Fri Jan 10, 2020 10:06 am

Hi, i just started with bare metal on RPi 4 (actually just started with RPi). I got this code from a tutorial video

Code: Select all

MOV R0 0xXX00 0000
MOV R1 0x0020 0000
ORR R0 R0 R1   //R0 holds the gpio base address 0xXX200000 , for XX I tried 20, 7E
MOV R1 0x0020 0000
STR R1 R0 04  //store 00200000 at address 0xXX200004, set GPIO17 (pin11 on the header) to be an output
MOV R1 0x0002 0000
STR R1 R0 1C  // set gpio17 bit   // I used the bcm2835 arm peripherals.pdf for the register relations
B -2   // inf loop
I wrote those instructions in HEX using a hex editor and saved as kernel7l.img and replaced all the kernal files with it on the raspbian sd card (boot drive). I wish to see pin 11 go high after power up and failed without doubt.
Is there anything wrong with the code, algorithm and what should be the GPIO base address? BTW, i can't find any bare metal tutorial specially made for RPi4.
Thanks in advance

wxs
Posts: 31
Joined: Wed Dec 04, 2019 9:01 am

Re: gpio base address on RPi 4

Tue Jan 14, 2020 9:16 am

Sloved, RPi 4 peri base is 0xFE000000, and GPIO base is 0xFE200000

Return to “Bare metal, Assembly language”