# Update package repositories sudo apt update # Install packages required for Yocto build sudo apt install -y gawk wget git diffstat unzip texinfo gcc build-essential \ chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils \ iputils-ping python3-git python3-jinja2 python3-subunit zstd liblz4-tool file \ locales libacl1 libssl-dev libncurses5-dev u-boot-tools # Generate locale sudo locale-gen en_US.UTF-8git clone git://git.yoctoproject.org/poky (this really takes time)cd poky git checkout kirkstoneEdit your local.conf file and add the desired package:
IMAGE_INSTALL += "recipe-name" For example, to add usbutils for lsusb, use:
IMAGE_INSTALL += "usbutils" Alternatively, you can append it:
IMAGE_INSTALL_append = " usbutils" - bitbake: Contains all Python scripts used by the
bitbakecommand. - documentation: Source files for Yocto Project documentation.
- meta: Contains the core metadata.
- meta-poky: Configuration for the Poky reference distribution.
- meta-skeleton: Template recipes for BSP and kernel development.
- meta-yocto-bsp: Maintains BSPs for the Beaglebone, EdgeRouter, and generic IA machines.
- scripts: Scripts for environment setup, development tools, and flashing generated images.
- LICENSE: The license under which Poky is distributed (GPLv2 and MIT).
- Clone the Raspberry Pi meta-layer:
git clone git://git.yoctoproject.org/meta-raspberrypi cd meta-raspberrypi git checkout kirkstone- meta-openembedded: Required dependencies for the Raspberry Pi layer.
git clone git://git.openembedded.org/meta-openembedded cd meta-openembedded git checkout kirkstonemeta-oemeta-multimediameta-networkingmeta-python
~/embd_linux/ ├── poky ├── meta-raspberrypi └── meta-openembedded - Run the environment script to set up the Yocto Environment and create the build directory:
source poky/oe-init-build-env build_pi- Add
meta-openembeddedlayers (meta-oe, meta-multimedia, meta-networking, meta-python) and themeta-raspberrypilayer tobuild_pi/conf/bblayers.conf.
BBLAYERS ?= " \ ${TOPDIR}/../poky/meta \ ${TOPDIR}/../poky/meta-poky \ ${TOPDIR}/../poky/meta-yocto-bsp \ ${TOPDIR}/../meta-openembedded/meta-oe \ ${TOPDIR}/../meta-openembedded/meta-multimedia \ ${TOPDIR}/../meta-openembedded/meta-networking \ ${TOPDIR}/../meta-openembedded/meta-python \ ${TOPDIR}/../meta-raspberrypi \ "- Configure local.conf for Raspberry Pi 3: Edit the build_pi/conf/local.conf file to set up the Raspberry Pi and enable UART, SPI, I2C, SSH, and Ethernet:
# Set the target machine MACHINE = "raspberrypi3" # Enable UART ENABLE_UART = "1" # Enable SSH server EXTRA_IMAGE_FEATURES += " ssh-server-openssh" # Include Ethernet, SPI, and I2C tools IMAGE_INSTALL += " i2c-tools spi-tools python3-serial dhcp-client iproute2" # Add support for systemd DISTRO_FEATURES += " systemd" VIRTUAL-RUNTIME_init_manager = "systemd" BB_GIT_CLONE_FOR_SRC_URI = "1" BB_FETCH_TIMEOUT = "60000" GIT_CONFIG[user.timeout] = "60000" BB_GIT_SHALLOW = "1" GIT_SHALLOW_pn-linux-raspberrypi = "1" BB_NUMBER_THREADS = "8" PARALLEL_MAKE = "-j8" - To see available images:
ls ../meta-raspberrypi/recipes-*/images/- rpi-hwup-image.bb: Based on
core-image-minimal. - rpi-basic-image.bb: Based on
rpi-hwup-image.bbwith added features (e.g., splash screen). - rpi-test-image.bb: Based on
rpi-basic-image.bb, includes packages frommeta-raspberrypi.
bitbake core-image-minimal- Broadcom BCM2837
- CPU: 1.2GHz 64-bit quad-core ARMv8 Cortex-A53
- GPU: Broadcom VideoCore IV
- SDRAM: 1024 MiB
- GPU Core: First stage bootloader, stored in ROM on the SoC.
- bootcode.bin
- start.elf
- config.txt
- cmdline.txt
- kernel7.img
The built images can be found at:
tmp/deploy/images/raspberrypi3/core-image-minimal-raspberrypi3-20241004105158.rootfs.wic.bz2 This variable adds extra free space to the root filesystem image. The value is specified in kilobytes.
For example, to add an additional 4 GB of space:
IMAGE_ROOTFS_EXTRA_SPACE = "4194304"