Yocto for Raspberry Pi 5 Part 2 (Flashing and Inspection)
Requirements
- Built image for Raspberry Pi 5 (from Part 1)
- Raspberry Pi 5 and MicroSD card or Compute Module with eMMC
- Hardware to write to MicroSD or eMMC
- Software to write to MicroSD or eMMC
- Monitor, keyboard, cables, etc. for Raspberry Pi 5
Flashing
We need to find our created image which should be inside build/tmp/deploy/images/raspberrypi5 and can be found with the following command:
ls -lh | grep wic.bz2
We should see two files. One will look like core-image-base-raspberrypi5.rootfs-##############.wic.bz2 where the # will represent the build date and time, and the other will be a link to that file. The compressed .bz2 file is roughly 75MiB at the time of this writing. Depending on your operating system, it’ll be easier to flash directly to a target device (Linux) or copy it over to the operating system directory then write onto a MicroSD or to the eMMC of a compute module.
Linux:
From inside build/tmp/deploy/images/raspberrypi5, the following command will write the uncompressed contents of the .bz2 file to the root of a MicroSD card at /dev/sdA. You may need to change this to sdB, sdC, etc. depending on your computer configuration. Note that we’re writing directly to sdA and not a partition. The data contained in the .bz2 has everything needed including partition tables.
bzcat core-image-base-raspberrypi5.rootfs.wic.bz2 | sudo dd of=/dev/sdA bs=4M status=progress oflag=sync
WSL on Windows:
Make a directory in yocto-rpi5-01 called wic-images. From inside /build/tmp/deploy/images/raspberrypi5, run the following command:
bzcat core-image-base-raspberrypi5.rootfs.wic.bz2 > ../../../../../wic-images/core-image-base-raspberrypi5.rootfs.wic
This is easier than trying to uncompress the .bz2 file, and we won’t have to deal with the timestamp in the name of the file. From inside wic-images, let’s inspect the file:
ls -lh
We should see one file of size of roughly 375M. That’s a heck of a lot smaller than standard Raspberry Pi operating system images! Anyway, copy it from here to your machine. Here, I’m copying it to my D: drive which is mounted at /mnt/d, BUT REMEMBER TO INCLUDE A TRAILING slash!
cp core-image-base-raspberrypi5.rootfs.wic /mnt/d/
Use an image writer such as Raspberry Pi Imager to write the .wic file to the MicroSD card or eMMC.
Booting and Inspection
Our experimental Raspberry Pi 5 does not have UART or SSH enabled, so connect it to a monitor and keyboard. We should see the following message on the terminal screen once it has fully booted:
Poky (Yocto Project Reference Distro) 5.0.19 raspberrypi5 /dev/tty1
Log in as root with no password and try the command nano which will not work. The command vi will launch the software; type :q to quit. Let’s determine our initialization software:
readlink -f /sbin/init
The default installation will use /sbin/init.sysvinit as the system init. In the next section, will change it to systemd to more closely match Debian and to see where the configuration is handled. We will also modify the configuration to pull and install nano during image creation.