User Tools

Site Tools


newer_raspberry_pis_with_older_sd_cards_and_distributions_without_support

Newer raspberry pis with older SD cards and distributions without support

General method for changing the kernel in any RPi SD Card

The general methodology is as follows:

  1. Get the RPi booting files from an official source. This should contain the kernels, dtbs, start.elfs overlays, kernel modules and many more.
  2. Boot both SD partitions (boot and root).
  3. Replace the corresponding kernel.img files, dtbs, start.elfs, overlays in the boot partition. And the kernel modules in the root partition

Details

Get the pre-compiled kernel and boot files from here:

https://github.com/raspberrypi/firmware/

You can choose a tag version to be able to select a particular kernel version. Remember: newer RPis hardware require newer builds and therefore: newer kernels.

You can build your own kernel with:

https://www.raspberrypi.com/documentation/computers/linux_kernel.html

It may still miss the proprietary booting code

You must be sure to copy the correct kernel image to the boot partition. You have to take two things into consideration: the raspberry pi hardware version and if you need it in 32 or 64bits. For this you can use the table in https://www.raspberrypi.com/documentation/computers/linux_kernel.html#natively-build-a-kernel to select the correct kernel image filename.

For example:

  1. For a Raspberry PI Zero 2 W running at 64bits: “kernel8.img”
  2. For a Raspberry PI Zero 2 W running at 32bits: “kernel7.img”
  3. For a Raspberry PI 5 running at 64bits: “kernel_2712.img”

Depending on the selected kernel you have to use a different kernel modules variety:

  • For kernel.img: use x.w.z+ (with + at the end)
  • For kernel7.img: use x.w.z-v7+
  • For kernel7l.img: use x.w.z-v7l+
  • For kernel8.img: use x.w.z-v8+
  • For kernel_2712.img: use x.w.z-v8-16k+

RPi 5 in Ubuntu Jammy

I need to run Ubuntu Jammy in a RPi5 because we need ROS2 humble. Jammy is not officially supported in RPi5.

Method 1: Replace files

  • Mount both SD card partitions
  • In boot partition copy all dtbs, start elfs and other files except the kernel image files
  • Select the correct kernel image file for your device and copy this file over vmlinuz file
  • Copy the corresponding modules directory to the root partition /lib/modules directory
  • When upgrading Ubuntu it may overwrite vmlinuz, Replace it from vmlinuz.bak after the upgrade.

Method 2: Generate a custom completely new image

Use: https://github.com/pyavitz/rpi-img-builder to generate a new image

  • It only works in a native Ubuntu Jammy machine. It doesn't work in nspawn container nor in debian
  • It can generate several debian/ubuntu varieties
  • The generated image is missing the package resolvconf necessary for DNS resolving. Use nmcli to configure the network. Create /etc/resolv.conf with a proper nameserver entry and install resolvconf as soon as possible.
  • In this method Ubuntu doesn't try to overwrite vmlinuz (apparently)

Steps:

  1. make list (to see the name of the board to use). In case of RPI 5: bcm2712
  2. make ccompile (install ubuntu dependencies)
  3. make config (configuration)
  4. make all board=bcm2712

It will generate an img file

RPi zero 2 W with motioneyeos 2020

MotionEyeOs doesn't support RPIZ2W. I already have an SD-Card with a security camera configured for a RPiZW.

This MotionEyeOs uses broadcom UART, I2C and GPIO. It also uses the camera and wifi interfaces.

Modification steps

The boot partition in this is too small for the new extra files that need to be added. It must be increased. Also, The proper procedure is:

  1. Store the image from the SD card to disk
  2. Use pishrink.sh to reduce this image to its minimum https://github.com/Drewsif/PiShrink
  3. Store the image back to the SD card
  4. Using CFdisk increase the boot partition and the root partition. Thanks to the pishrink script there are free gaps for this two partitions for expanding. Use them.
  5. To expand the boot partition use fatresize. “-i” to find the maximum size.
  6. To expand the root partition use resize2fs
  7. Because motioneyeos is very old, it need a v5 kernel. Use the 1.20220118 version from https://github.com/raspberrypi/firmware/ for getting the firmware and kernel files.
  8. In the boot partition replace all files including kernel.img and kernel7.img from the repo.
  9. In the root partition copy over all the 5.10.92-v7+ kernel module files to /lib/modules
  10. Boot!
newer_raspberry_pis_with_older_sd_cards_and_distributions_without_support.txt · Last modified: 2024/07/29 17:01 by memeruiz