I’m assuming Linux kernel.
Pull the kernel and build one. Try building a kernel for Raspberry Pi from upstream instructions. Get a small i2c device and check out its driver source code. Make a small i2c driver if necessary.
Check out the kernel logs for the boot up sequence on the Raspberry Pi up to the userspace.