March 12, 2019
With just a few simple steps, you can compile and boot a Raspberry Pi using the Linux kernel mainline source code. Here's a quick tutorial on how to do just that.
This post uses Raspberry Pi model B rev2 as a base, however you can easily adapt it to your board.
Download any Raspbian image from https://www.raspberrypi.org/downloads/raspbian/
unzip 2018-11-13-raspbian-stretch-lite.zip # Check with lsblk what is the device path of your sdcard, using /dev/mmcblk0 just for this example sudo dd if=2018-11-13-raspbian-stretch-lite.img of=/dev/mmcblk0 bs=512M
Insert your SD card into the Raspberry Pi and turn it on. Raspbian will finish its installation.
Once the boot process is complete, turn it off and insert the SD card into your computer again.
sudo apt install gcc-arm-linux-gnueabihf
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git cd linux make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2835_defconfig make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j8 zImage modules dtbs
# Mount the sdcard partitions mkdir -p ../rpi-boot mkdir -p ../rpi-rootfs sudo mount /dev/mmcblk0p1 ../rpi-boot sudo mount /dev/mmcblk0p2 ../rpi-rootfs # Install the modules to the rootfs sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=../rpi-rootfs modules_install # Copy the kernel and the device tree files to the sdcard sudo cp arch/arm/boot/zImage ../rpi-boot sudo cp arch/arm/boot/dts/*.dtb ../rpi-boot # Inform to the firmware which kernel image and device tree to use # You might need to change the device tree according to you board model echo "kernel=zImage" >> ../rpi-boot/config.txt echo "device_tree=bcm2835-rpi-b-rev2.dtb" >> ../rpi-boot/config.txt # Unmount sudo umount ../rpi-boot sudo umount ../rpi-rootfs
That's it! Remove the SD card, plug it in your Raspberry Pi and boot!
Now, just put the previous commands in a bash script (just remember to remove the lines that modifies config.txt as this is only required once), and execute it whenever you want to re-build and re-install the kernel on your sdcard.
If you need to revert to the original kernel, you can always do so by inserting the SD card into your computer, mounting the boot partition and commenting the kernel and device_tree lines from your config.txt
# Uncomment these lines to boot custom kernel #kernel=zImage #device_tree=bcm2835-rpi-b-rev2.dtb
Visit Helen's blog.
Recently, we have been using Perfetto to successfully profile Apitrace traces in crosvm through VirGL renderer. We have now added perfetto…
As part of a project backed by INVEST-AI, a program managed by IVADO Labs, we have developed a multi-stage neural network-based solution…
Did you know you could run a permissively-licensed MTP implementation with minimal dependencies on an embedded device? Here's a step-by-step…
Earlier this year, the Rust compiler gained support for LLVM source-base code coverage. In this post we'll explain how to setup a CI job…
Over the past few months, I've been working on a side project to improve Meson sub-project support. The best stress test is to build projects…
The most complete automated testing and continuous integration tool for the Linux kernel continues to evolve at a rapid pace. Here's a look…