We're using an embedded Raspberry Pi that uses a (I2C) 4x20 LCD (character) instead of HDMI.

Since the boot process can take some time I'd like to get something on the LCD as soon as possible to say we're alive. The existing code I have is C++ using the Wiring Pi library so does not need python or any other scripting.

What is the earliest place in the boot process we could run something to init the LCD (I2C) & where would I need to insert this?

While I've written lots of user level code I'm not familiar with the Linux boot process other than auto running a program as the last thing.

  • 3
    GPIO is available within the initramfs via /sys, I'm guessing you could load the I2C driver there as well. Commented Apr 13, 2019 at 21:53

2 Answers 2


Here's an example of a project which starts custom executables directly from a RAM disk image (/boot/initrd). It's certanly not the earliest place possible, but at least it happens before the root partition is mounted, so this code runs before anything located on the root partition. It's as early as you can get without writing kernel code.

The I2C driver can be built into the kernel, or loaded from the RAM disk using rd.modules_load=i2c_dev kernel command line parameter. Don't forget to include the module and systemd-modules-load.service in the initrd as well, otherwise the module will only be available once the root FS is mounted.

Note that doing this properly may also require you to add hooks to the package manager which rebuild the RAM disk image every time the user installs an update for whatever files you'll have on the RAM disk: kernel modules, systemd, libc, wiringpi, etc. etc.


Raspberry Pi does not use a structured boot loader like grub or lilo or usable U-boot and Berryboot. It is seen as an embedded system and typical for this the boot procedure is very hardware-dependent. I think it's not an easy task to modify it.

To get an idea you may have a look at the Boot flow to find the right place for your insertion.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.