From 495f5db09da6a1e5b7a16460d9f4bf26fbee2dff Mon Sep 17 00:00:00 2001 From: Anton Gerasimov Date: Tue, 5 Feb 2019 12:39:56 +0100 Subject: Add support for device tree overlays in FIT images Signed-off-by: Anton Gerasimov --- README.adoc | 5 ++++- classes/sota_raspberrypi.bbclass | 15 ++++++++++++++- recipes-sota/fit-conf/fit-conf.bb | 22 ++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 recipes-sota/fit-conf/fit-conf.bb diff --git a/README.adoc b/README.adoc index ea9bb21..27ecabf 100644 --- a/README.adoc +++ b/README.adoc @@ -81,6 +81,7 @@ Although we have used U-Boot so far, other boot loaders can be configured work w * `OSTREE_COMMIT_BODY` - Message attached to OSTree commit. Empty by default. * `OSTREE_COMMIT_SUBJECT` - Commit subject used by OSTree. Defaults to `Commit-id: ${IMAGE_NAME}` * `OSTREE_UPDATE_SUMMARY` - Set this to '1' to update summary of OSTree repository on each commit. '0' by default. +* `OSTREE_DEPLOY_DEVICETREE` - Set this to '1' to include devicetree(s) to boot * `INITRAMFS_IMAGE` - initramfs/initrd image that is used as a proxy while booting into OSTree deployment. Do not change this setting unless you are sure that your initramfs can serve as such a proxy. * `SOTA_PACKED_CREDENTIALS` - when set, your ostree commit will be pushed to a remote repo as a bitbake step. This should be the path to a zipped credentials file in https://github.com/advancedtelematic/aktualizr/blob/master/docs/credentials.adoc[the format accepted by garage-push]. * `SOTA_DEPLOY_CREDENTIALS` - when set to '1' (default value), deploys credentials to the built image. Override it in `local.conf` to built a generic image that can be provisioned manually after the build. @@ -88,7 +89,9 @@ Although we have used U-Boot so far, other boot loaders can be configured work w * `SOTA_CLIENT_FEATURES` - extensions to aktualizr. The only valid options are `hsm` (to build with HSM support) and `secondary-network` (to set up a simulated 'in-vehicle' network with support for a primary node with a DHCP server and a secondary node with a DHCP client). * `SOTA_SECONDARY_CONFIG_DIR` - a directory containing JSON configuration files for virtual secondaries on the host. These will be installed into `/etc/sota/ecus` on the device and automatically provided to aktualizr. * `SOTA_HARDWARE_ID` - a custom hardware ID that will be written to the aktualizr config. Defaults to MACHINE if not set. -* `OSTREE_DEPLOY_DEVICETREE` - Set this to '1' to include devicetree(s) to boot +* `SOTA_MAIN_DTB` - base device tree to use with the kernel. Used together with FIT images. You can change it, and the device tree will also be changed after the update. +* `SOTA_DT_OVERLAYS` - whitespace-separated list of used device tree overlays for FIT image. This list is OSTree-updateable as well. +* `SOTA_EXTRA_CONF_FRAGS` - extra https://lxr.missinglinkelectronics.com/uboot/doc/uImage.FIT/overlay-fdt-boot.txt[configuration fragments] for FIT image. == Usage diff --git a/classes/sota_raspberrypi.bbclass b/classes/sota_raspberrypi.bbclass index 600f9e9..e1c0054 100644 --- a/classes/sota_raspberrypi.bbclass +++ b/classes/sota_raspberrypi.bbclass @@ -5,6 +5,13 @@ KERNEL_IMAGETYPE_sota = "fitImage" INITRAMFS_FSTYPES = "cpio.gz" OSTREE_KERNEL = "${KERNEL_IMAGETYPE}-${INITRAMFS_IMAGE}-${MACHINE}-${KERNEL_FIT_LINK_NAME}" +# DTB needs to be relocated to apply overlays +UBOOT_DTB_LOADADDRESS = "0x05000000" +UBOOT_DTBO_LOADADDRESS = "0x06000000" + +# Deploy config fragment list to OSTree root fs +IMAGE_INSTALL_append = " fit-conf" + PREFERRED_PROVIDER_virtual/bootloader_sota ?= "u-boot" UBOOT_ENTRYPOINT_sota ?= "0x00008000" @@ -18,7 +25,13 @@ IMAGE_BOOT_FILES_sota = "bcm2835-bootfiles/* u-boot.bin;${SDIMG_KERNELIMAGE}" KERNEL_DEVICETREE_raspberrypi2_sota ?= " bcm2709-rpi-2-b.dtb " KERNEL_DEVICETREE_raspberrypi3_sota ?= " bcm2710-rpi-3-b.dtb overlays/vc4-kms-v3d.dtbo overlays/rpi-ft5406.dtbo" +SOTA_MAIN_DTB_raspberrypi2 ?= "bcm2709-rpi-2-b.dtb" +SOTA_MAIN_DTB_raspberrypi3 ?= "bcm2710-rpi-3-b.dtb" + +SOTA_DT_OVERLAYS_raspberrypi3 ?= "vc4-kms-v3d.dtbo rpi-ft5406.dtbo" + # Kernel args normally provided by RPi's internal bootloader. Non-updateable -OSTREE_KERNEL_ARGS_sota ?= " 8250.nr_uarts=1 bcm2708_fb.fbwidth=720 bcm2708_fb.fbheight=480 bcm2708_fb.fbswap=1 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 dwc_otg.lpm_enable=0 console=ttyS0,115200 usbhid.mousepoll=0 " +OSTREE_KERNEL_ARGS_sota ?= " 8250.nr_uarts=1 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=614 bcm2708_fb.fbswap=1 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 dwc_otg.lpm_enable=0 console=ttyS0,115200 usbhid.mousepoll=0 " SOTA_CLIENT_FEATURES_append = " ubootenv" + diff --git a/recipes-sota/fit-conf/fit-conf.bb b/recipes-sota/fit-conf/fit-conf.bb new file mode 100644 index 0000000..c6cecec --- /dev/null +++ b/recipes-sota/fit-conf/fit-conf.bb @@ -0,0 +1,22 @@ +SUMMARY = "FIT image configuration for u-boot to use" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" + +do_install() { + mkdir -p ${D}${libdir} + echo -n "fit_conf=" >${D}${libdir}/fit_conf + + if [ -n ${SOTA_MAIN_DTB} ]; then + echo -n "#conf@${SOTA_MAIN_DTB}" >> ${D}${libdir}/fit_conf + fi + + for ovrl in ${SOTA_DT_OVERLAYS}; do + echo -n "#conf@overlays_${ovrl}" >> ${D}${libdir}/fit_conf + done + + for conf_frag in ${SOTA_EXTRA_CONF_FRAGS}; do + echo -n "#${conf_frag}" >> ${D}${libdir}/fit_conf + done +} + +FILES_${PN} += "${libdir}/fit_conf" -- cgit v1.2.3-54-g00ecf