So, I'm building a device involving a raspberry pi (Pi4) and an e-ink display, with SPI communication. I'm wondering what the soonest would be, I could communicate with the display. Main idea here is, to show something on the display as soon as possible, informing user device is actually booting. Since a getty terminal is available very shortly (UART), I assume SPI should also be available pretty much right after a few seconds, once the bcm2711 (or older) is initialized.

Side note: I access SPI directly through mem using go-rpio, and not using the bcm2835 lib (mostly the go-rpio driver is a limited low-level adaptation of the bcm2835 lib), so it requires access to /proc/device-tree/soc/ranges to obtain the mem base range, then access to /dev/mem or /dev/gpiomem to memmap the ranges.

Follow-up question: what's the best way to run my code after boot so I have the earliest possible access: creating a systemd service? what would be the After/Before targets to use?

Edit: added follow-up question

  • perhaps a cheap microcontroller could be added to display the initial image
    – jsotola
    Commented May 30 at 16:15
  • "I'm wondering what the soonest would be ...". Why don't you try it?
    – Seamus
    Commented May 30 at 18:30
  • I did try and the soonest I get is around 20s post power on, which I believe is largely improvable, since I only need to be able to access SPI (not loading anything from disk). I just don't know if I'm overlooking something, since I see the GPIO driver is loaded around 5s in... Would I need to move my code to the /boot/firmware partition?
    – Phil H
    Commented May 31 at 14:24
  • Add a line to /etc/rc.local and by the time the system runs that SPI will be more than alive.
    – Dougie
    Commented May 31 at 17:02
  • I want to take advantage of systemd so the app can be restarted in case of crash and handled properly on shutdown or reboot
    – Phil H
    Commented Jun 2 at 0:29


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.