Skip to content

Commit

Permalink
Switch to balena bootloader on raspberrypi4-64
Browse files Browse the repository at this point in the history
Change-type: minor
Signed-off-by: Michal Toman <michalt@balena.io>
  • Loading branch information
mtoman committed Jan 8, 2024
1 parent d8be9e5 commit 8a3b32e
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ CMDLINE += " ${@bb.utils.contains('DISTRO_FEATURES','osdev-image',"console=tty1
CMDLINE += " cgroup_enable=memory"
CMDLINE:remove = "root=/dev/mmcblk0p2"
CMDLINE_DEBUG = ""

# Necessary for balena bootloader to work
# These will not be passed to the actual kernel
CMDLINE:append:raspberrypi4-64 := " balena_stage2 nr_cpus=1"
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ BALENA_BOOT_PARTITION_FILES:rpi = " \
bootfiles:/ \
"

BALENA_BOOT_PARTITION_FILES:remove:raspberrypi4-64 = " \
u-boot.bin:/${SDIMG_KERNELIMAGE} \
boot.scr:/boot.scr \
"

BALENA_BOOT_PARTITION_FILES:append:raspberrypi4-64 = " \
balena-bootloader/${KERNEL_IMAGETYPE}-initramfs-${MACHINE}.bin:/${SDIMG_KERNELIMAGE} \
balena-bootloader/bootenv:/bootenv \
"

BALENA_BOOT_PARTITION_FILES:append:revpi-core-3 = " revpi-core-dt-blob-overlay.dtb:/dt-blob.bin"

BALENA_BOOT_PARTITION_FILES:append:revpi-connect = " revpi-connect-dt-blob-overlay.dtb:/dt-blob.bin"
Expand Down Expand Up @@ -63,6 +73,11 @@ python overlay_dtbs_handler () {
do_resin_boot_dirgen_and_deploy[prefuncs] += "overlay_dtbs_handler"

IMAGE_INSTALL:append:rpi = " u-boot"
IMAGE_INSTALL:remove:raspberrypi4-64 = " u-boot"
IMAGE_INSTALL:append:raspberrypi4-64 = " grub-editenv"

do_rootfs[depends] += "${@oe.utils.conditional('MACHINE','raspberrypi4-64',' virtual/balena-bootloader:do_deploy','',d)}"
do_image_balenaos_img[depends] += "${@oe.utils.conditional('MACHINE','raspberrypi4-64',' virtual/balena-bootloader:do_deploy','',d)}"

do_resin_boot_dirgen_and_deploy[depends] += "virtual/kernel:do_install"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
LINUX_VERSION ?= "6.1.64"
LINUX_RPI_BRANCH ?= "rpi-6.1.y"
LINUX_RPI_KMETA_BRANCH ?= "yocto-6.1"

SRCREV_machine = "dad5d57939cfae7af363e7c9862b59d33d96794b"
SRCREV_meta = "f845a7f37d7114230d6609e2bd630070f2f6cd9b"

KMETA = "kernel-meta"

SRC_URI = " \
git://github.com/raspberrypi/linux.git;name=machine;branch=${LINUX_RPI_BRANCH};protocol=https \
git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=${LINUX_RPI_KMETA_BRANCH};destsuffix=${KMETA} \
"
SRC_URI:remove = "file://initramfs-image-bundle.cfg"
SRC_URI:remove = "file://vc4graphics.cfg"

require recipes-kernel/linux/linux-raspberrypi.inc

inherit balena-bootloader

BALENA_DEFCONFIG_NAME = "${KBUILD_DEFCONFIG}"

BALENA_CONFIGS:append = " \
rpisense \
"

BALENA_CONFIGS[rpisense] = " \
CONFIG_MFD_RPISENSE_CORE=n \
CONFIG_FB_RPISENSE=n \
"

do_deploy:append () {
BOOTENV_FILE="${DEPLOYDIR}/${KERNEL_PACKAGE_NAME}/bootenv"
grub-editenv "${BOOTENV_FILE}" create
grub-editenv "${BOOTENV_FILE}" set "resin_root_part=A"
grub-editenv "${BOOTENV_FILE}" set "bootcount=0"
grub-editenv "${BOOTENV_FILE}" set "upgrade_available=0"
}

do_deploy[depends] += " grub-native:do_populate_sysroot"

KERNEL_DTC_FLAGS += "-@ -H epapr"

INITRAMFS_IMAGE = "balena-image-bootloader-initramfs"

KERNEL_PACKAGE_NAME = "balena-bootloader"

KERNEL_DEVICETREE = "${RPI_KERNEL_DEVICETREE}"

PROVIDES = "virtual/balena-bootloader"
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ FILESEXTRAPATHS:append := ":${THISDIR}/files"

HOSTAPP_HOOKS += " 99-resin-uboot 999-resin-boot-cleaner"
HOSTAPP_HOOKS:append:revpi-core-3 = " 9999-bootfiles"

HOSTAPP_HOOKS:remove:raspberrypi4-64 = "99-resin-uboot 999-resin-boot-cleaner"
HOSTAPP_HOOKS:append:raspberrypi4-64 = " 99-balena-bootloader"

0 comments on commit 8a3b32e

Please sign in to comment.