From 611ed9b02dce5814c08f4f9e9bb9210f9795a263 Mon Sep 17 00:00:00 2001 From: Dmitry Konyshev Date: Sun, 12 Mar 2023 17:16:16 +0100 Subject: [PATCH] NAVQP-30: re-work reliable upgrade support as an image feature --- .../001-reliable_update_mmcroot_setup.patch | 20 +++ .../u-boot/u-boot-imx_2022.04.bbappend | 2 + recipes-core/images/files/sw-description | 34 ++-- recipes-core/images/navq-rootfs.bb | 11 +- recipes-core/images/navq-swu.bb | 6 + recipes-fsl/images/files/sw-description | 151 ++++++++++++++++++ .../images/imx-image-desktop-ros-swu.bb | 39 +++++ recipes-fsl/images/imx-image-desktop-ros.bb | 15 ++ wic/imx8mpnavq-emmc-swupdate-minimal.wks.in | 14 ++ wic/imx8mpnavq-emmc-swupdate.wks.in | 14 ++ wic/imx8mpnavq-sdcard-swupdate.wks.in | 14 ++ 11 files changed, 297 insertions(+), 23 deletions(-) create mode 100644 recipes-bsp/u-boot/u-boot-imx/001-reliable_update_mmcroot_setup.patch create mode 100644 recipes-fsl/images/files/sw-description create mode 100644 recipes-fsl/images/imx-image-desktop-ros-swu.bb create mode 100644 wic/imx8mpnavq-emmc-swupdate-minimal.wks.in create mode 100644 wic/imx8mpnavq-emmc-swupdate.wks.in create mode 100644 wic/imx8mpnavq-sdcard-swupdate.wks.in diff --git a/recipes-bsp/u-boot/u-boot-imx/001-reliable_update_mmcroot_setup.patch b/recipes-bsp/u-boot/u-boot-imx/001-reliable_update_mmcroot_setup.patch new file mode 100644 index 0000000..c68ffbb --- /dev/null +++ b/recipes-bsp/u-boot/u-boot-imx/001-reliable_update_mmcroot_setup.patch @@ -0,0 +1,20 @@ +diff --git a/board/voxelbotics/navqp/navqp.c b/board/voxelbotics/navqp/navqp.c +index e1232aacca..01ec173423 100644 +--- a/board/voxelbotics/navqp/navqp.c ++++ b/board/voxelbotics/navqp/navqp.c +@@ -550,7 +550,15 @@ int board_init(void) + int board_late_init(void) + { + #ifdef CONFIG_ENV_IS_IN_MMC ++ char mmcblk[32]; ++ u32 dev_no = mmc_get_env_dev(); ++ /* rootfs partition number is boot partition + 2 for reliable upgrade */ ++ int part = env_get_ulong("mmcpart", 10, 1) + 2; ++ + board_late_mmc_env_init(); ++ sprintf(mmcblk, "/dev/mmcblk%dp%d rootwait rw", ++ mmc_map_to_kernel_blk(dev_no), part); ++ env_set("mmcroot", mmcblk); + #endif + #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG + env_set("board_name", "EVK"); diff --git a/recipes-bsp/u-boot/u-boot-imx_2022.04.bbappend b/recipes-bsp/u-boot/u-boot-imx_2022.04.bbappend index adb7ba5..9e50ef4 100644 --- a/recipes-bsp/u-boot/u-boot-imx_2022.04.bbappend +++ b/recipes-bsp/u-boot/u-boot-imx_2022.04.bbappend @@ -2,4 +2,6 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/u-boot-imx:" SRC_URI = "git://github.com/voxelbotics/u-boot-imx.git;protocol=https;branch=imx-5.15.32-vb" +SRC_URI:append = " ${@bb.utils.contains('EXTRA_IMAGE_FEATURES', 'navq-swupdate', 'file://001-reliable_update_mmcroot_setup.patch', '', d)} " + SRCREV = "${AUTOREV}" diff --git a/recipes-core/images/files/sw-description b/recipes-core/images/files/sw-description index 3c29c09..4399240 100644 --- a/recipes-core/images/files/sw-description +++ b/recipes-core/images/files/sw-description @@ -10,7 +10,7 @@ software = partitions: ( { type = "diskformat"; - device = "/dev/mmcblk2p1"; + device = "@@SWU_STG_DEV@@p1"; properties: { fstype = "vfat"; @@ -19,7 +19,7 @@ software = }, { type = "diskformat"; - device = "/dev/mmcblk2p3"; + device = "@@SWU_STG_DEV@@p3"; properties: { fstype = "ext4"; @@ -33,7 +33,7 @@ software = filename = "@@SWU_UBOOT_FILE@@"; version = "@@SWU_UBOOT_VERSION@@"; install-if-different = true; - device = "/dev/mmcblk2"; + device = "@@SWU_STG_DEV@@"; offset = "32K"; sha256 = "$swupdate_get_sha256(@@SWU_UBOOT_FILE@@)"; } @@ -41,7 +41,7 @@ software = files: ( { filename = "Image"; - device = "/dev/mmcblk2p1"; + device = "@@SWU_STG_DEV@@p1"; path = "/Image"; filesystem = "vfat"; preserve-attributes = true; @@ -50,7 +50,7 @@ software = }, { filename = "@@KERNEL_DEVICETREE_BASENAME@@.dtb"; - device = "/dev/mmcblk2p1"; + device = "@@SWU_STG_DEV@@p1"; path = "/@@KERNEL_DEVICETREE_BASENAME@@.dtb"; filesystem = "vfat"; preserve-attributes = true; @@ -60,9 +60,10 @@ software = { filename = "@@SWU_ROOTFS_FILE@@"; type = "archive"; - device = "/dev/mmcblk2p3"; + device = "@@SWU_STG_DEV@@p3"; path = "/"; filesystem = "ext4"; + installed-directly = true; preserve-attributes = true; sha256 = "$swupdate_get_sha256(@@SWU_ROOTFS_FILE@@)"; @@ -73,10 +74,6 @@ software = name = "mmcpart"; value = "1"; }, - { - name = "mmcroot"; - value = "/dev/mmcblk2p3 rootwait rw"; - }, ); }; copy2: @@ -84,7 +81,7 @@ software = partitions: ( { type = "diskformat"; - device = "/dev/mmcblk2p2"; + device = "@@SWU_STG_DEV@@p2"; properties: { fstype = "vfat"; @@ -93,7 +90,7 @@ software = }, { type = "diskformat"; - device = "/dev/mmcblk2p4"; + device = "@@SWU_STG_DEV@@p4"; properties: { fstype = "ext4"; @@ -107,7 +104,7 @@ software = filename = "@@SWU_UBOOT_FILE@@"; version = "@@SWU_UBOOT_VERSION@@"; install-if-different = true; - device = "/dev/mmcblk2"; + device = "@@SWU_STG_DEV@@"; offset = "32K"; sha256 = "$swupdate_get_sha256(@@SWU_UBOOT_FILE@@)"; } @@ -115,7 +112,7 @@ software = files: ( { filename = "Image"; - device = "/dev/mmcblk2p2"; + device = "@@SWU_STG_DEV@@p2"; path = "/Image"; filesystem = "vfat"; preserve-attributes = true; @@ -124,7 +121,7 @@ software = }, { filename = "@@KERNEL_DEVICETREE_BASENAME@@.dtb"; - device = "/dev/mmcblk2p2"; + device = "@@SWU_STG_DEV@@p2"; path = "/@@KERNEL_DEVICETREE_BASENAME@@.dtb"; filesystem = "vfat"; preserve-attributes = true; @@ -134,9 +131,10 @@ software = { filename = "@@SWU_ROOTFS_FILE@@"; type = "archive"; - device = "/dev/mmcblk2p4"; + device = "@@SWU_STG_DEV@@p4"; path = "/"; filesystem = "ext4"; + installed-directly = true; preserve-attributes = true; sha256 = "$swupdate_get_sha256(@@SWU_ROOTFS_FILE@@)"; } @@ -146,10 +144,6 @@ software = name = "mmcpart"; value = "2"; }, - { - name = "mmcroot"; - value = "/dev/mmcblk2p4 rootwait rw"; - }, ); }; }; diff --git a/recipes-core/images/navq-rootfs.bb b/recipes-core/images/navq-rootfs.bb index afe7c11..d595a32 100644 --- a/recipes-core/images/navq-rootfs.bb +++ b/recipes-core/images/navq-rootfs.bb @@ -5,7 +5,7 @@ SECTION = "" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" -IMAGE_FSTYPES = "tar.bz2" +IMAGE_FSTYPES = "tar.bz2 wic.bz2" include recipes-core/images/core-image-minimal.bb @@ -18,7 +18,11 @@ IMAGE_INSTALL:append = " \ navq-wpa-supplicant \ usb-gadgets-mtp1 \ openssh \ - opkg \ + ${@bb.utils.contains('PACKAGE_CLASSES', 'package_ipk', 'opkg', '', d)} \ + ${@bb.utils.contains('PACKAGE_CLASSES', 'package_rpm', 'rpm', '', d)} \ +" + +FEATURE_PACKAGES_navq-swupdate = " \ swupdate \ e2fsprogs \ dosfstools \ @@ -26,5 +30,6 @@ IMAGE_INSTALL:append = " \ u-boot-imx-env \ libubootenv-bin \ libubootenv \ - ${@bb.utils.contains('PACKAGE_CLASSES', 'package_rpm', 'rpm', '', d)} \ " + +WKS_FILE := " ${@bb.utils.contains('EXTRA_IMAGE_FEATURES', 'navq-swupdate', 'imx8mpnavq-emmc-swupdate-minimal.wks.in', '${WKS_FILE}', d)}" diff --git a/recipes-core/images/navq-swu.bb b/recipes-core/images/navq-swu.bb index 9b7becc..3e0634e 100644 --- a/recipes-core/images/navq-swu.bb +++ b/recipes-core/images/navq-swu.bb @@ -15,6 +15,7 @@ SRC_URI = " \ SWU_VERSION = "${NAVQ_DISTRO_VERSION}" SWU_ROOTFS = "navq-rootfs" +SWU_STG_DEV = "/dev/mmcblk2" SWU_ROOTFS_FILE = "${SWU_ROOTFS}-${MACHINE}.tar.bz2" SWU_UBOOT_FILE = "imx-boot" @@ -31,3 +32,8 @@ SWUPDATE_IMAGES = "${SWU_ROOTFS} ${SWU_UBOOT_FILE} ${SWU_KERNEL_FILE} ${SWU_DTB_ SWUPDATE_IMAGES_FSTYPES[navq-rootfs] = "-${MACHINE}.tar.bz2" inherit swupdate + +python () { + if not bb.utils.contains('EXTRA_IMAGE_FEATURES', 'navq-swupdate', True, False, d): + bb.fatal("EXTRA_IMAGE_FEATURES must include 'navq-swupdate' for .swu build") +} diff --git a/recipes-fsl/images/files/sw-description b/recipes-fsl/images/files/sw-description new file mode 100644 index 0000000..4399240 --- /dev/null +++ b/recipes-fsl/images/files/sw-description @@ -0,0 +1,151 @@ +software = +{ + version = "@@SWU_VERSION@@"; + hardware-compatibility: [ "@@SWU_HWCOMPAT@@" ]; + @@SWU_BOARD@@ = { + stable: + { + copy1: + { + partitions: ( + { + type = "diskformat"; + device = "@@SWU_STG_DEV@@p1"; + + properties: { + fstype = "vfat"; + force = "true"; + } + }, + { + type = "diskformat"; + device = "@@SWU_STG_DEV@@p3"; + + properties: { + fstype = "ext4"; + force = "true"; + } + } + ); + images: ( + { + name = "bootloader"; + filename = "@@SWU_UBOOT_FILE@@"; + version = "@@SWU_UBOOT_VERSION@@"; + install-if-different = true; + device = "@@SWU_STG_DEV@@"; + offset = "32K"; + sha256 = "$swupdate_get_sha256(@@SWU_UBOOT_FILE@@)"; + } + ); + files: ( + { + filename = "Image"; + device = "@@SWU_STG_DEV@@p1"; + path = "/Image"; + filesystem = "vfat"; + preserve-attributes = true; + sha256 = "$swupdate_get_sha256(Image)"; + + }, + { + filename = "@@KERNEL_DEVICETREE_BASENAME@@.dtb"; + device = "@@SWU_STG_DEV@@p1"; + path = "/@@KERNEL_DEVICETREE_BASENAME@@.dtb"; + filesystem = "vfat"; + preserve-attributes = true; + sha256 = "$swupdate_get_sha256(@@KERNEL_DEVICETREE_BASENAME@@.dtb)"; + + }, + { + filename = "@@SWU_ROOTFS_FILE@@"; + type = "archive"; + device = "@@SWU_STG_DEV@@p3"; + path = "/"; + filesystem = "ext4"; + installed-directly = true; + preserve-attributes = true; + sha256 = "$swupdate_get_sha256(@@SWU_ROOTFS_FILE@@)"; + + } + ); + bootenv: ( + { + name = "mmcpart"; + value = "1"; + }, + ); + }; + copy2: + { + partitions: ( + { + type = "diskformat"; + device = "@@SWU_STG_DEV@@p2"; + + properties: { + fstype = "vfat"; + force = "true"; + } + }, + { + type = "diskformat"; + device = "@@SWU_STG_DEV@@p4"; + + properties: { + fstype = "ext4"; + force = "true"; + } + } + ); + images: ( + { + name = "bootloader"; + filename = "@@SWU_UBOOT_FILE@@"; + version = "@@SWU_UBOOT_VERSION@@"; + install-if-different = true; + device = "@@SWU_STG_DEV@@"; + offset = "32K"; + sha256 = "$swupdate_get_sha256(@@SWU_UBOOT_FILE@@)"; + } + ); + files: ( + { + filename = "Image"; + device = "@@SWU_STG_DEV@@p2"; + path = "/Image"; + filesystem = "vfat"; + preserve-attributes = true; + sha256 = "$swupdate_get_sha256(Image)"; + + }, + { + filename = "@@KERNEL_DEVICETREE_BASENAME@@.dtb"; + device = "@@SWU_STG_DEV@@p2"; + path = "/@@KERNEL_DEVICETREE_BASENAME@@.dtb"; + filesystem = "vfat"; + preserve-attributes = true; + sha256 = "$swupdate_get_sha256(@@KERNEL_DEVICETREE_BASENAME@@.dtb)"; + + }, + { + filename = "@@SWU_ROOTFS_FILE@@"; + type = "archive"; + device = "@@SWU_STG_DEV@@p4"; + path = "/"; + filesystem = "ext4"; + installed-directly = true; + preserve-attributes = true; + sha256 = "$swupdate_get_sha256(@@SWU_ROOTFS_FILE@@)"; + } + ); + bootenv: ( + { + name = "mmcpart"; + value = "2"; + }, + ); + }; + }; + }; +} diff --git a/recipes-fsl/images/imx-image-desktop-ros-swu.bb b/recipes-fsl/images/imx-image-desktop-ros-swu.bb new file mode 100644 index 0000000..3ef7955 --- /dev/null +++ b/recipes-fsl/images/imx-image-desktop-ros-swu.bb @@ -0,0 +1,39 @@ +# Copyrigh (C) 2023 Voxelbotics +DESCRIPTION = "NAVQ+ ROS upgrade image in SWU format" +SECTION = "" + +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" + +# Add all local files to be added to the SWU +# sw-description must always be in the list. +# You can extend with scripts or whatever you need +SRC_URI = " \ + file://sw-description \ +" + +SWU_VERSION = "${NAVQ_DISTRO_VERSION}" + +SWU_ROOTFS = "imx-image-desktop-ros" +SWU_STG_DEV = "/dev/mmcblk1" + +SWU_ROOTFS_FILE = "${SWU_ROOTFS}-${MACHINE}.tar.bz2" +SWU_UBOOT_FILE = "imx-boot" +SWU_KERNEL_FILE = "Image" +SWU_DTB_FILE = "${KERNEL_DEVICETREE_BASENAME}.dtb" + +# images to build before building swupdate image +IMAGE_DEPENDS = "${SWU_ROOTFS} imx-boot linux-imx" + +# images and files that will be included in the .swu image +SWUPDATE_IMAGES = "${SWU_ROOTFS} ${SWU_UBOOT_FILE} ${SWU_KERNEL_FILE} ${SWU_DTB_FILE}" + +# a deployable image can have multiple format, choose one +SWUPDATE_IMAGES_FSTYPES[imx-image-desktop-ros] = "-${MACHINE}.tar.bz2" + +inherit swupdate + +python () { + if not bb.utils.contains('EXTRA_IMAGE_FEATURES', 'navq-swupdate', True, False, d): + bb.fatal("EXTRA_IMAGE_FEATURES must include 'navq-swupdate' for .swu build") +} diff --git a/recipes-fsl/images/imx-image-desktop-ros.bb b/recipes-fsl/images/imx-image-desktop-ros.bb index 49accb6..2fbb3b0 100644 --- a/recipes-fsl/images/imx-image-desktop-ros.bb +++ b/recipes-fsl/images/imx-image-desktop-ros.bb @@ -216,6 +216,21 @@ fakeroot do_install_home_files() { set +x } +IMAGE_INSTALL += "navq-files" + +FEATURE_PACKAGES_navq-swupdate = " \ + navq-files-wpa \ + usb-gadgets-mtp1 \ + swupdate \ + e2fsprogs \ + libgcc \ + u-boot-imx-env \ + libubootenv-bin \ + libubootenv \ +" + +WKS_FILE := " ${@bb.utils.contains('EXTRA_IMAGE_FEATURES', 'navq-swupdate', 'imx8mpnavq-sdcard-swupdate.wks.in', '${WKS_FILE}', d)}" + fakeroot do_aptget_user_update() { wget -q -P ${APTGET_CHROOT_DIR}/ https://github.com/rudislabs/NavQPlus-Resources/raw/lf-5.15.32_2.0.0/python/tflite_runtime-2.12.0-cp310-cp310-linux_aarch64.whl chroot ${APTGET_CHROOT_DIR} /usr/bin/pip3 install tflite_runtime-2.12.0-cp310-cp310-linux_aarch64.whl diff --git a/wic/imx8mpnavq-emmc-swupdate-minimal.wks.in b/wic/imx8mpnavq-emmc-swupdate-minimal.wks.in new file mode 100644 index 0000000..183b8db --- /dev/null +++ b/wic/imx8mpnavq-emmc-swupdate-minimal.wks.in @@ -0,0 +1,14 @@ +# short-description: Create SD card image with a boot partition +# long-description: +# Create an image that can be written onto a SD card using dd for use +# with i.MX SoC family +# It uses u-boot + other binaries gathered together on imx-boot file +# +part u-boot --source rawcopy --sourceparams="file=imx-boot" --ondisk mmcblk --no-table --align ${IMX_BOOT_SEEK} +part /boot --part-name "boot1" --source bootimg-partition --ondisk mmcblk --fstype=vfat --label boot --active --align 8192 --fixed-size 128 +part /boot2 --part-name "boot2" --ondisk mmcblk --fstype=vfat --label boot --align 8192 --fixed-size 128 +part / --part-name "rootfs1" --source rootfs --ondisk mmcblk --fstype=ext4 --label root --align 8192 --fixed-size 512M +part /rootfs2 --part-name "rootfs2" --ondisk mmcblk --fstype=ext4 --label root --align 8192 --fixed-size 512M +part /data --part-name "data" --ondisk mmcblk --fstype=ext4 --label root --align 8192 --fixed-size 128M + +bootloader --ptable gpt diff --git a/wic/imx8mpnavq-emmc-swupdate.wks.in b/wic/imx8mpnavq-emmc-swupdate.wks.in new file mode 100644 index 0000000..59ee71a --- /dev/null +++ b/wic/imx8mpnavq-emmc-swupdate.wks.in @@ -0,0 +1,14 @@ +# short-description: Create SD card image with a boot partition +# long-description: +# Create an image that can be written onto a SD card using dd for use +# with i.MX SoC family +# It uses u-boot + other binaries gathered together on imx-boot file +# +part u-boot --source rawcopy --sourceparams="file=imx-boot" --ondisk mmcblk --no-table --align ${IMX_BOOT_SEEK} +part /boot --part-name "boot1" --source bootimg-partition --ondisk mmcblk --fstype=vfat --label boot --active --align 8192 --fixed-size 128 +part /boot2 --part-name "boot2" --ondisk mmcblk --fstype=vfat --label boot --align 8192 --fixed-size 128 +part / --part-name "rootfs1" --source rootfs --ondisk mmcblk --fstype=ext4 --label root --align 8192 --fixed-size 5G +part /rootfs2 --part-name "rootfs2" --ondisk mmcblk --fstype=ext4 --label root --align 8192 --fixed-size 5G +part /data --part-name "data" --ondisk mmcblk --fstype=ext4 --label root --align 8192 --fixed-size 4G + +bootloader --ptable gpt diff --git a/wic/imx8mpnavq-sdcard-swupdate.wks.in b/wic/imx8mpnavq-sdcard-swupdate.wks.in new file mode 100644 index 0000000..ed902bf --- /dev/null +++ b/wic/imx8mpnavq-sdcard-swupdate.wks.in @@ -0,0 +1,14 @@ +# short-description: Create SD card image with a boot partition +# long-description: +# Create an image that can be written onto a SD card using dd for use +# with i.MX SoC family +# It uses u-boot + other binaries gathered together on imx-boot file +# +part u-boot --source rawcopy --sourceparams="file=imx-boot" --ondisk mmcblk --no-table --align ${IMX_BOOT_SEEK} +part /boot --part-name "boot1" --source bootimg-partition --ondisk mmcblk --fstype=vfat --label boot --active --align 8192 --fixed-size 128 +part /boot2 --part-name "boot2" --ondisk mmcblk --fstype=vfat --label boot --align 8192 --fixed-size 128 +part / --part-name "rootfs1" --source rootfs --ondisk mmcblk --fstype=ext4 --label root --align 8192 --fixed-size 10G +part /rootfs2 --part-name "rootfs2" --ondisk mmcblk --fstype=ext4 --label root --align 8192 --fixed-size 10G +part /data --part-name "data" --ondisk mmcblk --fstype=ext4 --label root --align 8192 --fixed-size 5G + +bootloader --ptable gpt