From 550a4080839184988487a8a64188c2de9fed956b Mon Sep 17 00:00:00 2001 From: Christopher Clark Date: Sat, 24 Apr 2021 01:31:03 -0700 Subject: xen, rpi4: add xen-rpi-u-boot-scr recipe for default u-boot script Add a new xen-rpi-u-boot-scr recipe to PROVIDE u-boot-default-script instead of using a bbappend to rpi-u-boot-scr. This allows the new recipe to be selected by indicating it as PREFERRED_PROVIDER of u-boot-default-script, and then do that in the Xen on Raspberry Pi 4 config file, xen-raspberrypi4-64.inc. Signed-off-by: Christopher Clark Signed-off-by: Bruce Ashfield --- .../conf/distro/include/xen-raspberrypi4-64.inc | 2 + .../rpi-u-boot-scr/files/boot.cmd.xen.in | 55 ---------------------- .../rpi-u-boot-scr/rpi-u-boot-scr.bbappend | 17 ------- .../xen-rpi-u-boot-scr/files/boot.cmd.xen.in | 55 ++++++++++++++++++++++ .../xen-rpi-u-boot-scr/xen-rpi-u-boot-scr.bb | 34 +++++++++++++ 5 files changed, 91 insertions(+), 72 deletions(-) delete mode 100644 dynamic-layers/raspberrypi/recipes-bsp/rpi-u-boot-scr/files/boot.cmd.xen.in delete mode 100644 dynamic-layers/raspberrypi/recipes-bsp/rpi-u-boot-scr/rpi-u-boot-scr.bbappend create mode 100644 dynamic-layers/raspberrypi/recipes-bsp/xen-rpi-u-boot-scr/files/boot.cmd.xen.in create mode 100644 dynamic-layers/raspberrypi/recipes-bsp/xen-rpi-u-boot-scr/xen-rpi-u-boot-scr.bb diff --git a/dynamic-layers/raspberrypi/conf/distro/include/xen-raspberrypi4-64.inc b/dynamic-layers/raspberrypi/conf/distro/include/xen-raspberrypi4-64.inc index 9c362551..2ea19dd4 100644 --- a/dynamic-layers/raspberrypi/conf/distro/include/xen-raspberrypi4-64.inc +++ b/dynamic-layers/raspberrypi/conf/distro/include/xen-raspberrypi4-64.inc @@ -21,3 +21,5 @@ BOOT_SPACE = "61440" # Override the meta-raspberrypi default kernel preference PREFERRED_PROVIDER_virtual/kernel ?= "linux-yocto" KERNEL_DEVICETREE ?= "broadcom/bcm2711-rpi-4-b.dtb" + +PREFERRED_PROVIDER_u-boot-default-script ?= "xen-rpi-u-boot-scr" diff --git a/dynamic-layers/raspberrypi/recipes-bsp/rpi-u-boot-scr/files/boot.cmd.xen.in b/dynamic-layers/raspberrypi/recipes-bsp/rpi-u-boot-scr/files/boot.cmd.xen.in deleted file mode 100644 index 0367e36c..00000000 --- a/dynamic-layers/raspberrypi/recipes-bsp/rpi-u-boot-scr/files/boot.cmd.xen.in +++ /dev/null @@ -1,55 +0,0 @@ -# Set the fdt address to what came from the GPU, so we can edit it -fdt addr ${fdt_addr} - -# Pull the bootargs that the GPU has edited -fdt get value bootargs /chosen bootargs - -# Set module load addresses -setenv xen_loadaddr "0x00200000" -setenv kernel_loadaddr "0x00400000" - -# Add some space to the fdt so we can edit it -fdt resize 0x1000 -echo Add boot arguments for Xen -fdt set /chosen xen,xen-bootargs "console=dtuart dtuart=/soc/serial@7e215040 dom0_mem='@@RPI_DOM0_MEM@@' @@RPI_DEBUG_XEN_ARGS@@" - -echo Add boot arguments for dom0 -setenv dom0_bootargs "console=hvc0 earlycon=xenboot debug root=/dev/mmcblk0p2 rootwait" -fdt set /chosen xen,dom0-bootargs \"${dom0_bootargs}\" - -echo Add a dom0 node to chosen to put Linux boot information in -fdt mknode /chosen dom0 - -echo Set this for the Linux boot command -fdt set /chosen/dom0 compatible "multiboot,module" - -# Tell Xen where PCI is -fdt set /scb/pcie@7d500000 device_type "pci" -# Workaround to fix: -# "Unable to retrieve address 0 for /scb/pcie@7d500000/pci@1,0/usb@1,0" -fdt rm /scb/pcie@7d500000/pci@1,0/usb@1,0 - -echo Delay to allow the MMC card to be ready -sleep 1 - -echo Load Xen into memory -fatload mmc 1:1 ${xen_loadaddr} xen -echo Xen loaded, size: 0x$filesize - -echo Load Linux kernel into memory -fatload mmc 1:1 ${kernel_loadaddr} Image -setenv kernel_size 0x$filesize -echo Linux loaded, size: 0x$filesize - -echo Set the address and size for the Linux kernel so Xen can pick it up -fdt set /chosen/dom0 reg <${kernel_loadaddr} ${kernel_size}> - -# Define the size and address cells -fdt set /chosen '#size-cells' <1> -fdt set /chosen '#address-cells' <1> - -# Display the chosen fdt section - can be important for debugging -fdt print /chosen - -echo Boot Xen -booti ${xen_loadaddr} - ${fdt_addr} diff --git a/dynamic-layers/raspberrypi/recipes-bsp/rpi-u-boot-scr/rpi-u-boot-scr.bbappend b/dynamic-layers/raspberrypi/recipes-bsp/rpi-u-boot-scr/rpi-u-boot-scr.bbappend deleted file mode 100644 index 2a511160..00000000 --- a/dynamic-layers/raspberrypi/recipes-bsp/rpi-u-boot-scr/rpi-u-boot-scr.bbappend +++ /dev/null @@ -1,17 +0,0 @@ -FILESEXTRAPATHS_prepend := "${THISDIR}/files:" - -RPI_DOM0_MEM ??= "256M" -RPI_DEBUG_XEN_ARGS ??= "sync_console bootscrub=0" - -SRC_URI += "file://boot.cmd.xen.in" - -# If the distro is Xen enabled, override the default boot.cmd.in with the -# alternative boot.cmd.xen.in from this layer, with variables subsitution here -do_compile_append() { - if [ "${@bb.utils.contains('DISTRO_FEATURES', 'xen', 'yes', 'no', d)}" = "yes" ]; then - sed -e 's/@@RPI_DOM0_MEM@@/${RPI_DOM0_MEM}/' \ - -e 's/@@RPI_DEBUG_XEN_ARGS@@/${RPI_DEBUG_XEN_ARGS}/' \ - "${WORKDIR}/boot.cmd.xen.in" > "${WORKDIR}/boot.cmd" - mkimage -A arm -T script -C none -n "Boot script" -d "${WORKDIR}/boot.cmd" boot.scr - fi -} diff --git a/dynamic-layers/raspberrypi/recipes-bsp/xen-rpi-u-boot-scr/files/boot.cmd.xen.in b/dynamic-layers/raspberrypi/recipes-bsp/xen-rpi-u-boot-scr/files/boot.cmd.xen.in new file mode 100644 index 00000000..0367e36c --- /dev/null +++ b/dynamic-layers/raspberrypi/recipes-bsp/xen-rpi-u-boot-scr/files/boot.cmd.xen.in @@ -0,0 +1,55 @@ +# Set the fdt address to what came from the GPU, so we can edit it +fdt addr ${fdt_addr} + +# Pull the bootargs that the GPU has edited +fdt get value bootargs /chosen bootargs + +# Set module load addresses +setenv xen_loadaddr "0x00200000" +setenv kernel_loadaddr "0x00400000" + +# Add some space to the fdt so we can edit it +fdt resize 0x1000 +echo Add boot arguments for Xen +fdt set /chosen xen,xen-bootargs "console=dtuart dtuart=/soc/serial@7e215040 dom0_mem='@@RPI_DOM0_MEM@@' @@RPI_DEBUG_XEN_ARGS@@" + +echo Add boot arguments for dom0 +setenv dom0_bootargs "console=hvc0 earlycon=xenboot debug root=/dev/mmcblk0p2 rootwait" +fdt set /chosen xen,dom0-bootargs \"${dom0_bootargs}\" + +echo Add a dom0 node to chosen to put Linux boot information in +fdt mknode /chosen dom0 + +echo Set this for the Linux boot command +fdt set /chosen/dom0 compatible "multiboot,module" + +# Tell Xen where PCI is +fdt set /scb/pcie@7d500000 device_type "pci" +# Workaround to fix: +# "Unable to retrieve address 0 for /scb/pcie@7d500000/pci@1,0/usb@1,0" +fdt rm /scb/pcie@7d500000/pci@1,0/usb@1,0 + +echo Delay to allow the MMC card to be ready +sleep 1 + +echo Load Xen into memory +fatload mmc 1:1 ${xen_loadaddr} xen +echo Xen loaded, size: 0x$filesize + +echo Load Linux kernel into memory +fatload mmc 1:1 ${kernel_loadaddr} Image +setenv kernel_size 0x$filesize +echo Linux loaded, size: 0x$filesize + +echo Set the address and size for the Linux kernel so Xen can pick it up +fdt set /chosen/dom0 reg <${kernel_loadaddr} ${kernel_size}> + +# Define the size and address cells +fdt set /chosen '#size-cells' <1> +fdt set /chosen '#address-cells' <1> + +# Display the chosen fdt section - can be important for debugging +fdt print /chosen + +echo Boot Xen +booti ${xen_loadaddr} - ${fdt_addr} diff --git a/dynamic-layers/raspberrypi/recipes-bsp/xen-rpi-u-boot-scr/xen-rpi-u-boot-scr.bb b/dynamic-layers/raspberrypi/recipes-bsp/xen-rpi-u-boot-scr/xen-rpi-u-boot-scr.bb new file mode 100644 index 00000000..87619d01 --- /dev/null +++ b/dynamic-layers/raspberrypi/recipes-bsp/xen-rpi-u-boot-scr/xen-rpi-u-boot-scr.bb @@ -0,0 +1,34 @@ +SUMMARY = "U-boot boot script for Xen on Raspberry Pi 4" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" +COMPATIBLE_MACHINE = "^raspberrypi4-64$" + +DEPENDS = "u-boot-mkimage-native" + +INHIBIT_DEFAULT_DEPS = "1" + +SRC_URI = "file://boot.cmd.xen.in" + +RPI_DOM0_MEM ??= "256M" +RPI_DEBUG_XEN_ARGS ??= "sync_console bootscrub=0" + +do_compile() { + sed -e 's/@@KERNEL_IMAGETYPE@@/${KERNEL_IMAGETYPE}/' \ + -e 's/@@KERNEL_BOOTCMD@@/${KERNEL_BOOTCMD}/' \ + -e 's/@@RPI_DOM0_MEM@@/${RPI_DOM0_MEM}/' \ + -e 's/@@RPI_DEBUG_XEN_ARGS@@/${RPI_DEBUG_XEN_ARGS}/' \ + "${WORKDIR}/boot.cmd.xen.in" > "${WORKDIR}/boot.cmd" + + mkimage -A ${UBOOT_ARCH} -T script -C none -n "Boot script" -d "${WORKDIR}/boot.cmd" boot.scr +} + +inherit kernel-arch deploy nopackages + +do_deploy() { + install -d ${DEPLOYDIR} + install -m 0644 boot.scr ${DEPLOYDIR} +} + +addtask do_deploy after do_compile before do_build + +PROVIDES += "u-boot-default-script" -- cgit v1.2.3-54-g00ecf