Robert G. Plantz


About Me

Book Errata

RPi4 gpio

x86-64 Hints


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,0x3f000000
.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-a53
.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 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.