Preparing a release configuration Yocto image (for Raspberry Pi)

In an attempt to build a small image for an application running on Yocto and Raspberry Pi I found the following things helpful:

    IMAGE_LINGUAS = " "


I don't need support for any additional languages.

    IMAGE_FEATURES += "read-only-rootfs"


For my application fixed content and therefore read-only rootfs are fine. I'd imagine this could help reduce the notorious sd-card failures as well.

IMAGE_INSTALL += "\

    packagegroup-core-boot \

    kernel-module-xxx \

    busybox-udhcpc \

    ntpdate \

    ncurses \

    "


For a networked application, I just need to be able to boot, get an IP address and time. Then use a specific kernel driver, no need to install them all. Surprisingly, mDNS avahi seems to be missing dependency declaration to ncurses. 

IMAGE_ROOTFS_SIZE="0"

IMAGE_OVERHEAD_FACTOR="1.15"

IMAGE_ROOTFS_EXTRA_SPACE="1"


Since the rootfs is read-only, it's there's little need for extra space in there. These were the setting that worked fine for me.

RPI_KERNEL_DEVICETREE_OVERLAYS = ""

RPI_KERNEL_DEVICETREE ?= " \

    bcm2710-rpi-3-b.dtb \

    bcm2710-rpi-3-b-plus.dtb \

    bcm2711-rpi-4-b.dtb \

    bcm2710-rpi-cm3.dtb \

    bcm2711-rpi-cm4.dtb \

    "

No need to have all the possible dtb overlays on the boot partition. Just explicitly list the models that need to be supported.

WKS_FILE = "sdimage-xxx.wks"


part /boot --source bootimg-partition --ondisk mmcblk0 --fstype=vfat --label boot --active --align 128 --overhead-factor 1.1

part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --label root --align 128


Use a custom kickstart file to minimize boot partition size and lay out partitions tightly on the card.

SERIAL_CONSOLES_CHECK = ""

SERIAL_CONSOLES = ""

USE_VT = "0"

Disabling run time serial consoles check is required for the read-only rootfs, but disabling consoles sure reduces attack surface and might also save some space as well.

DISTRO_FEATURES="ipv4 zeroconf vfat sysvinit"

MACHINE_FEATURES:remove="apm usbhost keyboard vfat ext2 screen touchscreen alsa bluetooth wifi sdio"

NO_RECOMMENDATIONS = "1"


This was a sufficient set of distro features for my application. Also reducing the set of machine features eliminated quite a bit of content being pulled into the image. Your mileage will vary here.

I hope this helps you reduce your image size. I'm sure I'll be returning here as I've surely forgotten many of these by the time I need to prepare a release configuration the next time.

Comments

Popular posts from this blog

iMovie event library on a network drive, NAS

Proxmox PCIe passthrough on HP gen8 - failed to set iommu for container

Backup and restore observium