I'm attempting this Rust, but the code is segfaulting:
unsafe {
const PERIPH_BASE: u32 = 0xFE000000;
const GPIO_BASE: u32 = PERIPH_BASE + 0x00200000;
// Turn on pin GPIO 24
ptr::write_volatile(GPIO_BASE as *mut u32, 1 << 24);
}
I'm suspicious this is due to using the wrong address. The only info on the subject I've found is a RP forum post. I'm unable to find info in the RP4 datasheet, and can't find a manual for the Broadcom chipset.
I'm running this code on Raspian on a Raspberry Pi SBC. I'm attempting to generalize the code to make it easier to port to true embedded later, hence why I am avoiding libraries.
I've looked through rppal and embedded-hal, but was surprised to not find the solution. I've looked through every file in the gpio module's code. mem.rs and ioctl.rs look the closest, but I've been unable to find it.