Robert G. Plantz
Change periperhals address in ARM book
The peripherals base memory address is different on the Raspberry Pi 4, which requires a modification in Listing 19.1.1 in the book. Change
.equ PERIPH,0x3f000000to
.equ PERIPH,0xfe000000
The Raspberry Pi 4 uses a different model of the ARM processor. In Listing 19.1.1 in the book. Change
.cpu cortex-a53to
.equ cortex-a72
A common mistake when running this program is forgetting to use sudo
If you wish to check the location of the peripherals address on your Raspberry Pi, you can write a C program to do that. This is discussed at https://www.raspberrypi.org/documentation/hardware/raspberrypi/peripheral_addresses.md. Here's the program I used:
/* periphAddr.c
* Shows where periperhal memory addresses start
* Compile with:
* gcc -I/opt/vc/include -L/opt/vc/lib -lbcm_host -o periphAddr periphAddr.c
*/
#include <stdio.h>
#include <bcm_host.h>
int main(void)
{
unsigned int theAddress;
theAddress = bcm_host_get_peripheral_address();
printf("The peripherals start at: 0x%x\n", theAddress);
return 0;
}
I wish to thank Gerald Pechoc for pointing this issue out to me.