From e43af1e3a6d04231129bf543b3be9ff01fafd26d Mon Sep 17 00:00:00 2001 From: Allan Xavier Date: Fri, 30 Dec 2022 09:40:55 +0000 Subject: [PATCH] rpi-eeprom: Add recipe for eeprom update/configuration This recipe will allow yocto images to support configuring and updating the bootloader on Raspberry Pi 4 boards. So far this recipe just includes the commands and firmware with no automation for updates. Note that this depends on nvmem-rmem support either built into the kernel or as a module. If that is not part of the kernel the scripts will error out suggesting that the vcgencmd command from the userland package is missing. Whilst using vcgencmd from the userland package does work, it would lead to a conflict with the mesa backend for graphics, so using the kernel interface is recommended. Co-authored-by: Maciej Pijanowski Signed-off-by: Allan Xavier --- ...eprom-update-when-using-busybox-find.patch | 36 +++++++++++ recipes-bsp/rpi-eeprom/rpi-eeprom_git.bb | 64 +++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 recipes-bsp/rpi-eeprom/files/0001-Fix-rpi-eeprom-update-when-using-busybox-find.patch create mode 100644 recipes-bsp/rpi-eeprom/rpi-eeprom_git.bb diff --git a/recipes-bsp/rpi-eeprom/files/0001-Fix-rpi-eeprom-update-when-using-busybox-find.patch b/recipes-bsp/rpi-eeprom/files/0001-Fix-rpi-eeprom-update-when-using-busybox-find.patch new file mode 100644 index 0000000..b85be19 --- /dev/null +++ b/recipes-bsp/rpi-eeprom/files/0001-Fix-rpi-eeprom-update-when-using-busybox-find.patch @@ -0,0 +1,36 @@ +From 55ca589ab9e6e719c1e1f9fc72997d1643d28fe3 Mon Sep 17 00:00:00 2001 +From: Allan Xavier +Date: Thu, 12 Jan 2023 12:08:55 +0000 +Subject: [PATCH] Fix rpi-eeprom-update when using busybox find + +The busybox implementation of find does not detect recursive nested +symlinks, this results in it finding multiple instances of of_node +matching -samefile, the result of which then fails the -e path test. + +The of_node symlink we're tyring to find should match the path +/sys/bus/nvmem/devices/*/of_node so just limit the find depth to 3 as +there's no point searching deeper than that. + +Signed-off-by: Allan Xavier + +Upstream-Status: Backport [https://github.com/raspberrypi/rpi-eeprom/commit/55ca589ab9e6e719c1e1f9fc72997d1643d28fe3] +--- + rpi-eeprom-update | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/rpi-eeprom-update b/rpi-eeprom-update +index 79eb3bf..cb25316 100755 +--- a/rpi-eeprom-update ++++ b/rpi-eeprom-update +@@ -126,7 +126,7 @@ getBootloaderConfig() { + + if [ -f "${blconfig_alias}" ]; then + local blconfig_ofnode_path="/sys/firmware/devicetree/base"$(strings "${blconfig_alias}")"" +- local blconfig_ofnode_link=$(find -L /sys/bus/nvmem -samefile "${blconfig_ofnode_path}" 2>/dev/null) ++ local blconfig_ofnode_link=$(find -L /sys/bus/nvmem -maxdepth 3 -samefile "${blconfig_ofnode_path}" 2>/dev/null) + + if [ -e "${blconfig_ofnode_link}" ]; then + blconfig_nvmem_path=$(dirname "${blconfig_ofnode_link}") +-- +2.34.1 + diff --git a/recipes-bsp/rpi-eeprom/rpi-eeprom_git.bb b/recipes-bsp/rpi-eeprom/rpi-eeprom_git.bb new file mode 100644 index 0000000..bf0d430 --- /dev/null +++ b/recipes-bsp/rpi-eeprom/rpi-eeprom_git.bb @@ -0,0 +1,64 @@ +SUMMARY = "Installation scripts and binaries for the Raspberry Pi 4 EEPROM" +DESCRIPTION = "This repository contains the rpi4 bootloader and scripts \ +for updating it in the spi eeprom" +LICENSE = "BSD-3-Clause & Broadcom-RPi" +LIC_FILES_CHKSUM = "file://LICENSE;md5=f546ed4f47e9d4c1fe954ecc9d3ef4f3" + +SRC_URI = " \ + git://github.com/raspberrypi/rpi-eeprom.git;protocol=https;branch=master \ + file://0001-Fix-rpi-eeprom-update-when-using-busybox-find.patch \ +" + +SRCREV = "6e79e995bbc75c5fdd5305bd7fe029758cfade2f" +PV = "v2022.12.07-138a1" + +S = "${WORKDIR}/git" + +RDEPENDS:${PN} += " \ + coreutils \ + python3 \ + python3-pycryptodomex \ + openssl \ + xxd \ + pciutils \ +" + +inherit python3native + +do_install() { + install -d ${D}${bindir} + + # install executables + install -m 0755 ${S}/tools/vl805 ${D}${bindir} + install -m 0755 ${S}/rpi-eeprom-update ${D}${bindir} + install -m 0755 ${S}/rpi-eeprom-config ${D}${bindir} + install -m 0755 ${S}/rpi-eeprom-digest ${D}${bindir} + + # copy firmware files + install -d ${D}${base_libdir}/firmware/raspberrypi/bootloader/critical + install -d ${D}${base_libdir}/firmware/raspberrypi/bootloader/stable + install -d ${D}${base_libdir}/firmware/raspberrypi/bootloader/beta + + install -m 644 ${S}/firmware/critical/* ${D}${base_libdir}/firmware/raspberrypi/bootloader/critical + install -m 644 ${S}/firmware/stable/* ${D}${base_libdir}/firmware/raspberrypi/bootloader/stable + install -m 644 ${S}/firmware/beta/* ${D}${base_libdir}/firmware/raspberrypi/bootloader/beta + + ln -s critical ${D}${base_libdir}/firmware/raspberrypi/bootloader/default + ln -s stable ${D}${base_libdir}/firmware/raspberrypi/bootloader/latest + + # copy default config + install -d ${D}${sysconfdir}/default + install -D ${S}/rpi-eeprom-update-default ${D}${sysconfdir}/default/rpi-eeprom-update +} + +FILES:${PN} += "${base_libdir}/firmware/raspberrypi/bootloader/*" + +INHIBIT_PACKAGE_STRIP = "1" +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" + +# vl805 tool sources are not available (yet), as it comes as a precompiled +# binary only. It has ARM architecture whereas target machine is Aarch64. We +# need to disable arch check for it otherwise it cannot packed. +QAPATHTEST[arch] = "" + +COMPATIBLE_MACHINE = "raspberrypi4|raspberrypi4-64"