diff --git a/meta-digi-arm/classes/image_types_digi.bbclass b/meta-digi-arm/classes/image_types_digi.bbclass index e5d4bc81a..ca0c6f60a 100644 --- a/meta-digi-arm/classes/image_types_digi.bbclass +++ b/meta-digi-arm/classes/image_types_digi.bbclass @@ -231,15 +231,17 @@ IMAGE_TYPES += "cpio.gz.u-boot.tf" do_image_squashfs[postfuncs] += "${@oe.utils.conditional('TRUSTFENCE_SIGN', '1', 'rootfs_sign', '', d)}" rootfs_sign() { - # Set environment variables for trustfence configuration - export CONFIG_SIGN_KEYS_PATH="${TRUSTFENCE_SIGN_KEYS_PATH}" - [ -n "${CONFIG_KEY_INDEX}" ] && export CONFIG_KEY_INDEX="${TRUSTFENCE_KEY_INDEX}" + # Set environment variables for trustfence configuration + export CONFIG_SIGN_KEYS_PATH="${TRUSTFENCE_SIGN_KEYS_PATH}" + [ -n "${CONFIG_KEY_INDEX}" ] && export CONFIG_KEY_INDEX="${TRUSTFENCE_KEY_INDEX}" - ROOTFS_IMAGE="${IMGDEPLOYDIR}/${IMAGE_NAME}.rootfs.squashfs" - TMP_ROOTFS_IMAGE_SIGNED="$(mktemp ${ROOTFS_IMAGE}-signed.XXXXXX)" - # Sign rootfs read-only image - trustfence-sign-artifact.sh -p "${DIGI_SOM}" -r "${ROOTFS_IMAGE}" "${TMP_ROOTFS_IMAGE_SIGNED}" - mv "${TMP_ROOTFS_IMAGE_SIGNED}" "${ROOTFS_IMAGE}" + if [ "${DEY_SOC_VENDOR}" = "NXP" ]; then + ROOTFS_IMAGE="${IMGDEPLOYDIR}/${IMAGE_NAME}.rootfs.squashfs" + TMP_ROOTFS_IMAGE_SIGNED="$(mktemp ${ROOTFS_IMAGE}-signed.XXXXXX)" + # Sign rootfs read-only image + trustfence-sign-artifact.sh -p "${DIGI_SOM}" -r "${ROOTFS_IMAGE}" "${TMP_ROOTFS_IMAGE_SIGNED}" + mv "${TMP_ROOTFS_IMAGE_SIGNED}" "${ROOTFS_IMAGE}" + fi } rootfs_sign[dirs] = "${DEPLOY_DIR_IMAGE}" diff --git a/meta-digi-arm/conf/layer.conf b/meta-digi-arm/conf/layer.conf index 8868577f6..78f9e516b 100644 --- a/meta-digi-arm/conf/layer.conf +++ b/meta-digi-arm/conf/layer.conf @@ -24,6 +24,15 @@ LAYERDEPENDS_digi-arm += "${@oe.utils.conditional('DEY_SOC_VENDOR', 'STM', 'stm- LAYERSERIES_COMPAT_digi-arm = "kirkstone" +# Define new EULAs and add them to the list defined in meta-freescale. +# See fsl-eula-unpack.bbclass. +FSL_EULA_FILE_MD5SUM_LA_OPT_NXP_SOFTWARE_LICENSE_V42 = "ea25d099982d035af85d193c88a1b479" +FSL_EULA_FILE_MD5SUM_LA_OPT_NXP_SOFTWARE_LICENSE_V45 = "63a38e9f392d8813d6f1f4d0d6fbe657" +FSL_EULA_FILE_MD5SUMS:append = " \ + ${FSL_EULA_FILE_MD5SUM_LA_OPT_NXP_SOFTWARE_LICENSE_V42} \ + ${FSL_EULA_FILE_MD5SUM_LA_OPT_NXP_SOFTWARE_LICENSE_V45} \ +" + # STM EULA EULA_FILE_ST_${MACHINE} = "${LAYERDIR}/conf/eula/${MACHINE}" EULA_FILE_ST_MD5SUM_${MACHINE} = "8b505090fb679839cefbcc784afe8ce9" diff --git a/meta-digi-arm/conf/machine/ccimx8x-sbc-express.conf b/meta-digi-arm/conf/machine/ccimx8x-sbc-express.conf index a4b554e66..9298dc444 100644 --- a/meta-digi-arm/conf/machine/ccimx8x-sbc-express.conf +++ b/meta-digi-arm/conf/machine/ccimx8x-sbc-express.conf @@ -6,11 +6,9 @@ include conf/machine/include/ccimx8x.inc # U-Boot configurations -# Last one is the default (the one the symlinks point at) -UBOOT_CONFIG ??= "ccimx8x_sbc_express512MB ccimx8x_sbc_express1GB ccimx8x_sbc_express2GB" -UBOOT_CONFIG[ccimx8x_sbc_express2GB] = "ccimx8x_sbc_express2GB_defconfig,,u-boot-dtb.${UBOOT_SUFFIX}" -UBOOT_CONFIG[ccimx8x_sbc_express1GB] = "ccimx8x_sbc_express1GB_defconfig,,u-boot-dtb.${UBOOT_SUFFIX}" -UBOOT_CONFIG[ccimx8x_sbc_express512MB] = "ccimx8x_sbc_express512MB_defconfig,,u-boot-dtb.${UBOOT_SUFFIX}" +UBOOT_CONFIG ??= "ccimx8x_sbc_express" +UBOOT_CONFIG[ccimx8x_sbc_express] = "ccimx8x_sbc_express_defconfig,,u-boot-dtb.${UBOOT_SUFFIX}" +SPL_BINARY = "spl/u-boot-spl.bin" KERNEL_DEVICETREE ?= " \ digi/ccimx8x-sbc-express.dtb \ @@ -36,12 +34,6 @@ IMAGE_FSTYPES ?= '${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", \ # Boot artifacts to be copied from the deploy dir to the installer ZIP BOOTABLE_ARTIFACTS = " \ - imx-boot-ccimx8x-sbc-express-B0-1GB_16bit.bin \ - imx-boot-ccimx8x-sbc-express-B0-1GB_32bit.bin \ - imx-boot-ccimx8x-sbc-express-B0-2GB_32bit.bin \ - imx-boot-ccimx8x-sbc-express-B0-512MB_16bit.bin \ - imx-boot-ccimx8x-sbc-express-C0-1GB_16bit.bin \ - imx-boot-ccimx8x-sbc-express-C0-1GB_32bit.bin \ - imx-boot-ccimx8x-sbc-express-C0-2GB_32bit.bin \ - imx-boot-ccimx8x-sbc-express-C0-512MB_16bit.bin \ + imx-boot-ccimx8x-sbc-express-B0.bin \ + imx-boot-ccimx8x-sbc-express-C0.bin \ " diff --git a/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf b/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf index abe7bb3df..bb3db876b 100644 --- a/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf +++ b/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf @@ -7,10 +7,9 @@ include conf/machine/include/ccimx8x.inc # U-Boot configurations # Last one is the default (the one the symlinks point at) -UBOOT_CONFIG ??= "ccimx8x_sbc_pro512MB ccimx8x_sbc_pro1GB ccimx8x_sbc_pro2GB" -UBOOT_CONFIG[ccimx8x_sbc_pro2GB] = "ccimx8x_sbc_pro2GB_defconfig,,u-boot-dtb.${UBOOT_SUFFIX}" -UBOOT_CONFIG[ccimx8x_sbc_pro1GB] = "ccimx8x_sbc_pro1GB_defconfig,,u-boot-dtb.${UBOOT_SUFFIX}" -UBOOT_CONFIG[ccimx8x_sbc_pro512MB] = "ccimx8x_sbc_pro512MB_defconfig,,u-boot-dtb.${UBOOT_SUFFIX}" +UBOOT_CONFIG ??= "ccimx8x_sbc_pro" +UBOOT_CONFIG[ccimx8x_sbc_pro] = "ccimx8x_sbc_pro_defconfig,,u-boot-dtb.${UBOOT_SUFFIX}" +SPL_BINARY = "spl/u-boot-spl.bin" KERNEL_DEVICETREE ?= " \ digi/ccimx8x-sbc-pro.dtb \ @@ -49,17 +48,11 @@ IMAGE_FSTYPES ?= '${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", \ # Boot artifacts to be copied from the deploy dir to the installer ZIP BOOTABLE_ARTIFACTS = " \ - imx-boot-ccimx8x-sbc-pro-B0-1GB_16bit.bin \ - imx-boot-ccimx8x-sbc-pro-B0-1GB_32bit.bin \ - imx-boot-ccimx8x-sbc-pro-B0-2GB_32bit.bin \ - imx-boot-ccimx8x-sbc-pro-B0-512MB_16bit.bin \ - imx-boot-ccimx8x-sbc-pro-C0-1GB_16bit.bin \ - imx-boot-ccimx8x-sbc-pro-C0-1GB_32bit.bin \ - imx-boot-ccimx8x-sbc-pro-C0-2GB_32bit.bin \ - imx-boot-ccimx8x-sbc-pro-C0-512MB_16bit.bin \ + imx-boot-ccimx8x-sbc-pro-B0.bin \ + imx-boot-ccimx8x-sbc-pro-C0.bin \ " # Default overlayfs_etc mount point and type OVERLAYFS_ETC_MOUNT_POINT ?= "/mnt/data" OVERLAYFS_ETC_DEVICE ?= "/dev/mmcblk0p7" -OVERLAYFS_ETC_FSTYPE ?= "ext4" \ No newline at end of file +OVERLAYFS_ETC_FSTYPE ?= "ext4" diff --git a/meta-digi-arm/conf/machine/ccimx93-dvk.conf b/meta-digi-arm/conf/machine/ccimx93-dvk.conf index cd9bee422..e8201cea0 100644 --- a/meta-digi-arm/conf/machine/ccimx93-dvk.conf +++ b/meta-digi-arm/conf/machine/ccimx93-dvk.conf @@ -14,6 +14,9 @@ UBOOT_CONFIG ??= "ccimx93-dvk" UBOOT_CONFIG[ccimx93-dvk] = "ccimx93-dvk_defconfig" UBOOT_DTB_NAME = "ccimx93-dvk.dtb" +BOOTLOADER_SEEK_USERDATA = "32" +BOOTLOADER_SEEK_BOOT = "0" + KERNEL_DEVICETREE ?= " \ digi/ccimx93-dvk.dtb \ digi/_ov_board_dsi_display_ccimx93-dvk.dtbo \ diff --git a/meta-digi-arm/conf/machine/ccmp13-dvk.conf b/meta-digi-arm/conf/machine/ccmp13-dvk.conf index c64f2706c..ffe3de0fa 100644 --- a/meta-digi-arm/conf/machine/ccmp13-dvk.conf +++ b/meta-digi-arm/conf/machine/ccmp13-dvk.conf @@ -17,8 +17,9 @@ MACHINEOVERRIDES = "arm:armv7ve:stcommon:stm32mpcommon:stm32mp1common:${DIGI_FAM # ========================================================================= # boot device # ========================================================================= -# Configure the list of boards that enable NAND +# Configure the list of boards that enable NAND/SDCARD DEVICE_BOARD_ENABLE:NAND += "ccmp13-dvk" +DEVICE_BOARD_ENABLE:SDCARD += "${@bb.utils.contains('BOOTDEVICE_LABELS', 'sdcard', 'ccmp13-dvk', '', d)}" # ========================================================================= # U-Boot configs @@ -92,12 +93,6 @@ ST_TOOLS_FOR_SDK:remove = "nativesdk-gcc-arm-none-eabi" # activate/deactivate the debug and trace on boot stage ST_DEBUG_TRACE = "0" -# ========================================================================= -# trusted-firmware-a -# ========================================================================= -# Configure trusted-firmware-a build -TF_A_CONFIG = "optee nand" - # ========================================================================= # optee # ========================================================================= @@ -114,6 +109,7 @@ OPTEE_CONF = "ccmp13-dvk" KERNEL_IMAGETYPE = "zImage" KERNEL_ALT_IMAGETYPE = "Image uImage vmlinux" KERNEL_DEFCONFIG ?= "ccmp1_defconfig" +KERNEL_EXTERNAL_DEFCONFIG ?= "defconfig" ST_KERNEL_LOADADDR ?= "0xC0008000" # ========================================================================= @@ -166,5 +162,5 @@ BOOTABLE_ARTIFACTS = " \ # Default overlayfs_etc mount point and type OVERLAYFS_ETC_MOUNT_POINT ?= "/mnt/data" -OVERLAYFS_ETC_DEVICE ?= "ubi0:data" +OVERLAYFS_ETC_DEVICE ?= "ubi1:data" OVERLAYFS_ETC_FSTYPE ?= "ubifs" diff --git a/meta-digi-arm/conf/machine/ccmp15-dvk.conf b/meta-digi-arm/conf/machine/ccmp15-dvk.conf index f87e95cf0..bf45951ff 100644 --- a/meta-digi-arm/conf/machine/ccmp15-dvk.conf +++ b/meta-digi-arm/conf/machine/ccmp15-dvk.conf @@ -17,8 +17,9 @@ MACHINEOVERRIDES = "arm:armv7ve:stcommon:stm32mpcommon:stm32mp1common:${DIGI_FAM # ========================================================================= # boot device # ========================================================================= -# Configure the list of boards that enable NAND +# Configure the list of boards that enable NAND/SDCARD DEVICE_BOARD_ENABLE:NAND += "ccmp15-dvk" +DEVICE_BOARD_ENABLE:SDCARD += "${@bb.utils.contains('BOOTDEVICE_LABELS', 'sdcard', 'ccmp15-dvk', '', d)}" # ========================================================================= # U-Boot configs @@ -50,6 +51,7 @@ STM32MP_KERNEL_DEVICETREE:ccmp15-dvk += " \ _ov_board_v1_ccmp15-dvk.dtbo \ _ov_som_bt_ccmp15.dtbo \ _ov_som_bt_test_ccmp15.dtbo \ + _ov_som_mca_ccmp15.dtbo \ _ov_som_wifi_ccmp15.dtbo \ " @@ -99,12 +101,6 @@ ST_TOOLS_FOR_SDK:remove = "nativesdk-gcc-arm-none-eabi" # activate/deactivate the debug and trace on boot stage ST_DEBUG_TRACE = "0" -# ========================================================================= -# trusted-firmware-a -# ========================================================================= -# Configure trusted-firmware-a build -TF_A_CONFIG = "optee nand" - # ========================================================================= # optee # ========================================================================= @@ -121,6 +117,7 @@ OPTEE_CONF = "ccmp15-dvk" KERNEL_IMAGETYPE = "zImage" KERNEL_ALT_IMAGETYPE = "Image uImage vmlinux" KERNEL_DEFCONFIG ?= "ccmp1_defconfig" +KERNEL_EXTERNAL_DEFCONFIG ?= "defconfig" ST_KERNEL_LOADADDR ?= "0xC0008000" # ========================================================================= @@ -170,5 +167,5 @@ BOOTABLE_ARTIFACTS = " \ # Default overlayfs_etc mount point and type OVERLAYFS_ETC_MOUNT_POINT ?= "/mnt/data" -OVERLAYFS_ETC_DEVICE ?= "ubi0:data" +OVERLAYFS_ETC_DEVICE ?= "ubi1:data" OVERLAYFS_ETC_FSTYPE ?= "ubifs" diff --git a/meta-digi-arm/conf/machine/include/ccimx6.inc b/meta-digi-arm/conf/machine/include/ccimx6.inc index 90cfacf0f..f90064980 100644 --- a/meta-digi-arm/conf/machine/include/ccimx6.inc +++ b/meta-digi-arm/conf/machine/include/ccimx6.inc @@ -11,6 +11,8 @@ include conf/machine/include/arm/armv7a/tune-cortexa9.inc # Platform u-boot settings UBOOT_PREFIX = "u-boot" UBOOT_SUFFIX = "imx" +BOOTABLE_FILENAME = "${UBOOT_PREFIX}-${MACHINE}.${UBOOT_SUFFIX}" +SDIMG_BOOTLOADER = "${DEPLOY_DIR_IMAGE}/${BOOTABLE_FILENAME}" # Linux kernel configuration KERNEL_DEFCONFIG ?= "arch/arm/configs/ccimx6sbc_defconfig" diff --git a/meta-digi-arm/conf/machine/include/ccimx8x.inc b/meta-digi-arm/conf/machine/include/ccimx8x.inc index e48438e53..000cc3834 100644 --- a/meta-digi-arm/conf/machine/include/ccimx8x.inc +++ b/meta-digi-arm/conf/machine/include/ccimx8x.inc @@ -23,12 +23,6 @@ BOOTLOADER_SEEK_BOOT ?= "0" BOOTABLE_FILENAME = "${UBOOT_PREFIX}-${MACHINE}.bin" SDIMG_BOOTLOADER = "${DEPLOY_DIR_IMAGE}/${BOOTABLE_FILENAME}" -# RAM variants -# This determines the number of different DCD files, and thus the number of -# different U-Boot binaries required. -# Last one is the default (the one the symlinks point at) -RAM_CONFIGS = "512MB_16bit 1GB_16bit 1GB_32bit 2GB_32bit" - # The original variable used by NXP to store the mkimage "REV" parameter, # REV_OPTION, has a format of "REV=X0". Since we are interested in building # images for multiple revisions and using the revision in the imx-boot filename, @@ -70,6 +64,13 @@ MACHINE_FEATURES += "accel-graphics wifi bluetooth cryptochip pci mca" # TrustFence TRUSTFENCE_SIGN_MODE = "AHAB" +IMXBOOT_TARGETS = "flash_spl" + +IMX_BOOT_SOC_TARGET = "iMX8QX" +IMX_BOOT_SEEK = "32" + +IMX_EXTRA_FIRMWARE:mx8x-generic-bsp = "digi-sc-firmware imx-seco" + # SWUpdate sw-description configuration BOOTFS_EXT ?= ".boot.vfat" ROOTFS_EXT ?= '${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", ".squashfs", ".ext4.gz", d)}' diff --git a/meta-digi-arm/conf/machine/include/ccmp1.inc b/meta-digi-arm/conf/machine/include/ccmp1.inc index 7a96ef851..15ff18221 100644 --- a/meta-digi-arm/conf/machine/include/ccmp1.inc +++ b/meta-digi-arm/conf/machine/include/ccmp1.inc @@ -44,12 +44,26 @@ MACHINE_EXTRA_RDEPENDS += " \ # Image FS types IMAGE_FSTYPES:remove = "ext4 tar.xz" +IMAGE_FSTYPES:append = " ${@bb.utils.contains('BOOTDEVICE_LABELS', 'sdcard', 'boot.vfat ext4.gz', '', d)}" # List of supported boot devices -BOOTDEVICE_LABELS ?= "sdcard" +BOOTDEVICE_LABELS ?= "nand-4-256" +# Supported boot schemes +BOOTSCHEME_LABELS ?= "optee" + +# Wic files +WKS_FILE += "ccmp1.wks.in" +WKS_FILE_DEPENDS ?= " \ + virtual/bootloader \ + virtual/trusted-firmware-a \ + ${@bb.utils.contains('BOOTSCHEME_LABELS', 'optee', 'virtual/optee-os', '', d)} \ +" # Default secure console configuration TRUSTFENCE_CONSOLE_DISABLE ?= "0" # Alternatively, uncommment to enable the console autoboot stop passphrase # TRUSTFENCE_CONSOLE_PASSPHRASE_ENABLE = "" + +# Disable the generation of flashlayout files +do_create_flashlayout_config[noexec] = "1" diff --git a/meta-digi-arm/conf/machine/include/digi-defaults.inc b/meta-digi-arm/conf/machine/include/digi-defaults.inc index af46097ae..8abd7f5c5 100644 --- a/meta-digi-arm/conf/machine/include/digi-defaults.inc +++ b/meta-digi-arm/conf/machine/include/digi-defaults.inc @@ -85,10 +85,10 @@ DEY_SELINUX_POLICY ?= "1" # U-Boot scripts to include in 'linux' partition # (use the '+=' operator, since other layers may append scripts to this list) -BOOT_SCRIPTS += "boot.scr:boot.scr altboot.scr:altboot.scr" +BOOT_SCRIPTS += "boot.scr:boot.scr" # This can be used to enable U-Boot update through swupdate SWUPDATE_UBOOTIMG ?= "false" -# Cloud Connector package to install -CLOUDCONNECTOR_PKG ?= "cloudconnector" +# ConnectCore Cloud Services packages to install +CCCS_PKGS ?= "cccs-gs-demo dey-examples-cccs" diff --git a/meta-digi-arm/conf/machine/include/imx-digi-base.inc b/meta-digi-arm/conf/machine/include/imx-digi-base.inc index 6c7ef4461..55eb59536 100644 --- a/meta-digi-arm/conf/machine/include/imx-digi-base.inc +++ b/meta-digi-arm/conf/machine/include/imx-digi-base.inc @@ -69,7 +69,7 @@ MACHINEOVERRIDES_EXTENDER:mx8mn:use-mainline-bsp = "imx-generic-bsp:imx-mainlin MACHINEOVERRIDES_EXTENDER:mx8mp:use-mainline-bsp = "imx-generic-bsp:imx-mainline-bsp:mx8-generic-bsp:mx8-mainline-bsp:mx8m-generic-bsp:mx8m-mainline-bsp:mx8mp-generic-bsp:mx8mp-mainline-bsp" MACHINEOVERRIDES_EXTENDER:mx8qxp:use-mainline-bsp = "imx-generic-bsp:imx-mainline-bsp:mx8-generic-bsp:mx8-mainline-bsp:mx8x-generic-bsp:mx8x-mainline-bsp:mx8qxp-generic-bsp:mx8qxp-mainline-bsp" MACHINEOVERRIDES_EXTENDER:mx8dx:use-mainline-bsp = "imx-generic-bsp:imx-mainline-bsp:mx8-generic-bsp:mx8-mainline-bsp:mx8x-generic-bsp:mx8x-mainline-bsp:mx8dx-generic-bsp:mx8dx-mainline-bsp" -MACHINEOVERRIDES_EXTENDER:mx93:use-mainline-bsp = "imx-generic-bsp:imx-mainline-bsp:imxdrm:imxpxp:mx9-generic-bsp:mx9-mainline-bsp:mx93-generic-bsp:mx93-mainline-bsp" +MACHINEOVERRIDES_EXTENDER:mx93:use-mainline-bsp = "imx-generic-bsp:imx-mainline-bsp:mx9-generic-bsp:mx9-mainline-bsp:mx93-generic-bsp:mx93-mainline-bsp" MACHINEOVERRIDES_EXTENDER_FILTER_OUT = " \ mx6 \ @@ -272,11 +272,20 @@ PREFERRED_VERSION_vulkan-tools:imxvulkan ??= "1.2.182.0" # Use i.MX optee Version PREFERRED_VERSION_optee-os:mx8-nxp-bsp ??= "3.19.0.imx" -PREFERRED_VERSION_optee-os:mx9-nxp-bsp ??= "3.19.0.imx" +PREFERRED_VERSION_optee-os:mx9-nxp-bsp ??= "3.21.0.imx" PREFERRED_VERSION_optee-client:mx8-nxp-bsp ??= "3.19.0.imx" -PREFERRED_VERSION_optee-client:mx9-nxp-bsp ??= "3.19.0.imx" +PREFERRED_VERSION_optee-client:mx9-nxp-bsp ??= "3.21.0.imx" PREFERRED_VERSION_optee-test:mx8-nxp-bsp ??= "3.19.0.imx" -PREFERRED_VERSION_optee-test:mx9-nxp-bsp ??= "3.19.0.imx" +PREFERRED_VERSION_optee-test:mx9-nxp-bsp ??= "3.21.0.imx" + +# Machine learning backports from NXP's lf-6.1.1_1.0.0 release +PREFERRED_VERSION_deepview-rt:ccimx93 = "2.4.46.1-aarch64" +PREFERRED_VERSION_ethos-u-vela:ccimx93 = "3.6.0" +PREFERRED_VERSION_flatbuffers:ccimx93 = "2.0.7" +PREFERRED_VERSION_flatbuffers-native:ccimx93 = "2.0.7" +PREFERRED_VERSION_tensorflow-lite:ccimx93 = "2.10.0" +PREFERRED_VERSION_tensorflow-lite-host-tools:ccimx93 = "2.10.0" +PREFERRED_VERSION_tensorflow-lite-host-tools-native:ccimx93 = "2.10.0" # Optee runtime packages to install OPTEE_PKGS ??= "optee-client optee-os" @@ -290,7 +299,7 @@ EXTRA_IMAGEDEPENDS += "u-boot" KERNEL_IMAGETYPE = "zImage" KERNEL_IMAGETYPE:aarch64 = "Image.gz" -MACHINE_FEATURES = "usbgadget usbhost vfat alsa touchscreen" +MACHINE_FEATURES = "usbgadget usbhost vfat alsa touchscreen screen" # IMX specific udev extra rules added when device manager is systemd/udev UDEV_EXTRA_RULES:append = " udev-rules-imx" diff --git a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/firmware-imx/firmware-imx-9_8.18.bb b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/firmware-imx/firmware-imx-9_8.20.bb similarity index 52% rename from meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/firmware-imx/firmware-imx-9_8.18.bb rename to meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/firmware-imx/firmware-imx-9_8.20.bb index 08a1b4e93..5a96865d9 100644 --- a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/firmware-imx/firmware-imx-9_8.18.bb +++ b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/firmware-imx/firmware-imx-9_8.20.bb @@ -2,7 +2,16 @@ SUMMARY = "Freescale i.MX firmware for i.MX 9 family" DESCRIPTION = "Freescale i.MX firmware for i.MX 9 family" -require recipes-bsp/firmware-imx/firmware-imx-${PV}.inc +# +# Use meta-freescale's firmware-imx-8.18.inc and ammend license and +# SRC_URI checksums +# +# require recipes-bsp/firmware-imx/firmware-imx-${PV}.inc +require recipes-bsp/firmware-imx/firmware-imx-8.18.inc + +LIC_FILES_CHKSUM = "file://COPYING;md5=63a38e9f392d8813d6f1f4d0d6fbe657" +SRC_URI[md5sum] = "25c50f3371450b2324401ee06ff1bf6a" +SRC_URI[sha256sum] = "f6dc6a5c8fd9b913a15360d3ccd53d188db05a08a8594c518e57622478c72383" inherit deploy diff --git a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/firmware-imx/firmware-nxp-wifi/ccimx93/sd_w61x_v1.bin.se b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/firmware-imx/firmware-nxp-wifi/ccimx93/sd_w61x_v1.bin.se new file mode 100644 index 000000000..4416129c8 Binary files /dev/null and b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/firmware-imx/firmware-nxp-wifi/ccimx93/sd_w61x_v1.bin.se differ diff --git a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/firmware-imx/firmware-nxp-wifi/ccimx93/sduart_nw61x_v1.bin.se b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/firmware-imx/firmware-nxp-wifi/ccimx93/sduart_nw61x_v1.bin.se deleted file mode 100644 index f9bcce6c7..000000000 Binary files a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/firmware-imx/firmware-nxp-wifi/ccimx93/sduart_nw61x_v1.bin.se and /dev/null differ diff --git a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/firmware-imx/firmware-nxp-wifi/ccimx93/uartspi_n61x_v1.bin.se b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/firmware-imx/firmware-nxp-wifi/ccimx93/uartspi_n61x_v1.bin.se new file mode 100644 index 000000000..89d030f6b Binary files /dev/null and b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/firmware-imx/firmware-nxp-wifi/ccimx93/uartspi_n61x_v1.bin.se differ diff --git a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/firmware-imx/firmware-nxp-wifi_%.bbappend b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/firmware-imx/firmware-nxp-wifi_%.bbappend index 59b9282a7..38b5cd8f5 100644 --- a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/firmware-imx/firmware-nxp-wifi_%.bbappend +++ b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/firmware-imx/firmware-nxp-wifi_%.bbappend @@ -8,14 +8,19 @@ SRCBRANCH:ccimx93 = "lf-6.1.1_1.0.0" SRCREV:ccimx93 = "bacbeb4789c1b13d13aab12ada29217ce8c3e905" # Use this temporal binary till it is released -SRC_URI:append:ccimx93 = " file://sduart_nw61x_v1.bin.se" +SRC_URI:append:ccimx93 = " \ + file://sd_w61x_v1.bin.se \ + file://uartspi_n61x_v1.bin.se \ +" do_install:append:ccimx93() { - install -m 444 ${WORKDIR}/sduart_nw61x_v1.bin.se ${D}${base_libdir}/firmware/nxp + install -m 444 ${WORKDIR}/sd_w61x_v1.bin.se ${D}${base_libdir}/firmware/nxp + install -m 444 ${WORKDIR}/uartspi_n61x_v1.bin.se ${D}${base_libdir}/firmware/nxp } PACKAGES:prepend:ccimx93 = "${PN}-nxpiw612 " FILES:${PN}-nxpiw612 = " \ - ${base_libdir}/firmware/nxp/sduart_nw61x_v1.bin.se \ + ${base_libdir}/firmware/nxp/sd_w61x_v1.bin.se \ + ${base_libdir}/firmware/nxp/uartspi_n61x_v1.bin.se \ " diff --git a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/firmware-sentinel/firmware-sentinel_0.10.bb b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/firmware-sentinel/firmware-sentinel_0.10.bb new file mode 100644 index 000000000..7a71ee87b --- /dev/null +++ b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/firmware-sentinel/firmware-sentinel_0.10.bb @@ -0,0 +1,29 @@ +# Copyright 2021-2023 NXP +SUMMARY = "NXP i.MX Sentinel firmware" +DESCRIPTION = "Firmware for i.MX Sentinel Security Controller" +SECTION = "base" +LICENSE = "Proprietary" +LIC_FILES_CHKSUM = "file://COPYING;md5=63a38e9f392d8813d6f1f4d0d6fbe657" + +inherit fsl-eula-unpack use-imx-security-controller-firmware deploy + +SRC_URI = "${FSL_MIRROR}/${BP}.bin;fsl-eula=true" +SRC_URI[md5sum] = "a92e272d665a3b3bb9281253d5eca69f" +SRC_URI[sha256sum] = "be862b62c849510cce08ec24c1ddf53d826458e326e5a7f09c4b35092d6f9950" + +do_compile[noexec] = "1" + +do_install() { + install -d ${D}${nonarch_base_libdir}/firmware/imx/ele + install -m 0644 ${S}/${SECO_FIRMWARE_NAME} ${D}${nonarch_base_libdir}/firmware/imx/ele +} + +do_deploy () { + # Deploy the related firmware to be package by imx-boot + install -m 0644 ${S}/${SECO_FIRMWARE_NAME} ${DEPLOYDIR} +} +addtask deploy after do_install before do_build + +FILES:${PN} += "${nonarch_base_libdir}/firmware/imx/ele/${SECO_FIRMWARE_NAME}" + +COMPATIBLE_MACHINE = "(mx8ulp-nxp-bsp|mx9-nxp-bsp)" diff --git a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/imx-atf/imx-atf/0005-ccimx93-use-UART6-for-the-default-console.patch b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/imx-atf/imx-atf/0005-ccimx93-use-UART6-for-the-default-console.patch index 3bc032412..49e60da78 100644 --- a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/imx-atf/imx-atf/0005-ccimx93-use-UART6-for-the-default-console.patch +++ b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/imx-atf/imx-atf/0005-ccimx93-use-UART6-for-the-default-console.patch @@ -8,12 +8,12 @@ Signed-off-by: Javier Viguera 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plat/imx/imx93/include/platform_def.h b/plat/imx/imx93/include/platform_def.h -index a820c27a5b49..a563d8852d23 100644 +index 59ce1c267568..c4855d7f5e82 100644 --- a/plat/imx/imx93/include/platform_def.h +++ b/plat/imx/imx93/include/platform_def.h -@@ -47,7 +47,7 @@ - #define MAX_XLAT_TABLES 12 +@@ -53,7 +53,7 @@ #define MAX_MMAP_REGIONS 16 + #endif -#define IMX_LPUART_BASE 0x44380000 +#define IMX_LPUART_BASE 0x425a0000 diff --git a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/imx-atf/imx-atf_2.6.bbappend b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/imx-atf/imx-atf_%.bbappend similarity index 92% rename from meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/imx-atf/imx-atf_2.6.bbappend rename to meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/imx-atf/imx-atf_%.bbappend index 8eeba6d29..9d804184b 100644 --- a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/imx-atf/imx-atf_2.6.bbappend +++ b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/imx-atf/imx-atf_%.bbappend @@ -2,11 +2,13 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}:" -SRC_URI:append = " \ +SRC_URI:append:ccimx8m = " \ file://0001-imx8mm-Define-UART1-as-console-for-boot-stage.patch \ file://0002-imx8mm-Disable-M4-debug-console.patch \ file://0003-imx8mn-Define-UART1-as-console-for-boot-stage.patch \ file://0004-imx8mn-Disable-M7-debug-console.patch \ +" +SRC_URI:append:ccimx93 = " \ file://0005-ccimx93-use-UART6-for-the-default-console.patch \ " diff --git a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/imx-atf/imx-atf_2.8.bb b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/imx-atf/imx-atf_2.8.bb new file mode 100644 index 000000000..ef98ab91a --- /dev/null +++ b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/imx-atf/imx-atf_2.8.bb @@ -0,0 +1,12 @@ +# Copyright 2023 Digi International Inc. + +# +# Reuse meta-freescale's imx-atf_2.6.bb +# +require recipes-bsp/imx-atf/imx-atf_2.6.bb + +SRC_URI = "git://github.com/nxp-imx/imx-atf.git;protocol=https;branch=${SRCBRANCH}" +SRCBRANCH = "lf_v2.8" +SRCREV = "99195a23d3aef485fb8f10939583b1bdef18881c" + +COMPATIBLE_MACHINE = "(ccimx93)" diff --git a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/imx-mkimage/imx-boot_1.0.bbappend b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/imx-mkimage/imx-boot_1.0.bbappend index 5b93391e8..918a7310c 100644 --- a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/imx-mkimage/imx-boot_1.0.bbappend +++ b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/imx-mkimage/imx-boot_1.0.bbappend @@ -2,11 +2,16 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/files:" -SRC_URI:append = " \ +SRC_URI:append:ccimx8m = " \ file://0001-imx8m-soc.mak-preserve-dtbs-after-build.patch \ file://0002-imx8m-soc.mak-capture-commands-output-into-a-log-fil.patch \ " +# Use NXP's lf-6.1.22-2.0.0 release for ccimx93 +SRC_URI:ccimx93 = "git://github.com/nxp-imx/imx-mkimage.git;protocol=https;branch=${SRCBRANCH}" +SRCBRANCH:ccimx93 = "lf-6.1.22_2.0.0" +SRCREV:ccimx93 = "5cfd218012e080fb907d9cc301fbb4ece9bc17a9" + DEPENDS += "${@oe.utils.conditional('TRUSTFENCE_SIGN', '1', 'trustfence-sign-tools-native', '', d)}" # Do not tag imx-boot @@ -25,7 +30,42 @@ do_compile:append:ccimx8m() { make SOC=${IMX_BOOT_SOC_TARGET} dtbs=${UBOOT_DTB_NAME} print_fit_hab } -do_deploy:append() { +do_compile:ccimx8x () { + compile_${SOC_FAMILY} + if ${DEPLOY_OPTEE}; then + cp ${DEPLOY_DIR_IMAGE}/tee.bin {BOOT_STAGING} + fi + # mkimage for i.MX8 + + for target in ${IMXBOOT_TARGETS}; do + for rev in ${SOC_REVISIONS}; do + bbnote "building ${IMX_BOOT_SOC_TARGET} - REV=${rev} ${target}" + make SOC=${IMX_BOOT_SOC_TARGET} dtbs=${UBOOT_DTB_NAME} REV=${rev} ${target} > ${S}/mkimage-${rev}-${target}.log 2>&1 + if [ -e "${BOOT_STAGING}/flash.bin" ]; then + cp ${BOOT_STAGING}/flash.bin ${S}/${UBOOT_PREFIX}-${MACHINE}-${rev}.bin-${target} + fi + SCFWBUILT="yes" + # Remove u-boot-atf-container.img so it gets generated in the next iteration + rm ${BOOT_STAGING}/u-boot-atf-container.img + done + done + + # Check that SCFW was built at least once + if [ "${IMX_BOOT_SOC_TARGET}" = "iMX8QX" and "${SCFWBUILT}" != "yes" ]; then + bbfatal "SCFW was not built!" + fi +} + +do_install:ccimx8x () { + install -d ${D}/boot + for bin in ${BOOTABLE_ARTIFACTS}; do + for target in ${IMXBOOT_TARGETS}; do + install -m 0644 ${S}/${bin}-${target} ${D}/boot/ + done + done +} + +generate_symlinks() { # imx-boot recipe in meta-freescale assumes only *one* build configuration # (otherwise variable BOOT_CONFIG_MACHINE would expand to something incorrect) for target in ${IMXBOOT_TARGETS}; do @@ -36,12 +76,47 @@ do_deploy:append() { } do_deploy:append:ccimx8m() { + generate_symlinks for target in ${IMXBOOT_TARGETS}; do install -m 0644 ${BOOT_STAGING}/mkimage-${target}.log ${DEPLOYDIR}/${BOOT_TOOLS} done install -m 0644 ${BOOT_STAGING}/mkimage-print_fit_hab.log ${DEPLOYDIR}/${BOOT_TOOLS} } +do_deploy:append:ccimx93() { + generate_symlinks +} + +do_deploy:ccimx8x () { + deploy_${SOC_FAMILY} + # copy tee.bin to deploy path + if "${DEPLOY_OPTEE}"; then + install -m 0644 ${DEPLOY_DIR_IMAGE}/tee.bin ${DEPLOYDIR}/${BOOT_TOOLS} + fi + # copy makefile (soc.mak) for reference + install -m 0644 ${BOOT_STAGING}/soc.mak ${DEPLOYDIR}/${BOOT_TOOLS} + # copy the generated boot image to deploy path + for rev in ${SOC_REVISIONS}; do + IMAGE_IMXBOOT_TARGET="" + for target in ${IMXBOOT_TARGETS}; do + # Use first "target" as IMAGE_IMXBOOT_TARGET + if [ "$IMAGE_IMXBOOT_TARGET" = "" ]; then + IMAGE_IMXBOOT_TARGET="$target" + echo "Set boot target as $IMAGE_IMXBOOT_TARGET" + fi + install -m 0644 ${S}/${UBOOT_PREFIX}-${MACHINE}-${rev}.bin-${target} ${DEPLOYDIR} + # copy make log for reference + install -m 0644 ${S}/mkimage-${rev}-${target}.log ${DEPLOYDIR}/${BOOT_TOOLS} + done + cd ${DEPLOYDIR} + ln -sf ${UBOOT_PREFIX}-${MACHINE}-${rev}.bin-${IMAGE_IMXBOOT_TARGET} ${UBOOT_PREFIX}-${MACHINE}-${rev}.bin + # Link to default bootable U-Boot filename. It gets overwritten + # on every loop so the only last RAM_CONFIG will survive. + ln -sf ${UBOOT_PREFIX}-${MACHINE}-${rev}.bin-${IMAGE_IMXBOOT_TARGET} ${BOOTABLE_FILENAME} + cd - + done +} + do_deploy[postfuncs] += "${@oe.utils.conditional('TRUSTFENCE_SIGN', '1', 'trustfence_sign_imxboot', '', d)}" trustfence_sign_imxboot() { TF_SIGN_ENV="CONFIG_SIGN_KEYS_PATH=${TRUSTFENCE_SIGN_KEYS_PATH}" @@ -61,5 +136,25 @@ trustfence_sign_imxboot() { fi done } + +trustfence_sign_imxboot:ccimx8x() { + TF_SIGN_ENV="CONFIG_SIGN_KEYS_PATH=${TRUSTFENCE_SIGN_KEYS_PATH}" + [ -n "${TRUSTFENCE_KEY_INDEX}" ] && TF_SIGN_ENV="$TF_SIGN_ENV CONFIG_KEY_INDEX=${TRUSTFENCE_KEY_INDEX}" + [ -n "${TRUSTFENCE_SIGN_MODE}" ] && TF_SIGN_ENV="$TF_SIGN_ENV CONFIG_SIGN_MODE=${TRUSTFENCE_SIGN_MODE}" + [ -n "${TRUSTFENCE_SRK_REVOKE_MASK}" ] && TF_SIGN_ENV="$TF_SIGN_ENV SRK_REVOKE_MASK=${TRUSTFENCE_SRK_REVOKE_MASK}" + + # Sign/encrypt boot image + for target in ${IMXBOOT_TARGETS}; do + for rev in ${SOC_REVISIONS}; do + TF_SIGN_ENV="$TF_SIGN_ENV CONFIG_MKIMAGE_LOG_PATH=${DEPLOYDIR}/${BOOT_TOOLS}/mkimage-${rev}-${target}.log" + env $TF_SIGN_ENV trustfence-sign-uboot.sh ${BOOT_NAME}-${MACHINE}-${rev}.bin-${target} ${BOOT_NAME}-signed-${MACHINE}-${rev}.bin-${target} + if [ -n "${TRUSTFENCE_DEK_PATH}" ] && [ "${TRUSTFENCE_DEK_PATH}" != "0" ]; then + TF_ENC_ENV="CONFIG_DEK_PATH=${TRUSTFENCE_DEK_PATH} ENABLE_ENCRYPTION=y" + env $TF_SIGN_ENV $TF_ENC_ENV trustfence-sign-uboot.sh ${BOOT_NAME}-${MACHINE}-${rev}.bin-${target} ${BOOT_NAME}-encrypted-${MACHINE}-${rev}.bin-${target} + fi + done + done +} + trustfence_sign_imxboot[dirs] = "${DEPLOYDIR}" trustfence_sign_imxboot[vardeps] += "TRUSTFENCE_SIGN_KEYS_PATH TRUSTFENCE_KEY_INDEX TRUSTFENCE_DEK_PATH TRUSTFENCE_SIGN_MODE TRUSTFENCE_SRK_REVOKE_MASK TRUSTFENCE_UNLOCK_KEY_REVOCATION" diff --git a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/imx-mkimage/imx-mkimage_git.bbappend b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/imx-mkimage/imx-mkimage_git.bbappend index d6305ff21..18a4a08c3 100644 --- a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/imx-mkimage/imx-mkimage_git.bbappend +++ b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-bsp/imx-mkimage/imx-mkimage_git.bbappend @@ -2,10 +2,15 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/files:" -SRC_URI:append = " \ +SRC_URI:append:ccimx8m = " \ file://0001-imx8m-soc.mak-preserve-dtbs-after-build.patch \ " +# Use NXP's lf-6.1.22-2.0.0 release for ccimx93 +SRC_URI:ccimx93 = "git://github.com/nxp-imx/imx-mkimage.git;protocol=https;branch=${SRCBRANCH}" +SRCBRANCH:ccimx93 = "lf-6.1.22_2.0.0" +SRCREV:ccimx93 = "5cfd218012e080fb907d9cc301fbb4ece9bc17a9" + # "fmacro-prefix-map" is not supported on old versions of GCC DEBUG_PREFIX_MAP:remove:class-nativesdk = "-fmacro-prefix-map=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}" diff --git a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-security/optee-imx/optee-client/tee-supplicant.service b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-security/optee-imx/optee-client/tee-supplicant.service new file mode 100644 index 000000000..0e2b4f6ba --- /dev/null +++ b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-security/optee-imx/optee-client/tee-supplicant.service @@ -0,0 +1,11 @@ +[Unit] +Description=TEE Supplicant + +[Service] +User=root +EnvironmentFile=-/etc/default/tee-supplicant +ExecStart=/usr/bin/tee-supplicant $OPTARGS + +[Install] +WantedBy=basic.target + diff --git a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-security/optee-imx/optee-client_3.21.0.imx.bb b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-security/optee-imx/optee-client_3.21.0.imx.bb new file mode 100644 index 000000000..882b390cd --- /dev/null +++ b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-security/optee-imx/optee-client_3.21.0.imx.bb @@ -0,0 +1,15 @@ +# Copyright 2023 Digi International Inc. + +# +# Reuse meta-freescale's optee-client_3.19.0.imx.bb +# +require recipes-security/optee-imx/optee-client_3.19.0.imx.bb + +SRCBRANCH = "lf-6.1.22_2.0.0" +SRCREV = "8533e0e6329840ee96cf81b6453f257204227e6c" + +# Otherwise optee-client's makefile defaults to use $(CROSS_COMPILE)pkg-config +# which is not what Yocto provides. +export PKG_CONFIG='pkg-config' + +COMPATIBLE_MACHINE = "(ccimx93)" diff --git a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-security/optee-imx/optee-os/0001-core-imx-support-ccimx93-dvk.patch b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-security/optee-imx/optee-os/0001-core-imx-support-ccimx93-dvk.patch new file mode 100644 index 000000000..ed58a2f7b --- /dev/null +++ b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-security/optee-imx/optee-os/0001-core-imx-support-ccimx93-dvk.patch @@ -0,0 +1,46 @@ +From: Javier Viguera +Date: Mon, 15 May 2023 17:59:54 +0200 +Subject: [PATCH] core: imx: support ccimx93-dvk + +Signed-off-by: Javier Viguera +--- + core/arch/arm/plat-imx/conf.mk | 6 ++++++ + core/arch/arm/plat-imx/registers/imx93.h | 1 + + 2 files changed, 7 insertions(+) + +diff --git a/core/arch/arm/plat-imx/conf.mk b/core/arch/arm/plat-imx/conf.mk +index 1d5081f96afe..5e2d0733dd04 100644 +--- a/core/arch/arm/plat-imx/conf.mk ++++ b/core/arch/arm/plat-imx/conf.mk +@@ -88,6 +88,7 @@ mx8ulp-flavorlist = \ + mx8ulpevk \ + + mx93-flavorlist = \ ++ ccimx93dvk \ + mx93evk \ + + ifneq (,$(filter $(PLATFORM_FLAVOR),$(mx6ul-flavorlist))) +@@ -449,6 +450,11 @@ CFG_DDR_SIZE ?= 0x80000000 + CFG_UART_BASE ?= UART1_BASE + endif + ++ifneq (,$(filter $(PLATFORM_FLAVOR),ccimx93dvk)) ++CFG_DDR_SIZE ?= 0x40000000 ++CFG_UART_BASE ?= UART6_BASE ++endif ++ + # i.MX6 Solo/SL/SoloX/DualLite/Dual/Quad specific config + ifeq ($(filter y, $(CFG_MX6QP) $(CFG_MX6Q) $(CFG_MX6D) $(CFG_MX6DL) $(CFG_MX6S) \ + $(CFG_MX6SL) $(CFG_MX6SLL) $(CFG_MX6SX)), y) +diff --git a/core/arch/arm/plat-imx/registers/imx93.h b/core/arch/arm/plat-imx/registers/imx93.h +index e91607537380..66a6408109c2 100644 +--- a/core/arch/arm/plat-imx/registers/imx93.h ++++ b/core/arch/arm/plat-imx/registers/imx93.h +@@ -9,6 +9,7 @@ + #define GICR_BASE 0x48040000 + + #define UART1_BASE 0x44380000 ++#define UART6_BASE 0x425a0000 + #define MU_BASE 0x47520000 + #define MU_SIZE 0x10000 + diff --git a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-security/optee-imx/optee-os/0007-allow-setting-sysroot-for-clang.patch b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-security/optee-imx/optee-os/0007-allow-setting-sysroot-for-clang.patch new file mode 100644 index 000000000..067ba6ebf --- /dev/null +++ b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-security/optee-imx/optee-os/0007-allow-setting-sysroot-for-clang.patch @@ -0,0 +1,30 @@ +From db9e44af75c7cfd3316cab15aaa387383df3e57e Mon Sep 17 00:00:00 2001 +From: Brett Warren +Date: Wed, 23 Sep 2020 09:27:34 +0100 +Subject: [PATCH] optee: enable clang support + +When compiling with clang, the LIBGCC_LOCATE_CFLAG variable used +to provide a sysroot wasn't included, which results in not locating +compiler-rt. This is mitigated by including the variable as ammended. + +Upstream-Status: Pending +ChangeId: 8ba69a4b2eb8ebaa047cb266c9aa6c2c3da45701 +Signed-off-by: Brett Warren + +--- + mk/clang.mk | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/mk/clang.mk b/mk/clang.mk +index c141a3f2..7d067cc0 100644 +--- a/mk/clang.mk ++++ b/mk/clang.mk +@@ -27,7 +27,7 @@ comp-cflags-warns-clang := -Wno-language-extension-token \ + + # Note, use the compiler runtime library (libclang_rt.builtins.*.a) instead of + # libgcc for clang +-libgcc$(sm) := $(shell $(CC$(sm)) $(CFLAGS$(arch-bits-$(sm))) \ ++libgcc$(sm) := $(shell $(CC$(sm)) $(LIBGCC_LOCATE_CFLAGS) $(CFLAGS$(arch-bits-$(sm))) \ + -rtlib=compiler-rt -print-libgcc-file-name 2> /dev/null) + + # Core ASLR relies on the executable being ready to run from its preferred load diff --git a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-security/optee-imx/optee-os_3.21.0.imx.bb b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-security/optee-imx/optee-os_3.21.0.imx.bb new file mode 100644 index 000000000..d837d877a --- /dev/null +++ b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-security/optee-imx/optee-os_3.21.0.imx.bb @@ -0,0 +1,18 @@ +# Copyright 2023 Digi International Inc. + +# +# Reuse meta-freescale's optee-os_3.19.0.imx.bb +# +require recipes-security/optee-imx/optee-os_3.19.0.imx.bb + +SRC_URI = " \ + git://github.com/nxp-imx/imx-optee-os.git;protocol=https;branch=${SRCBRANCH} \ + file://0007-allow-setting-sysroot-for-clang.patch \ + file://0001-core-imx-support-ccimx93-dvk.patch \ +" +SRCBRANCH = "lf-6.1.22_2.0.0" +SRCREV = "1962aec9581760803b1485d455cd62cb11c14870" + +PLATFORM_FLAVOR:ccimx93 = "ccimx93dvk" + +COMPATIBLE_MACHINE = "(ccimx93)" diff --git a/meta-digi-arm/dynamic-layers/freescale-layer/recipes-security/optee-imx/optee-test_3.21.0.imx.bb b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-security/optee-imx/optee-test_3.21.0.imx.bb new file mode 100644 index 000000000..916da297c --- /dev/null +++ b/meta-digi-arm/dynamic-layers/freescale-layer/recipes-security/optee-imx/optee-test_3.21.0.imx.bb @@ -0,0 +1,11 @@ +# Copyright 2023 Digi International Inc. + +# +# Reuse meta-freescale's optee-test_3.19.0.imx.bb +# +require recipes-security/optee-imx/optee-test_3.19.0.imx.bb + +SRCBRANCH = "lf-6.1.22_2.0.0" +SRCREV = "c2c9f922044d2c8a7ab384812bb124c6da2b7888" + +COMPATIBLE_MACHINE = "(ccimx93)" diff --git a/meta-digi-arm/dynamic-layers/stm-st-stm32mp/recipes-bsp/trusted-firmware-a/tf-a-stm32mp_%.bbappend b/meta-digi-arm/dynamic-layers/stm-st-stm32mp/recipes-bsp/trusted-firmware-a/tf-a-stm32mp_%.bbappend index fab4ddbb6..459ffc4e4 100644 --- a/meta-digi-arm/dynamic-layers/stm-st-stm32mp/recipes-bsp/trusted-firmware-a/tf-a-stm32mp_%.bbappend +++ b/meta-digi-arm/dynamic-layers/stm-st-stm32mp/recipes-bsp/trusted-firmware-a/tf-a-stm32mp_%.bbappend @@ -17,7 +17,7 @@ SRC_URI = " \ TF_A_CONFIG[nand] = "${DEVICE_BOARD_ENABLE:NAND},STM32MP_RAW_NAND=1 ${@'STM32MP_FORCE_MTD_START_OFFSET=${TF_A_MTD_START_OFFSET_NAND}' if ${TF_A_MTD_START_OFFSET_NAND} else ''} STM32MP_USB_PROGRAMMER=1" DEPENDS += " \ - ${@oe.utils.conditional('TRUSTFENCE_SIGN', '1', 'trustfence-sign-tools-native trustfence-genpki-native', '', d)} \ + ${@oe.utils.conditional('TRUSTFENCE_SIGN', '1', 'trustfence-sign-tools-native', '', d)} \ " # This dependency is required so that the PKI generation completes before @@ -28,6 +28,15 @@ do_install[depends] = " \ openssl-native:do_populate_sysroot \ " +# Generate PKI tree if it doesn't exist. +# This is an append to do_compile because in this recipe, the do_deploy +# task comes right after do_compile, and the keys must be ready before that. +do_compile:append() { + if ${@oe.utils.conditional('TRUSTFENCE_SIGN','1','true','false',d)}; then + check_gen_pki_tree + fi +} + # Obtain password to use in FIP generation # Get password from file using the given key index do_deploy[prefuncs] += "${@oe.utils.conditional('TRUSTFENCE_SIGN', '1', 'set_fip_sign_key', '', d)}" diff --git a/meta-digi-arm/dynamic-layers/stm-st-stm32mp/recipes-security/optee/optee-os-stm32mp_%.bbappend b/meta-digi-arm/dynamic-layers/stm-st-stm32mp/recipes-security/optee/optee-os-stm32mp_%.bbappend index ec8bc733a..d3367b5ec 100644 --- a/meta-digi-arm/dynamic-layers/stm-st-stm32mp/recipes-security/optee/optee-os-stm32mp_%.bbappend +++ b/meta-digi-arm/dynamic-layers/stm-st-stm32mp/recipes-security/optee/optee-os-stm32mp_%.bbappend @@ -14,6 +14,3 @@ SRC_URI = " \ ${OPTEE_GIT_URI};branch=${SRCBRANCH};name=os \ file://fonts.tar.gz;subdir=git;name=fonts \ " - -# Enable OTP write support -EXTRA_OEMAKE += "CFG_STM32_BSEC_WRITE=y" diff --git a/meta-digi-arm/recipes-bsp/alsa-state/alsa-state/ccimx93/asound.conf b/meta-digi-arm/recipes-bsp/alsa-state/alsa-state/ccimx93/asound.conf index 11c4cbba0..2a3359f54 100644 --- a/meta-digi-arm/recipes-bsp/alsa-state/alsa-state/ccimx93/asound.conf +++ b/meta-digi-arm/recipes-bsp/alsa-state/alsa-state/ccimx93/asound.conf @@ -1,9 +1,9 @@ -pcm.imxmax98088 { +pcm.max98088audio { type hw card 0 } -ctl.imxmax98088 { +ctl.max98088audio { type hw card 0 } -ctl.!default imxmax98088 +ctl.!default max98088audio diff --git a/meta-digi-arm/recipes-bsp/alsa-state/alsa-state/ccimx93/asound.state b/meta-digi-arm/recipes-bsp/alsa-state/alsa-state/ccimx93/asound.state index 07076e3ac..c094dc9b2 100644 --- a/meta-digi-arm/recipes-bsp/alsa-state/alsa-state/ccimx93/asound.state +++ b/meta-digi-arm/recipes-bsp/alsa-state/alsa-state/ccimx93/asound.state @@ -1,4 +1,4 @@ -state.imxmax98088 { +state.max98088audio { control.1 { iface MIXER name 'Headphone Volume' @@ -132,18 +132,18 @@ state.imxmax98088 { } control.11 { iface MIXER - name 'INA Volume' - value 4 + name 'Noise Gate Threshold' + value 0 comment { access 'read write' type INTEGER count 1 - range '0 - 7' + range '0 - 15' } } control.12 { iface MIXER - name 'INB Volume' + name 'INA Volume' value 4 comment { access 'read write' @@ -154,18 +154,18 @@ state.imxmax98088 { } control.13 { iface MIXER - name 'ADCL Volume' - value 0 + name 'INB Volume' + value 4 comment { access 'read write' type INTEGER count 1 - range '0 - 15' + range '0 - 7' } } control.14 { iface MIXER - name 'ADCR Volume' + name 'ADCL Volume' value 0 comment { access 'read write' @@ -176,18 +176,18 @@ state.imxmax98088 { } control.15 { iface MIXER - name 'ADCL Boost Volume' + name 'ADCR Volume' value 0 comment { access 'read write' type INTEGER count 1 - range '0 - 3' + range '0 - 15' } } control.16 { iface MIXER - name 'ADCR Boost Volume' + name 'ADCL Boost Volume' value 0 comment { access 'read write' @@ -197,6 +197,17 @@ state.imxmax98088 { } } control.17 { + iface MIXER + name 'ADCR Boost Volume' + value 0 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 3' + } + } + control.18 { iface MIXER name 'EQ1 Switch' value false @@ -206,7 +217,7 @@ state.imxmax98088 { count 1 } } - control.18 { + control.19 { iface MIXER name 'EQ2 Switch' value false @@ -216,7 +227,7 @@ state.imxmax98088 { count 1 } } - control.19 { + control.20 { iface MIXER name 'EX Limiter Mode' value Off @@ -235,7 +246,7 @@ state.imxmax98088 { item.8 '400-800Hz' } } - control.20 { + control.21 { iface MIXER name 'EX Limiter Threshold' value '0.6' @@ -253,7 +264,7 @@ state.imxmax98088 { item.7 '4.8' } } - control.21 { + control.22 { iface MIXER name 'DAI1 Filter Mode' value Music @@ -265,7 +276,7 @@ state.imxmax98088 { item.1 Music } } - control.22 { + control.23 { iface MIXER name 'DAI1 DAC Filter' value Off @@ -281,7 +292,7 @@ state.imxmax98088 { item.5 'fc=200' } } - control.23 { + control.24 { iface MIXER name 'DAI1 ADC Filter' value Off @@ -297,7 +308,7 @@ state.imxmax98088 { item.5 'fc=200' } } - control.24 { + control.25 { iface MIXER name 'DAI2 DC Block Switch' value false @@ -307,7 +318,7 @@ state.imxmax98088 { count 1 } } - control.25 { + control.26 { iface MIXER name 'ALC Switch' value false @@ -317,7 +328,7 @@ state.imxmax98088 { count 1 } } - control.26 { + control.27 { iface MIXER name 'ALC Threshold' value 0 @@ -328,7 +339,7 @@ state.imxmax98088 { range '0 - 7' } } - control.27 { + control.28 { iface MIXER name 'ALC Multiband' value false @@ -338,7 +349,7 @@ state.imxmax98088 { count 1 } } - control.28 { + control.29 { iface MIXER name 'ALC Release Time' value 0 @@ -349,7 +360,7 @@ state.imxmax98088 { range '0 - 7' } } - control.29 { + control.30 { iface MIXER name 'PWR Limiter Threshold' value 0 @@ -360,7 +371,7 @@ state.imxmax98088 { range '0 - 15' } } - control.30 { + control.31 { iface MIXER name 'PWR Limiter Weight' value 0 @@ -371,7 +382,7 @@ state.imxmax98088 { range '0 - 7' } } - control.31 { + control.32 { iface MIXER name 'PWR Limiter Time1' value 0 @@ -382,7 +393,7 @@ state.imxmax98088 { range '0 - 15' } } - control.32 { + control.33 { iface MIXER name 'PWR Limiter Time2' value 0 @@ -393,7 +404,7 @@ state.imxmax98088 { range '0 - 15' } } - control.33 { + control.34 { iface MIXER name 'THD Limiter Threshold' value 0 @@ -404,7 +415,7 @@ state.imxmax98088 { range '0 - 15' } } - control.34 { + control.35 { iface MIXER name 'THD Limiter Time' value 0 @@ -415,7 +426,7 @@ state.imxmax98088 { range '0 - 7' } } - control.35 { + control.36 { iface MIXER name 'REC Output Mode' value true @@ -425,627 +436,7 @@ state.imxmax98088 { count 1 } } - control.36 { - iface MIXER - name 'Right ADC Mixer MIC1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } control.37 { - iface MIXER - name 'Right ADC Mixer MIC2 Switch' - value true - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.38 { - iface MIXER - name 'Right ADC Mixer INA1 Switch' - value true - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.39 { - iface MIXER - name 'Right ADC Mixer INA2 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.40 { - iface MIXER - name 'Right ADC Mixer INB1 Switch' - value true - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.41 { - iface MIXER - name 'Right ADC Mixer INB2 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.42 { - iface MIXER - name 'Left ADC Mixer MIC1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.43 { - iface MIXER - name 'Left ADC Mixer MIC2 Switch' - value true - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.44 { - iface MIXER - name 'Left ADC Mixer INA1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.45 { - iface MIXER - name 'Left ADC Mixer INA2 Switch' - value true - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.46 { - iface MIXER - name 'Left ADC Mixer INB1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.47 { - iface MIXER - name 'Left ADC Mixer INB2 Switch' - value true - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.48 { - iface MIXER - name 'Right REC Mixer Left DAC1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.49 { - iface MIXER - name 'Right REC Mixer Right DAC1 Switch' - value true - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.50 { - iface MIXER - name 'Right REC Mixer Left DAC2 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.51 { - iface MIXER - name 'Right REC Mixer Right DAC2 Switch' - value true - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.52 { - iface MIXER - name 'Right REC Mixer MIC1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.53 { - iface MIXER - name 'Right REC Mixer MIC2 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.54 { - iface MIXER - name 'Right REC Mixer INA1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.55 { - iface MIXER - name 'Right REC Mixer INA2 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.56 { - iface MIXER - name 'Right REC Mixer INB1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.57 { - iface MIXER - name 'Right REC Mixer INB2 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.58 { - iface MIXER - name 'Left REC Mixer Left DAC1 Switch' - value true - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.59 { - iface MIXER - name 'Left REC Mixer Right DAC1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.60 { - iface MIXER - name 'Left REC Mixer Left DAC2 Switch' - value true - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.61 { - iface MIXER - name 'Left REC Mixer Right DAC2 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.62 { - iface MIXER - name 'Left REC Mixer MIC1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.63 { - iface MIXER - name 'Left REC Mixer MIC2 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.64 { - iface MIXER - name 'Left REC Mixer INA1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.65 { - iface MIXER - name 'Left REC Mixer INA2 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.66 { - iface MIXER - name 'Left REC Mixer INB1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.67 { - iface MIXER - name 'Left REC Mixer INB2 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.68 { - iface MIXER - name 'Right SPK Mixer Left DAC1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.69 { - iface MIXER - name 'Right SPK Mixer Right DAC1 Switch' - value true - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.70 { - iface MIXER - name 'Right SPK Mixer Left DAC2 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.71 { - iface MIXER - name 'Right SPK Mixer Right DAC2 Switch' - value true - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.72 { - iface MIXER - name 'Right SPK Mixer MIC1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.73 { - iface MIXER - name 'Right SPK Mixer MIC2 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.74 { - iface MIXER - name 'Right SPK Mixer INA1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.75 { - iface MIXER - name 'Right SPK Mixer INA2 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.76 { - iface MIXER - name 'Right SPK Mixer INB1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.77 { - iface MIXER - name 'Right SPK Mixer INB2 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.78 { - iface MIXER - name 'Left SPK Mixer Left DAC1 Switch' - value true - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.79 { - iface MIXER - name 'Left SPK Mixer Right DAC1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.80 { - iface MIXER - name 'Left SPK Mixer Left DAC2 Switch' - value true - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.81 { - iface MIXER - name 'Left SPK Mixer Right DAC2 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.82 { - iface MIXER - name 'Left SPK Mixer MIC1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.83 { - iface MIXER - name 'Left SPK Mixer MIC2 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.84 { - iface MIXER - name 'Left SPK Mixer INA1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.85 { - iface MIXER - name 'Left SPK Mixer INA2 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.86 { - iface MIXER - name 'Left SPK Mixer INB1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.87 { - iface MIXER - name 'Left SPK Mixer INB2 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.88 { - iface MIXER - name 'Right HP Mixer Left DAC1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.89 { - iface MIXER - name 'Right HP Mixer Right DAC1 Switch' - value true - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.90 { - iface MIXER - name 'Right HP Mixer Left DAC2 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.91 { - iface MIXER - name 'Right HP Mixer Right DAC2 Switch' - value true - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.92 { - iface MIXER - name 'Right HP Mixer MIC1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.93 { - iface MIXER - name 'Right HP Mixer MIC2 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.94 { - iface MIXER - name 'Right HP Mixer INA1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.95 { - iface MIXER - name 'Right HP Mixer INA2 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.96 { - iface MIXER - name 'Right HP Mixer INB1 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.97 { - iface MIXER - name 'Right HP Mixer INB2 Switch' - value false - comment { - access 'read write' - type BOOLEAN - count 1 - } - } - control.98 { iface MIXER name 'Left HP Mixer Left DAC1 Switch' value true @@ -1055,7 +446,7 @@ state.imxmax98088 { count 1 } } - control.99 { + control.38 { iface MIXER name 'Left HP Mixer Right DAC1 Switch' value false @@ -1065,7 +456,7 @@ state.imxmax98088 { count 1 } } - control.100 { + control.39 { iface MIXER name 'Left HP Mixer Left DAC2 Switch' value true @@ -1075,7 +466,7 @@ state.imxmax98088 { count 1 } } - control.101 { + control.40 { iface MIXER name 'Left HP Mixer Right DAC2 Switch' value false @@ -1085,7 +476,7 @@ state.imxmax98088 { count 1 } } - control.102 { + control.41 { iface MIXER name 'Left HP Mixer MIC1 Switch' value false @@ -1095,7 +486,7 @@ state.imxmax98088 { count 1 } } - control.103 { + control.42 { iface MIXER name 'Left HP Mixer MIC2 Switch' value false @@ -1105,7 +496,7 @@ state.imxmax98088 { count 1 } } - control.104 { + control.43 { iface MIXER name 'Left HP Mixer INA1 Switch' value false @@ -1115,7 +506,7 @@ state.imxmax98088 { count 1 } } - control.105 { + control.44 { iface MIXER name 'Left HP Mixer INA2 Switch' value false @@ -1125,7 +516,7 @@ state.imxmax98088 { count 1 } } - control.106 { + control.45 { iface MIXER name 'Left HP Mixer INB1 Switch' value false @@ -1135,7 +526,7 @@ state.imxmax98088 { count 1 } } - control.107 { + control.46 { iface MIXER name 'Left HP Mixer INB2 Switch' value false @@ -1145,4 +536,624 @@ state.imxmax98088 { count 1 } } + control.47 { + iface MIXER + name 'Right HP Mixer Left DAC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.48 { + iface MIXER + name 'Right HP Mixer Right DAC1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.49 { + iface MIXER + name 'Right HP Mixer Left DAC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.50 { + iface MIXER + name 'Right HP Mixer Right DAC2 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.51 { + iface MIXER + name 'Right HP Mixer MIC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.52 { + iface MIXER + name 'Right HP Mixer MIC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.53 { + iface MIXER + name 'Right HP Mixer INA1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.54 { + iface MIXER + name 'Right HP Mixer INA2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.55 { + iface MIXER + name 'Right HP Mixer INB1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.56 { + iface MIXER + name 'Right HP Mixer INB2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.57 { + iface MIXER + name 'Left SPK Mixer Left DAC1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.58 { + iface MIXER + name 'Left SPK Mixer Right DAC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.59 { + iface MIXER + name 'Left SPK Mixer Left DAC2 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.60 { + iface MIXER + name 'Left SPK Mixer Right DAC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.61 { + iface MIXER + name 'Left SPK Mixer MIC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.62 { + iface MIXER + name 'Left SPK Mixer MIC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.63 { + iface MIXER + name 'Left SPK Mixer INA1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.64 { + iface MIXER + name 'Left SPK Mixer INA2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.65 { + iface MIXER + name 'Left SPK Mixer INB1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.66 { + iface MIXER + name 'Left SPK Mixer INB2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.67 { + iface MIXER + name 'Right SPK Mixer Left DAC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.68 { + iface MIXER + name 'Right SPK Mixer Right DAC1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.69 { + iface MIXER + name 'Right SPK Mixer Left DAC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.70 { + iface MIXER + name 'Right SPK Mixer Right DAC2 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.71 { + iface MIXER + name 'Right SPK Mixer MIC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.72 { + iface MIXER + name 'Right SPK Mixer MIC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.73 { + iface MIXER + name 'Right SPK Mixer INA1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.74 { + iface MIXER + name 'Right SPK Mixer INA2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.75 { + iface MIXER + name 'Right SPK Mixer INB1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.76 { + iface MIXER + name 'Right SPK Mixer INB2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.77 { + iface MIXER + name 'Left REC Mixer Left DAC1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.78 { + iface MIXER + name 'Left REC Mixer Right DAC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.79 { + iface MIXER + name 'Left REC Mixer Left DAC2 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.80 { + iface MIXER + name 'Left REC Mixer Right DAC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.81 { + iface MIXER + name 'Left REC Mixer MIC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.82 { + iface MIXER + name 'Left REC Mixer MIC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.83 { + iface MIXER + name 'Left REC Mixer INA1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.84 { + iface MIXER + name 'Left REC Mixer INA2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.85 { + iface MIXER + name 'Left REC Mixer INB1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.86 { + iface MIXER + name 'Left REC Mixer INB2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.87 { + iface MIXER + name 'Right REC Mixer Left DAC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.88 { + iface MIXER + name 'Right REC Mixer Right DAC1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.89 { + iface MIXER + name 'Right REC Mixer Left DAC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.90 { + iface MIXER + name 'Right REC Mixer Right DAC2 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.91 { + iface MIXER + name 'Right REC Mixer MIC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.92 { + iface MIXER + name 'Right REC Mixer MIC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.93 { + iface MIXER + name 'Right REC Mixer INA1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.94 { + iface MIXER + name 'Right REC Mixer INA2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.95 { + iface MIXER + name 'Right REC Mixer INB1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.96 { + iface MIXER + name 'Right REC Mixer INB2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.97 { + iface MIXER + name 'Left ADC Mixer MIC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.98 { + iface MIXER + name 'Left ADC Mixer MIC2 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.99 { + iface MIXER + name 'Left ADC Mixer INA1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.100 { + iface MIXER + name 'Left ADC Mixer INA2 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.101 { + iface MIXER + name 'Left ADC Mixer INB1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.102 { + iface MIXER + name 'Left ADC Mixer INB2 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.103 { + iface MIXER + name 'Right ADC Mixer MIC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.104 { + iface MIXER + name 'Right ADC Mixer MIC2 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.105 { + iface MIXER + name 'Right ADC Mixer INA1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.106 { + iface MIXER + name 'Right ADC Mixer INA2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.107 { + iface MIXER + name 'Right ADC Mixer INB1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.108 { + iface MIXER + name 'Right ADC Mixer INB2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } } diff --git a/meta-digi-arm/recipes-bsp/digi-sc-firmware/digi-sc-firmware_1.11.0.bb b/meta-digi-arm/recipes-bsp/digi-sc-firmware/digi-sc-firmware_1.15.0.bb similarity index 52% rename from meta-digi-arm/recipes-bsp/digi-sc-firmware/digi-sc-firmware_1.11.0.bb rename to meta-digi-arm/recipes-bsp/digi-sc-firmware/digi-sc-firmware_1.15.0.bb index ed6649a55..b1b3055e8 100644 --- a/meta-digi-arm/recipes-bsp/digi-sc-firmware/digi-sc-firmware_1.11.0.bb +++ b/meta-digi-arm/recipes-bsp/digi-sc-firmware/digi-sc-firmware_1.15.0.bb @@ -1,18 +1,18 @@ # Copyright (C) 2016 Freescale Semiconductor # Copyright 2017-2018 NXP -# Copyright (C) 2018-2021 Digi International. +# Copyright (C) 2018-2023 Digi International. DESCRIPTION = "i.MX System Controller Firmware, customized for Digi platforms" LICENSE = "Proprietary" -LIC_FILES_CHKSUM = "file://COPYING;md5=03bcadc8dc0a788f66ca9e2b89f56c6f" +LIC_FILES_CHKSUM = "file://COPYING;md5=ea25d099982d035af85d193c88a1b479" SECTION = "BSP" inherit pkgconfig deploy SRC_URI = "${DIGI_PKG_SRC}/${BPN}-${PV}.tar.gz" -SRC_URI[md5sum] = "0d20c7bb41d53bb8c2688b259c7ddfd4" -SRC_URI[sha256sum] = "36a02b956c288dad6ce6ecb2b13a4e6fb2983fd5c39cab5028ae9a7dafe4a4c9" +SRC_URI[md5sum] = "d7d74493bb04ff73341481a9fbc551eb" +SRC_URI[sha256sum] = "aa4acd333bb8fc137854d276d12961a9bdf29064a94bcf4d3c76761d79afaca9" S = "${WORKDIR}/${PN}-${PV}" @@ -23,22 +23,19 @@ SYSROOT_DIRS += "/boot" do_install () { install -d ${D}/boot - for ramc in ${RAM_CONFIGS}; do - install -m 0644 ${S}/${SC_FIRMWARE_NAME}-${ramc} ${D}/boot/ - done + install -m 0644 ${S}/${SC_FIRMWARE_NAME} ${D}/boot/ + } BOOT_TOOLS = "imx-boot-tools" do_deploy () { install -d ${DEPLOYDIR}/${BOOT_TOOLS} - for ramc in ${RAM_CONFIGS}; do - install -m 0644 ${S}/${SC_FIRMWARE_NAME}-${ramc} ${DEPLOYDIR}/${BOOT_TOOLS}/ - cd ${DEPLOYDIR}/${BOOT_TOOLS}/ - rm -f ${symlink_name}-${ramc} - ln -sf ${SC_FIRMWARE_NAME}-${ramc} ${symlink_name}-${ramc} - cd - - done + install -m 0644 ${S}/${SC_FIRMWARE_NAME} ${DEPLOYDIR}/${BOOT_TOOLS}/ + cd ${DEPLOYDIR}/${BOOT_TOOLS}/ + rm -f ${symlink_name} + ln -sf ${SC_FIRMWARE_NAME} ${symlink_name} + cd - } addtask deploy after do_install diff --git a/meta-digi-arm/recipes-bsp/firmware-murata/firmware-murata.bb b/meta-digi-arm/recipes-bsp/firmware-murata/firmware-murata.bb index 73962067e..168b12219 100644 --- a/meta-digi-arm/recipes-bsp/firmware-murata/firmware-murata.bb +++ b/meta-digi-arm/recipes-bsp/firmware-murata/firmware-murata.bb @@ -8,14 +8,15 @@ LIC_FILES_CHKSUM = "file://${S}/cyw-bt-patch/LICENCE.cypress;md5=cbc5f665d04f741 SRC_URI = " \ git://github.com/murata-wireless/cyw-fmac-fw;protocol=http;branch=fafnir;destsuffix=cyw-fmac-fw;name=cyw-fmac-fw \ git://github.com/murata-wireless/cyw-fmac-nvram;protocol=http;branch=fafnir;destsuffix=cyw-fmac-nvram;name=cyw-fmac-nvram \ - git://github.com/murata-wireless/cyw-bt-patch;protocol=http;branch=kirkstone-fafnir;destsuffix=cyw-bt-patch;name=cyw-bt-patch \ + git://github.com/murata-wireless/cyw-bt-patch;protocol=http;branch=master;destsuffix=cyw-bt-patch;name=cyw-bt-patch \ git://github.com/murata-wireless/cyw-fmac-utils-imx32;protocol=http;branch=fafnir;destsuffix=cyw-fmac-utils-imx32;name=cyw-fmac-utils-imx32 \ git://github.com/murata-wireless/cyw-fmac-utils-imx64;protocol=http;branch=fafnir;destsuffix=cyw-fmac-utils-imx64;name=cyw-fmac-utils-imx64 \ + file://cyfmac4373-sdio_US.clm_blob \ " SRCREV_cyw-fmac-fw="1f83e807b8187508c811a7d91a353a768fef2d37" SRCREV_cyw-fmac-nvram="303acf1b04441f62fbc48d278a70a099fabacb4a" -SRCREV_cyw-bt-patch="32af98f8bc8a8e123b4c428af0035d74e85ae4bb" +SRCREV_cyw-bt-patch="9d24c254dae92af99ddfd661a4ea30af69190038" SRCREV_cyw-fmac-utils-imx32="e248804b6ba386fedcd462ddd9394f42f73a17af" SRCREV_cyw-fmac-utils-imx64="1bc78d68f9609290b2f6578516011c57691f7815" @@ -33,12 +34,12 @@ do_install () { # Install Bluetooth patch *.HCD file # For Murata 2AE (LBEE5PK2AE-564) - install -m 444 ${S}/cyw-bt-patch/BCM4373A0.2AE.hcd ${D}${base_libdir}/firmware/brcm/BCM4373A0.hcd + install -m 444 ${S}/cyw-bt-patch/BCM4373A0_001.001.025.0103.0155.FCC.CE.2AE.hcd ${D}${base_libdir}/firmware/brcm/BCM4373A0_FCC.CE.hcd # Install WLAN firmware file (*.bin) and Regulatory binary file (*.clm_blob) # For Murata 2AE (LBEE5PK2AE-564) install -m 444 ${S}/cyw-fmac-fw/cyfmac4373-sdio.2AE.bin ${D}${base_libdir}/firmware/cypress/cyfmac4373-sdio.bin - install -m 444 ${S}/cyw-fmac-fw/cyfmac4373-sdio.2AE.clm_blob ${D}${base_libdir}/firmware/cypress/cyfmac4373-sdio.clm_blob + install -m 444 cyfmac4373-sdio_US.clm_blob ${D}${base_libdir}/firmware/cypress/cyfmac4373-sdio_US.clm_blob # Install NVRAM files (*.txt) # For Murata 2AE (LBEE5PK2AE-564) diff --git a/meta-digi-arm/recipes-bsp/firmware-murata/firmware-murata/cyfmac4373-sdio_US.clm_blob b/meta-digi-arm/recipes-bsp/firmware-murata/firmware-murata/cyfmac4373-sdio_US.clm_blob new file mode 100644 index 000000000..00a4b51e4 Binary files /dev/null and b/meta-digi-arm/recipes-bsp/firmware-murata/firmware-murata/cyfmac4373-sdio_US.clm_blob differ diff --git a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm.bb b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm.bb index 30dd69a8e..58b65f655 100644 --- a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm.bb +++ b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm.bb @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2022 Digi International. +# Copyright (C) 2016-2023 Digi International. SUMMARY = "Qualcomm firmware files for Digi's platforms." SECTION = "base" @@ -110,10 +110,6 @@ do_install() { ln -s /proc/device-tree/wireless/mac-address2 ${D}${WIFI_FW_PATH}/wlan/wlan_mac2 ln -s /proc/device-tree/wireless/mac-address3 ${D}${WIFI_FW_PATH}/wlan/wlan_mac3 - # Create symbolic links to the proper FW files depending on the country region - ln -s bdwlan30_US.bin ${D}${WIFI_FW_PATH}/bdwlan30.bin - ln -s bdwlan30_US.bin ${D}${WIFI_FW_PATH}/utfbd30.bin - if [ "${FW_QUALCOMM_WIFI}" = "${FW_QCA65X4_PCIE_PROPRIETARY}" ]; then ln -s qwlan30.bin ${D}${WIFI_FW_PATH}/athwlan.bin ln -s otp30.bin ${D}${WIFI_FW_PATH}/athsetup.bin diff --git a/meta-digi-arm/recipes-bsp/libubootenv/libubootenv/0005-Implement-support-for-environment-encryption-for-CCM.patch b/meta-digi-arm/recipes-bsp/libubootenv/libubootenv/0005-Implement-support-for-environment-encryption-for-CCM.patch new file mode 100644 index 000000000..04962f18a --- /dev/null +++ b/meta-digi-arm/recipes-bsp/libubootenv/libubootenv/0005-Implement-support-for-environment-encryption-for-CCM.patch @@ -0,0 +1,2814 @@ +From 89b035959578fe0d7714748487dad875bc018ef5 Mon Sep 17 00:00:00 2001 +From: Mike Engel +Date: Fri, 26 May 2023 11:21:43 +0200 +Subject: [PATCH] Implement support for environment encryption for CCMP1 + +This commit implements environment encryption/decryption of the +u-boot environment in Linux using cryp controller on the CCMP1 +platform. + +Signed-off-by: Mike Engel +--- + src/CMakeLists.txt | 4 + + src/ta_ccmp1_aes.h | 84 +++ + src/tee.h | 417 ++++++++++++++ + src/tee_bench.h | 77 +++ + src/tee_client_api.c | 958 ++++++++++++++++++++++++++++++++ + src/tee_client_api.h | 555 ++++++++++++++++++ + src/tee_client_api_extensions.h | 57 ++ + src/teec_benchmark.h | 37 ++ + src/teec_trace.c | 141 +++++ + src/teec_trace.h | 148 +++++ + src/uboot_env.c | 181 +++++- + 11 files changed, 2655 insertions(+), 4 deletions(-) + create mode 100644 src/ta_ccmp1_aes.h + create mode 100644 src/tee.h + create mode 100644 src/tee_bench.h + create mode 100644 src/tee_client_api.c + create mode 100644 src/tee_client_api.h + create mode 100644 src/tee_client_api_extensions.h + create mode 100644 src/teec_benchmark.h + create mode 100644 src/teec_trace.c + create mode 100644 src/teec_trace.h + +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index d7e38a1..15dad7a 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -1,6 +1,10 @@ + cmake_minimum_required (VERSION 2.6) + # Sources and private headers + SET(libubootenv_SOURCES ++ teec_trace.c ++ teec_trace.h ++ tee_client_api.c ++ tee_client_api.h + md5.c + md5.h + uboot_env.c +diff --git a/src/ta_ccmp1_aes.h b/src/ta_ccmp1_aes.h +new file mode 100644 +index 0000000..9110cda +--- /dev/null ++++ b/src/ta_ccmp1_aes.h +@@ -0,0 +1,84 @@ ++/* ++ * Copyright 2023 Digi International Inc ++ * ++ * SPDX-License-Identifier: GPL-2.0+ ++ */ ++ ++#ifndef __TA_CCMP1_AES_H__ ++#define __TA_CCMP1_AES_H__ ++ ++/* ++ * AES is a stream cipher which works a block at a time, with each block ++ * in this case being AES_BLOCK_LENGTH bytes. ++ */ ++ ++enum { ++ AES_STATECOLS = 4, /* columns in the state & expanded key */ ++ AES128_KEYCOLS = 4, /* columns in a key for aes128 */ ++ AES192_KEYCOLS = 6, /* columns in a key for aes128 */ ++ AES256_KEYCOLS = 8, /* columns in a key for aes128 */ ++ AES128_ROUNDS = 10, /* rounds in encryption for aes128 */ ++ AES192_ROUNDS = 12, /* rounds in encryption for aes192 */ ++ AES256_ROUNDS = 14, /* rounds in encryption for aes256 */ ++ AES128_KEY_LENGTH = 128 / 8, ++ AES192_KEY_LENGTH = 192 / 8, ++ AES256_KEY_LENGTH = 256 / 8, ++ AES128_EXPAND_KEY_LENGTH = 4 * AES_STATECOLS * (AES128_ROUNDS + 1), ++ AES192_EXPAND_KEY_LENGTH = 4 * AES_STATECOLS * (AES192_ROUNDS + 1), ++ AES256_EXPAND_KEY_LENGTH = 4 * AES_STATECOLS * (AES256_ROUNDS + 1), ++ AES_BLOCK_LENGTH = 128 / 8, ++}; ++ ++struct aes_ctx { ++ TEEC_Context ctx; ++ TEEC_Session sess; ++}; ++ ++/* The function IDs implemented in the associated TA */ ++ ++/* ++ * TA_AES_CMD_SET_KEY - Allocate resources for the AES ciphering ++ * param[0] (value) Algorithmus ++ * param[1] (value) Key size ++ * param[2] (value) encryption mode (encrypt/decrypt) ++ * param[3] unused ++ */ ++#define TA_AES_CMD_PREPARE 0 ++ ++/* ++ * TA_AES_CMD_SET_KEY - Allocate resources for the AES ciphering ++ * param[0] (memref) key data, size shall equal key length ++ * param[1] unused ++ * param[2] unused ++ * param[3] unused ++ */ ++#define TA_AES_CMD_SET_KEY 1 ++ ++/* ++ * TA_AES_CMD_SET_IV - reset IV ++ * param[0] (memref) initial vector, size shall equal block length ++ * param[1] unused ++ * param[2] unused ++ * param[3] unused ++ */ ++#define TA_AES_CMD_SET_IV 2 ++ ++/* ++ * TA_AES_CMD_CIPHER - Cipher input buffer into output buffer ++ * param[0] (memref) input buffer ++ * param[1] (memref) output buffer (shall be bigger than input buffer) ++ * param[2] unused ++ * param[3] unused ++ */ ++#define TA_AES_CMD_CIPHER 3 ++ ++#define TA_AES_MODE_ENCODE 1 ++#define TA_AES_MODE_DECODE 0 ++ ++#define TA_AES_ALGO_CTR 2 ++ ++/* UUID of the TA */ ++#define TA_STM32MP_CRYP_UUID { 0xc2fad363, 0x5d9f, 0x4fc4, \ ++ { 0xa4, 0x17, 0x55, 0x58, 0x41, 0xe0, 0x57, 0x45 } } ++ ++#endif /* __TA_CCMP1_AES_H__ */ +\ No newline at end of file +diff --git a/src/tee.h b/src/tee.h +new file mode 100644 +index 0000000..f883ebc +--- /dev/null ++++ b/src/tee.h +@@ -0,0 +1,417 @@ ++/* ++ * Copyright (c) 2015-2016, Linaro Limited ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright notice, ++ * this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright notice, ++ * this list of conditions and the following disclaimer in the documentation ++ * and/or other materials provided with the distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE ++ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ++ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ++ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++ * POSSIBILITY OF SUCH DAMAGE. ++ */ ++ ++#ifndef __TEE_H ++#define __TEE_H ++ ++#include ++#include ++ ++/* ++ * This file describes the API provided by a TEE driver to user space. ++ * ++ * Each TEE driver defines a TEE specific protocol which is used for the ++ * data passed back and forth using TEE_IOC_CMD. ++ */ ++ ++/* Helpers to make the ioctl defines */ ++#define TEE_IOC_MAGIC 0xa4 ++#define TEE_IOC_BASE 0 ++ ++/* Flags relating to shared memory */ ++#define TEE_IOCTL_SHM_MAPPED 0x1 /* memory mapped in normal world */ ++#define TEE_IOCTL_SHM_DMA_BUF 0x2 /* dma-buf handle on shared memory */ ++ ++#define TEE_MAX_ARG_SIZE 1024 ++ ++#define TEE_GEN_CAP_GP (1 << 0)/* GlobalPlatform compliant TEE */ ++#define TEE_GEN_CAP_PRIVILEGED (1 << 1)/* Privileged device (for supplicant) */ ++#define TEE_GEN_CAP_REG_MEM (1 << 2)/* Supports registering shared memory */ ++#define TEE_GEN_CAP_MEMREF_NULL (1 << 3) /* Support NULL MemRef */ ++ ++#define TEE_MEMREF_NULL ((__u64)-1) /* NULL MemRef Buffer */ ++ ++/* ++ * TEE Implementation ID ++ */ ++#define TEE_IMPL_ID_OPTEE 1 ++#define TEE_IMPL_ID_AMDTEE 2 ++ ++/* ++ * OP-TEE specific capabilities ++ */ ++#define TEE_OPTEE_CAP_TZ (1 << 0) ++ ++/** ++ * struct tee_ioctl_version_data - TEE version ++ * @impl_id: [out] TEE implementation id ++ * @impl_caps: [out] Implementation specific capabilities ++ * @gen_caps: [out] Generic capabilities, defined by TEE_GEN_CAPS_* above ++ * ++ * Identifies the TEE implementation, @impl_id is one of TEE_IMPL_ID_* above. ++ * @impl_caps is implementation specific, for example TEE_OPTEE_CAP_* ++ * is valid when @impl_id == TEE_IMPL_ID_OPTEE. ++ */ ++struct tee_ioctl_version_data { ++ __u32 impl_id; ++ __u32 impl_caps; ++ __u32 gen_caps; ++}; ++ ++/** ++ * TEE_IOC_VERSION - query version of TEE ++ * ++ * Takes a tee_ioctl_version_data struct and returns with the TEE version ++ * data filled in. ++ */ ++#define TEE_IOC_VERSION _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 0, \ ++ struct tee_ioctl_version_data) ++ ++/** ++ * struct tee_ioctl_shm_alloc_data - Shared memory allocate argument ++ * @size: [in/out] Size of shared memory to allocate ++ * @flags: [in/out] Flags to/from allocation. ++ * @id: [out] Identifier of the shared memory ++ * ++ * The flags field should currently be zero as input. Updated by the call ++ * with actual flags as defined by TEE_IOCTL_SHM_* above. ++ * This structure is used as argument for TEE_IOC_SHM_ALLOC below. ++ */ ++struct tee_ioctl_shm_alloc_data { ++ __u64 size; ++ __u32 flags; ++ __s32 id; ++}; ++ ++/** ++ * TEE_IOC_SHM_ALLOC - allocate shared memory ++ * ++ * Allocates shared memory between the user space process and secure OS. ++ * ++ * Returns a file descriptor on success or < 0 on failure ++ * ++ * The returned file descriptor is used to map the shared memory into user ++ * space. The shared memory is freed when the descriptor is closed and the ++ * memory is unmapped. ++ */ ++#define TEE_IOC_SHM_ALLOC _IOWR(TEE_IOC_MAGIC, TEE_IOC_BASE + 1, \ ++ struct tee_ioctl_shm_alloc_data) ++ ++/** ++ * struct tee_ioctl_shm_register_fd_data - Shared memory registering argument ++ * @fd: [in] file descriptor identifying the shared memory ++ * @size: [out] Size of shared memory to allocate ++ * @flags: [in] Flags to/from allocation. ++ * @id: [out] Identifier of the shared memory ++ * ++ * The flags field should currently be zero as input. Updated by the call ++ * with actual flags as defined by TEE_IOCTL_SHM_* above. ++ * This structure is used as argument for TEE_IOC_SHM_ALLOC below. ++ */ ++struct tee_ioctl_shm_register_fd_data { ++ __s64 fd; ++ __u64 size; ++ __u32 flags; ++ __s32 id; ++} __aligned(8); ++ ++/* ++ * Attributes for struct tee_ioctl_param, selects field in the union ++ */ ++#define TEE_IOCTL_PARAM_ATTR_TYPE_NONE 0 /* parameter not used */ ++ ++/* ++ * These defines value parameters (struct tee_ioctl_param_value) ++ */ ++#define TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT 1 ++#define TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_OUTPUT 2 ++#define TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INOUT 3 /* input and output */ ++ ++/* ++ * These defines shared memory reference parameters (struct ++ * tee_ioctl_param_memref) ++ */ ++#define TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT 5 ++#define TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT 6 ++#define TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT 7 /* input and output */ ++ ++/* ++ * Mask for the type part of the attribute, leaves room for more types ++ */ ++#define TEE_IOCTL_PARAM_ATTR_TYPE_MASK 0xff ++ ++/* Meta parameter carrying extra information about the message. */ ++#define TEE_IOCTL_PARAM_ATTR_META 0x100 ++ ++/* Mask of all known attr bits */ ++#define TEE_IOCTL_PARAM_ATTR_MASK \ ++ (TEE_IOCTL_PARAM_ATTR_TYPE_MASK | TEE_IOCTL_PARAM_ATTR_META) ++ ++/* ++ * Matches TEEC_LOGIN_* in GP TEE Client API ++ * Are only defined for GP compliant TEEs ++ */ ++#define TEE_IOCTL_LOGIN_PUBLIC 0 ++#define TEE_IOCTL_LOGIN_USER 1 ++#define TEE_IOCTL_LOGIN_GROUP 2 ++#define TEE_IOCTL_LOGIN_APPLICATION 4 ++#define TEE_IOCTL_LOGIN_USER_APPLICATION 5 ++#define TEE_IOCTL_LOGIN_GROUP_APPLICATION 6 ++ ++/** ++ * struct tee_ioctl_param - parameter ++ * @attr: attributes ++ * @a: if a memref, offset into the shared memory object, else a value parameter ++ * @b: if a memref, size of the buffer, else a value parameter ++ * @c: if a memref, shared memory identifier, else a value parameter ++ * ++ * @attr & TEE_PARAM_ATTR_TYPE_MASK indicates if memref or value is used in ++ * the union. TEE_PARAM_ATTR_TYPE_VALUE_* indicates value and ++ * TEE_PARAM_ATTR_TYPE_MEMREF_* indicates memref. TEE_PARAM_ATTR_TYPE_NONE ++ * indicates that none of the members are used. ++ * ++ * Shared memory is allocated with TEE_IOC_SHM_ALLOC which returns an ++ * identifier representing the shared memory object. A memref can reference ++ * a part of a shared memory by specifying an offset (@a) and size (@b) of ++ * the object. To supply the entire shared memory object set the offset ++ * (@a) to 0 and size (@b) to the previously returned size of the object. ++ */ ++struct tee_ioctl_param { ++ __u64 attr; ++ __u64 a; ++ __u64 b; ++ __u64 c; ++}; ++ ++#define TEE_IOCTL_UUID_LEN 16 ++ ++/** ++ * struct tee_ioctl_open_session_arg - Open session argument ++ * @uuid: [in] UUID of the Trusted Application ++ * @clnt_uuid: [in] UUID of client ++ * @clnt_login: [in] Login class of client, TEE_IOCTL_LOGIN_* above ++ * @cancel_id: [in] Cancellation id, a unique value to identify this request ++ * @session: [out] Session id ++ * @ret: [out] return value ++ * @ret_origin [out] origin of the return value ++ * @num_params [in] number of parameters following this struct ++ */ ++struct tee_ioctl_open_session_arg { ++ __u8 uuid[TEE_IOCTL_UUID_LEN]; ++ __u8 clnt_uuid[TEE_IOCTL_UUID_LEN]; ++ __u32 clnt_login; ++ __u32 cancel_id; ++ __u32 session; ++ __u32 ret; ++ __u32 ret_origin; ++ __u32 num_params; ++ /* num_params tells the actual number of element in params */ ++ struct tee_ioctl_param params[]; ++}; ++ ++/** ++ * TEE_IOC_OPEN_SESSION - opens a session to a Trusted Application ++ * ++ * Takes a struct tee_ioctl_buf_data which contains a struct ++ * tee_ioctl_open_session_arg followed by any array of struct ++ * tee_ioctl_param ++ */ ++#define TEE_IOC_OPEN_SESSION _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 2, \ ++ struct tee_ioctl_buf_data) ++ ++/** ++ * struct tee_ioctl_invoke_func_arg - Invokes a function in a Trusted ++ * Application ++ * @func: [in] Trusted Application function, specific to the TA ++ * @session: [in] Session id ++ * @cancel_id: [in] Cancellation id, a unique value to identify this request ++ * @ret: [out] return value ++ * @ret_origin [out] origin of the return value ++ * @num_params [in] number of parameters following this struct ++ */ ++struct tee_ioctl_invoke_arg { ++ __u32 func; ++ __u32 session; ++ __u32 cancel_id; ++ __u32 ret; ++ __u32 ret_origin; ++ __u32 num_params; ++ /* num_params tells the actual number of element in params */ ++ struct tee_ioctl_param params[]; ++}; ++ ++/** ++ * TEE_IOC_INVOKE - Invokes a function in a Trusted Application ++ * ++ * Takes a struct tee_ioctl_buf_data which contains a struct ++ * tee_invoke_func_arg followed by any array of struct tee_param ++ */ ++#define TEE_IOC_INVOKE _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 3, \ ++ struct tee_ioctl_buf_data) ++ ++/** ++ * struct tee_ioctl_cancel_arg - Cancels an open session or invoke ioctl ++ * @cancel_id: [in] Cancellation id, a unique value to identify this request ++ * @session: [in] Session id, if the session is opened, else set to 0 ++ */ ++struct tee_ioctl_cancel_arg { ++ __u32 cancel_id; ++ __u32 session; ++}; ++ ++/** ++ * TEE_IOC_CANCEL - Cancels an open session or invoke ++ */ ++#define TEE_IOC_CANCEL _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 4, \ ++ struct tee_ioctl_cancel_arg) ++ ++/** ++ * struct tee_ioctl_close_session_arg - Closes an open session ++ * @session: [in] Session id ++ */ ++struct tee_ioctl_close_session_arg { ++ __u32 session; ++}; ++ ++/** ++ * TEE_IOC_CLOSE_SESSION - Closes a session ++ */ ++#define TEE_IOC_CLOSE_SESSION _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 5, \ ++ struct tee_ioctl_close_session_arg) ++ ++/** ++ * struct tee_iocl_supp_recv_arg - Receive a request for a supplicant function ++ * @func: [in] supplicant function ++ * @num_params [in/out] number of parameters following this struct ++ * ++ * @num_params is the number of params that tee-supplicant has room to ++ * receive when input, @num_params is the number of actual params ++ * tee-supplicant receives when output. ++ */ ++struct tee_iocl_supp_recv_arg { ++ __u32 func; ++ __u32 num_params; ++ /* num_params tells the actual number of element in params */ ++ struct tee_ioctl_param params[]; ++}; ++ ++/** ++ * TEE_IOC_SUPPL_RECV - Receive a request for a supplicant function ++ * ++ * Takes a struct tee_ioctl_buf_data which contains a struct ++ * tee_iocl_supp_recv_arg followed by any array of struct tee_param ++ */ ++#define TEE_IOC_SUPPL_RECV _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 6, \ ++ struct tee_ioctl_buf_data) ++ ++/** ++ * struct tee_iocl_supp_send_arg - Send a response to a received request ++ * @ret: [out] return value ++ * @num_params [in] number of parameters following this struct ++ */ ++struct tee_iocl_supp_send_arg { ++ __u32 ret; ++ __u32 num_params; ++ /* num_params tells the actual number of element in params */ ++ struct tee_ioctl_param params[]; ++}; ++ ++/** ++ * TEE_IOC_SUPPL_SEND - Receive a request for a supplicant function ++ * ++ * Takes a struct tee_ioctl_buf_data which contains a struct ++ * tee_iocl_supp_send_arg followed by any array of struct tee_param ++ */ ++#define TEE_IOC_SUPPL_SEND _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 7, \ ++ struct tee_ioctl_buf_data) ++ ++/** ++ * struct tee_ioctl_shm_register_data - Shared memory register argument ++ * @addr: [in] Start address of shared memory to register ++ * @length: [in/out] Length of shared memory to register ++ * @flags: [in/out] Flags to/from registration. ++ * @id: [out] Identifier of the shared memory ++ * ++ * The flags field should currently be zero as input. Updated by the call ++ * with actual flags as defined by TEE_IOCTL_SHM_* above. ++ * This structure is used as argument for TEE_IOC_SHM_REGISTER below. ++ */ ++struct tee_ioctl_shm_register_data { ++ __u64 addr; ++ __u64 length; ++ __u32 flags; ++ __s32 id; ++}; ++ ++/** ++ * TEE_IOC_SHM_REGISTER_FD - register a shared memory from a file descriptor ++ * ++ * Returns a file descriptor on success or < 0 on failure ++ * ++ * The returned file descriptor refers to the shared memory object in kernel ++ * land. The shared memory is freed when the descriptor is closed. ++ */ ++#define TEE_IOC_SHM_REGISTER_FD _IOWR(TEE_IOC_MAGIC, TEE_IOC_BASE + 8, \ ++ struct tee_ioctl_shm_register_fd_data) ++ ++/** ++ * struct tee_ioctl_buf_data - Variable sized buffer ++ * @buf_ptr: [in] A __user pointer to a buffer ++ * @buf_len: [in] Length of the buffer above ++ * ++ * Used as argument for TEE_IOC_OPEN_SESSION, TEE_IOC_INVOKE, ++ * TEE_IOC_SUPPL_RECV, and TEE_IOC_SUPPL_SEND below. ++ */ ++struct tee_ioctl_buf_data { ++ __u64 buf_ptr; ++ __u64 buf_len; ++}; ++ ++/** ++ * TEE_IOC_SHM_REGISTER - Register shared memory argument ++ * ++ * Registers shared memory between the user space process and secure OS. ++ * ++ * Returns a file descriptor on success or < 0 on failure ++ * ++ * The shared memory is unregisterred when the descriptor is closed. ++ */ ++#define TEE_IOC_SHM_REGISTER _IOWR(TEE_IOC_MAGIC, TEE_IOC_BASE + 9, \ ++ struct tee_ioctl_shm_register_data) ++/* ++ * Five syscalls are used when communicating with the TEE driver. ++ * open(): opens the device associated with the driver ++ * ioctl(): as described above operating on the file descriptor from open() ++ * close(): two cases ++ * - closes the device file descriptor ++ * - closes a file descriptor connected to allocated shared memory ++ * mmap(): maps shared memory into user space using information from struct ++ * tee_ioctl_shm_alloc_data ++ * munmap(): unmaps previously shared memory ++ */ ++ ++#endif /*__TEE_H*/ +diff --git a/src/tee_bench.h b/src/tee_bench.h +new file mode 100644 +index 0000000..600407f +--- /dev/null ++++ b/src/tee_bench.h +@@ -0,0 +1,77 @@ ++/* ++ * Copyright (c) 2017, Linaro Limited ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright notice, ++ * this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright notice, ++ * this list of conditions and the following disclaimer in the documentation ++ * and/or other materials provided with the distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE ++ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ++ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ++ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++ * POSSIBILITY OF SUCH DAMAGE. ++ */ ++ ++#ifndef TEE_BENCH_H ++#define TEE_BENCH_H ++ ++#include ++ ++#define PTA_BENCHMARK_UUID \ ++ { 0x0b9a63b0, 0xb4c6, 0x4c85, \ ++ { 0xa2, 0x84, 0xa2, 0x28, 0xef, 0x54, 0x7b, 0x4e } } ++ ++#define BENCHMARK_CMD(id) (0xFA190000 | ((id) & 0xFFFF)) ++#define BENCHMARK_CMD_REGISTER_MEMREF BENCHMARK_CMD(1) ++#define BENCHMARK_CMD_GET_MEMREF BENCHMARK_CMD(2) ++#define BENCHMARK_CMD_UNREGISTER BENCHMARK_CMD(3) ++ ++/* ++ * Cycle count divider is enabled (in PMCR), ++ * CCNT value is incremented every 64th clock cycle ++ */ ++#define TEE_BENCH_DIVIDER 64 ++/* max amount of timestamps per buffer */ ++#define TEE_BENCH_MAX_STAMPS 32 ++#define TEE_BENCH_MAX_MASK (TEE_BENCH_MAX_STAMPS - 1) ++ ++/* OP-TEE susbsystems ids */ ++#define TEE_BENCH_CLIENT 0x10000000 ++#define TEE_BENCH_KMOD 0x20000000 ++#define TEE_BENCH_CORE 0x30000000 ++#define TEE_BENCH_UTEE 0x40000000 ++#define TEE_BENCH_DUMB_TA 0xF0000001 ++ ++/* storing timestamp */ ++struct tee_time_st { ++ uint64_t cnt; /* stores value from CNTPCT register */ ++ uint64_t addr; /* stores value from program counter register */ ++ uint64_t src; /* OP-TEE subsystem id */ ++}; ++ ++/* per-cpu circular buffer for timestamps */ ++struct tee_ts_cpu_buf { ++ uint64_t head; ++ uint64_t tail; ++ struct tee_time_st stamps[TEE_BENCH_MAX_STAMPS]; ++}; ++ ++/* memory layout for shared memory, where timestamps will be stored */ ++struct tee_ts_global { ++ uint64_t cores; ++ struct tee_ts_cpu_buf cpu_buf[]; ++}; ++#endif /* TEE_BENCH_H */ +diff --git a/src/tee_client_api.c b/src/tee_client_api.c +new file mode 100644 +index 0000000..2b07d30 +--- /dev/null ++++ b/src/tee_client_api.c +@@ -0,0 +1,958 @@ ++/* ++ * Copyright (c) 2015-2016, Linaro Limited ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright notice, ++ * this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright notice, ++ * this list of conditions and the following disclaimer in the documentation ++ * and/or other materials provided with the distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE ++ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ++ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ++ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++ * POSSIBILITY OF SUCH DAMAGE. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#ifndef __aligned ++#define __aligned(x) __attribute__((__aligned__(x))) ++#endif ++#include ++ ++#include "teec_benchmark.h" ++ ++#define MIN(x, y) (((x) < (y)) ? (x) : (y)) ++ ++/* How many device sequence numbers will be tried before giving up */ ++#define TEEC_MAX_DEV_SEQ 10 ++ ++/* Helpers to access memref parts of a struct tee_ioctl_param */ ++#define MEMREF_SHM_ID(p) ((p)->c) ++#define MEMREF_SHM_OFFS(p) ((p)->a) ++#define MEMREF_SIZE(p) ((p)->b) ++ ++/* ++ * Internal flags of TEEC_SharedMemory::internal.flags ++ */ ++#define SHM_FLAG_BUFFER_ALLOCED (1u << 0) ++#define SHM_FLAG_SHADOW_BUFFER_ALLOCED (1u << 1) ++ ++static pthread_mutex_t teec_mutex = PTHREAD_MUTEX_INITIALIZER; ++ ++static void teec_mutex_lock(pthread_mutex_t *mu) ++{ ++ pthread_mutex_lock(mu); ++} ++ ++static void teec_mutex_unlock(pthread_mutex_t *mu) ++{ ++ pthread_mutex_unlock(mu); ++} ++ ++static void *teec_paged_aligned_alloc(size_t sz) ++{ ++ void *p = NULL; ++ ++ if (!posix_memalign(&p, sysconf(_SC_PAGESIZE), sz)) ++ return p; ++ ++ return NULL; ++} ++ ++static int teec_open_dev(const char *devname, const char *capabilities, ++ uint32_t *gen_caps) ++{ ++ int fd = 0; ++ struct tee_ioctl_version_data vers; ++ ++ memset(&vers, 0, sizeof(vers)); ++ ++ fd = open(devname, O_RDWR); ++ if (fd < 0) ++ return -1; ++ ++ if (ioctl(fd, TEE_IOC_VERSION, &vers)) { ++ EMSG("TEE_IOC_VERSION failed"); ++ goto err; ++ } ++ ++ /* We can only handle GP TEEs */ ++ if (!(vers.gen_caps & TEE_GEN_CAP_GP)) ++ goto err; ++ ++ if (capabilities) { ++ if (strcmp(capabilities, "optee-tz") == 0) { ++ if (vers.impl_id != TEE_IMPL_ID_OPTEE) ++ goto err; ++ if (!(vers.impl_caps & TEE_OPTEE_CAP_TZ)) ++ goto err; ++ } else { ++ /* Unrecognized capability requested */ ++ goto err; ++ } ++ } ++ ++ *gen_caps = vers.gen_caps; ++ return fd; ++err: ++ close(fd); ++ return -1; ++} ++ ++static int teec_shm_alloc(int fd, size_t size, int *id) ++{ ++ int shm_fd = 0; ++ struct tee_ioctl_shm_alloc_data data; ++ ++ memset(&data, 0, sizeof(data)); ++ ++ data.size = size; ++ shm_fd = ioctl(fd, TEE_IOC_SHM_ALLOC, &data); ++ if (shm_fd < 0) ++ return -1; ++ *id = data.id; ++ return shm_fd; ++} ++ ++static int teec_shm_register(int fd, void *buf, size_t size, int *id) ++{ ++ int shm_fd = 0; ++ struct tee_ioctl_shm_register_data data; ++ ++ memset(&data, 0, sizeof(data)); ++ ++ data.addr = (uintptr_t)buf; ++ data.length = size; ++ shm_fd = ioctl(fd, TEE_IOC_SHM_REGISTER, &data); ++ if (shm_fd < 0) ++ return -1; ++ *id = data.id; ++ return shm_fd; ++} ++ ++TEEC_Result TEEC_InitializeContext(const char *name, TEEC_Context *ctx) ++{ ++ char devname[PATH_MAX] = { 0 }; ++ int fd = 0; ++ size_t n = 0; ++ ++ if (!ctx) ++ return TEEC_ERROR_BAD_PARAMETERS; ++ ++ for (n = 0; n < TEEC_MAX_DEV_SEQ; n++) { ++ uint32_t gen_caps = 0; ++ ++ snprintf(devname, sizeof(devname), "/dev/tee%zu", n); ++ fd = teec_open_dev(devname, name, &gen_caps); ++ if (fd >= 0) { ++ ctx->fd = fd; ++ ctx->reg_mem = gen_caps & TEE_GEN_CAP_REG_MEM; ++ ctx->memref_null = gen_caps & TEE_GEN_CAP_MEMREF_NULL; ++ return TEEC_SUCCESS; ++ } ++ } ++ ++ return TEEC_ERROR_ITEM_NOT_FOUND; ++} ++ ++void TEEC_FinalizeContext(TEEC_Context *ctx) ++{ ++ if (ctx) ++ close(ctx->fd); ++} ++ ++ ++static TEEC_Result teec_pre_process_tmpref(TEEC_Context *ctx, ++ uint32_t param_type, TEEC_TempMemoryReference *tmpref, ++ struct tee_ioctl_param *param, ++ TEEC_SharedMemory *shm) ++{ ++ TEEC_Result res = TEEC_ERROR_GENERIC; ++ ++ switch (param_type) { ++ case TEEC_MEMREF_TEMP_INPUT: ++ param->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT; ++ shm->flags = TEEC_MEM_INPUT; ++ break; ++ case TEEC_MEMREF_TEMP_OUTPUT: ++ param->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT; ++ shm->flags = TEEC_MEM_OUTPUT; ++ break; ++ case TEEC_MEMREF_TEMP_INOUT: ++ param->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT; ++ shm->flags = TEEC_MEM_INPUT | TEEC_MEM_OUTPUT; ++ break; ++ default: ++ return TEEC_ERROR_BAD_PARAMETERS; ++ } ++ shm->size = tmpref->size; ++ ++ if (!tmpref->buffer) { ++ if (tmpref->size) ++ return TEEC_ERROR_BAD_PARAMETERS; ++ ++ if (ctx->memref_null) { ++ /* Null pointer, indicate no shared memory attached */ ++ MEMREF_SHM_ID(param) = TEE_MEMREF_NULL; ++ shm->id = -1; ++ } else { ++ res = TEEC_AllocateSharedMemory(ctx, shm); ++ if (res != TEEC_SUCCESS) ++ return res; ++ MEMREF_SHM_ID(param) = shm->id; ++ } ++ } else { ++ shm->buffer = tmpref->buffer; ++ res = TEEC_RegisterSharedMemory(ctx, shm); ++ if (res != TEEC_SUCCESS) ++ return res; ++ ++ if (shm->shadow_buffer) ++ memcpy(shm->shadow_buffer, tmpref->buffer, ++ tmpref->size); ++ ++ MEMREF_SHM_ID(param) = shm->id; ++ } ++ ++ MEMREF_SIZE(param) = tmpref->size; ++ ++ return TEEC_SUCCESS; ++} ++ ++static TEEC_Result teec_pre_process_whole( ++ TEEC_RegisteredMemoryReference *memref, ++ struct tee_ioctl_param *param) ++{ ++ const uint32_t inout = TEEC_MEM_INPUT | TEEC_MEM_OUTPUT; ++ uint32_t flags = memref->parent->flags & inout; ++ TEEC_SharedMemory *shm = NULL; ++ ++ if (flags == inout) ++ param->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT; ++ else if (flags & TEEC_MEM_INPUT) ++ param->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT; ++ else if (flags & TEEC_MEM_OUTPUT) ++ param->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT; ++ else ++ return TEEC_ERROR_BAD_PARAMETERS; ++ ++ shm = memref->parent; ++ /* ++ * We're using a shadow buffer in this reference, copy the real buffer ++ * into the shadow buffer if needed. We'll copy it back once we've ++ * returned from the call to secure world. ++ */ ++ if (shm->shadow_buffer && (flags & TEEC_MEM_INPUT)) ++ memcpy(shm->shadow_buffer, shm->buffer, shm->size); ++ ++ MEMREF_SHM_ID(param) = shm->id; ++ MEMREF_SIZE(param) = shm->size; ++ ++ return TEEC_SUCCESS; ++} ++ ++static TEEC_Result teec_pre_process_partial(uint32_t param_type, ++ TEEC_RegisteredMemoryReference *memref, ++ struct tee_ioctl_param *param) ++{ ++ uint32_t req_shm_flags = 0; ++ TEEC_SharedMemory *shm = NULL; ++ ++ switch (param_type) { ++ case TEEC_MEMREF_PARTIAL_INPUT: ++ req_shm_flags = TEEC_MEM_INPUT; ++ param->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT; ++ break; ++ case TEEC_MEMREF_PARTIAL_OUTPUT: ++ req_shm_flags = TEEC_MEM_OUTPUT; ++ param->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT; ++ break; ++ case TEEC_MEMREF_PARTIAL_INOUT: ++ req_shm_flags = TEEC_MEM_OUTPUT | TEEC_MEM_INPUT; ++ param->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT; ++ break; ++ default: ++ return TEEC_ERROR_BAD_PARAMETERS; ++ } ++ ++ shm = memref->parent; ++ ++ if ((shm->flags & req_shm_flags) != req_shm_flags) ++ return TEEC_ERROR_BAD_PARAMETERS; ++ ++ if ((memref->offset + memref->size < memref->offset) || ++ (memref->offset + memref->size > shm->size)) ++ return TEEC_ERROR_BAD_PARAMETERS; ++ ++ /* ++ * We're using a shadow buffer in this reference, copy the real buffer ++ * into the shadow buffer if needed. We'll copy it back once we've ++ * returned from the call to secure world. ++ */ ++ if (shm->shadow_buffer && param_type != TEEC_MEMREF_PARTIAL_OUTPUT) ++ memcpy((char *)shm->shadow_buffer + memref->offset, ++ (char *)shm->buffer + memref->offset, memref->size); ++ ++ MEMREF_SHM_ID(param) = shm->id; ++ MEMREF_SHM_OFFS(param) = memref->offset; ++ MEMREF_SIZE(param) = memref->size; ++ ++ return TEEC_SUCCESS; ++} ++ ++static TEEC_Result teec_pre_process_operation(TEEC_Context *ctx, ++ TEEC_Operation *operation, ++ struct tee_ioctl_param *params, ++ TEEC_SharedMemory *shms) ++{ ++ TEEC_Result res = TEEC_ERROR_GENERIC; ++ size_t n = 0; ++ ++ memset(shms, 0, sizeof(TEEC_SharedMemory) * ++ TEEC_CONFIG_PAYLOAD_REF_COUNT); ++ ++ for (n = 0; n < TEEC_CONFIG_PAYLOAD_REF_COUNT; n++) ++ shms[n].id = -1; ++ ++ if (!operation) { ++ memset(params, 0, sizeof(struct tee_ioctl_param) * ++ TEEC_CONFIG_PAYLOAD_REF_COUNT); ++ return TEEC_SUCCESS; ++ } ++ ++ for (n = 0; n < TEEC_CONFIG_PAYLOAD_REF_COUNT; n++) { ++ uint32_t param_type = 0; ++ ++ param_type = TEEC_PARAM_TYPE_GET(operation->paramTypes, n); ++ switch (param_type) { ++ case TEEC_NONE: ++ params[n].attr = param_type; ++ break; ++ case TEEC_VALUE_INPUT: ++ case TEEC_VALUE_OUTPUT: ++ case TEEC_VALUE_INOUT: ++ params[n].attr = param_type; ++ params[n].a = operation->params[n].value.a; ++ params[n].b = operation->params[n].value.b; ++ break; ++ case TEEC_MEMREF_TEMP_INPUT: ++ case TEEC_MEMREF_TEMP_OUTPUT: ++ case TEEC_MEMREF_TEMP_INOUT: ++ res = teec_pre_process_tmpref(ctx, param_type, ++ &operation->params[n].tmpref, params + n, ++ shms + n); ++ if (res != TEEC_SUCCESS) ++ return res; ++ break; ++ case TEEC_MEMREF_WHOLE: ++ res = teec_pre_process_whole( ++ &operation->params[n].memref, ++ params + n); ++ if (res != TEEC_SUCCESS) ++ return res; ++ break; ++ case TEEC_MEMREF_PARTIAL_INPUT: ++ case TEEC_MEMREF_PARTIAL_OUTPUT: ++ case TEEC_MEMREF_PARTIAL_INOUT: ++ res = teec_pre_process_partial(param_type, ++ &operation->params[n].memref, params + n); ++ if (res != TEEC_SUCCESS) ++ return res; ++ break; ++ default: ++ return TEEC_ERROR_BAD_PARAMETERS; ++ } ++ } ++ ++ return TEEC_SUCCESS; ++} ++ ++static void teec_post_process_tmpref(uint32_t param_type, ++ TEEC_TempMemoryReference *tmpref, ++ struct tee_ioctl_param *param, ++ TEEC_SharedMemory *shm) ++{ ++ if (param_type != TEEC_MEMREF_TEMP_INPUT) { ++ if (tmpref->buffer && shm->shadow_buffer) ++ memcpy(tmpref->buffer, shm->shadow_buffer, ++ MIN(MEMREF_SIZE(param), tmpref->size)); ++ ++ tmpref->size = MEMREF_SIZE(param); ++ } ++} ++ ++static void teec_post_process_whole(TEEC_RegisteredMemoryReference *memref, ++ struct tee_ioctl_param *param) ++{ ++ TEEC_SharedMemory *shm = memref->parent; ++ ++ if (shm->flags & TEEC_MEM_OUTPUT) { ++ ++ /* ++ * We're using a shadow buffer in this reference, copy back ++ * the shadow buffer into the real buffer now that we've ++ * returned from secure world. ++ */ ++ if (shm->shadow_buffer && MEMREF_SIZE(param) <= shm->size) ++ memcpy(shm->buffer, shm->shadow_buffer, ++ MEMREF_SIZE(param)); ++ ++ memref->size = MEMREF_SIZE(param); ++ } ++} ++ ++static void teec_post_process_partial(uint32_t param_type, ++ TEEC_RegisteredMemoryReference *memref, ++ struct tee_ioctl_param *param) ++{ ++ if (param_type != TEEC_MEMREF_PARTIAL_INPUT) { ++ TEEC_SharedMemory *shm = memref->parent; ++ ++ /* ++ * We're using a shadow buffer in this reference, copy back ++ * the shadow buffer into the real buffer now that we've ++ * returned from secure world. ++ */ ++ if (shm->shadow_buffer && MEMREF_SIZE(param) <= memref->size) ++ memcpy((char *)shm->buffer + memref->offset, ++ (char *)shm->shadow_buffer + memref->offset, ++ MEMREF_SIZE(param)); ++ ++ memref->size = MEMREF_SIZE(param); ++ } ++} ++ ++static void teec_post_process_operation(TEEC_Operation *operation, ++ struct tee_ioctl_param *params, ++ TEEC_SharedMemory *shms) ++{ ++ size_t n = 0; ++ ++ if (!operation) ++ return; ++ ++ for (n = 0; n < TEEC_CONFIG_PAYLOAD_REF_COUNT; n++) { ++ uint32_t param_type = 0; ++ ++ param_type = TEEC_PARAM_TYPE_GET(operation->paramTypes, n); ++ switch (param_type) { ++ case TEEC_VALUE_INPUT: ++ break; ++ case TEEC_VALUE_OUTPUT: ++ case TEEC_VALUE_INOUT: ++ operation->params[n].value.a = params[n].a; ++ operation->params[n].value.b = params[n].b; ++ break; ++ case TEEC_MEMREF_TEMP_INPUT: ++ case TEEC_MEMREF_TEMP_OUTPUT: ++ case TEEC_MEMREF_TEMP_INOUT: ++ teec_post_process_tmpref(param_type, ++ &operation->params[n].tmpref, params + n, ++ shms + n); ++ break; ++ case TEEC_MEMREF_WHOLE: ++ teec_post_process_whole(&operation->params[n].memref, ++ params + n); ++ break; ++ case TEEC_MEMREF_PARTIAL_INPUT: ++ case TEEC_MEMREF_PARTIAL_OUTPUT: ++ case TEEC_MEMREF_PARTIAL_INOUT: ++ teec_post_process_partial(param_type, ++ &operation->params[n].memref, params + n); ++ default: ++ break; ++ } ++ } ++} ++ ++static void teec_free_temp_refs(TEEC_Operation *operation, ++ TEEC_SharedMemory *shms) ++{ ++ size_t n = 0; ++ ++ if (!operation) ++ return; ++ ++ for (n = 0; n < TEEC_CONFIG_PAYLOAD_REF_COUNT; n++) { ++ switch (TEEC_PARAM_TYPE_GET(operation->paramTypes, n)) { ++ case TEEC_MEMREF_TEMP_INPUT: ++ case TEEC_MEMREF_TEMP_OUTPUT: ++ case TEEC_MEMREF_TEMP_INOUT: ++ TEEC_ReleaseSharedMemory(shms + n); ++ break; ++ default: ++ break; ++ } ++ } ++} ++ ++static TEEC_Result ioctl_errno_to_res(int err) ++{ ++ switch (err) { ++ case ENOMEM: ++ return TEEC_ERROR_OUT_OF_MEMORY; ++ case EINVAL: ++ return TEEC_ERROR_BAD_PARAMETERS; ++ default: ++ return TEEC_ERROR_GENERIC; ++ } ++} ++ ++static void uuid_to_octets(uint8_t d[TEE_IOCTL_UUID_LEN], const TEEC_UUID *s) ++{ ++ d[0] = s->timeLow >> 24; ++ d[1] = s->timeLow >> 16; ++ d[2] = s->timeLow >> 8; ++ d[3] = s->timeLow; ++ d[4] = s->timeMid >> 8; ++ d[5] = s->timeMid; ++ d[6] = s->timeHiAndVersion >> 8; ++ d[7] = s->timeHiAndVersion; ++ memcpy(d + 8, s->clockSeqAndNode, sizeof(s->clockSeqAndNode)); ++} ++ ++static void setup_client_data(struct tee_ioctl_open_session_arg *arg, ++ uint32_t connection_method, ++ const void *connection_data) ++{ ++ arg->clnt_login = connection_method; ++ ++ switch (connection_method) { ++ case TEE_IOCTL_LOGIN_PUBLIC: ++ /* No connection data to pass */ ++ break; ++ case TEE_IOCTL_LOGIN_USER: ++ /* Kernel auto-fills UID and forms client UUID */ ++ break; ++ case TEE_IOCTL_LOGIN_GROUP: ++ /* ++ * Connection data for group login is uint32_t and rest of ++ * clnt_uuid is set as zero. ++ * ++ * Kernel verifies group membership and then forms client UUID. ++ */ ++ memcpy(arg->clnt_uuid, connection_data, sizeof(gid_t)); ++ break; ++ case TEE_IOCTL_LOGIN_APPLICATION: ++ /* ++ * Kernel auto-fills application identifier and forms client ++ * UUID. ++ */ ++ break; ++ case TEE_IOCTL_LOGIN_USER_APPLICATION: ++ /* ++ * Kernel auto-fills application identifier, UID and forms ++ * client UUID. ++ */ ++ break; ++ case TEE_IOCTL_LOGIN_GROUP_APPLICATION: ++ /* ++ * Connection data for group login is uint32_t rest of ++ * clnt_uuid is set as zero. ++ * ++ * Kernel verifies group membership, auto-fills application ++ * identifier and then forms client UUID. ++ */ ++ memcpy(arg->clnt_uuid, connection_data, sizeof(gid_t)); ++ break; ++ default: ++ /* ++ * Unknown login method, don't pass any connection data as we ++ * don't know size. ++ */ ++ break; ++ } ++} ++ ++TEEC_Result TEEC_OpenSession(TEEC_Context *ctx, TEEC_Session *session, ++ const TEEC_UUID *destination, ++ uint32_t connection_method, const void *connection_data, ++ TEEC_Operation *operation, uint32_t *ret_origin) ++{ ++ struct tee_ioctl_open_session_arg *arg = NULL; ++ struct tee_ioctl_param *params = NULL; ++ TEEC_Result res = TEEC_ERROR_GENERIC; ++ uint32_t eorig = 0; ++ int rc = 0; ++ const size_t arg_size = sizeof(struct tee_ioctl_open_session_arg) + ++ TEEC_CONFIG_PAYLOAD_REF_COUNT * ++ sizeof(struct tee_ioctl_param); ++ union { ++ struct tee_ioctl_open_session_arg arg; ++ uint8_t data[arg_size]; ++ } buf; ++ struct tee_ioctl_buf_data buf_data; ++ TEEC_SharedMemory shm[TEEC_CONFIG_PAYLOAD_REF_COUNT]; ++ ++ memset(&buf, 0, sizeof(buf)); ++ memset(&shm, 0, sizeof(shm)); ++ memset(&buf_data, 0, sizeof(buf_data)); ++ ++ if (!ctx || !session) { ++ eorig = TEEC_ORIGIN_API; ++ res = TEEC_ERROR_BAD_PARAMETERS; ++ goto out; ++ } ++ ++ buf_data.buf_ptr = (uintptr_t)&buf; ++ buf_data.buf_len = sizeof(buf); ++ ++ arg = &buf.arg; ++ arg->num_params = TEEC_CONFIG_PAYLOAD_REF_COUNT; ++ params = (struct tee_ioctl_param *)(arg + 1); ++ ++ uuid_to_octets(arg->uuid, destination); ++ ++ setup_client_data(arg, connection_method, connection_data); ++ ++ res = teec_pre_process_operation(ctx, operation, params, shm); ++ if (res != TEEC_SUCCESS) { ++ eorig = TEEC_ORIGIN_API; ++ goto out_free_temp_refs; ++ } ++ ++ rc = ioctl(ctx->fd, TEE_IOC_OPEN_SESSION, &buf_data); ++ if (rc) { ++ EMSG("TEE_IOC_OPEN_SESSION failed"); ++ eorig = TEEC_ORIGIN_COMMS; ++ res = ioctl_errno_to_res(errno); ++ goto out_free_temp_refs; ++ } ++ res = arg->ret; ++ eorig = arg->ret_origin; ++ if (res == TEEC_SUCCESS) { ++ session->ctx = ctx; ++ session->session_id = arg->session; ++ } ++ teec_post_process_operation(operation, params, shm); ++ ++out_free_temp_refs: ++ teec_free_temp_refs(operation, shm); ++out: ++ if (ret_origin) ++ *ret_origin = eorig; ++ return res; ++} ++ ++void TEEC_CloseSession(TEEC_Session *session) ++{ ++ struct tee_ioctl_close_session_arg arg; ++ ++ memset(&arg, 0, sizeof(arg)); ++ ++ if (!session) ++ return; ++ ++ arg.session = session->session_id; ++ if (ioctl(session->ctx->fd, TEE_IOC_CLOSE_SESSION, &arg)) ++ EMSG("Failed to close session 0x%x", session->session_id); ++} ++ ++TEEC_Result TEEC_InvokeCommand(TEEC_Session *session, uint32_t cmd_id, ++ TEEC_Operation *operation, uint32_t *error_origin) ++{ ++ struct tee_ioctl_invoke_arg *arg = NULL; ++ struct tee_ioctl_param *params = NULL; ++ TEEC_Result res = TEEC_ERROR_GENERIC; ++ uint32_t eorig = 0; ++ int rc = 0; ++ const size_t arg_size = sizeof(struct tee_ioctl_invoke_arg) + ++ TEEC_CONFIG_PAYLOAD_REF_COUNT * ++ sizeof(struct tee_ioctl_param); ++ union { ++ struct tee_ioctl_invoke_arg arg; ++ uint8_t data[arg_size]; ++ } buf; ++ struct tee_ioctl_buf_data buf_data; ++ TEEC_SharedMemory shm[TEEC_CONFIG_PAYLOAD_REF_COUNT]; ++ ++ memset(&buf, 0, sizeof(buf)); ++ memset(&buf_data, 0, sizeof(buf_data)); ++ memset(&shm, 0, sizeof(shm)); ++ ++ if (!session) { ++ eorig = TEEC_ORIGIN_API; ++ res = TEEC_ERROR_BAD_PARAMETERS; ++ goto out; ++ } ++ ++ bm_timestamp(); ++ ++ buf_data.buf_ptr = (uintptr_t)&buf; ++ buf_data.buf_len = sizeof(buf); ++ ++ arg = &buf.arg; ++ arg->num_params = TEEC_CONFIG_PAYLOAD_REF_COUNT; ++ params = (struct tee_ioctl_param *)(arg + 1); ++ ++ arg->session = session->session_id; ++ arg->func = cmd_id; ++ ++ if (operation) { ++ teec_mutex_lock(&teec_mutex); ++ operation->session = session; ++ teec_mutex_unlock(&teec_mutex); ++ } ++ ++ res = teec_pre_process_operation(session->ctx, operation, params, shm); ++ if (res != TEEC_SUCCESS) { ++ eorig = TEEC_ORIGIN_API; ++ goto out_free_temp_refs; ++ } ++ ++ rc = ioctl(session->ctx->fd, TEE_IOC_INVOKE, &buf_data); ++ if (rc) { ++ EMSG("TEE_IOC_INVOKE failed"); ++ eorig = TEEC_ORIGIN_COMMS; ++ res = ioctl_errno_to_res(errno); ++ goto out_free_temp_refs; ++ } ++ ++ res = arg->ret; ++ eorig = arg->ret_origin; ++ teec_post_process_operation(operation, params, shm); ++ ++ bm_timestamp(); ++ ++out_free_temp_refs: ++ teec_free_temp_refs(operation, shm); ++out: ++ if (error_origin) ++ *error_origin = eorig; ++ return res; ++} ++ ++void TEEC_RequestCancellation(TEEC_Operation *operation) ++{ ++ TEEC_Session *session = NULL; ++ struct tee_ioctl_cancel_arg arg; ++ ++ memset(&arg, 0, sizeof(arg)); ++ ++ if (!operation) ++ return; ++ ++ teec_mutex_lock(&teec_mutex); ++ session = operation->session; ++ teec_mutex_unlock(&teec_mutex); ++ ++ if (!session) ++ return; ++ ++ arg.session = session->session_id; ++ arg.cancel_id = 0; ++ ++ if (ioctl(session->ctx->fd, TEE_IOC_CANCEL, &arg)) ++ EMSG("TEE_IOC_CANCEL: %s", strerror(errno)); ++} ++ ++TEEC_Result TEEC_RegisterSharedMemory(TEEC_Context *ctx, TEEC_SharedMemory *shm) ++{ ++ TEEC_Result res = TEEC_SUCCESS; ++ int fd = 0; ++ size_t s = 0; ++ ++ if (!ctx || !shm) ++ return TEEC_ERROR_BAD_PARAMETERS; ++ ++ if (!shm->flags || (shm->flags & ~(TEEC_MEM_INPUT | TEEC_MEM_OUTPUT))) ++ return TEEC_ERROR_BAD_PARAMETERS; ++ ++ if (!shm->buffer) ++ return TEEC_ERROR_BAD_PARAMETERS; ++ ++ s = shm->size; ++ if (!s) ++ s = 8; ++ if (ctx->reg_mem) { ++ fd = teec_shm_register(ctx->fd, shm->buffer, s, &shm->id); ++ if (fd >= 0) { ++ shm->registered_fd = fd; ++ shm->shadow_buffer = NULL; ++ shm->internal.flags = 0; ++ goto out; ++ } ++ ++ /* ++ * If we're here TEE_IOC_SHM_REGISTER failed, probably ++ * because some read-only memory was supplied and the Linux ++ * kernel doesn't like that at the moment. ++ * ++ * The error could also have some other origin. In any case ++ * we're not making matters worse by trying to allocate and ++ * register a shadow buffer before giving up. ++ */ ++ shm->shadow_buffer = teec_paged_aligned_alloc(s); ++ if (!shm->shadow_buffer) ++ return TEEC_ERROR_OUT_OF_MEMORY; ++ fd = teec_shm_register(ctx->fd, shm->shadow_buffer, s, ++ &shm->id); ++ if (fd >= 0) { ++ shm->registered_fd = fd; ++ shm->internal.flags = SHM_FLAG_SHADOW_BUFFER_ALLOCED; ++ goto out; ++ } ++ ++ if (errno == ENOMEM) ++ res = TEEC_ERROR_OUT_OF_MEMORY; ++ else ++ res = TEEC_ERROR_GENERIC; ++ free(shm->shadow_buffer); ++ shm->shadow_buffer = NULL; ++ return res; ++ } else { ++ fd = teec_shm_alloc(ctx->fd, s, &shm->id); ++ if (fd < 0) ++ return TEEC_ERROR_OUT_OF_MEMORY; ++ ++ shm->shadow_buffer = mmap(NULL, s, PROT_READ | PROT_WRITE, ++ MAP_SHARED, fd, 0); ++ close(fd); ++ if (shm->shadow_buffer == (void *)MAP_FAILED) { ++ shm->id = -1; ++ return TEEC_ERROR_OUT_OF_MEMORY; ++ } ++ shm->registered_fd = -1; ++ shm->internal.flags = 0; ++ } ++ ++out: ++ shm->alloced_size = s; ++ return TEEC_SUCCESS; ++} ++ ++TEEC_Result TEEC_RegisterSharedMemoryFileDescriptor(TEEC_Context *ctx, ++ TEEC_SharedMemory *shm, ++ int fd) ++{ ++ int rfd = 0; ++ struct tee_ioctl_shm_register_fd_data data; ++ ++ memset(&data, 0, sizeof(data)); ++ ++ if (!ctx || !shm || fd < 0) ++ return TEEC_ERROR_BAD_PARAMETERS; ++ ++ if (!shm->flags || (shm->flags & ~(TEEC_MEM_INPUT | TEEC_MEM_OUTPUT))) ++ return TEEC_ERROR_BAD_PARAMETERS; ++ ++ data.fd = fd; ++ rfd = ioctl(ctx->fd, TEE_IOC_SHM_REGISTER_FD, &data); ++ if (rfd < 0) ++ return TEEC_ERROR_BAD_PARAMETERS; ++ ++ shm->buffer = NULL; ++ shm->shadow_buffer = NULL; ++ shm->registered_fd = rfd; ++ shm->id = data.id; ++ shm->size = data.size; ++ return TEEC_SUCCESS; ++} ++ ++TEEC_Result TEEC_AllocateSharedMemory(TEEC_Context *ctx, TEEC_SharedMemory *shm) ++{ ++ int fd = 0; ++ size_t s = 0; ++ ++ if (!ctx || !shm) ++ return TEEC_ERROR_BAD_PARAMETERS; ++ ++ if (!shm->flags || (shm->flags & ~(TEEC_MEM_INPUT | TEEC_MEM_OUTPUT))) ++ return TEEC_ERROR_BAD_PARAMETERS; ++ ++ s = shm->size; ++ if (!s) ++ s = 8; ++ ++ if (ctx->reg_mem) { ++ shm->buffer = teec_paged_aligned_alloc(s); ++ if (!shm->buffer) ++ return TEEC_ERROR_OUT_OF_MEMORY; ++ ++ fd = teec_shm_register(ctx->fd, shm->buffer, s, &shm->id); ++ if (fd < 0) { ++ free(shm->buffer); ++ shm->buffer = NULL; ++ return TEEC_ERROR_OUT_OF_MEMORY; ++ } ++ shm->registered_fd = fd; ++ } else { ++ fd = teec_shm_alloc(ctx->fd, s, &shm->id); ++ if (fd < 0) ++ return TEEC_ERROR_OUT_OF_MEMORY; ++ ++ shm->buffer = mmap(NULL, s, PROT_READ | PROT_WRITE, ++ MAP_SHARED, fd, 0); ++ close(fd); ++ if (shm->buffer == (void *)MAP_FAILED) { ++ shm->id = -1; ++ return TEEC_ERROR_OUT_OF_MEMORY; ++ } ++ shm->registered_fd = -1; ++ } ++ ++ shm->shadow_buffer = NULL; ++ shm->alloced_size = s; ++ shm->internal.flags = SHM_FLAG_BUFFER_ALLOCED; ++ return TEEC_SUCCESS; ++} ++ ++void TEEC_ReleaseSharedMemory(TEEC_SharedMemory *shm) ++{ ++ if (!shm || shm->id == -1) ++ return; ++ ++ if (shm->shadow_buffer) { ++ if (shm->registered_fd >= 0) { ++ if (shm->internal.flags & ++ SHM_FLAG_SHADOW_BUFFER_ALLOCED) ++ free(shm->shadow_buffer); ++ close(shm->registered_fd); ++ } else { ++ munmap(shm->shadow_buffer, shm->alloced_size); ++ } ++ } else if (shm->buffer) { ++ if (shm->registered_fd >= 0) { ++ if (shm->internal.flags & SHM_FLAG_BUFFER_ALLOCED) ++ free(shm->buffer); ++ close(shm->registered_fd); ++ } else { ++ munmap(shm->buffer, shm->alloced_size); ++ } ++ } else if (shm->registered_fd >= 0) { ++ close(shm->registered_fd); ++ } ++ ++ shm->id = -1; ++ shm->shadow_buffer = NULL; ++ shm->buffer = NULL; ++ shm->registered_fd = -1; ++ shm->internal.flags = 0; ++} +diff --git a/src/tee_client_api.h b/src/tee_client_api.h +new file mode 100644 +index 0000000..1693998 +--- /dev/null ++++ b/src/tee_client_api.h +@@ -0,0 +1,555 @@ ++/* ++ * Copyright (c) 2014, STMicroelectronics International N.V. ++ * All rights reserved. ++ * Copyright (c) 2015, Linaro Limited ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright notice, ++ * this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright notice, ++ * this list of conditions and the following disclaimer in the documentation ++ * and/or other materials provided with the distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE ++ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ++ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ++ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++ * POSSIBILITY OF SUCH DAMAGE. ++ */ ++#ifndef TEE_CLIENT_API_H ++#define TEE_CLIENT_API_H ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++#include ++#include ++ ++/* ++ * Defines the number of available memory references in an open session or ++ * invoke command operation payload. ++ */ ++#define TEEC_CONFIG_PAYLOAD_REF_COUNT 4 ++ ++/** ++ * Defines the maximum size of a single shared memory block, in bytes, of both ++ * API allocated and API registered memory. There is no good value to put here ++ * (limits depend on specific config used), so this define does not provide any ++ * restriction in this implementation. ++ */ ++#define TEEC_CONFIG_SHAREDMEM_MAX_SIZE ULONG_MAX ++ ++/** ++ * Flag constants indicating the type of parameters encoded inside the ++ * operation payload (TEEC_Operation), Type is uint32_t. ++ * ++ * TEEC_NONE The Parameter is not used ++ * ++ * TEEC_VALUE_INPUT The Parameter is a TEEC_Value tagged as input. ++ * ++ * TEEC_VALUE_OUTPUT The Parameter is a TEEC_Value tagged as output. ++ * ++ * TEEC_VALUE_INOUT The Parameter is a TEEC_Value tagged as both as ++ * input and output, i.e., for which both the ++ * behaviors of TEEC_VALUE_INPUT and ++ * TEEC_VALUE_OUTPUT apply. ++ * ++ * TEEC_MEMREF_TEMP_INPUT The Parameter is a TEEC_TempMemoryReference ++ * describing a region of memory which needs to be ++ * temporarily registered for the duration of the ++ * Operation and is tagged as input. ++ * ++ * TEEC_MEMREF_TEMP_OUTPUT Same as TEEC_MEMREF_TEMP_INPUT, but the Memory ++ * Reference is tagged as output. The ++ * Implementation may update the size field to ++ * reflect the required output size in some use ++ * cases. ++ * ++ * TEEC_MEMREF_TEMP_INOUT A Temporary Memory Reference tagged as both ++ * input and output, i.e., for which both the ++ * behaviors of TEEC_MEMREF_TEMP_INPUT and ++ * TEEC_MEMREF_TEMP_OUTPUT apply. ++ * ++ * TEEC_MEMREF_WHOLE The Parameter is a Registered Memory Reference ++ * that refers to the entirety of its parent Shared ++ * Memory block. The parameter structure is a ++ * TEEC_MemoryReference. In this structure, the ++ * Implementation MUST read only the parent field ++ * and MAY update the size field when the operation ++ * completes. ++ * ++ * TEEC_MEMREF_PARTIAL_INPUT A Registered Memory Reference structure that ++ * refers to a partial region of its parent Shared ++ * Memory block and is tagged as input. ++ * ++ * TEEC_MEMREF_PARTIAL_OUTPUT Registered Memory Reference structure that ++ * refers to a partial region of its parent Shared ++ * Memory block and is tagged as output. ++ * ++ * TEEC_MEMREF_PARTIAL_INOUT The Registered Memory Reference structure that ++ * refers to a partial region of its parent Shared ++ * Memory block and is tagged as both input and ++ * output, i.e., for which both the behaviors of ++ * TEEC_MEMREF_PARTIAL_INPUT and ++ * TEEC_MEMREF_PARTIAL_OUTPUT apply. ++ */ ++#define TEEC_NONE 0x00000000 ++#define TEEC_VALUE_INPUT 0x00000001 ++#define TEEC_VALUE_OUTPUT 0x00000002 ++#define TEEC_VALUE_INOUT 0x00000003 ++#define TEEC_MEMREF_TEMP_INPUT 0x00000005 ++#define TEEC_MEMREF_TEMP_OUTPUT 0x00000006 ++#define TEEC_MEMREF_TEMP_INOUT 0x00000007 ++#define TEEC_MEMREF_WHOLE 0x0000000C ++#define TEEC_MEMREF_PARTIAL_INPUT 0x0000000D ++#define TEEC_MEMREF_PARTIAL_OUTPUT 0x0000000E ++#define TEEC_MEMREF_PARTIAL_INOUT 0x0000000F ++ ++/** ++ * Flag constants indicating the data transfer direction of memory in ++ * TEEC_Parameter. TEEC_MEM_INPUT signifies data transfer direction from the ++ * client application to the TEE. TEEC_MEM_OUTPUT signifies data transfer ++ * direction from the TEE to the client application. Type is uint32_t. ++ * ++ * TEEC_MEM_INPUT The Shared Memory can carry data from the client ++ * application to the Trusted Application. ++ * TEEC_MEM_OUTPUT The Shared Memory can carry data from the Trusted ++ * Application to the client application. ++ */ ++#define TEEC_MEM_INPUT 0x00000001 ++#define TEEC_MEM_OUTPUT 0x00000002 ++ ++/** ++ * Return values. Type is TEEC_Result ++ * ++ * TEEC_SUCCESS The operation was successful. ++ * TEEC_ERROR_GENERIC Non-specific cause. ++ * TEEC_ERROR_ACCESS_DENIED Access privileges are not sufficient. ++ * TEEC_ERROR_CANCEL The operation was canceled. ++ * TEEC_ERROR_ACCESS_CONFLICT Concurrent accesses caused conflict. ++ * TEEC_ERROR_EXCESS_DATA Too much data for the requested operation was ++ * passed. ++ * TEEC_ERROR_BAD_FORMAT Input data was of invalid format. ++ * TEEC_ERROR_BAD_PARAMETERS Input parameters were invalid. ++ * TEEC_ERROR_BAD_STATE Operation is not valid in the current state. ++ * TEEC_ERROR_ITEM_NOT_FOUND The requested data item is not found. ++ * TEEC_ERROR_NOT_IMPLEMENTED The requested operation should exist but is not ++ * yet implemented. ++ * TEEC_ERROR_NOT_SUPPORTED The requested operation is valid but is not ++ * supported in this implementation. ++ * TEEC_ERROR_NO_DATA Expected data was missing. ++ * TEEC_ERROR_OUT_OF_MEMORY System ran out of resources. ++ * TEEC_ERROR_BUSY The system is busy working on something else. ++ * TEEC_ERROR_COMMUNICATION Communication with a remote party failed. ++ * TEEC_ERROR_SECURITY A security fault was detected. ++ * TEEC_ERROR_SHORT_BUFFER The supplied buffer is too short for the ++ * generated output. ++ * TEEC_ERROR_TARGET_DEAD Trusted Application has panicked ++ * during the operation. ++ */ ++ ++/** ++ * Standard defined error codes. ++ */ ++#define TEEC_SUCCESS 0x00000000 ++#define TEEC_ERROR_STORAGE_NOT_AVAILABLE 0xF0100003 ++#define TEEC_ERROR_GENERIC 0xFFFF0000 ++#define TEEC_ERROR_ACCESS_DENIED 0xFFFF0001 ++#define TEEC_ERROR_CANCEL 0xFFFF0002 ++#define TEEC_ERROR_ACCESS_CONFLICT 0xFFFF0003 ++#define TEEC_ERROR_EXCESS_DATA 0xFFFF0004 ++#define TEEC_ERROR_BAD_FORMAT 0xFFFF0005 ++#define TEEC_ERROR_BAD_PARAMETERS 0xFFFF0006 ++#define TEEC_ERROR_BAD_STATE 0xFFFF0007 ++#define TEEC_ERROR_ITEM_NOT_FOUND 0xFFFF0008 ++#define TEEC_ERROR_NOT_IMPLEMENTED 0xFFFF0009 ++#define TEEC_ERROR_NOT_SUPPORTED 0xFFFF000A ++#define TEEC_ERROR_NO_DATA 0xFFFF000B ++#define TEEC_ERROR_OUT_OF_MEMORY 0xFFFF000C ++#define TEEC_ERROR_BUSY 0xFFFF000D ++#define TEEC_ERROR_COMMUNICATION 0xFFFF000E ++#define TEEC_ERROR_SECURITY 0xFFFF000F ++#define TEEC_ERROR_SHORT_BUFFER 0xFFFF0010 ++#define TEEC_ERROR_EXTERNAL_CANCEL 0xFFFF0011 ++#define TEEC_ERROR_TARGET_DEAD 0xFFFF3024 ++#define TEEC_ERROR_STORAGE_NO_SPACE 0xFFFF3041 ++ ++/** ++ * Function error origins, of type TEEC_ErrorOrigin. These indicate where in ++ * the software stack a particular return value originates from. ++ * ++ * TEEC_ORIGIN_API The error originated within the TEE Client API ++ * implementation. ++ * TEEC_ORIGIN_COMMS The error originated within the underlying ++ * communications stack linking the rich OS with ++ * the TEE. ++ * TEEC_ORIGIN_TEE The error originated within the common TEE code. ++ * TEEC_ORIGIN_TRUSTED_APP The error originated within the Trusted Application ++ * code. ++ */ ++#define TEEC_ORIGIN_API 0x00000001 ++#define TEEC_ORIGIN_COMMS 0x00000002 ++#define TEEC_ORIGIN_TEE 0x00000003 ++#define TEEC_ORIGIN_TRUSTED_APP 0x00000004 ++ ++/** ++ * Session login methods, for use in TEEC_OpenSession() as parameter ++ * connectionMethod. Type is uint32_t. ++ * ++ * TEEC_LOGIN_PUBLIC No login data is provided. ++ * TEEC_LOGIN_USER Login data about the user running the Client ++ * Application process is provided. ++ * TEEC_LOGIN_GROUP Login data about the group running the Client ++ * Application process is provided. ++ * TEEC_LOGIN_APPLICATION Login data about the running Client Application ++ * itself is provided. ++ * TEEC_LOGIN_USER_APPLICATION Login data about the user and the running ++ * Client Application itself is provided. ++ * TEEC_LOGIN_GROUP_APPLICATION Login data about the group and the running ++ * Client Application itself is provided. ++ */ ++#define TEEC_LOGIN_PUBLIC 0x00000000 ++#define TEEC_LOGIN_USER 0x00000001 ++#define TEEC_LOGIN_GROUP 0x00000002 ++#define TEEC_LOGIN_APPLICATION 0x00000004 ++#define TEEC_LOGIN_USER_APPLICATION 0x00000005 ++#define TEEC_LOGIN_GROUP_APPLICATION 0x00000006 ++ ++/** ++ * Encode the paramTypes according to the supplied types. ++ * ++ * @param p0 The first param type. ++ * @param p1 The second param type. ++ * @param p2 The third param type. ++ * @param p3 The fourth param type. ++ */ ++#define TEEC_PARAM_TYPES(p0, p1, p2, p3) \ ++ ((p0) | ((p1) << 4) | ((p2) << 8) | ((p3) << 12)) ++ ++/** ++ * Get the i_th param type from the paramType. ++ * ++ * @param p The paramType. ++ * @param i The i-th parameter to get the type for. ++ */ ++#define TEEC_PARAM_TYPE_GET(p, i) (((p) >> (i * 4)) & 0xF) ++ ++typedef uint32_t TEEC_Result; ++ ++/** ++ * struct TEEC_Context - Represents a connection between a client application ++ * and a TEE. ++ */ ++typedef struct { ++ /* Implementation defined */ ++ int fd; ++ bool reg_mem; ++ bool memref_null; ++} TEEC_Context; ++ ++/** ++ * This type contains a Universally Unique Resource Identifier (UUID) type as ++ * defined in RFC4122. These UUID values are used to identify Trusted ++ * Applications. ++ */ ++typedef struct { ++ uint32_t timeLow; ++ uint16_t timeMid; ++ uint16_t timeHiAndVersion; ++ uint8_t clockSeqAndNode[8]; ++} TEEC_UUID; ++ ++/** ++ * struct TEEC_SharedMemory - Memory to transfer data between a client ++ * application and trusted code. ++ * ++ * @param buffer The memory buffer which is to be, or has been, shared ++ * with the TEE. ++ * @param size The size, in bytes, of the memory buffer. ++ * @param flags Bit-vector which holds properties of buffer. ++ * The bit-vector can contain either or both of the ++ * TEEC_MEM_INPUT and TEEC_MEM_OUTPUT flags. ++ * ++ * A shared memory block is a region of memory allocated in the context of the ++ * client application memory space that can be used to transfer data between ++ * that client application and a trusted application. The user of this struct ++ * is responsible to populate the buffer pointer. ++ */ ++typedef struct { ++ void *buffer; ++ size_t size; ++ uint32_t flags; ++ /* ++ * Implementation-Defined ++ */ ++ int id; ++ size_t alloced_size; ++ void *shadow_buffer; ++ int registered_fd; ++ union { ++ bool dummy; ++ uint8_t flags; ++ } internal; ++} TEEC_SharedMemory; ++ ++/** ++ * struct TEEC_TempMemoryReference - Temporary memory to transfer data between ++ * a client application and trusted code, only used for the duration of the ++ * operation. ++ * ++ * @param buffer The memory buffer which is to be, or has been shared with ++ * the TEE. ++ * @param size The size, in bytes, of the memory buffer. ++ * ++ * A memory buffer that is registered temporarily for the duration of the ++ * operation to be called. ++ */ ++typedef struct { ++ void *buffer; ++ size_t size; ++} TEEC_TempMemoryReference; ++ ++/** ++ * struct TEEC_RegisteredMemoryReference - use a pre-registered or ++ * pre-allocated shared memory block of memory to transfer data between ++ * a client application and trusted code. ++ * ++ * @param parent Points to a shared memory structure. The memory reference ++ * may utilize the whole shared memory or only a part of it. ++ * Must not be NULL ++ * ++ * @param size The size, in bytes, of the memory buffer. ++ * ++ * @param offset The offset, in bytes, of the referenced memory region from ++ * the start of the shared memory block. ++ * ++ */ ++typedef struct { ++ TEEC_SharedMemory *parent; ++ size_t size; ++ size_t offset; ++} TEEC_RegisteredMemoryReference; ++ ++/** ++ * struct TEEC_Value - Small raw data container ++ * ++ * Instead of allocating a shared memory buffer this structure can be used ++ * to pass small raw data between a client application and trusted code. ++ * ++ * @param a The first integer value. ++ * ++ * @param b The second value. ++ */ ++typedef struct { ++ uint32_t a; ++ uint32_t b; ++} TEEC_Value; ++ ++/** ++ * union TEEC_Parameter - Memory container to be used when passing data between ++ * client application and trusted code. ++ * ++ * Either the client uses a shared memory reference, parts of it or a small raw ++ * data container. ++ * ++ * @param tmpref A temporary memory reference only valid for the duration ++ * of the operation. ++ * ++ * @param memref The entire shared memory or parts of it. ++ * ++ * @param value The small raw data container to use ++ */ ++typedef union { ++ TEEC_TempMemoryReference tmpref; ++ TEEC_RegisteredMemoryReference memref; ++ TEEC_Value value; ++} TEEC_Parameter; ++ ++/** ++ * struct TEEC_Session - Represents a connection between a client application ++ * and a trusted application. ++ */ ++typedef struct { ++ /* Implementation defined */ ++ TEEC_Context *ctx; ++ uint32_t session_id; ++} TEEC_Session; ++ ++/** ++ * struct TEEC_Operation - Holds information and memory references used in ++ * TEEC_InvokeCommand(). ++ * ++ * @param started Client must initialize to zero if it needs to cancel ++ * an operation about to be performed. ++ * @param paramTypes Type of data passed. Use TEEC_PARAM_TYPES macro to ++ * create the correct flags. ++ * 0 means TEEC_NONE is passed for all params. ++ * @param params Array of parameters of type TEEC_Parameter. ++ * @param session Internal pointer to the last session used by ++ * TEEC_InvokeCommand with this operation. ++ * ++ */ ++typedef struct { ++ uint32_t started; ++ uint32_t paramTypes; ++ TEEC_Parameter params[TEEC_CONFIG_PAYLOAD_REF_COUNT]; ++ /* Implementation-Defined */ ++ TEEC_Session *session; ++} TEEC_Operation; ++ ++/** ++ * TEEC_InitializeContext() - Initializes a context holding connection ++ * information on the specific TEE, designated by the name string. ++ ++ * @param name A zero-terminated string identifying the TEE to connect to. ++ * If name is set to NULL, the default TEE is connected to. NULL ++ * is the only supported value in this version of the API ++ * implementation. ++ * ++ * @param context The context structure which is to be initialized. ++ * ++ * @return TEEC_SUCCESS The initialization was successful. ++ * @return TEEC_Result Something failed. ++ */ ++TEEC_Result TEEC_InitializeContext(const char *name, TEEC_Context *context); ++ ++/** ++ * TEEC_FinalizeContext() - Destroys a context holding connection information ++ * on the specific TEE. ++ * ++ * This function destroys an initialized TEE context, closing the connection ++ * between the client application and the TEE. This function must only be ++ * called when all sessions related to this TEE context have been closed and ++ * all shared memory blocks have been released. ++ * ++ * @param context The context to be destroyed. ++ */ ++void TEEC_FinalizeContext(TEEC_Context *context); ++ ++/** ++ * TEEC_OpenSession() - Opens a new session with the specified trusted ++ * application. ++ * ++ * @param context The initialized TEE context structure in which ++ * scope to open the session. ++ * @param session The session to initialize. ++ * @param destination A structure identifying the trusted application ++ * with which to open a session. ++ * ++ * @param connectionMethod The connection method to use. ++ * @param connectionData Any data necessary to connect with the chosen ++ * connection method. Not supported, should be set to ++ * NULL. ++ * @param operation An operation structure to use in the session. May ++ * be set to NULL to signify no operation structure ++ * needed. ++ * ++ * @param returnOrigin A parameter which will hold the error origin if ++ * this function returns any value other than ++ * TEEC_SUCCESS. ++ * ++ * @return TEEC_SUCCESS OpenSession successfully opened a new session. ++ * @return TEEC_Result Something failed. ++ * ++ */ ++TEEC_Result TEEC_OpenSession(TEEC_Context *context, ++ TEEC_Session *session, ++ const TEEC_UUID *destination, ++ uint32_t connectionMethod, ++ const void *connectionData, ++ TEEC_Operation *operation, ++ uint32_t *returnOrigin); ++ ++/** ++ * TEEC_CloseSession() - Closes the session which has been opened with the ++ * specific trusted application. ++ * ++ * @param session The opened session to close. ++ */ ++void TEEC_CloseSession(TEEC_Session *session); ++ ++/** ++ * TEEC_InvokeCommand() - Executes a command in the specified trusted ++ * application. ++ * ++ * @param session A handle to an open connection to the trusted ++ * application. ++ * @param commandID Identifier of the command in the trusted application ++ * to invoke. ++ * @param operation An operation structure to use in the invoke command. ++ * May be set to NULL to signify no operation structure ++ * needed. ++ * @param returnOrigin A parameter which will hold the error origin if this ++ * function returns any value other than TEEC_SUCCESS. ++ * ++ * @return TEEC_SUCCESS OpenSession successfully opened a new session. ++ * @return TEEC_Result Something failed. ++ */ ++TEEC_Result TEEC_InvokeCommand(TEEC_Session *session, ++ uint32_t commandID, ++ TEEC_Operation *operation, ++ uint32_t *returnOrigin); ++ ++/** ++ * TEEC_RegisterSharedMemory() - Register a block of existing memory as a ++ * shared block within the scope of the specified context. ++ * ++ * @param context The initialized TEE context structure in which scope to ++ * open the session. ++ * @param sharedMem pointer to the shared memory structure to register. ++ * ++ * @return TEEC_SUCCESS The registration was successful. ++ * @return TEEC_ERROR_OUT_OF_MEMORY Memory exhaustion. ++ * @return TEEC_Result Something failed. ++ */ ++TEEC_Result TEEC_RegisterSharedMemory(TEEC_Context *context, ++ TEEC_SharedMemory *sharedMem); ++ ++/** ++ * TEEC_AllocateSharedMemory() - Allocate shared memory for TEE. ++ * ++ * @param context The initialized TEE context structure in which scope to ++ * open the session. ++ * @param sharedMem Pointer to the allocated shared memory. ++ * ++ * @return TEEC_SUCCESS The registration was successful. ++ * @return TEEC_ERROR_OUT_OF_MEMORY Memory exhaustion. ++ * @return TEEC_Result Something failed. ++ */ ++TEEC_Result TEEC_AllocateSharedMemory(TEEC_Context *context, ++ TEEC_SharedMemory *sharedMem); ++ ++/** ++ * TEEC_ReleaseSharedMemory() - Free or deregister the shared memory. ++ * ++ * @param sharedMem Pointer to the shared memory to be freed. ++ */ ++void TEEC_ReleaseSharedMemory(TEEC_SharedMemory *sharedMemory); ++ ++/** ++ * TEEC_RequestCancellation() - Request the cancellation of a pending open ++ * session or command invocation. ++ * ++ * @param operation Pointer to an operation previously passed to open session ++ * or invoke. ++ */ ++void TEEC_RequestCancellation(TEEC_Operation *operation); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff --git a/src/tee_client_api_extensions.h b/src/tee_client_api_extensions.h +new file mode 100644 +index 0000000..85298aa +--- /dev/null ++++ b/src/tee_client_api_extensions.h +@@ -0,0 +1,57 @@ ++/* ++ * Copyright (c) 2016, Linaro Limited ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright notice, ++ * this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright notice, ++ * this list of conditions and the following disclaimer in the documentation ++ * and/or other materials provided with the distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE ++ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ++ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ++ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++ * POSSIBILITY OF SUCH DAMAGE. ++ */ ++#ifndef TEE_CLIENT_API_EXTENSIONS_H ++#define TEE_CLIENT_API_EXTENSIONS_H ++ ++#include ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++/** ++ * TEEC_RegisterMemoryFileDescriptor() - Register a block of existing memory as ++ * a shared block within the scope of the specified context. ++ * ++ * @param context The initialized TEE context structure in which scope to ++ * open the session. ++ * @param sharedMem pointer to the shared memory structure to register. ++ * @param fd file descriptor of the target memory. ++ * ++ * @return TEEC_SUCCESS The registration was successful. ++ * @return TEEC_ERROR_OUT_OF_MEMORY Memory exhaustion. ++ * @return TEEC_Result Something failed. ++ */ ++TEEC_Result TEEC_RegisterSharedMemoryFileDescriptor(TEEC_Context *context, ++ TEEC_SharedMemory *sharedMem, ++ int fd); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* TEE_CLIENT_API_EXTENSIONS_H */ +diff --git a/src/teec_benchmark.h b/src/teec_benchmark.h +new file mode 100644 +index 0000000..17d99ac +--- /dev/null ++++ b/src/teec_benchmark.h +@@ -0,0 +1,37 @@ ++/* ++ * Copyright (c) 2017, Linaro Limited ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright notice, ++ * this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright notice, ++ * this list of conditions and the following disclaimer in the documentation ++ * and/or other materials provided with the distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE ++ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ++ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ++ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++ * POSSIBILITY OF SUCH DAMAGE. ++ */ ++ ++#ifndef __TEEC_BENCHMARK_H ++#define __TEEC_BENCHMARK_H ++ ++#ifdef CFG_TEE_BENCHMARK ++void bm_timestamp(void); ++#else ++static inline void bm_timestamp(void) {} ++#endif ++ ++#endif /* __TEEC_BENCHMARK_H */ +diff --git a/src/teec_trace.c b/src/teec_trace.c +new file mode 100644 +index 0000000..7194c8c +--- /dev/null ++++ b/src/teec_trace.c +@@ -0,0 +1,141 @@ ++/* ++ * Copyright (c) 2014, STMicroelectronics International N.V. ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright notice, ++ * this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright notice, ++ * this list of conditions and the following disclaimer in the documentation ++ * and/or other materials provided with the distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE ++ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ++ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ++ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++ * POSSIBILITY OF SUCH DAMAGE. ++ */ ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++#include ++ ++#include "teec_trace.h" ++ ++#define MIN(x, y) (((x) < (y)) ? (x) : (y)) ++ ++/* ++ * The length of the prefix is 37, for example it looks like this: ++ * P = Prefix ++ * M = Message ++ * F = Function name ++ * L = Line number ++ * PPPP: MMMMM [FFFFFFFFFFFFFFF : LLLLL] ++ */ ++#define MAX_PRINT_SIZE 256 ++ ++#ifdef TEEC_LOG_FILE ++static void log_to_file(const char *buffer) ++{ ++ FILE *log_file = fopen(TEEC_LOG_FILE, "a"); ++ ++ if (log_file != NULL) { ++ fprintf(log_file, "%s", buffer); ++ fclose(log_file); ++ log_file = NULL; ++ } ++} ++#else ++#define log_to_file(buffer) ++#endif ++ ++static const char * const trace_level_strings[] = { ++ "", "ERR", "INF", "DBG", "FLW" ++}; ++ ++void _dprintf(const char *function, int line, int level, const char *prefix, ++ const char *fmt, ...) ++{ ++ char msg[MAX_PRINT_SIZE]; ++ int n = 0; ++ va_list ap; ++ ++ if (function) { ++ int thread_id = syscall(SYS_gettid); ++ ++ n = snprintf(msg, sizeof(msg), "%s [%d] %s:%s:%d: ", ++ trace_level_strings[level], thread_id, prefix, ++ function, line); ++ if (n < 0) ++ return; ++ } ++ ++ if ((size_t)n < sizeof(msg)) { ++ va_start(ap, fmt); ++ n = vsnprintf(msg + n, sizeof(msg) - n, fmt, ap); ++ va_end(ap); ++ if (n < 0) ++ return; ++ } ++ ++ fprintf(stdout, "%s", msg); ++ log_to_file(msg); ++} ++ ++#if (defined(DEBUGLEVEL_3) || defined(DEBUGLEVEL_true) || defined(DEBUGLEVEL_4)) ++void dump_buffer(const char *bname, const uint8_t *buffer, size_t blen) ++{ ++ fprintf(stderr, "#### %s\n", bname); ++ ++ while (blen > 0) { ++ size_t n = 0; ++ ++ for (n = 0; n < 16; n++) { ++ if (n < blen) ++ fprintf(stderr, "%02x ", (int)buffer[n]); ++ else ++ fprintf(stderr, " "); ++ ++ if (n == 7) ++ fprintf(stderr, " "); ++ } ++ ++ fprintf(stderr, " |"); ++ ++ for (n = 0; n < 16; n++) { ++ if (n < blen) { ++ if (isprint(buffer[n])) ++ fprintf(stderr, "%c", (int)buffer[n]); ++ else ++ fprintf(stderr, "."); ++ } ++ } ++ ++ fprintf(stderr, "|\n"); ++ ++ blen -= MIN(blen, 16); ++ buffer += 16; ++ } ++} ++#else ++void dump_buffer(const char *bname, const uint8_t *buffer, size_t blen) ++{ ++ (void)bname; ++ (void)buffer; ++ (void)blen; ++} ++#endif +diff --git a/src/teec_trace.h b/src/teec_trace.h +new file mode 100644 +index 0000000..b1e37ec +--- /dev/null ++++ b/src/teec_trace.h +@@ -0,0 +1,148 @@ ++/* ++ * Copyright (c) 2014, STMicroelectronics International N.V. ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright notice, ++ * this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright notice, ++ * this list of conditions and the following disclaimer in the documentation ++ * and/or other materials provided with the distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE ++ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ++ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ++ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++ * POSSIBILITY OF SUCH DAMAGE. ++ */ ++#ifndef TEEC_TRACE_H ++#define TEEC_TRACE_H ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#include ++#include ++#include ++#define BINARY_PREFIX "LT" ++ ++#ifndef BINARY_PREFIX ++#error "BINARY_PREFIX not defined" ++#endif ++ ++/* ++ * Trace levels. ++ * ++ * ERROR is used when some kind of error has happened, this is most likely the ++ * print you will use most of the time when you report some kind of error. ++ * ++ * INFO is used when you want to print some 'normal' text to the user. ++ * This is the default level. ++ * ++ * DEBUG is used to print extra information to enter deeply in the module. ++ * ++ * FLOW is used to print the execution flox, typically the in/out of functions. ++ * ++ * */ ++ ++#define TRACE_ERROR 1 ++#define TRACE_INFO 2 ++#define TRACE_DEBUG 3 ++#define TRACE_FLOW 4 ++ ++#if defined(DEBUGLEVEL_0) && !defined(DEBUGLEVEL) ++#define DEBUGLEVEL TRACE_ERROR ++#endif ++ ++#if defined(DEBUGLEVEL_1) && !defined(DEBUGLEVEL) ++#define DEBUGLEVEL TRACE_ERROR ++#endif ++ ++#if defined(DEBUGLEVEL_2) && !defined(DEBUGLEVEL) ++#define DEBUGLEVEL TRACE_INFO ++#endif ++ ++#if defined(DEBUGLEVEL_3) && !defined(DEBUGLEVEL) ++#define DEBUGLEVEL TRACE_DEBUG ++#endif ++ ++#if defined(DEBUGLEVEL_4) && !defined(DEBUGLEVEL) ++#define DEBUGLEVEL TRACE_FLOW ++#endif ++ ++#ifndef DEBUGLEVEL ++/* Default debug level. */ ++#define DEBUGLEVEL TRACE_INFO ++#endif ++ ++/* ++ * This define make sure that parameters are checked in the same manner as it ++ * is done in the normal printf function. ++ */ ++#define __PRINTFLIKE(__fmt, __varargs) __attribute__\ ++ ((__format__(__printf__, __fmt, __varargs))) ++ ++void _dprintf(const char *function, int line, int level, const char *prefix, ++ const char *fmt, ...) __PRINTFLIKE(5, 6); ++ ++#define dprintf(level, x...) do { \ ++ if ((level) <= DEBUGLEVEL) { \ ++ _dprintf(__func__, __LINE__, level, \ ++ BINARY_PREFIX, x); \ ++ } \ ++ } while (0) ++ ++#define EMSG(fmt, ...) dprintf(TRACE_ERROR, fmt "\n", ##__VA_ARGS__) ++#define IMSG(fmt, ...) dprintf(TRACE_INFO, fmt "\n", ##__VA_ARGS__) ++#define DMSG(fmt, ...) dprintf(TRACE_DEBUG, fmt "\n", ##__VA_ARGS__) ++#define FMSG(fmt, ...) dprintf(TRACE_FLOW, fmt "\n", ##__VA_ARGS__) ++ ++#define INMSG(fmt, ...) FMSG("> " fmt, ##__VA_ARGS__) ++#define OUTMSG(fmt, ...) FMSG("< " fmt, ##__VA_ARGS__) ++#define OUTRMSG(r) \ ++ do { \ ++ if (r) \ ++ EMSG("Function returns with [%d]", r); \ ++ OUTMSG("r=[%d]", r); \ ++ return r; \ ++ } while (0) ++ ++#define dprintf_raw(level, x...) do { \ ++ if ((level) <= DEBUGLEVEL) \ ++ _dprintf(0, 0, (level), BINARY_PREFIX, x); \ ++ } while (0) ++ ++#define EMSG_RAW(fmt, ...) dprintf_raw(TRACE_ERROR, fmt, ##__VA_ARGS__) ++#define IMSG_RAW(fmt, ...) dprintf_raw(TRACE_INFO, fmt, ##__VA_ARGS__) ++#define DMSG_RAW(fmt, ...) dprintf_raw(TRACE_DEBUG, fmt, ##__VA_ARGS__) ++#define FMSG_RAW(fmt, ...) dprintf_raw(TRACE_FLOW, fmt, ##__VA_ARGS__) ++ ++/* ++ * This function will hex and ascii dump a buffer. ++ * ++ * Note that this function will only print if debug flag ++ * DEBUGLEVEL is INFO or FLOOD. ++ * ++ * @param bname Information string describing the buffer. ++ * @param buffer Pointer to the buffer. ++ * @param blen Length of the buffer. ++ * ++ * @return void ++ */ ++void dump_buffer(const char *bname, const uint8_t *buffer, size_t blen); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff --git a/src/uboot_env.c b/src/uboot_env.c +index 86f9b9e..f9aa985 100644 +--- a/src/uboot_env.c ++++ b/src/uboot_env.c +@@ -41,6 +41,9 @@ + #include "md5.h" + #include "uboot_private.h" + ++#include ++#include ++ + /* + * The BLOB includes a random AES-256 key (32 bytes) and a + * Message Authentication Code (MAC) (16 bytes) +@@ -972,7 +975,7 @@ static bool machine_is_compatible(char *machine) + } + + #define MAX_HWID_WORDS 4 +-static int env_caam_get_keymod(unsigned char output[16]) ++static int env_encryption_get_keymod(unsigned char output[16]) + { + int i; + int len; +@@ -993,6 +996,7 @@ static int env_caam_get_keymod(unsigned char output[16]) + return -1; + } + ocotp_hwid[i] = ntohl(*(uint32_t *)buf); ++ fprintf(stderr, "HWID_%d %x \n ",i,ocotp_hwid[i]); + close(fd); + } else if (machine_is_compatible("digi,ccimx6ul") || + machine_is_compatible("digi,ccimx6")) { +@@ -1040,7 +1044,7 @@ static int env_caam_crypt(char *data, unsigned int size, const int enc) + char *buffer; + unsigned char key_modifier[16]; + +- ret = env_caam_get_keymod(key_modifier); ++ ret = env_encryption_get_keymod(key_modifier); + if (ret) + return ret; + +@@ -1087,6 +1091,165 @@ free: + return ret; + } + ++void prepare_tee_session(struct aes_ctx *ctx) ++{ ++ TEEC_Result ret; ++ uint32_t origin; ++ TEEC_UUID uuid = TA_STM32MP_CRYP_UUID; ++ ++ ret = TEEC_InitializeContext(NULL, &ctx->ctx); ++ if (ret != TEEC_SUCCESS) ++ printf("TEEC_InitializeContext failed with code 0x%x", ret); ++ ++ /* Open a session with the TA */ ++ ret = TEEC_OpenSession(&ctx->ctx, &ctx->sess, &uuid, ++ TEEC_LOGIN_PUBLIC, NULL, NULL, &origin); ++ if (ret != TEEC_SUCCESS) ++ printf("TEEC_Opensession failed with code 0x%x origin 0x%x", ++ ret, origin); ++ ++} ++ ++void terminate_tee_session(struct aes_ctx *ctx) ++{ ++ TEEC_CloseSession(&ctx->sess); ++ TEEC_FinalizeContext(&ctx->ctx); ++} ++ ++void prepare_aes(struct aes_ctx *ctx, int encode) ++{ ++ TEEC_Operation op; ++ uint32_t origin; ++ TEEC_Result res; ++ ++ memset(&op, 0, sizeof(op)); ++ op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, ++ TEEC_VALUE_INPUT, ++ TEEC_VALUE_INPUT, ++ TEEC_NONE); ++ ++ op.params[0].value.a = TA_AES_ALGO_CTR; ++ op.params[1].value.a = AES128_KEY_LENGTH; ++ op.params[2].value.a = encode ? TA_AES_MODE_ENCODE : ++ TA_AES_MODE_DECODE; ++ ++ res = TEEC_InvokeCommand(&ctx->sess, TA_AES_CMD_PREPARE, ++ &op, &origin); ++ if (res != TEEC_SUCCESS) ++ printf("TEEC_InvokeCommand(PREPARE) failed 0x%x origin 0x%x", ++ res, origin); ++} ++ ++void set_key(struct aes_ctx *ctx, size_t key_sz) ++{ ++ TEEC_Operation op; ++ uint32_t origin; ++ TEEC_Result res; ++ ++ memset(&op, 0, sizeof(op)); ++ ++ op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, ++ TEEC_NONE, TEEC_NONE, TEEC_NONE); ++ ++ op.params[0].value.a = key_sz; ++ ++ res = TEEC_InvokeCommand(&ctx->sess, TA_AES_CMD_SET_KEY, ++ &op, &origin); ++ if (res != TEEC_SUCCESS) ++ printf("TEEC_InvokeCommand(SET_KEY) failed 0x%x origin 0x%x", ++ res, origin); ++} ++ ++void set_iv(struct aes_ctx *ctx, char *iv, size_t iv_sz) ++{ ++ TEEC_Operation op; ++ uint32_t origin; ++ TEEC_Result res; ++ ++ memset(&op, 0, sizeof(op)); ++ op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT, ++ TEEC_NONE, TEEC_NONE, TEEC_NONE); ++ op.params[0].tmpref.buffer = iv; ++ op.params[0].tmpref.size = iv_sz; ++ ++ res = TEEC_InvokeCommand(&ctx->sess, TA_AES_CMD_SET_IV, ++ &op, &origin); ++ if (res != TEEC_SUCCESS) ++ printf("TEEC_InvokeCommand(SET_IV) failed 0x%x origin 0x%x", ++ res, origin); ++} ++ ++void cipher_buffer(struct aes_ctx *ctx, char *in, char *out, size_t sz) ++{ ++ TEEC_Operation op; ++ uint32_t origin; ++ TEEC_Result res; ++ ++ memset(&op, 0, sizeof(op)); ++ op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT, ++ TEEC_MEMREF_TEMP_OUTPUT, ++ TEEC_NONE, TEEC_NONE); ++ op.params[0].tmpref.buffer = in; ++ op.params[0].tmpref.size = sz; ++ op.params[1].tmpref.buffer = out; ++ op.params[1].tmpref.size = sz; ++ ++ res = TEEC_InvokeCommand(&ctx->sess, TA_AES_CMD_CIPHER, ++ &op, &origin); ++ if (res != TEEC_SUCCESS) ++ printf("TEEC_InvokeCommand(CIPHER) failed 0x%x origin 0x%x", ++ res, origin); ++} ++ ++static int env_ccmp1_crypt(char *data, unsigned int size, const int enc) ++{ ++ int ret, i; ++ uint32_t origin; ++ struct aes_ctx *aes; ++ char *iv, *ciph; ++ TEEC_UUID uuid = TA_STM32MP_CRYP_UUID; ++ unsigned char key_modifier[16]; ++ ++ /* Allocate all the buffer */ ++ iv = calloc(AES_BLOCK_LENGTH, sizeof(char)); ++ ciph = calloc(size+1, sizeof(unsigned int)); ++ ++ if (!iv || !ciph) { ++ printf("%s: can't allocate memory\n", __func__); ++ ret = -ENOMEM; ++ goto err_free_buffs; ++ } ++ ++ /* Get key_modifer for IV */ ++ ret = env_encryption_get_keymod(key_modifier); ++ if (ret) ++ return ret; ++ ++ memcpy(iv, key_modifier, AES_BLOCK_LENGTH); ++ aes = (struct aes_ctx*)malloc(sizeof(struct aes_ctx)); ++ if (aes == NULL) { ++ printf("%s: can't allocate context memory\n", __func__); ++ ret = -ENOMEM; ++ } else { ++ prepare_tee_session(aes); ++ ++ prepare_aes(aes, enc); ++ set_key(aes, AES128_KEY_LENGTH); ++ set_iv(aes, iv, AES_BLOCK_LENGTH); ++ memset(ciph, 0, size); ++ cipher_buffer(aes, data, ciph, size); ++ /* copy ciphered data */ ++ memcpy(data, ciph, size); ++ free(aes); ++ } ++ ++err_free_buffs: ++ free(iv); ++ free(ciph); ++ ++ return ret; ++} ++ + int libuboot_env_store(struct uboot_ctx *ctx) + { + struct var_entry *entry; +@@ -1163,7 +1326,12 @@ int libuboot_env_store(struct uboot_ctx *ctx) + } + + if (ctx->encrypted) { +- ret = env_caam_crypt(data, ctx->usable_size, 1); ++ /* Detect the platform */ ++ if (machine_is_compatible("digi,ccmp15") || ++ machine_is_compatible("digi,ccmp13")) ++ ret = env_ccmp1_crypt(data, ctx->usable_size, 1); ++ else ++ ret = env_caam_crypt(data, ctx->usable_size, 1); + if (ret) { + fprintf(stderr, + "Error: can't encrypt env for flash\n"); +@@ -1237,7 +1405,12 @@ static int libuboot_load(struct uboot_ctx *ctx) + crc = *(uint32_t *)(buf[i] + offsetcrc); + dev->crc = crc32(0, (uint8_t *)data, usable_envsize); + if (ctx->encrypted) { +- ret = env_caam_crypt((char *)data, ctx->usable_size, 0); ++ /* Detect the platform */ ++ if (machine_is_compatible("digi,ccmp15") || ++ machine_is_compatible("digi,ccmp13")) ++ ret = env_ccmp1_crypt((char *)data, ctx->usable_size, 0); ++ else ++ ret = env_caam_crypt((char *)data, ctx->usable_size, 0); + if (ret) { + fprintf(stderr, "Error: can't decrypt environment\n"); + return ret; +-- +2.34.1 + diff --git a/meta-digi-arm/recipes-bsp/libubootenv/libubootenv_%.bbappend b/meta-digi-arm/recipes-bsp/libubootenv/libubootenv_%.bbappend index d4298883e..5ff1b39e6 100644 --- a/meta-digi-arm/recipes-bsp/libubootenv/libubootenv_%.bbappend +++ b/meta-digi-arm/recipes-bsp/libubootenv/libubootenv_%.bbappend @@ -21,6 +21,7 @@ SRC_URI += " \ file://0002-Implement-U-Boot-environment-access-functions.patch \ file://0003-tools-env-add-support-to-set-dynamic-location-of-env.patch \ file://0004-fall-back-to-read-HWID-from-nvmem-device-if-not-avai.patch \ + file://0005-Implement-support-for-environment-encryption-for-CCM.patch \ " do_install:append() { diff --git a/meta-digi-arm/recipes-bsp/trustfence-cst/trustfence-cst-3.3.1.inc b/meta-digi-arm/recipes-bsp/trustfence-cst/trustfence-cst-3.3.1.inc index a9319dfc0..cf5dda093 100644 --- a/meta-digi-arm/recipes-bsp/trustfence-cst/trustfence-cst-3.3.1.inc +++ b/meta-digi-arm/recipes-bsp/trustfence-cst/trustfence-cst-3.3.1.inc @@ -21,6 +21,7 @@ SRC_URI = " \ file://0005-ahab_pki_tree.sh-automate-script.patch \ file://0006-ahab_pki_tree.sh-use-a-random-password-for-the-defau.patch \ file://0007-rules.mk-weaken-specific-function-err_msg.patch \ + file://0008-pki_tree.sh-extract-public-keys-from-certificates.patch \ " SRC_URI[cst.md5sum] = "27ba9c8bc0b8a7f14d23185775c53794" diff --git a/meta-digi-arm/recipes-bsp/trustfence-cst/trustfence-cst/0008-pki_tree.sh-extract-public-keys-from-certificates.patch b/meta-digi-arm/recipes-bsp/trustfence-cst/trustfence-cst/0008-pki_tree.sh-extract-public-keys-from-certificates.patch new file mode 100644 index 000000000..dcaa24120 --- /dev/null +++ b/meta-digi-arm/recipes-bsp/trustfence-cst/trustfence-cst/0008-pki_tree.sh-extract-public-keys-from-certificates.patch @@ -0,0 +1,42 @@ +From: Hector Palacios +Date: Thu, 3 Aug 2023 16:25:36 +0200 +Subject: [PATCH] pki_tree.sh: extract public keys from certificates + +The public key needs to be available on the rootfs so that signed SWU +packages can be authenticated. +Do this on the PKI generation script so that recipes don't need to do it. + +Signed-off-by: Hector Palacios +--- + keys/ahab_pki_tree.sh | 3 +++ + keys/hab4_pki_tree.sh | 3 +++ + 2 files changed, 6 insertions(+) + +diff --git a/keys/ahab_pki_tree.sh b/keys/ahab_pki_tree.sh +index 7f10c5388146..63b5ce58ade7 100755 +--- a/keys/ahab_pki_tree.sh ++++ b/keys/ahab_pki_tree.sh +@@ -632,6 +632,9 @@ do + -in temp_sgk.pem \ + -out ${sgk_key}.pem + ++ # Extract public key from the certificate ++ openssl x509 -pubkey -noout -in "${srk_crt_i}" > ../crts/key${i}.pub ++ + # Cleanup + rm ./temp_sgk.pem ./temp_sgk_req.pem + +diff --git a/keys/hab4_pki_tree.sh b/keys/hab4_pki_tree.sh +index ac6fb29b7f91..e76f22f40643 100755 +--- a/keys/hab4_pki_tree.sh ++++ b/keys/hab4_pki_tree.sh +@@ -682,6 +682,9 @@ do + -in temp_img.pem \ + -out ${img_key}.pem + ++ # Extract public key from the certificate ++ openssl x509 -pubkey -noout -in "${img_crt}.pem" > ../crts/key${i}.pub ++ + # Cleanup + rm ./temp_img.pem ./temp_img_req.pem + diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey.inc b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey.inc index efa8ade57..894da6074 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey.inc +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey.inc @@ -28,7 +28,6 @@ INSTALL_FW_UBOOT_SCRIPTS = " \ SRC_URI = " \ ${UBOOT_GIT_URI};branch=${SRCBRANCH} \ - file://altboot.txt \ file://boot.txt \ ${INSTALL_FW_UBOOT_SCRIPTS} \ " @@ -96,9 +95,6 @@ build_uboot_scripts() { mkimage -T script -n bootscript -C none -d ${TMP_BOOTSCR} ${DEPLOYDIR}/boot.scr rm -f ${TMP_BOOTSCR} - # Alternate boot script for dualboot - mkimage -T script -n "Alternate bootscript" -C none -d ${WORKDIR}/altboot.txt ${DEPLOYDIR}/altboot.scr - # Sign the scripts (TODO signing of artifacts for STM-based platforms) if [ "${TRUSTFENCE_SIGN}" = "1" ] && [ "${DEY_SOC_VENDOR}" != "STM" ]; then export CONFIG_SIGN_KEYS_PATH="${TRUSTFENCE_SIGN_KEYS_PATH}" @@ -109,11 +105,6 @@ build_uboot_scripts() { TMP_SIGNED_BOOTSCR="$(mktemp ${WORKDIR}/bootscr-signed.XXXXXX)" trustfence-sign-artifact.sh -p "${DIGI_SOM}" -b "${DEPLOYDIR}/boot.scr" "${TMP_SIGNED_BOOTSCR}" mv "${TMP_SIGNED_BOOTSCR}" "${DEPLOYDIR}/boot.scr" - - # Sign altboot script - TMP_SIGNED_BOOTSCR="$(mktemp ${WORKDIR}/altboot-signed.XXXXXX)" - trustfence-sign-artifact.sh -p "${DIGI_SOM}" -b "${DEPLOYDIR}/altboot.scr" "${TMP_SIGNED_BOOTSCR}" - mv "${TMP_SIGNED_BOOTSCR}" "${DEPLOYDIR}/altboot.scr" fi } @@ -182,14 +173,6 @@ BOOT_TOOLS:ccmp1 = "u-boot" FIP_UBOOT_HEADER = "ccmp15-dvk" FIP_UBOOT_HEADER:ccmp13 = "ccmp13-dvk" -do_deploy:append:ccimx8x() { - # Move all U-Boot artifacts to the imx-boot-tools folder - # U-Boot images are not bootable on the i.MX8X - install -d ${DEPLOYDIR}/${BOOT_TOOLS} - mv ${DEPLOYDIR}/u-boot* ${DEPLOYDIR}/${BOOT_TOOLS}/ - mv ${DEPLOYDIR}/${UBOOT_SYMLINK}-* ${DEPLOYDIR}/${BOOT_TOOLS}/ -} - do_deploy:append:ccimx8m() { # Deploy u-boot-nodtb.bin and ccimx8m[m|n]-dvk.dtb, to be packaged in boot binary by imx-boot if [ -n "${UBOOT_CONFIG}" ] diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6/altboot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6/altboot.txt deleted file mode 100644 index 29172875b..000000000 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6/altboot.txt +++ /dev/null @@ -1,37 +0,0 @@ -# -# U-Boot bootscript for altbootcmd (dual boot fallback after retries) -# - -# After an upgrade, active_system has changed. U-Boot tries to boot this system -# for a number of tries. If the limit is reached, altbootcmd is run instead. -# This is the script that it will run. It has to: -# * switch back to previous system -# * reset the firmware update flag -# * run the regular boot command - -if test "${dualboot}" = "yes" && test "${upgrade_available}" = "1"; then - echo "## Update failed; Rolling back to previous version." - if test "${active_system}" = "linux_a"; then - setenv active_system linux_b - part number mmc ${mmcbootdev} linux_b linux_b_index - setexpr mmcpart ${linux_b_index} - # Save the partition index on variable rootfs_b_index - part number mmc ${mmcbootdev} rootfs_b rootfs_b_index - # Save the rootfs_b UUID into mmcroot_b - part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b - setenv mmcroot PARTUUID=${mmcroot_b} - else - setenv active_system linux_a - part number mmc ${mmcbootdev} linux_a linux_a_index - setexpr mmcpart ${linux_a_index} - # Save the partition index on variable rootfs_a_index - part number mmc ${mmcbootdev} rootfs_a rootfs_a_index - # Save the rootfs_a UUID into mmcroot_a - part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a - setenv mmcroot PARTUUID=${mmcroot_a} - fi - setenv upgrade_available - setenv bootcount 0 - saveenv -fi -run bootcmd diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt index 099380233..660614a7e 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt @@ -13,23 +13,26 @@ if test "${dualboot}" = "yes"; then echo "Update detected; Booting new system in ${active_system} (try ${bootcount})" else if test "${active_system}" = "linux_a"; then - echo "Booting from system A" - part number mmc ${mmcbootdev} linux_a pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_a_index - part number mmc ${mmcbootdev} rootfs_a rootfs_a_index - # Save the rootfs_a UUID into mmcroot_a - part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a - setenv mmcroot PARTUUID=${mmcroot_a} + echo "Booting from system A (try ${bootcount})" + part number mmc ${mmcbootdev} linux_a tmp_mmcpart + part number mmc ${mmcbootdev} rootfs_a tmp_rootfs_index else - echo "Booting from system B" - part number mmc ${mmcbootdev} linux_b pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_b_index - part number mmc ${mmcbootdev} rootfs_b rootfs_b_index - # Save the rootfs_b UUID into mmcroot_b - part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b - setenv mmcroot PARTUUID=${mmcroot_b} + echo "Booting from system B (try ${bootcount})" + part number mmc ${mmcbootdev} linux_b tmp_mmcpart + part number mmc ${mmcbootdev} rootfs_b tmp_rootfs_index + fi + part uuid mmc ${mmcbootdev}:${tmp_rootfs_index} tmp_mmcroot + if test "${mmcpart}" -ne "${tmp_mmcpart}"; then + setexpr mmcpart ${tmp_mmcpart} + env_save_needed="1" + fi + if test "${mmcroot}" != "PARTUUID=${tmp_mmcroot}"; then + setenv mmcroot PARTUUID=${tmp_mmcroot} + env_save_needed="1" + fi + if test "${env_save_needed}" = "1"; then + env delete tmp_mmcpart tmp_rootfs_index tmp_mmcroot + env save fi fi else diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_sd.txt index 3f953a5a7..0b856cea3 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_sd.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_sd.txt @@ -63,6 +63,8 @@ for install_f in ${INSTALL_UBOOT_FILENAME} ${INSTALL_LINUX_FILENAME} ${INSTALL_R fi; done if test "${install_abort}" = "1"; then + echo "To install a different image, set variable 'image-name', e.g.:" + echo " => setenv image-name core-image-base" echo "Aborted."; exit; fi diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_usb.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_usb.txt index 1810e52f5..9e9a84f1c 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_usb.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/install_linux_fw_usb.txt @@ -63,6 +63,8 @@ for install_f in ${INSTALL_UBOOT_FILENAME} ${INSTALL_LINUX_FILENAME} ${INSTALL_R fi; done if test "${install_abort}" = "1"; then + echo "To install a different image, set variable 'image-name', e.g.:" + echo " => setenv image-name core-image-base" echo "Aborted."; exit; fi diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt index a0a1cc0d8..46cff15a2 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt @@ -13,23 +13,26 @@ if test "${dualboot}" = "yes"; then echo "Update detected; Booting new system in ${active_system} (try ${bootcount})" else if test "${active_system}" = "linux_a"; then - echo "Booting from system A" - part number mmc ${mmcbootdev} linux_a pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_a_index - part number mmc ${mmcbootdev} rootfs_a rootfs_a_index - # Save the rootfs_a UUID into mmcroot_a - part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a - setenv mmcroot PARTUUID=${mmcroot_a} + echo "Booting from system A (try ${bootcount})" + part number mmc ${mmcbootdev} linux_a tmp_mmcpart + part number mmc ${mmcbootdev} rootfs_a tmp_rootfs_index else - echo "Booting from system B" - part number mmc ${mmcbootdev} linux_b pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_b_index - part number mmc ${mmcbootdev} rootfs_b rootfs_b_index - # Save the rootfs_b UUID into mmcroot_b - part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b - setenv mmcroot PARTUUID=${mmcroot_b} + echo "Booting from system B (try ${bootcount})" + part number mmc ${mmcbootdev} linux_b tmp_mmcpart + part number mmc ${mmcbootdev} rootfs_b tmp_rootfs_index + fi + part uuid mmc ${mmcbootdev}:${tmp_rootfs_index} tmp_mmcroot + if test "${mmcpart}" -ne "${tmp_mmcpart}"; then + setexpr mmcpart ${tmp_mmcpart} + env_save_needed="1" + fi + if test "${mmcroot}" != "PARTUUID=${tmp_mmcroot}"; then + setenv mmcroot PARTUUID=${tmp_mmcroot} + env_save_needed="1" + fi + if test "${env_save_needed}" = "1"; then + env delete tmp_mmcpart tmp_rootfs_index tmp_mmcroot + env save fi fi else diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_sd.txt index c0d368393..339785774 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_sd.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_sd.txt @@ -74,6 +74,8 @@ for install_f in ${INSTALL_UBOOT_FILENAME} ${INSTALL_LINUX_FILENAME} ${INSTALL_R fi; done if test "${install_abort}" = "1"; then + echo "To install a different image, set variable 'image-name', e.g.:" + echo " => setenv image-name core-image-base" echo "Aborted."; exit; fi diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_usb.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_usb.txt index cf7de617b..586deb72f 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_usb.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/install_linux_fw_usb.txt @@ -74,6 +74,8 @@ for install_f in ${INSTALL_UBOOT_FILENAME} ${INSTALL_LINUX_FILENAME} ${INSTALL_R fi; done if test "${install_abort}" = "1"; then + echo "To install a different image, set variable 'image-name', e.g.:" + echo " => setenv image-name core-image-base" echo "Aborted."; exit; fi diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/altboot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/altboot.txt deleted file mode 100644 index 3d8abc1cb..000000000 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/altboot.txt +++ /dev/null @@ -1,29 +0,0 @@ -# -# U-Boot bootscript for altbootcmd (dual boot fallback after retries) -# - -# After an upgrade, active_system has changed. U-Boot tries to boot this system -# for a number of tries. If the limit is reached, altbootcmd is run instead. -# This is the script that it will run. It has to: -# * switch back to previous system -# * reset the firmware update flag -# * run the regular boot command - -if test "${dualboot}" = "yes" && test "${upgrade_available}" = "1"; then - echo "## Update failed; Rolling back to previous version." - if test "${active_system}" = "linux_a"; then - setenv active_system linux_b - setenv mtdbootpart ${active_system} - setenv mtdrootfspart ${rootfsvol_b} - setenv rootfsvol ${rootfsvol_b} - else - setenv active_system linux_a - setenv mtdbootpart ${active_system} - setenv mtdrootfspart ${rootfsvol_a} - setenv rootfsvol ${rootfsvol_a} - fi - setenv upgrade_available - setenv bootcount 0 - saveenv -fi -run bootcmd diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt index 785a67e96..f03b47ef7 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt @@ -67,6 +67,8 @@ for install_f in ${INSTALL_UBOOT_FILENAME} ${INSTALL_LINUX_FILENAME} ${INSTALL_R fi; done if test "${install_abort}" = "1"; then + echo "To install a different image, set variable 'image-name', e.g.:" + echo " => setenv image-name core-image-base" echo "Aborted."; exit; fi diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt index 71195f38d..1b375ee31 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt @@ -67,6 +67,8 @@ for install_f in ${INSTALL_UBOOT_FILENAME} ${INSTALL_LINUX_FILENAME} ${INSTALL_R fi; done if test "${install_abort}" = "1"; then + echo "To install a different image, set variable 'image-name', e.g.:" + echo " => setenv image-name core-image-base" echo "Aborted."; exit; fi diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt index fb8232879..65be2bf99 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt @@ -2,29 +2,39 @@ # U-Boot bootscript for NAND images created by Yocto. # -# As the first step in the boot script, check if we are using DualBoot and -# if an upgrade is available. This requires the script to change some variables -# and save them, while the rest of the script changes variables only temporarily -# without saving them. +# As the first step in the boot script, check if we are using DualBoot. This +# requires the script to change some variables and save them, while the rest +# of the script changes variables only temporarily without saving them. -# Dual boot update verification +# Dual boot verification if test "${dualboot}" = "yes"; then - if test "${upgrade_available}" = "1"; then - echo "Update detected; Booting new system in ${active_system} (try ${bootcount})" + if test "${active_system}" = "linux_a"; then + echo "Booting from system A (try ${bootcount})" + setenv tmp_mtdrootfspart ${rootfsvol_a} + setenv tmp_rootfsvol ${rootfsvol_a} else - if test "${active_system}" = "linux_a"; then - echo "Booting from system A" - setenv mtdbootpart ${active_system} - setenv mtdrootfspart ${rootfsvol_a} - setenv rootfsvol ${rootfsvol_a} - else - echo "Booting from system B" - setenv mtdbootpart ${active_system} - setenv mtdrootfspart ${rootfsvol_b} - setenv rootfsvol ${rootfsvol_b} - fi + echo "Booting from system B (try ${bootcount})" + setenv tmp_mtdrootfspart ${rootfsvol_b} + setenv tmp_rootfsvol ${rootfsvol_b} + fi + if test "${mtdbootpart}" != "${active_system}"; then + setenv mtdbootpart ${active_system} + env_save_needed="1" + fi + if test "${mtdrootfspart}" != "${tmp_mtdrootfspart}"; then + setenv mtdrootfspart ${tmp_mtdrootfspart} + env_save_needed="1" + fi + if test "${rootfsvol}" != "${tmp_rootfsvol}"; then + setenv rootfsvol ${tmp_rootfsvol} + env_save_needed="1" + fi + if test "${env_save_needed}" = "1"; then + env delete tmp_rootfsvol tmp_mtdrootfspart + env save fi else + echo "Booting system (try ${bootcount})" if test "${mtdbootpart}" = "recovery"; then setenv boot_initrd true setenv initrd_file uramdisk-recovery.img diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt index dcb054d4b..6a9926838 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt @@ -2,29 +2,39 @@ # U-Boot bootscript for NAND images created by Yocto. # -# As the first step in the boot script, check if we are using DualBoot and -# if an upgrade is available. This requires the script to change some variables -# and save them, while the rest of the script changes variables only temporarily -# without saving them. +# As the first step in the boot script, check if we are using DualBoot. This +# requires the script to change some variables and save them, while the rest +# of the script changes variables only temporarily without saving them. -# Dual boot update verification +# Dual boot verification if test "${dualboot}" = "yes"; then - if test "${upgrade_available}" = "1"; then - echo "Update detected; Booting new system in ${active_system} (try ${bootcount})" + if test "${active_system}" = "linux_a"; then + echo "Booting from system A (try ${bootcount})" + setenv tmp_mtdrootfspart ${rootfsvol_a} + setenv tmp_rootfsvol ${rootfsvol_a} else - if test "${active_system}" = "linux_a"; then - echo "Booting from system A" - setenv mtdbootpart ${active_system} - setenv mtdrootfspart ${rootfsvol_a} - setenv rootfsvol ${rootfsvol_a} - else - echo "Booting from system B" - setenv mtdbootpart ${active_system} - setenv mtdrootfspart ${rootfsvol_b} - setenv rootfsvol ${rootfsvol_b} - fi + echo "Booting from system B (try ${bootcount})" + setenv tmp_mtdrootfspart ${rootfsvol_b} + setenv tmp_rootfsvol ${rootfsvol_b} + fi + if test "${mtdbootpart}" != "${active_system}"; then + setenv mtdbootpart ${active_system} + env_save_needed="1" + fi + if test "${mtdrootfspart}" != "${tmp_mtdrootfspart}"; then + setenv mtdrootfspart ${tmp_mtdrootfspart} + env_save_needed="1" + fi + if test "${rootfsvol}" != "${tmp_rootfsvol}"; then + setenv rootfsvol ${tmp_rootfsvol} + env_save_needed="1" + fi + if test "${env_save_needed}" = "1"; then + env delete tmp_rootfsvol tmp_mtdrootfspart + env save fi else + echo "Booting system (try ${bootcount})" if test "${mtdbootpart}" = "recovery"; then setenv boot_initrd true setenv initrd_file uramdisk-recovery.img diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/altboot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/altboot.txt deleted file mode 100644 index 29172875b..000000000 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/altboot.txt +++ /dev/null @@ -1,37 +0,0 @@ -# -# U-Boot bootscript for altbootcmd (dual boot fallback after retries) -# - -# After an upgrade, active_system has changed. U-Boot tries to boot this system -# for a number of tries. If the limit is reached, altbootcmd is run instead. -# This is the script that it will run. It has to: -# * switch back to previous system -# * reset the firmware update flag -# * run the regular boot command - -if test "${dualboot}" = "yes" && test "${upgrade_available}" = "1"; then - echo "## Update failed; Rolling back to previous version." - if test "${active_system}" = "linux_a"; then - setenv active_system linux_b - part number mmc ${mmcbootdev} linux_b linux_b_index - setexpr mmcpart ${linux_b_index} - # Save the partition index on variable rootfs_b_index - part number mmc ${mmcbootdev} rootfs_b rootfs_b_index - # Save the rootfs_b UUID into mmcroot_b - part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b - setenv mmcroot PARTUUID=${mmcroot_b} - else - setenv active_system linux_a - part number mmc ${mmcbootdev} linux_a linux_a_index - setexpr mmcpart ${linux_a_index} - # Save the partition index on variable rootfs_a_index - part number mmc ${mmcbootdev} rootfs_a rootfs_a_index - # Save the rootfs_a UUID into mmcroot_a - part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a - setenv mmcroot PARTUUID=${mmcroot_a} - fi - setenv upgrade_available - setenv bootcount 0 - saveenv -fi -run bootcmd diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_sd.txt index 3a50597f0..9108f1f2b 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_sd.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_sd.txt @@ -34,6 +34,8 @@ for install_f in ${INSTALL_UBOOT_FILENAME} ${INSTALL_LINUX_FILENAME} ${INSTALL_R fi; done if test "${install_abort}" = "1"; then + echo "To install a different image, set variable 'image-name', e.g.:" + echo " => setenv image-name core-image-base" echo "Aborted."; exit; fi diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_usb.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_usb.txt index e916de50e..fad077216 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_usb.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_usb.txt @@ -34,6 +34,8 @@ for install_f in ${INSTALL_UBOOT_FILENAME} ${INSTALL_LINUX_FILENAME} ${INSTALL_R fi; done if test "${install_abort}" = "1"; then + echo "To install a different image, set variable 'image-name', e.g.:" + echo " => setenv image-name core-image-base" echo "Aborted."; exit; fi diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt index e7d3c933c..c42e51422 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt @@ -2,37 +2,36 @@ # U-Boot bootscript for EMMC/SD images created by Yocto. # -# As the first step in the boot script, check if we are using DualBoot and -# if an upgrade is available. This requires the script to change some variables -# and save them, while the rest of the script changes variables only temporarily -# without saving them. +# As the first step in the boot script, check if we are using DualBoot. This +# requires the script to change some variables and save them, while the rest +# of the script changes variables only temporarily without saving them. -# Dual boot update verification +# Dual boot verification if test "${dualboot}" = "yes"; then - if test "${upgrade_available}" = "1"; then - echo "Update detected; Booting new system in ${active_system} (try ${bootcount})" + if test "${active_system}" = "linux_a"; then + echo "Booting from system A (try ${bootcount})" + part number mmc ${mmcbootdev} linux_a tmp_mmcpart + part number mmc ${mmcbootdev} rootfs_a tmp_rootfs_index else - if test "${active_system}" = "linux_a"; then - echo "Booting from system A" - part number mmc ${mmcbootdev} linux_a pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_a_index - part number mmc ${mmcbootdev} rootfs_a rootfs_a_index - # Save the rootfs_a UUID into mmcroot_a - part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a - setenv mmcroot PARTUUID=${mmcroot_a} - else - echo "Booting from system B" - part number mmc ${mmcbootdev} linux_b pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_b_index - part number mmc ${mmcbootdev} rootfs_b rootfs_b_index - # Save the rootfs_b UUID into mmcroot_b - part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b - setenv mmcroot PARTUUID=${mmcroot_b} - fi + echo "Booting from system B (try ${bootcount})" + part number mmc ${mmcbootdev} linux_b tmp_mmcpart + part number mmc ${mmcbootdev} rootfs_b tmp_rootfs_index + fi + part uuid mmc ${mmcbootdev}:${tmp_rootfs_index} tmp_mmcroot + if test "${mmcpart}" -ne "${tmp_mmcpart}"; then + setexpr mmcpart ${tmp_mmcpart} + env_save_needed="1" + fi + if test "${mmcroot}" != "PARTUUID=${tmp_mmcroot}"; then + setenv mmcroot PARTUUID=${tmp_mmcroot} + env_save_needed="1" + fi + if test "${env_save_needed}" = "1"; then + env delete tmp_mmcpart tmp_rootfs_index tmp_mmcroot + env save fi else + echo "Booting system (try ${bootcount})" # Get the UUID of the configured boot partition. part uuid mmc ${mmcbootdev}:${mmcpart} bootpart # Check the boot source. diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt index 3b7011212..62fbaf495 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt @@ -2,37 +2,36 @@ # U-Boot bootscript for EMMC/SD images created by Yocto. # -# As the first step in the boot script, check if we are using DualBoot and -# if an upgrade is available. This requires the script to change some variables -# and save them, while the rest of the script changes variables only temporarily -# without saving them. +# As the first step in the boot script, check if we are using DualBoot. This +# requires the script to change some variables and save them, while the rest +# of the script changes variables only temporarily without saving them. -# Dual boot update verification +# Dual boot verification if test "${dualboot}" = "yes"; then - if test "${upgrade_available}" = "1"; then - echo "Update detected; Booting new system in ${active_system} (try ${bootcount})" + if test "${active_system}" = "linux_a"; then + echo "Booting from system A (try ${bootcount})" + part number mmc ${mmcbootdev} linux_a tmp_mmcpart + part number mmc ${mmcbootdev} rootfs_a tmp_rootfs_index else - if test "${active_system}" = "linux_a"; then - echo "Booting from system A" - part number mmc ${mmcbootdev} linux_a pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_a_index - part number mmc ${mmcbootdev} rootfs_a rootfs_a_index - # Save the rootfs_a UUID into mmcroot_a - part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a - setenv mmcroot PARTUUID=${mmcroot_a} - else - echo "Booting from system B" - part number mmc ${mmcbootdev} linux_b pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_b_index - part number mmc ${mmcbootdev} rootfs_b rootfs_b_index - # Save the rootfs_b UUID into mmcroot_b - part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b - setenv mmcroot PARTUUID=${mmcroot_b} - fi + echo "Booting from system B (try ${bootcount})" + part number mmc ${mmcbootdev} linux_b tmp_mmcpart + part number mmc ${mmcbootdev} rootfs_b tmp_rootfs_index + fi + part uuid mmc ${mmcbootdev}:${tmp_rootfs_index} tmp_mmcroot + if test "${mmcpart}" -ne "${tmp_mmcpart}"; then + setexpr mmcpart ${tmp_mmcpart} + env_save_needed="1" + fi + if test "${mmcroot}" != "PARTUUID=${tmp_mmcroot}"; then + setenv mmcroot PARTUUID=${tmp_mmcroot} + env_save_needed="1" + fi + if test "${env_save_needed}" = "1"; then + env delete tmp_mmcpart tmp_rootfs_index tmp_mmcroot + env save fi else + echo "Booting system (try ${bootcount})" # Get the UUID of the configured boot partition. part uuid mmc ${mmcbootdev}:${mmcpart} bootpart # Check the boot source. diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt index f05730df6..ba60afc40 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt @@ -2,37 +2,36 @@ # U-Boot bootscript for EMMC/SD images created by Yocto. # -# As the first step in the boot script, check if we are using DualBoot and -# if an upgrade is available. This requires the script to change some variables -# and save them, while the rest of the script changes variables only temporarily -# without saving them. +# As the first step in the boot script, check if we are using DualBoot. This +# requires the script to change some variables and save them, while the rest +# of the script changes variables only temporarily without saving them. -# Dual boot update verification +# Dual boot verification if test "${dualboot}" = "yes"; then - if test "${upgrade_available}" = "1"; then - echo "Update detected; Booting new system in ${active_system} (try ${bootcount})" + if test "${active_system}" = "linux_a"; then + echo "Booting from system A (try ${bootcount})" + part number mmc ${mmcbootdev} linux_a tmp_mmcpart + part number mmc ${mmcbootdev} rootfs_a tmp_rootfs_index else - if test "${active_system}" = "linux_a"; then - echo "Booting from system A" - part number mmc ${mmcbootdev} linux_a pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_a_index - part number mmc ${mmcbootdev} rootfs_a rootfs_a_index - # Save the rootfs_a UUID into mmcroot_a - part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a - setenv mmcroot PARTUUID=${mmcroot_a} - else - echo "Booting from system B" - part number mmc ${mmcbootdev} linux_b pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_b_index - part number mmc ${mmcbootdev} rootfs_b rootfs_b_index - # Save the rootfs_b UUID into mmcroot_b - part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b - setenv mmcroot PARTUUID=${mmcroot_b} - fi + echo "Booting from system B (try ${bootcount})" + part number mmc ${mmcbootdev} linux_b tmp_mmcpart + part number mmc ${mmcbootdev} rootfs_b tmp_rootfs_index + fi + part uuid mmc ${mmcbootdev}:${tmp_rootfs_index} tmp_mmcroot + if test "${mmcpart}" -ne "${tmp_mmcpart}"; then + setexpr mmcpart ${tmp_mmcpart} + env_save_needed="1" + fi + if test "${mmcroot}" != "PARTUUID=${tmp_mmcroot}"; then + setenv mmcroot PARTUUID=${tmp_mmcroot} + env_save_needed="1" + fi + if test "${env_save_needed}" = "1"; then + env delete tmp_mmcpart tmp_rootfs_index tmp_mmcroot + env save fi else + echo "Booting system (try ${bootcount})" # Get the UUID of the configured boot partition. part uuid mmc ${mmcbootdev}:${mmcpart} bootpart # Check the boot source. diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt index 86188c350..4ee3d440f 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt @@ -2,37 +2,36 @@ # U-Boot bootscript for EMMC/SD images created by Yocto. # -# As the first step in the boot script, check if we are using DualBoot and -# if an upgrade is available. This requires the script to change some variables -# and save them, while the rest of the script changes variables only temporarily -# without saving them. +# As the first step in the boot script, check if we are using DualBoot. This +# requires the script to change some variables and save them, while the rest +# of the script changes variables only temporarily without saving them. -# Dual boot update verification +# Dual boot verification if test "${dualboot}" = "yes"; then - if test "${upgrade_available}" = "1"; then - echo "Update detected; Booting new system in ${active_system} (try ${bootcount})" + if test "${active_system}" = "linux_a"; then + echo "Booting from system A (try ${bootcount})" + part number mmc ${mmcbootdev} linux_a tmp_mmcpart + part number mmc ${mmcbootdev} rootfs_a tmp_rootfs_index else - if test "${active_system}" = "linux_a"; then - echo "Booting from system A" - part number mmc ${mmcbootdev} linux_a pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_a_index - part number mmc ${mmcbootdev} rootfs_a rootfs_a_index - # Save the rootfs_a UUID into mmcroot_a - part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a - setenv mmcroot PARTUUID=${mmcroot_a} - else - echo "Booting from system B" - part number mmc ${mmcbootdev} linux_b pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_b_index - part number mmc ${mmcbootdev} rootfs_b rootfs_b_index - # Save the rootfs_b UUID into mmcroot_b - part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b - setenv mmcroot PARTUUID=${mmcroot_b} - fi + echo "Booting from system B (try ${bootcount})" + part number mmc ${mmcbootdev} linux_b tmp_mmcpart + part number mmc ${mmcbootdev} rootfs_b tmp_rootfs_index + fi + part uuid mmc ${mmcbootdev}:${tmp_rootfs_index} tmp_mmcroot + if test "${mmcpart}" -ne "${tmp_mmcpart}"; then + setexpr mmcpart ${tmp_mmcpart} + env_save_needed="1" + fi + if test "${mmcroot}" != "PARTUUID=${tmp_mmcroot}"; then + setenv mmcroot PARTUUID=${tmp_mmcroot} + env_save_needed="1" + fi + if test "${env_save_needed}" = "1"; then + env delete tmp_mmcpart tmp_rootfs_index tmp_mmcroot + env save fi else + echo "Booting system (try ${bootcount})" # Get the UUID of the configured boot partition. part uuid mmc ${mmcbootdev}:${mmcpart} bootpart # Check the boot source. diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/altboot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/altboot.txt deleted file mode 100644 index 29172875b..000000000 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/altboot.txt +++ /dev/null @@ -1,37 +0,0 @@ -# -# U-Boot bootscript for altbootcmd (dual boot fallback after retries) -# - -# After an upgrade, active_system has changed. U-Boot tries to boot this system -# for a number of tries. If the limit is reached, altbootcmd is run instead. -# This is the script that it will run. It has to: -# * switch back to previous system -# * reset the firmware update flag -# * run the regular boot command - -if test "${dualboot}" = "yes" && test "${upgrade_available}" = "1"; then - echo "## Update failed; Rolling back to previous version." - if test "${active_system}" = "linux_a"; then - setenv active_system linux_b - part number mmc ${mmcbootdev} linux_b linux_b_index - setexpr mmcpart ${linux_b_index} - # Save the partition index on variable rootfs_b_index - part number mmc ${mmcbootdev} rootfs_b rootfs_b_index - # Save the rootfs_b UUID into mmcroot_b - part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b - setenv mmcroot PARTUUID=${mmcroot_b} - else - setenv active_system linux_a - part number mmc ${mmcbootdev} linux_a linux_a_index - setexpr mmcpart ${linux_a_index} - # Save the partition index on variable rootfs_a_index - part number mmc ${mmcbootdev} rootfs_a rootfs_a_index - # Save the rootfs_a UUID into mmcroot_a - part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a - setenv mmcroot PARTUUID=${mmcroot_a} - fi - setenv upgrade_available - setenv bootcount 0 - saveenv -fi -run bootcmd diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_sd.txt index d405e4ebb..300ef49d2 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_sd.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_sd.txt @@ -18,66 +18,7 @@ fi # the necessary logic to choose the correct imx-boot file for the target's SOC. setenv skip-uboot-check "yes" -# Determine U-Boot file to program basing on SOM's RAM size and SOC type (linked to bus width) -bus_width="32bit" -if test -n "${module_ram}" && test -n "${soc_type}"; then - if test "${soc_type}" = "imx8dx"; then - bus_width="16bit" - fi - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-${module_ram}_${bus_width}.bin; -else - # Determine U-Boot file to program basing on SOM's variant - if test -n "${module_variant}"; then - if test "${module_variant}" = "0x01"; then - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-1GB_32bit.bin; - elif test "${module_variant}" = "0x02"; then - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-2GB_32bit.bin; - elif test "${module_variant}" = "0x03"; then - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-2GB_32bit.bin; - elif test "${module_variant}" = "0x04"; then - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-1GB_16bit.bin; - elif test "${module_variant}" = "0x05"; then - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-1GB_16bit.bin; - elif test "${module_variant}" = "0x06"; then - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-512MB_16bit.bin; - elif test "${module_variant}" = "0x07"; then - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-1GB_32bit.bin; - elif test "${module_variant}" = "0x08"; then - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-1GB_32bit.bin; - elif test "${module_variant}" = "0x09"; then - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-512MB_16bit.bin; - elif test "${module_variant}" = "0x0A"; then - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-1GB_16bit.bin; - elif test "${module_variant}" = "0x0B"; then - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-1GB_16bit.bin; - fi - fi -fi - -# Use 'test -n ...' because 'test -z ...' does not work well on old versions of -# u-boot when the checked value is empty. -if test -n "${INSTALL_UBOOT_FILENAME}"; then - true; -else - echo ""; - echo "[ERROR] Cannot determine U-Boot file for this module!"; - echo ""; - echo "1. Set variable 'INSTALL_UBOOT_FILENAME' depending on your ConnectCore 8X variant:"; - echo " - For a QuadXPlus CPU with 1GB LPDDR4, run:"; - echo " => setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-1GB_32bit.bin"; - echo " - For a QuadXPlus CPU with 2GB LPDDR4, run:"; - echo " => setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-2GB_32bit.bin"; - echo " - For a DualX CPU with 1GB LPDDR4, run:"; - echo " => setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-1GB_16bit.bin"; - echo " - For a DualX CPU with 512MB LPDDR4, run:"; - echo " => setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-512MB_16bit.bin"; - echo ""; - echo "2. Run the install script again."; - echo ""; - echo "Aborted"; - echo ""; - exit; -fi; +setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}.bin; setenv INSTALL_MMCDEV 1 @@ -105,6 +46,8 @@ for install_f in ${INSTALL_UBOOT_FILENAME} ${INSTALL_LINUX_FILENAME} ${INSTALL_R fi; done if test "${install_abort}" = "1"; then + echo "To install a different image, set variable 'image-name', e.g.:" + echo " => setenv image-name core-image-base" echo "Aborted."; exit; fi diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_usb.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_usb.txt index f3688b958..32c3eaf99 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_usb.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_usb.txt @@ -18,66 +18,7 @@ fi # the necessary logic to choose the correct imx-boot file for the target's SOC. setenv skip-uboot-check "yes" -# Determine U-Boot file to program basing on SOM's RAM size and SOC type (linked to bus width) -bus_width="32bit" -if test -n "${module_ram}" && test -n "${soc_type}"; then - if test "${soc_type}" = "imx8dx"; then - bus_width="16bit" - fi - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-${module_ram}_${bus_width}.bin; -else - # Determine U-Boot file to program basing on SOM's variant - if test -n "${module_variant}"; then - if test "${module_variant}" = "0x01"; then - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-1GB_32bit.bin; - elif test "${module_variant}" = "0x02"; then - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-2GB_32bit.bin; - elif test "${module_variant}" = "0x03"; then - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-2GB_32bit.bin; - elif test "${module_variant}" = "0x04"; then - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-1GB_16bit.bin; - elif test "${module_variant}" = "0x05"; then - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-1GB_16bit.bin; - elif test "${module_variant}" = "0x06"; then - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-512MB_16bit.bin; - elif test "${module_variant}" = "0x07"; then - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-1GB_32bit.bin; - elif test "${module_variant}" = "0x08"; then - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-1GB_32bit.bin; - elif test "${module_variant}" = "0x09"; then - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-512MB_16bit.bin; - elif test "${module_variant}" = "0x0A"; then - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-1GB_16bit.bin; - elif test "${module_variant}" = "0x0B"; then - setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-1GB_16bit.bin; - fi - fi -fi - -# Use 'test -n ...' because 'test -z ...' does not work well on old versions of -# u-boot when the checked value is empty. -if test -n "${INSTALL_UBOOT_FILENAME}"; then - true; -else - echo ""; - echo "[ERROR] Cannot determine U-Boot file for this module!"; - echo ""; - echo "1. Set variable 'INSTALL_UBOOT_FILENAME' depending on your ConnectCore 8X variant:"; - echo " - For a QuadXPlus CPU with 1GB LPDDR4, run:"; - echo " => setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-1GB_32bit.bin"; - echo " - For a QuadXPlus CPU with 2GB LPDDR4, run:"; - echo " => setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-2GB_32bit.bin"; - echo " - For a DualX CPU with 1GB LPDDR4, run:"; - echo " => setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-1GB_16bit.bin"; - echo " - For a DualX CPU with 512MB LPDDR4, run:"; - echo " => setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}-512MB_16bit.bin"; - echo ""; - echo "2. Run the install script again."; - echo ""; - echo "Aborted"; - echo ""; - exit; -fi; +setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##-${soc_rev}.bin; setenv INSTALL_USBDEV 0 @@ -105,6 +46,8 @@ for install_f in ${INSTALL_UBOOT_FILENAME} ${INSTALL_LINUX_FILENAME} ${INSTALL_R fi; done if test "${install_abort}" = "1"; then + echo "To install a different image, set variable 'image-name', e.g.:" + echo " => setenv image-name core-image-base" echo "Aborted."; exit; fi diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh index ddfb41624..de02952cf 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh @@ -93,7 +93,7 @@ fi echo "" echo "Determining image files to use..." -# Determine U-Boot file to program basing on SOM's SOC type (linked to bus width) +# Determine U-Boot file to program basing on SOM's SOC revision if [ -z ${INSTALL_UBOOT_FILENAME} ]; then # Since SOMs with the B0 SOC might have an older U-Boot that doesn't export the # SOC revision to the environment, use B0 by default @@ -102,59 +102,7 @@ if [ -z ${INSTALL_UBOOT_FILENAME} ]; then soc_rev="B0" fi - bus_width="32bit" - soc_type=$(getenv "soc_type") - if [ "$soc_type" = "imx8dx" ]; then - bus_width="16bit" - fi - - module_ram=$(getenv "module_ram") - if [ -z "${module_ram}" ]; then - module_variant=$(getenv "module_variant") - # Determine U-Boot file to program basing on SOM's variant - if [ -n "$module_variant" ] || [ "$module_variant" = "0x00" ]; then - if [ "$module_variant" = "0x01" ] || \ - [ "$module_variant" = "0x04" ] || \ - [ "$module_variant" = "0x05" ]; then - module_ram="1GB" - elif [ "$module_variant" = "0x06" ] || \ - [ "$module_variant" = "0x09" ]; then - module_ram="512MB" - else - module_ram="2GB" - fi - INSTALL_UBOOT_FILENAME="imx-boot-##MACHINE##-${soc_rev}-${module_ram}_${bus_width}.bin" - fi - else - INSTALL_UBOOT_FILENAME="imx-boot-##MACHINE##-${soc_rev}-${module_ram}_${bus_width}.bin" - fi - - # U-Boot when the checked value is empty. - if [ -n "${INSTALL_UBOOT_FILENAME}" ]; then - true - else - # remove redirect - uuu fb: ucmd setenv stdout serial - - echo "" - echo "[ERROR] Cannot determine U-Boot file for this module!" - echo "" - echo "1. Add U-boot file name, depending on your ConnectCore 8X variant, to script command line:" - echo " - For a QuadXPlus CPU with 1GB LPDDR4, run:" - echo " => ./install_linux_fw_uuu.sh -u imx-boot-##MACHINE##-${soc_rev}-1GB_32bit.bin" - echo " - For a QuadXPlus CPU with 2GB LPDDR4, run:" - echo " => ./install_linux_fw_uuu.sh -u imx-boot-##MACHINE##-${soc_rev}-2GB_32bit.bin" - echo " - For a DualX CPU with 1GB LPDDR4, run:" - echo " => ./install_linux_fw_uuu.sh -u imx-boot-##MACHINE##-${soc_rev}-1GB_16bit.bin" - echo " - For a DualX CPU with 512MB LPDDR4, run:" - echo " => ./install_linux_fw_uuu.sh -u imx-boot-##MACHINE##-${soc_rev}-512MB_16bit.bin" - echo "" - echo "2. Run the install script again." - echo "" - echo "Aborted" - echo "" - exit - fi + INSTALL_UBOOT_FILENAME="imx-boot-##MACHINE##-${soc_rev}.bin" fi # remove redirect diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx93-dvk/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx93-dvk/boot.txt index 04aa40eba..9b169085c 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx93-dvk/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx93-dvk/boot.txt @@ -2,37 +2,39 @@ # U-Boot bootscript for EMMC/SD images created by Yocto. # -# As the first step in the boot script, check if we are using DualBoot and -# if an upgrade is available. This requires the script to change some variables -# and save them, while the rest of the script changes variables only temporarily -# without saving them. +# As the first step in the boot script, check if we are using DualBoot. This +# requires the script to change some variables and save them, while the rest +# of the script changes variables only temporarily without saving them. -# Dual boot update verification -if test "${dualboot}" = "yes"; then - if test "${upgrade_available}" = "1"; then - echo "Update detected; Booting new system in ${active_system} (try ${bootcount})" +# Pre step: check if we boot from uSD. +if test "${mmcbootdev}" = "1"; then + # We are booting from the SD card. + setenv mmcroot /dev/mmcblk${mmcbootdev}p2 +elif test "${dualboot}" = "yes"; then + if test "${active_system}" = "linux_a"; then + echo "Booting from system A (try ${bootcount})" + part number mmc ${mmcbootdev} linux_a tmp_mmcpart + part number mmc ${mmcbootdev} rootfs_a tmp_rootfs_index else - if test "${active_system}" = "linux_a"; then - echo "Booting from system A" - part number mmc ${mmcbootdev} linux_a pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_a_index - part number mmc ${mmcbootdev} rootfs_a rootfs_a_index - # Save the rootfs_a UUID into mmcroot_a - part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a - setenv mmcroot PARTUUID=${mmcroot_a} - else - echo "Booting from system B" - part number mmc ${mmcbootdev} linux_b pi - setenv mmcpart ${pi} - # Save the partition index on variable rootfs_b_index - part number mmc ${mmcbootdev} rootfs_b rootfs_b_index - # Save the rootfs_b UUID into mmcroot_b - part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b - setenv mmcroot PARTUUID=${mmcroot_b} - fi + echo "Booting from system B (try ${bootcount})" + part number mmc ${mmcbootdev} linux_b tmp_mmcpart + part number mmc ${mmcbootdev} rootfs_b tmp_rootfs_index + fi + part uuid mmc ${mmcbootdev}:${tmp_rootfs_index} tmp_mmcroot + if test "${mmcpart}" -ne "${tmp_mmcpart}"; then + setexpr mmcpart ${tmp_mmcpart} + env_save_needed="1" + fi + if test "${mmcroot}" != "PARTUUID=${tmp_mmcroot}"; then + setenv mmcroot PARTUUID=${tmp_mmcroot} + env_save_needed="1" + fi + if test "${env_save_needed}" = "1"; then + env delete tmp_mmcpart tmp_rootfs_index tmp_mmcroot + env save fi else + echo "Booting system (try ${bootcount})" # Get the UUID of the configured boot partition. part uuid mmc ${mmcbootdev}:${mmcpart} bootpart # Check the boot source. @@ -43,9 +45,6 @@ else # We are booting from the eMMC using 'recovery'. setenv boot_initrd true setenv initrd_file uramdisk-recovery.img - else - # We are booting from the SD card. - setenv mmcroot /dev/mmcblk${mmcbootdev}p2 fi fi @@ -75,6 +74,17 @@ if test "${module_has_mca}" = "1" && test -z "${disable_mca}"; then setenv overlays _ov_som_mca_ccimx93.dtbo,${overlays} fi +if test "${cpu_type}" = "imx9352" || \ + test "${cpu_type}" = "imx9351" || \ + test "${cpu_type}" = "imx9322" || \ + test "${cpu_type}" = "imx9321"; then + module_has_npu="1" +fi + +if test "${module_has_npu}" = "1" && test -z "${disable_npu}"; then + setenv overlays _ov_som_npu_ccimx93.dtbo,${overlays} +fi + dboot linux mmc ${mmcbootdev}:${mmcpart} # diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx93/altboot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx93/altboot.txt deleted file mode 100644 index 29172875b..000000000 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx93/altboot.txt +++ /dev/null @@ -1,37 +0,0 @@ -# -# U-Boot bootscript for altbootcmd (dual boot fallback after retries) -# - -# After an upgrade, active_system has changed. U-Boot tries to boot this system -# for a number of tries. If the limit is reached, altbootcmd is run instead. -# This is the script that it will run. It has to: -# * switch back to previous system -# * reset the firmware update flag -# * run the regular boot command - -if test "${dualboot}" = "yes" && test "${upgrade_available}" = "1"; then - echo "## Update failed; Rolling back to previous version." - if test "${active_system}" = "linux_a"; then - setenv active_system linux_b - part number mmc ${mmcbootdev} linux_b linux_b_index - setexpr mmcpart ${linux_b_index} - # Save the partition index on variable rootfs_b_index - part number mmc ${mmcbootdev} rootfs_b rootfs_b_index - # Save the rootfs_b UUID into mmcroot_b - part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b - setenv mmcroot PARTUUID=${mmcroot_b} - else - setenv active_system linux_a - part number mmc ${mmcbootdev} linux_a linux_a_index - setexpr mmcpart ${linux_a_index} - # Save the partition index on variable rootfs_a_index - part number mmc ${mmcbootdev} rootfs_a rootfs_a_index - # Save the rootfs_a UUID into mmcroot_a - part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a - setenv mmcroot PARTUUID=${mmcroot_a} - fi - setenv upgrade_available - setenv bootcount 0 - saveenv -fi -run bootcmd diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/altboot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/altboot.txt deleted file mode 100644 index 8bd41ca3d..000000000 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/altboot.txt +++ /dev/null @@ -1,27 +0,0 @@ -# -# U-Boot bootscript for altbootcmd (dual boot fallback after retries) -# - -# After an upgrade, active_system has changed. U-Boot tries to boot this system -# for a number of tries. If the limit is reached, altbootcmd is run instead. -# This is the script that it will run. It has to: -# * switch back to previous system -# * reset the firmware update flag -# * run the regular boot command - -if test "${dualboot}" = "yes" && test "${upgrade_available}" = "1"; then - echo "## Update failed; Rolling back to previous version." - if test "${active_system}" = "linux_a"; then - setenv active_system linux_b - setenv mtdbootpart ${active_system} - setenv rootfsvol ${rootfsvol_b} - else - setenv active_system linux_a - setenv mtdbootpart ${active_system} - setenv rootfsvol ${rootfsvol_a} - fi - setenv upgrade_available - setenv bootcount 0 - saveenv -fi -run bootcmd diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_sd.txt index cdfa0d917..6d36154d7 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_sd.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_sd.txt @@ -35,6 +35,8 @@ for install_f in ${INSTALL_ATF_FILENAME} ${INSTALL_FIP_FILENAME} ${INSTALL_LINUX fi; done if test "${install_abort}" = "1"; then + echo "To install a different image, set variable 'image-name', e.g.:" + echo " => setenv image-name core-image-base" echo "Aborted."; exit; fi @@ -251,8 +253,10 @@ setenv bootcmd " echo \"\"; echo \"\"; sleep 1; + bootcount reset; reset; " +bootcount reset saveenv reset diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_usb.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_usb.txt index 6a0fa9968..3d161c03f 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_usb.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_usb.txt @@ -35,6 +35,8 @@ for install_f in ${INSTALL_ATF_FILENAME} ${INSTALL_FIP_FILENAME} ${INSTALL_RECOV fi; done if test "${install_abort}" = "1"; then + echo "To install a different image, set variable 'image-name', e.g.:" + echo " => setenv image-name core-image-base" echo "Aborted."; exit; fi @@ -252,8 +254,10 @@ setenv bootcmd " echo \"\"; echo \"\"; sleep 1; + bootcount reset; reset; " +bootcount reset saveenv reset diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_uuu.sh index def428e67..aaa5555b3 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_uuu.sh @@ -221,12 +221,14 @@ fi # Set 'bootcmd' for the second part of the script that will # - Reset environment to defaults # - Keep the 'dualboot' status +# - Reset the bootcount # - Save the environment # - Update the 'linux' partition(s) # - Update the 'rootfs' partition(s) uuu fb: ucmd setenv bootcmd " env default -a; setenv dualboot \${dualboot}; + bootcount reset; saveenv; saveenv; echo \"\"; @@ -277,6 +279,7 @@ else fi # Reset the target +uuu fb: ucmd bootcount reset uuu fb: acmd reset echo "\033[32m" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp13-dvk/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp13-dvk/boot.txt index 3f72cee46..94fed3c6d 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp13-dvk/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp13-dvk/boot.txt @@ -2,27 +2,33 @@ # U-Boot bootscript for NAND/SD images created by Yocto. # -# As the first step in the boot script, check if we are using DualBoot and -# if an upgrade is available. This requires the script to change some variables -# and save them, while the rest of the script changes variables only temporarily -# without saving them. +# As the first step in the boot script, check if we are using DualBoot. This +# requires the script to change some variables and save them, while the rest +# of the script changes variables only temporarily without saving them. -# Dual boot update verification +# Dual boot verification if test "${dualboot}" = "yes"; then - if test "${upgrade_available}" = "1"; then - echo "Update detected; Booting new system in ${active_system} (try ${bootcount})" + if test "${active_system}" = "linux_a"; then + echo "Booting from system A (try ${bootcount})" + setenv tmp_rootfsvol ${rootfsvol_a} else - if test "${active_system}" = "linux_a"; then - echo "Booting from system A" - setenv mtdbootpart ${active_system} - setenv rootfsvol ${rootfsvol_a} - else - echo "Booting from system B" - setenv mtdbootpart ${active_system} - setenv rootfsvol ${rootfsvol_b} - fi + echo "Booting from system B (try ${bootcount})" + setenv tmp_rootfsvol ${rootfsvol_b} + fi + if test "${mtdbootpart}" != "${active_system}"; then + setenv mtdbootpart ${active_system} + env_save_needed="1" + fi + if test "${rootfsvol}" != "${tmp_rootfsvol}"; then + setenv rootfsvol ${tmp_rootfsvol} + env_save_needed="1" + fi + if test "${env_save_needed}" = "1"; then + env delete tmp_rootfsvol + env save fi else + echo "Booting system (try ${bootcount})" # Check the boot source. if test "${mtdbootpart}" = "linux"; then # We are booting from the NAND using 'linux'. diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp15-dvk/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp15-dvk/boot.txt index 9cf317362..632feb7aa 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp15-dvk/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp15-dvk/boot.txt @@ -2,27 +2,33 @@ # U-Boot bootscript for NAND/SD images created by Yocto. # -# As the first step in the boot script, check if we are using DualBoot and -# if an upgrade is available. This requires the script to change some variables -# and save them, while the rest of the script changes variables only temporarily -# without saving them. +# As the first step in the boot script, check if we are using DualBoot. This +# requires the script to change some variables and save them, while the rest +# of the script changes variables only temporarily without saving them. -# Dual boot update verification +# Dual boot verification if test "${dualboot}" = "yes"; then - if test "${upgrade_available}" = "1"; then - echo "Update detected; Booting new system in ${active_system} (try ${bootcount})" + if test "${active_system}" = "linux_a"; then + echo "Booting from system A (try ${bootcount})" + setenv tmp_rootfsvol ${rootfsvol_a} else - if test "${active_system}" = "linux_a"; then - echo "Booting from system A" - setenv mtdbootpart ${active_system} - setenv rootfsvol ${rootfsvol_a} - else - echo "Booting from system B" - setenv mtdbootpart ${active_system} - setenv rootfsvol ${rootfsvol_b} - fi + echo "Booting from system B (try ${bootcount})" + setenv tmp_rootfsvol ${rootfsvol_b} + fi + if test "${mtdbootpart}" != "${active_system}"; then + setenv mtdbootpart ${active_system} + env_save_needed="1" + fi + if test "${rootfsvol}" != "${tmp_rootfsvol}"; then + setenv rootfsvol ${tmp_rootfsvol} + env_save_needed="1" + fi + if test "${env_save_needed}" = "1"; then + env delete tmp_rootfsvol + env save fi else + echo "Booting system (try ${bootcount})" # Check the boot source. if test "${mtdbootpart}" = "linux"; then # We are booting from the NAND using 'linux'. @@ -45,6 +51,8 @@ setenv ORIG_overlays ${overlays} # Determine overlays to apply depending on the hardware capabilities # described by the HWID, SOM version, and carrier board version. # +setexpr module_has_mca ${hwid_2} \& 10000 +setexpr module_has_mca ${module_has_mca} / 10000 setexpr module_has_wifi ${hwid_2} \& 20000 setexpr module_has_wifi ${module_has_wifi} / 20000 setexpr module_has_bt ${hwid_2} \& 40000 @@ -58,6 +66,10 @@ if test "${module_has_wifi}" = "1" && test -z "${disable_wifi}"; then setenv overlays _ov_som_wifi_ccmp15.dtbo,${overlays} fi +if test "${module_has_mca}" = "1" && test -z "${disable_mca}"; then + setenv overlays _ov_som_mca_ccmp15.dtbo,${overlays} +fi + # Apply DVKv1 overlay if the board_version is 1 if test -z "${board_version}" || test "${board_version}" -eq "1"; then setenv overlays _ov_board_v1_ccmp15-dvk.dtbo,${overlays} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey_2022.04.bb b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey_2022.04.bb deleted file mode 100644 index 2ac814261..000000000 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey_2022.04.bb +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (C) 2022 Digi International - -require u-boot-dey.inc -LIC_FILES_CHKSUM = "file://Licenses/README;md5=5a7450c57ffe5ae63fd732446b988025" - -DEPENDS += "flex-native bison-native" - -SRCBRANCH = "v2022.04/maint" -SRCREV = "${AUTOREV}" - -COMPATIBLE_MACHINE = "(ccimx93)" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey_2023.04.bb b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey_2023.04.bb new file mode 100644 index 000000000..c8cb7dee1 --- /dev/null +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey_2023.04.bb @@ -0,0 +1,11 @@ +# Copyright 2023 Digi International Inc. + +require u-boot-dey.inc +LIC_FILES_CHKSUM = "file://Licenses/README;md5=2ca5f2c35c8cc335f0a19756634782f1" + +DEPENDS += "flex-native bison-native" + +SRCBRANCH = "v2023.04/master" +SRCREV = "${AUTOREV}" + +COMPATIBLE_MACHINE = "(ccimx93)" diff --git a/meta-digi-arm/recipes-connectivity/nxp-wlan-sdk/nxp-wlan-sdk_git.inc b/meta-digi-arm/recipes-connectivity/nxp-wlan-sdk/nxp-wlan-sdk_git.inc index 0e92104db..882507e4b 100644 --- a/meta-digi-arm/recipes-connectivity/nxp-wlan-sdk/nxp-wlan-sdk_git.inc +++ b/meta-digi-arm/recipes-connectivity/nxp-wlan-sdk/nxp-wlan-sdk_git.inc @@ -3,10 +3,10 @@ LICENSE = "GPL-2.0-only" LIC_FILES_CHKSUM = "file://${WORKDIR}/git/LICENSE;md5=ab04ac0f249af12befccb94447c08b77" # For Kernel 5.4 and later -SRCBRANCH = "lf-6.1.1_1.0.0" +SRCBRANCH = "lf-6.1.22_2.0.0" MRVL_SRC ?= "git://github.com/nxp-imx/mwifiex.git;protocol=https" SRC_URI = "${MRVL_SRC};branch=${SRCBRANCH}" -SRCREV = "98e5b28b1a7afea9dbded4067e93bfd584531a79" +SRCREV = "f1382ccbd34fc22daf504e798745f6cddb702b82" S = "${WORKDIR}/git/mxm_wifiex/wlan_src" diff --git a/meta-digi-arm/recipes-core/udev/udev-extraconf/00-disable-sd.rules b/meta-digi-arm/recipes-core/udev/udev-extraconf/00-disable-sd.rules deleted file mode 100644 index 4096f815a..000000000 --- a/meta-digi-arm/recipes-core/udev/udev-extraconf/00-disable-sd.rules +++ /dev/null @@ -1,2 +0,0 @@ -# Disable all SD devices -SUBSYSTEMS=="mmc", ATTRS{type}=="SD", RUN:="/bin/true" diff --git a/meta-digi-arm/recipes-core/udev/udev-extraconf/automount.rules b/meta-digi-arm/recipes-core/udev/udev-extraconf/automount.rules index 84bec7099..df3fb866a 100644 --- a/meta-digi-arm/recipes-core/udev/udev-extraconf/automount.rules +++ b/meta-digi-arm/recipes-core/udev/udev-extraconf/automount.rules @@ -16,7 +16,7 @@ # Digi-mounted partitions: linux, update, data SUBSYSTEM=="block", ENV{ID_PART_ENTRY_NAME}=="linux*|update*|data*", ACTION=="add", RUN+="/etc/udev/scripts/mount_digiparts.sh", GOTO="automount_rules_end" SUBSYSTEM=="mtd", ATTRS{name}=="linux*|update*|data*", ACTION=="add", RUN+="/etc/udev/scripts/mount_digiparts.sh", GOTO="automount_rules_end" -SUBSYSTEM=="ubi", KERNEL=="ubi0*", ATTRS{name}=="linux*|update*|data*", ACTION=="add", RUN+="/etc/udev/scripts/mount_digiparts.sh", GOTO="automount_rules_end" +SUBSYSTEM=="ubi", KERNEL=="ubi*", ATTRS{name}=="linux*|update*|data*", ACTION=="add", RUN+="/etc/udev/scripts/mount_digiparts.sh", GOTO="automount_rules_end" # Avoid mounting recovery partition SUBSYSTEM=="block", ENV{ID_PART_ENTRY_NAME}=="recovery*", ACTION=="add", GOTO="automount_rules_end" diff --git a/meta-digi-arm/recipes-core/udev/udev-extraconf/mount_digiparts.sh b/meta-digi-arm/recipes-core/udev/udev-extraconf/mount_digiparts.sh index 53a9dc465..f72b6da8c 100644 --- a/meta-digi-arm/recipes-core/udev/udev-extraconf/mount_digiparts.sh +++ b/meta-digi-arm/recipes-core/udev/udev-extraconf/mount_digiparts.sh @@ -3,7 +3,7 @@ # # mount_bootparts.sh # -# Copyright (C) 2014-2022 by Digi International Inc. +# Copyright (C) 2014-2023 by Digi International Inc. # All rights reserved. # # This program is free software; you can redistribute it and/or modify it @@ -15,14 +15,9 @@ #=============================================================================== BASE_INIT="$(readlink -f "@base_sbindir@/init")" +BASE_INIT_ORIG="$(readlink -f "@base_sbindir@/init.orig")" INIT_SYSTEMD="@systemd_unitdir@/systemd" -# Partitions are mounted: -# * For multi-MTD systems, when an MTD subsystem event is received. -# * For single-MTD systems, when a UBI subsystem event is received. -# So, do nothing for UBI subsystem events in multi-MTD systems. -[ "${SUBSYSTEM}" = "ubi" ] && [ -c /dev/ubi1 ] && exit 0 - if [ "${SUBSYSTEM}" = "block" ]; then PARTNAME="${ID_PART_ENTRY_NAME}" elif [ "${SUBSYSTEM}" = "mtd" ]; then @@ -30,6 +25,12 @@ elif [ "${SUBSYSTEM}" = "mtd" ]; then PARTNAME="$(grep ${MTDN} /proc/mtd | sed -ne 's,.*"\(.*\)",\1,g;T;p')" elif [ "${SUBSYSTEM}" = "ubi" ]; then PARTNAME="$(cat /sys/${DEVPATH}/name)" + # Multi-MTD systems only have one UBI volume per MTD partition that is + # called the same as the MTD partition. Do nothing for UBI events if the + # MTD partition is called the same, as they are already handled by the + # "mtd" subsystem rule + result="$(grep '\"${PARTNAME}\"$' /proc/mtd)" + [ -n "${result}" ] && exit 0 fi MOUNT_FOLDER=${PARTNAME} @@ -39,6 +40,13 @@ if [ "${PARTNAME}" = "linux" ] || [ "${PARTNAME}" = "linux_a" ] || [ "${PARTNAME MOUNT_FOLDER="linux" MOUNT_PARAMS="${MOUNT_PARAMS} -o ro" fi +MOUNTPOINT="/mnt/${MOUNT_FOLDER}" + +# Skip if partition is already mounted. For example R/O systems with the '/etc' overlay enabled mount the 'data' partition in very early stages. +if grep -qs "${MOUNTPOINT}" /proc/mounts; then + logger "Partition '${PARTNAME}' is already mounted, skipping..." + exit 0 +fi DUALBOOT_MODE="$(fw_printenv -n dualboot 2>/dev/null)" if [ "${DUALBOOT_MODE}" = "yes" ]; then @@ -51,7 +59,9 @@ if [ "${DUALBOOT_MODE}" = "yes" ]; then fi fi -if [ "x$BASE_INIT" = "x$INIT_SYSTEMD" ];then +# R/O systems using 'systemd' and '/etc' overlayfs do not link '/sbin/init' to 'systemd'. In these cases +# 'init' is renamed to 'init.orig' and that is the linked file, so check this case too. +if [ "x$BASE_INIT" = "x$INIT_SYSTEMD" ] || [ "x$BASE_INIT_ORIG" = "x$INIT_SYSTEMD" ]; then # systemd as init uses systemd-mount to mount block devices # Verify if unit is already launched, if so just restart it. @@ -85,7 +95,6 @@ else fi # Create mount point if needed -MOUNTPOINT="/mnt/${MOUNT_FOLDER}" [ -d "${MOUNTPOINT}" ] || mkdir -p ${MOUNTPOINT} if [ "${SUBSYSTEM}" = "block" ]; then diff --git a/meta-digi-arm/recipes-core/udev/udev-extraconf_1.1.bbappend b/meta-digi-arm/recipes-core/udev/udev-extraconf_1.1.bbappend index 134bfd839..48063b477 100644 --- a/meta-digi-arm/recipes-core/udev/udev-extraconf_1.1.bbappend +++ b/meta-digi-arm/recipes-core/udev/udev-extraconf_1.1.bbappend @@ -9,7 +9,6 @@ SRC_URI += " \ " SRC_URI:append:ccmp1 = " \ file://99-ext-rtc-wakeup.rules \ - file://00-disable-sd.rules \ " do_install:append() { @@ -60,9 +59,6 @@ do_install:append() { do_install:append:ccmp1() { install -m 0644 ${WORKDIR}/99-ext-rtc-wakeup.rules ${D}${sysconfdir}/udev/rules.d/ - # Disables all SD device but keeps on mounting other external memory devices like USB. - # This is currently needed for the CCMP1 platform as a workaround to fix a boot issue. - install -m 0644 ${WORKDIR}/00-disable-sd.rules ${D}${sysconfdir}/udev/rules.d/ } FILES:${PN}:append = " \ diff --git a/meta-digi-arm/recipes-digi/trustfence/trustfence-genpki-native.bb b/meta-digi-arm/recipes-digi/trustfence/trustfence-genpki-native.bb deleted file mode 100644 index b1167f55c..000000000 --- a/meta-digi-arm/recipes-digi/trustfence/trustfence-genpki-native.bb +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright (C) 2023, Digi International Inc. - -SUMMARY = "TrustFence generation of Public Key Infrastructure (PKI)" -LICENSE = "GPL-2.0-only" -LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6" - -inherit native - -RDEPENDS:${PN} = " \ - trustfence-sign-tools-native \ - openssl-native \ -" - -S = "${WORKDIR}" - -do_fetch[noexec] = "1" -do_configure[noexec] = "1" -do_compile[noexec] = "1" - -# Function to generate a PKI tree (with lock dir protection) -GENPKI_LOCK_DIR = "${TRUSTFENCE_SIGN_KEYS_PATH}/.genpki.lock" -gen_pki_tree() { - if mkdir -p ${GENPKI_LOCK_DIR}; then - if [ "${DEY_SOC_VENDOR}" = "NXP" ]; then - trustfence-gen-pki.sh ${TRUSTFENCE_SIGN_KEYS_PATH} - elif [ "${DEY_SOC_VENDOR}" = "STM" ]; then - # Call sign script with no artifact arguments to just - # generate the keys - export CONFIG_SIGN_KEYS_PATH="${TRUSTFENCE_SIGN_KEYS_PATH}" - export CONFIG_KEY_INDEX="${TRUSTFENCE_KEY_INDEX}" - trustfence-sign-artifact.sh -p ${DIGI_SOM} - fi - rm -rf ${GENPKI_LOCK_DIR} - else - bbfatal "Could not get lock to generate PKI tree" - fi -} - -# Function that generates a PKI tree if there isn't one -check_gen_pki_tree() { - if [ "${DEY_SOC_VENDOR}" = "NXP" ]; then - SRK_KEYS="$(echo ${TRUSTFENCE_SIGN_KEYS_PATH}/crts/SRK*crt.pem | sed s/\ /\,/g)" - n_commas="$(echo ${SRK_KEYS} | grep -o "," | wc -l)" - if [ "${n_commas}" -eq 0 ]; then - gen_pki_tree - elif [ "${n_commas}" -ne 3 ]; then - bbfatal "Inconsistent PKI tree" - fi - elif [ "${DEY_SOC_VENDOR}" = "STM" ]; then - # The script that generates the PKI tree already checks if - # there isn't one, so there's nothing to do here but calling it. - gen_pki_tree - fi -} - -do_install[depends] = "trustfence-sign-tools-native:do_populate_sysroot \ - openssl-native:do_populate_sysroot" -do_install() { - check_gen_pki_tree -} - -FILES:${PN} = "${bindir}" diff --git a/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools.inc b/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools.inc index 0f2a30aaf..676122560 100644 --- a/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools.inc +++ b/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools.inc @@ -18,6 +18,7 @@ SRC_URI = " \ ${UBOOT_GIT_URI};branch=${SRCBRANCH} \ file://trustfence-sign-artifact-nxp.sh \ file://trustfence-sign-artifact-stm.sh \ + file://trustfence-gen-pki-stm.sh \ file://sign_hab;name=artifact-hab-sign \ file://encrypt_hab;name=artifact-hab-encrypt \ file://sign_ahab;name=artifact-ahab-sign \ @@ -46,13 +47,18 @@ do_install() { # Select U-Boot sign script depending on U-Boot including an SPL image if [ -n "${SPL_BINARY}" ]; then - install -m 0755 git/scripts/sign_spl_fit.sh ${D}${bindir}/trustfence-sign-uboot.sh + if [ "${TRUSTFENCE_SIGN_MODE}" = "AHAB" ]; then + install -m 0755 git/scripts/sign_spl_ahab.sh ${D}${bindir}/trustfence-sign-uboot.sh + else + install -m 0755 git/scripts/sign_spl_fit.sh ${D}${bindir}/trustfence-sign-uboot.sh + fi else install -m 0755 git/scripts/sign.sh ${D}${bindir}/trustfence-sign-uboot.sh fi elif [ "${DEY_SOC_VENDOR}" = "STM" ]; then install -d ${D}${bindir} install -m 0755 trustfence-sign-artifact-stm.sh ${D}${bindir}/trustfence-sign-artifact.sh + install -m 0755 trustfence-gen-pki-stm.sh ${D}${bindir}/trustfence-gen-pki.sh fi } diff --git a/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/trustfence-gen-pki-stm.sh b/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/trustfence-gen-pki-stm.sh new file mode 100755 index 000000000..ad0c4548d --- /dev/null +++ b/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/trustfence-gen-pki-stm.sh @@ -0,0 +1,91 @@ +#!/bin/sh +#=============================================================================== +# +# trustfence-gen-pki-stm.sh +# +# Copyright (C) 2023 by Digi International Inc. +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published by +# the Free Software Foundation. +# +# +# Description: +# Script for generating PKI tree using STM tools +# +#=============================================================================== + +# Avoid parallel execution of this script +SINGLE_PROCESS_LOCK="/tmp/gen_pki_script.lock.d" +trap 'rm -rf "${SINGLE_PROCESS_LOCK}"' INT TERM EXIT +while ! mkdir "${SINGLE_PROCESS_LOCK}" > /dev/null 2>&1; do + sleep 1 +done + +SCRIPT_NAME="$(basename "${0}")" +SUPPORTED_PLATFORMS="ccmp15, ccmp13" + +while getopts "p:" c; do + case "${c}" in + p) PLATFORM="${OPTARG}";; + esac +done +shift "$((OPTIND - 1))" + +usage() { + cat < + + Options: + -p platform + +Supported platforms: ${SUPPORTED_PLATFORMS} + +EOF +} + +if [ -z "${CONFIG_SIGN_KEYS_PATH}" ]; then + echo "Undefined CONFIG_SIGN_KEYS_PATH"; + exit 1 +fi +[ -d "${CONFIG_SIGN_KEYS_PATH}" ] || mkdir "${CONFIG_SIGN_KEYS_PATH}" + +# Default values +KEY_PASS_FILE="${CONFIG_SIGN_KEYS_PATH}/keys/key_pass.txt" + +# Generate random keys if they don't exist +N_PUBK="$(ls -l "${CONFIG_SIGN_KEYS_PATH}"/keys/publicKey*.pem 2>/dev/null | wc -l)" +N_PRVK="$(ls -l "${CONFIG_SIGN_KEYS_PATH}"/keys/privateKey*.pem 2>/dev/null | wc -l)" +if [ "${PLATFORM}" = "ccmp15" ]; then + if [ "${N_PUBK}" != "1" ] && [ "${N_PRVK}" != 1 ] && [ ! -f "${KEY_PASS_FILE}" ]; then + install -d "${CONFIG_SIGN_KEYS_PATH}/keys/" + # Random password + password="$(openssl rand -base64 32)" + echo "Generating random key" + if ! STM32MP_KeyGen_CLI -abs "${CONFIG_SIGN_KEYS_PATH}/keys/" -pwd ${password}; then + echo "[ERROR] Could not generate PKI tree" + exit 1 + fi + echo "${password}" > "${KEY_PASS_FILE}" + fi +elif [ "${PLATFORM}" = "ccmp13" ]; then + if [ "${N_PUBK}" != "8" ] && [ "${N_PRVK}" != 8 ] && [ ! -f "${KEY_PASS_FILE}" ]; then + install -d "${CONFIG_SIGN_KEYS_PATH}/keys/" + # 8 random passwords (separated by whitespaces) + passwords="$(openssl rand -base64 32)" + for i in $(seq 1 7); do + passwords="${passwords} $(openssl rand -base64 32)" + done + echo "Generating random keys" + if ! STM32MP_KeyGen_CLI -abs "${CONFIG_SIGN_KEYS_PATH}/keys/" -pwd ${passwords} -n 8; then + echo "[ERROR] Could not generate PKI tree" + exit 1 + fi + echo "${passwords}" > "${KEY_PASS_FILE}" + fi +else + echo "Undefined platform" + exit 1 +fi diff --git a/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/trustfence-sign-artifact-nxp.sh b/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/trustfence-sign-artifact-nxp.sh index ba916eafa..0f22934f2 100755 --- a/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/trustfence-sign-artifact-nxp.sh +++ b/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/trustfence-sign-artifact-nxp.sh @@ -58,7 +58,7 @@ Usage: ${SCRIPT_NAME} [OPTIONS] input-unsigned-image output-signed-image -l sign/encrypt Linux image -r sign read-only rootfs image -Supported platforms: ccimx6, ccimx6ul, ccimx8x, ccimx8mn, ccimx8mm +Supported platforms: ccimx6, ccimx6qp, ccimx6ul, ccimx8x, ccimx8mn, ccimx8mm EOF } @@ -81,7 +81,7 @@ fi [ -d "${CONFIG_SIGN_KEYS_PATH}" ] || mkdir "${CONFIG_SIGN_KEYS_PATH}" # Get RAM_START address -if [ "${PLATFORM}" = "ccimx6" ]; then +if [ "${PLATFORM}" = "ccimx6" ] || [ "${PLATFORM}" = "ccimx6qp" ]; then CONFIG_FDT_LOADADDR="0x18000000" CONFIG_RAMDISK_LOADADDR="0x19000000" CONFIG_KERNEL_LOADADDR="0x12000000" diff --git a/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/trustfence-sign-artifact-stm.sh b/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/trustfence-sign-artifact-stm.sh index ddf2d1c86..236033d95 100755 --- a/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/trustfence-sign-artifact-stm.sh +++ b/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/trustfence-sign-artifact-stm.sh @@ -47,59 +47,36 @@ Usage: ${SCRIPT_NAME} [ ] Supported platforms: ${SUPPORTED_PLATFORMS} -When called without filename parameters, it generates random keys if they -do not exist. - EOF } +if [ "${#}" != "2" ]; then + usage + exit 1 +fi + if [ -z "${CONFIG_SIGN_KEYS_PATH}" ]; then echo "Undefined CONFIG_SIGN_KEYS_PATH"; exit 1 fi -[ -d "${CONFIG_SIGN_KEYS_PATH}" ] || mkdir "${CONFIG_SIGN_KEYS_PATH}" # Default values [ -z "${CONFIG_KEY_INDEX}" ] && CONFIG_KEY_INDEX="0" KEY_PASS_FILE="${CONFIG_SIGN_KEYS_PATH}/keys/key_pass.txt" # Generate random keys if they don't exist -if [ "${PLATFORM}" = "ccmp15" ]; then - PUBLIC_KEY="${CONFIG_SIGN_KEYS_PATH}/keys/publicKey00.pem" - PRIVATE_KEY="${CONFIG_SIGN_KEYS_PATH}/keys/privateKey00.pem" - if [ ! -f "${PRIVATE_KEY}" ] && [ ! -f "${PUBLIC_KEY}" ] && [ ! -f "${KEY_PASS_FILE}" ]; then - install -d "${CONFIG_SIGN_KEYS_PATH}/keys/" - # Random password - password="$(openssl rand -base64 32)" - echo "Generating random key" - STM32MP_KeyGen_CLI -abs "${CONFIG_SIGN_KEYS_PATH}/keys/" -pwd ${password} -n 1 - echo "${password}" > "${KEY_PASS_FILE}" - fi -elif [ "${PLATFORM}" = "ccmp13" ]; then - N_PUBK="$(ls -l ${CONFIG_SIGN_KEYS_PATH}/keys/publicKey0* 2>/dev/null | wc -l)" - N_PRVK="$(ls -l ${CONFIG_SIGN_KEYS_PATH}/keys/privateKey0* 2>/dev/null | wc -l)" - PUBLIC_KEY="${CONFIG_SIGN_KEYS_PATH}/keys/publicKey0*.pem" - PRIVATE_KEY="${CONFIG_SIGN_KEYS_PATH}/keys/privateKey0${CONFIG_KEY_INDEX}.pem" - if [ "${N_PUBK}" != "8" ] && [ "${N_PRVK}" != 8 ] && [ ! -f "${KEY_PASS_FILE}" ]; then - install -d "${CONFIG_SIGN_KEYS_PATH}/keys/" - # 8 random passwords (separated by whitespaces) - passwords="$(openssl rand -base64 32)" - for i in $(seq 1 7); do - passwords="${passwords} $(openssl rand -base64 32)" - done - echo "Generating random keys" - STM32MP_KeyGen_CLI -abs "${CONFIG_SIGN_KEYS_PATH}/keys/" -pwd ${passwords} -n 8 - echo "${passwords}" > "${KEY_PASS_FILE}" - fi -else - echo "Undefined platform" +if ! trustfence-gen-pki.sh -p ${PLATFORM}; then exit 1 fi -if [ "${#}" = "0" ]; then - exit 0 -elif [ "${#}" != "2" ]; then - usage +if [ "${PLATFORM}" = "ccmp15" ]; then + PUBLIC_KEY="${CONFIG_SIGN_KEYS_PATH}/keys/publicKey.pem" + PRIVATE_KEY="${CONFIG_SIGN_KEYS_PATH}/keys/privateKey.pem" +elif [ "${PLATFORM}" = "ccmp13" ]; then + PUBLIC_KEY="${CONFIG_SIGN_KEYS_PATH}/keys/publicKey0*.pem" + PRIVATE_KEY="${CONFIG_SIGN_KEYS_PATH}/keys/privateKey0${CONFIG_KEY_INDEX}.pem" +else + echo "Undefined platform" exit 1 fi diff --git a/meta-digi-arm/recipes-kernel/dtc/dtc/0001-fdtdump-Fix-gcc11-warning.patch b/meta-digi-arm/recipes-kernel/dtc/dtc/0001-fdtdump-Fix-gcc11-warning.patch new file mode 100644 index 000000000..6a0313aaf --- /dev/null +++ b/meta-digi-arm/recipes-kernel/dtc/dtc/0001-fdtdump-Fix-gcc11-warning.patch @@ -0,0 +1,53 @@ +From: David Gibson +Date: Wed, 6 Jan 2021 14:52:26 +1100 +Subject: [PATCH] fdtdump: Fix gcc11 warning + +In one place, fdtdump abuses fdt_set_magic(), passing it just a small char +array instead of the full fdt header it expects. That's relying on the +fact that in fact fdt_set_magic() will only actually access the first 4 +bytes of the buffer. + +This trips a new warning in GCC 11 - and it's entirely possible it was +always UB. So, don't do that. + +Signed-off-by: David Gibson +(cherry picked from commit ca16a723fa9dde9c5da80dba567f48715000e77c) +--- + fdtdump.c | 2 +- + libfdt/libfdt.h | 10 ++++++++++ + 2 files changed, 11 insertions(+), 1 deletion(-) + +diff --git a/fdtdump.c b/fdtdump.c +index fa3b561..072c0af 100644 +--- a/fdtdump.c ++++ b/fdtdump.c +@@ -214,7 +214,7 @@ int main(int argc, char *argv[]) + char *p = buf; + char *endp = buf + len; + +- fdt_set_magic(smagic, FDT_MAGIC); ++ fdt32_st(smagic, FDT_MAGIC); + + /* poor man's memmem */ + while ((endp - p) >= FDT_MAGIC_SIZE) { +diff --git a/libfdt/libfdt.h b/libfdt/libfdt.h +index 313c72a..8795f10 100644 +--- a/libfdt/libfdt.h ++++ b/libfdt/libfdt.h +@@ -153,6 +153,16 @@ static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen) + + uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset); + ++static inline void fdt32_st(void *property, uint32_t value) ++{ ++ uint8_t *bp = (uint8_t *)property; ++ ++ bp[0] = value >> 24; ++ bp[1] = (value >> 16) & 0xff; ++ bp[2] = (value >> 8) & 0xff; ++ bp[3] = value & 0xff; ++} ++ + /**********************************************************************/ + /* Traversal functions */ + /**********************************************************************/ diff --git a/meta-digi-arm/recipes-kernel/dtc/dtc_1.4.5.bb b/meta-digi-arm/recipes-kernel/dtc/dtc_1.4.5.bb index 32d160586..7c6400c5f 100644 --- a/meta-digi-arm/recipes-kernel/dtc/dtc_1.4.5.bb +++ b/meta-digi-arm/recipes-kernel/dtc/dtc_1.4.5.bb @@ -9,6 +9,7 @@ SRCREV = "22a65c5331c22979d416738eb756b9541672e00d" SRC_URI:append = " \ file://0001-Remove-redundant-YYLOC-global-declaration.patch \ + file://0001-fdtdump-Fix-gcc11-warning.patch \ " S = "${WORKDIR}/git" diff --git a/meta-digi-arm/recipes-kernel/kernel-modules/kernel-module-nxp-wlan.bbappend b/meta-digi-arm/recipes-kernel/kernel-modules/kernel-module-nxp-wlan.bbappend index e1a0c245a..df541be20 100644 --- a/meta-digi-arm/recipes-kernel/kernel-modules/kernel-module-nxp-wlan.bbappend +++ b/meta-digi-arm/recipes-kernel/kernel-modules/kernel-module-nxp-wlan.bbappend @@ -3,6 +3,7 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}:" SRC_URI:append = " \ + file://0001-Fix-for-the-HE-Rate-Index.patch \ file://81-iw612-wifi.rules \ file://load_iw612.sh \ " diff --git a/meta-digi-arm/recipes-kernel/kernel-modules/kernel-module-nxp-wlan/0001-Fix-for-the-HE-Rate-Index.patch b/meta-digi-arm/recipes-kernel/kernel-modules/kernel-module-nxp-wlan/0001-Fix-for-the-HE-Rate-Index.patch new file mode 100644 index 000000000..c2f0c04ba --- /dev/null +++ b/meta-digi-arm/recipes-kernel/kernel-modules/kernel-module-nxp-wlan/0001-Fix-for-the-HE-Rate-Index.patch @@ -0,0 +1,70 @@ +From: Achyut Hegde +Date: Thu, 28 Apr 2022 17:51:45 +0000 +Subject: [PATCH] Fix for the HE Rate Index + +--- + .../mlinux/moal_sta_cfg80211.c | 37 ++++++++++++++++++- + 1 file changed, 35 insertions(+), 2 deletions(-) + +diff --git a/mxm_wifiex/mlinux/moal_sta_cfg80211.c b/mxm_wifiex/mlinux/moal_sta_cfg80211.c +index bf39f0e9b003..5f300288a6c8 100644 +--- a/mlinux/moal_sta_cfg80211.c ++++ b/mlinux/moal_sta_cfg80211.c +@@ -3393,6 +3393,37 @@ done: + return ret; + } + ++#if CFG80211_VERSION_CODE >= KERNEL_VERSION(5, 1, 18) ++/** ++ * @brief This function convert he_gi to nl80211_he_gi ++ * ++ * @param he_gi 0/1/2/3 ++ * ++ * ++ * @return 0: NL80211_RATE_INFO_HE_GI_0_8 ++ * 1: NL80211_RATE_INFO_HE_GI_1_6 ++ * 2: NL80211_RATE_INFO_HE_GI_3_2 ++ */ ++static t_u8 woal_he_gi_to_nl80211_he_gi(t_u8 he_gi) ++{ ++ t_u8 cfg_he_gi = 0; ++ switch(he_gi){ ++ case 3: ++ cfg_he_gi = NL80211_RATE_INFO_HE_GI_3_2; ++ break; ++ case 2: ++ cfg_he_gi = NL80211_RATE_INFO_HE_GI_1_6; ++ break; ++ case 0: ++ case 1: ++ default: ++ cfg_he_gi = NL80211_RATE_INFO_HE_GI_0_8; ++ break; ++ } ++ return cfg_he_gi; ++} ++#endif ++ + /** + * @brief Request the driver to fill the tx/rx rate info + * +@@ -3469,7 +3500,8 @@ static void woal_cfg80211_fill_rate_info(moal_private *priv, + sinfo->txrate.flags = RATE_INFO_FLAGS_HE_MCS; + sinfo->txrate.nss = rate->param.data_rate.tx_nss + 1; + sinfo->txrate.mcs = rate->param.data_rate.tx_mcs_index; +- sinfo->txrate.he_gi = rate->param.data_rate.tx_ht_gi; ++ sinfo->txrate.he_gi = woal_he_gi_to_nl80211_he_gi( ++ rate->param.data_rate.tx_ht_gi); + if (rate->param.data_rate.tx_ht_bw == MLAN_VHT_BW80) + sinfo->txrate.bw = RATE_INFO_BW_80; + else if (rate->param.data_rate.tx_ht_bw == MLAN_HT_BW40) +@@ -3516,7 +3548,8 @@ static void woal_cfg80211_fill_rate_info(moal_private *priv, + sinfo->rxrate.flags = RATE_INFO_FLAGS_HE_MCS; + sinfo->rxrate.nss = rate->param.data_rate.rx_nss + 1; + sinfo->rxrate.mcs = rate->param.data_rate.rx_mcs_index; +- sinfo->rxrate.he_gi = rate->param.data_rate.rx_ht_gi; ++ sinfo->rxrate.he_gi = woal_he_gi_to_nl80211_he_gi( ++ rate->param.data_rate.rx_ht_gi); + if (rate->param.data_rate.rx_ht_bw == MLAN_VHT_BW80) + sinfo->rxrate.bw = RATE_INFO_BW_80; + else if (rate->param.data_rate.rx_ht_bw == MLAN_HT_BW40) diff --git a/meta-digi-arm/recipes-kernel/kernel-modules/kernel-module-nxp-wlan/load_iw612.sh b/meta-digi-arm/recipes-kernel/kernel-modules/kernel-module-nxp-wlan/load_iw612.sh index 8a8539688..e6acea5c5 100644 --- a/meta-digi-arm/recipes-kernel/kernel-modules/kernel-module-nxp-wlan/load_iw612.sh +++ b/meta-digi-arm/recipes-kernel/kernel-modules/kernel-module-nxp-wlan/load_iw612.sh @@ -20,7 +20,7 @@ host_mlme=1 \ drv_mode=${DRIVER_MODE} \ drvdbg=${DRIVER_DEBUG} \ sta_name=wlan \ -fw_name=nxp/sduart_nw61x_v1.bin.se\ +fw_name=nxp/sd_w61x_v1.bin.se\ " log() { diff --git a/meta-digi-arm/recipes-kernel/linux/linux-dey-src.inc b/meta-digi-arm/recipes-kernel/linux/linux-dey-src.inc deleted file mode 100644 index e3e15bca2..000000000 --- a/meta-digi-arm/recipes-kernel/linux/linux-dey-src.inc +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (C) 2018-2022 Digi International - -LOCALVERSION = "-dey" - -# Select internal or Github Linux repo -LINUX_URI_STASH = "${DIGI_MTK_GIT}/linux/linux.git;protocol=ssh" -LINUX_URI_GITHUB = "${DIGI_GITHUB_GIT}/linux.git;protocol=https" -LINUX_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${LINUX_URI_STASH}', '${LINUX_URI_GITHUB}', d)}" - -SRC_URI = "${LINUX_GIT_URI};branch=${SRCBRANCH}" - -# A user can provide his own kernel 'defconfig' file by: -# - setting the variable KERNEL_DEFCONFIG to a custom kernel configuration file -# inside the kernel repository. -# - setting the variable KERNEL_DEFCONFIG to a kernel configuration file using -# the full path to the file. -# - clearing the variable KERNEL_DEFCONFIG and providing a kernel configuration -# file in the layer (in this case the file must be named 'defconfig'). -# Otherwise the default platform's kernel configuration file will be taken from -# the Linux source code tree. -do_copy_defconfig[vardeps] += "KERNEL_DEFCONFIG" -do_copy_defconfig[dirs] = "${S}" -do_copy_defconfig () { - if [ -n "${KERNEL_DEFCONFIG}" ]; then - cp -f ${KERNEL_DEFCONFIG} ${WORKDIR}/defconfig - fi -} -addtask copy_defconfig after do_patch before do_kernel_localversion - -S = "${WORKDIR}/git" diff --git a/meta-digi-arm/recipes-kernel/linux/linux-dey.inc b/meta-digi-arm/recipes-kernel/linux/linux-dey.inc new file mode 100644 index 000000000..de58e8115 --- /dev/null +++ b/meta-digi-arm/recipes-kernel/linux/linux-dey.inc @@ -0,0 +1,74 @@ +# Copyright (C) 2018-2023 Digi International +SUMMARY = "Linux kernel for Digi boards" +LICENSE = "GPL-2.0-only" +LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46" + +inherit kernel +inherit ${@oe.utils.conditional('DEY_SOC_VENDOR', 'NXP', 'fsl-kernel-localversion', '', d)} +require ${@oe.utils.conditional('DEY_SOC_VENDOR', 'STM', 'recipes-kernel/linux/linux-stm32mp.inc', '', d)} +require ${@bb.utils.contains('DISTRO_FEATURES', 'virtualization', 'linux-virtualization.inc', '', d)} +require ${@oe.utils.conditional('TRUSTFENCE_SIGN', '1', 'recipes-kernel/linux/linux-trustfence.inc', '', d)} + +# CONFIG_KERNEL_LZO in defconfig +DEPENDS += "${@oe.utils.conditional('DEY_SOC_VENDOR', 'NXP', 'lzop-native', '', d)}" + +# Select internal or Github Linux repo +LINUX_URI_STASH = "${DIGI_MTK_GIT}/linux/linux.git;protocol=ssh" +LINUX_URI_GITHUB = "${DIGI_GITHUB_GIT}/linux.git;protocol=https" +LINUX_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1', '${LINUX_URI_STASH}', '${LINUX_URI_GITHUB}', d)}" +SRC_URI = " \ + ${LINUX_GIT_URI};branch=${SRCBRANCH} \ + ${@oe.utils.conditional('KERNEL_DEFCONFIG', '', 'file://defconfig', '', d)} \ +" +S = "${WORKDIR}/git" + +LOCALVERSION = "-dey" + +# Create base DTB suitable for overlays +OVERLAYS_DTC_FLAGS = "-@" +OVERLAYS_DTC_FLAGS:ccimx6ul = "" +OVERLAYS_DTC_FLAGS:ccimx6 = "" +KERNEL_DTC_FLAGS = "${OVERLAYS_DTC_FLAGS}" + +KERNEL_EXTRA_ARGS:stm32mpcommon += "LOADADDR=${ST_KERNEL_LOADADDR}" + +# A user can provide his own kernel 'defconfig' file by: +# - setting the variable KERNEL_DEFCONFIG to a custom kernel configuration file +# inside the kernel repository. +# - setting the variable KERNEL_DEFCONFIG to a kernel configuration file using +# the full path to the file. +# - clearing the variable KERNEL_DEFCONFIG and providing a kernel configuration +# file in the layer (in this case the file must be named 'defconfig'). +# +# Otherwise the default platform's kernel configuration file will be taken from +# the Linux source code tree. +do_copy_defconfig[vardeps] += "KERNEL_DEFCONFIG" +do_copy_defconfig[dirs] = "${S}" +do_copy_defconfig () { + if [ -n "${KERNEL_DEFCONFIG}" ]; then + cp -f ${KERNEL_DEFCONFIG} ${WORKDIR}/defconfig + fi +} +addtask copy_defconfig after do_patch before do_kernel_localversion + +# This is needed because kernel_localversion (in fsl-kernel-localversion.bbclass) +# creates a basic ${B}/.config file and because that file exists, kernel_do_configure +# (in kernel.bbclass) does not apply our defconfig. +do_configure:prepend:imx-nxp-bsp() { + if [ -f "${WORKDIR}/defconfig" ] && [ -f "${B}/.config" ]; then + cat "${WORKDIR}/defconfig" >> "${B}/.config" + fi +} + +# Apply configuration fragments +do_configure:append() { + # Only accept fragments ending in .cfg. If the fragments contain + # something other than kernel configs, it will be filtered out + # automatically. + if [ -n "${@' '.join(find_cfgs(d))}" ]; then + ${S}/scripts/kconfig/merge_config.sh -m -O ${B} ${B}/.config ${@" ".join(find_cfgs(d))} + fi +} + +# Don't create custom folder for kernel artifacts +do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}" diff --git a/meta-digi-arm/recipes-kernel/linux/linux-dey_5.15.bb b/meta-digi-arm/recipes-kernel/linux/linux-dey_5.15.bb index d6a71f85e..1a908da36 100644 --- a/meta-digi-arm/recipes-kernel/linux/linux-dey_5.15.bb +++ b/meta-digi-arm/recipes-kernel/linux/linux-dey_5.15.bb @@ -1,55 +1,10 @@ # Copyright (C) 2022,2023 Digi International -SUMMARY = "Linux kernel for Digi boards" -LICENSE = "GPL-2.0-only" -LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46" - -# CONFIG_KERNEL_LZO in defconfig -DEPENDS += "${@oe.utils.conditional('DEY_SOC_VENDOR', 'NXP', 'lzop-native', '', d)}" - -inherit kernel -inherit ${@oe.utils.conditional('DEY_SOC_VENDOR', 'NXP', 'fsl-kernel-localversion', '', d)} +require recipes-kernel/linux/linux-dey.inc SRCBRANCH = "v5.15/nxp/dey-4.0/maint" SRCBRANCH:stm32mpcommon = "v5.15/stm/dey-4.0/maint" SRCREV = "${AUTOREV}" SRCREV:stm32mpcommon = "${AUTOREV}" -require ${@oe.utils.conditional('DEY_SOC_VENDOR', 'STM', 'recipes-kernel/linux/linux-stm32mp.inc', '', d)} -# Don't create custom folder for kernel artifacts -do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}" - -require recipes-kernel/linux/linux-dey-src.inc -require ${@bb.utils.contains('DISTRO_FEATURES', 'virtualization', 'linux-virtualization.inc', '', d)} -require ${@oe.utils.conditional('TRUSTFENCE_SIGN', '1', 'recipes-kernel/linux/linux-trustfence.inc', '', d)} - -# Use custom provided 'defconfig' if variable KERNEL_DEFCONFIG is cleared -SRC_URI +="${@oe.utils.conditional('KERNEL_DEFCONFIG', '', 'file://defconfig', '', d)}" - -# This is needed because kernel_localversion (in fsl-kernel-localversion.bbclass) -# creates a basic ${B}/.config file and because that file exists, kernel_do_configure -# (in kernel.bbclass) does not apply our defconfig. -do_configure:prepend:imx-nxp-bsp() { - if [ -f "${WORKDIR}/defconfig" ] && [ -f "${B}/.config" ]; then - cat "${WORKDIR}/defconfig" >> "${B}/.config" - fi -} - -# Apply configuration fragments -do_configure:append() { - # Only accept fragments ending in .cfg. If the fragments contain - # something other than kernel configs, it will be filtered out - # automatically. - if [ -n "${@' '.join(find_cfgs(d))}" ]; then - ${S}/scripts/kconfig/merge_config.sh -m -O ${B} ${B}/.config ${@" ".join(find_cfgs(d))} - fi -} - -# Create base DTB suitable for overlays -OVERLAYS_DTC_FLAGS = "-@" -OVERLAYS_DTC_FLAGS:ccimx6ul = "" -KERNEL_DTC_FLAGS = "${OVERLAYS_DTC_FLAGS}" - -KERNEL_EXTRA_ARGS:stm32mpcommon += "LOADADDR=${ST_KERNEL_LOADADDR}" - -COMPATIBLE_MACHINE = "(ccimx6ul|ccimx8m|ccimx93|ccmp1)" +COMPATIBLE_MACHINE = "(ccimx6ul|ccimx8m|ccimx6|ccmp1|ccimx8x)" diff --git a/meta-digi-arm/recipes-kernel/linux/linux-dey_6.1.bb b/meta-digi-arm/recipes-kernel/linux/linux-dey_6.1.bb new file mode 100644 index 000000000..eac62ffb6 --- /dev/null +++ b/meta-digi-arm/recipes-kernel/linux/linux-dey_6.1.bb @@ -0,0 +1,12 @@ +# Copyright (C) 2023 Digi International + +require recipes-kernel/linux/linux-dey.inc + +SRCBRANCH = "v6.1.22/nxp/master" +SRCREV = "${AUTOREV}" + +# Blacklist btnxpuart module. It will be managed by the bluetooth-init script +KERNEL_MODULE_PROBECONF += "btnxpuart" +module_conf_btnxpuart = "blacklist btnxpuart" + +COMPATIBLE_MACHINE = "(ccimx93)" diff --git a/meta-digi-arm/wic/ccmp1.wks.in b/meta-digi-arm/wic/ccmp1.wks.in new file mode 100644 index 000000000..a2d3e8835 --- /dev/null +++ b/meta-digi-arm/wic/ccmp1.wks.in @@ -0,0 +1,37 @@ +# short-description: Create SD card image with a boot partition (1GB) +# long-description: Creates a partitioned SD card image (1GB) +# +# - -------- ------------- ------ ------ ------------ -------- --------- -------- +# | | TFA(2) | Metadata(2) | FIPA | FIPB | U-BOOT ENV | linux | rootfs | data | +# - -------- ------------- ------ ------ ------------ -------- --------- -------- +# ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ +# | | | | | | | | | | +# 0 17kB 542kB 1.06MB 5.26MB 9.45MB 9.97MB 77.1MB 898MB 1032MB +# +# Warning: the first stage of boot (here fsbl1, fsbl2, metadata1, metadata2, fipa, fipb) MUST be on GPT partition to be detected. +# + +# FSBL partitions aka TF-A BL2 +part fsbl1 --source rawcopy --fstype=ext4 --fsoptions "noauto" --part-name=fsbl1 --sourceparams="file=${DEPLOY_DIR_IMAGE}/arm-trusted-firmware/tf-a-${MACHINE}-sdcard.stm32" --ondisk mmcblk --part-type 0x8301 --fixed-size 256K --align 17 +part fsbl2 --source rawcopy --fstype=ext4 --fsoptions "noauto" --part-name=fsbl2 --sourceparams="file=${DEPLOY_DIR_IMAGE}/arm-trusted-firmware/tf-a-${MACHINE}-sdcard.stm32" --ondisk mmcblk --part-type 0x8301 --fixed-size 256K + +# Metadata partitions +part metadata1 --source rawcopy --fstype=ext4 --fsoptions "noauto" --part-name=metadata1 --sourceparams="file=${DEPLOY_DIR_IMAGE}/arm-trusted-firmware/metadata.bin" --ondisk mmcblk --part-type 0x8301 --fixed-size 256K +part metadata2 --source rawcopy --fstype=ext4 --fsoptions "noauto" --part-name=metadata2 --sourceparams="file=${DEPLOY_DIR_IMAGE}/arm-trusted-firmware/metadata.bin" --ondisk mmcblk --part-type 0x8301 --fixed-size 256K + +# Fip partitions +part fip-a --source rawcopy --fstype=ext4 --fsoptions "noauto" --part-name=fip-a --sourceparams="file=${DEPLOY_DIR_IMAGE}/fip/fip-${MACHINE}-optee.bin" --ondisk mmcblk --part-type 19d5df83-11b0-457b-be2c-7559c13142a5 --fixed-size 4096K --uuid 4fd84c93-54ef-463f-a7ef-ae25ff887087 +part fip-b --source rawcopy --fstype=ext4 --fsoptions "noauto" --part-name=fip-b --sourceparams="file=${DEPLOY_DIR_IMAGE}/fip/fip-${MACHINE}-optee.bin" --ondisk mmcblk --part-type 19d5df83-11b0-457b-be2c-7559c13142a5 --fixed-size 4096K --uuid 09c54952-d5bf-45af-acee-335303766fb3 + +# U-BOOT env +part u-boot-env --source empty --part-name=uboot-env --ondisk mmcblk --part-type 0x8301 --fixed-size 512K + +# linux +part --source rawcopy --sourceparams="file=${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.boot.vfat" --ondisk mmcblk --fstype=vfat --part-name=linux --active --fixed-size 64M + +# Rootfs +part / --source rootfs --ondisk mmcblk --fstype=ext4 --label rootfs --fixed-size 783M --uuid e91c4e10-16e6-4c0e-bd0e-77becf4a3582 --part-name=rootfs +# data +part data --ondisk mmcblk --fstype=ext4 --label data --fixed-size 128M --part-name=data + +bootloader --ptable gpt diff --git a/meta-digi-dey/classes/dey-image.bbclass b/meta-digi-dey/classes/dey-image.bbclass index ca180b916..e91c10b8e 100644 --- a/meta-digi-dey/classes/dey-image.bbclass +++ b/meta-digi-dey/classes/dey-image.bbclass @@ -57,13 +57,22 @@ fakeroot toolchain_create_sdk_dey_version() { } toolchain_create_sdk_dey_version[vardepsexclude] = "DATETIME" +create_sw_versions_file() { + local swversionsfile="${IMAGE_ROOTFS}${sysconfdir}/sw-versions" + + rm -f $swversionsfile + touch $swversionsfile + echo 'firmware ${DEY_FIRMWARE_VERSION}' >> $swversionsfile +} +ROOTFS_POSTPROCESS_COMMAND:append = " create_sw_versions_file;" + # # Add dependency for read-only signed rootfs # DEPENDS += "${@oe.utils.conditional('TRUSTFENCE_SIGN', '1', 'trustfence-sign-tools-native', '', d)}" -# Remove kernel-module-imx-gpu-viv from all images -BAD_RECOMMENDATIONS += "kernel-module-imx-gpu-viv" - # Do not include kernel in rootfs images PACKAGE_EXCLUDE = "kernel-image-*" + +# Add required methods to generate the correct SWU update package. +inherit dey-swupdate diff --git a/meta-digi-dey/classes/dey-swupdate-common.bbclass b/meta-digi-dey/classes/dey-swupdate-common.bbclass new file mode 100644 index 000000000..7e3031d3e --- /dev/null +++ b/meta-digi-dey/classes/dey-swupdate-common.bbclass @@ -0,0 +1,112 @@ +# Copyright (C) 2023 Digi International. +# + +####################################### +########## General variables ########## +####################################### + +def get_baseimg_pn(d): + file_name = d.getVar('PN') + return file_name[:file_name.find("-swu")] if "-swu" in file_name else file_name + +IMAGE_DEPENDS = "${@get_baseimg_pn(d)}" + +IMG_NAME = "${IMAGE_DEPENDS}" + +# Update description. +SWUPDATE_DESCRIPTION = "${@oe.utils.ifelse(d.getVar('TRUSTFENCE_ENCRYPT_ROOTFS') == '1', 'Encrypted rootfs ${IMG_NAME} update', '${IMG_NAME} update')}" + +# Storage type. +SWUPDATE_STORAGE_TYPE = "${@oe.utils.conditional('STORAGE_MEDIA', 'mmc', 'mmc', 'mtd', d)}" + +# Root file system type. +SWUPDATE_ROOTFS_TYPE = "${@bb.utils.contains('IMAGE_FEATURES', 'read-only-rootfs', 'squashfs', '', d)}" + +# Dual boot partition names for eMMC or MTD +BOOT_DEV_NAME_A ?= "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', '/dev/mmcblk0p1', 'linux_a', d)}" +BOOT_DEV_NAME_B ?= "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', '/dev/mmcblk0p2', 'linux_b', d)}" +ROOTFS_DEV_NAME_A ?= "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', '/dev/mmcblk0p3', 'rootfs_a', d)}" +ROOTFS_DEV_NAME_B ?= "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', '/dev/mmcblk0p4', 'rootfs_b', d)}" + +####################################### +###### SWU Update based on files ###### +####################################### + +# Variable used to generate the tar.gz file. Do not modify. +SWUPDATE_FILES_TARGZ_FILE_NAME = "swupdate-files.tar.gz" + +# Initialize variable to provide a custom tar.gz file containing files/dirs to install. +SWUPDATE_FILES_TARGZ_FILE ?= "" + +# Initialize variable to store the files/folders that will be part of the SWUpdate package. +SWUPDATE_FILES_LIST ?= "" + +# Checks whether SWU update is based on files or not. +def update_based_on_files(d): + return str(d.getVar('SWUPDATE_FILES_TARGZ_FILE') != "" or d.getVar('SWUPDATE_FILES_LIST') != "").lower() + +# Variable that determines if SWU update is based on files or not. +SWUPDATE_IS_FILES_UPDATE = "${@update_based_on_files(d)}" + +####################################### +###### SWU Update based on RDIFF ###### +####################################### + +# Variable used to generate the 'rootfs' RDIFF file. Do not modify. +SWUPDATE_RDIFF_ROOTFS_DELTA_FILE_NAME = "swupdate-rootfs.rdiff" + +# Initialize variable to provide the base file from which to generate the 'rootfs' RDIFF file. +SWUPDATE_RDIFF_ROOTFS_SOURCE_FILE ?= "" + +# Rdiff image template based on storage type. +SWUPDATE_RDIFF_IMAGE_TEMPLATE_FILE = "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', 'image_template_rdiff_mmc', 'image_template_rdiff_nand', d)}" + +# Checks whether SWU update is based on RDIFF or not. +def update_based_on_rdiff(d): + return str("read-only-rootfs" in d.getVar('IMAGE_FEATURES') and d.getVar('SWUPDATE_IS_FILES_UPDATE') != "true" and d.getVar('SWUPDATE_RDIFF_ROOTFS_SOURCE_FILE') != "").lower() + +# Variable that determines if SWU update is based on RDIFF or not. +SWUPDATE_IS_RDIFF_UPDATE = "${@update_based_on_rdiff(d)}" + +####################################### +##### SWU Update based on images ###### +####################################### + +# Image template based on storage type. +SWUPDATE_IMAGES_IMAGE_TEMPLATE_FILE = "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', 'image_template_mmc', 'image_template_nand', d)}" + +# Checks whether SWU update is based on images or not. +def update_based_on_images(d): + return str(d.getVar('SWUPDATE_IS_FILES_UPDATE') != "true" and d.getVar('SWUPDATE_IS_RDIFF_UPDATE') != "true").lower() + +# Variable that determines if SWU update is based on images or not. +SWUPDATE_IS_IMAGES_UPDATE = "${@update_based_on_images(d)}" + +####################################### +########## SWU Update U-Boot ########## +####################################### + +# Determine the correct UBoot update script file to use depending on storage type. +SWUPDATE_UBOOT_SCRIPT = "${@oe.utils.conditional('STORAGE_MEDIA', 'mmc', 'swupdate_uboot_mmc.sh', 'swupdate_uboot_nand.sh', d)}" + +UBOOT_EXT ?= ".${UBOOT_SUFFIX}" + +UBOOTIMG_OFFSET ?= "${BOOTLOADER_SEEK_BOOT}" + +####################################### +########## SWU Update Script ########## +####################################### + +# Retrieve the correct update script name based on the SWU update type. +def get_update_script_name(d): + if d.getVar('SWUPDATE_IS_FILES_UPDATE') == "true": + return "update_files.sh" + if d.getVar('SWUPDATE_IS_RDIFF_UPDATE') == "true": + return "update_rdiff.sh" + return "update_images.sh" + +# Initialize variable that configures the update script to use. +SWUPDATE_SCRIPT ?= "${@get_update_script_name(d)}" + +# Name of the update script to include in the SWU package. +SWUPDATE_SCRIPT_NAME = "${@os.path.basename(d.getVar('SWUPDATE_SCRIPT'))}" diff --git a/meta-digi-dey/classes/dey-swupdate.bbclass b/meta-digi-dey/classes/dey-swupdate.bbclass new file mode 100644 index 000000000..15e0e3c29 --- /dev/null +++ b/meta-digi-dey/classes/dey-swupdate.bbclass @@ -0,0 +1,87 @@ +# Copyright (C) 2023 Digi International. +# +# Generates a 'tar.gz' file with the files and folders to be included in the update package +# as part of discrete files SWUpdate installation process. +# +# Usage: +# +# In your "local.conf" file, fill the "SWUPDATE_FILES_LIST" variable with the list of +# files/folders to include in the SWUpdate package. Paths must be relative to "/": +# +# SWUPDATE_FILES_LIST = " ..." +# + +# Load commmon variables. +inherit dey-swupdate-common + +DEPENDS += "${@oe.utils.ifelse(d.getVar('SWUPDATE_IS_RDIFF_UPDATE') == 'true', 'librsync-native', '')}" + +####################################### +###### SWU Update based on files ###### +####################################### + +create_swupdate_targz_file() { + local targzfile="${DEPLOY_DIR_IMAGE}/${SWUPDATE_FILES_TARGZ_FILE_NAME}" + # Clean previous versions of the file. + rm -f "${targzfile}" + + # Create the tar file including the 'sw-versions' file, as it is mandatory. + if [ "${SWUPDATE_FILES_TARGZ_FILE}" != "" ]; then + # User provides a custom tar.gz file. Copy it to distribution dir. + cp "${SWUPDATE_FILES_TARGZ_FILE}" "${targzfile}" + # Uncompress the tar file. + if ! gzip -t "${targzfile}"; then + # File is not correctly compressed, exit with error. + echo "[ERROR] File ${SWUPDATE_FILES_TARGZ_FILE} is not a valid 'tar.gz' file. Aborting..." + exit 1 + fi + gunzip "${targzfile}" + # Add the 'sw-versions' file. + tar -C "${IMAGE_ROOTFS}" -uf "${targzfile%.*}" etc/sw-versions + else + # The tar.gz file is not provided by user. Create it including the 'sw-versions' file + tar -C "${IMAGE_ROOTFS}" -cf "${targzfile%.*}" etc/sw-versions + fi + + # Iterate the list of files and folders. Add all entries directly except paths starting + # with 'mnt/linux'. Those files must be added from the 'DEPLOY_DIR_IMAGE' instead of + # 'IMAGE_ROOTFS', as they are part of the 'boot' image. + for file in ${SWUPDATE_FILES_LIST}; do + case "${file}" in + mnt/linux/*) + FILE_NAME="$(basename "${file}")" + tar -C "${DEPLOY_DIR_IMAGE}" --transform 's,^,mnt/linux/,' -uhf "${targzfile%.*}" "${FILE_NAME}" + ;; + *) + tar -C "${IMAGE_ROOTFS}" -uf "${targzfile%.*}" "${file}" + ;; + esac + done + + # Compress the tar file. + gzip "${targzfile%.*}" +} +ROOTFS_POSTPROCESS_COMMAND:append = "${@oe.utils.conditional('SWUPDATE_IS_FILES_UPDATE', 'true', ' create_swupdate_targz_file;', '', d)}" + +####################################### +###### SWU Update based on RDIFF ###### +####################################### + +create_swupdate_rdiff_file() { + local signature_file="${DEPLOY_DIR_IMAGE}/swupdate_rootfs_rdiff.sig" + local rootfs_rdiff_file="${DEPLOY_DIR_IMAGE}/${SWUPDATE_RDIFF_ROOTFS_DELTA_FILE_NAME}" + local rootfs_file="${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.squashfs" + + # Clean previous versions of the files. + rm -f "${signature_file}" "${rootfs_rdiff_file}" + + # Create signature file. + rdiff signature "${SWUPDATE_RDIFF_ROOTFS_SOURCE_FILE}" "${signature_file}" + + # Create the delta file. + rdiff delta "${signature_file}" "${rootfs_file}" "${rootfs_rdiff_file}" + + # Clean intermediates. + rm -f "${signature_file}" +} +IMAGE_POSTPROCESS_COMMAND:append = "${@oe.utils.conditional('SWUPDATE_IS_RDIFF_UPDATE', 'true', ' create_swupdate_rdiff_file;', '', d)}" diff --git a/meta-digi-dey/classes/trustfence.bbclass b/meta-digi-dey/classes/trustfence.bbclass index 6dabb0174..35597ecd8 100644 --- a/meta-digi-dey/classes/trustfence.bbclass +++ b/meta-digi-dey/classes/trustfence.bbclass @@ -24,7 +24,6 @@ TRUSTFENCE_SIGN_KEYS_PATH ?= "default" TRUSTFENCE_DEK_PATH ?= "default" TRUSTFENCE_DEK_PATH:ccmp1 ?= "0" TRUSTFENCE_ENCRYPT_ENVIRONMENT ?= "1" -TRUSTFENCE_ENCRYPT_ENVIRONMENT:ccmp1 ?= "0" TRUSTFENCE_SRK_REVOKE_MASK ?= "0x0" TRUSTFENCE_KEY_INDEX ?= "0" @@ -37,6 +36,79 @@ TRUSTFENCE_READ_ONLY_ROOTFS ?= "${@bb.utils.contains("IMAGE_FEATURES", "read-onl IMAGE_FEATURES += "dey-trustfence" +# Function to generate a PKI tree (with lock dir protection) +GENPKI_LOCK_DIR = "${TRUSTFENCE_SIGN_KEYS_PATH}/.genpki.lock" +gen_pki_tree() { + if mkdir -p ${GENPKI_LOCK_DIR}; then + if [ "${DEY_SOC_VENDOR}" = "NXP" ]; then + trustfence-gen-pki.sh ${TRUSTFENCE_SIGN_KEYS_PATH} + elif [ "${DEY_SOC_VENDOR}" = "STM" ]; then + export CONFIG_SIGN_KEYS_PATH="${TRUSTFENCE_SIGN_KEYS_PATH}" + trustfence-gen-pki.sh -p ${DIGI_SOM} + fi + rm -rf ${GENPKI_LOCK_DIR} + else + bbfatal "Could not get lock to generate PKI tree" + fi +} + +# Function that generates a PKI tree if there isn't one +check_gen_pki_tree() { + if [ "${DEY_SOC_VENDOR}" = "NXP" ]; then + SRK_KEYS="$(echo ${TRUSTFENCE_SIGN_KEYS_PATH}/crts/SRK*crt.pem | sed s/\ /\,/g)" + n_commas="$(echo ${SRK_KEYS} | grep -o "," | wc -l)" + if [ "${n_commas}" -eq 0 ]; then + gen_pki_tree + elif [ "${n_commas}" -ne 3 ]; then + bbfatal "Inconsistent PKI tree" + fi + elif [ "${DEY_SOC_VENDOR}" = "STM" ]; then + # The script that generates the PKI tree already checks if + # there isn't one, so there's nothing to do here but calling it. + gen_pki_tree + fi +} + +copy_public_key() { + if [ "${DEY_SOC_VENDOR}" = "NXP" ]; then + KEY_INDEX="$(expr $TRUSTFENCE_KEY_INDEX + 1)" + PUBLIC_KEY="${TRUSTFENCE_SIGN_KEYS_PATH}/crts/key${KEY_INDEX}.pub" + # The new hab/ahab_pki_tree.sh script extracts the public keys after the PKI + # generation and leaves them in the crts/ folder. However, the PKI tree may + # already exist, the PKI generation script not called, and then the public + # keys may not be available. This is a fall-back to generate at least the + # selected public key. + if [ ! -f "${PUBLIC_KEY}" ]; then + if [ "${TRUSTFENCE_SIGN_MODE}" = "HAB" ]; then + CERT_IMG="$(echo ${TRUSTFENCE_SIGN_KEYS_PATH}/crts/IMG${KEY_INDEX}*crt.pem)" + elif [ "${TRUSTFENCE_SIGN_MODE}" = "AHAB" ]; then + CERT_IMG="$(echo ${TRUSTFENCE_SIGN_KEYS_PATH}/crts/SRK${KEY_INDEX}*_ca_crt.pem)" + else + bberror "Unknown TRUSTFENCE_SIGN_MODE value" + exit 1 + fi + # Extract the public key from the certificate. + openssl x509 -pubkey -noout -in "${CERT_IMG}" > "${PUBLIC_KEY}" + fi + elif [ "${DEY_SOC_VENDOR}" = "STM" ]; then + if [ "${DIGI_SOM}" = "ccmp15" ]; then + PUBLIC_KEY="${TRUSTFENCE_SIGN_KEYS_PATH}/keys/publicKey.pem" + elif [ "${DIGI_SOM}" = "ccmp13" ]; then + PUBLIC_KEY="${TRUSTFENCE_SIGN_KEYS_PATH}/keys/publicKey0${TRUSTFENCE_KEY_INDEX}.pem" + else + bberror "Unknown DIGI_SOM" + exit 1 + fi + else + echo "ERROR: Cannot determine the public key" + exit 1 + fi + # Copy the public key to the rootfs + install -d ${IMAGE_ROOTFS}${sysconfdir}/ssl/certs + cp -f "${PUBLIC_KEY}" "${IMAGE_ROOTFS}${sysconfdir}/ssl/certs/key.pub" +} +ROOTFS_POSTPROCESS_COMMAND:append = " copy_public_key;" + python () { import binascii import hashlib @@ -77,7 +149,7 @@ python () { d.setVar("FIP_SIGN_ENABLE", "1") d.setVar("FIP_SIGN_KEY_EXTERNAL", "1") if (d.getVar("DIGI_SOM") == "ccmp15" ): - d.setVar("FIP_SIGN_KEY", d.getVar("TRUSTFENCE_SIGN_KEYS_PATH") + "/keys/privateKey00.pem"); + d.setVar("FIP_SIGN_KEY", d.getVar("TRUSTFENCE_SIGN_KEYS_PATH") + "/keys/privateKey.pem"); elif (d.getVar("DIGI_SOM") == "ccmp13" ): d.setVar("FIP_SIGN_KEY", d.getVar("TRUSTFENCE_SIGN_KEYS_PATH") + "/keys/privateKey0%s.pem" % d.getVar("TRUSTFENCE_KEY_INDEX")); d.setVar("TRUSTFENCE_PASSWORD_FILE", d.getVar("TRUSTFENCE_SIGN_KEYS_PATH") + "/keys/key_pass.txt") @@ -100,6 +172,8 @@ python () { if (d.getVar("TRUSTFENCE_ENCRYPT_ENVIRONMENT") == "1"): if (d.getVar("DEY_SOC_VENDOR") == "NXP"): d.appendVar("UBOOT_TF_CONF", "CONFIG_ENV_AES=y CONFIG_ENV_AES_CAAM_KEY=y ") + elif (d.getVar("DEY_SOC_VENDOR") == "STM"): + d.appendVar("UBOOT_TF_CONF", "CONFIG_ENV_AES_CCMP1=y ") # Provide sane default values for SWUPDATE class in case Trustfence is enabled if (d.getVar("TRUSTFENCE_SIGN") == "1"): @@ -140,25 +214,3 @@ python () { else: d.setVar("TRUSTFENCE_INITRAMFS_IMAGE", ""); } - -# Function to generate a PKI tree (with lock dir protection) -GENPKI_LOCK_DIR = "${TRUSTFENCE_SIGN_KEYS_PATH}/.genpki.lock" -gen_pki_tree() { - if mkdir -p ${GENPKI_LOCK_DIR}; then - trustfence-gen-pki.sh ${TRUSTFENCE_SIGN_KEYS_PATH} - rm -rf ${GENPKI_LOCK_DIR} - else - bbfatal "Could not get lock to generate PKI tree" - fi -} - -# Function that generates a PKI tree if there isn't one -check_gen_pki_tree() { - SRK_KEYS="$(echo ${TRUSTFENCE_SIGN_KEYS_PATH}/crts/SRK*crt.pem | sed s/\ /\,/g)" - n_commas="$(echo ${SRK_KEYS} | grep -o "," | wc -l)" - if [ "${n_commas}" -eq 0 ]; then - gen_pki_tree - elif [ "${n_commas}" -ne 3 ]; then - bbfatal "Inconsistent PKI tree" - fi -} diff --git a/meta-digi-dey/conf/distro/dey.conf b/meta-digi-dey/conf/distro/dey.conf index e6e8793e8..394cd3a93 100644 --- a/meta-digi-dey/conf/distro/dey.conf +++ b/meta-digi-dey/conf/distro/dey.conf @@ -1,8 +1,18 @@ require conf/distro/poky.conf +# Discrete version values. +YOCTO_MAJOR = "4" +YOCTO_MINOR = "0" +DEY_RELEASE = "4" +DEY_BUILD = "1" + +# Firmware version of the system. +DEY_FIRMWARE_VERSION ?= "${YOCTO_MAJOR}.${YOCTO_MINOR}.${DEY_RELEASE}.${DEY_BUILD}" + +# Distribution info. DISTRO = "dey" DISTRO_NAME = "Digi Embedded Yocto" -DISTRO_VERSION = "4.0-r3" +DISTRO_VERSION = "${YOCTO_MAJOR}.${YOCTO_MINOR}-r${DEY_RELEASE}" SDK_VENDOR = "-deysdk" @@ -61,3 +71,9 @@ LICENSE_FLAGS_ACCEPTED += "commercial" # Use systemd init manager by default INIT_MANAGER ?= "systemd" + +# Enable examples for some QT packages +PACKAGECONFIG:append:class-target:pn-qtbase = " examples" +PACKAGECONFIG:append:class-target:pn-qtdeclarative = " examples" +PACKAGECONFIG:append:class-target:pn-qtquick3d = " examples" +PACKAGECONFIG:append:class-target:pn-qtwebengine = " examples" diff --git a/meta-digi-dey/dynamic-layers/freescale-layer/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.4.3.p4.6-aarch32.bbappend b/meta-digi-dey/dynamic-layers/freescale-layer/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.4.3.p4.6-aarch32.bbappend new file mode 100644 index 000000000..7effe3064 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/freescale-layer/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.4.3.p4.6-aarch32.bbappend @@ -0,0 +1,5 @@ +# Copyright (C) 2023 Digi International + +# We configure imx-gpu-viv driver as built-in, so there's no need to install +# the module. +RRECOMMENDS:libgal-imx:remove:ccimx6 = "kernel-module-imx-gpu-viv" diff --git a/meta-digi-dey/dynamic-layers/meta-ml/recipes-devtools/flatbuffers/files/flatbuffers.pc.in b/meta-digi-dey/dynamic-layers/meta-ml/recipes-devtools/flatbuffers/files/flatbuffers.pc.in new file mode 100644 index 000000000..3a0666c3e --- /dev/null +++ b/meta-digi-dey/dynamic-layers/meta-ml/recipes-devtools/flatbuffers/files/flatbuffers.pc.in @@ -0,0 +1,7 @@ +Name: flatbuffers +Description: memory efficient serialization library +Version: @version@ +Requires: +Libs: -L@libdir@ -lflatbuffers +Cflags: -I@includedir@ + diff --git a/meta-digi-dey/dynamic-layers/meta-ml/recipes-devtools/flatbuffers/flatbuffers_2.%.bbappend b/meta-digi-dey/dynamic-layers/meta-ml/recipes-devtools/flatbuffers/flatbuffers_2.%.bbappend new file mode 100644 index 000000000..b7c5e09a5 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/meta-ml/recipes-devtools/flatbuffers/flatbuffers_2.%.bbappend @@ -0,0 +1,11 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/files:" + +SRC_URI:append = " file://flatbuffers.pc.in" + +do_install:append() { + install -D -m 0644 ${WORKDIR}/flatbuffers.pc.in ${D}${libdir}/pkgconfig/flatbuffers.pc + sed -i 's:@version@:${PV}:g + s:@libdir@:${libdir}:g + s:@includedir@:${includedir}:g' ${D}${libdir}/pkgconfig/flatbuffers.pc +} + diff --git a/meta-digi-dey/dynamic-layers/meta-ml/recipes-devtools/flatbuffers/flatbuffers_2.0.7.bb b/meta-digi-dey/dynamic-layers/meta-ml/recipes-devtools/flatbuffers/flatbuffers_2.0.7.bb new file mode 100644 index 000000000..1fe5facda --- /dev/null +++ b/meta-digi-dey/dynamic-layers/meta-ml/recipes-devtools/flatbuffers/flatbuffers_2.0.7.bb @@ -0,0 +1,34 @@ +SUMMARY = "Memory Efficient Serialization Library" +HOMEPAGE = "https://github.com/google/flatbuffers" +SECTION = "console/tools" +LICENSE = "Apache-2.0" + +PACKAGE_BEFORE_PN = "${PN}-compiler" +DEPENDS = "flatbuffers-native" + +RDEPENDS:${PN}-compiler = "${PN}" +RDEPENDS:${PN}-${PYTHON_PN} = "${PN}" +RDEPENDS:${PN}-dev += "${PN}-compiler" + +LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=3b83ef96387f14655fc854ddc3c6bd57" + +SRCREV = "8367664f15c3ea2ee58c67dacf9d630b49466de5" + +SRC_URI = "git://github.com/google/flatbuffers.git;branch=master;protocol=https" + +CVE_CHECK_IGNORE += "CVE-2020-35864" + +EXTRA_OECMAKE += "\ + -DFLATBUFFERS_BUILD_TESTS=OFF \ + -DFLATBUFFERS_BUILD_SHAREDLIB=ON \ +" + +EXTRA_OECMAKE:append:class-target = " -DFLATBUFFERS_FLATC_EXECUTABLE=${STAGING_BINDIR_NATIVE}/flatc" + +inherit cmake python3native + +S = "${WORKDIR}/git" + +FILES:${PN}-compiler = "${bindir}" + +BBCLASSEXTEND = "native nativesdk" diff --git a/meta-digi-dey/dynamic-layers/meta-ml/recipes-devtools/flatbuffers/python3-flatbuffers_2.0.7.bb b/meta-digi-dey/dynamic-layers/meta-ml/recipes-devtools/flatbuffers/python3-flatbuffers_2.0.7.bb new file mode 100644 index 000000000..151aa793b --- /dev/null +++ b/meta-digi-dey/dynamic-layers/meta-ml/recipes-devtools/flatbuffers/python3-flatbuffers_2.0.7.bb @@ -0,0 +1,14 @@ +SUMMARY = "Memory Efficient Serialization Library - Python3 Modules" +HOMEPAGE = "https://github.com/google/flatbuffers" +SECTION = "console/tools" +LICENSE = "Apache-2.0" + +LIC_FILES_CHKSUM = "file://../LICENSE.txt;md5=3b83ef96387f14655fc854ddc3c6bd57" + +SRCREV = "8367664f15c3ea2ee58c67dacf9d630b49466de5" +SRC_URI = "git://github.com/google/flatbuffers.git;branch=master;protocol=https" +S = "${WORKDIR}/git/python" + +RDEPENDS:${PN} = "flatbuffers" + +inherit setuptools3 \ No newline at end of file diff --git a/meta-digi-dey/dynamic-layers/meta-ml/recipes-fsl/packagegroup/packagegroup-imx-ml.bbappend b/meta-digi-dey/dynamic-layers/meta-ml/recipes-fsl/packagegroup/packagegroup-imx-ml.bbappend new file mode 100644 index 000000000..115c1e62a --- /dev/null +++ b/meta-digi-dey/dynamic-layers/meta-ml/recipes-fsl/packagegroup/packagegroup-imx-ml.bbappend @@ -0,0 +1,7 @@ +# Copyright 2023 Digi International Inc. + +# ARM ethos-u package +ETHOS_U_PKGS:append:mx93-nxp-bsp = " \ + eiq-examples \ + tensorflow-lite-ethosu-delegate \ +" diff --git a/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/deepview-rt/deepview-rt_2.4.46.1-aarch64.bb b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/deepview-rt/deepview-rt_2.4.46.1-aarch64.bb new file mode 100644 index 000000000..ec22eec23 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/deepview-rt/deepview-rt_2.4.46.1-aarch64.bb @@ -0,0 +1,57 @@ +DESCRIPTION = "This package includes the updated and experimental ModelRunner for TensorFlow Lite and ARM NN. Also in this repository is a pre-release of DeepViewRT with support for the OpenVX backend." +LICENSE = "Proprietary" +LIC_FILES_CHKSUM = "file://COPYING;md5=ea25d099982d035af85d193c88a1b479" + +DEPENDS = "python3 python3-pip-native" + +SRC_URI = "${FSL_MIRROR}/${BPN}-${PV}.bin;fsl-eula=true" +SRC_URI[md5sum] = "a4782e44df2254d30f7c6b0a45c4102e" +SRC_URI[sha256sum] = "40d6c12bbe5fc29a257a1717684ec650bd390eb1565c5bca82ec56e3ffbcf918" +S = "${WORKDIR}/${BPN}-${PV}" + +inherit fsl-eula-unpack python3native + +PACKAGECONFIG ?= "${PACKAGECONFIG_OPENVX}" +PACKAGECONFIG_OPENVX = "" +PACKAGECONFIG_OPENVX:mx8-nxp-bsp:imxgpu = "openvx" +PACKAGECONFIG_OPENVX:mx8mm-nxp-bsp = "" +# The tensorflow-lite implementation for 8ULP uses CPU, and so doesn't +# support OpenVX +PACKAGECONFIG_OPENVX:mx8ulp-nxp-bsp = "" + +PACKAGECONFIG[openvx] = ",,,libopenvx-imx" + +do_install () { + install -d ${D}${bindir} + install -d ${D}${libdir} + install -d ${D}${includedir} + install -d ${D}/${PYTHON_SITEPACKAGES_DIR} + + cp -r ${S}/modelrunner/bin/* ${D}${bindir} + cp -rP ${S}/modelrunner/lib/* ${D}${libdir} + cp -rP ${S}/${BPN}/lib/* ${D}${libdir} + cp -r ${S}/${BPN}/include/* ${D}${includedir} + if ${@bb.utils.contains('PACKAGECONFIG', 'openvx', 'false', 'true', d)} ; then + rm ${D}${libdir}/deepview-rt-openvx.so + fi + + ${STAGING_BINDIR_NATIVE}/pip3 install --disable-pip-version-check -v \ + -t ${D}/${PYTHON_SITEPACKAGES_DIR} --no-cache-dir --no-deps \ + ${S}/whl/deepview_rt-*.whl + + chown -R root:root "${D}" +} + +INHIBIT_PACKAGE_STRIP = "1" +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" +INHIBIT_SYSROOT_STRIP = "1" + +FILES_SOLIBSDEV = "" + +FILES:${PN} += "${libdir}/*" +RDEPENDS:${PN} = "onnxruntime tensorflow-lite" +INSANE_SKIP:${PN} += "dev-so dev-deps ldflags" + +BBCLASSEXTEND = "nativesdk" + +COMPATIBLE_MACHINE = "(mx8-nxp-bsp|mx9-nxp-bsp)" diff --git a/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/eiq-examples/eiq-examples_git.bb b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/eiq-examples/eiq-examples_git.bb new file mode 100644 index 000000000..127a68575 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/eiq-examples/eiq-examples_git.bb @@ -0,0 +1,28 @@ +SUMMARY = "The eiq examples based on Tf-lite" +DESCRIPTION = "The eiq examples based on Tf-lite" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=86d3f3a95c324c9479bd8986968f4327" + +SRC_URI = "${EIQ_EXAMPLES_SRC};branch=${SRCBRANCH}" +EIQ_EXAMPLES_SRC ?= "git://github.com/nxp-imx/eiq-example.git;protocol=https" +SRCBRANCH = "lf-6.1.1_1.0.0" +SRCREV = "798519ee033fb7a5aef989a793afe16f400d6479" + +S = "${WORKDIR}/git" + +do_install () { + # install scripts to /usr/bin + install -d ${D}${bindir}/${PN}-${PV}/ + cp ${S}/download_models.py ${D}${bindir}/${PN}-${PV}/ + cp -r ${S}/dms ${D}${bindir}/${PN}-${PV}/ + cp -r ${S}/face_recognition ${D}${bindir}/${PN}-${PV}/ + cp -r ${S}/image_classification ${D}${bindir}/${PN}-${PV}/ + cp -r ${S}/object_detection ${D}${bindir}/${PN}-${PV}/ + cp -r ${S}/gesture_detection ${D}${bindir}/${PN}-${PV}/ +} + +RDEPENDS:${PN} = "python3 python3-numpy python3-pillow python3-requests \ + python3-opencv python3-pillow tensorflow-lite" + +#Only support imx93 currently, will add other plantform support. +COMPATIBLE_MACHINE = "(mx93-nxp-bsp)" diff --git a/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/ethos-u-driver-stack/ethos-u-driver-stack_22.08.bbappend b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/ethos-u-driver-stack/ethos-u-driver-stack_22.08.bbappend new file mode 100644 index 000000000..7056e97c0 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/ethos-u-driver-stack/ethos-u-driver-stack_22.08.bbappend @@ -0,0 +1,6 @@ +# Copyright (C) 2023 Digi International + +LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=e3fc50a88d0a364313df4b21ef20c29e" + +SRCBRANCH = "lf-6.1.1_1.0.0" +SRCREV = "ca1a424bcd00758e0b50043ac7f8a3ff214e9ed8" diff --git a/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/ethos-u-driver-stack/ethos-u-firmware/ccimx93/ethosu_firmware b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/ethos-u-driver-stack/ethos-u-firmware/ccimx93/ethosu_firmware new file mode 100755 index 000000000..cac0eee6a Binary files /dev/null and b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/ethos-u-driver-stack/ethos-u-firmware/ccimx93/ethosu_firmware differ diff --git a/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/ethos-u-driver-stack/ethos-u-firmware_22.08.bbappend b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/ethos-u-driver-stack/ethos-u-firmware_22.08.bbappend new file mode 100644 index 000000000..abb93bf82 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/ethos-u-driver-stack/ethos-u-firmware_22.08.bbappend @@ -0,0 +1,12 @@ +# Copyright 2023 Digi International Inc. + +FILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}:" + +# Use our custom ethosu_firmware without debug port; keep the commented info for traceability +#SRCBRANCH = "lf-6.1.1_1.0.0" +#SRCREV = "c80a413664f650c366fc4721474a3fe1d1503eb5" +SRC_URI:append:ccimx93 = " file://ethosu_firmware" + +do_install:append:ccimx93 () { + install -m 0644 ${WORKDIR}/ethosu_firmware ${D}${nonarch_base_libdir}/firmware +} diff --git a/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/ethos-u-vela/ethos-u-vela_3.6.0.bb b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/ethos-u-vela/ethos-u-vela_3.6.0.bb new file mode 100644 index 000000000..031be0fda --- /dev/null +++ b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/ethos-u-vela/ethos-u-vela_3.6.0.bb @@ -0,0 +1,28 @@ +# Copyright 2022 NXP +DESCRIPTION = "The vela tool is used to compile a TensorFlow Lite for \ +Microcontrollers neural network model into an optimised version that \ +can run on an embedded system containing an Arm Ethos-U NPU" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=e3fc50a88d0a364313df4b21ef20c29e" +DEPENDS = "python3-pip-native python3-wheel-native flatbuffers python3-numpy python3-lxml" + +SRC_URI = "${VELA_SRC};branch=${SRCBRANCH}" +VELA_SRC ?= "git://github.com/nxp-imx/ethos-u-vela.git;protocol=https" +SRCBRANCH = "lf-6.1.1_1.0.0" +SRCREV = "8b138a2e6880e31bd199764db9c5177c46bd5579" + +S = "${WORKDIR}/git" + +inherit setuptools3 + +do_compile[network] = "1" +do_compile:prepend() { + export HTTP_PROXY=${http_proxy} + export HTTPS_PROXY=${https_proxy} + export http_proxy=${http_proxy} + export https_proxy=${https_proxy} +} + +RDEPENDS:${PN} += "flatbuffers python3-numpy python3-lxml" + +COMPATIBLE_MACHINE = "(mx93-nxp-bsp)" diff --git a/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/onnxruntime/onnxruntime_1.10.0.bbappend b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/onnxruntime/onnxruntime_1.10.0.bbappend new file mode 100644 index 000000000..c21ee1e10 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/onnxruntime/onnxruntime_1.10.0.bbappend @@ -0,0 +1,8 @@ +# Copyright (C) 2023 Digi International + +SRCBRANCH_runtime:ccimx93 = "lf-6.1.1_1.0.0" +SRCREV_runtime:ccimx93 = "66e3e9a93840ed1e55dc2d7e894c0ae26fb0e51e" + +# Updated flatbuffers recipe for ccimx93, renamed the runtime python package +PYTHON_RDEPENDS:remove:ccimx93 = "flatbuffers-${PYTHON_PN}" +PYTHON_RDEPENDS:append:ccimx93 = " ${PYTHON_PN}-flatbuffers" diff --git a/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/tensorflow-lite/tensorflow-lite-2.10.0.inc b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/tensorflow-lite/tensorflow-lite-2.10.0.inc new file mode 100644 index 000000000..007d1ac97 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/tensorflow-lite/tensorflow-lite-2.10.0.inc @@ -0,0 +1,5 @@ +# Copyright 2020-2021 NXP + +TENSORFLOW_LITE_SRC ?= "git://github.com/nxp-imx/tensorflow-imx.git;protocol=https" +SRCBRANCH_tf = "lf-6.1.1_1.0.0" +SRCREV_tf = "6cac366ef5b7e632305c2413875ce2d3b72c03dd" diff --git a/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/tensorflow-lite/tensorflow-lite-ethosu-delegate_2.10.0.bb b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/tensorflow-lite/tensorflow-lite-ethosu-delegate_2.10.0.bb new file mode 100644 index 000000000..a0de103d8 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/tensorflow-lite/tensorflow-lite-ethosu-delegate_2.10.0.bb @@ -0,0 +1,61 @@ +# Copyright 2020-2023 NXP +DESCRIPTION = "TensorFlow Lite Ethos-u Delegate" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=86d3f3a95c324c9479bd8986968f4327" + +DEPENDS = "tensorflow-lite ethos-u-driver-stack" + +require tensorflow-lite-${PV}.inc + +TENSORFLOW_LITE_ETHOSU_DELEGATE_SRC ?= "git://github.com/nxp-imx/tflite-ethosu-delegate-imx.git;protocol=https" +SRCBRANCH_ethosu = "lf-6.1.1_1.0.0" +SRCREV_ethosu = "4bd28d3e64d26f4d5b5ee358036b2d06f3322a57" + +SRCREV_FORMAT = "ethosu_tf" + +SRC_URI = "${TENSORFLOW_LITE_ETHOSU_DELEGATE_SRC};branch=${SRCBRANCH_ethosu};name=ethosu \ + ${TENSORFLOW_LITE_SRC};branch=${SRCBRANCH_tf};name=tf;destsuffix=tfgit \ +" + +S = "${WORKDIR}/git" + +inherit python3native cmake + +EXTRA_OECMAKE = "-DCMAKE_SYSROOT=${PKG_CONFIG_SYSROOT_DIR}" +EXTRA_OECMAKE += " \ + -DFETCHCONTENT_FULLY_DISCONNECTED=OFF \ + -DFETCHCONTENT_SOURCE_DIR_TENSORFLOW=${WORKDIR}/tfgit \ + -DTFLITE_LIB_LOC=${STAGING_DIR_HOST}/usr/lib/libtensorflow-lite.so \ + ${S} \ +" + +CXXFLAGS += "-fPIC" + +do_configure[network] = "1" +do_configure:prepend() { + export HTTP_PROXY=${http_proxy} + export HTTPS_PROXY=${https_proxy} + export http_proxy=${http_proxy} + export https_proxy=${https_proxy} + + # There is no Fortran compiler in the toolchain, but bitbake sets this variable anyway + # with unavailable binary. + export FC="" +} + +do_install() { + # install libraries + install -d ${D}${libdir} + for lib in ${B}/lib*.so* + do + cp --no-preserve=ownership -d $lib ${D}${libdir} + done +} + +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" + +# Output library is unversioned +SOLIBS = ".so" +FILES_SOLIBSDEV = "" + +COMPATIBLE_MACHINE = "(mx93-nxp-bsp)" diff --git a/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/tensorflow-lite/tensorflow-lite-host-tools_2.10.0.bb b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/tensorflow-lite/tensorflow-lite-host-tools_2.10.0.bb new file mode 100644 index 000000000..191ddc0ad --- /dev/null +++ b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/tensorflow-lite/tensorflow-lite-host-tools_2.10.0.bb @@ -0,0 +1,29 @@ +# Copyright 2022 NXP +DESCRIPTION = "Host tools required for build of TensorFlow Lite C++ Library unit tests and Evaluation Tools" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=4158a261ca7f2525513e31ba9c50ae98" + +require tensorflow-lite-${PV}.inc +SRC_URI = "${TENSORFLOW_LITE_SRC};branch=${SRCBRANCH_tf};name=tf" + +inherit cmake + +S = "${WORKDIR}/git" +OECMAKE_SOURCEPATH = "${S}/tensorflow/lite/tools/cmake/native_tools" + +BBCLASSEXTEND = "native nativesdk" + +EXTRA_OECMAKE = " \ + -DFETCHCONTENT_FULLY_DISCONNECTED=OFF \ + -DCMAKE_SYSROOT=${PKG_CONFIG_SYSROOT_DIR} \ +" + +CXXFLAGS += "-fPIC" + +do_configure[network] = "1" +do_configure:prepend() { + export HTTP_PROXY=${http_proxy} + export HTTPS_PROXY=${https_proxy} + export http_proxy=${http_proxy} + export https_proxy=${https_proxy} +} \ No newline at end of file diff --git a/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/tensorflow-lite/tensorflow-lite/tensorflow-lite.pc.in b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/tensorflow-lite/tensorflow-lite/tensorflow-lite.pc.in new file mode 100644 index 000000000..1d3a96419 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/tensorflow-lite/tensorflow-lite/tensorflow-lite.pc.in @@ -0,0 +1,6 @@ + Name: tensorflow lite + Description: tensorflow lite static library + Version: @version@ + Requires: + Libs: -L@libdir@ -ltensorflow-lite -lrt + Cflags: -I@includedir@ diff --git a/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/tensorflow-lite/tensorflow-lite_2.%.bbappend b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/tensorflow-lite/tensorflow-lite_2.%.bbappend new file mode 100644 index 000000000..13b6d3f84 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/tensorflow-lite/tensorflow-lite_2.%.bbappend @@ -0,0 +1,12 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" + +SRC_URI:append = " file://tensorflow-lite.pc.in" + +do_install:append() { + install -d ${D}${libdir}/pkgconfig + install -m 0644 ${WORKDIR}/tensorflow-lite.pc.in ${D}${libdir}/pkgconfig/tensorflow2-lite.pc + + sed -i 's:@version@:${PV}:g + s:@libdir@:${libdir}:g + s:@includedir@:${includedir}:g' ${D}${libdir}/pkgconfig/tensorflow2-lite.pc +} diff --git a/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/tensorflow-lite/tensorflow-lite_2.10.0.bb b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/tensorflow-lite/tensorflow-lite_2.10.0.bb new file mode 100644 index 000000000..a72ac949f --- /dev/null +++ b/meta-digi-dey/dynamic-layers/meta-ml/recipes-libraries/tensorflow-lite/tensorflow-lite_2.10.0.bb @@ -0,0 +1,132 @@ +# Copyright 2020-2021 NXP +DESCRIPTION = "TensorFlow Lite C++ Library" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=4158a261ca7f2525513e31ba9c50ae98" + + +DEPENDS = "flatbuffers python3-numpy-native python3-pip-native python3-pybind11-native python3-wheel-native unzip-native \ + python3 tensorflow-protobuf jpeg zlib ${BPN}-host-tools-native" + +require tensorflow-lite-${PV}.inc +SRC_URI = "${TENSORFLOW_LITE_SRC};branch=${SRCBRANCH_tf};name=tf" + +SRC_URI += "https://storage.googleapis.com/download.tensorflow.org/models/mobilenet_v1_2018_08_02/mobilenet_v1_1.0_224_quant.tgz;name=model-mobv1" +SRC_URI[model-mobv1.md5sum] = "36af340c00e60291931cb30ce32d4e86" +SRC_URI[model-mobv1.sha256sum] = "d32432d28673a936b2d6281ab0600c71cf7226dfe4cdcef3012555f691744166" + +S = "${WORKDIR}/git" + +inherit python3native cmake + +PACKAGECONFIG ??= "${PACKAGECONFIG_ETHOSU}" +PACKAGECONFIG_ETHOSU = "" +PACKAGECONFIG_ETHOSU:mx93-nxp-bsp = "ethosu" + +PACKAGECONFIG[ethosu] = "-DTFLITE_ENABLE_ETHOSU=on,-DTFLITE_ENABLE_ETHOSU=off,ethos-u-driver-stack" + +EXTRA_OECMAKE = " \ + -DCMAKE_SYSROOT=${PKG_CONFIG_SYSROOT_DIR} \ + -DFETCHCONTENT_FULLY_DISCONNECTED=OFF \ + -DTFLITE_EVAL_TOOLS=on \ + -DTFLITE_HOST_TOOLS_DIR=${STAGING_BINDIR_NATIVE} \ + -DTFLITE_BUILD_SHARED_LIB=on \ + -DTFLITE_ENABLE_NNAPI=off \ + -DTFLITE_ENABLE_NNAPI_VERBOSE_VALIDATION=on \ + -DTFLITE_ENABLE_RUY=on \ + -DTFLITE_ENABLE_XNNPACK=on \ + -DTFLITE_PYTHON_WRAPPER_BUILD_CMAKE2=on \ + -DTFLITE_ENABLE_EXTERNAL_DELEGATE=on \ + ${S}/tensorflow/lite/ \ +" +EXTRA_OECMAKE_BUILD = "benchmark_model label_image" + +CXXFLAGS += "-fPIC" + +do_configure[network] = "1" +do_configure:prepend() { + export HTTP_PROXY=${http_proxy} + export HTTPS_PROXY=${https_proxy} + export http_proxy=${http_proxy} + export https_proxy=${https_proxy} + + # There is no Fortran compiler in the toolchain, but bitbake sets this variable anyway + # with unavailable binary. + export FC="" +} + + +do_compile:append () { + # build pip package + cd ${B} + CI_BUILD_PYTHON=${PYTHON} BUILD_NUM_JOBS=8 ${S}/tensorflow/lite/tools/pip_package/build_pip_package_with_cmake2.sh ${TARGET_ARCH} +} + +do_install() { + # install libraries + install -d ${D}${libdir} + for lib in ${B}/lib*.so* + do + cp --no-preserve=ownership -d $lib ${D}${libdir} + done + + # install header files + install -d ${D}${includedir}/tensorflow/lite + cd ${S}/tensorflow/lite + cp --parents \ + $(find . -name "*.h*") \ + ${D}${includedir}/tensorflow/lite + + # install version.h from core + install -d ${D}${includedir}/tensorflow/core/public + cp ${S}/tensorflow/core/public/version.h ${D}${includedir}/tensorflow/core/public + + # install examples + install -d ${D}${bindir}/${PN}-${PV}/examples + install -m 0555 ${B}/examples/label_image/label_image ${D}${bindir}/${PN}-${PV}/examples + install -m 0555 ${B}/tools/benchmark/benchmark_model ${D}${bindir}/${PN}-${PV}/examples + install -m 0555 ${B}/tools/evaluation/coco_object_detection_run_eval ${D}${bindir}/${PN}-${PV}/examples + install -m 0555 ${B}/tools/evaluation/imagenet_image_classification_run_eval ${D}${bindir}/${PN}-${PV}/examples + install -m 0555 ${B}/tools/evaluation/inference_diff_run_eval ${D}${bindir}/${PN}-${PV}/examples + + # install label_image data + cp ${S}/tensorflow/lite/examples/label_image/testdata/grace_hopper.bmp ${D}${bindir}/${PN}-${PV}/examples + cp ${S}/tensorflow/lite/java/ovic/src/testdata/labels.txt ${D}${bindir}/${PN}-${PV}/examples + + + # Install python example + cp ${S}/tensorflow/lite/examples/python/label_image.py ${D}${bindir}/${PN}-${PV}/examples + + # Install mobilenet tflite file + cp ${WORKDIR}/mobilenet_*.tflite ${D}${bindir}/${PN}-${PV}/examples + + # Install pip package + install -d ${D}/${PYTHON_SITEPACKAGES_DIR} + ${STAGING_BINDIR_NATIVE}/pip3 install --disable-pip-version-check -vvv --platform linux_${TARGET_ARCH} \ + -t ${D}/${PYTHON_SITEPACKAGES_DIR} --no-cache-dir --no-deps \ + ${B}/tflite_pip/dist/tflite_runtime-*.whl +} + +RDEPENDS:${PN} = " \ + python3 \ + python3-numpy \ + ${RDEPENDS_OPENVX} \ +" +RDEPENDS_OPENVX = "" +RDEPENDS_OPENVX:mx8-nxp-bsp:imxgpu = "libnn-imx nn-imx" +RDEPENDS_OPENVX:mx8mm-nxp-bsp = "" +# The tensorflow-lite implementation for 8ULP uses CPU, and so doesn't +# support OpenVX +RDEPENDS_OPENVX:mx8ulp-nxp-bsp = "" + +# TensorFlow and TensorFlow Lite both exports few files, suppress the error +# SSTATE_ALLOW_OVERLAP_FILES = "${D}${includedir}" +SSTATE_ALLOW_OVERLAP_FILES = "/" + +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" + +INSANE_SKIP:${PN} += " \ + already-stripped \ + staticdev \ +" + +FILES:${PN} += "${libdir}/python*" diff --git a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-fsl/packagegroup/packagegroup-qt6-demos.bb b/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-fsl/packagegroup/packagegroup-qt6-demos.bb deleted file mode 100644 index 044dcc8d7..000000000 --- a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-fsl/packagegroup/packagegroup-qt6-demos.bb +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (C) 2014 Freescale Semiconductor -# Copyright 2017-2018, 2020 NXP -# Released under the MIT license (see COPYING.MIT for the terms) - -DESCRIPTION = "Package group for Qt6 demos" -LICENSE = "MIT" - -inherit packagegroup - -RDEPENDS:${PN}:append = " \ - qtbase-examples \ - qtdeclarative-examples \ -" - -RDEPENDS:${PN}:append:imxgpu = " \ - cinematicexperience-rhi \ - cinematicexperience-rhi-tools \ -" - -RDEPENDS:${PN}:append:ccimx93 = " \ - cinematicexperience-rhi \ - cinematicexperience-rhi-tools \ -" - -RDEPENDS:${PN}:append:imxgpu3d = " \ - qt3d-examples \ -" diff --git a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-fsl/packagegroup/packagegroup-qt6-dey.bb b/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-fsl/packagegroup/packagegroup-qt6-dey.bb deleted file mode 100644 index d839fab74..000000000 --- a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-fsl/packagegroup/packagegroup-qt6-dey.bb +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2019-20 NXP -# Released under the MIT license (see COPYING.MIT for the terms) - -DESCRIPTION = "Package group for i.MX Qt6" -LICENSE = "MIT" - -PACKAGE_ARCH = "${TUNE_PKGARCH}" - -inherit packagegroup - -# Install Freescale QT demo applications -QT6_IMAGE_INSTALL_APPS = "" -#QT6_IMAGE_INSTALL_APPS:imxgpu3d = "${@bb.utils.contains("MACHINE_GSTREAMER_1_0_PLUGIN", "imx-gst1.0-plugin", "imx-qtapplications", "", d)}" - -# Install fonts -QT6_FONTS = "ttf-dejavu-common ttf-dejavu-sans ttf-dejavu-sans-mono ttf-dejavu-serif " - -# Install qtquick3d -QT6_QTQUICK3D = "qtquick3d qtquick3d-examples" - -QT6_IMAGE_INSTALL = "" -QT6_IMAGE_INSTALL_common = " \ - packagegroup-qt6-demos \ - ${QT6_QTQUICK3D} \ - ${QT6_FONTS} \ - ${QT6_IMAGE_INSTALL_APPS} \ - ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'libxkbcommon', '', d)} \ - ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'qtwayland qtwayland-plugins', '', d)}\ - " -QT6_IMAGE_INSTALL:imxgpu2d = "${@bb.utils.contains('DISTRO_FEATURES', 'x11','${QT6_IMAGE_INSTALL_common}', \ - 'qtbase qtbase-plugins', d)}" - -QT6_IMAGE_INSTALL:imxpxp = "${@bb.utils.contains('DISTRO_FEATURES', 'x11','${QT6_IMAGE_INSTALL_common}', \ - 'qtbase qtbase-examples qtbase-plugins', d)}" - -QT6_IMAGE_INSTALL:imxgpu3d = " \ - ${QT6_IMAGE_INSTALL_common} \ -" -RDEPENDS:${PN} += " \ - ${QT6_IMAGE_INSTALL} \ -" diff --git a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qt3d_%.bbappend b/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qt3d_%.bbappend deleted file mode 100644 index ca240e412..000000000 --- a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qt3d_%.bbappend +++ /dev/null @@ -1,7 +0,0 @@ -PACKAGECONFIG += "examples" - -do_install:append() { -if ls ${D}${libdir}/pkgconfig/Qt6*.pc >/dev/null 2>&1; then - sed -i 's,-L${STAGING_DIR_HOST}/usr/lib,,' ${D}${libdir}/pkgconfig/Qt6*.pc -fi -} diff --git a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase/0001-egl.prf-Fix-build-error-when-egl-headers-need-platfo.patch b/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase/0001-egl.prf-Fix-build-error-when-egl-headers-need-platfo.patch deleted file mode 100644 index 2a345f4cd..000000000 --- a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase/0001-egl.prf-Fix-build-error-when-egl-headers-need-platfo.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 3f9703fecd670b36030e1093466f6d11b370c19f Mon Sep 17 00:00:00 2001 -From: Yuqing Zhu -Date: Mon, 27 Mar 2017 15:33:35 +0800 -Subject: [PATCH] egl.prf: Fix build error when egl headers need platform - definition - -Gain the value through pkg-config and pass it through QMAKE_CFLAGS_EGL. - -Upstream-Status: Pending [https://bugreports.qt.io/browse/QTBUG-61712] - -Signed-off-by: Yuqing Zhu ---- - mkspecs/features/egl.prf | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/mkspecs/features/egl.prf b/mkspecs/features/egl.prf -index 9fa0c9e..85d5852 100644 ---- a/mkspecs/features/egl.prf -+++ b/mkspecs/features/egl.prf -@@ -1,3 +1,9 @@ -+# egl headers need a definition -+PKG_CONFIG = $$pkgConfigExecutable() -+PKGCONFIG_CFLAGS = $$system($$PKG_CONFIG --cflags egl) -+PKGCONFIG_CFLAGS = $$find(PKGCONFIG_CFLAGS, ^-D.*) -+QMAKE_CFLAGS_EGL = $$PKGCONFIG_CFLAGS -+ - INCLUDEPATH += $$QMAKE_INCDIR_EGL - LIBS_PRIVATE += $$QMAKE_LIBS_EGL - QMAKE_CFLAGS += $$QMAKE_CFLAGS_EGL --- -1.9.1 - diff --git a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase/0014-Add-IMX-GPU-support.patch b/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase/0014-Add-IMX-GPU-support.patch deleted file mode 100644 index e86d9ed54..000000000 --- a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase/0014-Add-IMX-GPU-support.patch +++ /dev/null @@ -1,14 +0,0 @@ -Index: git/mkspecs/linux-oe-g++/qmake.conf -=================================================================== ---- git.orig/mkspecs/linux-oe-g++/qmake.conf 2017-06-26 10:20:57.139653321 -0500 -+++ git/mkspecs/linux-oe-g++/qmake.conf 2017-06-26 10:30:12.000000000 -0500 -@@ -39,5 +39,9 @@ - - include(../oe-device-extra.pri) - -+QMAKE_LIBS_EGL += -lEGL -+QMAKE_LIBS_OPENGL_ES2 += -lEGL -lGLESv2 -+QMAKE_LIBS_OPENVG += -lEGL -lOpenVG -+ - load(device_config) - load(qt_config) diff --git a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase/qt6-fb.sh b/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase/qt-eglfs.sh similarity index 100% rename from meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase/qt6-fb.sh rename to meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase/qt-eglfs.sh diff --git a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase/qt-linuxfb.sh b/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase/qt-linuxfb.sh new file mode 100644 index 000000000..668167838 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase/qt-linuxfb.sh @@ -0,0 +1,8 @@ +#!/bin/sh +if test -z $XDG_RUNTIME_DIR; then + export XDG_RUNTIME_DIR=/run/user/$(id -u) + if [ ! -d $XDG_RUNTIME_DIR ]; then + mkdir -m 700 -p $XDG_RUNTIME_DIR + fi +fi +export QT_QPA_PLATFORM=linuxfb diff --git a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase/qt6-wayland.sh b/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase/qt-wayland.sh similarity index 100% rename from meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase/qt6-wayland.sh rename to meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase/qt-wayland.sh diff --git a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase/qt6-x11.sh b/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase/qt-x11.sh similarity index 100% rename from meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase/qt6-x11.sh rename to meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase/qt-x11.sh diff --git a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase_%.bbappend b/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase_%.bbappend index deb2b0c9f..13632bfbe 100644 --- a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase_%.bbappend +++ b/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtbase_%.bbappend @@ -1,74 +1,75 @@ # Copyright (C) 2013 Eric Bénard - Eukréa Electromatique -# Copyright (C) 2016 O.S. Systems Software LTDA. # Copyright (C) 2016 Freescale Semiconductor -# Copyright 2017-2021 NXP +# Copyright (C) 2016, 2017 O.S. Systems Software LTDA. +# Copyright (C) 2017-2018 NXP -### Copy qtbase bbappend from meta-freescale +PACKAGECONFIG_GRAPHICS:imxpxp = " \ + gles2" +PACKAGECONFIG_GRAPHICS:imxgpu2d = " \ + ${@bb.utils.contains('DISTRO_FEATURES', 'x11', ' gl', '', d)} \ + ${PACKAGECONFIG_GRAPHICS_IMX_GPU}" +PACKAGECONFIG_GRAPHICS:imxgpu3d = " \ + gles2 \ + ${PACKAGECONFIG_GRAPHICS_IMX_GPU}" +PACKAGECONFIG_GRAPHICS_IMX_GPU = "" +PACKAGECONFIG_GRAPHICS_IMX_GPU:mx8-nxp-bsp = " \ + gbm kms" -FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" +PACKAGECONFIG_GRAPHICS:use-mainline-bsp ?= " \ + gles2 gbm kms" -SRC_URI:append:imxgpu = " \ - file://0014-Add-IMX-GPU-support.patch \ - file://0001-egl.prf-Fix-build-error-when-egl-headers-need-platfo.patch \ -" +PACKAGECONFIG += " \ + ${PACKAGECONFIG_PLATFORM}" -PACKAGECONFIG_GRAPHICS_IMX_GPU = "" -PACKAGECONFIG_GRAPHICS_IMX_GPU:mx8-nxp-bsp = "gbm kms" - -PACKAGECONFIG_GRAPHICS:imxpxp = "gles2" -PACKAGECONFIG_GRAPHICS:imxgpu2d = "${@bb.utils.contains('DISTRO_FEATURES', 'x11', ' gl', '', d)} \ - ${PACKAGECONFIG_GRAPHICS_IMX_GPU}" -PACKAGECONFIG_GRAPHICS:imxgpu3d = "gles2 \ - ${PACKAGECONFIG_GRAPHICS_IMX_GPU}" -PACKAGECONFIG_GRAPHICS:use-mainline-bsp ?= "gles2 gbm kms" - -PACKAGECONFIG_PLATFORM = "" -PACKAGECONFIG_PLATFORM:imxgpu2d = "no-opengl linuxfb" +PACKAGECONFIG_PLATFORM = "" +PACKAGECONFIG_PLATFORM:imxgpu2d = " \ + no-opengl \ + linuxfb \ + ${PACKAGECONFIG_PLATFORM_EGLFS}" PACKAGECONFIG_PLATFORM:imxgpu3d = " \ + ${PACKAGECONFIG_PLATFORM_EGLFS}" + +PACKAGECONFIG_PLATFORM_EGLFS = "" +PACKAGECONFIG_PLATFORM_EGLFS:imxgpu3d = " \ ${@bb.utils.contains('DISTRO_FEATURES', 'x11', '', \ bb.utils.contains('DISTRO_FEATURES', 'wayland', '', \ 'eglfs', d), d)}" -PACKAGECONFIG_PLATFORM:use-mainline-bsp = "${@bb.utils.contains('DISTRO_FEATURES', 'x11', '', 'eglfs', d)}" -PACKAGECONFIG += "${PACKAGECONFIG_PLATFORM}" +PACKAGECONFIG_PLATFORM_EGLFS:mx8-nxp-bsp = " \ + eglfs" -PACKAGECONFIG_VULKAN_IMX_GPU = "" +PACKAGECONFIG_PLATFORM:use-mainline-bsp = " \ + ${@bb.utils.contains('DISTRO_FEATURES', 'x11', '', 'eglfs', d)}" + +PACKAGECONFIG += " \ + ${@bb.utils.contains('DISTRO_FEATURES', 'vulkan', '${PACKAGECONFIG_VULKAN}', '', d)}" +PACKAGECONFIG_VULKAN = "" +PACKAGECONFIG_VULKAN:imxgpu = " \ + ${PACKAGECONFIG_VULKAN_IMX_GPU}" +PACKAGECONFIG_VULKAN_IMX_GPU = "" PACKAGECONFIG_VULKAN_IMX_GPU:mx8-nxp-bsp = "vulkan" PACKAGECONFIG_VULKAN_IMX_GPU:mx8mm-nxp-bsp = "" -PACKAGECONFIG_VULKAN = "" -PACKAGECONFIG_VULKAN:imxgpu = "${PACKAGECONFIG_VULKAN_IMX_GPU}" -PACKAGECONFIG += "${@bb.utils.contains('DISTRO_FEATURES', 'vulkan', '${PACKAGECONFIG_VULKAN}', '', d)}" -##### End of meta-freescale qtbase bbappend +# +# FROM meta-imx +# +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" + +SRC_URI += "file://qt-${IMX_BACKEND}.sh" IMX_BACKEND = \ - "${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland',\ - bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', \ - 'fb', d), d)}" - -SRC_URI:append = " \ - file://qt6-${IMX_BACKEND}.sh \ -" - -PACKAGECONFIG += "examples" - -PACKAGECONFIG_PLATFORM_IMX_GPU = "" -PACKAGECONFIG_PLATFORM_IMX_GPU:mx8-nxp-bsp = "eglfs" -PACKAGECONFIG_PLATFORM:imxgpu2d += "${PACKAGECONFIG_PLATFORM_IMX_GPU}" -PACKAGECONFIG_PLATFORM:imxgpu3d += "${PACKAGECONFIG_PLATFORM_IMX_GPU}" - -PARALLEL_MAKEINST = "" -PARALLEL_MAKE:task-install = "${PARALLEL_MAKEINST}" + "${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland', \ + bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', \ + '${IMX_BACKEND_FB}', d), d)}" +IMX_BACKEND_FB = "linuxfb" +IMX_BACKEND_FB:imxgpu3d = "eglfs" do_install:append () { - if ls ${D}${libdir}/pkgconfig/Qt6*.pc >/dev/null 2>&1; then - sed -i 's,-L${STAGING_DIR_HOST}/usr/lib,,' ${D}${libdir}/pkgconfig/Qt6*.pc - fi install -d ${D}${sysconfdir}/profile.d/ - install -m 0755 ${WORKDIR}/qt6-${IMX_BACKEND}.sh ${D}${sysconfdir}/profile.d/qt6.sh + install -m 0755 ${WORKDIR}/qt-${IMX_BACKEND}.sh ${D}${sysconfdir}/profile.d/qt.sh } do_install:append:ccimx93() { - echo "export QMLSCENE_DEVICE=softwarecontext" >> ${D}${sysconfdir}/profile.d/qt6.sh + if ! grep -qs "^export QMLSCENE_DEVICE=softwarecontext" ${D}${sysconfdir}/profile.d/qt.sh; then + echo "export QMLSCENE_DEVICE=softwarecontext" >> ${D}${sysconfdir}/profile.d/qt.sh + fi } - -FILES:${PN} += "${sysconfdir}/profile.d/qt5.sh" diff --git a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtdeclarative_%.bbappend b/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtdeclarative_%.bbappend deleted file mode 100644 index fa6fdc8de..000000000 --- a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtdeclarative_%.bbappend +++ /dev/null @@ -1,10 +0,0 @@ -PACKAGECONFIG:append:class-target = " examples" - -PARALLEL_MAKEINST = "" -PARALLEL_MAKE:task-install = "${PARALLEL_MAKEINST}" - -do_install:append() { -if ls ${D}${libdir}/pkgconfig/Qt6*.pc >/dev/null 2>&1; then - sed -i 's,-L${STAGING_DIR_HOST}/usr/lib,,' ${D}${libdir}/pkgconfig/Qt6*.pc -fi -} diff --git a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtmultimedia_%.bbappend b/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtmultimedia_%.bbappend index a0f8891f0..4b7a78ba8 100644 --- a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtmultimedia_%.bbappend +++ b/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtmultimedia_%.bbappend @@ -1,6 +1,8 @@ -do_install:append() { -if ls ${D}${libdir}/pkgconfig/Qt6*.pc >/dev/null 2>&1; then - sed -i 's,-L${STAGING_DIR_HOST}/usr/lib,,' ${D}${libdir}/pkgconfig/Qt6*.pc -fi -} +PACKAGECONFIG:remove = "${PACKAGECONFIG_REMOVE}" +PACKAGECONFIG_REMOVE ?= \ + "${@bb.utils.contains('LICENSE_FLAGS_ACCEPTED', 'commercial', '', 'ffmpeg', d)}" +pkg_postinst:${PN}:ccimx6() { + echo '# Use FSL gstreamer plugin video source' >> $D${sysconfdir}/profile.d/qt6.sh + echo 'export QT_GSTREAMER_CAMERABIN_VIDEOSRC="imxv4l2src"' >> $D${sysconfdir}/profile.d/qt6.sh +} diff --git a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtquick3d_%.bbappend b/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtquick3d_%.bbappend deleted file mode 100644 index 2091cb378..000000000 --- a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtquick3d_%.bbappend +++ /dev/null @@ -1 +0,0 @@ -PACKAGECONFIG:append = " examples" diff --git a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtsvg_%.bbappend b/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtsvg_%.bbappend deleted file mode 100644 index a0f8891f0..000000000 --- a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtsvg_%.bbappend +++ /dev/null @@ -1,6 +0,0 @@ -do_install:append() { -if ls ${D}${libdir}/pkgconfig/Qt6*.pc >/dev/null 2>&1; then - sed -i 's,-L${STAGING_DIR_HOST}/usr/lib,,' ${D}${libdir}/pkgconfig/Qt6*.pc -fi -} - diff --git a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qttools_%.bbappend b/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qttools_%.bbappend deleted file mode 100644 index a0f8891f0..000000000 --- a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qttools_%.bbappend +++ /dev/null @@ -1,6 +0,0 @@ -do_install:append() { -if ls ${D}${libdir}/pkgconfig/Qt6*.pc >/dev/null 2>&1; then - sed -i 's,-L${STAGING_DIR_HOST}/usr/lib,,' ${D}${libdir}/pkgconfig/Qt6*.pc -fi -} - diff --git a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtwayland_%.bbappend b/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtwayland_%.bbappend index 4ecf367cd..ca011758b 100644 --- a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtwayland_%.bbappend +++ b/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtwayland_%.bbappend @@ -1,21 +1,6 @@ -###Copy qtwayland bbappend from meta-freescale - # etnaviv mesa does not have glx PACKAGECONFIG:remove:use-mainline-bsp = "xcomposite-glx" PACKAGECONFIG:remove:mx6-nxp-bsp = "xcomposite-egl xcomposite-glx" PACKAGECONFIG:remove:mx7-nxp-bsp = "xcomposite-egl xcomposite-glx" - -# i.MX8 does never provide native x11, so required dependencies are not met PACKAGECONFIG:remove:mx8-nxp-bsp = "xcomposite-egl xcomposite-glx" - -###### End of meta-freescale bbappend - -PACKAGECONFIG:remove:mx6sl-nxp-bsp = "wayland-egl" - -do_install:append() { -if ls ${D}${libdir}/pkgconfig/Qt6*.pc >/dev/null 2>&1; then - sed -i 's,-L${STAGING_DIR_HOST}/usr/lib,,' ${D}${libdir}/pkgconfig/Qt6*.pc -fi -} - diff --git a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtwebengine_%.bbappend b/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtwebengine_%.bbappend index 2fbc111a2..24b2f3b3e 100644 --- a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtwebengine_%.bbappend +++ b/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/qt6/qtwebengine_%.bbappend @@ -1,3 +1 @@ -PACKAGECONFIG:append = " examples" - -EXTRA_OECMAKE:append = " -DFEATURE_webengine_printing_and_pdf=OFF" +DEPENDS += "libdrm" diff --git a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/examples/cinematicexperience-rhi/icon_qt.png b/meta-digi-dey/dynamic-layers/qt6-layer/recipes-qt/examples/cinematicexperience-rhi/icon_qt.png similarity index 100% rename from meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/examples/cinematicexperience-rhi/icon_qt.png rename to meta-digi-dey/dynamic-layers/qt6-layer/recipes-qt/examples/cinematicexperience-rhi/icon_qt.png diff --git a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/examples/cinematicexperience-rhi_%.bbappend b/meta-digi-dey/dynamic-layers/qt6-layer/recipes-qt/examples/cinematicexperience-rhi_%.bbappend similarity index 100% rename from meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/examples/cinematicexperience-rhi_%.bbappend rename to meta-digi-dey/dynamic-layers/qt6-layer/recipes-qt/examples/cinematicexperience-rhi_%.bbappend diff --git a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/examples/cinematicexperience-rhi_1.0.bb b/meta-digi-dey/dynamic-layers/qt6-layer/recipes-qt/examples/cinematicexperience-rhi_1.0.bb similarity index 100% rename from meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-qt/examples/cinematicexperience-rhi_1.0.bb rename to meta-digi-dey/dynamic-layers/qt6-layer/recipes-qt/examples/cinematicexperience-rhi_1.0.bb diff --git a/meta-digi-dey/dynamic-layers/qt6-layer/recipes-qt/packagegroups/packagegroup-qt6-dey.bb b/meta-digi-dey/dynamic-layers/qt6-layer/recipes-qt/packagegroups/packagegroup-qt6-dey.bb new file mode 100644 index 000000000..a51cd5eb8 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/qt6-layer/recipes-qt/packagegroups/packagegroup-qt6-dey.bb @@ -0,0 +1,34 @@ +# Copyright 2019-20 NXP +# Released under the MIT license (see COPYING.MIT for the terms) + +DESCRIPTION = "Package group for i.MX Qt6" +LICENSE = "MIT" + +PACKAGE_ARCH = "${TUNE_PKGARCH}" + +inherit packagegroup + +RDEPENDS:${PN} = " \ + ${QT6_IMAGE_INSTALL_APPS} \ + ${QT6_IMAGE_INSTALL_CINEMATICEXPERIENCE} \ + ${QT6_IMAGE_INSTALL_EXAMPLES} \ + ${QT6_IMAGE_INSTALL_FONTS} \ + ${QT6_IMAGE_INSTALL_QUICK3D} \ + ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'libxkbcommon', '', d)} \ + ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'qtwayland qtwayland-plugins', '', d)}" + +QT6_IMAGE_INSTALL_APPS = "" +#QT6_IMAGE_INSTALL_APPS:imxgpu3d = "${@bb.utils.contains("MACHINE_GSTREAMER_1_0_PLUGIN", "imx-gst1.0-plugin", "imx-qtapplications", "", d)}" + +QT6_IMAGE_INSTALL_CINEMATICEXPERIENCE = "" +QT6_IMAGE_INSTALL_CINEMATICEXPERIENCE:imxgpu = "cinematicexperience-rhi cinematicexperience-rhi-tools" +QT6_IMAGE_INSTALL_CINEMATICEXPERIENCE:ccimx93 = "cinematicexperience-rhi cinematicexperience-rhi-tools" +QT6_IMAGE_INSTALL_CINEMATICEXPERIENCE:ccmp15 = "cinematicexperience-rhi cinematicexperience-rhi-tools" + +QT6_IMAGE_INSTALL_EXAMPLES = "qtbase-examples qtdeclarative-examples" + +QT6_IMAGE_INSTALL_FONTS = "ttf-dejavu-common ttf-dejavu-sans ttf-dejavu-sans-mono ttf-dejavu-serif " + +QT6_IMAGE_INSTALL_QUICK3D = "qtquick3d qtquick3d-dev qtquick3d-examples" +# Quick3d does not work on systems without a proper GPU +QT6_IMAGE_INSTALL_QUICK3D:ccimx93 = "" diff --git a/meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-fsl/packagegroup/packagegroup-qt6-webengine.bb b/meta-digi-dey/dynamic-layers/qt6-layer/recipes-qt/packagegroups/packagegroup-qt6-webengine.bb similarity index 100% rename from meta-digi-dey/dynamic-layers/qt6-layer/NXP/recipes-fsl/packagegroup/packagegroup-qt6-webengine.bb rename to meta-digi-dey/dynamic-layers/qt6-layer/recipes-qt/packagegroups/packagegroup-qt6-webengine.bb diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5-5.65/0009-bdaddr-support-setting-MAC-address-for-NXP-iw612.patch b/meta-digi-dey/recipes-connectivity/bluez/bluez5-5.65/0009-bdaddr-support-setting-MAC-address-for-NXP-iw612.patch new file mode 100644 index 000000000..69a9f87e7 --- /dev/null +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5-5.65/0009-bdaddr-support-setting-MAC-address-for-NXP-iw612.patch @@ -0,0 +1,36 @@ +From: Javier Viguera +Date: Wed, 16 Aug 2023 12:03:21 +0200 +Subject: [PATCH] bdaddr: support setting MAC address for NXP iw612 + +It uses same command sequence than ericsson's, so reuse +ericsson_store_in_flash function. + +Signed-off-by: Javier Viguera +--- + tools/bdaddr.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/tools/bdaddr.c b/tools/bdaddr.c +index bc0478d461b2..ab73211ceb09 100644 +--- a/tools/bdaddr.c ++++ b/tools/bdaddr.c +@@ -290,6 +290,11 @@ static int st_write_bd_addr(int dd, bdaddr_t *bdaddr) + return ericsson_store_in_flash(dd, 0xfe, 6, (uint8_t *) bdaddr); + } + ++static int nxp_write_bd_addr(int dd, bdaddr_t *bdaddr) ++{ ++ return ericsson_store_in_flash(dd, 0xfe, 6, (uint8_t *) bdaddr); ++} ++ + static struct { + uint16_t compid; + int (*write_bd_addr)(int dd, bdaddr_t *bdaddr); +@@ -300,6 +305,7 @@ static struct { + { 13, ti_write_bd_addr, NULL }, + { 15, bcm_write_bd_addr, generic_reset_device }, + { 18, zeevo_write_bd_addr, NULL }, ++ { 37, nxp_write_bd_addr, generic_reset_device }, + { 48, st_write_bd_addr, generic_reset_device }, + { 57, ericsson_write_bd_addr, generic_reset_device }, + { 72, mrvl_write_bd_addr, generic_reset_device }, diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccimx93/bluetooth-init b/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccimx93/bluetooth-init index 54f288b76..ec2361970 100644 --- a/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccimx93/bluetooth-init +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccimx93/bluetooth-init @@ -14,14 +14,34 @@ #=============================================================================== HCI_IFACE="hci0" +MODULE_NAME="btnxpuart" log() { - printf "<3>iw612-bluetooth: %s\n" "${1}" >/dev/kmsg + printf "<3>iw61x-bluetooth: %s\n" "${1}" >/dev/kmsg +} + +# The power of the IW61x chip is managed by the WiFi DT entry. +# If WiFi is disabled, is needed to manage the power manually. +is_not_wifi() { + ! [ -e "/proc/device-tree/wireless/mac-address" ] +} + +power() { + is_not_wifi && gpioset 1 7="${1}" } set_btaddr() { - bt_addr=$(echo $(fw_printenv -n btaddr) | awk -F ":" '{ for(i=NF;i>=1;i--) printf "0x%s ", $i }') + hciconfig ${HCI_IFACE} up + sleep 0.2 + bt_addr=$(echo "$(fw_printenv -n btaddr)" | awk -F ":" '{ for(i=NF;i>=1;i--) printf "0x%s ", $i }') hcitool -i ${HCI_IFACE} cmd 0x3f 0x0022 0xfe 0x06 ${bt_addr} + hciconfig ${HCI_IFACE} down + sleep 0.2 + hciconfig ${HCI_IFACE} up +} + +is_kernel_module_loaded() { + lsmod | grep -qs -w "^${MODULE_NAME}" } bluetooth_start() { @@ -30,36 +50,21 @@ bluetooth_start() { return fi - # If there is a hciattach process running, just do nothing - pidof hciattach > /dev/null && log "Bluetooth already activated" && return + # If module is already loaded, skip + is_kernel_module_loaded && log "[ERROR] kernel module already present, skipping" && return 1 - # If port speed is 3M, assume that FW has been modified to run at that speed - if [ "$(stty -F /dev/ttyBt speed)" != "3000000" ]; then - hciattach -t5 /dev/ttyBt any 115200 flow nosleep && \ - hciconfig ${HCI_IFACE} up && \ - sleep 0.2 && \ - set_btaddr && \ - # Change rate to 3M using a custom vendor command - hcitool -i ${HCI_IFACE} cmd 0x3f 0x0009 0xc0 0xc6 0x2d 0x00 && \ - sleep 0.2 && \ - killall hciattach && \ - sleep 0.2 - fi - - hciattach -t5 /dev/ttyBt any -s 3000000 3000000 flow && \ - log "Bluetooth activated" && return - - log "[ERROR] Cannot initialize Bluetooth" - return 1 + power 0 && sleep 0.2 && power 1 + # Load manually the kernel module + modprobe "${MODULE_NAME}" + # Reconfigure the HCI interface with the expected MAC address + is_kernel_module_loaded && set_btaddr && log "Bluetooth activated" && return 0 + log "[ERROR] Cannot initialize Bluetooth correctly" && return 1 } bluetooth_stop() { - if [ -e "/sys/class/bluetooth/${HCI_IFACE}" ]; then - killall hciattach > /dev/null - sleep 1 - # send a raw hci reset to set the chip in a good state - echo -e -n \\x01\\x03\\x0c\\x00 > /dev/ttyBt - fi + # Remove the kernel module + rmmod "${MODULE_NAME}" + power 0 } case "$1" in @@ -71,7 +76,6 @@ case "$1" in ;; restart) $0 stop - sleep 1 $0 start ;; *) diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccimx93/bluetooth-init.service b/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccimx93/bluetooth-init.service index 9fbfc8b1e..7766720e2 100644 --- a/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccimx93/bluetooth-init.service +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccimx93/bluetooth-init.service @@ -5,7 +5,8 @@ Before=bluetooth.service After=systemd-modules-load.service [Service] -Type=forking +Type=oneshot +RemainAfterExit=yes ExecStart=/etc/bluetooth-init start ExecStop=/etc/bluetooth-init stop diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.65.bbappend b/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.65.bbappend index e14bd91b9..aed838a35 100644 --- a/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.65.bbappend +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.65.bbappend @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2022 Digi International. +# Copyright (C) 2015-2023 Digi International. FILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}:${THISDIR}/${BP}:" @@ -8,6 +8,7 @@ SRC_URI += " \ file://0002-hcitool-do-not-show-unsupported-refresh-option.patch \ file://0003-hcitool-increase-the-shown-connection-limit-to-20.patch \ file://0004-port-test-discovery-to-python3.patch \ + file://0009-bdaddr-support-setting-MAC-address-for-NXP-iw612.patch \ " QCA65XX_COMMON_PATCHES = " \ diff --git a/meta-digi-dey/recipes-connectivity/hostapd/hostapd/hostapd_uap0.conf b/meta-digi-dey/recipes-connectivity/hostapd/hostapd/hostapd_uap0.conf index 860aa6dc5..975a4eae8 100644 --- a/meta-digi-dey/recipes-connectivity/hostapd/hostapd/hostapd_uap0.conf +++ b/meta-digi-dey/recipes-connectivity/hostapd/hostapd/hostapd_uap0.conf @@ -9,7 +9,7 @@ ssid=ap-uap0-##MAC## # 802.11a (5 GHz) mode hw_mode=a -# Set the channel to use. If 0 (ACS), channel will be automatically selected +# Specify the channel to use. If 0 (ACS), channel will be automatically selected channel=44 # IEEE 802.11i, WPA2 encryption with PSK authentication @@ -19,10 +19,17 @@ wpa_key_mgmt=WPA-PSK wpa_pairwise=CCMP wpa_passphrase=password-wpa2aes -# Uncomment to enable WPA3-SAE authentication +# Uncomment to enable WPA3-SAE authentication (mixed with WPA2 encryption) # wpa_key_mgmt=WPA-PSK SAE # sae_password=password-wpa3sae + +# Uncomment to enable only WPA3 encryption (and comment previous WPA2 encryption block) +# ieee80211w=2 +# rsn_pairwise=CCMP +# wpa_key_mgmt=SAE +# wpa_passphrase=password-wpa3only + # IEEE 802.11n (Wi-Fi 4) features ieee80211n=1 ht_capab=[HT20][HT40+][HT40-][SHORT-GI-20][SHORT-GI-40] diff --git a/meta-digi-dey/recipes-connectivity/networkmanager/networkmanager/p2pbridge b/meta-digi-dey/recipes-connectivity/networkmanager/networkmanager/p2pbridge index 5e3599868..a095b8bfa 100644 --- a/meta-digi-dey/recipes-connectivity/networkmanager/networkmanager/p2pbridge +++ b/meta-digi-dey/recipes-connectivity/networkmanager/networkmanager/p2pbridge @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright 2019, Digi International Inc. +# Copyright 2019-2023, Digi International Inc. # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this @@ -18,9 +18,11 @@ # # This script is specific to create a P2P (BATMAN) bridge, so -# require the CONNECTION_ID to be "p2p-bridge" +# requires the CONNECTION_ID to be "p2p-bridge" [ "${CONNECTION_ID}" = "p2p-bridge" ] || exit 0 +P2P_IFACE="##WLAN_P2P_INTERFACE##" + log() { if type "systemd-cat" >/dev/null 2>/dev/null; then systemd-cat -p "${1}" -t p2pbridge printf "%s" "${2}" @@ -32,13 +34,13 @@ log() { case "${NM_DISPATCHER_ACTION}" in pre-up) # Reset virtual interfaces - { batctl if destroy; ifdown -f p2p0; } >/dev/null 2>&1 + { batctl if destroy; ifdown -f "${P2P_IFACE}"; } >/dev/null 2>&1 # Bring P2P link up log info "bring P2P link UP" - ifup p2p0 || { log err "p2p link NOT created"; exit 1; } - for P2P_IFNAME in $(basename $(echo /sys/class/net/p2p-p2p0-*)); do - echo "${P2P_IFNAME}" | grep -qs 'p2p-p2p0-\*' && continue + ifup "${P2P_IFACE}" || { log err "p2p link NOT created"; exit 1; } + for P2P_IFNAME in $(basename $(echo /sys/class/net/p2p-"${P2P_IFACE}"-*)); do + echo "${P2P_IFNAME}" | grep -qs "p2p-${P2P_IFACE}-\*" && continue ifconfig "${P2P_IFNAME}" 0.0.0.0 p2p_iface_found="1" break @@ -61,7 +63,7 @@ down) batctl if destroy log info "bring P2P link DOWN" - ifdown -f p2p0 || { log err "unable to bring P2P link DOWN"; exit 1; } + ifdown -f "${P2P_IFACE}" || { log err "unable to bring P2P link DOWN"; exit 1; } ;; *) # Do nothing diff --git a/meta-digi-dey/recipes-connectivity/networkmanager/networkmanager_%.bbappend b/meta-digi-dey/recipes-connectivity/networkmanager/networkmanager_%.bbappend index 8614945d7..e13caeebb 100644 --- a/meta-digi-dey/recipes-connectivity/networkmanager/networkmanager_%.bbappend +++ b/meta-digi-dey/recipes-connectivity/networkmanager/networkmanager_%.bbappend @@ -104,6 +104,7 @@ do_install:append() { install -m 0755 ${WORKDIR}/01dispatcher ${D}${sysconfdir}/NetworkManager/dispatcher.d/ install -m 0755 ${WORKDIR}/ifdownup ${D}${sysconfdir}/NetworkManager/dispatcher.d/device-connectivity-change.d/ install -m 0755 ${WORKDIR}/p2pbridge ${D}${sysconfdir}/NetworkManager/dispatcher.d/pre-up.d/ + sed -i -e 's,##WLAN_P2P_INTERFACE##,${WLAN_P2P_INTERFACE},g' ${D}${sysconfdir}/NetworkManager/dispatcher.d/pre-up.d/p2pbridge ln -s ../pre-up.d/p2pbridge ${D}${sysconfdir}/NetworkManager/dispatcher.d/down.d/p2pbridge # Disable terminal colors by default diff --git a/meta-digi-dey/recipes-core/busybox/busybox/0001-hwclock-add-get-set-parameters-option.patch b/meta-digi-dey/recipes-core/busybox/busybox/0001-hwclock-add-get-set-parameters-option.patch new file mode 100644 index 000000000..877cc86e0 --- /dev/null +++ b/meta-digi-dey/recipes-core/busybox/busybox/0001-hwclock-add-get-set-parameters-option.patch @@ -0,0 +1,225 @@ +From: Andrej Picej +Date: Tue, 11 Jul 2023 10:42:49 +0200 +Subject: [PATCH] hwclock: add get/set parameters option + +In kernel 5.16 special ioctls were introduced to get/set RTC parameters. +Add option to get/set parameters into busybox version of hwclock. +Implementation is similar to the one already used in linux-utils hwclock +tool. + +Example of parameter get use: +$ hwclock -g 2 +The RTC parameter 0x2 is set to 0x2. +$ hwclock --param-get bsm +The RTC parameter 0x2 is set to 0x2. + +Example of parameter set use: +$ hwclock -p 2=1 +The RTC parameter 0x2 will be set to 0x1. +$ hwclock -p bsm=2 +The RTC parameter 0x2 will be set to 0x2. + +function old new delta +hwclock_main 298 576 +278 +.rodata 105231 105400 +169 +packed_usage 34541 34576 +35 +static.hwclock_longopts 60 84 +24 +------------------------------------------------------------------------------ +(add/remove: 0/0 grow/shrink: 4/0 up/down: 506/0) Total: 506 bytes + +Signed-off-by: Andrej Picej +Signed-off-by: Denys Vlasenko +(cherry picked from commit d70256a5c719439cc6fab6a4571c1bb46178e4c7) +Signed-off-by: Javier Viguera +--- + include/rtc_.h | 18 +++++++++ + util-linux/hwclock.c | 87 +++++++++++++++++++++++++++++++++++++++++--- + 2 files changed, 100 insertions(+), 5 deletions(-) + +diff --git a/include/rtc_.h b/include/rtc_.h +index 24ff536..7829660 100644 +--- a/include/rtc_.h ++++ b/include/rtc_.h +@@ -46,6 +46,17 @@ struct linux_rtc_wkalrm { + struct linux_rtc_time time; /* time the alarm is set to */ + }; + ++struct rtc_param { ++ uint64_t param; ++ union { ++ uint64_t uvalue; ++ int64_t svalue; ++ uint64_t ptr; ++ }; ++ uint32_t index; ++ uint32_t __pad; ++}; ++ + /* + * ioctl calls that are permitted to the /dev/rtc interface, if + * any of the RTC drivers are enabled. +@@ -71,12 +82,19 @@ struct linux_rtc_wkalrm { + #define RTC_WKALM_SET _IOW('p', 0x0f, struct linux_rtc_wkalrm)/* Set wakeup alarm*/ + #define RTC_WKALM_RD _IOR('p', 0x10, struct linux_rtc_wkalrm)/* Get wakeup alarm*/ + ++#define RTC_PARAM_GET _IOW('p', 0x13, struct rtc_param) /* Get parameter */ ++#define RTC_PARAM_SET _IOW('p', 0x14, struct rtc_param) /* Set parameter */ ++ + /* interrupt flags */ + #define RTC_IRQF 0x80 /* any of the following is active */ + #define RTC_PF 0x40 + #define RTC_AF 0x20 + #define RTC_UF 0x10 + ++#define RTC_PARAM_FEATURES 0 ++#define RTC_PARAM_CORRECTION 1 ++#define RTC_PARAM_BACKUP_SWITCH_MODE 2 ++ + POP_SAVED_FUNCTION_VISIBILITY + + #endif +diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c +index 723b095..0101db7 100644 +--- a/util-linux/hwclock.c ++++ b/util-linux/hwclock.c +@@ -320,6 +320,70 @@ static void from_sys_clock(const char **pp_rtcname, int utc) + close(rtc); + } + ++static uint64_t resolve_rtc_param_alias(const char *alias) ++{ ++ int n; ++ ++ BUILD_BUG_ON(RTC_PARAM_FEATURES != 0 ++ || RTC_PARAM_CORRECTION != 1 ++ || RTC_PARAM_BACKUP_SWITCH_MODE != 2 ++ ); ++ n = index_in_strings( ++ "features" "\0" ++ "correction" "\0" ++ "bsm" "\0" ++ , alias); ++ if (n >= 0) ++ return n; ++ return xstrtoull(alias, 0); ++} ++ ++static void get_rtc_param(const char **pp_rtcname, const char *rtc_param) ++{ ++ int rtc; ++ struct rtc_param param; ++ ++ param.param = resolve_rtc_param_alias(rtc_param); ++ ++ rtc = rtc_xopen(pp_rtcname, O_RDONLY); ++ ++ xioctl(rtc, RTC_PARAM_GET, ¶m); ++ ++ printf("The RTC parameter 0x%llx is set to 0x%llx.\n", ++ (unsigned long long) param.param, (unsigned long long) param.uvalue); ++ ++ if (ENABLE_FEATURE_CLEAN_UP) ++ close(rtc); ++} ++ ++static void set_rtc_param(const char **pp_rtcname, char *rtc_param) ++{ ++ int rtc; ++ struct rtc_param param; ++ char *eq; ++ ++ /* handle param name */ ++ eq = strchr(rtc_param, '='); ++ if (!eq) ++ bb_error_msg_and_die("expected ="); ++ *eq = '\0'; ++ param.param = resolve_rtc_param_alias(rtc_param); ++ *eq = '='; ++ ++ /* handle param value */ ++ param.uvalue = xstrtoull(eq + 1, 0); ++ ++ rtc = rtc_xopen(pp_rtcname, O_WRONLY); ++ ++ printf("The RTC parameter 0x%llx will be set to 0x%llx.\n", ++ (unsigned long long) param.param, (unsigned long long) param.uvalue); ++ ++ xioctl(rtc, RTC_PARAM_SET, ¶m); ++ ++ if (ENABLE_FEATURE_CLEAN_UP) ++ close(rtc); ++} ++ + // hwclock from util-linux 2.36.1 + // hwclock [function] [option...] + //Functions: +@@ -346,10 +410,10 @@ static void from_sys_clock(const char **pp_rtcname, int utc) + + //usage:#define hwclock_trivial_usage + //usage: IF_LONG_OPTS( +-//usage: "[-swul] [--systz] [-f DEV]" ++//usage: "[-swul] [--systz] [--param-get PARAM] [--param-set PARAM=VAL] [-f DEV]" + //usage: ) + //usage: IF_NOT_LONG_OPTS( +-//usage: "[-swult] [-f DEV]" ++//usage: "[-swult] [-g PARAM] [-p PARAM=VAL] [-f DEV]" + //usage: ) + //usage:#define hwclock_full_usage "\n\n" + //usage: "Show or set hardware clock (RTC)\n" +@@ -360,6 +424,8 @@ static void from_sys_clock(const char **pp_rtcname, int utc) + //usage: IF_LONG_OPTS( + //usage: "\n --systz Set in-kernel timezone, correct system time" + //usage: "\n if RTC is kept in local time" ++//usage: "\n --param-get PARAM Get RTC parameter" ++//usage: "\n --param-set PARAM=VAL Set RTC parameter" + //usage: ) + //usage: "\n -f DEV Use specified device (e.g. /dev/rtc2)" + //usage: "\n -u Assume RTC is kept in UTC" +@@ -375,11 +441,14 @@ static void from_sys_clock(const char **pp_rtcname, int utc) + #define HWCLOCK_OPT_SYSTOHC 0x10 + #define HWCLOCK_OPT_SYSTZ 0x20 + #define HWCLOCK_OPT_RTCFILE 0x40 ++#define HWCLOCK_OPT_PARAM_GET 0x80 ++#define HWCLOCK_OPT_PARAM_SET 0x100 + + int hwclock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; + int hwclock_main(int argc UNUSED_PARAM, char **argv) + { + const char *rtcname = NULL; ++ char *param; + unsigned opt; + int utc; + #if ENABLE_LONG_OPTS +@@ -391,14 +460,18 @@ int hwclock_main(int argc UNUSED_PARAM, char **argv) + "systohc\0" No_argument "w" + "systz\0" No_argument "t" /* short opt is non-standard */ + "rtc\0" Required_argument "f" ++ "param-get\0" Required_argument "g" /* short opt is non-standard */ ++ "param-set\0" Required_argument "p" /* short opt is non-standard */ + ; + #endif + opt = getopt32long(argv, +- "^""lurswtf:v" /* -v is accepted and ignored */ ++ "^""lurswtf:g:p:v" /* -v is accepted and ignored */ + "\0" +- "r--wst:w--rst:s--wrt:t--rsw:l--u:u--l", ++ "r--wstgp:w--rstgp:s--wrtgp:t--rswgp:g--rswtp:p--rswtg:l--u:u--l", + hwclock_longopts, +- &rtcname ++ &rtcname, ++ ¶m, ++ ¶m + ); + + /* If -u or -l wasn't given, check if we are using utc */ +@@ -413,6 +486,10 @@ int hwclock_main(int argc UNUSED_PARAM, char **argv) + from_sys_clock(&rtcname, utc); + else if (opt & HWCLOCK_OPT_SYSTZ) + set_kernel_timezone_and_clock(utc, NULL); ++ else if (opt & HWCLOCK_OPT_PARAM_GET) ++ get_rtc_param(&rtcname, param); ++ else if (opt & HWCLOCK_OPT_PARAM_SET) ++ set_rtc_param(&rtcname, param); + else + /* default HWCLOCK_OPT_SHOW */ + show_clock(&rtcname, utc); diff --git a/meta-digi-dey/recipes-core/busybox/busybox/ccimx93/standby-actions b/meta-digi-dey/recipes-core/busybox/busybox/ccimx93/standby-actions index 154b40520..b200c71a7 100644 --- a/meta-digi-dey/recipes-core/busybox/busybox/ccimx93/standby-actions +++ b/meta-digi-dey/recipes-core/busybox/busybox/ccimx93/standby-actions @@ -38,13 +38,11 @@ if [ "${1}" = "pre" ]; then rmmod mlan if systemctl is-active bluetooth-init; then - # # bluetooth service relies on bluetooth-init service, so stop/start it unconditionally echo "systemctl start bluetooth-init" >> "${RESUME_ACTIONS}" echo "systemctl start bluetooth" >> "${RESUME_ACTIONS}" systemctl stop bluetooth-init systemctl stop bluetooth - stty -F /dev/ttyBt 115200 fi fi elif [ "${1}" = "post" ]; then diff --git a/meta-digi-dey/recipes-core/busybox/busybox_1.35.%.bbappend b/meta-digi-dey/recipes-core/busybox/busybox_1.35.%.bbappend index 4ff121156..62e798f14 100644 --- a/meta-digi-dey/recipes-core/busybox/busybox_1.35.%.bbappend +++ b/meta-digi-dey/recipes-core/busybox/busybox_1.35.%.bbappend @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2022 Digi International. +# Copyright (C) 2013-2023 Digi International. FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" @@ -16,6 +16,7 @@ SRC_URI += "file://standby \ ${@bb.utils.contains("MACHINE_FEATURES", "mca", "file://poweroff_safe \ file://reboot_safe \ ", "", d)} \ + file://0001-hwclock-add-get-set-parameters-option.patch \ " HAS_SYSTEMD = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}" diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/p2plink b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/p2plink index f0f617962..aded43cc4 100644 --- a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/p2plink +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/p2plink @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright 2019, Digi International Inc. +# Copyright 2019-2023, Digi International Inc. # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this @@ -27,8 +27,8 @@ # p2p-network-id # -# Execute only for the p2p0 interface -[ "${IFACE}" = "p2p0" ] || exit 0 +# Execute only for the P2P interface +[ "${IFACE}" = "##WLAN_P2P_INTERFACE##" ] || exit 0 log() { if type "systemd-cat" >/dev/null 2>/dev/null; then @@ -68,8 +68,8 @@ if [ "${MODE}" = "start" ]; then if [ -n "${p2p_link_found}" ]; then # Configure the newly created interface if [ -n "${IF_P2P_LOCAL_ADDRESS}" ]; then - for P2P_IFNAME in $(basename $(echo /sys/class/net/p2p-p2p0-*)); do - echo "${P2P_IFNAME}" | grep -qs 'p2p-p2p0-\*' && continue + for P2P_IFNAME in $(basename $(echo /sys/class/net/p2p-"${IFACE}"-*)); do + echo "${P2P_IFNAME}" | grep -qs "p2p-${IFACE}-\*" && continue ifconfig "${P2P_IFNAME}" "${IF_P2P_LOCAL_ADDRESS}" ${IF_P2P_LOCAL_NETMASK:+netmask ${IF_P2P_LOCAL_NETMASK}} up break done diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend index c5d6ca29d..cb08becd3 100644 --- a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend @@ -47,6 +47,7 @@ do_install:append() { cat ${WORKDIR}/interfaces.p2p >> ${D}${sysconfdir}/network/interfaces [ -n "${WLAN_P2P_AUTO}" ] && sed -i -e 's/^#auto ##WLAN_P2P_INTERFACE##/auto ##WLAN_P2P_INTERFACE##/g' ${D}${sysconfdir}/network/interfaces sed -i -e 's,##WLAN_P2P_INTERFACE##,${WLAN_P2P_INTERFACE},g' ${D}${sysconfdir}/network/interfaces + sed -i -e 's,##WLAN_P2P_INTERFACE##,${WLAN_P2P_INTERFACE},g' ${D}${sysconfdir}/network/if-up.d/p2plink fi fi diff --git a/meta-digi-dey/recipes-core/packagegroups/packagegroup-dey-core.bb b/meta-digi-dey/recipes-core/packagegroups/packagegroup-dey-core.bb index 4692b509c..d736c7b23 100644 --- a/meta-digi-dey/recipes-core/packagegroups/packagegroup-dey-core.bb +++ b/meta-digi-dey/recipes-core/packagegroups/packagegroup-dey-core.bb @@ -1,5 +1,5 @@ # -# Copyright (C) 2012-2022 Digi International. +# Copyright (C) 2012-2023 Digi International. # SUMMARY = "Core packagegroup for DEY image" @@ -36,8 +36,9 @@ SYSVINIT_SCRIPTS = " \ RDEPENDS:${PN} = "\ base-files \ base-passwd \ + bootcount \ connectcore-demo-example \ - ${CLOUDCONNECTOR_PKG} \ + ${CCCS_PKGS} \ dualboot \ ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'firmwared', '',d)} \ ${@bb.utils.contains("MACHINE_FEATURES", "keyboard", "${VIRTUAL-RUNTIME_keymaps}", "", d)} \ diff --git a/meta-digi-dey/recipes-core/recovery/recovery-initramfs.bb b/meta-digi-dey/recipes-core/recovery/recovery-initramfs.bb index 7b2a395fe..afb16da69 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-initramfs.bb +++ b/meta-digi-dey/recipes-core/recovery/recovery-initramfs.bb @@ -36,44 +36,6 @@ do_install() { install -m 0755 ${WORKDIR}/automount_mtd.sh ${D}${base_libdir}/mdev/automount_mtd.sh install -m 0755 ${WORKDIR}/automount_ubi.sh ${D}${base_libdir}/mdev/automount_ubi.sh install -m 0644 ${WORKDIR}/mdev.conf ${D}${sysconfdir} - - # If Trustfence is enabled, copy the public key that is going to be used into the - # initramfs '/etc/ssl/certs' folder in order to verify swupdate packages. - if [ "${TRUSTFENCE_SIGN}" = "1" ]; then - # Retrieve the key index to use. - KEY_INDEX="0" - if [ -n "${TRUSTFENCE_KEY_INDEX}" ]; then - KEY_INDEX="${TRUSTFENCE_KEY_INDEX}" - fi - KEY_INDEX_1=$(expr ${KEY_INDEX} + 1) - - # Find the certificate to use. - if [ "${DEY_SOC_VENDOR}" = "NXP" ]; then - if [ "${TRUSTFENCE_SIGN_MODE}" = "HAB" ]; then - CERT_IMG="$(echo ${TRUSTFENCE_SIGN_KEYS_PATH}/crts/IMG${KEY_INDEX_1}*crt.pem)" - elif [ "${TRUSTFENCE_SIGN_MODE}" = "AHAB" ]; then - CERT_IMG="$(echo ${TRUSTFENCE_SIGN_KEYS_PATH}/crts/SRK${KEY_INDEX_1}*_ca_crt.pem)" - else - bberror "Unkown TRUSTFENCE_SIGN_MODE value" - exit 1 - fi - # Extract the public key from the certificate. - install -d ${D}${sysconfdir}/ssl/certs - openssl x509 -pubkey -noout -in "${CERT_IMG}" > ${D}${sysconfdir}/ssl/certs/key.pub - elif [ "${DEY_SOC_VENDOR}" = "STM" ]; then - # Copy the public key to the rootfs - if [ "${DIGI_SOM}" = "ccmp15" ]; then - PUBLIC_KEY="${TRUSTFENCE_SIGN_KEYS_PATH}/keys/publicKey00.pem" - elif [ "${DIGI_SOM}" = "ccmp13" ]; then - PUBLIC_KEY="${TRUSTFENCE_SIGN_KEYS_PATH}/keys/publicKey0${KEY_INDEX}.pem" - else - bberror "Unknown DIGI_SOM" - exit 1 - fi - install -d ${D}${sysconfdir}/ssl/certs - cp ${PUBLIC_KEY} ${D}${sysconfdir}/ssl/certs/key.pub - fi - fi } # Do not create debug/devel packages diff --git a/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init index 9c02e310c..59d0e995d 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init +++ b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init @@ -169,10 +169,10 @@ quit_with_error() { # @return - "yes" if the system is running in NAND, "no" otherwise #------------------------------------------------------------------------------ is_nand() { - if grep -qs "\broot=\(ubi\|mtd\)" /proc/cmdline; then - echo "yes" - else + if grep -qs 'root=PARTUUID.*' /proc/cmdline; then echo "no" + else + echo "yes" fi } @@ -231,23 +231,10 @@ format_ubi_volume() { psplash_message "Formatting '${1}' partition..." psplash_progress "0" - # Read the singlemtdsys variable. - read_uboot_var singlemtdsys singlemtdsys - - if [ "${singlemtdsys}" = "yes" ]; then - # Find the volume number associated to the volume name - for d in /dev/ubi0_*; do - volname="$(ubinfo ${d} | grep ^Name | awk '{print $(2)}')" - if [ "${volname}" = "${1}" ]; then - # Find mountpoint - mountpoint="$(mount | grep ubi0:${1} | awk '{print $(3) }')" - umount ${mountpoint} 2> /dev/null - # Wipe out volume - ubiupdatevol ${d} -t - fi - done - psplash_progress "100" - else + # If the system is a multi-MTD, there must be an MTD partition by the + # same name as the UBI volume + result="$(grep '\"${1}\"$' /proc/mtd)" + if [ -n "${result}" ]; then # Find the MTD partition. local mtd_num="$(sed -ne "s/mtd\([0-9]\+\):.*\<${1}\>.*/\1/g;T;p" /proc/mtd 2>/dev/null)" if [ -z "${mtd_num}" ]; then @@ -282,6 +269,24 @@ format_ubi_volume() { quit_with_error "Error creating '${1}' UBI volume" fi fi + else + # Find the volume number associated to the volume name + ubidevs="$(ls /dev/ubi* | grep 'ubi[0-9]\+$')" + for d in $ubidevs;do + for v in "${d}"_*; do + volname="$(ubinfo ${v} | grep ^Name | awk '{print $(2)}')" + if [ "${volname}" = "${1}" ]; then + # Find mountpoint + u="$(basename ${d})" + mountpoint="$(mount | grep ${u}:${1} | awk '{print $(3) }')" + umount ${mountpoint} 2> /dev/null + # Wipe out volume + ubiupdatevol ${v} -t + break 2 + fi + done + done + psplash_progress "100" fi } diff --git a/meta-digi-dey/recipes-core/systemd/systemd-conf_%.bbappend b/meta-digi-dey/recipes-core/systemd/systemd-conf_%.bbappend index 01735aaa4..00f88e0c3 100644 --- a/meta-digi-dey/recipes-core/systemd/systemd-conf_%.bbappend +++ b/meta-digi-dey/recipes-core/systemd/systemd-conf_%.bbappend @@ -10,6 +10,10 @@ SRC_URI:append:ccmp1 = " \ file://logind.conf-digi \ " +SRC_URI:append:ccimx93 = " \ + file://logind.conf-digi \ +" + do_install:append() { install -D -m0644 ${WORKDIR}/system.conf-digi ${D}${systemd_unitdir}/system.conf.d/01-${PN}.conf } @@ -17,3 +21,7 @@ do_install:append() { do_install:append:ccmp1() { install -D -m0644 ${WORKDIR}/logind.conf-digi ${D}${systemd_unitdir}/logind.conf.d/01-${PN}.conf } + +do_install:append:ccimx93() { + install -D -m0644 ${WORKDIR}/logind.conf-digi ${D}${systemd_unitdir}/logind.conf.d/01-${PN}.conf +} diff --git a/meta-digi-dey/recipes-core/systemd/systemd_%.bbappend b/meta-digi-dey/recipes-core/systemd/systemd_%.bbappend index 55a98777e..cf8b62a96 100644 --- a/meta-digi-dey/recipes-core/systemd/systemd_%.bbappend +++ b/meta-digi-dey/recipes-core/systemd/systemd_%.bbappend @@ -20,4 +20,9 @@ do_install:append () { SUBSYSTEM=="input", KERNEL=="event[0-9]*", ENV{ID_INPUT_TOUCHSCREEN}=="1", SYMLINK+="input/touchscreen0" EOF fi + + # Disable virtual terminals + if [ "${USE_VT}" = "0" ]; then + sed -i -e "/getty@.service/s,enable,disable,g" ${D}${systemd_unitdir}/system-preset/90-systemd.preset + fi } diff --git a/meta-digi-dey/recipes-devtools/python3-connectcore-ble/python3-connectcore-ble_git.bb b/meta-digi-dey/recipes-devtools/python3-connectcore-ble/python3-connectcore-ble_git.bb index a89c868cf..db73c96b4 100644 --- a/meta-digi-dey/recipes-devtools/python3-connectcore-ble/python3-connectcore-ble_git.bb +++ b/meta-digi-dey/recipes-devtools/python3-connectcore-ble/python3-connectcore-ble_git.bb @@ -1,4 +1,4 @@ -# Copyright (C) 2022, Digi International Inc. +# Copyright (C) 2022, 2023, Digi International Inc. SUMMARY = "Bluetooth Low Energy Python library for ConnetCore devices" DESCRIPTION = "The ConnectCore BLE Python library allows your Digi International's ConnectCore modules to interact with mobile applications." @@ -8,14 +8,10 @@ LICENSE = "MPL-2.0" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad" SRCBRANCH ?= "master" -SRCREV = "${AUTOREV}" - -CONNECTCORE_BLE_URI_STASH = "${DIGI_MTK_GIT}/python/connectcore-ble-python.git;protocol=ssh" -CONNECTCORE_BLE_URI_GITHUB = "${DIGI_GITHUB_GIT}/connectcore-ble-python.git;protocol=https" -CONNECTCORE_BLE_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${CONNECTCORE_BLE_URI_STASH}', '${CONNECTCORE_BLE_URI_GITHUB}', d)}" +SRCREV = "eeeb705ded84cfb4ba1a4b50a41a98e3bfe59700" SRC_URI = " \ - ${CONNECTCORE_BLE_URI};branch=${SRCBRANCH} \ + ${DIGI_GITHUB_GIT}/connectcore-ble-python.git;protocol=https;branch=${SRCBRANCH} \ " S = "${WORKDIR}/git" diff --git a/meta-digi-dey/recipes-devtools/python3-xbee/python3-xbee_1.4.1.bb b/meta-digi-dey/recipes-devtools/python3-xbee/python3-xbee_git.bb similarity index 64% rename from meta-digi-dey/recipes-devtools/python3-xbee/python3-xbee_1.4.1.bb rename to meta-digi-dey/recipes-devtools/python3-xbee/python3-xbee_git.bb index 6baa3db83..9fa6381c4 100644 --- a/meta-digi-dey/recipes-devtools/python3-xbee/python3-xbee_1.4.1.bb +++ b/meta-digi-dey/recipes-devtools/python3-xbee/python3-xbee_git.bb @@ -1,4 +1,4 @@ -# Copyright (C) 2022 Digi International Inc. +# Copyright (C) 2022, 2023 Digi International Inc. SUMMARY = "Python library to interact with Digi International's XBee radio frequency modules." DESCRIPTION = "The XBee Python Library provides the ability to communicate with remote nodes in the network, IoT devices and other interfaces of the local device." @@ -7,11 +7,15 @@ SECTION = "devel/python" LICENSE = "MPL-2.0" LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=f74526e982749d58a537b3fcdb5d3318" -SRC_URI[md5sum] = "0608ecc8051b31d821b58dcec5396705" -SRC_URI[sha256sum] = "3b10e749431f406d80c189d872f4673b8d3cd510f7b411f817780a0e72499cd2" +SRCBRANCH ?= "master" +SRCREV = "1024d8954e1b445fe6aacd7f0880de65978c351b" -PYPI_PACKAGE = "digi-xbee" +SRC_URI = " \ + git://github.com/digidotcom/xbee-python.git;protocol=https;branch=${SRCBRANCH} \ +" -inherit pypi setuptools3 +S = "${WORKDIR}/git" + +inherit setuptools3 RDEPENDS:${PN} = "python3-asyncio python3-pyserial" diff --git a/meta-digi-dey/recipes-digi/bootcount/bootcount.bb b/meta-digi-dey/recipes-digi/bootcount/bootcount.bb new file mode 100644 index 000000000..e1b720d8e --- /dev/null +++ b/meta-digi-dey/recipes-digi/bootcount/bootcount.bb @@ -0,0 +1,44 @@ +# Copyright (C) 2023 Digi International + +SUMMARY = "Application to manage the bootcount value" +LICENSE = "MPL-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad" + +DEPENDS = "libubootenv" + +PV = "1.0" + +SRC_URI = " \ + file://bootcount-bin \ + file://bootcount-init/bootcount-init \ + file://bootcount-init/bootcount-init.service \ +" + +S = "${WORKDIR}/bootcount-bin" + +inherit pkgconfig systemd update-rc.d + +do_install() { + oe_runmake DESTDIR=${D} install + + # INITSCRIPT + install -d ${D}${sysconfdir}/init.d/ + install -m 0755 ${WORKDIR}/bootcount-init/bootcount-init ${D}${sysconfdir}/bootcount-init + ln -sf /etc/bootcount-init ${D}${sysconfdir}/init.d/bootcount-init + + # SYSTEMD + install -d ${D}${systemd_unitdir}/system/ + install -m 0644 ${WORKDIR}/bootcount-init/bootcount-init.service ${D}${systemd_unitdir}/system/ +} + +FILES:${PN} += " \ + ${sysconfdir}/bootcount-init \ + ${sysconfdir}/init.d/bootcount-init \ + ${systemd_unitdir}/system/bootcount-init.service \ +" + +INITSCRIPT_PACKAGES += "${PN}" +INITSCRIPT_NAME:${PN} = "bootcount-init" +INITSCRIPT_PARAMS:${PN = "start 19 2 3 4 5 . stop 21 0 1 6 ." + +SYSTEMD_SERVICE:${PN} = "bootcount-init.service" diff --git a/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/.gitignore b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/.gitignore new file mode 100644 index 000000000..b87dd0a6a --- /dev/null +++ b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/.gitignore @@ -0,0 +1,5 @@ +bootcount +*.o +.cproject +.project +.settings/ diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/Makefile b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/Makefile similarity index 53% rename from meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/Makefile rename to meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/Makefile index 989acb8a6..1341e0594 100644 --- a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/Makefile +++ b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2017, Digi International Inc. +# Copyright (c) 2023, Digi International Inc. # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this @@ -14,14 +14,29 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # -SUBDIRS := device_request_listener upload_data_points upload_file +PROGRAM := bootcount -all: $(SUBDIRS) +GIT_REVISION := $(shell git rev-parse --verify --short=7 HEAD 2>/dev/null) -.PHONY: $(SUBDIRS) -$(SUBDIRS): - $(MAKE) -C $@ +CFLAGS += -Wall -DGIT_REVISION=\"$(if $(GIT_REVISION),-g$(GIT_REVISION))\" +CFLAGS += -Iinclude +CFLAGS += $(shell pkg-config --cflags libubootenv) +LDLIBS += $(shell pkg-config --libs libubootenv) -.PHONY: clean install -clean install: - for a in $(SUBDIRS); do $(MAKE) -C $$a $@; done +SRCS = $(wildcard *.c) +OBJS = $(SRCS:.c=.o) + +.PHONY: all +all: $(PROGRAM) + +$(PROGRAM): $(OBJS) + $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ + +.PHONY: install +install: $(PROGRAM) + install -d $(DESTDIR)/usr/bin + install -m 0755 $(PROGRAM) $(DESTDIR)/usr/bin/ + +.PHONY: clean +clean: + -rm -f *.o $(PROGRAM) diff --git a/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/bootcount.c b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/bootcount.c new file mode 100644 index 000000000..c90aa0a18 --- /dev/null +++ b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/bootcount.c @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2023, Digi International Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at http://mozilla.org/MPL/2.0/. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include + +#include "bootcount_env.h" +#include "bootcount_nvmem.h" +#include "platform_utils.h" + +#define VERSION "1.0" GIT_REVISION + +#define USAGE \ + "Bootcount utility.\n" \ + "Copyright(c) Digi International Inc.\n" \ + "\n" \ + "Version: %s\n" \ + "\n" \ + "Usage: bootcount [options] \n\n" \ + " -p --print Print the current bootcount value (Default action)\n" \ + " -s --set= Set current bootcount to a specific value.\n" \ + " -r --reset Reset bootcount value to zero.\n" \ + " -h --help Print help and exit\n" \ + "\n" + +/* + * Struct used to store the pointers to the methods to read/write + * the bootcount value for each platform. + */ +struct platform_functions { + int (*read_bootcount) (void); + int (*write_bootcount) (unsigned int); +}; + +/* + * Static list of the platforms with their corresponding methods to + * access the bootcount. + */ +struct platform_functions platforms_functions[] = { + [PLATFORM_CC6QP] = {read_bootcount_env, write_bootcount_env}, + [PLATFORM_CC6SBC] = {read_bootcount_env, write_bootcount_env}, + [PLATFORM_CC6UL] = {read_bootcount_nvmem, write_bootcount_nvmem}, + [PLATFORM_CC8MM] = {read_bootcount_nvmem, write_bootcount_nvmem}, + [PLATFORM_CC8MN] = {read_bootcount_nvmem, write_bootcount_nvmem}, + [PLATFORM_CC8X] = {read_bootcount_nvmem, write_bootcount_nvmem}, + [PLATFORM_CC93] = {read_bootcount_nvmem, write_bootcount_nvmem}, + [PLATFORM_CCMP13] = {read_bootcount_nvmem, write_bootcount_nvmem}, + [PLATFORM_CCMP15] = {read_bootcount_nvmem, write_bootcount_nvmem}, + [PLATFORM_UNKNOWN] = {NULL, NULL} +}; + +/* Global variables. */ +platform_t platform; + +/* Command line variables */ +static bool read, write, reset = false; +static uint write_value; + +/** + * @brief Print usage information and exit the program with the specified exit value. + * + * @param exitval The exit status code for the program. + */ +static void usage_and_exit(int exitval) { + fprintf(stdout, USAGE, VERSION); + + exit(exitval); +} + +/** + * @brief Parses command-line options. + * + * This function parses the command-line options passed to the bootcount utility. + * + * If no options are provided (`argc == 1`), the default action is assumed to be read, + * and the 'read' flag is set to true. + * + * If invalid options or incorrect bootcount values are provided, the function prints + * error messages and exits with failure status. + * + * @param argc The number of command-line arguments. + * @param argv An array of strings containing the command-line arguments. + */ +static void parse_options(int argc, char *argv[]) { + static int opt_index, opt; + static const char *short_options = "ps:rh"; + static const struct option long_options[] = { + {"print", no_argument, NULL, 'p'}, + {"set", required_argument, NULL, 's'}, + {"reset", no_argument, NULL, 'r'}, + {"help", no_argument, NULL, 'h'}, + {NULL, 0, NULL, 0} + }; + char *endptr; + + if (argc == 1) { + /* Consider default action is print. */ + read = true; + return; + } + + while (1) { + opt = getopt_long(argc, argv, short_options, long_options, &opt_index); + if (opt == -1) + break; + + switch (opt) { + case 'p': + read = true; + break; + case 's': + write = true; + write_value = (int)strtoul(optarg, &endptr, 10); + if (*endptr) { + printf("Error: incorrect bootcount value\n"); + exit(EXIT_FAILURE); + } + break; + case 'r': + reset = true; + break; + case 'h': + usage_and_exit(EXIT_SUCCESS); + break; + default: + usage_and_exit(EXIT_FAILURE); + break; + } + } +} + +/** + * @brief Main program function and entry point. + * + * @param argc The number of command-line arguments. + * @param argv An array of strings containing the command-line arguments. + * + * @return 0 if the process finishes successfully, any other value otherwise.. + */ +int main(int argc, char *argv[]) { + int ret = 0; + struct platform_functions *pfuncs; + + /* Read and parse command line */ + parse_options(argc, argv); + + /* Determine platform. */ + platform = get_platform(); + pfuncs = &platforms_functions[platform]; + + /* Execute the requested action. */ + if (read) { + ret = pfuncs->read_bootcount(); + if (ret >= 0) { + printf("%d\n", ret); + ret = 0; + } + } else if (write) { + ret = pfuncs->write_bootcount(write_value); + } else if (reset) { + ret = pfuncs->write_bootcount(0); + } + + return ret; +} diff --git a/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/bootcount_env.c b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/bootcount_env.c new file mode 100644 index 000000000..a18ecdf0e --- /dev/null +++ b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/bootcount_env.c @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2023, Digi International Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at http://mozilla.org/MPL/2.0/. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#include "bootcount_env.h" +#include "libuboot.h" + +/* Environment variables. */ +#define ENV_VAR_UPGRADE_AVAILABLE "upgrade_available" +#define ENV_VAR_BOOTCOUNT "bootcount" + +int read_bootcount_env() { + int ret; + char* endptr; + const char *var; + + /* Obtain 'bootcount' value from environment. */ + ret = uboot_getenv(ENV_VAR_BOOTCOUNT, &var); + if (!ret) { + /* Convert read value to integer. */ + ret = (int)strtoul(var, &endptr, 10); + if (*endptr) { + printf("Error: incorrect bootcount value in environment\n"); + ret = -1; + } + } else { + fprintf(stderr, "Error: could not read '%s' variable from U-Boot environment'\n", ENV_VAR_BOOTCOUNT); + ret = -1; + } + + free((char*)var); + return ret; +} + +int write_bootcount_env(uint count) { + int ret; + char value_str[5]; + + /* Convert value to string. */ + snprintf(value_str, sizeof(value_str), "%u", count); + /* Write value to environment. */ + ret = uboot_setenv(ENV_VAR_BOOTCOUNT, value_str); + if (ret) { + fprintf(stderr, "Error: could not write '%s' variable to U-Boot environment\n", ENV_VAR_BOOTCOUNT); + ret = -1; + } else if (count == 0) { + /* Clear 'upgrade_available' variable. */ + ret = uboot_setenv(ENV_VAR_UPGRADE_AVAILABLE, NULL); + if (ret) { + fprintf(stderr, "Error: could not unset '%s' variable in U-Boot environment\n", ENV_VAR_UPGRADE_AVAILABLE); + ret = -1; + } + } else { + /* Set 'upgrade_available' variable to '1'. */ + snprintf(value_str, sizeof(value_str), "%u", 1); + ret = uboot_setenv(ENV_VAR_UPGRADE_AVAILABLE, value_str); + if (ret) { + fprintf(stderr, "Error: could not set '%s' variable in U-Boot environment\n", ENV_VAR_UPGRADE_AVAILABLE); + ret = -1; + } + } + + return ret; +} diff --git a/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/bootcount_nvmem.c b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/bootcount_nvmem.c new file mode 100644 index 000000000..fa462c426 --- /dev/null +++ b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/bootcount_nvmem.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2023, Digi International Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at http://mozilla.org/MPL/2.0/. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include + +#include "file_utils.h" +#include "bootcount_nvmem.h" +#include "platform_utils.h" + +/* Platform struct for the bootcount nvmem access */ +struct platform_nvmem { + const char *nvmem_path; + long bootcount_offset; + int bootcount_size; +}; + +/* List of platform structs for the bootcount nvmem access */ +struct platform_nvmem platforms_nvmem[] = { + [PLATFORM_CC6QP] = {NULL, 0, 1}, + [PLATFORM_CC6SBC] = {NULL, 0, 1}, + [PLATFORM_CC6UL] = {"/sys/bus/i2c/devices/0-007e/nvram", 0, 1}, + [PLATFORM_CC8MM] = {"/sys/bus/i2c/devices/0-0063/nvram", 0, 1}, + [PLATFORM_CC8MN] = {"/sys/bus/i2c/devices/0-0063/nvram", 0, 1}, + [PLATFORM_CC8X] = {"/sys/bus/i2c/devices/0-0063/nvram", 0, 1}, + [PLATFORM_CC93] = {"/sys/bus/i2c/devices/2-0052/rv3028_nvram0/nvmem", 0, 1}, + [PLATFORM_CCMP13] = {"/sys/bus/i2c/devices/2-0052/rv3028_nvram0/nvmem", 0, 1}, + [PLATFORM_CCMP15] = {"/sys/bus/i2c/devices/6-0052/rv3028_nvram0/nvmem", 0, 1}, + [PLATFORM_UNKNOWN] = {NULL, 0, 0}, +}; + +/* Variables. */ +extern platform_t platform; + +int read_bootcount_nvmem() { + char value; + int ret; + struct platform_nvmem *platform_data = &platforms_nvmem[platform]; + + ret = read_file(platform_data->nvmem_path, &value, platform_data->bootcount_offset, platform_data->bootcount_size); + if (!ret) { + return value; + } else { + return -1; + } +} + +int write_bootcount_nvmem(uint count) { + char value = (char)(count & 0xFF); + struct platform_nvmem *platform_data = &platforms_nvmem[platform]; + + return write_file(platform_data->nvmem_path, &value, platform_data->bootcount_offset, platform_data->bootcount_size); +} diff --git a/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/file_utils.c b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/file_utils.c new file mode 100644 index 000000000..a5b435edd --- /dev/null +++ b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/file_utils.c @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2023, Digi International Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at http://mozilla.org/MPL/2.0/. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#include "file_utils.h" + +int read_file(const char* path, char* buffer, long offset, int num_bytes) { + FILE* file; + int ret = -1; + + /* Sanity check. */ + if (path == NULL) { + fprintf(stderr, "Error opening file: path is NULL"); + return ret; + } + + file = fopen(path, "rb"); + if (!file) { + fprintf(stderr, "Error opening file"); + return ret; + } + + fseek(file, offset, SEEK_SET); + ret = fread(buffer, sizeof(char), num_bytes, file); + if (ret != num_bytes) { + printf("Error reading from file '%s'\n", path); + ret = -1; + } else { + ret = 0; + } + + fclose(file); + return ret; +} + +int write_file(const char* path, const char* data, long offset, int num_bytes) { + FILE* file; + int ret = -1; + + /* Sanity check. */ + if (path == NULL) { + fprintf(stderr, "Error opening file: path is NULL"); + return ret; + } + + file = fopen(path, "r+b"); + if (!file) { + fprintf(stderr, "Error opening file"); + return ret; + } + + fseek(file, offset, SEEK_SET); + ret = fwrite(data, sizeof(char), num_bytes, file); + if (ret != num_bytes) { + printf("Error writing to file '%s'\n", path); + ret = -1; + } else { + ret = 0; + } + + fclose(file); + return ret; +} diff --git a/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/include/bootcount_env.h b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/include/bootcount_env.h new file mode 100644 index 000000000..072817cfd --- /dev/null +++ b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/include/bootcount_env.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023, Digi International Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at http://mozilla.org/MPL/2.0/. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef BOOTCOUNT_ENV_H +#define BOOTCOUNT_ENV_H + +#include +#include + +/** + * @brief Read the 'bootcount' variable from the U-Boot environment. + * + * This function retrieves the 'bootcount' value from the U-Boot environment and + * converts it to an integer. + * + * @return The 'bootcount' value as an integer on success, -1 on error. + */ +int read_bootcount_env(); + +/** + * @brief Set the 'bootcount' variable in the U-Boot environment. + * + * This function sets the 'bootcount' value to the given one in the U-Boot environment. + * +* @param count The new bootcount value to set. + * + * @return 0 on success, -1 on error. + */ +int write_bootcount_env(uint count); + +#endif /* BOOTCOUNT_ENV_H */ diff --git a/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/include/bootcount_nvmem.h b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/include/bootcount_nvmem.h new file mode 100644 index 000000000..20d4dd301 --- /dev/null +++ b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/include/bootcount_nvmem.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023, Digi International Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at http://mozilla.org/MPL/2.0/. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef BOOTCOUNT_NVMEM_H +#define BOOTCOUNT_NVMEM_H + +#include + +/** + * @brief Read the 'bootcount' value from the NVMEM registers. + * + * The method performs an internal check to use the correct NVMEM path depending + * on the running platform. + * + * @return The 'bootcount' value as an integer on success, -1 on error. + */ +int read_bootcount_nvmem(); + +/** + * @brief Write the 'bootcount' value to the NVMEM registers. + * + * The method performs an internal check to use the correct NVMEM path depending + * on the running platform. + * + * @param count The new bootcount value to set. + * + * @return 0 on success, -1 on error. + */ +int write_bootcount_nvmem(uint count); + +#endif /* BOOTCOUNT_NVMEM_H */ diff --git a/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/include/file_utils.h b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/include/file_utils.h new file mode 100644 index 000000000..776f050fe --- /dev/null +++ b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/include/file_utils.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023, Digi International Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at http://mozilla.org/MPL/2.0/. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef FILE_UTILS_H +#define FILE_UTILS_H + +/** + * @brief Reads data from a binary file into the provided buffer. + * + * This function opens the specified binary file in read mode and reads up to + * 'num_bytes' of data starting at 'offset' into the provided 'buffer'. + * + * @param path The path to the binary file to read. + * @param buffer The buffer to store the read data. + * @param offset The offset from where to start reading in the file. + * @param num_bytes The number of bytes to read. + * + * @return 0 on success, -1 on error. + */ +int read_file(const char* path, char* buffer, long offset, int num_bytes); + +/** + * @brief Writes data to a binary file at the specified offset. + * + * This function opens the specified binary file in read/write mode and writes up to + * 'num_bytes' of data from the provided 'data' buffer starting at 'offset' in the file. + * + * @param path The path to the binary file to write to. + * @param data The buffer containing the data to write to the file. + * @param offset The offset in the file where to start writing. + * @param num_bytes The number of bytes to write. + * + * @return 0 on success, -1 on error. + */ +int write_file(const char* path, const char* data, long offset, int num_bytes); + +#endif /* FILE_UTILS_H */ diff --git a/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/include/platform_utils.h b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/include/platform_utils.h new file mode 100644 index 000000000..7086c1a8c --- /dev/null +++ b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/include/platform_utils.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023, Digi International Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at http://mozilla.org/MPL/2.0/. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef PLATFORM_UTILS_H +#define PLATFORM_UTILS_H + +#include + +/* List of all available platforms. */ +typedef enum { + PLATFORM_CC6QP, + PLATFORM_CC6SBC, + PLATFORM_CC6UL, + PLATFORM_CC8MM, + PLATFORM_CC8MN, + PLATFORM_CC8X, + PLATFORM_CC93, + PLATFORM_CCMP13, + PLATFORM_CCMP15, + PLATFORM_UNKNOWN +} platform_t; + +/* List of all platform names. */ +extern char* platform_names[]; + +/** + * @brief Retrieve the running platform. + * + * The running platform is determined by reading the corresponding entry from + * the device tree. + * + * @return The running platform, 'PLATFORM_UNKNOWN' if the platform cannot be determined. + */ +platform_t get_platform(); + +#endif /* PLATFORM_UTILS_H */ diff --git a/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/platform_utils.c b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/platform_utils.c new file mode 100644 index 000000000..937ef7b57 --- /dev/null +++ b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/platform_utils.c @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2023, Digi International Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at http://mozilla.org/MPL/2.0/. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include + +#include "file_utils.h" +#include "platform_utils.h" + +#define DT_COMPATIBLE_NODE "/proc/device-tree/compatible" + +char* platform_names[] = { + [PLATFORM_CC6QP] = "ccimx6qp", + [PLATFORM_CC6SBC] = "ccimx6sbc", + [PLATFORM_CC6UL] = "ccimx6ul", + [PLATFORM_CC8MM] = "ccimx8mm", + [PLATFORM_CC8MN] = "ccimx8mn", + [PLATFORM_CC8X] = "ccimx8x", + [PLATFORM_CC93] = "ccimx93", + [PLATFORM_CCMP13] = "ccmp13", + [PLATFORM_CCMP15] = "ccmp15", + [PLATFORM_UNKNOWN] = "unknown" +}; + +/** + * @brief Checks if the running platform matches the given platform name. + * + * The running platform is determined by reading the corresponding entry from + * the device tree. + * + * @param platform_name The name of the platform to check. + * + * @return true if the given platform name matches the running one, false otherwise. + */ +platform_t get_platform() { + FILE *fd; + char buffer[100]; + int bytes_read = 0; + platform_t platform = PLATFORM_UNKNOWN; + + fd = fopen(DT_COMPATIBLE_NODE, "r"); + if (fd == NULL) { + fprintf(stderr, "No DT node " DT_COMPATIBLE_NODE "\n"); + return platform; + } + + /* The 'compatible' node specifies multiple strings null-deliniated. The fread() will read + * the full file, however, strstr() will consider data up to the first null byte. The strings + * comparison must continue until bytes_read number is reached. + */ + while (feof(fd) == 0 && ferror(fd) == 0 && platform == PLATFORM_UNKNOWN) { + if ((bytes_read = fread(buffer, 1, sizeof(buffer)-1, fd)) > 0 ) { + buffer[bytes_read] = 0; // null-terminate the full string + char *ptr = buffer; + while (ptr < buffer + bytes_read) { + platform = 0; + while (platform < PLATFORM_UNKNOWN) { + if (strstr(ptr, platform_names[platform]) != NULL) { + goto end; + } + platform += 1; + } + ptr += strlen(ptr) + 1; + } + } + } + +end: + fclose(fd); + return platform; +} diff --git a/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-init/bootcount-init b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-init/bootcount-init new file mode 100644 index 000000000..7d0bb6714 --- /dev/null +++ b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-init/bootcount-init @@ -0,0 +1,26 @@ +#!/bin/sh +#=============================================================================== +# +# Copyright (C) 2023 by Digi International Inc. +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published by +# the Free Software Foundation. +# +# +# !Description: Clear bootcount value +# +#=============================================================================== + +case "$1" in + start) + echo -n "Resetting bootcount value... " + bootcount -r + echo "done." + ;; + *) + echo "Usage: $0 {start}" + exit 1 + ;; +esac diff --git a/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-init/bootcount-init.service b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-init/bootcount-init.service new file mode 100755 index 000000000..22b6e042e --- /dev/null +++ b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-init/bootcount-init.service @@ -0,0 +1,12 @@ +[Unit] +Description=Reset bootcount value +After=default.target + +[Service] +Type=simple +RemainAfterExit=no +ExecStart=/etc/bootcount-init start +TimeoutStartSec=0 + +[Install] +WantedBy=default.target diff --git a/meta-digi-dey/recipes-digi/cccs/cccs_git.bb b/meta-digi-dey/recipes-digi/cccs/cccs_git.bb new file mode 100644 index 000000000..d35847eca --- /dev/null +++ b/meta-digi-dey/recipes-digi/cccs/cccs_git.bb @@ -0,0 +1,132 @@ +# Copyright (C) 2017-2023, Digi International Inc. + +SUMMARY = "Digi's ConnectCore Cloud services" +SECTION = "libs" +LICENSE = "MPL-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad" + +DEPENDS = "libconfuse libdigiapix openssl recovery-utils swupdate zlib json-c" + +SRCBRANCH = "master" +SRCREV = "${AUTOREV}" + +CC_STASH = "gitsm://git@stash.digi.com/cc/cc_dey.git;protocol=ssh" +CC_GITHUB = "gitsm://github.com/digi-embedded/cc_dey.git;protocol=https" + +CC_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${CC_STASH}', '${CC_GITHUB}', d)}" + +CCCS_DEVICE_TYPE ?= "${MACHINE}" + +SRC_URI = " \ + ${CC_GIT_URI};branch=${SRCBRANCH} \ + file://cccsd-init \ + file://cccsd.service \ + file://cccs-gs-demo-init \ + file://cccs-gs-demo.service \ +" + +S = "${WORKDIR}/git" + +inherit pkgconfig systemd update-rc.d + +do_install() { + oe_runmake DESTDIR=${D} install + + if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then + # Install systemd unit files + install -d ${D}${systemd_unitdir}/system + install -m 0644 ${WORKDIR}/cccsd.service ${D}${systemd_unitdir}/system/ + install -m 0644 ${WORKDIR}/cccs-gs-demo.service ${D}${systemd_unitdir}/system/ + fi + + install -d ${D}${sysconfdir}/init.d/ + install -m 755 ${WORKDIR}/cccsd-init ${D}${sysconfdir}/cccsd + ln -sf /etc/cccsd ${D}${sysconfdir}/init.d/cccsd + install -m 755 ${WORKDIR}/cccs-gs-demo-init ${D}${sysconfdir}/cccs-gs-demo + ln -sf /etc/cccs-gs-demo ${D}${sysconfdir}/init.d/cccs-gs-demo + + # Set the device type. Its maximum length is 255 characters + [ -z "${CCCS_DEVICE_TYPE}" ] && device_type="${MACHINE}" || device_type="${CCCS_DEVICE_TYPE}" + device_type="$(echo "${device_type}" | cut -c1-255)" + sed -i "/device_type = .*/c\device_type = \"${device_type}\"" ${D}${sysconfdir}/cccs.conf +} + +do_install:append:ccimx6ul() { + sed -i "/url = \"edp12.devicecloud.com\"/c\url = \"remotemanager.digi.com\"" ${D}${sysconfdir}/cccs.conf + sed -i "/client_cert_path = \"\/mnt\/data\/drm_cert.pem\"/c\client_cert_path = \"\/etc\/ssl\/certs\/drm_cert.pem\"" ${D}${sysconfdir}/cccs.conf +} + +pkg_postinst_ontarget:${PN}() { + # If dualboot is enabled, change the CCCSD download path on the first boot + if [ "$(fw_printenv -n dualboot 2>/dev/null)" = "yes" ]; then + sed -i "/firmware_download_path = \/mnt\/update/c\firmware_download_path = \/home\/root" /etc/cccs.conf + fi +} + +inherit ${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "remove-pkg-postinst-ontarget", "", d)} + +INITSCRIPT_PACKAGES = "${PN}-daemon ${PN}-gs-demo" +INITSCRIPT_NAME:${PN}-daemon = "cccsd" +INITSCRIPT_PARAMS:${PN}-daemon = "defaults 19 81" +INITSCRIPT_NAME:${PN}-gs-demo = "cccs-gs-demo" +INITSCRIPT_PARAMS:${PN}-gs-demo = "defaults 81 19" + +SYSTEMD_PACKAGES = "${PN}-daemon ${PN}-gs-demo" +SYSTEMD_SERVICE:${PN}-daemon = "cccsd.service" +SYSTEMD_SERVICE:${PN}-gs-demo = "cccs-gs-demo.service" + +PACKAGES =+ " \ + ${PN}-cert \ + ${PN}-daemon \ + ${PN}-gs-demo \ + ${PN}-legacy \ + ${PN}-legacy-dev \ + ${PN}-legacy-staticdev \ +" + +FILES:${PN}-cert = "${sysconfdir}/ssl/certs/Digi_Int-ca-cert-public.crt" + +FILES:${PN}-daemon = " \ + ${bindir}/cccsd \ + ${systemd_unitdir}/system/cccsd.service \ + ${sysconfdir}/cccsd \ + ${sysconfdir}/cccs.conf \ + ${sysconfdir}/init.d/cccsd \ +" + +FILES:${PN}-gs-demo = " \ + ${bindir}/cccs-gs-demo \ + ${systemd_unitdir}/system/cccs-gs-demo.service \ + ${sysconfdir}/cccs-gs-demo \ +" + +FILES:${PN}-legacy = " \ + ${bindir}/cloud-connector \ + ${sysconfdir}/cc.conf \ +" + +FILES:${PN}-legacy-dev = " \ + ${includedir}/cloudconnector \ + ${libdir}/pkgconfig/cloudconnector.pc \ +" + +FILES:${PN}-legacy-staticdev = " \ + ${libdir}/libcloudconnector.a \ +" + +CONFFILES:${PN}-daemon += "${sysconfdir}/cccs.conf" + +CONFFILES:${PN}-legacy += "${sysconfdir}/cc.conf" + +RDEPENDS:${PN}-daemon = "${PN} ${PN}-cert" + +RDEPENDS:${PN}-gs-demo = "${PN}-daemon" + +RDEPENDS:${PN}-legacy = "${PN} ${PN}-cert" + +# 'cccsd-init' and 'cccs-gs-demo-init' scripts use '/etc/init.d/functions' +RDEPENDS:${PN}-daemon += "initscripts-functions" +RDEPENDS:${PN}-gs-demo += "initscripts-functions" + +# Disable extra compilation checks from SECURITY_CFLAGS to avoid build errors +lcl_maybe_fortify:pn-cccs = "" diff --git a/meta-digi-dey/recipes-digi/cccs/files/cccs-gs-demo-init b/meta-digi-dey/recipes-digi/cccs/files/cccs-gs-demo-init new file mode 100644 index 000000000..fffca4212 --- /dev/null +++ b/meta-digi-dey/recipes-digi/cccs/files/cccs-gs-demo-init @@ -0,0 +1,46 @@ +#!/bin/sh +#=============================================================================== +# +# Copyright (C) 2022, 2023 by Digi International Inc. +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published by +# the Free Software Foundation. +# +# +# !Description: ConnectCore Cloud Services get started demo start/stop script +# +#=============================================================================== + +# Source function library: status and killproc +. /etc/init.d/functions + +readonly CCCS_DEMO_BINARY="/usr/bin/cccs-gs-demo" +readonly STOP_TIMEOUT="5" + +case "$1" in + start) + status ${CCCS_DEMO_BINARY} > /dev/null || ${CCCS_DEMO_BINARY}>/dev/null 2>&1 & + ;; + stop) + # Try to stop gracefully + killproc ${CCCS_DEMO_BINARY} >/dev/null 2>&1 + for i in $(seq ${STOP_TIMEOUT}); do + pid="$(pidof -o $$ "${CCCS_DEMO_BINARY}")" || break + if [ "${i}" -eq ${STOP_TIMEOUT} ]; then + kill -KILL "${pid}" >/dev/null 2>&1 + fi + sleep 1 + done + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac diff --git a/meta-digi-dey/recipes-digi/cccs/files/cccs-gs-demo.service b/meta-digi-dey/recipes-digi/cccs/files/cccs-gs-demo.service new file mode 100644 index 000000000..02e94f52d --- /dev/null +++ b/meta-digi-dey/recipes-digi/cccs/files/cccs-gs-demo.service @@ -0,0 +1,16 @@ +[Unit] +Description=CCCS get start demo +After=cccsd.service +BindsTo=cccsd.service +Upholds=cccsd.service + +[Service] +Type=forking +ExecStart=/etc/cccs-gs-demo start +ExecStop=/etc/cccs-gs-demo stop +# SIGTERM signal is a valid status value +SuccessExitStatus=143 +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/meta-digi-dey/recipes-digi/cloudconnector/files/cloud-connector-init b/meta-digi-dey/recipes-digi/cccs/files/cccsd-init similarity index 64% rename from meta-digi-dey/recipes-digi/cloudconnector/files/cloud-connector-init rename to meta-digi-dey/recipes-digi/cccs/files/cccsd-init index f776aef9d..0a3a8a7c5 100644 --- a/meta-digi-dey/recipes-digi/cloudconnector/files/cloud-connector-init +++ b/meta-digi-dey/recipes-digi/cccs/files/cccsd-init @@ -1,7 +1,7 @@ #!/bin/sh #=============================================================================== # -# Copyright (C) 2022 by Digi International Inc. +# Copyright (C) 2022, 2023 by Digi International Inc. # All rights reserved. # # This program is free software; you can redistribute it and/or modify it @@ -9,25 +9,25 @@ # the Free Software Foundation. # # -# !Description: Initialize Cloud Connector service +# !Description: ConnectCore Cloud Services daemon start/stop script # #=============================================================================== -# Source function library: status, pidofproc and killproc +# Source function library: status and killproc . /etc/init.d/functions -readonly CC_BINARY="/usr/bin/cloud-connector" +readonly CCCSD_BINARY="/usr/bin/cccsd" readonly STOP_TIMEOUT="5" case "$1" in start) - status ${CC_BINARY} > /dev/null || ${CC_BINARY} -d > /dev/null 2>&1 + status ${CCCSD_BINARY} > /dev/null || ${CCCSD_BINARY} -d > /dev/null 2>&1 ;; stop) - # try to stop gracefully - killproc ${CC_BINARY} >/dev/null 2>&1 + # Try to stop gracefully + killproc ${CCCSD_BINARY} >/dev/null 2>&1 for i in $(seq ${STOP_TIMEOUT}); do - pid=$(pidofproc ${CC_BINARY}) || break + pid="$(pidof -o $$ "${CCCSD_BINARY}")" || break if [ "${i}" -eq ${STOP_TIMEOUT} ]; then kill -KILL "${pid}" >/dev/null 2>&1 fi diff --git a/meta-digi-dey/recipes-digi/cccs/files/cccsd.service b/meta-digi-dey/recipes-digi/cccs/files/cccsd.service new file mode 100644 index 000000000..f63515d85 --- /dev/null +++ b/meta-digi-dey/recipes-digi/cccs/files/cccsd.service @@ -0,0 +1,14 @@ +[Unit] +Description=CCCS daemon +After=network.target + +[Service] +Type=forking +ExecStart=/etc/cccsd start +ExecStop=/etc/cccsd stop +PIDFile=/run/cccsd.pid +Restart=on-failure + +[Install] +WantedBy=multi-user.target +Alias=cloud-connector.service diff --git a/meta-digi-dey/recipes-digi/cloudconnector/cloudconnector_git.bb b/meta-digi-dey/recipes-digi/cloudconnector/cloudconnector_git.bb deleted file mode 100644 index 2ddc74bb4..000000000 --- a/meta-digi-dey/recipes-digi/cloudconnector/cloudconnector_git.bb +++ /dev/null @@ -1,77 +0,0 @@ -# Copyright (C) 2017-2022, Digi International Inc. - -SUMMARY = "Digi's device cloud connector" -SECTION = "libs" -LICENSE = "MPL-2.0" -LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad" - -DEPENDS = "libconfuse libdigiapix openssl recovery-utils swupdate zlib json-c" - -SRCBRANCH = "dey-4.0/maint" -SRCREV = "${AUTOREV}" - -CC_STASH = "gitsm://git@stash.digi.com/cc/cc_dey.git;protocol=ssh" -CC_GITHUB = "gitsm://github.com/digi-embedded/cc_dey.git;protocol=https" - -CC_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${CC_STASH}', '${CC_GITHUB}', d)}" - -SRC_URI = " \ - ${CC_GIT_URI};branch=${SRCBRANCH} \ - file://cloud-connector-init \ - file://cloud-connector.service \ -" - -S = "${WORKDIR}/git" - -inherit pkgconfig systemd update-rc.d - -do_install() { - oe_runmake DESTDIR=${D} install - - if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then - # Install systemd unit files - install -d ${D}${systemd_unitdir}/system - install -m 0644 ${WORKDIR}/cloud-connector.service ${D}${systemd_unitdir}/system/ - fi - - install -d ${D}${sysconfdir}/init.d/ - install -m 755 ${WORKDIR}/cloud-connector-init ${D}${sysconfdir}/cloud-connector - ln -sf /etc/cloud-connector ${D}${sysconfdir}/init.d/cloud-connector -} - -do_install:append:ccimx6ul() { - sed -i "/url = \"edp12.devicecloud.com\"/c\url = \"remotemanager.digi.com\"" ${D}${sysconfdir}/cc.conf - sed -i "/client_cert_path = \"\/mnt\/data\/drm_cert.pem\"/c\client_cert_path = \"\/etc\/ssl\/certs\/drm_cert.pem\"" ${D}${sysconfdir}/cc.conf -} - -pkg_postinst_ontarget:${PN}() { - # If dualboot is enabled, change the CloudConnector download path on the first boot - if [ "$(fw_printenv -n dualboot 2>/dev/null)" = "yes" ]; then - sed -i "/firmware_download_path = \/mnt\/update/c\firmware_download_path = \/home\/root" /etc/cc.conf - fi -} - -inherit ${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "remove-pkg-postinst-ontarget", "", d)} - -INITSCRIPT_NAME = "cloud-connector" -SYSTEMD_SERVICE:${PN} = "cloud-connector.service" - -PACKAGES =+ "${PN}-cert" - -FILES:${PN} += " \ - ${systemd_unitdir}/system/cloud-connector.service \ - ${sysconfdir}/cloud-connector \ - ${sysconfdir}/init.d/cloud-connector \ -" - -FILES:${PN}-cert = "${sysconfdir}/ssl/certs/Digi_Int-ca-cert-public.crt" - -CONFFILES:${PN} += "${sysconfdir}/cc.conf" - -RDEPENDS:${PN} = "${PN}-cert" - -# 'cloud-connector-init' script uses '/etc/init.d/functions' -RDEPENDS:${PN} += "initscripts-functions" - -# Disable extra compilation checks from SECURITY_CFLAGS to avoid build errors -lcl_maybe_fortify:pn-cloudconnector = "" diff --git a/meta-digi-dey/recipes-digi/cloudconnector/files/cloud-connector.service b/meta-digi-dey/recipes-digi/cloudconnector/files/cloud-connector.service deleted file mode 100644 index 5df91d30e..000000000 --- a/meta-digi-dey/recipes-digi/cloudconnector/files/cloud-connector.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=Cloud Connector service initialization -After=network.target - -[Service] -Type=forking -ExecStart=/etc/cloud-connector start -ExecStop=/etc/cloud-connector stop - -[Install] -WantedBy=multi-user.target diff --git a/meta-digi-dey/recipes-digi/dey-examples/dey-examples-cccs.bb b/meta-digi-dey/recipes-digi/dey-examples/dey-examples-cccs.bb new file mode 100644 index 000000000..ba19d5475 --- /dev/null +++ b/meta-digi-dey/recipes-digi/dey-examples/dey-examples-cccs.bb @@ -0,0 +1,26 @@ +# Copyright (C) 2017-2023 Digi International Inc. + +require recipes-digi/dey-examples/dey-examples-src.inc + +SUMMARY = "DEY examples: ConnectCore Cloud Services example applications" +SECTION = "examples" +LICENSE = "ISC" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/ISC;md5=f3b90e78ea0cffb20bf5cca7947a896d" + +DEPENDS = "cccs" + +S = "${WORKDIR}/git" + +inherit pkgconfig + +EXTRA_OEMAKE += "-f cccs-examples.mk" + +do_compile() { + oe_runmake +} + +do_install() { + oe_runmake DESTDIR=${D} install +} + +RDEPENDS:${PN} = "cccs-daemon" diff --git a/meta-digi-dey/recipes-digi/dey-examples/dey-examples-cloudconnector.bb b/meta-digi-dey/recipes-digi/dey-examples/dey-examples-cloudconnector.bb deleted file mode 100644 index 919f33792..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/dey-examples-cloudconnector.bb +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (C) 2017, 2018 Digi International Inc. - -SUMMARY = "DEY examples: Remote Manager test applications" -SECTION = "examples" -LICENSE = "MPL-2.0" -LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad" - -DEPENDS = "cloudconnector" - -SRC_URI = "file://cloudconnector_test" - -S = "${WORKDIR}/cloudconnector_test" - -inherit pkgconfig - -do_install() { - oe_runmake DESTDIR=${D} install -} - -RDEPENDS:${PN} = "cloudconnector-cert" diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/Makefile b/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/Makefile deleted file mode 100644 index 068457973..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -# *************************************************************************** -# Copyright (c) 2017-2023 Digi International Inc. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this file, -# You can obtain one at http://mozilla.org/MPL/2.0/. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. -# -# Digi International Inc., 9350 Excelsior Blvd., Suite 700, Hopkins, MN 55343 -# -# *************************************************************************** - -PROGRAM := device_request_listener - -CFLAGS += -Wall - -CFLAGS += $(shell pkg-config --cflags cloudconnector) -LDLIBS += $(shell pkg-config --libs --static cloudconnector) - -all: $(PROGRAM) - -OBJS = device_request.o main.o - -$(PROGRAM): $(OBJS) - $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ - -.PHONY: install -install: $(PROGRAM) - install -d $(DESTDIR)/usr/bin - install -m 0755 $(PROGRAM) $(DESTDIR)/usr/bin/ - -.PHONY: clean -clean: - -rm -f *.o $(PROGRAM) diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/device_request.c b/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/device_request.c deleted file mode 100644 index 992a73f30..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/device_request.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2017-2023 Digi International Inc. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Digi International Inc., 9350 Excelsior Blvd., Suite 700, Hopkins, MN 55343 - * =========================================================================== - */ - -#include -#include -#include -#include - -#include "device_request.h" - -#if !(defined UNUSED_ARGUMENT) -#define UNUSED_ARGUMENT(a) (void)(a) -#endif - -/* - * get_time_cb() - Data callback for 'get_time' device requests - * - * @target: Target ID of the device request (get_time). - * @transport: Communication transport used by the device request. - * @req_buf_info: Buffer containing the device request. - * @resp_buf_info: Buffer to store the answer of the request. - * - * Logs information about the received request and executes the corresponding - * command. - */ -ccapi_receive_error_t get_time_cb(char const *const target, - ccapi_transport_t const transport, - ccapi_buffer_info_t const *const req_buf_info, - ccapi_buffer_info_t *const resp_buf_info) -{ - time_t t = time(NULL); - char *time_str = ctime(&t); - - UNUSED_ARGUMENT(req_buf_info); - log_debug("%s: target='%s' - transport='%d'", __func__, target, transport); - - resp_buf_info->length = snprintf(NULL, 0, "Time: %s", time_str); - resp_buf_info->buffer = calloc(resp_buf_info->length + 1, sizeof(char)); - if (resp_buf_info->buffer == NULL) { - log_error("%s: resp_buf_info calloc error", __func__); - return CCAPI_RECEIVE_ERROR_INSUFFICIENT_MEMORY; - } - - resp_buf_info->length = sprintf(resp_buf_info->buffer, "Time: %s", time_str); - - return CCAPI_RECEIVE_ERROR_NONE; -} - -/* - * get_time_status_cb() - Status callback for 'get_time' device requests - * - * @target: Target ID of the device request (get_time) - * @transport: Communication transport used by the device request. - * @resp_buf_info: Buffer containing the response data. - * @receive_error: The error status of the receive process. - * - * This callback is executed when the response process has finished. It doesn't - * matter if everything worked or there was an error during the process. - * - * Cleans and frees the response buffer. - */ -void get_time_status_cb(char const *const target, - ccapi_transport_t const transport, - ccapi_buffer_info_t *const resp_buf_info, - ccapi_receive_error_t receive_error) -{ - log_debug("%s: target='%s' - transport='%d' - error='%d'", - __func__, target, transport, receive_error); - - /* Free the response buffer */ - if (resp_buf_info != NULL) - free(resp_buf_info->buffer); -} diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/device_request.h b/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/device_request.h deleted file mode 100644 index bdd9530c3..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/device_request.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2017-2023 Digi International Inc. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Digi International Inc., 9350 Excelsior Blvd., Suite 700, Hopkins, MN 55343 - * =========================================================================== - */ - -#ifndef DEVICE_REQUEST_H_ -#define DEVICE_REQUEST_H_ - -#include - -#define TARGET_GET_TIME "get_time" - -ccapi_receive_error_t get_time_cb(char const *const target, - ccapi_transport_t const transport, - ccapi_buffer_info_t const *const req_buf_info, - ccapi_buffer_info_t *const resp_buf_info); -void get_time_status_cb(char const *const target, - ccapi_transport_t const transport, - ccapi_buffer_info_t *const resp_buf_info, - ccapi_receive_error_t receive_error); - -#endif /* DEVICE_REQUEST_H_ */ diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/main.c b/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/main.c deleted file mode 100644 index 4e29aca32..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/device_request_listener/main.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2017-2023 Digi International Inc. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Digi International Inc., 9350 Excelsior Blvd., Suite 700, Hopkins, MN 55343 - * =========================================================================== - */ - -#include -#include -#include -#include -#include - -#include "device_request.h" - -static void sigint_handler(int signum) -{ - log_debug("%s: received signal %d to close Cloud connection.", - __func__, signum); - - exit(0); -} - -static void graceful_shutdown(void) -{ - stop_cloud_connection(); -} - -static void add_sigkill_signal(void) -{ - struct sigaction new_action; - struct sigaction old_action; - - atexit(graceful_shutdown); - - /* Setup signal hander. */ - new_action.sa_handler = sigint_handler; - sigemptyset(&new_action.sa_mask); - new_action.sa_flags = 0; - sigaction(SIGINT, NULL, &old_action); - if (old_action.sa_handler != SIG_IGN) - sigaction(SIGINT, &new_action, NULL); -} - - -/* - * Use the following SCI request to test this example (insert your Device ID): - * - * - * - * - * - * - * - * - * - * - * - * - */ - -int main(void) -{ - cc_init_error_t init_error; - cc_start_error_t start_error; - ccapi_receive_error_t receive_error; - - add_sigkill_signal(); - - init_error = init_cloud_connection(NULL); - if (init_error != CC_INIT_ERROR_NONE) { - log_error("Cannot initialize cloud connection, error %d", init_error); - return EXIT_FAILURE; - } - - start_error = start_cloud_connection(); - if (start_error != CC_START_ERROR_NONE) { - log_error("Cannot start cloud connection, error %d", start_error); - return EXIT_FAILURE; - } - - receive_error = ccapi_receive_add_target(TARGET_GET_TIME, get_time_cb, - get_time_status_cb, 0); - if (receive_error != CCAPI_RECEIVE_ERROR_NONE) { - log_error("Cannot register target '%s', error %d", TARGET_GET_TIME, - receive_error); - return EXIT_FAILURE; - } - - printf("Waiting for Remote Manager request...\n"); - printf("Press a key to exit\n"); - getchar(); - - return EXIT_SUCCESS; -} diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/Makefile b/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/Makefile deleted file mode 100644 index 80b011a0e..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -# *************************************************************************** -# Copyright (c) 2017-2023 Digi International Inc. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this file, -# You can obtain one at http://mozilla.org/MPL/2.0/. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. -# -# Digi International Inc., 9350 Excelsior Blvd., Suite 700, Hopkins, MN 55343 -# -# *************************************************************************** - -PROGRAM := upload_data_points - -CFLAGS += -Wall - -CFLAGS += $(shell pkg-config --cflags cloudconnector) -LDLIBS += $(shell pkg-config --libs --static cloudconnector) - -all: $(PROGRAM) - -OBJS = data_point.o main.o - -$(PROGRAM): $(OBJS) - $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ - -.PHONY: install -install: $(PROGRAM) - install -d $(DESTDIR)/usr/bin - install -m 0755 $(PROGRAM) $(DESTDIR)/usr/bin/ - -.PHONY: clean -clean: - -rm -f *.o $(PROGRAM) diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/data_point.c b/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/data_point.c deleted file mode 100644 index b469fe26b..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/data_point.c +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) 2017-2023 Digi International Inc. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Digi International Inc., 9350 Excelsior Blvd., Suite 700, Hopkins, MN 55343 - * =========================================================================== - */ - -#include -#include -#include - -#include "data_point.h" - -#define STREAM_NAME "incremental" - -/* - * get_incremental() - Retrieves an incremental value each time - */ -static int get_incremental(void) -{ - static int incremental = -1; - - if (incremental == INT_MAX) - incremental = 0; - else - incremental++; - - log_debug("Incremental = %d", incremental); - - return incremental; -} - -/* - * get_timestamp() - Get the current timestamp of the system - * - * Return: The timestamp of the system. - */ -static ccapi_timestamp_t *get_timestamp(void) -{ - ccapi_timestamp_t *timestamp = NULL; - size_t len = strlen("2016-09-27T07:07:09.546Z") + 1; - char *date = NULL; - time_t now; - - timestamp = (ccapi_timestamp_t*) malloc(sizeof(ccapi_timestamp_t)); - if (timestamp == NULL) - return NULL; - - date = (char*) malloc(sizeof(char) * len); - if (date == NULL) { - free(timestamp); - return NULL; - } - - time(&now); - if (strftime(date, len, "%FT%TZ", gmtime(&now)) > 0) { - timestamp->iso8601 = date; - } else { - free(date); - timestamp->iso8601 = NULL; - } - - return timestamp; -} - -/* - * free_timestamp() - Free given timestamp structure - * - * @timestamp: The timestamp structure to release. - */ -static void free_timestamp(ccapi_timestamp_t *timestamp) -{ - if (timestamp == NULL) - return; - - if (timestamp->iso8601 != NULL) { - free((char *) timestamp->iso8601); - timestamp->iso8601 = NULL; - } - free(timestamp); - timestamp = NULL; -} - -ccapi_dp_error_t init_data_stream(ccapi_dp_collection_handle_t *dp_collection) -{ - ccapi_dp_collection_handle_t collection; - ccapi_dp_error_t dp_error = ccapi_dp_create_collection(&collection); - - if (dp_error != CCAPI_DP_ERROR_NONE) { - log_error("%s: error %d", __func__, dp_error); - return dp_error; - } else { - *dp_collection = collection; - } - - dp_error = ccapi_dp_add_data_stream_to_collection_extra(collection, - STREAM_NAME, "int32 ts_iso", "counts", NULL); - if (dp_error != CCAPI_DP_ERROR_NONE) { - log_error("%s: error %d", __func__, dp_error); - ccapi_dp_destroy_collection(collection); - *dp_collection = NULL; - } - - return dp_error; -} - -ccapi_dp_error_t add_data_point(ccapi_dp_collection_handle_t dp_collection) -{ - ccapi_timestamp_t *timestamp = get_timestamp(); - ccapi_dp_error_t dp_error = ccapi_dp_add(dp_collection, STREAM_NAME, - get_incremental(), timestamp); - - if (dp_error != CCAPI_DP_ERROR_NONE) - log_error("%s: failed with error: %d", __func__, dp_error); - - free_timestamp(timestamp); - - return dp_error; -} - -ccapi_dp_error_t send_data_stream(ccapi_dp_collection_handle_t dp_collection) -{ - ccapi_dp_error_t dp_error; - - log_debug("%s", "Sending Data Stream with new incremental value"); - - dp_error = ccapi_dp_send_collection(CCAPI_TRANSPORT_TCP, dp_collection); - if (dp_error != CCAPI_DP_ERROR_NONE) - log_error("%s: error %d", __func__, dp_error); - - return dp_error; -} - -ccapi_dp_error_t destroy_data_stream(ccapi_dp_collection_handle_t dp_collection) -{ - log_debug("%s", "Destroying Data Stream"); - return ccapi_dp_destroy_collection(dp_collection); -} diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/data_point.h b/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/data_point.h deleted file mode 100644 index 8be777c93..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/data_point.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2017-2023 Digi International Inc. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Digi International Inc., 9350 Excelsior Blvd., Suite 700, Hopkins, MN 55343 - * =========================================================================== - */ - -#ifndef DATA_POINT_H_ -#define DATA_POINT_H_ - -#include - -ccapi_dp_error_t init_data_stream(ccapi_dp_collection_handle_t *dp_collection); -ccapi_dp_error_t add_data_point(ccapi_dp_collection_handle_t dp_collection); -ccapi_dp_error_t send_data_stream(ccapi_dp_collection_handle_t dp_collection); -ccapi_dp_error_t destroy_data_stream(ccapi_dp_collection_handle_t dp_collection); - -#endif /* DATA_POINT_H_ */ diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/main.c b/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/main.c deleted file mode 100644 index 9cf6ddce0..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_data_points/main.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2017-2023 Digi International Inc. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Digi International Inc., 9350 Excelsior Blvd., Suite 700, Hopkins, MN 55343 - * =========================================================================== - */ - -#include -#include -#include -#include - -#include "data_point.h" - -#define DP_SLEEP_TIME 5 -#define DP_NUMBER 10 - -static int running = 1; -static ccapi_dp_collection_handle_t dp_collection; - -static void sigint_handler(int signum) -{ - log_debug("%s: received signal %d to close Cloud connection.", - __func__, signum); - - exit(0); -} - -static void graceful_shutdown(void) -{ - if (running == 1) - destroy_data_stream(dp_collection); - - running = 0; - stop_cloud_connection(); -} - -static void add_sigkill_signal(void) -{ - struct sigaction new_action; - struct sigaction old_action; - - atexit(graceful_shutdown); - - /* Setup signal hander. */ - new_action.sa_handler = sigint_handler; - sigemptyset(&new_action.sa_mask); - new_action.sa_flags = 0; - sigaction(SIGINT, NULL, &old_action); - if (old_action.sa_handler != SIG_IGN) - sigaction(SIGINT, &new_action, NULL); -} - - -int main(void) -{ - cc_init_error_t init_error; - cc_start_error_t start_error; - ccapi_dp_error_t dp_error; - int i; - - add_sigkill_signal(); - - init_error = init_cloud_connection(NULL); - if (init_error != CC_INIT_ERROR_NONE) { - log_error("Cannot initialize cloud connection, error %d", init_error); - return EXIT_FAILURE; - } - - start_error = start_cloud_connection(); - if (start_error != CC_START_ERROR_NONE) { - log_error("Cannot start cloud connection, error %d", start_error); - return EXIT_FAILURE; - } - - dp_error = init_data_stream(&dp_collection); - if (dp_error != CCAPI_DP_ERROR_NONE) { - log_error("Cannot initialize data stream, error %d", start_error); - return EXIT_FAILURE; - } - - running = CCAPI_TRUE; - while (running != CCAPI_FALSE) { - - /* Collect DP_NUMBER data points sampled each DP_SLEEP_TIME seconds */ - for (i = 0; i < DP_NUMBER; i++) { - dp_error = add_data_point(dp_collection); - - if (dp_error != CCAPI_DP_ERROR_NONE) { - log_error("Cannot add data point, error %d", start_error); - i--; - } - - sleep(DP_SLEEP_TIME); - } - - /* Send the block of collected data points */ - dp_error = send_data_stream(dp_collection); - if (dp_error != CCAPI_DP_ERROR_NONE) - log_error("Cannot send data stream, error %d", start_error); - } - - return EXIT_SUCCESS; -} diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_file/Makefile b/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_file/Makefile deleted file mode 100644 index ff67e421a..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_file/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -# *************************************************************************** -# Copyright (c) 2017-2023 Digi International Inc. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this file, -# You can obtain one at http://mozilla.org/MPL/2.0/. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. -# -# Digi International Inc., 9350 Excelsior Blvd., Suite 700, Hopkins, MN 55343 -# -# *************************************************************************** - -PROGRAM := upload_file - -CFLAGS += -Wall - -CFLAGS += $(shell pkg-config --cflags cloudconnector) -LDLIBS += $(shell pkg-config --libs --static cloudconnector) - -all: $(PROGRAM) - -OBJS = main.o - -$(PROGRAM): $(OBJS) - $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ - -.PHONY: install -install: $(PROGRAM) - install -d $(DESTDIR)/usr/bin - install -m 0755 $(PROGRAM) $(DESTDIR)/usr/bin/ - -.PHONY: clean -clean: - -rm -f *.o $(PROGRAM) diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_file/main.c b/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_file/main.c deleted file mode 100644 index 69f9ad552..000000000 --- a/meta-digi-dey/recipes-digi/dey-examples/files/cloudconnector_test/upload_file/main.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2017-2023 Digi International Inc. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Digi International Inc., 9350 Excelsior Blvd., Suite 700, Hopkins, MN 55343 - * =========================================================================== - */ - -#include -#include -#include -#include - -#define UNUSED_ARGUMENT(a) (void)(a) - -#define STREAM_NAME "examples/uploaded_file" -#define UPLOAD_FILE "/etc/build" - -static void sigint_handler(int signum) -{ - log_debug("%s: received signal %d to close Cloud connection.", - __func__, signum); - - exit(0); -} - -static void graceful_shutdown(void) -{ - stop_cloud_connection(); -} - -static void add_sigkill_signal(void) -{ - struct sigaction new_action; - struct sigaction old_action; - - atexit(graceful_shutdown); - - /* Setup signal hander. */ - new_action.sa_handler = sigint_handler; - sigemptyset(&new_action.sa_mask); - new_action.sa_flags = 0; - sigaction(SIGINT, NULL, &old_action); - if (old_action.sa_handler != SIG_IGN) - sigaction(SIGINT, &new_action, NULL); -} - -int main(int argc, char *argv[]) -{ - cc_init_error_t init_error; - cc_start_error_t start_error; - ccapi_dp_b_error_t send_error; - - UNUSED_ARGUMENT(argc); - - add_sigkill_signal(); - - init_error = init_cloud_connection(NULL); - if (init_error != CC_INIT_ERROR_NONE) { - log_error("Cannot initialize cloud connection, error %d", init_error); - return EXIT_FAILURE; - } - - start_error = start_cloud_connection(); - if (start_error != CC_START_ERROR_NONE) { - log_error("Cannot start cloud connection, error %d", start_error); - return EXIT_FAILURE; - } - - send_error = ccapi_dp_binary_send_file(CCAPI_TRANSPORT_TCP, UPLOAD_FILE, STREAM_NAME); - if (send_error != CCAPI_DP_B_ERROR_NONE) { - log_error("%s failed, error %d", __func__, send_error); - return EXIT_FAILURE; - } - - return EXIT_SUCCESS; -} diff --git a/meta-digi-dey/recipes-digi/dualboot/dualboot.bb b/meta-digi-dey/recipes-digi/dualboot/dualboot.bb index 188ef3839..f4f8f3127 100644 --- a/meta-digi-dey/recipes-digi/dualboot/dualboot.bb +++ b/meta-digi-dey/recipes-digi/dualboot/dualboot.bb @@ -36,44 +36,6 @@ do_install() { install -d ${D}${systemd_unitdir}/system/ install -m 0644 ${WORKDIR}/firmware-update-check.service ${D}${systemd_unitdir}/system/ - - # If Trustfence is enabled, copy the public key that is going to be used into the - # initramfs '/etc/ssl/certs' folder in order to verify swupdate packages. - if [ "${TRUSTFENCE_SIGN}" = "1" ]; then - # Retrieve the key index to use. - KEY_INDEX="0" - if [ -n "${TRUSTFENCE_KEY_INDEX}" ]; then - KEY_INDEX="${TRUSTFENCE_KEY_INDEX}" - fi - KEY_INDEX_1=$(expr ${KEY_INDEX} + 1) - - # Find the certificate to use. - if [ "${DEY_SOC_VENDOR}" = "NXP" ]; then - if [ "${TRUSTFENCE_SIGN_MODE}" = "HAB" ]; then - CERT_IMG="$(echo ${TRUSTFENCE_SIGN_KEYS_PATH}/crts/IMG${KEY_INDEX_1}*crt.pem)" - elif [ "${TRUSTFENCE_SIGN_MODE}" = "AHAB" ]; then - CERT_IMG="$(echo ${TRUSTFENCE_SIGN_KEYS_PATH}/crts/SRK${KEY_INDEX_1}*_ca_crt.pem)" - else - bberror "Unknown TRUSTFENCE_SIGN_MODE value" - exit 1 - fi - # Extract the public key from the certificate. - install -d ${D}${sysconfdir}/ssl/certs - openssl x509 -pubkey -noout -in "${CERT_IMG}" > ${D}${sysconfdir}/ssl/certs/key.pub - elif [ "${DEY_SOC_VENDOR}" = "STM" ]; then - # Copy the public key to the rootfs - if [ "${DIGI_SOM}" = "ccmp15" ]; then - PUBLIC_KEY="${TRUSTFENCE_SIGN_KEYS_PATH}/keys/publicKey00.pem" - elif [ "${DIGI_SOM}" = "ccmp13" ]; then - PUBLIC_KEY="${TRUSTFENCE_SIGN_KEYS_PATH}/keys/publicKey0${KEY_INDEX}.pem" - else - bberror "Unknown DIGI_SOM" - exit 1 - fi - install -d ${D}${sysconfdir}/ssl/certs - cp ${PUBLIC_KEY} ${D}${sysconfdir}/ssl/certs/key.pub - fi - fi } FILES:${PN} += " \ diff --git a/meta-digi-dey/recipes-digi/dualboot/dualboot/dualboot-init b/meta-digi-dey/recipes-digi/dualboot/dualboot/dualboot-init index 63dc75ba0..e30cbc617 100644 --- a/meta-digi-dey/recipes-digi/dualboot/dualboot/dualboot-init +++ b/meta-digi-dey/recipes-digi/dualboot/dualboot/dualboot-init @@ -28,16 +28,6 @@ dualboot_init () { fw_setenv active_system "${MTD_BOOT_PART}" fi fi - - ISUPGRADING="$(fw_printenv -n upgrade_available 2>/dev/null)" - - if [ "$ISUPGRADING" = "1" ]; then - BOOTCOUNT="$(fw_printenv -n bootcount 2>/dev/null)" - if [ "${BOOTCOUNT}" -lt 3 ]; then - fw_setenv upgrade_available - fw_setenv bootcount 0 - fi - fi } case "$1" in diff --git a/meta-digi-dey/recipes-digi/dualboot/dualboot/update-firmware b/meta-digi-dey/recipes-digi/dualboot/dualboot/update-firmware index 8c24e896a..2fd76f9b8 100755 --- a/meta-digi-dey/recipes-digi/dualboot/dualboot/update-firmware +++ b/meta-digi-dey/recipes-digi/dualboot/dualboot/update-firmware @@ -116,6 +116,16 @@ reboot_system() { } swap_active_system() { + # Sanity check: Some firmware updates might request not to swap + # active bank after the update. + local SWAP_BANK=$(fw_printenv -n swap_bank) + if [ "${SWAP_BANK}" = "false" ]; then + echo "[WARNING] Active system swap cancelled by update process." + # Reset variable and return without swapping. + fw_setenv swap_bank + return 0 + fi + if [ -z "${EMMCROOTFS}" ]; then fw_setenv mtdbootpart ${ALT_BOOT} fw_setenv mtdrootfspart ${ALT_ROOTFS} diff --git a/meta-digi-dey/recipes-digi/packagegroups/packagegroup-dey-examples.bb b/meta-digi-dey/recipes-digi/packagegroups/packagegroup-dey-examples.bb index eda018369..507429885 100644 --- a/meta-digi-dey/recipes-digi/packagegroups/packagegroup-dey-examples.bb +++ b/meta-digi-dey/recipes-digi/packagegroups/packagegroup-dey-examples.bb @@ -17,7 +17,7 @@ RDEPENDS:${PN} = "\ ${@bb.utils.contains("MACHINE_FEATURES", "mca", "dey-examples-adc-cmp \ dey-examples-tamper", "", d)} \ dey-examples-caamblob \ - dey-examples-cloudconnector \ + dey-examples-cccs \ dey-examples-digiapix \ dey-examples-rtc \ connectcore-demo-example-multimedia \ diff --git a/meta-digi-dey/recipes-digi/swu-images/files/ccimx6ul/sw-description-images_template b/meta-digi-dey/recipes-digi/swu-images/files/ccimx6ul/sw-description-images_template new file mode 100644 index 000000000..d617686f8 --- /dev/null +++ b/meta-digi-dey/recipes-digi/swu-images/files/ccimx6ul/sw-description-images_template @@ -0,0 +1,62 @@ +software = +{ + version = "@@DEY_FIRMWARE_VERSION@@"; + description = "@@SWUPDATE_DESCRIPTION@@"; + + @@SWUPDATE_STORAGE_TYPE@@ = { + primary: { + images: ( + ##IMAGES_PRIMARY## + ); + scripts: ( + { + filename = "@@SWUPDATE_SCRIPT_NAME@@"; + type = "shellscript"; + } + ); + uboot: ( + { + name = "rootfstype" + value = "@@SWUPDATE_ROOTFS_TYPE@@" + } + ); + } + secondary: { + images: ( + ##IMAGES_SECONDARY## + ); + scripts: ( + { + filename = "@@SWUPDATE_SCRIPT_NAME@@"; + type = "shellscript"; + } + ); + uboot: ( + { + name = "rootfstype" + value = "@@SWUPDATE_ROOTFS_TYPE@@" + } + ); + } + single: { + images: ( + ##IMAGES_SINGLE## + ); + scripts: ( + { + filename = "@@SWUPDATE_SCRIPT_NAME@@"; + type = "shellscript"; + } + ); + uboot: ( + { + name = "rootfstype" + value = "@@SWUPDATE_ROOTFS_TYPE@@" + } + ); + } + platform = { + ref = "#./single"; + } + }; +} diff --git a/meta-digi-dey/recipes-digi/swu-images/files/ccmp1/sw-description-images_template b/meta-digi-dey/recipes-digi/swu-images/files/ccmp1/sw-description-images_template new file mode 100644 index 000000000..0cc414a85 --- /dev/null +++ b/meta-digi-dey/recipes-digi/swu-images/files/ccmp1/sw-description-images_template @@ -0,0 +1,70 @@ +software = +{ + version = "@@DEY_FIRMWARE_VERSION@@"; + description = "@@SWUPDATE_DESCRIPTION@@"; + + @@SWUPDATE_STORAGE_TYPE@@ = { + primary: { + images: ( + ##IMAGES_PRIMARY## + ); + scripts: ( + { + filename = "@@SWUPDATE_SCRIPT_NAME@@"; + type = "shellscript"; + } + ); + uboot: ( + { + name = "upgrade_available"; + value = "1"; + }, + { + name = "rootfstype" + value = "@@SWUPDATE_ROOTFS_TYPE@@" + } + ); + } + secondary: { + images: ( + ##IMAGES_SECONDARY## + ); + scripts: ( + { + filename = "@@SWUPDATE_SCRIPT_NAME@@"; + type = "shellscript"; + } + ); + uboot: ( + { + name = "upgrade_available"; + value = "1"; + }, + { + name = "rootfstype" + value = "@@SWUPDATE_ROOTFS_TYPE@@" + } + ); + } + single: { + images: ( + ##IMAGES_SINGLE## + ); + scripts: ( + { + filename = "@@SWUPDATE_SCRIPT_NAME@@"; + type = "shellscript"; + } + ); + uboot: ( + { + name = "rootfstype" + value = "@@SWUPDATE_ROOTFS_TYPE@@" + } + ); + } + platform = { + ref = "#./single"; + } + }; +} diff --git a/meta-digi-dey/recipes-digi/swu-images/files/image_template_mmc b/meta-digi-dey/recipes-digi/swu-images/files/image_template_mmc new file mode 100644 index 000000000..158806213 --- /dev/null +++ b/meta-digi-dey/recipes-digi/swu-images/files/image_template_mmc @@ -0,0 +1,8 @@ + { + filename = "##IMG_NAME##"; + device = "##DEV##"; + type = "raw"; + sha256 = "$swupdate_get_sha256(##IMG_NAME##)"; + compressed = "zlib"; + installed-directly = true; + } diff --git a/meta-digi-dey/recipes-digi/swu-images/files/image_template_nand b/meta-digi-dey/recipes-digi/swu-images/files/image_template_nand new file mode 100644 index 000000000..1fa5cc8b9 --- /dev/null +++ b/meta-digi-dey/recipes-digi/swu-images/files/image_template_nand @@ -0,0 +1,7 @@ + { + filename = "##IMG_NAME##"; + volume = "##DEV##"; + type = "ubivol"; + sha256 = "$swupdate_get_sha256(##IMG_NAME##)"; + installed-directly = true; + } diff --git a/meta-digi-dey/recipes-digi/swu-images/files/image_template_rdiff_mmc b/meta-digi-dey/recipes-digi/swu-images/files/image_template_rdiff_mmc new file mode 100644 index 000000000..6ca186650 --- /dev/null +++ b/meta-digi-dey/recipes-digi/swu-images/files/image_template_rdiff_mmc @@ -0,0 +1,8 @@ + { + type = "rdiff_image"; + filename = "@@SWUPDATE_RDIFF_ROOTFS_DELTA_FILE_NAME@@"; + device = "##DEV##"; + properties: { + rdiffbase = ["/dev/rdiff_source_rootfs"]; + }; + } diff --git a/meta-digi-dey/recipes-digi/swu-images/files/image_template_rdiff_nand b/meta-digi-dey/recipes-digi/swu-images/files/image_template_rdiff_nand new file mode 100644 index 000000000..88585fa5b --- /dev/null +++ b/meta-digi-dey/recipes-digi/swu-images/files/image_template_rdiff_nand @@ -0,0 +1,9 @@ + { + type = "ubivol_rdiff_image"; + filename = "@@SWUPDATE_RDIFF_ROOTFS_DELTA_FILE_NAME@@"; + volume = "##DEV##"; + properties: { + rdiffbase = ["/dev/rdiff_source_rootfs"]; + rdiffnewsize = "$swupdate_get_size(@@DEPLOY_DIR_IMAGE@@/@@IMG_NAME@@-@@MACHINE@@.squashfs)"; + }; + } diff --git a/meta-digi-dey/recipes-digi/swu-images/files/sw-description b/meta-digi-dey/recipes-digi/swu-images/files/sw-description deleted file mode 100644 index 8d0af5f13..000000000 --- a/meta-digi-dey/recipes-digi/swu-images/files/sw-description +++ /dev/null @@ -1,167 +0,0 @@ -software = -{ - version = "##SW_VERSION##"; - description = "##DESCRIPTION##"; - - mmc = { - primary: { - images: ( - { - filename = "##BOOTIMG_NAME##"; - device = "##BOOT_DEV_A##"; - type = "raw"; - sha256 = "$swupdate_get_sha256(##BOOTIMG_NAME##)"; - installed-directly = true; - }, - { - filename = "##ROOTIMG_NAME##"; - device = "##ROOTFS_DEV_A##"; - type = "raw"; - sha256 = "$swupdate_get_sha256(##ROOTIMG_NAME##)"; - compressed = "zlib"; - installed-directly = true; - } - ); - uboot: ( - { - name = "upgrade_available"; - value = "1"; - }, - { - name = "rootfstype" - value = "##ROOTFS_TYPE##" - } - ); - } - secondary: { - images: ( - { - filename = "##BOOTIMG_NAME##"; - device = "##BOOT_DEV_B##"; - type = "raw"; - sha256 = "$swupdate_get_sha256(##BOOTIMG_NAME##)"; - installed-directly = true; - }, - { - filename = "##ROOTIMG_NAME##"; - device = "##ROOTFS_DEV_B##"; - type = "raw"; - sha256 = "$swupdate_get_sha256(##ROOTIMG_NAME##)"; - compressed = "zlib"; - installed-directly = true; - } - ); - uboot: ( - { - name = "upgrade_available"; - value = "1"; - }, - { - name = "rootfstype" - value = "##ROOTFS_TYPE##" - } - ); - } - single: { - images: ( - { - filename = "##BOOTIMG_NAME##"; - device = "##BOOT_DEV##"; - type = "raw"; - sha256 = "$swupdate_get_sha256(##BOOTIMG_NAME##)"; - installed-directly = true; - }, - { - filename = "##ROOTIMG_NAME##"; - device = "##ROOTFS_DEV##"; - type ="raw"; - sha256 = "$swupdate_get_sha256(##ROOTIMG_NAME##)"; - compressed = "zlib"; - installed-directly = true; - } - ); - } - platform = { - ref = "#./single"; - } - } - mtd = { - primary: { - images: ( - { - filename = "##BOOTIMG_NAME##"; - volume = "##BOOT_DEV_A##"; - type = "ubivol"; - sha256 = "$swupdate_get_sha256(##BOOTIMG_NAME##)"; - installed-directly = true; - }, - { - filename = "##ROOTIMG_NAME##"; - volume = "##ROOTFS_DEV_A##"; - type = "ubivol"; - sha256 = "$swupdate_get_sha256(##ROOTIMG_NAME##)"; - installed-directly = true; - } - ); - uboot: ( - { - name = "upgrade_available"; - value = "1"; - }, - { - name = "rootfstype" - value = "##ROOTFS_TYPE##" - } - ); - } - secondary: { - images: ( - { - filename = "##BOOTIMG_NAME##"; - volume = "##BOOT_DEV_B##"; - type = "ubivol"; - sha256 = "$swupdate_get_sha256(##BOOTIMG_NAME##)"; - installed-directly = true; - }, - { - filename = "##ROOTIMG_NAME##"; - volume = "##ROOTFS_DEV_B##"; - type = "ubivol"; - sha256 = "$swupdate_get_sha256(##ROOTIMG_NAME##)"; - installed-directly = true; - } - ); - uboot: ( - { - name = "upgrade_available"; - value = "1"; - }, - { - name = "rootfstype" - value = "##ROOTFS_TYPE##" - } - ); - } - single: { - images: ( - { - filename = "##BOOTIMG_NAME##"; - volume = "##BOOT_DEV##"; - type = "ubivol"; - sha256 = "$swupdate_get_sha256(##BOOTIMG_NAME##)"; - installed-directly = true; - }, - { - filename = "##ROOTIMG_NAME##"; - volume = "##ROOTFS_DEV##"; - type ="ubivol"; - sha256 = "$swupdate_get_sha256(##ROOTIMG_NAME##)"; - installed-directly = true; - } - ); - } - platform = { - ref = "#./single"; - } - }; -} diff --git a/meta-digi-dey/recipes-digi/swu-images/files/sw-description-files_template b/meta-digi-dey/recipes-digi/swu-images/files/sw-description-files_template new file mode 100644 index 000000000..d6fb84bdc --- /dev/null +++ b/meta-digi-dey/recipes-digi/swu-images/files/sw-description-files_template @@ -0,0 +1,54 @@ +software = +{ + version = "@@DEY_FIRMWARE_VERSION@@"; + description = "@@SWUPDATE_DESCRIPTION@@"; + + @@SWUPDATE_STORAGE_TYPE@@ = { + primary: { + files: ( + { + filename = "@@SWUPDATE_FILES_TARGZ_FILE_NAME@@"; + type = "archive"; + compressed = "zlib"; + path = "/"; + } + ); + scripts: ( + { + filename = "@@SWUPDATE_SCRIPT_NAME@@"; + sha256 = "$swupdate_get_sha256(@@SWUPDATE_SCRIPT_NAME@@)"; + type = "shellscript"; + } + ); + uboot: ( + { + name = "swap_bank"; + value = "false"; + } + ); + } + secondary: { + ref = "#./primary"; + } + single: { + files: ( + { + filename = "@@SWUPDATE_FILES_TARGZ_FILE_NAME@@"; + type = "archive"; + compressed = "zlib"; + path = "/system/"; + } + ); + scripts: ( + { + filename = "@@SWUPDATE_SCRIPT_NAME@@"; + sha256 = "$swupdate_get_sha256(@@SWUPDATE_SCRIPT_NAME@@)"; + type = "shellscript"; + } + ); + } + platform = { + ref = "#./single"; + } + }; +} diff --git a/meta-digi-dey/recipes-digi/swu-images/files/sw-description-images_template b/meta-digi-dey/recipes-digi/swu-images/files/sw-description-images_template new file mode 100644 index 000000000..dd0559912 --- /dev/null +++ b/meta-digi-dey/recipes-digi/swu-images/files/sw-description-images_template @@ -0,0 +1,59 @@ +software = +{ + version = "@@DEY_FIRMWARE_VERSION@@"; + description = "@@SWUPDATE_DESCRIPTION@@"; + + @@SWUPDATE_STORAGE_TYPE@@ = { + primary: { + images: ( + ##IMAGES_PRIMARY## + ); + scripts: ( + { + filename = "@@SWUPDATE_SCRIPT_NAME@@"; + sha256 = "$swupdate_get_sha256(@@SWUPDATE_SCRIPT_NAME@@)"; + type = "shellscript"; + } + ); + uboot: ( + { + name = "upgrade_available"; + value = "@@UPGRADE_AVAILABLE@@"; + } + ); + } + secondary: { + images: ( + ##IMAGES_SECONDARY## + ); + scripts: ( + { + filename = "@@SWUPDATE_SCRIPT_NAME@@"; + sha256 = "$swupdate_get_sha256(@@SWUPDATE_SCRIPT_NAME@@)"; + type = "shellscript"; + } + ); + uboot: ( + { + name = "upgrade_available"; + value = "@@UPGRADE_AVAILABLE@@"; + } + ); + } + single: { + images: ( + ##IMAGES_SINGLE## + ); + scripts: ( + { + filename = "@@SWUPDATE_SCRIPT_NAME@@"; + sha256 = "$swupdate_get_sha256(@@SWUPDATE_SCRIPT_NAME@@)"; + type = "shellscript"; + } + ); + } + platform = { + ref = "#./single"; + } + }; +} diff --git a/meta-digi-dey/recipes-digi/swu-images/files/sw-description-rdiff_template b/meta-digi-dey/recipes-digi/swu-images/files/sw-description-rdiff_template new file mode 100644 index 000000000..797095ed8 --- /dev/null +++ b/meta-digi-dey/recipes-digi/swu-images/files/sw-description-rdiff_template @@ -0,0 +1,49 @@ +software = +{ + version = "@@DEY_FIRMWARE_VERSION@@"; + description = "@@SWUPDATE_DESCRIPTION@@"; + + @@SWUPDATE_STORAGE_TYPE@@ = { + primary: { + images: ( + ##IMAGES_PRIMARY## + ); + scripts: ( + { + filename = "@@SWUPDATE_SCRIPT_NAME@@"; + type = "shellscript"; + data = "$swupdate_get_sha256(@@SWUPDATE_RDIFF_ROOTFS_SOURCE_FILE@@)" + sha256 = "$swupdate_get_sha256(@@SWUPDATE_SCRIPT_NAME@@)"; + } + ); + uboot: ( + { + name = "upgrade_available"; + value = "@@UPGRADE_AVAILABLE@@"; + } + ); + } + secondary: { + images: ( + ##IMAGES_SECONDARY## + ); + scripts: ( + { + filename = "@@SWUPDATE_SCRIPT_NAME@@"; + type = "shellscript"; + data = "$swupdate_get_sha256(@@SWUPDATE_RDIFF_ROOTFS_SOURCE_FILE@@)" + sha256 = "$swupdate_get_sha256(@@SWUPDATE_SCRIPT_NAME@@)"; + } + ); + uboot: ( + { + name = "upgrade_available"; + value = "@@UPGRADE_AVAILABLE@@"; + } + ); + } + platform = { + ref = "#./primary"; + } + }; +} diff --git a/meta-digi-dey/recipes-digi/swu-images/files/sw-description-uboot b/meta-digi-dey/recipes-digi/swu-images/files/sw-description-uboot index 6270310d6..c72e564ba 100644 --- a/meta-digi-dey/recipes-digi/swu-images/files/sw-description-uboot +++ b/meta-digi-dey/recipes-digi/swu-images/files/sw-description-uboot @@ -1,6 +1,6 @@ software = { - version = "##SW_VERSION##"; + version = "##FW_VERSION##"; description = "##DESCRIPTION##"; mmc = { diff --git a/meta-digi-dey/recipes-digi/swu-images/files/update_files.sh b/meta-digi-dey/recipes-digi/swu-images/files/update_files.sh new file mode 100755 index 000000000..9d28629ec --- /dev/null +++ b/meta-digi-dey/recipes-digi/swu-images/files/update_files.sh @@ -0,0 +1,144 @@ +#!/bin/sh +#=============================================================================== +# +# update_files +# +# Copyright (C) 2023 by Digi International Inc. +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published by +# the Free Software Foundation. +# +# +# !Description: SWU update files script +# +#=============================================================================== + +# Sanity check. This script should be always executed with at least one argument. +if [ $# -lt 1 ]; then + exit 1; +fi + +# Variables. +FS_TYPE="ext4" +LINUX_DEV_BLOCK="/dev/mmcblk0p1" +LINUX_MOUNT_POINT="/mnt/linux" +ROOTFS_DEV_BLOCK="/dev/mmcblk0p3" +ROOTFS_MOUNT_POINT="/system" + +# Determines whether the file system type is UBI or not. +is_ubifs() { + [ -c "/dev/ubi0" ] +} + +# Retrieves the MTD partition number corresponding to the given partition name. +# +# Args: +# $1: partition name. +# +# Returns: +# The MTD partition number corresponding to the given partition name, -1 if +# not found. +get_mtd_number() { + local mtd_line="$(sed -ne "/${1}/s,^mtd\([0-9]\+\).*,\1,g;T;p" /proc/mtd)" + echo "${mtd_line:--1}" +} + +# Creates the UBI device for the given MTD partition number. +# +# Args: +# $1: the MTD partition number to create the UBI device for. +# +# Returns: +# The created UBI device number for the given MTD partition number, -1 if error. +create_ubi_device() { + local dev_number="$(ubiattach -m "${1}" 2>/dev/null | sed -ne 's,.*device number \([0-9]\).*,\1,g;T;p' 2>/dev/null)" + echo "${dev_number:--1}" +} + +# Retrieves the UBI device number containing the given partition name. If the +# device does not exist, the method attempts to create it based on the MTD dev +# number containing the desired partition. +# +# Args: +# $1: partition name. +# +# Returns: +# The UBI device number containing the given partition name, -1 if not found. +get_ubi_device() { + local ubi_devices="$(ubinfo | grep "Present UBI devices:" | cut -d ":" -f2 | xargs | sed -e 's/,//g')" + for ubi_device in ${ubi_devices}; do + if ubinfo "/dev/${ubi_device}" -a | grep -qe "Name:.*$1"; then + echo "${ubi_device}" | tr -dc '0-9' + return 0 + fi + done + + # Look for the MTD number containing the given partition name. + local mtd_num="$(get_mtd_number "${1}")" + if [ "${mtd_num}" = "-1" ]; then + echo "-1" + return 1 + else + # Create the UBI device. + ubi_device_number="$(create_ubi_device "${mtd_num}")" + echo "${ubi_device_number}" + fi +} + +# Mounts all required partitions to perform the firmware update based on the update +# running source and file system type. +mount_partitions() { + # Determine whether the update is running from recovery partition or not. + BOOT_RECOVERY="$(fw_printenv -n boot_recovery)" + if [ "${BOOT_RECOVERY}" = "yes" ]; then + # Update is running from recovery partition. We need to mount both, + # the rootfs and the kernel partitions. To do so first determine the + # filesystem type, assume it is MMC device. + if is_ubifs; then + FS_TYPE="ubifs" + # Look for the UBI device containing 'linux' partition. + local linux_ubi_device="$(get_ubi_device linux)" + [ "${linux_ubi_device}" = "-1" ] && { echo "Unable to find UBI device containing 'linux' partition."; exit 1; } + LINUX_DEV_BLOCK="ubi${linux_ubi_device}:linux" + # Look for the UBI device containing 'rootfs' partition. + local rootfs_ubi_device="$(get_ubi_device rootfs)" + [ "${rootfs_ubi_device}" = "-1" ] && { echo "Unable to find UBI device containing 'rootfs' partition."; exit 1; } + ROOTFS_DEV_BLOCK="ubi${rootfs_ubi_device}:rootfs" + fi + # Mount 'rootfs' partition. + mkdir -p "${ROOTFS_MOUNT_POINT}" + mount -t "${FS_TYPE}" "${ROOTFS_DEV_BLOCK}" "${ROOTFS_MOUNT_POINT}" + # Mount 'linux' partition. + LINUX_MOUNT_POINT="${ROOTFS_MOUNT_POINT}${LINUX_MOUNT_POINT}" + mkdir -p "${LINUX_MOUNT_POINT}" + if ! is_ubifs; then + FS_TYPE="auto" + fi + mount -t "${FS_TYPE}" "${LINUX_DEV_BLOCK}" "${LINUX_MOUNT_POINT}" + else + # Update is running from the active system. In this case the 'rootfs' and 'linux' + # partitions are already mounted; however 'linux' partition is in R/O mode. Just + # remount 'linux' partition as R/W. + mount -o remount,rw "${LINUX_MOUNT_POINT}" + fi +} + +# Called just before installation process starts. +if [ "${1}" = "preinst" ]; then + mount_partitions + + # TODO: Execute custom code here. For example: + # - Mount additional devices/partitions. + # - Stop services/process before installing files. +fi + +# Called just after installation process ends. +if [ "${1}" = "postinst" ]; then + : + + # TODO: Execute custom code here. For example: + # - Clean directories. + # - Post-process files. +fi diff --git a/meta-digi-dey/recipes-digi/swu-images/files/update_images.sh b/meta-digi-dey/recipes-digi/swu-images/files/update_images.sh new file mode 100755 index 000000000..5219ebc54 --- /dev/null +++ b/meta-digi-dey/recipes-digi/swu-images/files/update_images.sh @@ -0,0 +1,39 @@ +#!/bin/sh +#=============================================================================== +# +# update_images +# +# Copyright (C) 2023 by Digi International Inc. +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published by +# the Free Software Foundation. +# +# +# !Description: SWU update images script +# +#=============================================================================== + +# Sanity check. This script should be always executed with at least one argument. +if [ $# -lt 1 ]; then + exit 1; +fi + +# Called just before installation process starts. +if [ "${1}" = "preinst" ]; then + : + + # TODO: Execute custom code here. For example: + # - Mount additional devices/partitions. + # - Stop services/process before installing files. +fi + +# Called just after installation process ends. +if [ "${1}" = "postinst" ]; then + : + + # TODO: Execute custom code here. For example: + # - Clean files/directories. + # - Post-process files. +fi diff --git a/meta-digi-dey/recipes-digi/swu-images/files/update_rdiff.sh b/meta-digi-dey/recipes-digi/swu-images/files/update_rdiff.sh new file mode 100755 index 000000000..aca86d7f5 --- /dev/null +++ b/meta-digi-dey/recipes-digi/swu-images/files/update_rdiff.sh @@ -0,0 +1,206 @@ +#!/bin/sh +#=============================================================================== +# +# update_rdiff +# +# Copyright (C) 2023 by Digi International Inc. +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published by +# the Free Software Foundation. +# +# +# !Description: SWU update rdiff script +# +#=============================================================================== + +# Sanity check. This script should be always executed with at least one argument. +if [ $# -lt 1 ]; then + exit 1; +fi + +# Sanity check. Do not run in single-boot systems. +[ "$(fw_printenv -n dualboot)" = "yes" ] || { echo "This update cannot be applied to single-boot systems, aborting..."; exit 1; } + +# Sanity check. Do not run in R/W systems. +if ! grep "/proc/mounts" -qe "squashfs"; then + echo "This update cannot be applied to R/W systems, aborting..." + exit 1 +fi + +# Variables. +BLOCK_SIZE=4096 +ROOTFS_NAME="rootfs" +ROOTFS_SOURCE_ENDPOINT="/dev/rdiff_source_rootfs" +ROOTFS_DEV_BLOCK="mmcblk0p3" +ROOTFS_DEV_BLOCK_A="mmcblk0p3" +ROOTFS_DEV_BLOCK_B="mmcblk0p4" + +# Determines whether the file system type is UBIFS or not. +is_ubifs() { + [ -c "/dev/ubi0" ] +} + +# Determines whether the system is dualboot or not. +is_dualboot() { + [ "$(fw_printenv -n dualboot)" = "yes" ] +} + +# Retrieves the dualboot active system letter. +# +# Returns: +# The dualboot active system letter: 'a' for primary, 'b' for secondary. +get_active_system() { + local active_system="$(fw_printenv -n active_system)" + echo "${active_system}" | cut -d_ -f2 +} + +# Retrieves the MTD partition number corresponding to the given partition name. +# +# Args: +# $1: partition name. +# +# Returns: +# The MTD partition number corresponding to the given partition name, -1 if +# not found. +get_mtd_number() { + local mtd_line="$(sed -ne "/${1}/s,^mtd\([0-9]\+\).*,\1,g;T;p" /proc/mtd)" + echo "${mtd_line:--1}" +} + +# Creates the UBI device for the given MTD partition number. +# +# Args: +# $1: the MTD partition number to create the UBI device for. +# +# Returns: +# The created UBI device number for the given MTD partition number, -1 if error. +create_ubi_device() { + local dev_number="$(ubiattach -m "${1}" 2>/dev/null | sed -ne 's,.*device number \([0-9]\).*,\1,g;T;p' 2>/dev/null)" + echo "${dev_number:--1}" +} + +# Retrieves the UBI device number containing the given partition name. If the +# device does not exist, the method attempts to create it based on the MTD dev +# number containing the desired partition. +# +# Args: +# $1: partition name. +# +# Returns: +# The UBI device number containing the given partition name, -1 if not found. +get_ubi_device() { + local ubi_devices="$(ubinfo | grep "Present UBI devices:" | cut -d ":" -f2 | xargs | sed -e 's/,//g')" + for ubi_device in ${ubi_devices}; do + if ubinfo "/dev/${ubi_device}" -a | grep -qe "Name:.*$1"; then + echo "${ubi_device}" | tr -dc '0-9' + return 0 + fi + done + + # Look for the MTD number containing the given partition name. + local mtd_num="$(get_mtd_number "${1}")" + if [ "${mtd_num}" = "-1" ]; then + echo "-1" + return 1 + else + # Create the UBI device. + ubi_device_number="$(create_ubi_device "${mtd_num}")" + echo "${ubi_device_number}" + fi +} + +# Retrieves the UBI volume containing the given partition name. +# +# Args: +# $1: partition name. +# +# Returns: +# The UBI volume containing the given partition name, -1 if not found. +get_ubi_volume() { + # Look for the UBI device containing given partition. + local ubi_device="$(get_ubi_device "${1}")" + if [ "${ubi_device}" = "-1" ]; then + echo "-1" + return 1 + fi + # Look for the UBI volume containing given partition. + local ubi_volume="$(ubinfo -d "${ubi_device}" -N "${1}" | grep "Volume ID" | cut -d ":" -f2 | xargs | cut -d " " -f1)" + if [ -z "${ubi_volume}" ]; then + echo "-1" + return 1 + fi + echo "ubi${ubi_device}_${ubi_volume}" +} + +# Creates the 'rootfs' source endpoint. +# +# Update source for the 'rootfs' partition cannot be determined at build time. For MTD +# devices, it depends on whether system is based on single or multiple MTD partitions. +# For this reason, hook the source update to a well known endpoint and just create the +# required link from the running system once all the information is available. +create_source_endpoint() { + # Initialize vars. Assume system is MMC based. + local rootfs_source_partiton="${ROOTFS_NAME}" + local rootfs_source_dev="${ROOTFS_DEV_BLOCK}" + + # Remove previous link. + [ -L "${ROOTFS_SOURCE_ENDPOINT}" ] && unlink "${ROOTFS_SOURCE_ENDPOINT}" + + # Update variables for dualboot systems. + if is_dualboot; then + local active_part="$(get_active_system)" + rootfs_source_partiton="${rootfs_source_partiton}_${active_part}" + if [ "${active_part}" = "a" ]; then + rootfs_source_dev=${ROOTFS_DEV_BLOCK_A} + else + rootfs_source_dev=${ROOTFS_DEV_BLOCK_B} + fi + fi + + # Update variables for MTD systems. + if is_ubifs; then + # Look for 'rootfs' source UBI volume. + rootfs_source_dev="$(get_ubi_volume "${rootfs_source_partiton}")" + [ "${rootfs_source_dev}" = "-1" ] && { echo "Unable to find UBI volume containing '${rootfs_source_partiton}' partition."; exit 1; } + fi + + # Create link. + ln -s "${rootfs_source_dev}" "${ROOTFS_SOURCE_ENDPOINT}" +} + +# Validates the base image before applying the RDIFF patch. +# +# Args: +# $1: Checksum of original base image. +validate_base_image() { + local fs_size="$(hexdump -s 0x28 -n 4 -e '1/4 "%d"' "${ROOTFS_SOURCE_ENDPOINT}")" + fs_size=$(( (fs_size + 0xfff) & 0xfffff000 )) + local n_blocks=$(( fs_size/BLOCK_SIZE )) + local checksum="$(dd if="${ROOTFS_SOURCE_ENDPOINT}" bs="${BLOCK_SIZE}" count="${n_blocks}" 2> /dev/null | sha256sum | cut -d " " -f1)" + + if [ "${checksum}" != "${1}" ]; then + echo "[ERROR] Base image is not the expected one or has been modified. Aborting update..." + exit 1 + fi +} + +# Called just before installation process starts. +if [ "${1}" = "preinst" ]; then + create_source_endpoint + validate_base_image "${2}" + + # TODO: Execute custom code here. For example: + # - Mount additional devices/partitions. + # - Stop services/process before installation. +fi + +# Called just after installation process ends. +if [ "${1}" = "postinst" ]; then + : + + # TODO: Execute custom code here. For example: + # - Clean files/directories. + # - Post-process files. +fi diff --git a/meta-digi-dey/recipes-digi/swu-images/swu.inc b/meta-digi-dey/recipes-digi/swu-images/swu.inc index 444615d1e..6d6933350 100644 --- a/meta-digi-dey/recipes-digi/swu-images/swu.inc +++ b/meta-digi-dey/recipes-digi/swu-images/swu.inc @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2022, Digi International Inc. +# Copyright (C) 2016-2023, Digi International Inc. SUMMARY = "Generate update package for SWUpdate" SECTION = "base" @@ -6,88 +6,137 @@ LICENSE = "GPL-2.0-only" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6" SRC_URI = " \ - file://sw-description \ + file://sw-description-images_template \ + file://sw-description-files_template \ + file://sw-description-rdiff_template \ file://sw-description-uboot \ file://swupdate_uboot_nand.sh \ file://swupdate_uboot_mmc.sh \ + file://image_template_mmc \ + file://image_template_nand \ + file://image_template_rdiff_mmc \ + file://image_template_rdiff_nand \ + file://update_images.sh \ + file://update_files.sh \ + file://update_rdiff.sh \ " -inherit swupdate +inherit swupdate dey-swupdate-common -IMAGE_DEPENDS = "${@get_baseimg_pn(d)}" - -IMG_NAME = "${IMAGE_DEPENDS}" +# Avoid all 'SRC_URI' files to be included in the SWU image. Include only 'SWUPDATE_IMAGES' files and 'sw-description' (added by default). +INHIBIT_SWUPDATE_ADD_SRC_URI = "true" +# Files to include in the SWU update package. SWUPDATE_IMAGES = " \ - ${IMG_NAME} \ + ${@oe.utils.ifelse(d.getVar('SWUPDATE_IS_IMAGES_UPDATE') == 'true', '${IMG_NAME}', '')} \ + ${@oe.utils.ifelse(d.getVar('SWUPDATE_IS_FILES_UPDATE') == 'true', '${SWUPDATE_FILES_TARGZ_FILE_NAME}', '')} \ + ${@oe.utils.ifelse(d.getVar('SWUPDATE_IS_RDIFF_UPDATE') == 'true', '${IMG_NAME} ${SWUPDATE_RDIFF_ROOTFS_DELTA_FILE_NAME}', '')} \ ${@oe.utils.ifelse(d.getVar('SWUPDATE_UBOOTIMG') == 'true', '${UBOOT_PREFIX}', '')} \ + ${@oe.utils.ifelse(d.getVar('SWUPDATE_UBOOTIMG') == 'true', '${SWUPDATE_UBOOT_SCRIPT}', '')} \ + ${SWUPDATE_SCRIPT_NAME} \ " -SOFTWARE_VERSION ?= "0.0.1" -DESCRIPTION = "${@oe.utils.ifelse(d.getVar('TRUSTFENCE_ENCRYPT_ROOTFS') == '1', 'Encrypted rootfs ${IMG_NAME} update', '${IMG_NAME} update')}" - -UBOOT_EXT ?= ".${UBOOT_SUFFIX}" - -UBOOTIMG_OFFSET ?= "${BOOTLOADER_SEEK_BOOT}" - -SWUPDATE_STORAGE_MEDIA = "${@oe.utils.conditional('STORAGE_MEDIA', 'mmc', 'swupdate_uboot_mmc.sh', 'swupdate_uboot_nand.sh', d)}" - +# Associate images and file types. python () { - img_fstypes = d.getVar('BOOTFS_EXT') + " " + d.getVar('ROOTFS_EXT') + img_fstypes = d.getVar('BOOTFS_EXT') + if d.getVar('SWUPDATE_IS_IMAGES_UPDATE') == "true": + img_fstypes = img_fstypes + " " + d.getVar('ROOTFS_EXT') d.setVarFlag("SWUPDATE_IMAGES_FSTYPES", d.getVar('IMG_NAME'), img_fstypes) if (d.getVar('SWUPDATE_UBOOTIMG') == "true"): uboot_fstypes = d.getVar('UBOOT_EXT') d.setVarFlag("SWUPDATE_IMAGES_FSTYPES", d.getVar('UBOOT_PREFIX'), uboot_fstypes) } +# Execute extra tasks before creating SWU update package. python do_swuimage:prepend() { import glob + import os.path + import shutil + # Set signing key for trustfence enabled updates. if (d.getVar('TRUSTFENCE_SIGN') == "1"): d.setVar('SWUPDATE_PRIVATE_KEY', glob.glob(d.getVar('SWUPDATE_PRIVATE_KEY_TEMPLATE'))[0]) + + # Copy script file. + updatescript = d.getVar('SWUPDATE_SCRIPT', True) + imgdeploydir = d.getVar('DEPLOY_DIR_IMAGE', True) + if "/" not in updatescript: + workdir = d.getVar('WORKDIR', True) + updatescript = os.path.join(workdir, updatescript) + if os.path.isfile(updatescript): + shutil.copyfile(updatescript, os.path.join(imgdeploydir, os.path.basename(updatescript))) } -def get_baseimg_pn(d): - file_name = d.getVar('PN') - return file_name[:file_name.find("-swu")] - - -# Dual boot partition names for eMMC or MTD -BOOT_DEV_NAME_A ?= "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', '/dev/mmcblk0p1', 'linux_a', d)}" -BOOT_DEV_NAME_B ?= "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', '/dev/mmcblk0p2', 'linux_b', d)}" -ROOTFS_DEV_NAME_A ?= "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', '/dev/mmcblk0p3', 'rootfs_a', d)}" -ROOTFS_DEV_NAME_B ?= "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', '/dev/mmcblk0p4', 'rootfs_b', d)}" - -ROOTFS_TYPE = "${@bb.utils.contains('IMAGE_FEATURES', 'read-only-rootfs', 'squashfs', '', d)}" -do_unpack[postfuncs] += "fill_description" +# Upgrade available. +UPGRADE_AVAILABLE = "" +UPGRADE_AVAILABLE:ccimx6 = "1" +# Create and fill 'sw-description' file. fill_description() { if [ "${SWUPDATE_UBOOTIMG}" = "true" ]; then cp ${WORKDIR}/sw-description-uboot ${WORKDIR}/sw-description + cp ${WORKDIR}/${SWUPDATE_UBOOT_SCRIPT} ${DEPLOY_DIR_IMAGE}/${SWUPDATE_UBOOT_SCRIPT} if [ "${TRUSTFENCE_DEK_PATH}" != "0" ] && [ "${TRUSTFENCE_DEK_PATH}" != "default" ]; then sed -i -e "s,##UBOOTIMG_ENC##,enc,g" "${WORKDIR}/sw-description" else sed -i -e "s,##UBOOTIMG_ENC##,normal,g" "${WORKDIR}/sw-description" fi sed -i -e "s,##UBOOTIMG_NAME##,${UBOOT_PREFIX}-${MACHINE}${UBOOT_EXT},g" "${WORKDIR}/sw-description" - sed -i -e "s,##SWUPDATE_UBOOT_SCRIPT##,${SWUPDATE_STORAGE_MEDIA},g" "${WORKDIR}/sw-description" + sed -i -e "s,##SWUPDATE_UBOOT_SCRIPT##,${SWUPDATE_UBOOT_SCRIPT},g" "${WORKDIR}/sw-description" sed -i -e "s,##UBOOTIMG_OFFSET##,${UBOOTIMG_OFFSET},g" "${WORKDIR}/sw-description" + elif [ "${SWUPDATE_IS_FILES_UPDATE}" = "true" ]; then + cp ${WORKDIR}/sw-description-files_template ${WORKDIR}/sw-description + elif [ "${SWUPDATE_IS_RDIFF_UPDATE}" = "true" ]; then + cp ${WORKDIR}/sw-description-rdiff_template ${WORKDIR}/sw-description + else + cp ${WORKDIR}/sw-description-images_template ${WORKDIR}/sw-description fi - sed -i -e "s,##BOOTIMG_NAME##,${IMG_NAME}-${MACHINE}${BOOTFS_EXT},g" "${WORKDIR}/sw-description" - sed -i -e "s,##BOOT_DEV##,${BOOT_DEV_NAME},g" "${WORKDIR}/sw-description" - sed -i -e "s,##ROOTIMG_NAME##,${IMG_NAME}-${MACHINE}${ROOTFS_EXT},g" "${WORKDIR}/sw-description" - sed -i -e "s,##ROOTFS_DEV##,${ROOTFS_DEV_NAME_FINAL},g" "${WORKDIR}/sw-description" - sed -i -e "s,##SW_VERSION##,${SOFTWARE_VERSION},g" "${WORKDIR}/sw-description" - sed -i -e "s,##DESCRIPTION##,${DESCRIPTION},g" "${WORKDIR}/sw-description" - # Dualboot description - sed -i -e "s,##BOOT_DEV_A##,${BOOT_DEV_NAME_A},g" "${WORKDIR}/sw-description" - sed -i -e "s,##BOOT_DEV_B##,${BOOT_DEV_NAME_B},g" "${WORKDIR}/sw-description" - sed -i -e "s,##ROOTFS_DEV_A##,${ROOTFS_DEV_NAME_A},g" "${WORKDIR}/sw-description" - sed -i -e "s,##ROOTFS_DEV_B##,${ROOTFS_DEV_NAME_B},g" "${WORKDIR}/sw-description" + if [ "${SWUPDATE_IS_FILES_UPDATE}" = "true" ]; then + return 0 + fi + + # Build image names. + BOOT_IMAGE_NAME="${IMG_NAME}-${MACHINE}${BOOTFS_EXT}" + ROOTFS_IMAGE_NAME="${IMG_NAME}-${MACHINE}${ROOTFS_EXT}" + + # Set correct image templates. + BOOT_IMAGE_TEMPLATE="${SWUPDATE_IMAGES_IMAGE_TEMPLATE_FILE}" + ROOTFS_IMAGE_TEMPLATE="${SWUPDATE_IMAGES_IMAGE_TEMPLATE_FILE}" + if [ "${SWUPDATE_IS_RDIFF_UPDATE}" = "true" ]; then + ROOTFS_IMAGE_TEMPLATE="${SWUPDATE_RDIFF_IMAGE_TEMPLATE_FILE}" + fi + + # Add primary bank images section for dual boot systems. + printf "%s,\n%s\n" \ + "$(sed -e "s,##IMG_NAME##,${BOOT_IMAGE_NAME},g" -e "s,##DEV##,${BOOT_DEV_NAME_A},g" -e "/compressed/d" "${BOOT_IMAGE_TEMPLATE}")" \ + "$(sed -e "s,##IMG_NAME##,${ROOTFS_IMAGE_NAME},g" -e "s,##DEV##,${ROOTFS_DEV_NAME_A},g" "${ROOTFS_IMAGE_TEMPLATE}")" \ + > images_temp.txt + sed -i -e "/##IMAGES_PRIMARY##/r images_temp.txt" -e "/##IMAGES_PRIMARY##/d" "${WORKDIR}/sw-description" + + # Add secondary bank images section for dual boot systems. + printf "%s,\n%s\n" \ + "$(sed -e "s,##IMG_NAME##,${BOOT_IMAGE_NAME},g" -e "s,##DEV##,${BOOT_DEV_NAME_B},g" -e "/compressed/d" "${BOOT_IMAGE_TEMPLATE}")" \ + "$(sed -e "s,##IMG_NAME##,${ROOTFS_IMAGE_NAME},g" -e "s,##DEV##,${ROOTFS_DEV_NAME_B},g" "${ROOTFS_IMAGE_TEMPLATE}")" \ + > images_temp.txt + sed -i -e "/##IMAGES_SECONDARY##/r images_temp.txt" -e "/##IMAGES_SECONDARY##/d" "${WORKDIR}/sw-description" + + # Add images section for single boot systems. + if [ "${SWUPDATE_IS_RDIFF_UPDATE}" != "true" ]; then + printf "%s,\n%s\n" \ + "$(sed -e "s,##IMG_NAME##,${BOOT_IMAGE_NAME},g" -e "s,##DEV##,${BOOT_DEV_NAME},g" -e "/compressed/d" "${BOOT_IMAGE_TEMPLATE}")" \ + "$(sed -e "s,##IMG_NAME##,${ROOTFS_IMAGE_NAME},g" -e "s,##DEV##,${ROOTFS_DEV_NAME_FINAL},g" "${ROOTFS_IMAGE_TEMPLATE}")" \ + > images_temp.txt + sed -i -e "/##IMAGES_SINGLE##/r images_temp.txt" -e "/##IMAGES_SINGLE##/d" "${WORKDIR}/sw-description" + fi + + # Remove 'compressed' flag for read-only file systems as they use 'squashfs' images. if [ -n "${@bb.utils.contains('IMAGE_FEATURES', 'read-only-rootfs', '1', '', d)}" ]; then - sed -i '/compressed/d' "${WORKDIR}/sw-description" + sed -i -e "/compressed/d" "${WORKDIR}/sw-description" fi - sed -i -e "s,##ROOTFS_TYPE##,${ROOTFS_TYPE},g" "${WORKDIR}/sw-description" + # Clean dir. + rm -f images_temp.txt } +fill_description[dirs] = "${DEPLOY_DIR_IMAGE} ${WORKDIR}" +do_unpack[postfuncs] += "fill_description" diff --git a/meta-digi-dey/recipes-digi/sysinfo/sysinfo/sysinfo b/meta-digi-dey/recipes-digi/sysinfo/sysinfo/sysinfo index 241ddb4f8..670ce3958 100755 --- a/meta-digi-dey/recipes-digi/sysinfo/sysinfo/sysinfo +++ b/meta-digi-dey/recipes-digi/sysinfo/sysinfo/sysinfo @@ -3,7 +3,7 @@ # # sysinfo # -# Copyright (C) 2016-2020 by Digi International Inc. +# Copyright (C) 2016-2023 by Digi International Inc. # All rights reserved. # # This program is free software; you can redistribute it and/or modify it @@ -27,6 +27,15 @@ make_report(){ uptime printf "\n\n" + echo "--------------------------------------" + echo "- -" + echo "- Firmware version -" + echo "- -" + echo "--------------------------------------" + echo "" + sed -n 's/^firmware \(.*\)/\1/p' < /etc/sw-versions + printf "\n\n" + echo "--------------------------------------" echo "- -" echo "- Kernel version -" @@ -343,7 +352,8 @@ REPORT_PATH="/tmp/sysinfo-${DEY_VERSION}-${BOARD_SN}-${DATE}" fi echo "|| DUT | ${DUT_HEADER}" echo "|| U-Boot | ${UBOOT_VERSION}" - echo "|| Firmware | ${DISTRO}-${DEY_VERSION}-$(cat /etc/version)" + echo "|| Firmware version | $(sed -n 's/^firmware \(.*\)/\1/p' < /etc/sw-versions)" + echo "|| DEY version | ${DISTRO}-${DEY_VERSION}-$(cat /etc/version)" echo "|| Kernel | $(uname -a)" echo "|| meta-digi | $(sed -ne '/^meta-digi-dey/s,.*= \(.*\)$,\1,g;T;p' /etc/build)" [ -n "${MCA_VERSION}" ] && echo "|| MCA | ${MCA_VERSION}" diff --git a/meta-digi-dey/recipes-multimedia/pulseaudio/pulseaudio/max98089/90-pulseaudio.rules b/meta-digi-dey/recipes-multimedia/pulseaudio/pulseaudio/max98089/90-pulseaudio.rules index 4c9b5ca17..02ddc76db 100644 --- a/meta-digi-dey/recipes-multimedia/pulseaudio/pulseaudio/max98089/90-pulseaudio.rules +++ b/meta-digi-dey/recipes-multimedia/pulseaudio/pulseaudio/max98089/90-pulseaudio.rules @@ -1,2 +1,3 @@ # Digi ConnectCore MAX98089 sound card ATTRS{id}=="imxmax98088", ENV{PULSE_PROFILE_SET}="dey-audio-max98089.conf" +ATTRS{id}=="max98088audio", ENV{PULSE_PROFILE_SET}="dey-audio-max98089.conf" diff --git a/meta-digi-dey/recipes-support/nghttp2/nghttp2_%.bbappend b/meta-digi-dey/recipes-support/nghttp2/nghttp2_%.bbappend deleted file mode 100644 index b7dbdad49..000000000 --- a/meta-digi-dey/recipes-support/nghttp2/nghttp2_%.bbappend +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright (C) 2023 Digi International Inc. - -ALLOW_EMPTY:${PN}-client = "1" -ALLOW_EMPTY:${PN}-server = "1" diff --git a/meta-digi-dey/recipes-support/swupdate/swupdate/0001-Makefile-change-Makefile-to-build-swupdate-library-s.patch b/meta-digi-dey/recipes-support/swupdate/swupdate/0001-Makefile-change-Makefile-to-build-swupdate-library-s.patch index 4ab476c52..dc7485828 100644 --- a/meta-digi-dey/recipes-support/swupdate/swupdate/0001-Makefile-change-Makefile-to-build-swupdate-library-s.patch +++ b/meta-digi-dey/recipes-support/swupdate/swupdate/0001-Makefile-change-Makefile-to-build-swupdate-library-s.patch @@ -5,19 +5,19 @@ Subject: [PATCH] Makefile: change Makefile to build swupdate library Signed-off-by: Mike Engel --- - Makefile | 4 +++- + Makefile | 2 ++ ipc-static/Makefile | 6 ++++++ ipc-static/network_ipc-if.c | 1 + ipc-static/network_ipc.c | 1 + ipc-static/progress_ipc.c | 1 + - 5 files changed, 12 insertions(+), 1 deletion(-) + 5 files changed, 11 insertions(+) create mode 100644 ipc-static/Makefile create mode 120000 ipc-static/network_ipc-if.c create mode 120000 ipc-static/network_ipc.c create mode 120000 ipc-static/progress_ipc.c diff --git a/Makefile b/Makefile -index 09d03a3..080b834 100644 +index 09d03a3..f34810b 100644 --- a/Makefile +++ b/Makefile @@ -364,6 +364,7 @@ include $(srctree)/Makefile.flags @@ -28,15 +28,6 @@ index 09d03a3..080b834 100644 bindings-y := bindings tools-y := tools -@@ -437,7 +438,7 @@ quiet_cmd_shared = LD $@ - "-shared -Wl,-soname,$@" \ - "$(KBUILD_CFLAGS) $(CFLAGS_swupdate)" \ - "$(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_swupdate) -L$(objtree)" \ -- "$(2)" \ -+ "$(2) ipc-static/lib.a" \ - "" \ - "$(LDLIBS)" - @@ -480,6 +481,7 @@ install: all install -m 0644 $(srctree)/include/progress_ipc.h ${DESTDIR}/${INCLUDEDIR} install -m 0755 $(objtree)/${swupdate-ipc-lib} ${DESTDIR}/${LIBDIR} diff --git a/meta-digi-dey/recipes-support/swupdate/swupdate/0003-handlers-rdiff-handler-for-applying-librsync-s-rdiff.patch b/meta-digi-dey/recipes-support/swupdate/swupdate/0003-handlers-rdiff-handler-for-applying-librsync-s-rdiff.patch new file mode 100644 index 000000000..8784f33ad --- /dev/null +++ b/meta-digi-dey/recipes-support/swupdate/swupdate/0003-handlers-rdiff-handler-for-applying-librsync-s-rdiff.patch @@ -0,0 +1,694 @@ +From: Sergey Nazaryev +Date: Thu, 27 Jan 2022 19:41:23 +0200 +Subject: [PATCH 1/1] handlers: rdiff handler for applying librsync's rdiff + patches to UBI volumes + +The ubivol rdiff handler adds support for applying binary +delta patches generated by librsync's rdiff tool to UBI volumes, +see http://librsync.sourcefrog.net + +Signed-off-by: Sergey Nazaryev +Signed-off-by: David Escalona +--- + Makefile.flags | 4 + + configs/all_handlers_defconfig | 1 + + handlers/Config.in | 13 + + handlers/Makefile | 1 + + handlers/ubivol_rdiff_handler.c | 606 ++++++++++++++++++++++++++++++++ + 5 files changed, 625 insertions(+) + create mode 100644 handlers/ubivol_rdiff_handler.c + +diff --git a/Makefile.flags b/Makefile.flags +index 2a021c8..b542358 100644 +--- a/Makefile.flags ++++ b/Makefile.flags +@@ -209,6 +209,10 @@ ifeq ($(CONFIG_RDIFFHANDLER),y) + LDLIBS += rsync + endif + ++ifeq ($(CONFIG_UBIVOL_RDIFFHANDLER),y) ++LDLIBS += rsync ++endif ++ + ifeq ($(CONFIG_REMOTE_HANDLER),y) + LDLIBS += zmq + endif +diff --git a/configs/all_handlers_defconfig b/configs/all_handlers_defconfig +index 8f6f8e0..9077220 100644 +--- a/configs/all_handlers_defconfig ++++ b/configs/all_handlers_defconfig +@@ -31,5 +31,6 @@ CONFIG_SHELLSCRIPTHANDLER=y + CONFIG_SWUFORWARDER_HANDLER=y + CONFIG_SSBLSWITCH=y + CONFIG_UBIVOL=y ++CONFIG_UBIVOL_RDIFFHANDLER=y + CONFIG_UCFWHANDLER=y + CONFIG_UNIQUEUUID=y +diff --git a/handlers/Config.in b/handlers/Config.in +index 107ffeb..62d54bd 100644 +--- a/handlers/Config.in ++++ b/handlers/Config.in +@@ -166,6 +166,19 @@ config RDIFFHANDLER + comment "rdiff support needs librsync" + depends on !HAVE_LIBRSYNC + ++config UBIVOL_RDIFFHANDLER ++ bool "ubirdiff" ++ depends on HAVE_LIBRSYNC ++ depends on HAVE_LIBUBI ++ depends on MTD ++ default n ++ help ++ Add support for applying librsync's rdiff patches to UBI volumes, ++ see http://librsync.sourcefrog.net/ ++ ++comment "ubirdiff support needs libubi and librsync" ++ depends on !HAVE_LIBRSYNC || !HAVE_LIBUBI ++ + config READBACKHANDLER + bool "readback" + depends on HASH_VERIFY +diff --git a/handlers/Makefile b/handlers/Makefile +index b5203f9..bd47d3b 100644 +--- a/handlers/Makefile ++++ b/handlers/Makefile +@@ -21,6 +21,7 @@ obj-$(CONFIG_CFIHAMMING1)+= flash_hamming1_handler.o + obj-$(CONFIG_LUASCRIPTHANDLER) += lua_scripthandler.o + obj-$(CONFIG_RAW) += raw_handler.o + obj-$(CONFIG_RDIFFHANDLER) += rdiff_handler.o ++obj-$(CONFIG_UBIVOL_RDIFFHANDLER) += ubivol_rdiff_handler.o + obj-$(CONFIG_READBACKHANDLER) += readback_handler.o + obj-$(CONFIG_REMOTE_HANDLER) += remote_handler.o + obj-$(CONFIG_SHELLSCRIPTHANDLER) += shell_scripthandler.o +diff --git a/handlers/ubivol_rdiff_handler.c b/handlers/ubivol_rdiff_handler.c +new file mode 100644 +index 0000000..3b6073d +--- /dev/null ++++ b/handlers/ubivol_rdiff_handler.c +@@ -0,0 +1,606 @@ ++/* ++ * Author: Christian Storm ++ * Copyright (C) 2018, Siemens AG ++ * ++ * SPDX-License-Identifier: GPL-2.0-only ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include "swupdate.h" ++#include "handler.h" ++#include "flash.h" ++#include "util.h" ++ ++/* Use rdiff's default inbuf and outbuf size of 64K */ ++#define RDIFF_BUFFER_SIZE 64 * 1024 ++ ++#define TEST_OR_FAIL(expr, failret) \ ++ if (expr) { \ ++ } else { \ ++ ERROR("Assertion violated: %s.", #expr); \ ++ return failret; \ ++ } ++ ++void ubivol_rdiff_image_handler(void); ++ ++struct rdiff_t ++{ ++ rs_job_t *job; ++ rs_buffers_t buffers; ++ ++ int dest_file_fd; ++ FILE *base_file; ++ ++ char *inbuf; ++ char *outbuf; ++ ++ uint8_t type; ++}; ++ ++static void rdiff_log(rs_loglevel level, char const *msg) ++{ ++ int loglevelmap[] = ++ { ++ [RS_LOG_EMERG] = ERRORLEVEL, ++ [RS_LOG_ALERT] = ERRORLEVEL, ++ [RS_LOG_CRIT] = ERRORLEVEL, ++ [RS_LOG_ERR] = ERRORLEVEL, ++ [RS_LOG_WARNING] = WARNLEVEL, ++ [RS_LOG_NOTICE] = INFOLEVEL, ++ [RS_LOG_INFO] = INFOLEVEL, ++ [RS_LOG_DEBUG] = TRACELEVEL ++ }; ++ *strchrnul(msg, '\n') = '\0'; ++ swupdate_notify(RUN, "%s", loglevelmap[level], msg); ++} ++ ++static rs_result base_file_read_cb(void *fp, rs_long_t pos, size_t *len, void **buf) ++{ ++ FILE *f = (FILE *)fp; ++ ++ if (fseek(f, pos, SEEK_SET) != 0) { ++ ERROR("Error seeking rdiff base file: %s", strerror(errno)); ++ return RS_IO_ERROR; ++ } ++ ++ int ret = fread(*buf, 1, *len, f); ++ if (ret == -1) { ++ ERROR("Error reading rdiff base file: %s", strerror(errno)); ++ return RS_IO_ERROR; ++ } ++ if (ret == 0) { ++ ERROR("Unexpected EOF on rdiff base file."); ++ return RS_INPUT_ENDED; ++ } ++ *len = ret; ++ ++ return RS_DONE; ++} ++ ++static rs_result fill_inbuffer(struct rdiff_t *rdiff_state, const void *buf, unsigned int *len) ++{ ++ rs_buffers_t *buffers = &rdiff_state->buffers; ++ ++ if (buffers->eof_in == true) { ++ TRACE("EOF on rdiff chunk input, not reading more data."); ++ return RS_DONE; ++ } ++ ++ if (*len == 0) { ++ TRACE("No rdiff chunk input to consume."); ++ return RS_DONE; ++ } ++ ++ if (buffers->avail_in == 0) { ++ /* No more buffered input data pending, get some... */ ++ TEST_OR_FAIL(*len <= RDIFF_BUFFER_SIZE, RS_IO_ERROR); ++ buffers->next_in = rdiff_state->inbuf; ++ buffers->avail_in = *len; ++ TRACE("Writing %d bytes to rdiff input buffer.", *len); ++ (void)memcpy(rdiff_state->inbuf, buf, *len); ++ *len = 0; ++ } else { ++ /* There's more input, try to append it to input buffer. */ ++ char *target = buffers->next_in + buffers->avail_in; ++ unsigned int buflen = rdiff_state->inbuf + RDIFF_BUFFER_SIZE - target; ++ buflen = buflen > *len ? *len : buflen; ++ TEST_OR_FAIL(target + buflen <= rdiff_state->inbuf + RDIFF_BUFFER_SIZE, RS_IO_ERROR); ++ ++ if (buflen == 0) { ++ TRACE("Not consuming rdiff chunk input, buffer already filled."); ++ return RS_BLOCKED; ++ } ++ TRACE("Appending %d bytes to rdiff input buffer.", buflen); ++ buffers->avail_in += buflen; ++ (void)memcpy(target, buf, buflen); ++ *len -= buflen; ++ } ++ return RS_DONE; ++} ++ ++static rs_result drain_outbuffer(struct rdiff_t *rdiff_state) ++{ ++ rs_buffers_t *buffers = &rdiff_state->buffers; ++ ++ int len = buffers->next_out - rdiff_state->outbuf; ++ TEST_OR_FAIL(len <= RDIFF_BUFFER_SIZE, RS_IO_ERROR); ++ TEST_OR_FAIL(buffers->next_out >= rdiff_state->outbuf, RS_IO_ERROR); ++ TEST_OR_FAIL(buffers->next_out <= rdiff_state->outbuf + RDIFF_BUFFER_SIZE, RS_IO_ERROR); ++ ++ if (len > 0) { ++ TRACE("Draining %d bytes from rdiff output buffer", len); ++ buffers->next_out = rdiff_state->outbuf; ++ buffers->avail_out = RDIFF_BUFFER_SIZE; ++ if (copy_write(&rdiff_state->dest_file_fd, buffers->next_out, len) != 0) { ++ ERROR("Cannot drain rdiff output buffer."); ++ return RS_IO_ERROR; ++ } ++ } else { ++ TRACE("No output rdiff buffer data to drain."); ++ } ++ return RS_DONE; ++} ++ ++static inline void rdiff_stats(const char* msg, struct rdiff_t *rdiff_state, rs_result result) { ++ rs_buffers_t *buffers = &rdiff_state->buffers; ++ char *strresult = (char*)"ERROR"; ++ switch (result) { ++ case RS_DONE: strresult = (char*)"DONE"; break; ++ case RS_BLOCKED: strresult = (char*)"BLOCKED"; break; ++ case RS_RUNNING: strresult = (char*)"RUNNING"; break; ++ default: break; ++ } ++ TRACE("%s avail_in=%ld avail_out=%ld result=%s", ++ msg, buffers->avail_in, buffers->avail_out, strresult); ++} ++ ++/** ++ * check_ubi_alwaysremove - check the property always-remove for this image ++ * @img: image information ++ * ++ * Return: 1 if the property always-remove is true, otherwise 0. ++ */ ++static bool check_ubi_alwaysremove(struct img_type *img) ++{ ++ return strtobool(dict_get_value(&img->properties, "always-remove")); ++} ++ ++static struct ubi_part *search_volume(const char *str, struct ubilist *list) ++{ ++ struct ubi_part *vol; ++ ++ LIST_FOREACH(vol, list, next) { ++ if (strcmp(vol->vol_info.name, str) == 0) ++ return vol; ++ } ++ return NULL; ++} ++ ++/* search a UBI volume by name across all mtd partitions */ ++static struct ubi_part *search_volume_global(const char *str) ++{ ++ struct flash_description *flash = get_flash_info(); ++ struct mtd_info *mtd_info = &flash->mtd; ++ struct mtd_ubi_info *mtd_ubi_info; ++ struct ubi_part *ubivol; ++ int i; ++ ++ for (i = mtd_info->lowest_mtd_num; i <= mtd_info->highest_mtd_num; i++) { ++ mtd_ubi_info = &flash->mtd_info[i]; ++ ubivol = search_volume(str, &mtd_ubi_info->ubi_partitions); ++ if (ubivol) ++ return ubivol; ++ } ++ return NULL; ++} ++ ++static int resize_volume(struct img_type *cfg, long long size) ++{ ++ struct flash_description *nandubi = get_flash_info(); ++ struct ubi_part *ubivol; ++ struct ubi_mkvol_request req; ++ struct mtd_ubi_info *mtd_info; ++ int mtdnum, req_vol_type; ++ char node[64]; ++ int err; ++ struct flash_description *flash = get_flash_info(); ++ ++ /* determine the requested volume type */ ++ if (!strcmp(cfg->type_data, "static")) ++ req_vol_type = UBI_STATIC_VOLUME; ++ else ++ req_vol_type = UBI_DYNAMIC_VOLUME; ++ ++ /* ++ * Partition are adjusted only in one MTD device ++ * Other MTD are not touched ++ */ ++ mtdnum = get_mtd_from_device(cfg->device); ++ if (mtdnum < 0) { ++ /* Allow device to be specified by name OR number */ ++ mtdnum = get_mtd_from_name(cfg->device); ++ } ++ if (mtdnum < 0 || !mtd_dev_present(flash->libmtd, mtdnum)) { ++ ERROR("%s does not exist: partitioning not possible", ++ cfg->device); ++ return -ENODEV; ++ } ++ ++ mtd_info = &nandubi->mtd_info[mtdnum]; ++ ++ /* ++ * Search for volume with the same name ++ */ ++ ubivol = mtd_info->ubi_partitions.lh_first; ++ for(ubivol = mtd_info->ubi_partitions.lh_first; ++ ubivol != NULL; ++ ubivol = ubivol->next.le_next) { ++ if (strcmp(ubivol->vol_info.name, cfg->volname) == 0) { ++ break; ++ } ++ } ++ ++ if (ubivol) { ++ unsigned int requested_lebs, allocated_lebs; ++ ++ /* This should never happen, the fields are filled by scan_ubi */ ++ if (!mtd_info->dev_info.leb_size) { ++ return -EFAULT; ++ } ++ ++ /* Check if size is changed */ ++ requested_lebs = size / mtd_info->dev_info.leb_size + ++ ((size % mtd_info->dev_info.leb_size) ? 1 : 0); ++ allocated_lebs = ubivol->vol_info.rsvd_bytes / mtd_info->dev_info.leb_size; ++ ++ if (requested_lebs == allocated_lebs && ++ req_vol_type == ubivol->vol_info.type && ++ !check_ubi_alwaysremove(cfg)) { ++ TRACE("skipping volume %s (same size and type)", ++ ubivol->vol_info.name); ++ return 0; ++ } ++ ++ snprintf(node, sizeof(node), "/dev/ubi%d", ubivol->vol_info.dev_num); ++ err = ubi_rmvol(nandubi->libubi, node, ubivol->vol_info.vol_id); ++ if (err) { ++ ERROR("Volume %s cannot be dropped", ubivol->vol_info.name); ++ return -1; ++ } ++ TRACE("Removed UBI Volume %s", ubivol->vol_info.name); ++ ++ LIST_REMOVE(ubivol, next); ++ free(ubivol); ++ } ++ ++ if (size) { ++ /* We do not need a volume to get the right node */ ++ snprintf(node, sizeof(node), "/dev/ubi%d", mtd_info->dev_info.dev_num); ++ ++ /* ++ * Creates all other partitions as specified in the description file ++ * Volumes are empty, and they are filled later by the update procedure ++ */ ++ memset(&req, 0, sizeof(req)); ++ req.vol_type = req_vol_type; ++ req.vol_id = UBI_VOL_NUM_AUTO; ++ req.alignment = 1; ++ req.bytes = size; ++ req.name = cfg->volname; ++ err = ubi_mkvol(nandubi->libubi, node, &req); ++ if (err < 0) { ++ ERROR("cannot create %s UBI volume %s of %lld bytes", ++ (req_vol_type == UBI_DYNAMIC_VOLUME) ? "dynamic" : "static", ++ req.name, req.bytes); ++ return err; ++ } ++ ++ ubivol = (struct ubi_part *)calloc(1, sizeof(struct ubi_part)); ++ if (!ubivol) { ++ ERROR("No memory: malloc failed"); ++ return -ENOMEM; ++ } ++ err = ubi_get_vol_info1(nandubi->libubi, ++ mtd_info->dev_info.dev_num, req.vol_id, ++ &ubivol->vol_info); ++ if (err) { ++ ERROR("cannot get information about " ++ "newly created UBI volume"); ++ return err; ++ } ++ LIST_INSERT_HEAD(&mtd_info->ubi_partitions, ubivol, next); ++ TRACE("Created %s UBI volume %s of %lld bytes (old size %lld)", ++ (req_vol_type == UBI_DYNAMIC_VOLUME) ? "dynamic" : "static", ++ req.name, req.bytes, ubivol->vol_info.rsvd_bytes); ++ } ++ ++ return 0; ++} ++ ++/** ++ * check_auto_resize - check the property auto-resize for this image ++ * @img: image information ++ * ++ * Return: 1 if the property auto-resize is true, otherwise 0. ++ */ ++static bool check_ubi_autoresize(struct img_type *img) ++{ ++ return strtobool(dict_get_value(&img->properties, "auto-resize")); ++} ++ ++static int wait_volume(struct img_type *img) ++{ ++ int ret = -1, num = 0, dev_num, vol_id; ++ struct ubi_part *ubivol; ++ struct stat buf; ++ char node[64]; ++ ++ ubivol = search_volume_global(img->volname); ++ if (!ubivol) { ++ ERROR("can't found volume %s", img->volname); ++ return -1; ++ } ++ ++ dev_num = ubivol->vol_info.dev_num; ++ vol_id = ubivol->vol_info.vol_id; ++ ++ snprintf(node, sizeof(node), "/dev/ubi%d_%d", ++ dev_num, ++ vol_id); ++ ++ while (num++ < 5) ++ { ++ ret = stat(node, &buf); ++ if (!ret) ++ break; ++ ++ sleep(1); ++ } ++ ++ return ret; ++} ++ ++static int apply_rdiff_chunk_cb(void *out, const void *buf, unsigned int len) ++{ ++ struct rdiff_t *rdiff_state = (struct rdiff_t *)out; ++ rs_buffers_t *buffers = &rdiff_state->buffers; ++ unsigned int inbytesleft = len; ++ rs_result result = RS_RUNNING; ++ rs_result drain_run_result = RS_RUNNING; ++ ++ if (buffers->next_out == NULL) { ++ TEST_OR_FAIL(buffers->avail_out == 0, -1); ++ buffers->next_out = rdiff_state->outbuf; ++ buffers->avail_out = RDIFF_BUFFER_SIZE; ++ } ++ ++ while (inbytesleft > 0 || buffers->avail_in > 0) { ++ rdiff_stats("[pre] ", rdiff_state, result); ++ result = fill_inbuffer(rdiff_state, buf, &inbytesleft); ++ if (result != RS_DONE && result != RS_BLOCKED) { ++ return -1; ++ } ++ result = rs_job_iter(rdiff_state->job, buffers); ++ if (result != RS_DONE && result != RS_BLOCKED) { ++ ERROR("Error processing rdiff chunk: %s", rs_strerror(result)); ++ return -1; ++ } ++ drain_run_result = drain_outbuffer(rdiff_state); ++ if (drain_run_result != RS_DONE) { ++ ERROR("drain_outbuffer return error"); ++ return -1; ++ } ++ rdiff_stats("[post]", rdiff_state, result); ++ ++ if (result == RS_DONE) { ++ TRACE("rdiff processing done."); ++ break; ++ } ++ } ++ rdiff_stats("[ret] ", rdiff_state, result); ++ return 0; ++} ++ ++static int apply_rdiff_patch(struct img_type *img, ++ void __attribute__((__unused__)) * data) ++{ ++ int ret = 0; ++ long long bytes; ++ char node[64]; ++ int err; ++ char sbuf[128]; ++ ++ struct rdiff_t rdiff_state = {}; ++ rdiff_state.type = IMAGE_HANDLER; ++ ++ struct flash_description *flash = get_flash_info(); ++ libubi_t libubi = flash->libubi; ++ ++ char *base_file_filename = NULL; ++ char *output_size_str = NULL; ++ struct ubi_part *ubivol; ++ struct ubi_vol_info *vol; ++ ++ if (img->seek) { ++ /* ++ * img->seek mandates copyfile()'s out parameter to be a fd, it ++ * isn't. So, the seek option is invalid for the rdiff handler. ++ * */ ++ ERROR("Option 'seek' is not supported for rdiff."); ++ return -1; ++ } ++ ++ base_file_filename = dict_get_value(&img->properties, "rdiffbase"); ++ if (base_file_filename == NULL) { ++ ERROR("Property 'rdiffbase' is missing in sw-description."); ++ return -1; ++ } ++ ++ output_size_str = dict_get_value(&img->properties, "rdiffnewsize"); ++ if (!output_size_str) { ++ ERROR("Property 'rdiffnewsize' is missing in sw-description."); ++ return -1; ++ } ++ ++ bytes = ustrtoull(output_size_str, NULL, 0); ++ if (errno || bytes <= 0) { ++ ERROR("rdiffnewsize argument %s: ustrtoull failed", ++ output_size_str); ++ return -1; ++ } ++ TRACE("The size after applying patch would be %lld bytes", bytes); ++ ++ if (check_ubi_autoresize(img)) { ++ ret = resize_volume(img, bytes); ++ if (ret < 0) { ++ ERROR("Can't resize ubi volume %s", img->volname); ++ return -1; ++ } ++ ++ ret = wait_volume(img); ++ if (ret < 0) { ++ ERROR("can't found ubi volume %s", img->volname); ++ return -1; ++ } ++ } ++ ++ if (!libubi) { ++ ERROR("Request to write into UBI, but no UBI on system"); ++ return -1; ++ } ++ ++ /* find the volume to be updated */ ++ ubivol = search_volume_global(img->volname); ++ ++ if (!ubivol) { ++ ERROR("Image %s should be stored in volume " ++ "%s, but no volume found", ++ img->fname, ++ img->volname); ++ return -1; ++ } ++ ++ vol = &ubivol->vol_info; ++ ++ if (bytes > vol->rsvd_bytes) { ++ ERROR("\"%s\" (size %lld) will not fit volume \"%s\" (size %lld)", ++ img->fname, bytes, img->volname, vol->rsvd_bytes); ++ return -1; ++ } ++ ++ snprintf(node, sizeof(node), "/dev/ubi%d_%d", ++ vol->dev_num, ++ vol->vol_id); ++ ++ err = ubi_probe_node(libubi, node); ++ ++ if (err == 1) { ++ ERROR("\"%s\" is an UBI device node, not an UBI volume node", ++ node); ++ return -1; ++ } ++ if (err < 0) { ++ if (errno == ENODEV) ++ ERROR("%s is not an UBI volume node", node); ++ else ++ ERROR("error while probing %s", node); ++ return -1; ++ } ++ ++ rdiff_state.dest_file_fd = open(node, O_RDWR); ++ if (rdiff_state.dest_file_fd < 0) { ++ ERROR("cannot open UBI volume \"%s\"", node); ++ return -1; ++ } ++ ++ if ((rdiff_state.base_file = fopen(base_file_filename, "rb+")) == NULL) { ++ ERROR("%s cannot be opened for reading: %s", base_file_filename, strerror(errno)); ++ ret = -1; ++ goto cleanup; ++ } ++ ++ if (!(rdiff_state.inbuf = malloc(RDIFF_BUFFER_SIZE))) { ++ ERROR("Cannot allocate memory for rdiff input buffer."); ++ ret = -1; ++ goto cleanup; ++ } ++ ++ if (!(rdiff_state.outbuf = malloc(RDIFF_BUFFER_SIZE))) { ++ ERROR("Cannot allocate memory for rdiff output buffer."); ++ ret = -1; ++ goto cleanup; ++ } ++ ++ err = ubi_update_start(libubi, rdiff_state.dest_file_fd, bytes); ++ if (err) { ++ ERROR("cannot start volume \"%s\" update", node); ++ ret = -1; ++ goto cleanup; ++ } ++ ++ snprintf(sbuf, sizeof(sbuf), "Installing image %s into volume %s(%s)", ++ img->fname, node, img->volname); ++ notify(RUN, RECOVERY_NO_ERROR, INFOLEVEL, sbuf); ++ ++ int loglevelmap[] = ++ { ++ [OFF] = RS_LOG_ERR, ++ [ERRORLEVEL] = RS_LOG_ERR, ++ [WARNLEVEL] = RS_LOG_WARNING, ++ [INFOLEVEL] = RS_LOG_INFO, ++ [DEBUGLEVEL] = RS_LOG_DEBUG, ++ [TRACELEVEL] = RS_LOG_DEBUG, ++ }; ++ rs_trace_set_level(loglevelmap[loglevel]); ++ rs_trace_to(rdiff_log); ++ ++ rdiff_state.job = rs_patch_begin(base_file_read_cb, rdiff_state.base_file); ++ ret = copyfile(img->fdin, ++ &rdiff_state, ++ img->size, ++ (unsigned long *)&img->offset, ++ img->seek, ++ 0, /* no skip */ ++ img->compressed, ++ &img->checksum, ++ img->sha256, ++ img->is_encrypted, ++ img->ivt_ascii, ++ apply_rdiff_chunk_cb); ++ if (ret != 0) { ++ ERROR("Error %d running rdiff job, aborting.", ret); ++ goto cleanup; ++ } ++ ++cleanup: ++ free(rdiff_state.inbuf); ++ free(rdiff_state.outbuf); ++ if (rdiff_state.job != NULL) { ++ (void)rs_job_free(rdiff_state.job); ++ } ++ if (rdiff_state.base_file != NULL) { ++ if (fclose(rdiff_state.base_file) == EOF) { ++ ERROR("Error while closing rdiff base: %s", strerror(errno)); ++ } ++ } ++ close(rdiff_state.dest_file_fd); ++ return ret; ++} ++ ++__attribute__((constructor)) ++void ubivol_rdiff_image_handler(void) ++{ ++ register_handler("ubivol_rdiff_image", apply_rdiff_patch, IMAGE_HANDLER, NULL); ++} diff --git a/meta-digi-dey/recipes-support/swupdate/swupdate/defconfig b/meta-digi-dey/recipes-support/swupdate/swupdate/defconfig index 5696220c0..ed9b3f416 100644 --- a/meta-digi-dey/recipes-support/swupdate/swupdate/defconfig +++ b/meta-digi-dey/recipes-support/swupdate/swupdate/defconfig @@ -1,126 +1,10 @@ -# -# Automatically generated file; DO NOT EDIT. -# SWUpdate Configuration -# - -# -# SWUpdate Settings -# - -# -# General Configuration -# -# CONFIG_CURL is not set -# CONFIG_CURL_SSL is not set -# CONFIG_DISKFORMAT is not set -# CONFIG_SYSTEMD is not set -CONFIG_DEFAULT_CONFIG_FILE="/etc/swupdate.cfg" -CONFIG_SCRIPTS=y -# CONFIG_HW_COMPATIBILITY is not set -CONFIG_SW_VERSIONS_FILE="/etc/sw-versions" - -# -# Socket Paths -# -CONFIG_SOCKET_CTRL_PATH="" -CONFIG_SOCKET_PROGRESS_PATH="" +# CONFIG_MTD is not set # CONFIG_LUA is not set -# CONFIG_FEATURE_SYSLOG is not set - -# -# Build Options -# -CONFIG_CROSS_COMPILE="" -CONFIG_SYSROOT="" -CONFIG_EXTRA_CFLAGS="" -CONFIG_EXTRA_LDFLAGS="" -CONFIG_EXTRA_LDLIBS="" - -# -# Debugging Options -# -# CONFIG_DEBUG is not set -# CONFIG_WERROR is not set -# CONFIG_NOCLEANUP is not set - -# -# Bootloader support -# - -# -# Bootloader Interfaces -# # CONFIG_BOOTLOADER_NONE is not set -# CONFIG_BOOTLOADER_EBG is not set CONFIG_UBOOT=y -CONFIG_UBOOT_FWENV="/etc/fw_env.config" -CONFIG_UBOOT_DEFAULTENV="/etc/u-boot-initial-env" -# CONFIG_BOOTLOADER_GRUB is not set -CONFIG_BOOTLOADER_DEFAULT_UBOOT=y -CONFIG_UPDATE_STATE_CHOICE_NONE=y -# CONFIG_UPDATE_STATE_CHOICE_BOOTLOADER is not set - -# -# Interfaces -# -# CONFIG_DOWNLOAD is not set -# CONFIG_SURICATTA is not set -# CONFIG_WEBSERVER is not set - -# -# Security -# -# CONFIG_SSL_IMPL_NONE is not set -CONFIG_SSL_IMPL_OPENSSL=y -# CONFIG_SSL_IMPL_WOLFSSL is not set -# CONFIG_SSL_IMPL_MBEDTLS is not set CONFIG_HASH_VERIFY=y -# CONFIG_SIGNED_IMAGES is not set -# CONFIG_ENCRYPTED_IMAGES is not set - -# -# Compressors (zlib always on) -# -CONFIG_GUNZIP=y -# CONFIG_ZSTD is not set - -# -# Parsers -# - -# -# Parser Features -# -CONFIG_LIBCONFIG=y -CONFIG_PARSERROOT="" -# CONFIG_JSON is not set -# CONFIG_SETSWDESCRIPTION is not set - -# -# Handlers -# - -# -# Image Handlers -# -# CONFIG_ARCHIVE is not set -# CONFIG_BOOTLOADERHANDLER is not set -CONFIG_CFI=y -# CONFIG_CFIHAMMING1 is not set -# CONFIG_DELTA is not set -# CONFIG_DISKPART is not set -# CONFIG_DISKFORMAT_HANDLER is not set +CONFIG_ARCHIVE=y +CONFIG_BOOTLOADERHANDLER=y CONFIG_RAW=y -# CONFIG_RDIFFHANDLER is not set -# CONFIG_READBACKHANDLER is not set -# CONFIG_REMOTE_HANDLER is not set +CONFIG_RDIFFHANDLER=y CONFIG_SHELLSCRIPTHANDLER=y -# CONFIG_SWUFORWARDER_HANDLER is not set -# CONFIG_SSBLSWITCH is not set -CONFIG_UBIVOL=y -CONFIG_UBIATTACH=y -CONFIG_UBIBLACKLIST="" -CONFIG_UBIWHITELIST="" -CONFIG_UBIVIDOFFSET=0 -# CONFIG_UCFWHANDLER is not set -# CONFIG_UNIQUEUUID is not set diff --git a/meta-digi-dey/recipes-support/swupdate/swupdate/mtd.cfg b/meta-digi-dey/recipes-support/swupdate/swupdate/mtd.cfg index 3e58d300c..787b48bfc 100644 --- a/meta-digi-dey/recipes-support/swupdate/swupdate/mtd.cfg +++ b/meta-digi-dey/recipes-support/swupdate/swupdate/mtd.cfg @@ -1,2 +1,10 @@ # Add MTD support CONFIG_MTD=y +# Add UBI support +CONFIG_UBIVOL=y +CONFIG_UBIATTACH=y +CONFIG_UBIBLACKLIST="" +CONFIG_UBIWHITELIST="" +CONFIG_UBIVIDOFFSET=0 +# Add UBIVOL_RDIFFHANDLER support +CONFIG_UBIVOL_RDIFFHANDLER=y diff --git a/meta-digi-dey/recipes-support/swupdate/swupdate/signed_images.cfg b/meta-digi-dey/recipes-support/swupdate/swupdate/signed_images.cfg new file mode 100644 index 000000000..a6f0b2c59 --- /dev/null +++ b/meta-digi-dey/recipes-support/swupdate/swupdate/signed_images.cfg @@ -0,0 +1,2 @@ +# Add SIGNED_IMAGES support +CONFIG_SIGNED_IMAGES=y diff --git a/meta-digi-dey/recipes-support/swupdate/swupdate_%.bbappend b/meta-digi-dey/recipes-support/swupdate/swupdate_%.bbappend index feaaeeb6e..de0feed77 100644 --- a/meta-digi-dey/recipes-support/swupdate/swupdate_%.bbappend +++ b/meta-digi-dey/recipes-support/swupdate/swupdate_%.bbappend @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2022 Digi International Inc. +# Copyright (C) 2016-2023 Digi International Inc. FILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}:" @@ -8,21 +8,12 @@ RDEPENDS:${PN} += "libgcc" SRC_URI += " \ file://0001-Makefile-change-Makefile-to-build-swupdate-library-s.patch \ file://0002-config-add-on-the-fly-build-configuration-variable.patch \ + file://0003-handlers-rdiff-handler-for-applying-librsync-s-rdiff.patch \ ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'file://systemd.cfg', '', d)} \ ${@bb.utils.contains('STORAGE_MEDIA', 'mtd', 'file://mtd.cfg', '', d)} \ + ${@oe.utils.conditional('TRUSTFENCE_SIGN', '1', 'file://signed_images.cfg', '', d)} \ " -do_configure:append() { - # If Trustfence is enabled, enable the signing support in the - # '.config' file. - if [ "${TRUSTFENCE_SIGN}" = "1" ]; then - echo "CONFIG_SIGNED_IMAGES=y" >> ${B}/.config - fi - # add U-Booot handler to use uboot: type - echo "CONFIG_BOOTLOADERHANDLER=y" >> ${B}/.config - cml1_do_configure -} - do_install:append() { # Copy the 'progress' binary. install -d ${D}${bindir}/ diff --git a/sdk/build.sh b/sdk/build.sh index cb590d646..0c803c107 100755 --- a/sdk/build.sh +++ b/sdk/build.sh @@ -15,7 +15,6 @@ # # Parameters set by Jenkins: # DY_BUILD_TCHAIN: Build toolchains for DEY images -# DY_BUILD_VARIANTS: Build all platform variants # DY_DISTRO: Distribution name (the default is 'dey') # DY_PLATFORMS: Platforms to build # DY_REVISION: Revision of the manifest repository (for 'repo init') @@ -158,10 +157,6 @@ if [ -z "${DY_MFG_IMAGE}" ] && echo "${JOB_NAME}" | grep -qs 'dey.*mfg'; then DY_MFG_IMAGE="true" fi -if [ -n "${DY_MACHINES_LAYER}" ]; then - MACHINES_LAYER="-m ${DY_MACHINES_LAYER}" -fi - [ -z "${DY_CVE_REPORT}" ] && DY_CVE_REPORT="false" [ -z "${DY_USE_CVE_LAYER}" ] && DY_USE_CVE_LAYER="false" @@ -251,7 +246,7 @@ for platform in ${DY_PLATFORMS}; do ( export TEMPLATECONF="${TEMPLATECONF:+${TEMPLATECONF}/${platform}}" # shellcheck disable=SC1091,SC2086 - MKP_PAGER="" . ${YOCTO_INST_DIR}/mkproject.sh -p "${platform}" ${MACHINES_LAYER} <<< "y" + MKP_PAGER="" . ${YOCTO_INST_DIR}/mkproject.sh -p "${platform}" ${DY_MACHINES_LAYER:+-m ${DY_MACHINES_LAYER}} <<< "y" # Set a common DL_DIR and SSTATE_DIR for all platforms sed -i -e "/^#DL_DIR ?=/cDL_DIR ?= \"${YOCTO_DOWNLOAD_DIR}\"" \ -e "/^#SSTATE_DIR ?=/cSSTATE_DIR ?= \"${YOCTO_PROJ_DIR}/sstate-cache\"" \ diff --git a/sdk/config/ccimx6qpsbc/bblayers.conf.sample b/sdk/config/ccimx6qpsbc/bblayers.conf.sample index 5ccdd6617..974e731e4 100644 --- a/sdk/config/ccimx6qpsbc/bblayers.conf.sample +++ b/sdk/config/ccimx6qpsbc/bblayers.conf.sample @@ -13,7 +13,7 @@ BBLAYERS ?= " \ ##DIGIBASE##/meta-openembedded/meta-python \ ##DIGIBASE##/meta-openembedded/meta-networking \ ##DIGIBASE##/meta-openembedded/meta-webserver \ - ##DIGIBASE##/meta-qt5 \ + ##DIGIBASE##/meta-qt6 \ ##DIGIBASE##/meta-swupdate \ ##DIGIBASE##/meta-freescale \ ##DIGIBASE##/meta-fsl-demos \ diff --git a/sdk/config/ccimx6sbc/bblayers.conf.sample b/sdk/config/ccimx6sbc/bblayers.conf.sample index 5ccdd6617..974e731e4 100644 --- a/sdk/config/ccimx6sbc/bblayers.conf.sample +++ b/sdk/config/ccimx6sbc/bblayers.conf.sample @@ -13,7 +13,7 @@ BBLAYERS ?= " \ ##DIGIBASE##/meta-openembedded/meta-python \ ##DIGIBASE##/meta-openembedded/meta-networking \ ##DIGIBASE##/meta-openembedded/meta-webserver \ - ##DIGIBASE##/meta-qt5 \ + ##DIGIBASE##/meta-qt6 \ ##DIGIBASE##/meta-swupdate \ ##DIGIBASE##/meta-freescale \ ##DIGIBASE##/meta-fsl-demos \ diff --git a/sdk/config/ccimx8x-sbc-express/bblayers.conf.sample b/sdk/config/ccimx8x-sbc-express/bblayers.conf.sample index 5ccdd6617..974e731e4 100644 --- a/sdk/config/ccimx8x-sbc-express/bblayers.conf.sample +++ b/sdk/config/ccimx8x-sbc-express/bblayers.conf.sample @@ -13,7 +13,7 @@ BBLAYERS ?= " \ ##DIGIBASE##/meta-openembedded/meta-python \ ##DIGIBASE##/meta-openembedded/meta-networking \ ##DIGIBASE##/meta-openembedded/meta-webserver \ - ##DIGIBASE##/meta-qt5 \ + ##DIGIBASE##/meta-qt6 \ ##DIGIBASE##/meta-swupdate \ ##DIGIBASE##/meta-freescale \ ##DIGIBASE##/meta-fsl-demos \ diff --git a/sdk/config/ccimx8x-sbc-pro/bblayers.conf.sample b/sdk/config/ccimx8x-sbc-pro/bblayers.conf.sample index 66728617e..1558e7315 100644 --- a/sdk/config/ccimx8x-sbc-pro/bblayers.conf.sample +++ b/sdk/config/ccimx8x-sbc-pro/bblayers.conf.sample @@ -14,7 +14,7 @@ BBLAYERS ?= " \ ##DIGIBASE##/meta-openembedded/meta-multimedia \ ##DIGIBASE##/meta-openembedded/meta-networking \ ##DIGIBASE##/meta-openembedded/meta-webserver \ - ##DIGIBASE##/meta-qt5 \ + ##DIGIBASE##/meta-qt6 \ ##DIGIBASE##/meta-swupdate \ ##DIGIBASE##/meta-freescale \ ##DIGIBASE##/meta-fsl-demos \ diff --git a/sdk/config/ccimx93-dvk/conf-notes.txt b/sdk/config/ccimx93-dvk/conf-notes.txt index b49f5e14b..d9cb627a2 100644 --- a/sdk/config/ccimx93-dvk/conf-notes.txt +++ b/sdk/config/ccimx93-dvk/conf-notes.txt @@ -5,7 +5,3 @@ Digi Embedded Yocto provides the following image recipes: By default the image is XWayland-based so it provides a full Weston desktop environment. - * dey-image-webkit: graphical WebKit image - - By default the image is XWayland-based so it provides a full Weston - desktop environment. diff --git a/sdk/mkproject.sh b/sdk/mkproject.sh index c201767de..86a4b2824 100755 --- a/sdk/mkproject.sh +++ b/sdk/mkproject.sh @@ -28,7 +28,7 @@ MKP_NONE="\033[0m" MKP_CONFIGPATH="${MKP_SCRIPTPATH}/sources/meta-digi/sdk/config" # Blacklist platforms (not officially supported in a DEY release) -MKP_BLACKLIST_PLATFORMS="ccimx6qpsbc ccimx6sbc ccimx8x-sbc-express ccimx8x-sbc-pro" +MKP_BLACKLIST_PLATFORMS="" MKP_SETUP_ENVIRONMENT='#!/bin/bash