diff --git a/README.md b/README.md index c93029719..afa831b3a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Digi Embedded Yocto (DEY) 2.6 -## Release 2.6-r2 +## Release 2.6-r3 This document provides information about Digi Embedded Yocto, Digi International's professional embedded Yocto development environment. @@ -86,8 +86,8 @@ Documentation is available online at https://www.digi.com/resources/documentatio # Downloads -* Demo images: ftp://ftp1.digi.com/support/digiembeddedyocto/2.6/r2/images/ -* Software Development Kit (SDK): ftp://ftp1.digi.com/support/digiembeddedyocto/2.6/r2/sdk/ +* Demo images: https://ftp1.digi.com/support/digiembeddedyocto/2.6/r2/images/ +* Software Development Kit (SDK): https://ftp1.digi.com/support/digiembeddedyocto/2.6/r2/sdk/ # Release Changelog diff --git a/meta-digi-arm/classes/fsl-eula-unpack.bbclass b/meta-digi-arm/classes/fsl-eula-unpack.bbclass index e33ed07c9..588fd3db9 100644 --- a/meta-digi-arm/classes/fsl-eula-unpack.bbclass +++ b/meta-digi-arm/classes/fsl-eula-unpack.bbclass @@ -6,7 +6,7 @@ # # SRC_URI = "${FSL_MIRROR}/firmware-imx-${PV};fsl-eula=true" -LIC_FILES_CHKSUM_append = " file://${FSL_EULA_FILE};md5=72c0f70181bb6e83eee6aab8de12a9f3" +LIC_FILES_CHKSUM_append = " file://${FSL_EULA_FILE};md5=fd4b227530cd88a82af6a5982cfb724d" LIC_FILES_CHKSUM[vardepsexclude] += "FSL_EULA_FILE" diff --git a/meta-digi-arm/classes/image_types_digi.bbclass b/meta-digi-arm/classes/image_types_digi.bbclass index bbfe2668d..dcb85f51d 100644 --- a/meta-digi-arm/classes/image_types_digi.bbclass +++ b/meta-digi-arm/classes/image_types_digi.bbclass @@ -206,6 +206,10 @@ trustence_sign_cpio() { [ -n "${TRUSTFENCE_KEY_INDEX}" ] && export CONFIG_KEY_INDEX="${TRUSTFENCE_KEY_INDEX}" [ -n "${TRUSTFENCE_DEK_PATH}" ] && [ "${TRUSTFENCE_DEK_PATH}" != "0" ] && export CONFIG_DEK_PATH="${TRUSTFENCE_DEK_PATH}" + if [ "${SIGN_MODE}" = "AHAB" ]; then + ${DEPLOY_DIR_IMAGE}/imx-boot-tools/mkimage_imx8 -soc ${MX8_SOC_VAR} -rev ${MX8_CHIP_REV} -c -ap ${1} a35 ${RAM_CONTAINER_LOC_TF} -out ${1}-mkimg + mv "${1}-mkimg" "${1}" + fi # Sign/encrypt the ramdisk trustfence-sign-kernel.sh -p "${DIGI_FAMILY}" -i "${1}" "${1}.tf" else @@ -215,7 +219,8 @@ trustence_sign_cpio() { } CONVERSIONTYPES += "tf" CONVERSION_CMD_tf = "trustence_sign_cpio ${IMAGE_NAME}.rootfs.${type}" -CONVERSION_DEPENDS_tf = "${@oe.utils.conditional('TRUSTFENCE_SIGN', '1', 'trustfence-sign-tools-native', '', d)}" +CONVERSION_DEPENDS_tf = "${@oe.utils.conditional('TRUSTFENCE_SIGN', '1', \ + oe.utils.conditional('SIGN_MODE', 'AHAB', 'trustfence-sign-tools-native imx-mkimage', 'trustfence-sign-tools-native', d), '', d)}" IMAGE_TYPES += "cpio.gz.u-boot.tf" ################################################################################ diff --git a/meta-digi-arm/conf/layer.conf b/meta-digi-arm/conf/layer.conf index d400f808d..332cd6334 100644 --- a/meta-digi-arm/conf/layer.conf +++ b/meta-digi-arm/conf/layer.conf @@ -23,6 +23,6 @@ LICENSE_PATH += "${LAYERDIR}/custom-licenses" DIGI_LOG_GIT ?= "git://log-sln-git.digi.com/" DIGI_MTK_GIT ?= "git://stash.digi.com/" DIGI_GIT ?= "${DIGI_LOG_GIT}" -DIGI_PKG_SRC ?= "ftp://ftp1.digi.com/support/digiembeddedyocto/source" +DIGI_PKG_SRC ?= "https://ftp1.digi.com/support/digiembeddedyocto/source" DIGI_GITHUB_GIT ?= "git://github.com/digi-embedded" diff --git a/meta-digi-arm/conf/machine/ccimx6qpsbc.conf b/meta-digi-arm/conf/machine/ccimx6qpsbc.conf index 334639e36..c033e6f50 100644 --- a/meta-digi-arm/conf/machine/ccimx6qpsbc.conf +++ b/meta-digi-arm/conf/machine/ccimx6qpsbc.conf @@ -7,9 +7,11 @@ include conf/machine/include/ccimx6.inc # Wireless external module WIRELESS_MODULE_append = " ${@oe.utils.conditional('HAVE_WIFI', '1', 'kernel-module-qualcomm', '', d)}" +HAS_WIFI_VIRTWLANS = "true" # Wireless p2p interface WLAN_P2P_INTERFACE ?= "p2p0" +WLAN_P2P_DEVICE_NAME ?= "ccimx6qp-p2p" MACHINE_EXTRA_RRECOMMENDS += " \ cryptoauthlib \ @@ -36,9 +38,15 @@ KERNEL_DEVICETREE ?= " \ SERIAL_CONSOLES ?= "115200;ttymxc3" +# Bluetooth interface +BT_DEVICE_NAME ?= "cc6qp" + # Bluetooth tty BT_TTY ?= "ttymxc1" +# XBee +XBEE_TTY ?= "ttymxc4" + # U-Boot script to be copied to the boot image BOOT_SCRIPTS = "boot.scr:boot.scr" diff --git a/meta-digi-arm/conf/machine/ccimx6sbc.conf b/meta-digi-arm/conf/machine/ccimx6sbc.conf index 5d399b38e..ea98b6b24 100644 --- a/meta-digi-arm/conf/machine/ccimx6sbc.conf +++ b/meta-digi-arm/conf/machine/ccimx6sbc.conf @@ -5,6 +5,11 @@ # Contains the ConnectCore 6 module. include conf/machine/include/ccimx6.inc +HAS_WIFI_VIRTWLANS = "false" + +# Wireless p2p interface +WLAN_P2P_DEVICE_NAME ?= "ccimx6-p2p" + # Firmware MACHINE_FIRMWARE_append = " ${@oe.utils.conditional('HAVE_BT', '1' , 'firmware-atheros-ar3k', '', d)}" MACHINE_FIRMWARE_append = " ${@oe.utils.conditional('HAVE_WIFI', '1' , 'firmware-atheros-ath6kl', '', d)}" @@ -35,9 +40,15 @@ KERNEL_DEVICETREE ?= " \ SERIAL_CONSOLES ?= "115200;ttymxc3" +# Bluetooth interface +BT_DEVICE_NAME ?= "cc6" + # Bluetooth tty BT_TTY ?= "ttymxc1" +# XBee +XBEE_TTY ?= "ttymxc4" + # U-Boot script to be copied to the boot image BOOT_SCRIPTS = "boot.scr:boot.scr" diff --git a/meta-digi-arm/conf/machine/ccimx6ulsbc.conf b/meta-digi-arm/conf/machine/ccimx6ulsbc.conf index 9df9a23d7..f633e8cd8 100644 --- a/meta-digi-arm/conf/machine/ccimx6ulsbc.conf +++ b/meta-digi-arm/conf/machine/ccimx6ulsbc.conf @@ -35,6 +35,9 @@ SERIAL_CONSOLES ?= "115200;ttymxc4" # Bluetooth tty BT_TTY ?= "ttymxc0" +# XBee +XBEE_TTY ?= "ttymxc1" + # U-Boot script to be copied to the boot image BOOT_SCRIPTS = "boot.scr:boot.scr" diff --git a/meta-digi-arm/conf/machine/ccimx8mn-dvk.conf b/meta-digi-arm/conf/machine/ccimx8mn-dvk.conf new file mode 100644 index 000000000..36b6b1197 --- /dev/null +++ b/meta-digi-arm/conf/machine/ccimx8mn-dvk.conf @@ -0,0 +1,36 @@ +#@TYPE: Machine +#@NAME: ConnectCore 8M Nano Development Kit. +#@DESCRIPTION: Machine configuration for Digi's ConnectCore 8M Nano DVK. + +# Include the machine configuration for Digi's ConnectCore 8M Nano module. +include conf/machine/include/ccimx8mn.inc + +# U-Boot configurations +# Last one is the default (the one the symlinks point at) +UBOOT_CONFIG ??= "ccimx8mn_dvk" +UBOOT_CONFIG[ccimx8mn_dvk] = "ccimx8mn_dvk_defconfig,,u-boot-dtb.${UBOOT_SUFFIX}" +SPL_BINARY = "spl/u-boot-spl.bin" + +# Set u-boot DTB +UBOOT_DTB_NAME = "ccimx8mn-dvk.dtb" + +KERNEL_DEVICETREE ?= " \ + digi/ccimx8mn-dvk-wb.dtb \ + digi/ccimx8mn-dvk.dtb \ +" + +SERIAL_CONSOLES ?= "115200;ttymxc0" + +# Bluetooth tty +BT_TTY ?= "ttymxc1" + +# XBees +XBEE_RESET_N_GPIO ?= "508,8" +XBEE_SLEEP_RQ_GPIO ?= "504,7" +XBEE_TTY ?= "ttymxc3" + +# U-Boot script to be copied to the boot image +BOOT_SCRIPTS = "boot.scr:boot.scr" + +# Flash image types +IMAGE_FSTYPES ?= "boot.vfat ext4 sdcard tar.bz2 recovery.vfat" diff --git a/meta-digi-arm/conf/machine/ccimx8x-sbc-express.conf b/meta-digi-arm/conf/machine/ccimx8x-sbc-express.conf index 0d7f05cab..674bf02c7 100644 --- a/meta-digi-arm/conf/machine/ccimx8x-sbc-express.conf +++ b/meta-digi-arm/conf/machine/ccimx8x-sbc-express.conf @@ -5,16 +5,6 @@ # Include the machine configuration for Digi's ConnectCore 8X module. include conf/machine/include/ccimx8x.inc -# Wireless external module -WIRELESS_MODULE_append = " ${@oe.utils.conditional('HAVE_WIFI', '1', 'kernel-module-qualcomm', '', d)}" - -# Wireless p2p interface -WLAN_P2P_INTERFACE ?= "p2p0" - -# Firmware -MACHINE_FIRMWARE_append = " ${@oe.utils.conditional('HAVE_BT', '1', 'firmware-qualcomm-qca6574-bt', '', d)}" -MACHINE_FIRMWARE_append = " ${@oe.utils.conditional('HAVE_WIFI', '1', 'firmware-qualcomm-qca6574-wifi', '', d)}" - # U-Boot configurations # Last one is the default (the one the symlinks point at) UBOOT_CONFIG ??= "ccimx8x_sbc_express2GB ccimx8x_sbc_express1GB" @@ -35,6 +25,7 @@ BT_TTY ?= "ttyLP1" # XBee XBEE_RESET_N_GPIO ?= "397" XBEE_SLEEP_RQ_GPIO ?= "400" +XBEE_TTY ?= "ttyLP0" # U-Boot script to be copied to the boot image BOOT_SCRIPTS = "boot.scr:boot.scr" diff --git a/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf b/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf index 6a5191ad3..76b687507 100644 --- a/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf +++ b/meta-digi-arm/conf/machine/ccimx8x-sbc-pro.conf @@ -5,16 +5,6 @@ # Include the machine configuration for Digi's ConnectCore 8X module. include conf/machine/include/ccimx8x.inc -# Wireless external module -WIRELESS_MODULE_append = " ${@oe.utils.conditional('HAVE_WIFI', '1', 'kernel-module-qualcomm', '', d)}" - -# Wireless p2p interface -WLAN_P2P_INTERFACE ?= "p2p0" - -# Firmware -MACHINE_FIRMWARE_append = " ${@oe.utils.conditional('HAVE_BT', '1', 'firmware-qualcomm-qca6574-bt', '', d)}" -MACHINE_FIRMWARE_append = " ${@oe.utils.conditional('HAVE_WIFI', '1', 'firmware-qualcomm-qca6574-wifi', '', d)}" - # 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" @@ -38,6 +28,7 @@ BT_TTY ?= "ttyLP1" # XBee XBEE_RESET_N_GPIO ?= "220" XBEE_SLEEP_RQ_GPIO ?= "216" +XBEE_TTY ?= "ttyMCA0" # U-Boot script to be copied to the boot image BOOT_SCRIPTS = "boot.scr:boot.scr" diff --git a/meta-digi-arm/conf/machine/include/ccimx6.inc b/meta-digi-arm/conf/machine/include/ccimx6.inc index 0e4240e1a..0a4d41c03 100644 --- a/meta-digi-arm/conf/machine/include/ccimx6.inc +++ b/meta-digi-arm/conf/machine/include/ccimx6.inc @@ -15,6 +15,8 @@ UBOOT_SUFFIX = "imx" # Linux kernel configuration KERNEL_DEFCONFIG ?= "arch/arm/configs/ccimx6sbc_defconfig" +STORAGE_MEDIA = "mmc" + # Wireless external module WIRELESS_MODULE ?= "" @@ -41,3 +43,5 @@ MACHINE_EXTRA_RRECOMMENDS += " \ " MACHINE_FEATURES += "accel-graphics accel-video wifi bluetooth pci" + +SIGN_MODE = "HAB" diff --git a/meta-digi-arm/conf/machine/include/ccimx6ul.inc b/meta-digi-arm/conf/machine/include/ccimx6ul.inc index fda7ce35d..be96b3aba 100644 --- a/meta-digi-arm/conf/machine/include/ccimx6ul.inc +++ b/meta-digi-arm/conf/machine/include/ccimx6ul.inc @@ -12,12 +12,19 @@ include conf/machine/include/tune-cortexa7.inc UBOOT_PREFIX = "u-boot" UBOOT_SUFFIX = "imx" +STORAGE_MEDIA = "mtd" + +# Bluetooth interface +BT_DEVICE_NAME ?= "cc6ul" + # Wireless external module WIRELESS_MODULE ?= "" WIRELESS_MODULE_append = " ${@oe.utils.conditional('HAVE_WIFI', '1', 'kernel-module-qualcomm', '', d)}" +HAS_WIFI_VIRTWLANS = "true" # Wireless p2p interface WLAN_P2P_INTERFACE ?= "p2p0" +WLAN_P2P_DEVICE_NAME ?= "ccimx6ul-p2p" # Firmware MACHINE_FIRMWARE ?= "firmware-imx-sdma" @@ -50,3 +57,5 @@ MKUBIFS_BOOT_ARGS ?= "-m 2048 -e 126976 -c 255" # mkfs.ubifs parameters for rootfs partition # Max LEB count (-c 8191) calculated for a partition of up to 1 GiB considering 128 KiB erase-block size. MKUBIFS_ARGS ?= "-m 2048 -e 126976 -c 8191" + +SIGN_MODE = "HAB" diff --git a/meta-digi-arm/conf/machine/include/ccimx8mn.inc b/meta-digi-arm/conf/machine/include/ccimx8mn.inc new file mode 100644 index 000000000..dc58b519f --- /dev/null +++ b/meta-digi-arm/conf/machine/include/ccimx8mn.inc @@ -0,0 +1,74 @@ +#@TYPE: Machine +#@NAME: ConnectCore 8M Nano module. +#@DESCRIPTION: Machine configuration for Digi's ConnectCore 8M Nano module. + +DIGI_FAMILY = "ccimx8mn" +MACHINEOVERRIDES =. "mx8:mx8m:mx8mn:ccimx8m:${DIGI_FAMILY}:" + +include conf/machine/include/imx-digi-base.inc +include conf/machine/include/arm/arch-arm64.inc + +# Platform u-boot settings +UBOOT_PREFIX = "imx-boot" +UBOOT_SUFFIX = "bin" + +# The bootloader image that gets flashed consists of U-Boot and several fw binaries +EXTRA_IMAGEDEPENDS = "imx-boot" +BOOTLOADER_IMAGE_RECIPE = "imx-boot" +BOOTLOADER_SEEK = "32" +BOOTABLE_FILENAME = "${UBOOT_PREFIX}-${MACHINE}.bin" +SDIMG_BOOTLOADER = "${DEPLOY_DIR_IMAGE}/${BOOTABLE_FILENAME}" + +# Set LPDDR4 FIRMWARE +DDR_FIRMWARE_NAME = "lpddr4_pmu_train_1d_imem.bin lpddr4_pmu_train_1d_dmem.bin lpddr4_pmu_train_2d_imem.bin lpddr4_pmu_train_2d_dmem.bin" + +# Linux kernel configuration +KERNEL_DEFCONFIG ?= "arch/arm64/configs/ccimx8_defconfig" + +STORAGE_MEDIA = "mmc" + +# Bluetooth interface +BT_DEVICE_NAME ?= "cc8mn" + +# Wireless external module +WIRELESS_MODULE ?= "" +WIRELESS_MODULE_append = " ${@oe.utils.conditional('HAVE_WIFI', '1', 'kernel-module-qualcomm', '', d)}" +HAS_WIFI_VIRTWLANS = "true" + +# Wireless p2p interface +WLAN_P2P_INTERFACE ?= "p2p0" +WLAN_P2P_DEVICE_NAME ?= "ccimx8mn-p2p" + +# Firmware +MACHINE_FIRMWARE ?= "firmware-imx-sdma firmware-imx-easrc" +MACHINE_FIRMWARE_append = " ${@oe.utils.conditional('HAVE_BT', '1', 'firmware-qualcomm-qca6564-bt', '', d)}" +MACHINE_FIRMWARE_append = " ${@oe.utils.conditional('HAVE_WIFI', '1', 'firmware-qualcomm-qca6564-wifi', '', d)}" + +MACHINE_EXTRA_RDEPENDS += " \ + e2fsprogs-mke2fs \ + e2fsprogs-resize2fs \ + mca-tool \ + parted \ + u-boot-fw-utils \ + xbee-init \ +" + +MACHINE_EXTRA_RRECOMMENDS += " \ + ${MACHINE_FIRMWARE} \ + ${WIRELESS_MODULE} \ + cryptodev-module \ + cryptoauthlib \ +" + +MACHINE_FEATURES += "accel-graphics accel-video wifi bluetooth cryptochip" + +# AARCH64 doesn't support self-extracting zImage +KERNEL_IMAGETYPE = "Image.gz" + +VIRTUAL-RUNTIME_init_manager ?= "systemd" +VIRTUAL-RUNTIME_initscripts ?= "initscripts" + +# Adding 'wayland' along with 'x11' enables the xwayland backend +# Vulkan is necessary for wayland to build +DISTRO_FEATURES_append = " wayland vulkan systemd pam" +DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit" diff --git a/meta-digi-arm/conf/machine/include/ccimx8x.inc b/meta-digi-arm/conf/machine/include/ccimx8x.inc index 0caea5a08..81a3cddb3 100644 --- a/meta-digi-arm/conf/machine/include/ccimx8x.inc +++ b/meta-digi-arm/conf/machine/include/ccimx8x.inc @@ -27,13 +27,26 @@ SDIMG_BOOTLOADER = "${DEPLOY_DIR_IMAGE}/${BOOTABLE_FILENAME}" RAM_CONFIGS = "1.2GHz_512MB_16bit 1.2GHz_1GB_16bit 1.2GHz_1GB_32bit 1.2GHz_2GB_32bit" # Linux kernel configuration -KERNEL_DEFCONFIG ?= "arch/arm64/configs/ccimx8x_defconfig" +KERNEL_DEFCONFIG ?= "arch/arm64/configs/ccimx8_defconfig" + +STORAGE_MEDIA = "mmc" + +# Bluetooth interface +BT_DEVICE_NAME ?= "cc8x" # Wireless external module WIRELESS_MODULE ?= "" +WIRELESS_MODULE_append = " ${@oe.utils.conditional('HAVE_WIFI', '1', 'kernel-module-qualcomm', '', d)}" +HAS_WIFI_VIRTWLANS = "true" + +# Wireless p2p interface +WLAN_P2P_INTERFACE ?= "p2p0" +WLAN_P2P_DEVICE_NAME ?= "ccimx8x-p2p" # Firmware MACHINE_FIRMWARE ?= "firmware-imx-vpu-imx8 firmware-imx-sdma" +MACHINE_FIRMWARE_append = " ${@oe.utils.conditional('HAVE_BT', '1', 'firmware-qualcomm-qca6574-bt', '', d)}" +MACHINE_FIRMWARE_append = " ${@oe.utils.conditional('HAVE_WIFI', '1', 'firmware-qualcomm-qca6574-wifi', '', d)}" MACHINE_EXTRA_RDEPENDS += " \ e2fsprogs-mke2fs \ @@ -59,6 +72,16 @@ KERNEL_IMAGETYPE = "Image.gz" VIRTUAL-RUNTIME_init_manager ?= "systemd" VIRTUAL-RUNTIME_initscripts ?= "initscripts" +# For i.MX 8 silicon chip revision +MX8_CHIP_REV ?= "B0" +MX8_SOC_VAR ?= "QX" +SIGN_MODE = "AHAB" + +# For Trustfence container header RAM locations +RAM_CONTAINER_LOC_BOOT = "0x80280000" +RAM_CONTAINER_LOC_DTB = "0x82000000" +RAM_CONTAINER_LOC_TF = "0x82100000" + # Adding 'wayland' along with 'x11' enables the xwayland backend # Vulkan is necessary for wayland to build DISTRO_FEATURES_append = " wayland vulkan systemd pam" diff --git a/meta-digi-arm/conf/machine/include/digi-defaults.inc b/meta-digi-arm/conf/machine/include/digi-defaults.inc index 0063dbc43..8e86a5d57 100644 --- a/meta-digi-arm/conf/machine/include/digi-defaults.inc +++ b/meta-digi-arm/conf/machine/include/digi-defaults.inc @@ -12,7 +12,8 @@ PREFERRED_PROVIDER_virtual/xserver = "xserver-xorg" # Platform Linux U-Boot # ------------------------------------------------- # ccimx6ul 4.14, 4.20 2017.03 -# ccimx8x 4.14 2018.03, 2017.03 (both packaged in imx-boot) +# ccimx8x 4.14 2019.04, 2018.03, 2017.03 (all packaged in imx-boot) +# ccimx8mn 4.14 2018.03 (packaged in imx-boot) # # Help variables used in recipes 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 f3474b6e3..1423e092e 100644 --- a/meta-digi-arm/conf/machine/include/imx-digi-base.inc +++ b/meta-digi-arm/conf/machine/include/imx-digi-base.inc @@ -28,6 +28,7 @@ MACHINEOVERRIDES_EXTENDER_mx6q = "imxfbdev:imxipu:imxvpu:imxvpucnm:imxgpu:imxg MACHINEOVERRIDES_EXTENDER_mx6dl = "imxfbdev:imxipu:imxpxp:imxvpu:imxvpucnm:imxgpu:imxgpu2d:imxdpublit:imxgpu3d:imxepdc" MACHINEOVERRIDES_EXTENDER_mx6ul = "imxfbdev:imxpxp" MACHINEOVERRIDES_EXTENDER_mx8qxp = "imxdrm:imxdpu:imxgpu:imxgpu2d:imxgpu3d" +MACHINEOVERRIDES_EXTENDER_mx8mn = "imxdrm:imxgpu:imxgpu3d" # Sub-architecture support MACHINE_SOCARCH_SUFFIX ?= "" @@ -37,16 +38,43 @@ MACHINE_SOCARCH_SUFFIX_mx6ul = "-mx6ul" MACHINE_SOCARCH_SUFFIX_mx8qxp = "-mx8qxp" MACHINE_SOCARCH_SUFFIX_mx8dxp = "-mx8dxp" MACHINE_SOCARCH_SUFFIX_mx8dx = "-mx8dx" +MACHINE_SOCARCH_SUFFIX_mx8mn = "-mx8mn" MACHINE_ARCH_FILTER = "virtual/kernel" -MACHINE_SOCARCH_FILTER_append_imxvpu = " imx-vpu libimxvpuapi imx-codec imx-vpuwrap imx-parser" -MACHINE_SOCARCH_FILTER_append_imxgpu2d = " virtual/libopenvg virtual/libgles1 virtual/libgles2 virtual/egl virtual/mesa virtual/libgl virtual/libg2d cairo pango" -MACHINE_SOCARCH_FILTER_append_imxpxp = " imx-codec imx-parser" +MACHINE_SOCARCH_FILTER_append_imxvpu = " \ + imx-codec \ + imx-vpu \ + imx-vpuwrap \ + libimxvpuapi \ +" +MACHINE_SOCARCH_FILTER_append_imxgpu = " \ + virtual/egl \ + virtual/mesa \ + virtual/libg2d \ + libgal-imx \ + virtual/libopenvg \ + cairo \ + opencv \ + pango \ +" + +MACHINE_SOCARCH_FILTER_append_imxgpu3d = " \ + virtual/libgl \ + virtual/libgles1 \ + virtual/libgles2 \ +" +MACHINE_SOCARCH_FILTER_append_mx6q = " \ + virtual/opencl-icd \ + opencl-headers \ +" MACHINE_SOCARCH_FILTER_append_mx8 = " \ virtual/libopenvx \ virtual/opencl-icd \ opencl-headers \ " +MACHINE_SOCARCH_FILTER_append_imxpxp = " \ + imx-codec \ +" INHERIT += "fsl-dynamic-packagearch" diff --git a/meta-digi-arm/recipes-bsp/alsa-state/alsa-state.bbappend b/meta-digi-arm/recipes-bsp/alsa-state/alsa-state.bbappend index 591606f34..695f9fd07 100644 --- a/meta-digi-arm/recipes-bsp/alsa-state/alsa-state.bbappend +++ b/meta-digi-arm/recipes-bsp/alsa-state/alsa-state.bbappend @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2018 Digi International. +# Copyright (C) 2013-2020 Digi International. FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" @@ -11,8 +11,8 @@ SRC_URI_append_ccimx6 = " \ " SRC_URI_append_ccimx6ul = " file://asound.state" - SRC_URI_append_ccimx8x = " file://asound.state" +SRC_URI_append_ccimx8m = " file://asound.state" do_install_append_ccimx6() { ln -sf asound.micro_play.state ${D}${localstatedir}/lib/alsa/asound.state diff --git a/meta-digi-arm/recipes-bsp/alsa-state/alsa-state/ccimx8mn/asound.conf b/meta-digi-arm/recipes-bsp/alsa-state/alsa-state/ccimx8mn/asound.conf new file mode 100644 index 000000000..11c4cbba0 --- /dev/null +++ b/meta-digi-arm/recipes-bsp/alsa-state/alsa-state/ccimx8mn/asound.conf @@ -0,0 +1,9 @@ +pcm.imxmax98088 { + type hw + card 0 +} +ctl.imxmax98088 { + type hw + card 0 +} +ctl.!default imxmax98088 diff --git a/meta-digi-arm/recipes-bsp/alsa-state/alsa-state/ccimx8mn/asound.state b/meta-digi-arm/recipes-bsp/alsa-state/alsa-state/ccimx8mn/asound.state new file mode 100644 index 000000000..07076e3ac --- /dev/null +++ b/meta-digi-arm/recipes-bsp/alsa-state/alsa-state/ccimx8mn/asound.state @@ -0,0 +1,1148 @@ +state.imxmax98088 { + control.1 { + iface MIXER + name 'Headphone Volume' + value.0 18 + value.1 18 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 31' + dbmin -6700 + dbmax 300 + dbvalue.0 -1100 + dbvalue.1 -1100 + } + } + control.2 { + iface MIXER + name 'Speaker Volume' + value.0 16 + value.1 16 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 31' + dbmin -6200 + dbmax 800 + dbvalue.0 -1000 + dbvalue.1 -1000 + } + } + control.3 { + iface MIXER + name 'Receiver Volume' + value.0 16 + value.1 16 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 31' + dbmin -6200 + dbmax 800 + dbvalue.0 -1000 + dbvalue.1 -1000 + } + } + control.4 { + iface MIXER + name 'Headphone Switch' + value.0 true + value.1 true + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.5 { + iface MIXER + name 'Speaker Switch' + value.0 true + value.1 true + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.6 { + iface MIXER + name 'Receiver Switch' + value.0 true + value.1 true + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.7 { + iface MIXER + name 'MIC1 Volume' + value 0 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 31' + } + } + control.8 { + iface MIXER + name 'MIC2 Volume' + value 15 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 31' + } + } + control.9 { + iface MIXER + name 'MIC1 Boost Volume' + value 0 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 2' + dbmin 0 + dbmax 3000 + dbvalue.0 0 + } + } + control.10 { + iface MIXER + name 'MIC2 Boost Volume' + value 1 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 2' + dbmin 0 + dbmax 3000 + dbvalue.0 2000 + } + } + control.11 { + iface MIXER + name 'INA Volume' + value 4 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 7' + } + } + control.12 { + iface MIXER + name 'INB Volume' + value 4 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 7' + } + } + control.13 { + iface MIXER + name 'ADCL Volume' + value 0 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 15' + } + } + control.14 { + iface MIXER + name 'ADCR Volume' + value 0 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 15' + } + } + control.15 { + iface MIXER + name 'ADCL Boost Volume' + value 0 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 3' + } + } + control.16 { + iface MIXER + name 'ADCR Boost Volume' + value 0 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 3' + } + } + control.17 { + iface MIXER + name 'EQ1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.18 { + iface MIXER + name 'EQ2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.19 { + iface MIXER + name 'EX Limiter Mode' + value Off + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 Off + item.1 '100Hz' + item.2 '400Hz' + item.3 '600Hz' + item.4 '800Hz' + item.5 '1000Hz' + item.6 '200-400Hz' + item.7 '400-600Hz' + item.8 '400-800Hz' + } + } + control.20 { + iface MIXER + name 'EX Limiter Threshold' + value '0.6' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 '0.6' + item.1 '1.2' + item.2 '1.8' + item.3 '2.4' + item.4 '3.0' + item.5 '3.6' + item.6 '4.2' + item.7 '4.8' + } + } + control.21 { + iface MIXER + name 'DAI1 Filter Mode' + value Music + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 Voice + item.1 Music + } + } + control.22 { + iface MIXER + name 'DAI1 DAC Filter' + value Off + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 Off + item.1 'fc=258/fs=16k' + item.2 'fc=500/fs=16k' + item.3 'fc=258/fs=8k' + item.4 'fc=500/fs=8k' + item.5 'fc=200' + } + } + control.23 { + iface MIXER + name 'DAI1 ADC Filter' + value Off + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 Off + item.1 'fc=258/fs=16k' + item.2 'fc=500/fs=16k' + item.3 'fc=258/fs=8k' + item.4 'fc=500/fs=8k' + item.5 'fc=200' + } + } + control.24 { + iface MIXER + name 'DAI2 DC Block Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.25 { + iface MIXER + name 'ALC Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.26 { + iface MIXER + name 'ALC Threshold' + value 0 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 7' + } + } + control.27 { + iface MIXER + name 'ALC Multiband' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.28 { + iface MIXER + name 'ALC Release Time' + value 0 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 7' + } + } + control.29 { + iface MIXER + name 'PWR Limiter Threshold' + value 0 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 15' + } + } + control.30 { + iface MIXER + name 'PWR Limiter Weight' + value 0 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 7' + } + } + control.31 { + iface MIXER + name 'PWR Limiter Time1' + value 0 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 15' + } + } + control.32 { + iface MIXER + name 'PWR Limiter Time2' + value 0 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 15' + } + } + control.33 { + iface MIXER + name 'THD Limiter Threshold' + value 0 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 15' + } + } + control.34 { + iface MIXER + name 'THD Limiter Time' + value 0 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 7' + } + } + control.35 { + iface MIXER + name 'REC Output Mode' + value true + comment { + access 'read write' + type BOOLEAN + 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 + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.99 { + iface MIXER + name 'Left HP Mixer Right DAC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.100 { + iface MIXER + name 'Left HP Mixer Left DAC2 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.101 { + iface MIXER + name 'Left HP Mixer Right DAC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.102 { + iface MIXER + name 'Left HP Mixer MIC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.103 { + iface MIXER + name 'Left HP Mixer MIC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.104 { + iface MIXER + name 'Left HP Mixer INA1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.105 { + iface MIXER + name 'Left HP Mixer INA2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.106 { + iface MIXER + name 'Left HP Mixer INB1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.107 { + iface MIXER + name 'Left HP 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.2.5.bb b/meta-digi-arm/recipes-bsp/digi-sc-firmware/digi-sc-firmware_1.3.0.1.bb similarity index 84% rename from meta-digi-arm/recipes-bsp/digi-sc-firmware/digi-sc-firmware_1.2.5.bb rename to meta-digi-arm/recipes-bsp/digi-sc-firmware/digi-sc-firmware_1.3.0.1.bb index e496ee6d0..721d0c8cf 100644 --- a/meta-digi-arm/recipes-bsp/digi-sc-firmware/digi-sc-firmware_1.2.5.bb +++ b/meta-digi-arm/recipes-bsp/digi-sc-firmware/digi-sc-firmware_1.3.0.1.bb @@ -4,15 +4,15 @@ DESCRIPTION = "i.MX System Controller Firmware, customized for Digi platforms" LICENSE = "Proprietary" -LIC_FILES_CHKSUM = "file://COPYING;md5=72c0f70181bb6e83eee6aab8de12a9f3" +LIC_FILES_CHKSUM = "file://COPYING;md5=6c12031a11b81db21cdfe0be88cac4b3" SECTION = "BSP" inherit pkgconfig deploy SRC_URI = "${DIGI_PKG_SRC}/${PN}-${PV}.tar.gz" -SRC_URI[md5sum] = "4a1a7a99cda9e55388d1c491011853c6" -SRC_URI[sha256sum] = "852cdd37d37905b08cfdc4b753ce33b7364749065bac91d78cc2292481e6d6a7" +SRC_URI[md5sum] = "29c2ab80f539dd285a8d99a23d616d3e" +SRC_URI[sha256sum] = "cb3f90c07e7ba547a8c467012bef23083a8e8c414c4a90e1b88c5a70dd7ece19" S = "${WORKDIR}/${PN}-${PV}" diff --git a/meta-digi-arm/recipes-bsp/firmware-imx/firmware-imx_8.3.bb b/meta-digi-arm/recipes-bsp/firmware-imx/firmware-imx_8.4.1.bb similarity index 78% rename from meta-digi-arm/recipes-bsp/firmware-imx/firmware-imx_8.3.bb rename to meta-digi-arm/recipes-bsp/firmware-imx/firmware-imx_8.4.1.bb index 599efb4df..f9f044f8a 100644 --- a/meta-digi-arm/recipes-bsp/firmware-imx/firmware-imx_8.3.bb +++ b/meta-digi-arm/recipes-bsp/firmware-imx/firmware-imx_8.4.1.bb @@ -6,14 +6,14 @@ SUMMARY = "Freescale IMX firmware" DESCRIPTION = "Freescale IMX firmware such as for the VPU" SECTION = "base" LICENSE = "Proprietary" -LIC_FILES_CHKSUM = "file://COPYING;md5=72c0f70181bb6e83eee6aab8de12a9f3" +LIC_FILES_CHKSUM = "file://COPYING;md5=fd4b227530cd88a82af6a5982cfb724d" PE = "1" SRC_URI = "${FSL_MIRROR}/firmware-imx-${PV}.bin;fsl-eula=true " -SRC_URI[md5sum] = "776c7fa64a6e96d9f0d9cd50bbf79ffc" -SRC_URI[sha256sum] = "48e4b9e4064930e2b6cd7f20f39177c8f4c5ef1a296f2ebc6ed422412ab56681" +SRC_URI[md5sum] = "70bdefdd7fb58f782237acf4c648f5cd" +SRC_URI[sha256sum] = "f04b2deb4f126e6b6cd4460462292acd72183b9f799e3b873fb390ff0f18eb55" inherit fsl-eula-unpack allarch @@ -61,26 +61,12 @@ inherit deploy addtask deploy before do_build after do_install do_deploy () { # Deploy i.MX8 related firmware files - if [ "${IS_MX8}" = "8m" ]; then - # Deploy ddr/synopsys - for ddr_firmware in ${DDR_FIRMWARE_NAME}; do - install -m 0644 ${S}/firmware/ddr/synopsys/${ddr_firmware} ${DEPLOYDIR} - done - - # Deploy hdmi/cadence - install -m 0644 ${S}/firmware/hdmi/cadence/signed_dp_imx8m.bin ${DEPLOYDIR} - install -m 0644 ${S}/firmware/hdmi/cadence/signed_hdmi_imx8m.bin ${DEPLOYDIR} - elif [ "${IS_MX8}" = "8qm" ]; then + if [ "${IS_MX8}" = "8qm" ]; then # Deploy hdmi/cadence install -m 0644 ${S}/firmware/hdmi/cadence/hdmitxfw.bin ${DEPLOYDIR} install -m 0644 ${S}/firmware/hdmi/cadence/hdmirxfw.bin ${DEPLOYDIR} install -m 0644 ${S}/firmware/hdmi/cadence/dpfw.bin ${DEPLOYDIR} - # Deploy seco - install -m 0644 ${S}/firmware/seco/mx8qm-ahab-container.img ${DEPLOYDIR} - elif [ "${IS_MX8}" = "8qx" ]; then - # Deploy seco - install -m 0644 ${S}/firmware/seco/mx8qx-ahab-container.img ${DEPLOYDIR} fi } 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 73101f768..1e5c5c4d0 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-2018 Digi International. +# Copyright (C) 2016-2020 Digi International. SUMMARY = "Qualcomm firmware files for Digi's platforms." SECTION = "base" @@ -10,42 +10,42 @@ QUALCOMM_WIFI_DRIVER ?= "proprietary" # Bluetooth firmware files FW_QUALCOMM_BT = " \ - file://${QCA_MODEL}_bt/nvm_tlv_3.2.bin \ - file://${QCA_MODEL}_bt/rampatch_tlv_3.2.tlv \ + file://qca65X4_bt/nvm_tlv_3.2.bin \ + file://qca65X4_bt/rampatch_tlv_3.2.tlv \ " # Firmware files for QCA6564 (Qualcomm proprietary driver) -FW_QCA6564_WIFI_PROPRIETARY = " \ +FW_QCA65X4_SDIO_PROPRIETARY = " \ file://bdwlan30_US.bin \ file://LICENCE.atheros_firmware \ - file://qca6564_proprietary/otp30.bin \ - file://qca6564_proprietary/qwlan30.bin \ - file://qca6564_proprietary/utf30.bin \ + file://qca65X4_sdio_proprietary/otp30.bin \ + file://qca65X4_sdio_proprietary/qwlan30.bin \ + file://qca65X4_sdio_proprietary/utf30.bin \ " # Firmware files for QCA6574 (Qualcomm proprietary driver) -FW_QCA6574_WIFI_PROPRIETARY = " \ +FW_QCA65X4_PCIE_PROPRIETARY = " \ + file://bdwlan30_US.bin \ file://LICENCE.atheros_firmware \ - file://qca6574_proprietary/qwlan30.bin \ - file://qca6574_proprietary/fakeboar_US.bin \ - file://qca6574_proprietary/otp.bin \ - file://qca6574_proprietary/utf.bin \ + file://qca65X4_pcie_proprietary/otp30.bin \ + file://qca65X4_pcie_proprietary/qwlan30.bin \ + file://qca65X4_pcie_proprietary/utf30.bin \ " # Firmware files for QCA6574 (Qualcomm community driver) # NOTE: the community file 'board.bin' must be substituted by proprietary -# 'fakeboar_US.bin' +# 'bdwlan30_US.bin' FW_QCA6574_WIFI_COMMUNITY = " \ + file://bdwlan30_US.bin \ file://qca6574_community/board-2.bin \ file://qca6574_community/firmware-4.bin \ file://qca6574_community/firmware-6.bin \ file://qca6574_community/notice_ath10k_firmware-4.txt \ file://qca6574_community/notice_ath10k_firmware-6.txt \ - file://qca6574_proprietary/fakeboar_US.bin \ " -FW_QUALCOMM_WIFI ?= "${FW_QCA6564_WIFI_PROPRIETARY}" -FW_QUALCOMM_WIFI_ccimx8x = "${@oe.utils.conditional('QUALCOMM_WIFI_DRIVER', 'community', '${FW_QCA6574_WIFI_COMMUNITY}', '${FW_QCA6574_WIFI_PROPRIETARY}', d)}" +FW_QUALCOMM_WIFI ?= "${FW_QCA65X4_SDIO_PROPRIETARY}" +FW_QUALCOMM_WIFI_ccimx8x = "${@oe.utils.conditional('QUALCOMM_WIFI_DRIVER', 'community', '${FW_QCA6574_WIFI_COMMUNITY}', '${FW_QCA65X4_PCIE_PROPRIETARY}', d)}" SRC_URI = " \ ${FW_QUALCOMM_BT} \ @@ -72,14 +72,24 @@ do_install() { install -m 0644 ${FW_WIFI_FILES} ${D}${WIFI_FW_PATH} if [ "${QUALCOMM_WIFI_DRIVER}" = "community" ]; then # If using community driver, create symlink 'board.bin' to - # proprietary 'fakeboar_US.bin' - ln -s fakeboar_US.bin ${D}${WIFI_FW_PATH}/board.bin + # proprietary 'bdwlan30_US.bin' + ln -s bdwlan30_US.bin ${D}${WIFI_FW_PATH}/board.bin else - if [ "${FW_QUALCOMM_WIFI}" = "${FW_QCA6574_WIFI_PROPRIETARY}" ]; then + if [ "${FW_QUALCOMM_WIFI}" = "${FW_QCA65X4_PCIE_PROPRIETARY}" ]; then ln -s qwlan30.bin ${D}${WIFI_FW_PATH}/athwlan.bin - ln -s otp.bin ${D}${WIFI_FW_PATH}/athsetup.bin + ln -s otp30.bin ${D}${WIFI_FW_PATH}/athsetup.bin fi fi + + # Disable IBS over H4 for all the platforms in the bluetooth firmware + printf \"\\x02\" | dd of="${D}${base_libdir}/firmware/qca/nvm_tlv_3.2.bin" bs=1 seek=54 count=1 conv=notrunc,fsync +} + +do_install_append_ccimx6ul() { + # Disable DEEP SLEEP in the bluetooth firmware + printf \"\\x00\" | dd of="${D}${base_libdir}/firmware/qca/nvm_tlv_3.2.bin" bs=1 seek=74 count=1 conv=notrunc,fsync + # Enable Internal Clock in the bluetooth firmware + printf \"\\x01\\x00\" | dd of="${D}${base_libdir}/firmware/qca/nvm_tlv_3.2.bin" bs=1 seek=93 count=2 conv=notrunc,fsync } QCA_MODEL ?= "qca6564" @@ -92,4 +102,4 @@ FILES_${PN}-${QCA_MODEL}-bt = "/lib/firmware/qca" FILES_${PN}-${QCA_MODEL}-wifi = "/lib/firmware" PACKAGE_ARCH = "${MACHINE_ARCH}" -COMPATIBLE_MACHINE = "(ccimx6qpsbc|ccimx6ul|ccimx8x)" +COMPATIBLE_MACHINE = "(ccimx6qpsbc|ccimx6ul|ccimx8x|ccimx8m)" diff --git a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/ccimx6ul/bdwlan30_US.bin b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/ccimx6ul/bdwlan30_US.bin index e923f41b6..d3ad01bb6 100644 Binary files a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/ccimx6ul/bdwlan30_US.bin and b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/ccimx6ul/bdwlan30_US.bin differ diff --git a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/ccimx8mn/bdwlan30_US.bin b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/ccimx8mn/bdwlan30_US.bin new file mode 100644 index 000000000..b5b763136 Binary files /dev/null and b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/ccimx8mn/bdwlan30_US.bin differ diff --git a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6574_proprietary/fakeboar_US.bin b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/ccimx8x/bdwlan30_US.bin similarity index 100% rename from meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6574_proprietary/fakeboar_US.bin rename to meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/ccimx8x/bdwlan30_US.bin diff --git a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6564_bt/nvm_tlv_3.2.bin b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6564_bt/nvm_tlv_3.2.bin deleted file mode 100644 index 2715082de..000000000 Binary files a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6564_bt/nvm_tlv_3.2.bin and /dev/null differ diff --git a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6564_bt/rampatch_tlv_3.2.tlv b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6564_bt/rampatch_tlv_3.2.tlv deleted file mode 100644 index def7cc30a..000000000 Binary files a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6564_bt/rampatch_tlv_3.2.tlv and /dev/null differ diff --git a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6574_bt/nvm_tlv_3.2.bin b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca65X4_bt/nvm_tlv_3.2.bin similarity index 96% rename from meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6574_bt/nvm_tlv_3.2.bin rename to meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca65X4_bt/nvm_tlv_3.2.bin index 6d531b2f0..5228c7196 100644 Binary files a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6574_bt/nvm_tlv_3.2.bin and b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca65X4_bt/nvm_tlv_3.2.bin differ diff --git a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6574_bt/rampatch_tlv_3.2.tlv b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca65X4_bt/rampatch_tlv_3.2.tlv similarity index 100% rename from meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6574_bt/rampatch_tlv_3.2.tlv rename to meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca65X4_bt/rampatch_tlv_3.2.tlv diff --git a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6574_proprietary/otp.bin b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca65X4_pcie_proprietary/otp30.bin old mode 100644 new mode 100755 similarity index 100% rename from meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6574_proprietary/otp.bin rename to meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca65X4_pcie_proprietary/otp30.bin diff --git a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6574_proprietary/qwlan30.bin b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca65X4_pcie_proprietary/qwlan30.bin similarity index 68% rename from meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6574_proprietary/qwlan30.bin rename to meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca65X4_pcie_proprietary/qwlan30.bin index 10c20eac4..7431c0001 100644 Binary files a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6574_proprietary/qwlan30.bin and b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca65X4_pcie_proprietary/qwlan30.bin differ diff --git a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6574_proprietary/utf.bin b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca65X4_pcie_proprietary/utf30.bin old mode 100644 new mode 100755 similarity index 77% rename from meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6574_proprietary/utf.bin rename to meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca65X4_pcie_proprietary/utf30.bin index 768150396..115fee910 Binary files a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6574_proprietary/utf.bin and b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca65X4_pcie_proprietary/utf30.bin differ diff --git a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6564_proprietary/otp30.bin b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca65X4_sdio_proprietary/otp30.bin similarity index 100% rename from meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6564_proprietary/otp30.bin rename to meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca65X4_sdio_proprietary/otp30.bin diff --git a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6564_proprietary/qwlan30.bin b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca65X4_sdio_proprietary/qwlan30.bin similarity index 56% rename from meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6564_proprietary/qwlan30.bin rename to meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca65X4_sdio_proprietary/qwlan30.bin index 6d7e653b1..2924a342f 100644 Binary files a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6564_proprietary/qwlan30.bin and b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca65X4_sdio_proprietary/qwlan30.bin differ diff --git a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6564_proprietary/utf30.bin b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca65X4_sdio_proprietary/utf30.bin old mode 100644 new mode 100755 similarity index 61% rename from meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6564_proprietary/utf30.bin rename to meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca65X4_sdio_proprietary/utf30.bin index 7f9f6589e..613a9470f Binary files a/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca6564_proprietary/utf30.bin and b/meta-digi-arm/recipes-bsp/firmware-qualcomm/firmware-qualcomm/qca65X4_sdio_proprietary/utf30.bin differ diff --git a/meta-digi-arm/recipes-bsp/imx-atf/imx-atf/0001-imx8mn-Disable-M7-debug-console.patch b/meta-digi-arm/recipes-bsp/imx-atf/imx-atf/0001-imx8mn-Disable-M7-debug-console.patch new file mode 100644 index 000000000..c492f8758 --- /dev/null +++ b/meta-digi-arm/recipes-bsp/imx-atf/imx-atf/0001-imx8mn-Disable-M7-debug-console.patch @@ -0,0 +1,32 @@ +From: Arturo Buzarra +Date: Fri, 27 Dec 2019 09:42:48 +0100 +Subject: [PATCH] imx8mn: Disable M7 debug console + +The Cortex-M7 uses the UART4 as debug console, and it is +shared with the Cortex-A53. + +Signed-off-by: Arturo Buzarra +--- + plat/imx/imx8mn/imx8mn_bl31_setup.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/plat/imx/imx8mn/imx8mn_bl31_setup.c b/plat/imx/imx8mn/imx8mn_bl31_setup.c +index 57db28a..a36c2d5 100644 +--- a/plat/imx/imx8mn/imx8mn_bl31_setup.c ++++ b/plat/imx/imx8mn/imx8mn_bl31_setup.c +@@ -242,11 +242,12 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, + #endif + bl31_tzc380_setup(); + + /* Assign M7 to domain 1 */ + mmio_write_32(IMX_RDC_BASE + 0x204, 0x1); +- mmio_write_32(IMX_RDC_BASE + 0x518, 0xfc); ++ /* Uncomment to use the M7 debug console (shared with A53 UART4) */ ++ /*mmio_write_32(IMX_RDC_BASE + 0x518, 0xfc);*/ + mmio_write_32(IMX_RDC_BASE + 0x5A4, 0xf3); + } + + void bl31_plat_arch_setup(void) + { +-- + diff --git a/meta-digi-arm/recipes-bsp/imx-atf/imx-atf_2.0.bb b/meta-digi-arm/recipes-bsp/imx-atf/imx-atf_2.0.bb index 12cd3096f..b1c84b70c 100644 --- a/meta-digi-arm/recipes-bsp/imx-atf/imx-atf_2.0.bb +++ b/meta-digi-arm/recipes-bsp/imx-atf/imx-atf_2.0.bb @@ -10,10 +10,12 @@ inherit fsl-eula-unpack pkgconfig deploy PV = "2.0+git${SRCPV}" ATF_SRC ?= "git://source.codeaurora.org/external/imx/imx-atf.git;protocol=https" -SRCBRANCH = "imx_4.14.98_2.1.0" +SRCBRANCH = "imx_4.14.98_2.3.0" SRC_URI = "${ATF_SRC};branch=${SRCBRANCH}" -SRCREV = "727cf896a4c79d152dae4537e28400c747bf39b9" +SRCREV = "09c5cc994634060ad7dfef4620866838d19694a4" + +SRC_URI_append_ccimx8mn = " file://0001-imx8mn-Disable-M7-debug-console.patch" S = "${WORKDIR}/git" diff --git a/meta-digi-arm/recipes-bsp/imx-mkimage/imx-boot/0001-iMX8QX-remove-SC_BD_FLAGS_ALT_CONFIG-flag-in-flash_r.patch b/meta-digi-arm/recipes-bsp/imx-mkimage/imx-boot/0001-iMX8QX-remove-SC_BD_FLAGS_ALT_CONFIG-flag-in-flash_r.patch index d5467c928..6487ea4ca 100644 --- a/meta-digi-arm/recipes-bsp/imx-mkimage/imx-boot/0001-iMX8QX-remove-SC_BD_FLAGS_ALT_CONFIG-flag-in-flash_r.patch +++ b/meta-digi-arm/recipes-bsp/imx-mkimage/imx-boot/0001-iMX8QX-remove-SC_BD_FLAGS_ALT_CONFIG-flag-in-flash_r.patch @@ -17,15 +17,15 @@ Signed-off-by: Gabriel Valcazar 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iMX8QX/soc.mak b/iMX8QX/soc.mak -index 3c8e7b1..f06ece8 100755 +index e08cf3c..88f990a 100755 --- a/iMX8QX/soc.mak +++ b/iMX8QX/soc.mak -@@ -114,7 +114,7 @@ flash_linux_m4_xip: $(MKIMG) mx8qx-ahab-container.img scfw_tcm.bin u-boot-atf-co +@@ -120,7 +120,7 @@ flash_linux_m4_xip: $(MKIMG) $(AHAB_IMG) scfw_tcm.bin u-boot-atf-container.img m ./$(QSPI_PACKER) $(QSPI_HEADER) - flash_regression_linux_m4: $(MKIMG) mx8qx-ahab-container.img scfw_tcm.bin u-boot-atf.bin m4_image.bin -- ./$(MKIMG) -soc QX -rev B0 -append mx8qx-ahab-container.img -c -flags 0x00200000 -scfw scfw_tcm.bin -ap u-boot-atf.bin a35 0x80000000 -p3 -m4 m4_image.bin 0 0x34FE0000 -out flash.bin -+ ./$(MKIMG) -soc QX -rev B0 -append mx8qx-ahab-container.img -c -scfw scfw_tcm.bin -ap u-boot-atf.bin a35 0x80000000 -m4 m4_image.bin 0 0x34FE0000 -out flash.bin + flash_regression_linux_m4: $(MKIMG) $(AHAB_IMG) scfw_tcm.bin u-boot-atf.bin m4_image.bin +- ./$(MKIMG) -soc QX -rev B0 -append $(AHAB_IMG) -c -flags 0x00200000 -scfw scfw_tcm.bin -ap u-boot-atf.bin a35 0x80000000 -p3 -m4 m4_image.bin 0 0x34FE0000 -out flash.bin ++ ./$(MKIMG) -soc QX -rev B0 -append $(AHAB_IMG) -c -scfw scfw_tcm.bin -ap u-boot-atf.bin a35 0x80000000 -m4 m4_image.bin 0 0x34FE0000 -out flash.bin - flash_regression_linux_m4_ddr: $(MKIMG) mx8qx-ahab-container.img scfw_tcm.bin u-boot-atf.bin m4_image.bin - ./$(MKIMG) -soc QX -rev B0 -append mx8qx-ahab-container.img -c -flags 0x00200000 -scfw scfw_tcm.bin -ap u-boot-atf.bin a35 0x80000000 -p3 -m4 m4_image.bin 0 0x88000000 -out flash.bin + flash_regression_linux_m4_ddr: $(MKIMG) $(AHAB_IMG) scfw_tcm.bin u-boot-atf.bin m4_image.bin + ./$(MKIMG) -soc QX -rev B0 -append $(AHAB_IMG) -c -flags 0x00200000 -scfw scfw_tcm.bin -ap u-boot-atf.bin a35 0x80000000 -p3 -m4 m4_image.bin 0 0x88000000 -out flash.bin diff --git a/meta-digi-arm/recipes-bsp/imx-mkimage/imx-boot_0.2.bbappend b/meta-digi-arm/recipes-bsp/imx-mkimage/imx-boot_0.2.bbappend index d308ac393..ab0299104 100644 --- a/meta-digi-arm/recipes-bsp/imx-mkimage/imx-boot_0.2.bbappend +++ b/meta-digi-arm/recipes-bsp/imx-mkimage/imx-boot_0.2.bbappend @@ -1,22 +1,25 @@ -# Copyright 2019 Digi International, Inc. +# Copyright 2019,2020 Digi International, Inc. inherit boot-artifacts # Use the v4.14 latest BSP branch -SRCBRANCH = "imx_4.14.98_2.1.0" -SRCREV = "abd6ce551a7b81fc6953d32d92b24a4a1d4b214e" +SRCBRANCH = "imx_4.14.98_2.3.0" +SRCREV = "2556000499f667123094af22326cfd8e4cbadaac" FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" SRC_URI_append_ccimx8x = " file://0001-iMX8QX-remove-SC_BD_FLAGS_ALT_CONFIG-flag-in-flash_r.patch" -IMX_EXTRA_FIRMWARE_ccimx8x = "digi-sc-firmware" +IMX_EXTRA_FIRMWARE_ccimx8x = "digi-sc-firmware imx-seco" DEPENDS_append_ccimx8x = " coreutils-native" +DEPENDS_append_ccimx8x += "${@oe.utils.conditional('TRUSTFENCE_SIGN', '1', 'trustfence-sign-tools-native', '', d)}" # For i.MX 8, this package aggregates the imx-m4-demos # output. Note that this aggregation replaces the aggregation # that would otherwise be done in the image build as controlled # by IMAGE_BOOTFILES_DEPENDS and IMAGE_BOOTFILES in image_types_fsl.bbclass -IMX_M4_DEMOS = "imx-m4-demos" +IMX_M4_DEMOS = "" +IMX_M4_DEMOS_mx8qm = "imx-m4-demos" +IMX_M4_DEMOS_mx8qxp = "imx-m4-demos" # This package aggregates output deployed by other packages, # so set the appropriate dependencies @@ -35,15 +38,29 @@ do_populate_lic[depends] += " \ firmware-imx:do_populate_lic \ " ATF_MACHINE_NAME_mx8qxp = "bl31-imx8qx.bin" +ATF_MACHINE_NAME_mx8mn = "bl31-imx8mn.bin" + +SECO_FIRMWARE ?= "" +SECO_FIRMWARE_mx8qm = "mx8qmb0-ahab-container.img" +SECO_FIRMWARE_mx8qxp = "mx8qxb0-ahab-container.img" +# i.MX8QXP C0 support +#SECO_FIRMWARE_mx8qxp = "mx8qxc0-ahab-container.img" + +# 8MQ/8MM/8MN share the same soc folder +BOOT_STAGING_mx8mn = "${S}/iMX8M" + +SOC_TARGET_mx8mn = "iMX8MN" IMXBOOT_TARGETS_ccimx8x = "${@bb.utils.contains('UBOOT_CONFIG', 'fspi', 'flash_flexspi', \ 'flash flash_regression_linux_m4', d)}" -do_compile () { +IMXBOOT_TARGETS_ccimx8mn = "${@bb.utils.contains('UBOOT_CONFIG', 'fspi', 'flash_evk_flexspi', 'flash_spl_uboot', d)}" + +compile_mx8x() { bbnote 8QX boot binary build - cp ${DEPLOY_DIR_IMAGE}/imx8qx_m4_TCM_srtm_demo.bin ${BOOT_STAGING}/m40_tcm.bin - cp ${DEPLOY_DIR_IMAGE}/imx8qx_m4_TCM_srtm_demo.bin ${BOOT_STAGING}/m4_image.bin - cp ${DEPLOY_DIR_IMAGE}/mx8qx-ahab-container.img ${BOOT_STAGING}/ + cp ${DEPLOY_DIR_IMAGE}/imx8qx_m4_TCM_power_mode_switch.bin ${BOOT_STAGING}/m40_tcm.bin + cp ${DEPLOY_DIR_IMAGE}/imx8qx_m4_TCM_power_mode_switch.bin ${BOOT_STAGING}/m4_image.bin + cp ${DEPLOY_DIR_IMAGE}/${SECO_FIRMWARE} ${BOOT_STAGING}/ cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/${ATF_MACHINE_NAME} ${BOOT_STAGING}/bl31.bin for type in ${UBOOT_CONFIG}; do cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/u-boot-${type}.bin ${BOOT_STAGING}/ @@ -51,63 +68,105 @@ do_compile () { for ramc in ${RAM_CONFIGS}; do cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/${SC_FIRMWARE_NAME}-${ramc} ${BOOT_STAGING}/ done +} +compile_mx8m() { + bbnote 8MQ/8MM/8MN boot binary build + cp ${DEPLOY_DIR_IMAGE}/signed_*_imx8m.bin ${BOOT_STAGING} + cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG} ${BOOT_STAGING}/u-boot-spl.bin + cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/${UBOOT_DTB_NAME} ${BOOT_STAGING}/fsl-imx8mn-evk.dtb + cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/u-boot-nodtb.bin-${MACHINE}-${UBOOT_CONFIG} ${BOOT_STAGING}/u-boot-nodtb.bin + + cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/mkimage_uboot ${BOOT_STAGING}/ + cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/${ATF_MACHINE_NAME} ${BOOT_STAGING}/bl31.bin + + for ddr_firmware in ${DDR_FIRMWARE_NAME}; do + cp ${DEPLOY_DIR_IMAGE}/${ddr_firmware} ${BOOT_STAGING} + done +} + +do_compile () { + compile_${SOC_FAMILY} # mkimage for i.MX8 for type in ${UBOOT_CONFIG}; do - RAM_SIZE="$(echo ${type} | sed -e 's,.*[a-z]\+\([0-9]\+[M|G]B\)$,\1,g')" - for ramc in ${RAM_CONFIGS}; do - if echo "${ramc}" | grep -qs "${RAM_SIZE}"; then - # Match U-Boot memory size and and SCFW memory configuration - cd ${BOOT_STAGING} - ln -sf u-boot-${type}.bin u-boot.bin - ln -sf ${SC_FIRMWARE_NAME}-${ramc} scfw_tcm.bin - cd - - for target in ${IMXBOOT_TARGETS}; do - bbnote "building ${SOC_TARGET} - ${ramc} - ${target}" - make SOC=${SOC_TARGET} ${target} - if [ -e "${BOOT_STAGING}/flash.bin" ]; then - cp ${BOOT_STAGING}/flash.bin ${S}/${UBOOT_PREFIX}-${MACHINE}-${ramc}.bin-${target} - fi - SCFWBUILT="yes" - done - rm ${BOOT_STAGING}/scfw_tcm.bin - rm ${BOOT_STAGING}/u-boot.bin - # Remove u-boot-atf.bin and u-boot-hash.bin so they get generated with the next iteration's U-Boot - rm ${BOOT_STAGING}/u-boot-atf.bin - rm ${BOOT_STAGING}/u-boot-hash.bin + if [ "${SOC_TARGET}" = "iMX8QX" ]; then + RAM_SIZE="$(echo ${type} | sed -e 's,.*[a-z]\+\([0-9]\+[M|G]B\)$,\1,g')" + for ramc in ${RAM_CONFIGS}; do + if echo "${ramc}" | grep -qs "${RAM_SIZE}"; then + # Match U-Boot memory size and and SCFW memory configuration + cd ${BOOT_STAGING} + ln -sf u-boot-${type}.bin u-boot.bin + ln -sf ${SC_FIRMWARE_NAME}-${ramc} scfw_tcm.bin + cd - + for target in ${IMXBOOT_TARGETS}; do + bbnote "building ${SOC_TARGET} - ${ramc} - ${target}" + make SOC=${SOC_TARGET} ${target} + # i.MX8QXP C0 support + #make SOC=${SOC_TARGET} REV=C0 ${target} + if [ -e "${BOOT_STAGING}/flash.bin" ]; then + cp ${BOOT_STAGING}/flash.bin ${S}/${UBOOT_PREFIX}-${MACHINE}-${ramc}.bin-${target} + fi + SCFWBUILT="yes" + done + rm ${BOOT_STAGING}/scfw_tcm.bin + rm ${BOOT_STAGING}/u-boot.bin + # Remove u-boot-atf.bin and u-boot-hash.bin so they get generated with the next iteration's U-Boot + rm ${BOOT_STAGING}/u-boot-atf.bin + rm ${BOOT_STAGING}/u-boot-hash.bin + fi + done + else + # mkimage for i.MX8M + for target in ${IMXBOOT_TARGETS}; do + bbnote "building ${SOC_TARGET} - ${target}" + make SOC=${SOC_TARGET} ${target} + if [ -e "${BOOT_STAGING}/flash.bin" ]; then + cp ${BOOT_STAGING}/flash.bin ${S}/${UBOOT_PREFIX}-${MACHINE}.bin-${target} fi - done + done + fi done # Check that SCFW was built at least once - if [ "${SCFWBUILT}" != "yes" ]; then + if [ "${SOC_TARGET}" = "iMX8QX" and "${SCFWBUILT}" != "yes" ]; then bbfatal "SCFW was not built!" fi } +# ConnectCore 8M Nano does not have different binaries +UBOOT_RAM_COMBINATIONS_ccimx8mn = "" + do_install () { install -d ${D}/boot - for ramc in ${UBOOT_RAM_COMBINATIONS}; do + if [ "${UBOOT_RAM_COMBINATIONS}" = "" ]; then for target in ${IMXBOOT_TARGETS}; do - install -m 0644 ${S}/${UBOOT_PREFIX}-${MACHINE}-${ramc}.bin-${target} ${D}/boot/ + install -m 0644 ${S}/${UBOOT_PREFIX}-${MACHINE}.bin-${target} ${D}/boot/ done - done + else + for ramc in ${UBOOT_RAM_COMBINATIONS}; do + for target in ${IMXBOOT_TARGETS}; do + install -m 0644 ${S}/${UBOOT_PREFIX}-${MACHINE}-${ramc}.bin-${target} ${D}/boot/ + done + done + fi } do_deploy () { install -d ${DEPLOYDIR}/${BOOT_TOOLS} # copy the tool mkimage to deploy path and sc fw, dcd and uboot - install -m 0644 ${BOOT_STAGING}/mx8qx-ahab-container.img ${DEPLOYDIR}/${BOOT_TOOLS} - install -m 0644 ${BOOT_STAGING}/m40_tcm.bin ${DEPLOYDIR}/${BOOT_TOOLS} - install -m 0644 ${BOOT_STAGING}/m4_image.bin ${DEPLOYDIR}/${BOOT_TOOLS} + if [ "${SOC_TARGET}" = "iMX8QX" ]; then + install -m 0644 ${BOOT_STAGING}/${SECO_FIRMWARE} ${DEPLOYDIR}/${BOOT_TOOLS} + install -m 0644 ${BOOT_STAGING}/m40_tcm.bin ${DEPLOYDIR}/${BOOT_TOOLS} + install -m 0644 ${BOOT_STAGING}/m4_image.bin ${DEPLOYDIR}/${BOOT_TOOLS} + fi install -m 0755 ${S}/${TOOLS_NAME} ${DEPLOYDIR}/${BOOT_TOOLS} # 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 ramc in ${UBOOT_RAM_COMBINATIONS}; do + if [ "${UBOOT_RAM_COMBINATIONS}" = "" ]; then IMAGE_IMXBOOT_TARGET="" for target in ${IMXBOOT_TARGETS}; do # Use first "target" as IMAGE_IMXBOOT_TARGET @@ -115,15 +174,52 @@ do_deploy () { IMAGE_IMXBOOT_TARGET="$target" echo "Set boot target as $IMAGE_IMXBOOT_TARGET" fi - install -m 0644 ${S}/${UBOOT_PREFIX}-${MACHINE}-${ramc}.bin-${target} ${DEPLOYDIR} + install -m 0644 ${S}/${UBOOT_PREFIX}-${MACHINE}.bin-${target} ${DEPLOYDIR} done cd ${DEPLOYDIR} - ln -sf ${UBOOT_PREFIX}-${MACHINE}-${ramc}.bin-${IMAGE_IMXBOOT_TARGET} ${UBOOT_PREFIX}-${MACHINE}-${ramc}.bin + ln -sf ${UBOOT_PREFIX}-${MACHINE}.bin-${IMAGE_IMXBOOT_TARGET} ${UBOOT_PREFIX}-${MACHINE}.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}-${ramc}.bin-${IMAGE_IMXBOOT_TARGET} ${BOOTABLE_FILENAME} + ln -sf ${UBOOT_PREFIX}-${MACHINE}.bin-${IMAGE_IMXBOOT_TARGET} ${BOOTABLE_FILENAME} cd - - done + else + for ramc in ${UBOOT_RAM_COMBINATIONS}; 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}-${ramc}.bin-${target} ${DEPLOYDIR} + done + cd ${DEPLOYDIR} + ln -sf ${UBOOT_PREFIX}-${MACHINE}-${ramc}.bin-${IMAGE_IMXBOOT_TARGET} ${UBOOT_PREFIX}-${MACHINE}-${ramc}.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}-${ramc}.bin-${IMAGE_IMXBOOT_TARGET} ${BOOTABLE_FILENAME} + cd - + done + fi + } -COMPATIBLE_MACHINE = "(ccimx8x)" +do_deploy_append () { + if [ "${TRUSTFENCE_SIGN}" = "1" ] && [ "${SIGN_MODE}" = "AHAB" ]; then + export CONFIG_SIGN_KEYS_PATH="${TRUSTFENCE_SIGN_KEYS_PATH}" + [ -n "${TRUSTFENCE_KEY_INDEX}" ] && export CONFIG_KEY_INDEX="${TRUSTFENCE_KEY_INDEX}" + [ -n "${TRUSTFENCE_DEK_PATH}" ] && [ "${TRUSTFENCE_DEK_PATH}" != "0" ] && export CONFIG_DEK_PATH="${TRUSTFENCE_DEK_PATH}" + + # Sign U-boot image + for ramc in ${RAM_CONFIGS}; do + trustfence-sign-ahab-uboot.sh ${DEPLOYDIR}/${UBOOT_PREFIX}-${MACHINE}-${ramc}.bin ${DEPLOYDIR}/${UBOOT_PREFIX}-${MACHINE}-${ramc}-signed.bin + done + + cd ${DEPLOYDIR} + cp ${B}/${config}SRK_efuses.bin ${DEPLOYDIR} + install ${B}/${config}SRK_efuses.bin SRK_efuses-${PV}-${PR}.bin + ln -sf SRK_efuses-${PV}-${PR}.bin SRK_efuses.bin + fi +} + +COMPATIBLE_MACHINE = "(ccimx8x|ccimx8mn)" diff --git a/meta-digi-arm/recipes-bsp/imx-mkimage/imx-mkimage_%.bbappend b/meta-digi-arm/recipes-bsp/imx-mkimage/imx-mkimage_%.bbappend index 0782c7f6a..079e27b22 100644 --- a/meta-digi-arm/recipes-bsp/imx-mkimage/imx-mkimage_%.bbappend +++ b/meta-digi-arm/recipes-bsp/imx-mkimage/imx-mkimage_%.bbappend @@ -1,5 +1,5 @@ -# Copyright (C) 2018,2019 Digi International, Inc. +# Copyright (C) 2018-2020 Digi International, Inc. # Use the v4.14 ga BSP branch -SRCBRANCH = "imx_4.14.98_2.1.0" -SRCREV = "abd6ce551a7b81fc6953d32d92b24a4a1d4b214e" +SRCBRANCH = "imx_4.14.98_2.3.0" +SRCREV = "2556000499f667123094af22326cfd8e4cbadaac" diff --git a/meta-digi-arm/recipes-bsp/imx-seco/imx-seco-libs_git.bb b/meta-digi-arm/recipes-bsp/imx-seco/imx-seco-libs_git.bb new file mode 100644 index 000000000..1a9d4417e --- /dev/null +++ b/meta-digi-arm/recipes-bsp/imx-seco/imx-seco-libs_git.bb @@ -0,0 +1,24 @@ +# Copyright 2019 NXP + +SUMMARY = "NXP i.MX SECO library" +DESCRIPTION = "NXP IMX SECO library" +SECTION = "base" +LICENSE = "Proprietary" +LIC_FILES_CHKSUM = "file://LA_OPT_NXP_Software_License.htm;md5=6a8fcab25f3d3f5c2898456114b91f44" + +DEPENDS = "zlib" + +SRCBRANCH = "master" +SECO_LIB_SRC ?= "git://github.com/NXP/imx-seco-libs.git;protocol=https" +SRC_URI = "${SECO_LIB_SRC};branch=${SRCBRANCH}" +SRCREV = "1afb4e66ba26cc723bd5bf96eb2e79a6c81daa70" + +S = "${WORKDIR}/git" + +TARGET_CC_ARCH += "${LDFLAGS}" + +do_install () { + oe_runmake DESTDIR=${D} install +} + +COMPATIBLE_MACHINE = "(mx8qm|mx8qxp)" diff --git a/meta-digi-arm/recipes-bsp/imx-seco/imx-seco_2.5.4.bb b/meta-digi-arm/recipes-bsp/imx-seco/imx-seco_2.5.4.bb new file mode 100644 index 000000000..9b3b2684a --- /dev/null +++ b/meta-digi-arm/recipes-bsp/imx-seco/imx-seco_2.5.4.bb @@ -0,0 +1,32 @@ +# Copyright 2019 NXP + +SUMMARY = "NXP i.MX SECO firmware" +DESCRIPTION = "NXP IMX SECO firmware" +SECTION = "base" +LICENSE = "Proprietary" +LIC_FILES_CHKSUM = "file://COPYING;md5=fd4b227530cd88a82af6a5982cfb724d" + +inherit fsl-eula-unpack deploy + +SRC_URI = "${FSL_MIRROR}/${PN}-${PV}.bin;fsl-eula=true " + +SRC_URI[md5sum] = "52f71d8965e99cd162a91a326e2e5dd8" +SRC_URI[sha256sum] = "552076de1dfcf880bf1ccf208ad646dee0f32454bf4f620f71b8699c95ccb96e" + +do_compile[noexec] = "1" + +do_install[noexec] = "1" + +SECO_FIRMWARE_NAME ?= "mx8qmb0-ahab-container.img" +SECO_FIRMWARE_NAME_mx8qm = "mx8qmb0-ahab-container.img" +SECO_FIRMWARE_NAME_mx8qxp = "mx8qxb0-ahab-container.img" +# i.MX8QXP C0 support +#SECO_FIRMWARE_NAME_mx8qxp = "mx8qxc0-ahab-container.img" + +addtask deploy after do_install +do_deploy () { + # Deploy i.MX8 SECO firmware files + install -m 0644 ${S}/firmware/seco/${SECO_FIRMWARE_NAME} ${DEPLOYDIR} +} + +COMPATIBLE_MACHINE = "(mx8qm|mx8qxp)" diff --git a/meta-digi-arm/recipes-bsp/trustfence-cst/trustfence-cst.inc b/meta-digi-arm/recipes-bsp/trustfence-cst/trustfence-cst.inc index 54ac3ec29..9639c584a 100644 --- a/meta-digi-arm/recipes-bsp/trustfence-cst/trustfence-cst.inc +++ b/meta-digi-arm/recipes-bsp/trustfence-cst/trustfence-cst.inc @@ -13,6 +13,8 @@ SRC_URI = " \ file://0002-hab4_pki_tree.sh-automate-script.patch \ file://0003-openssl_helper-use-dev-urandom-as-seed-source.patch \ file://0004-hab4_pki_tree.sh-usa-a-random-password-for-the-defau.patch \ + file://0005-ahab_pki_tree.sh-automate-script.patch \ + file://0006-ahab_pki_tree.sh-use-a-random-password-for-the-defau.patch \ file://Makefile \ " @@ -41,7 +43,14 @@ do_install() { install -d ${D}${bindir} install -m 0755 linux64/cst ${D}${bindir}/cst install -m 0755 $(find linux64 -type f -name srktool) ${D}${bindir}/srktool - install -m 0755 keys/hab4_pki_tree.sh ${D}${bindir}/trustfence-gen-pki.sh + if [ "${SIGN_MODE}" = "AHAB" ]; then + install -m 0755 keys/ahab_pki_tree.sh ${D}${bindir}/trustfence-gen-pki.sh + elif [ "${SIGN_MODE}" = "HAB" ]; then + install -m 0755 keys/hab4_pki_tree.sh ${D}${bindir}/trustfence-gen-pki.sh + else + bberror "Unkown SIGN_MODE value" + exit 1 + fi install -m 0755 ca/openssl.cnf ${D}${bindir}/openssl.cnf install -m 0755 ca/v3_ca.cnf ${D}${bindir}/v3_ca.cnf install -m 0755 ca/v3_usr.cnf ${D}${bindir}/v3_usr.cnf diff --git a/meta-digi-arm/recipes-bsp/trustfence-cst/trustfence-cst/0005-ahab_pki_tree.sh-automate-script.patch b/meta-digi-arm/recipes-bsp/trustfence-cst/trustfence-cst/0005-ahab_pki_tree.sh-automate-script.patch new file mode 100644 index 000000000..d238c945c --- /dev/null +++ b/meta-digi-arm/recipes-bsp/trustfence-cst/trustfence-cst/0005-ahab_pki_tree.sh-automate-script.patch @@ -0,0 +1,206 @@ +From: Mike Engel +Date: Fri, 24 Jan 2020 17:31:50 +0100 +Subject: [PATCH] ahab_pki_tree.sh: automate script + +Signed-off-by: Mike Engel +--- + keys/ahab_pki_tree.sh | 116 ++++++++++++++++++------------------------------------- + 1 file changed, 38 insertions(+), 78 deletions(-) + +diff --git a/keys/ahab_pki_tree.sh b/keys/ahab_pki_tree.sh +index 988c27e..00dd143 100755 +--- a/keys/ahab_pki_tree.sh ++++ b/keys/ahab_pki_tree.sh +@@ -47,74 +47,36 @@ + # + #----------------------------------------------------------------------------- + +-printf "\n" +-printf " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" +-printf " This script is a part of the Code signing tools for NXP's\n" +-printf " Advanced High Assurance Boot. It generates a basic PKI tree. The\n" +-printf " PKI tree consists of one or more Super Root Keys (SRK), with each\n" +-printf " SRK having one subordinate keys: \n" +-printf " + a Signing key (SGK) \n" +-printf " Additional keys can be added to the PKI tree but a separate \n" +-printf " script is available for this. This this script assumes openssl\n" +-printf " is installed on your system and is included in your search \n" +-printf " path. Finally, the private keys generated are password \n" +-printf " protectedwith the password provided by the file key_pass.txt.\n" +-printf " The format of the file is the password repeated twice:\n" +-printf " my_password\n" +-printf " my_password\n" +-printf " All private keys in the PKI tree are in PKCS #8 format will be\n" +-printf " protected by the same password.\n\n" +-printf " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" +- +-stty erase  +- +-printf "Do you want to use an existing CA key (y/n)?: \b" +-read existing_ca +-if [ $existing_ca = "y" ] +-then +- printf "Enter CA key name: \b" +- read ca_key +- printf "Enter CA certificate name: \b" +- read ca_cert ++SCRIPT_BASEDIR="$(cd $(dirname ${0}) && pwd)" ++CSF_PATH="${1}" ++if [ ! -d "${CSF_PATH}" ]; then ++ echo "Invalid CSF_PATH: ${CSF_PATH}" ++ exit 1 + fi + +-printf "Do you want to use Elliptic Curve Cryptography (y/n)?: \b" +-read use_ecc +-if [ $use_ecc = "y" ] +-then +- printf "Enter length for elliptic curve to be used for PKI tree:\n" +- printf "Possible values p256, p384, p521: \b" +- read kl +- +- # Confirm that a valid key length has been entered +- case $kl in +- p256) +- cn="prime256v1" ;; +- p384) +- cn="secp384r1" ;; +- p521) +- cn="secp521r1" ;; +- *) +- echo Invalid key length. Supported key lengths: 256, 384, 521 +- exit 1 ;; +- esac +-else +- printf "Enter key length in bits for PKI tree: \b" +- read kl +- +- # Confirm that a valid key length has been entered +- case $kl in +- 2048) ;; +- 3072) ;; +- 4096) ;; +- *) +- echo Invalid key length. Supported key lengths: 2048, 3072, 4096 +- exit 1 ;; +- esac +-fi ++cd "${CSF_PATH}" ++ ++[ -d crts ] || mkdir crts ++[ -d keys ] || mkdir keys ++ ++cd keys ++ ++use_ecc="y" ++existing_ca="n" ++kl="p521" ++cn="secp521r1" ++ ++# Confirm that a valid key length has been entered ++case $kl in ++ p256);; ++ p384);; ++ p521);; ++ *) ++ echo Invalid key length. Supported key lengths: 256, 384, 521 ++ exit 1 ;; ++esac + +-printf "Enter the digest algorithm to use: \b" +-read da ++da="sha512" + + # Confirm that a valid digest algorithm has been entered + case $da in +@@ -126,8 +88,7 @@ case $da in + exit 1 ;; + esac + +-printf "Enter PKI tree duration (years): \b" +-read duration ++duration="10" + + # Compute validity period + val_period=$((duration*365)) +@@ -144,8 +105,7 @@ then + fi + + # Check if SRKs should be generated as CA certs or user certs +-printf "Do you want the SRK certificates to have the CA flag set? (y/n)?: \b" +-read srk_ca ++srk_ca="y" + + # Check that the file "serial" is present, if not create it: + if [ ! -f serial ] +@@ -201,7 +161,7 @@ then + -x509 -extensions v3_ca \ + -keyout temp_ca.pem \ + -out ${ca_cert}.pem \ +- -days ${val_period} -config ../ca/openssl.cnf ++ -days ${val_period} -config "${SCRIPT_BASEDIR}/openssl.cnf" + + # Generate CA key in PKCS #8 format - both PEM and DER + openssl pkcs8 -passin file:./key_pass.txt -passout file:./key_pass.txt \ +@@ -218,7 +178,7 @@ then + openssl x509 -inform PEM -outform DER -in ${ca_cert}.pem -out ${ca_cert}.der + + # Cleanup +- \rm temp_ca.pem ++ rm temp_ca.pem + fi + + +@@ -292,7 +252,7 @@ then + -out ${srk_key}.pem + + # Cleanup +- \rm ./temp_srk.pem ./temp_srk_req.pem ++ rm ./temp_srk.pem ./temp_srk_req.pem + i=$((i+1)) + done + else +@@ -341,10 +301,10 @@ do + -in ./temp_srk_req.pem \ + -cert ${ca_cert}.pem \ + -keyfile ${ca_key}.pem \ +- -extfile ../ca/v3_ca.cnf \ ++ -extfile "${SCRIPT_BASEDIR}/v3_ca.cnf" \ + -out ${srk_crt}.pem \ + -days ${val_period} \ +- -config ../ca/openssl.cnf ++ -config "${SCRIPT_BASEDIR}/openssl.cnf" + + # Convert SRK Certificate to DER format + openssl x509 -inform PEM -outform DER \ +@@ -365,7 +325,7 @@ do + -out ${srk_key}.pem + + # Cleanup +- \rm ./temp_srk.pem ./temp_srk_req.pem ++ rm ./temp_srk.pem ./temp_srk_req.pem + + echo + echo ++++++++++++++++++++++++++++++++++++++++ +@@ -410,10 +370,10 @@ do + -in ./temp_sgk_req.pem \ + -cert ${srk_crt_i} \ + -keyfile ${srk_key_i} \ +- -extfile ../ca/v3_usr.cnf \ ++ -extfile "${SCRIPT_BASEDIR}/v3_usr.cnf" \ + -out ${sgk_crt}.pem \ + -days ${val_period} \ +- -config ../ca/openssl.cnf ++ -config "${SCRIPT_BASEDIR}/openssl.cnf" + + # Convert SGK Certificate to DER format + openssl x509 -inform PEM -outform DER \ +@@ -432,7 +392,7 @@ do + -out ${sgk_key}.pem + + # Cleanup +- \rm ./temp_sgk.pem ./temp_sgk_req.pem ++ rm ./temp_sgk.pem ./temp_sgk_req.pem + + i=$((i+1)) + done diff --git a/meta-digi-arm/recipes-bsp/trustfence-cst/trustfence-cst/0006-ahab_pki_tree.sh-use-a-random-password-for-the-defau.patch b/meta-digi-arm/recipes-bsp/trustfence-cst/trustfence-cst/0006-ahab_pki_tree.sh-use-a-random-password-for-the-defau.patch new file mode 100644 index 000000000..ab49ef09a --- /dev/null +++ b/meta-digi-arm/recipes-bsp/trustfence-cst/trustfence-cst/0006-ahab_pki_tree.sh-use-a-random-password-for-the-defau.patch @@ -0,0 +1,28 @@ +From: Mike Engel +Date: Fri, 24 Jan 2020 17:47:56 +0100 +Subject: [PATCH] ahab_pki_tree.sh: use a random password for the default PKI + generation + +Signed-off-by: Mike Engel +--- + keys/ahab_pki_tree.sh | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/keys/ahab_pki_tree.sh b/keys/ahab_pki_tree.sh +index 00dd143..8b81143 100755 +--- a/keys/ahab_pki_tree.sh ++++ b/keys/ahab_pki_tree.sh +@@ -117,9 +117,10 @@ fi + # Check that the file "key_pass.txt" is present, if not create it with default user/pwd: + if [ ! -f key_pass.txt ] + then +- echo "test" > key_pass.txt +- echo "test" >> key_pass.txt +- echo "A default file 'key_pass.txt' was created with password = test!" ++ password="$(openssl rand -base64 32)" ++ echo "${password}" > key_pass.txt ++ echo "${password}" >> key_pass.txt ++ echo "A file 'key_pass.txt' was created with a random password!" + fi + + # The following is required otherwise OpenSSL complains diff --git a/meta-digi-arm/recipes-bsp/u-boot/digi-u-boot.inc b/meta-digi-arm/recipes-bsp/u-boot/digi-u-boot.inc index b3acff935..68f14fc16 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/digi-u-boot.inc +++ b/meta-digi-arm/recipes-bsp/u-boot/digi-u-boot.inc @@ -63,7 +63,6 @@ do_compile () { if [ $j -eq $i ] then oe_runmake -C ${S} O=${B}/${config} ${config} - # Reconfigure U-Boot with Digi UBOOT_EXTRA_CONF for var in ${UBOOT_EXTRA_CONF}; do echo "${var}" >> ${B}/${config}/.config @@ -80,7 +79,7 @@ do_compile () { unset k # Secure boot artifacts - if [ "${TRUSTFENCE_SIGN}" = "1" ] + if [ "${TRUSTFENCE_SIGN}" = "1" ] && [ "${SIGN_MODE}" = "HAB" ] then cp ${B}/${config}/u-boot-dtb-signed.imx ${B}/${config}/u-boot-dtb-signed-${type}.${UBOOT_SUFFIX} cp ${B}/${config}/u-boot-dtb-usb-signed.imx ${B}/${config}/u-boot-dtb-usb-signed-${type}.${UBOOT_SUFFIX} @@ -123,8 +122,7 @@ do_deploy_append() { cd ${DEPLOYDIR} rm -r ${UBOOT_BINARY}-${type} ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} u-boot-${type}.${UBOOT_SUFFIX} - if [ "${TRUSTFENCE_SIGN}" = "1" ] - then + if [ "${TRUSTFENCE_SIGN}" = "1" ] && [ "${SIGN_MODE}" = "HAB" ]; then install ${B}/${config}/SRK_efuses.bin SRK_efuses-${PV}-${PR}.bin ln -sf SRK_efuses-${PV}-${PR}.bin SRK_efuses.bin @@ -163,9 +161,11 @@ do_deploy_append() { [ -n "${TRUSTFENCE_DEK_PATH}" ] && [ "${TRUSTFENCE_DEK_PATH}" != "0" ] && export CONFIG_DEK_PATH="${TRUSTFENCE_DEK_PATH}" # Sign boot script - TMP_SIGNED_BOOTSCR="$(mktemp ${WORKDIR}/bootscr-signed.XXXXXX)" - trustfence-sign-kernel.sh -p "${DIGI_FAMILY}" -b "${DEPLOYDIR}/boot.scr" "${TMP_SIGNED_BOOTSCR}" - mv "${TMP_SIGNED_BOOTSCR}" "${DEPLOYDIR}/boot.scr" + if [ "${SIGN_MODE}" = "HAB" ]; then + TMP_SIGNED_BOOTSCR="$(mktemp ${WORKDIR}/bootscr-signed.XXXXXX)" + trustfence-sign-kernel.sh -p "${DIGI_FAMILY}" -b "${DEPLOYDIR}/boot.scr" "${TMP_SIGNED_BOOTSCR}" + mv "${TMP_SIGNED_BOOTSCR}" "${DEPLOYDIR}/boot.scr" + fi fi rm -f ${TMP_BOOTSCR} } @@ -178,4 +178,36 @@ do_deploy_append_ccimx8x() { install -d ${DEPLOYDIR}/${BOOT_TOOLS} mv ${DEPLOYDIR}/u-boot* ${DEPLOYDIR}/${BOOT_TOOLS}/ mv ${DEPLOYDIR}/${UBOOT_SYMLINK}-* ${DEPLOYDIR}/${BOOT_TOOLS}/ + if [ "${TRUSTFENCE_SIGN}" = "1" ]; then + ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/mkimage_imx8 -soc ${MX8_SOC_VAR} -rev ${MX8_CHIP_REV} -c -ap ${DEPLOYDIR}/boot.scr a35 ${RAM_CONTAINER_LOC_BOOT} -out ${DEPLOYDIR}/boot-mkimg.scr + trustfence-sign-kernel.sh -p "${DIGI_FAMILY}" -b "${DEPLOYDIR}/boot-mkimg.scr" "${DEPLOYDIR}/boot.scr" + rm -f ${DEPLOYDIR}/boot-mkimg.scr + fi +} + +do_deploy_append_ccimx8mn() { + # Move all U-Boot artifacts to the imx-boot-tools folder + # U-Boot images are not bootable on the i.MX8M + install -d ${DEPLOYDIR}/${BOOT_TOOLS} + mv ${DEPLOYDIR}/u-boot-spl* ${DEPLOYDIR}/${BOOT_TOOLS}/ + + # Deploy the mkimage, u-boot-nodtb.bin and ccimx8mn-dvk.dtb for mkimage to generate boot binary + if [ -n "${UBOOT_CONFIG}" ] + then + for config in ${UBOOT_MACHINE}; do + i=$(expr $i + 1); + for type in ${UBOOT_CONFIG}; do + j=$(expr $j + 1); + if [ $j -eq $i ] + then + install -d ${DEPLOYDIR}/${BOOT_TOOLS} + install -m 0777 ${B}/${config}/arch/arm/dts/${UBOOT_DTB_NAME} ${DEPLOYDIR}/${BOOT_TOOLS} + install -m 0777 ${B}/${config}/tools/mkimage ${DEPLOYDIR}/${BOOT_TOOLS}/mkimage_uboot + install -m 0777 ${B}/${config}/u-boot-nodtb.bin ${DEPLOYDIR}/${BOOT_TOOLS}/u-boot-nodtb.bin-${MACHINE}-${UBOOT_CONFIG} + fi + done + unset j + done + unset i + fi } 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 new file mode 100644 index 000000000..469c583de --- /dev/null +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt @@ -0,0 +1,48 @@ +# +# U-Boot bootscript for EMMC/SD images created by Yocto. +# + +# Set SOC type to "imx8mn" if not already defined by U-Boot +if test ! -n "${soc_type}"; then + setenv soc_type "imx8mn" +fi + +# +# Set device tree filename depending on the board ID (if defined) +# +if test -n "${board_id}"; then + setenv fdt_file cc${soc_type}-dvk-id${board_id}.dtb +else + # + # Set device tree filename depending on the hardware capabilities + # + if test -n "${module_ram}"; then + setexpr module_has_wifi ${hwid_2} \& 10000 + setexpr module_has_wifi ${module_has_wifi} / 10000 + setexpr module_has_bt ${hwid_2} \& 20000 + setexpr module_has_bt ${module_has_bt} / 20000 + + if test "${module_has_wifi}" = "1" && + test "${module_has_bt}" = "1"; then + setenv fdt_file cc${soc_type}-dvk-wb.dtb + else + setenv fdt_file cc${soc_type}-dvk.dtb + fi + fi +fi + +# Get the UUID of the configured boot partition. +part uuid mmc ${mmcbootdev}:${mmcpart} bootpart +# Check the boot source. +if test "${bootpart}" = "${part1_uuid}"; then + # We are booting from the eMMC using 'linux'. + true +elif test "${bootpart}" = "${part2_uuid}"; then + # 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 +dboot linux mmc ${mmcbootdev}:${mmcpart} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/install_linux_fw_sd.txt new file mode 100644 index 000000000..b662264ff --- /dev/null +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/install_linux_fw_sd.txt @@ -0,0 +1,142 @@ +# +# U-Boot script for installing Linux images created by Yocto from the SD +# card into the eMMC +# + +echo "############################################################" +echo "# Linux firmware install from micro SD #" +echo "############################################################" +echo "" +echo " This process will erase your eMMC and will install a new" +echo " U-Boot and Linux firmware images on the eMMC." +echo "" +echo " Press CTRL+C now if you wish to abort or wait 10 seconds" +echo " to continue." + +sleep 10 +if test $? -eq 1; then + echo "Aborted by user."; + exit; +fi + +setenv INSTALL_UBOOT_FILENAME imx-boot-ccimx8mn-dvk.bin; +setenv INSTALL_MMCDEV 1 +setenv INSTALL_LINUX_FILENAME dey-image-qt-##GRAPHICAL_BACKEND##-ccimx8mn-dvk.boot.vfat +setenv INSTALL_RECOVERY_FILENAME dey-image-qt-##GRAPHICAL_BACKEND##-ccimx8mn-dvk.recovery.vfat +setenv INSTALL_ROOTFS_FILENAME dey-image-qt-##GRAPHICAL_BACKEND##-ccimx8mn-dvk.ext4 + +# Check for presence of firmware files on the SD card +for install_f in ${INSTALL_UBOOT_FILENAME} ${INSTALL_LINUX_FILENAME} ${INSTALL_RECOVERY_FILENAME} ${INSTALL_ROOTFS_FILENAME}; do + if test ! -e mmc ${INSTALL_MMCDEV} ${install_f}; then + echo "ERROR: Could not find file ${install_f}"; + install_abort=1; + fi; +done +if test -n "${install_abort}"; then + echo "Aborted."; + exit; +fi + +# Skip user confirmation for U-Boot update +setenv forced_update 1 + +# Set bootdelay to zero so that firmware update is run immediately after +# the first reset. +setenv bootdelay 0 + +# Set target MMC device index to eMMC +setenv mmcdev 0 + +# Update U-Boot +echo "" +echo "" +echo ">> Installing U-Boot boot loader (target will reset)" +echo "" +echo "" +update uboot mmc ${INSTALL_MMCDEV} fat ${INSTALL_UBOOT_FILENAME} +if test $? -eq 1; then + echo "[ERROR] Failed to update U-Boot boot loader!"; + echo ""; + echo "Aborted."; + exit; +fi + +# Set 'bootcmd' to the second part of the script that will +# - Reset environment to defaults +# - Save the environment +# - Force on-the-fly updates to avoid possible verification errors +# - Partition the eMMC user data area for Linux +# - Update the 'linux' partition +# - Update the 'recovery' partition +# - Update the 'rootfs' partition +# - Configure recovery to wipe 'update' partition +# - Disable on-the-fly updates +# - Run 'recovery' and let the system boot after +setenv bootcmd " + env default -a; + saveenv; + setenv otf-update yes; + echo \"\"; + echo \"\"; + echo \">> Creating Linux partition table on the eMMC\"; + echo \"\"; + echo \"\"; + run partition_mmc_linux; + if test \$? -eq 1; then + echo \"[ERROR] Failed to create Linux partition table!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing Linux kernel and device tree files\"; + echo \"\"; + echo \"\"; + update linux mmc ${INSTALL_MMCDEV} fat ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing recovery\"; + echo \"\"; + echo \"\"; + update recovery mmc ${INSTALL_MMCDEV} fat ${INSTALL_RECOVERY_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update recovery partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing Linux root file system\"; + echo \"\"; + echo \"\"; + update rootfs mmc ${INSTALL_MMCDEV} fat ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + setenv boot_recovery yes; + setenv recovery_command wipe_update; + setenv otf-update; + saveenv; + echo \"\"; + echo \"\"; + echo \">> Firmware installation complete. Rebooting into recovery mode for final deployment.\"; + echo \"\"; + echo \"\"; + sleep 1; + reset; +" + +saveenv +reset diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey_2018.03.bb b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey_2018.03.bb index 763c3b386..dd3b5a540 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey_2018.03.bb +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey_2018.03.bb @@ -1,8 +1,8 @@ -# Copyright (C) 2019 Digi International +# Copyright (C) 2019,2020 Digi International require digi-u-boot.inc SRCBRANCH = "v2018.03/maint" SRCREV = "${AUTOREV}" -COMPATIBLE_MACHINE = "(ccimx8x)" +COMPATIBLE_MACHINE = "(ccimx8x|ccimx8m)" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey_2019.04.bb b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey_2019.04.bb new file mode 100644 index 000000000..604ebbc43 --- /dev/null +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey_2019.04.bb @@ -0,0 +1,11 @@ +# Copyright (C) 2019 Digi International + +require digi-u-boot.inc +LIC_FILES_CHKSUM = "file://Licenses/README;md5=30503fd321432fc713238f582193b78e" + +DEPENDS += "flex-native bison-native" + +SRCBRANCH = "v2019.04/master" +SRCREV = "${AUTOREV}" + +COMPATIBLE_MACHINE = "(ccimx8x)" \ No newline at end of file diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-fw-utils/ccimx8mn/fw_env.config b/meta-digi-arm/recipes-bsp/u-boot/u-boot-fw-utils/ccimx8mn/fw_env.config new file mode 100644 index 000000000..040cd8e30 --- /dev/null +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-fw-utils/ccimx8mn/fw_env.config @@ -0,0 +1,7 @@ +# Configuration file for fw_(printenv/setenv) utility. +# Up to two entries are valid, in this case the redundant +# environment sector is assumed present. + +# Device name Offset Size +/dev/mmcblk0boot1 0x1C0000 0x4000 +/dev/mmcblk0boot1 0x1E0000 0x4000 diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-fw-utils_%.bbappend b/meta-digi-arm/recipes-bsp/u-boot/u-boot-fw-utils_%.bbappend index 195bc2a01..a6197e0f7 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-fw-utils_%.bbappend +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-fw-utils_%.bbappend @@ -82,5 +82,3 @@ pkg_postinst_ontarget_${PN}() { ${CONFIG_FILE} fi } - -COMPATIBLE_MACHINE = "(ccimx6$|ccimx6ul|ccimx8x)" 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 2657a90d9..caa40f64f 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 @@ -22,6 +22,14 @@ do_install_append() { >> ${D}${sysconfdir}/udev/rules.d/localextra.rules fi + # XBee TTY symlink + if [ -n "${XBEE_TTY}" ]; then + printf "%s\n%s\n" \ + "# Symlink to the XBee tty" \ + "KERNEL==\"${XBEE_TTY}\", MODE=\"0660\", GROUP=\"tty\", SYMLINK+=\"ttyXBee\"" \ + >> ${D}${sysconfdir}/udev/rules.d/localextra.rules + fi + install -d ${D}${sysconfdir}/modprobe.d install -m 0644 ${WORKDIR}/blacklist.conf ${D}${sysconfdir}/modprobe.d } diff --git a/meta-digi-arm/recipes-cpu/m4-demos/imx-m4-demos-2.inc b/meta-digi-arm/recipes-cpu/m4-demos/imx-m4-demos-2.inc index f35d6dc74..af6ac93b5 100644 --- a/meta-digi-arm/recipes-cpu/m4-demos/imx-m4-demos-2.inc +++ b/meta-digi-arm/recipes-cpu/m4-demos/imx-m4-demos-2.inc @@ -22,6 +22,7 @@ SCR = "SCR-${SOC}-m4-demo.txt" do_deploy () { # Install the demo binaries cp ${D}/* ${DEPLOYDIR}/ + chmod 0644 ${DEPLOYDIR}/* } addtask deploy after do_install diff --git a/meta-digi-arm/recipes-cpu/m4-demos/imx-m4-demos_2.5.2.bb b/meta-digi-arm/recipes-cpu/m4-demos/imx-m4-demos_2.5.2.bb deleted file mode 100644 index 910b7618e..000000000 --- a/meta-digi-arm/recipes-cpu/m4-demos/imx-m4-demos_2.5.2.bb +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright 2017-2019 NXP -# Released under the MIT license (see COPYING.MIT for the terms) - -require imx-m4-demos-2.inc - -LIC_FILES_CHKSUM = "file://COPYING;md5=80c0478f4339af024519b3723023fe28" - -SRC_URI[imx8qm.md5sum] = "6423c4c60412b509b6d7537ce1a3fd44" -SRC_URI[imx8qm.sha256sum] = "cf430d4a111370c021435e864666d34fae4c4242907c195aad0c46c48073f78f" - -SRC_URI[imx8qx.md5sum] = "fe2e5c9513faac946d29e5904bf792d9" -SRC_URI[imx8qx.sha256sum] = "151c6a578f6ae5a09b378015116061875047e4f3b6264e4becc80276621893b1" - -COMPATIBLE_MACHINE = "(mx8qm|mx8qxp)" diff --git a/meta-digi-arm/recipes-cpu/m4-demos/imx-m4-demos_2.7.0.bb b/meta-digi-arm/recipes-cpu/m4-demos/imx-m4-demos_2.7.0.bb new file mode 100644 index 000000000..e8ab3697b --- /dev/null +++ b/meta-digi-arm/recipes-cpu/m4-demos/imx-m4-demos_2.7.0.bb @@ -0,0 +1,11 @@ +# Copyright 2017-2019 NXP +# Released under the MIT license (see COPYING.MIT for the terms) + +require imx-m4-demos-2.inc + +LIC_FILES_CHKSUM = "file://COPYING;md5=fd4b227530cd88a82af6a5982cfb724d" + +SRC_URI[imx8qx.md5sum] = "659c0ccf3a215fae7345d30e85774143" +SRC_URI[imx8qx.sha256sum] = "74e97eea086b3cabe6d4430570e46586625fba822af97c0c2b5d025e69b3b3cb" + +COMPATIBLE_MACHINE = "(mx8qxp)" diff --git a/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0001-Port-changes-from-the-cryptoauth-engine-repo-to-the-.patch b/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0001-Port-changes-from-the-cryptoauth-engine-repo-to-the-.patch deleted file mode 100644 index 8c6261b34..000000000 --- a/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0001-Port-changes-from-the-cryptoauth-engine-repo-to-the-.patch +++ /dev/null @@ -1,404 +0,0 @@ -From: Gabriel Valcazar -Date: Wed, 14 Feb 2018 17:30:49 +0100 -Subject: [PATCH 1/2] Port changes from the cryptoauth engine repo to the - library repo - -Incorporate makefiles to be able to build cryptoauthlib as well as the changes -Digi has done in the atmel-cryptoauth-openssl-engine repo (except for -our modifications in the HAL section, which are not needed anymore). Update -package configuration version to 1.3, remove OpenSSL engine dependencies and -fix an infinite recursion that happened when cleaning the project. - -https://jira.digi.com/browse/DEL-5591 - -Signed-off-by: Gabriel Valcazar -Signed-off-by: Isaac Hermida ---- - Makefile | 32 +++++++++++++++++ - Makefile.generic | 22 ++++++++++++ - ecc-test-main.c | 71 +++++++++++++++++++++++++++++++++++++ - lib/Makefile | 46 ++++++++++++++++++++++++ - lib/atca_cfgs.c | 16 +++++++-- - lib/atcacert/Makefile | 1 + - lib/basic/Makefile | 1 + - lib/crypto/Makefile | 1 + - lib/crypto/hashes/Makefile | 1 + - lib/cryptoauthlib.pc | 11 ++++++ - lib/hal/Makefile | 1 + - lib/host/Makefile | 1 + - lib/jwt/Makefile | 1 + - lib/tls/Makefile | 1 + - test/Makefile | 15 ++++++++ - test/atcacert/Makefile | 1 + - test/jwt/Makefile | 1 + - test/sha-byte-test-vectors/Makefile | 1 + - test/tls/Makefile | 1 + - 19 files changed, 222 insertions(+), 3 deletions(-) - create mode 100644 Makefile - create mode 100644 Makefile.generic - create mode 100644 ecc-test-main.c - create mode 100644 lib/Makefile - create mode 100644 lib/atcacert/Makefile - create mode 100644 lib/basic/Makefile - create mode 100644 lib/crypto/Makefile - create mode 100644 lib/crypto/hashes/Makefile - create mode 100644 lib/cryptoauthlib.pc - create mode 100644 lib/hal/Makefile - create mode 100644 lib/host/Makefile - create mode 100644 lib/jwt/Makefile - create mode 100644 lib/tls/Makefile - create mode 100644 test/Makefile - create mode 100644 test/atcacert/Makefile - create mode 100644 test/jwt/Makefile - create mode 100644 test/sha-byte-test-vectors/Makefile - create mode 100644 test/tls/Makefile - -diff --git a/Makefile b/Makefile -new file mode 100644 -index 000000000000..a471428ad12c ---- /dev/null -+++ b/Makefile -@@ -0,0 +1,32 @@ -+CWD:= $(shell pwd) -+CFLAGS+= -I. -I../.. -fPIC -g -O0 -+SRC:= $(wildcard *.c) -+export CFLAGS -+ -+SUBDIRS= lib test -+ -+.PHONY: tgt_lib tgt_test clean -+ -+all: tgt_lib tgt_test ecc-test -+ -+%.o: %.c -+ $(CC) $(CFLAGS) -o $@ -c $< -+ -+tgt_lib: -+ make -w -C lib -+ -+tgt_test: -+ make -w -C test -+ -+ecc-test: tgt_lib tgt_test -+ $(CC) -c ecc-test-main.c $(CFLAGS) $(LDFLAGS) -I ./lib/ -I ./test/ -+ $(CC) -o ecc-test-main ecc-test-main.o $(LDFLAGS) test/tls/atcatls_tests.o -L lib -L test -lm -lc -lrt -lcryptoauth -lunity -+ -+install: -+ for a in $(SUBDIRS); do $(MAKE) -C $$a $@; done -+ install -d $(DESTDIR)/usr/bin -+ install -m 0755 ecc-test-main $(DESTDIR)/usr/bin/ -+ -+clean: -+ rm -f *.o *.a ecc-test-main -+ $(foreach subdir,$(basename $(SUBDIRS)),$(MAKE) -w -C $(subdir) clean;) -diff --git a/Makefile.generic b/Makefile.generic -new file mode 100644 -index 000000000000..f6a0d67c708c ---- /dev/null -+++ b/Makefile.generic -@@ -0,0 +1,22 @@ -+CWD:= $(shell pwd) -+CFLAGS+= -I. -I.. -I../.. -I../../.. -I../../../.. -I../../lib -I../lib -fPIC -g -O0 -DATCA_HAL_I2C -DATCAPRINTF -+SRC:= $(wildcard *.c) -+export CFLAGS -+ -+DIRECTORIES= $(shell find . -maxdepth 1 ! -path . -type d) -+SUBDIRS= $(DIRECTORIES) -+ -+.PHONY: clean tgt_local -+ -+MODULES= $(patsubst %.c,%.o,$(SRC)) -+ -+all: $(MODULES) tgt_local -+ $(foreach subdir,$(basename $(SUBDIRS)),$(MAKE) -w -C $(subdir);) -+ -+%.o: %.c -+ $(CC) $(CFLAGS) -o $@ -c $< -+ -+clean: -+ rm -f *.o *.a -+ $(foreach subdir,$(basename $(SUBDIRS)),$(MAKE) -w -C $(subdir) clean;) -+ -diff --git a/ecc-test-main.c b/ecc-test-main.c -new file mode 100644 -index 000000000000..032bc4bc2b5a ---- /dev/null -+++ b/ecc-test-main.c -@@ -0,0 +1,71 @@ -+/** \file ecc-test-main.c -+ * \brief Used to launch CryptoAuthLib tests for TLS -+ * -+ * Copyright (c) 2015 Atmel Corporation. All rights reserved. -+ * -+ * \atmel_crypto_device_library_license_start -+ * -+ * \page License -+ * -+ * 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. -+ * -+ * 3. Neither the name of Atmel nor the names of its contributors may be used to endorse -+ * or promote products derived from this software without specific prior written permission. -+ * -+ * 4. This software may only be redistributed and used in connection with an -+ * Atmel integrated circuit. -+ * -+ * 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 "ssl.h" -+#include -+#include -+#include -+#include -+#include -+ -+#define ATCA_HAL_I2C -+ -+// Get a pointer to the default configuration based on the compiler switch -+#ifdef ATCA_HAL_KIT_CDC -+ATCAIfaceCfg* pCfg = &cfg_ecc508_kitcdc_default; -+#elif defined(ATCA_HAL_KIT_HID) -+ATCAIfaceCfg* pCfg = &cfg_ecc508_kithid_default; -+#elif defined(ATCA_HAL_I2C) -+ATCAIfaceCfg* pCfg = &cfg_ateccx08a_i2c_default; -+#endif -+ -+ -+/** \brief Main function for running ATECC508 tests. -+ * Use this test program to ensure that the Engine can communicate to your ATECC508 -+ * -+ * \return For success return 0 -+ */ -+int main() -+{ -+ uint8_t runTests = true; -+ -+ if (runTests) -+ { -+ atcatls_test_runner(pCfg); -+ } -+ return 0; -+} -diff --git a/lib/Makefile b/lib/Makefile -new file mode 100644 -index 000000000000..e8c89380a43c ---- /dev/null -+++ b/lib/Makefile -@@ -0,0 +1,46 @@ -+CWD:=$(shell pwd) -+SRC:=$(wildcard *.c) -+ -+DIRECTORIES=$(shell find . -maxdepth 1 ! -path . -type d) -+SUBDIRS=$(DIRECTORIES) -+ -+.PHONY: clean -+ -+MODULES=$(patsubst %.c,%.o,$(SRC)) -+#O_FILES=$(shell find . -name \*.o) -+O_FILES=$(wildcard **/**/*.o) -+O_FILES+=$(wildcard **/*.o) -+LIBNAME=libcryptoauth -+ -+INCLUDE_PATH = "$(DESTDIR)/usr/include/cryptoauthlib" -+ -+all: $(MODULES) -+ - $(foreach subdir,$(basename $(SUBDIRS)),$(shell make -w -C $(subdir))) -+ @echo "OFILES: $(O_FILES)" -+ $(AR) -r $(LIBNAME).a $(MODULES) $(O_FILES) -+ $(RANLIB) $(LIBNAME).a -+ -+.PHONY: install -+install: $(LIBNAME).a -+ install -d $(DESTDIR)/usr/lib/pkgconfig -+ install -m 0644 $(LIBNAME).a $(DESTDIR)/usr/lib/ -+ install -m 0644 cryptoauthlib.pc $(DESTDIR)/usr/lib/pkgconfig/ -+ -+ install -d $(INCLUDE_PATH)/atcacert $(INCLUDE_PATH)/basic $(INCLUDE_PATH)/hal $(INCLUDE_PATH)/tls -+ install -m 0644 atcacert/*.h $(INCLUDE_PATH)/atcacert -+ install -m 0644 basic/*.h $(INCLUDE_PATH)/basic -+ install -m 0644 hal/*.h $(INCLUDE_PATH)/hal -+ install -m 0644 tls/*.h $(INCLUDE_PATH)/tls -+ install -m 0644 *.h $(INCLUDE_PATH) -+ -+ install -d $(INCLUDE_PATH)/crypto/hashes -+ install -m 0644 crypto/*.h $(INCLUDE_PATH)/crypto -+ install -m 0644 crypto/hashes/*.h $(INCLUDE_PATH)/crypto/hashes -+ -+%.o: %.c -+ $(CC) $(CFLAGS) -o $@ -c $< -+ -+clean: -+ rm -f *.o *.a -+ $(foreach subdir,$(basename $(SUBDIRS)),$(MAKE) -w -C $(subdir) clean;) -+ -diff --git a/lib/atca_cfgs.c b/lib/atca_cfgs.c -index b8de8e8ede7f..4cbd305724d4 100644 ---- a/lib/atca_cfgs.c -+++ b/lib/atca_cfgs.c -@@ -40,14 +40,24 @@ - - /* if the number of these configurations grows large, we can #ifdef them based on required device support */ - -+/* Default I2C configuration */ -+#ifndef ATCA_HAL_I2C_BUS -+#define ATCA_HAL_I2C_BUS 0 -+#warning "Using default value for ATCA_HAL_I2C_BUS: 0" -+#endif -+ -+#ifndef ATCA_HAL_I2C_SPEED -+#define ATCA_HAL_I2C_SPEED 400000 -+#warning "Using default value for ATCA_HAL_I2C_SPEED: 400000" -+#endif -+ - /** \brief default configuration for an ECCx08A device */ - ATCAIfaceCfg cfg_ateccx08a_i2c_default = { - .iface_type = ATCA_I2C_IFACE, - .devtype = ATECC508A, - .atcai2c.slave_address = 0xC0, -- .atcai2c.bus = 2, -- .atcai2c.baud = 400000, -- //.atcai2c.baud = 100000, -+ .atcai2c.bus = ATCA_HAL_I2C_BUS, -+ .atcai2c.baud = ATCA_HAL_I2C_SPEED, - .wake_delay = 1500, - .rx_retries = 20 - }; -diff --git a/lib/atcacert/Makefile b/lib/atcacert/Makefile -new file mode 100644 -index 000000000000..aa3e01644e15 ---- /dev/null -+++ b/lib/atcacert/Makefile -@@ -0,0 +1 @@ -+include ../../Makefile.generic -diff --git a/lib/basic/Makefile b/lib/basic/Makefile -new file mode 100644 -index 000000000000..aa3e01644e15 ---- /dev/null -+++ b/lib/basic/Makefile -@@ -0,0 +1 @@ -+include ../../Makefile.generic -diff --git a/lib/crypto/Makefile b/lib/crypto/Makefile -new file mode 100644 -index 000000000000..aa3e01644e15 ---- /dev/null -+++ b/lib/crypto/Makefile -@@ -0,0 +1 @@ -+include ../../Makefile.generic -diff --git a/lib/crypto/hashes/Makefile b/lib/crypto/hashes/Makefile -new file mode 100644 -index 000000000000..0356cb8c0cd5 ---- /dev/null -+++ b/lib/crypto/hashes/Makefile -@@ -0,0 +1 @@ -+include ../../../Makefile.generic -diff --git a/lib/cryptoauthlib.pc b/lib/cryptoauthlib.pc -new file mode 100644 -index 000000000000..001a02c1c341 ---- /dev/null -+++ b/lib/cryptoauthlib.pc -@@ -0,0 +1,11 @@ -+prefix=/usr -+exec_prefix=${prefix} -+libdir=${exec_prefix}/lib -+includedir=${prefix}/include -+ -+Name: cryptoauthlib -+Description: Atmel Cryptochip library for ATECC508A -+Version:1.3 -+ -+Libs: -L${libdir} -lcryptoauth -+Cflags: -I${includedir} -I${includedir}/cryptoauthlib -I${includedir}/cryptoauthlib/tls -diff --git a/lib/hal/Makefile b/lib/hal/Makefile -new file mode 100644 -index 000000000000..aa3e01644e15 ---- /dev/null -+++ b/lib/hal/Makefile -@@ -0,0 +1 @@ -+include ../../Makefile.generic -diff --git a/lib/host/Makefile b/lib/host/Makefile -new file mode 100644 -index 000000000000..aa3e01644e15 ---- /dev/null -+++ b/lib/host/Makefile -@@ -0,0 +1 @@ -+include ../../Makefile.generic -diff --git a/lib/jwt/Makefile b/lib/jwt/Makefile -new file mode 100644 -index 000000000000..aa3e01644e15 ---- /dev/null -+++ b/lib/jwt/Makefile -@@ -0,0 +1 @@ -+include ../../Makefile.generic -diff --git a/lib/tls/Makefile b/lib/tls/Makefile -new file mode 100644 -index 000000000000..aa3e01644e15 ---- /dev/null -+++ b/lib/tls/Makefile -@@ -0,0 +1 @@ -+include ../../Makefile.generic -diff --git a/test/Makefile b/test/Makefile -new file mode 100644 -index 000000000000..5de9ef42a46b ---- /dev/null -+++ b/test/Makefile -@@ -0,0 +1,15 @@ -+LIBNAME= libunity -+LIB= $(LIBNAME).a -+AR+= r -+ -+include ../Makefile.generic -+ -+tgt_local: -+ $(CC) -o unity.o -c unity.c -+ $(AR) $(LIB) unity.o -+ -+ecc-test: tgt_local -+ $(CC) -c ecc-test-main.c $(CFLAGS) -I. -I.. -+ $(CC) -o ecc-test-main ecc-test-main.o ../test/tls/atcatls_tests.o -Lcryptoauthlib/lib -lcryptoauth -Lcryptoauthlib/test -lunity -lm -lc -lrt -+ -+install: ; -diff --git a/test/atcacert/Makefile b/test/atcacert/Makefile -new file mode 100644 -index 000000000000..aa3e01644e15 ---- /dev/null -+++ b/test/atcacert/Makefile -@@ -0,0 +1 @@ -+include ../../Makefile.generic -diff --git a/test/jwt/Makefile b/test/jwt/Makefile -new file mode 100644 -index 000000000000..aa3e01644e15 ---- /dev/null -+++ b/test/jwt/Makefile -@@ -0,0 +1 @@ -+include ../../Makefile.generic -diff --git a/test/sha-byte-test-vectors/Makefile b/test/sha-byte-test-vectors/Makefile -new file mode 100644 -index 000000000000..78d24559879f ---- /dev/null -+++ b/test/sha-byte-test-vectors/Makefile -@@ -0,0 +1 @@ -+empty_target: ; -diff --git a/test/tls/Makefile b/test/tls/Makefile -new file mode 100644 -index 000000000000..aa3e01644e15 ---- /dev/null -+++ b/test/tls/Makefile -@@ -0,0 +1 @@ -+include ../../Makefile.generic diff --git a/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0001-lib-add-parameters-to-be-able-to-modify-default-I2C-.patch b/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0001-lib-add-parameters-to-be-able-to-modify-default-I2C-.patch new file mode 100644 index 000000000..da95dff95 --- /dev/null +++ b/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0001-lib-add-parameters-to-be-able-to-modify-default-I2C-.patch @@ -0,0 +1,63 @@ +From: Gabriel Valcazar +Date: Thu, 31 Oct 2019 11:49:06 +0100 +Subject: [PATCH 1/6] lib: add parameters to be able to modify default I2C bus + index and speed + +https://jira.digi.com/browse/DEL-6826 + +Signed-off-by: Gabriel Valcazar +--- + lib/CMakeLists.txt | 8 ++++++++ + lib/atca_cfgs.c | 15 +++++++++++++-- + 2 files changed, 21 insertions(+), 2 deletions(-) + +diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt +index 9816ed1..b198d1f 100644 +--- a/lib/CMakeLists.txt ++++ b/lib/CMakeLists.txt +@@ -66,6 +66,14 @@ add_definitions(-DATCA_HAL_I2C) + set(CRYPTOAUTH_SRC ${CRYPTOAUTH_SRC} ${TWI_SRC}) + endif(LINUX AND ATCA_HAL_I2C) + ++if(ATCA_HAL_I2C_BUS) ++add_definitions(-DATCA_HAL_I2C_BUS=${ATCA_HAL_I2C_BUS}) ++endif(ATCA_HAL_I2C_BUS) ++ ++if(ATCA_HAL_I2C_SPEED) ++add_definitions(-DATCA_HAL_I2C_SPEED=${ATCA_HAL_I2C_SPEED}) ++endif(ATCA_HAL_I2C_SPEED) ++ + if(ATCA_HAL_CUSTOM) + add_definitions(-DATCA_HAL_CUSTOM) + endif() +diff --git a/lib/atca_cfgs.c b/lib/atca_cfgs.c +index a79e02b..60727f7 100644 +--- a/lib/atca_cfgs.c ++++ b/lib/atca_cfgs.c +@@ -37,13 +37,24 @@ + + /* if the number of these configurations grows large, we can #ifdef them based on required device support */ + ++/* Default I2C configuration */ ++#ifndef ATCA_HAL_I2C_BUS ++#define ATCA_HAL_I2C_BUS 0 ++#warning "Using default value for ATCA_HAL_I2C_BUS: 0" ++#endif ++ ++#ifndef ATCA_HAL_I2C_SPEED ++#define ATCA_HAL_I2C_SPEED 400000 ++#warning "Using default value for ATCA_HAL_I2C_SPEED: 400000" ++#endif ++ + /** \brief default configuration for an ECCx08A device */ + ATCAIfaceCfg cfg_ateccx08a_i2c_default = { + .iface_type = ATCA_I2C_IFACE, + .devtype = ATECC608A, + .atcai2c.slave_address = 0xC0, +- .atcai2c.bus = 1, +- .atcai2c.baud = 400000, ++ .atcai2c.bus = ATCA_HAL_I2C_BUS, ++ .atcai2c.baud = ATCA_HAL_I2C_SPEED, + //.atcai2c.baud = 100000, + .wake_delay = 1500, + .rx_retries = 20 diff --git a/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0002-Remove-unused-HAL-implementations.patch b/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0002-Remove-unused-HAL-implementations.patch deleted file mode 100644 index b9a56fdda..000000000 --- a/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0002-Remove-unused-HAL-implementations.patch +++ /dev/null @@ -1,13459 +0,0 @@ -From: Gabriel Valcazar -Date: Mon, 19 Feb 2018 10:48:50 +0100 -Subject: [PATCH 2/2] Remove unused HAL implementations - -When building the library, all HAL implementations get compiled, leading to -failures due to missing Windows header files. The official README states that -only the necessary HAL implementations should be included in a project, so keep -the Linux userpace I2C HAL and remove everything else. - -https://jira.digi.com/browse/DEL-5591 - -Signed-off-by: Gabriel Valcazar ---- - lib/hal/hal_at90usb1287_i2c_asf.c | 520 ---------------------------- - lib/hal/hal_at90usb1287_i2c_asf.h | 64 ---- - lib/hal/hal_at90usb1287_timer_asf.c | 79 ----- - lib/hal/hal_i2c_bitbang.c | 518 ---------------------------- - lib/hal/hal_i2c_bitbang.h | 78 ----- - lib/hal/hal_linux_kit_cdc.c | 428 ----------------------- - lib/hal/hal_linux_kit_cdc.h | 67 ---- - lib/hal/hal_linux_kit_hid.c | 429 ----------------------- - lib/hal/hal_linux_kit_hid.h | 62 ---- - lib/hal/hal_pic32mx695f512h_i2c.c | 510 --------------------------- - lib/hal/hal_pic32mx695f512h_i2c.h | 74 ---- - lib/hal/hal_pic32mx695f512h_timer.c | 106 ------ - lib/hal/hal_sam4s_i2c_asf.c | 667 ------------------------------------ - lib/hal/hal_sam4s_i2c_asf.h | 67 ---- - lib/hal/hal_sam4s_timer_asf.c | 86 ----- - lib/hal/hal_samb11_i2c_asf.c | 485 -------------------------- - lib/hal/hal_samb11_i2c_asf.h | 60 ---- - lib/hal/hal_samb11_timer_asf.c | 78 ----- - lib/hal/hal_samd21_i2c_asf.c | 572 ------------------------------- - lib/hal/hal_samd21_i2c_asf.h | 63 ---- - lib/hal/hal_samd21_i2c_start.c | 545 ----------------------------- - lib/hal/hal_samd21_i2c_start.h | 64 ---- - lib/hal/hal_samd21_timer_asf.c | 79 ----- - lib/hal/hal_samd21_timer_start.c | 80 ----- - lib/hal/hal_samg55_i2c_asf.c | 661 ----------------------------------- - lib/hal/hal_samg55_i2c_asf.h | 67 ---- - lib/hal/hal_samg55_timer_asf.c | 86 ----- - lib/hal/hal_samv71_i2c_asf.c | 583 ------------------------------- - lib/hal/hal_samv71_i2c_asf.h | 63 ---- - lib/hal/hal_samv71_timer_asf.c | 79 ----- - lib/hal/hal_swi_bitbang.c | 347 ------------------- - lib/hal/hal_swi_bitbang.h | 76 ---- - lib/hal/hal_swi_uart.c | 527 ---------------------------- - lib/hal/hal_swi_uart.h | 62 ---- - lib/hal/hal_win_kit_cdc.c | 556 ------------------------------ - lib/hal/hal_win_kit_cdc.h | 58 ---- - lib/hal/hal_win_kit_hid.c | 469 ------------------------- - lib/hal/hal_win_kit_hid.h | 64 ---- - lib/hal/hal_win_timer.c | 86 ----- - lib/hal/hal_xmega_a3bu_i2c_asf.c | 520 ---------------------------- - lib/hal/hal_xmega_a3bu_i2c_asf.h | 64 ---- - lib/hal/hal_xmega_a3bu_timer_asf.c | 78 ----- - lib/hal/i2c_bitbang_samd21.c | 262 -------------- - lib/hal/i2c_bitbang_samd21.h | 195 ----------- - lib/hal/kit_phy.h | 62 ---- - lib/hal/kit_protocol.c | 430 ----------------------- - lib/hal/kit_protocol.h | 77 ----- - lib/hal/swi_bitbang_samd21.c | 272 --------------- - lib/hal/swi_bitbang_samd21.h | 148 -------- - lib/hal/swi_uart_at90usb1287_asf.c | 260 -------------- - lib/hal/swi_uart_at90usb1287_asf.h | 83 ----- - lib/hal/swi_uart_samd21_asf.c | 238 ------------- - lib/hal/swi_uart_samd21_asf.h | 84 ----- - lib/hal/swi_uart_samd21_start.c | 208 ----------- - lib/hal/swi_uart_samd21_start.h | 80 ----- - lib/hal/swi_uart_xmega_a3bu_asf.c | 258 -------------- - lib/hal/swi_uart_xmega_a3bu_asf.h | 83 ----- - 57 files changed, 12967 deletions(-) - delete mode 100644 lib/hal/hal_at90usb1287_i2c_asf.c - delete mode 100644 lib/hal/hal_at90usb1287_i2c_asf.h - delete mode 100644 lib/hal/hal_at90usb1287_timer_asf.c - delete mode 100644 lib/hal/hal_i2c_bitbang.c - delete mode 100644 lib/hal/hal_i2c_bitbang.h - delete mode 100644 lib/hal/hal_linux_kit_cdc.c - delete mode 100644 lib/hal/hal_linux_kit_cdc.h - delete mode 100644 lib/hal/hal_linux_kit_hid.c - delete mode 100644 lib/hal/hal_linux_kit_hid.h - delete mode 100644 lib/hal/hal_pic32mx695f512h_i2c.c - delete mode 100644 lib/hal/hal_pic32mx695f512h_i2c.h - delete mode 100644 lib/hal/hal_pic32mx695f512h_timer.c - delete mode 100644 lib/hal/hal_sam4s_i2c_asf.c - delete mode 100644 lib/hal/hal_sam4s_i2c_asf.h - delete mode 100644 lib/hal/hal_sam4s_timer_asf.c - delete mode 100644 lib/hal/hal_samb11_i2c_asf.c - delete mode 100644 lib/hal/hal_samb11_i2c_asf.h - delete mode 100644 lib/hal/hal_samb11_timer_asf.c - delete mode 100644 lib/hal/hal_samd21_i2c_asf.c - delete mode 100644 lib/hal/hal_samd21_i2c_asf.h - delete mode 100644 lib/hal/hal_samd21_i2c_start.c - delete mode 100644 lib/hal/hal_samd21_i2c_start.h - delete mode 100644 lib/hal/hal_samd21_timer_asf.c - delete mode 100644 lib/hal/hal_samd21_timer_start.c - delete mode 100644 lib/hal/hal_samg55_i2c_asf.c - delete mode 100644 lib/hal/hal_samg55_i2c_asf.h - delete mode 100644 lib/hal/hal_samg55_timer_asf.c - delete mode 100644 lib/hal/hal_samv71_i2c_asf.c - delete mode 100644 lib/hal/hal_samv71_i2c_asf.h - delete mode 100644 lib/hal/hal_samv71_timer_asf.c - delete mode 100644 lib/hal/hal_swi_bitbang.c - delete mode 100644 lib/hal/hal_swi_bitbang.h - delete mode 100644 lib/hal/hal_swi_uart.c - delete mode 100644 lib/hal/hal_swi_uart.h - delete mode 100644 lib/hal/hal_win_kit_cdc.c - delete mode 100644 lib/hal/hal_win_kit_cdc.h - delete mode 100644 lib/hal/hal_win_kit_hid.c - delete mode 100644 lib/hal/hal_win_kit_hid.h - delete mode 100644 lib/hal/hal_win_timer.c - delete mode 100644 lib/hal/hal_xmega_a3bu_i2c_asf.c - delete mode 100644 lib/hal/hal_xmega_a3bu_i2c_asf.h - delete mode 100644 lib/hal/hal_xmega_a3bu_timer_asf.c - delete mode 100644 lib/hal/i2c_bitbang_samd21.c - delete mode 100644 lib/hal/i2c_bitbang_samd21.h - delete mode 100644 lib/hal/kit_phy.h - delete mode 100644 lib/hal/kit_protocol.c - delete mode 100644 lib/hal/kit_protocol.h - delete mode 100644 lib/hal/swi_bitbang_samd21.c - delete mode 100644 lib/hal/swi_bitbang_samd21.h - delete mode 100644 lib/hal/swi_uart_at90usb1287_asf.c - delete mode 100644 lib/hal/swi_uart_at90usb1287_asf.h - delete mode 100644 lib/hal/swi_uart_samd21_asf.c - delete mode 100644 lib/hal/swi_uart_samd21_asf.h - delete mode 100644 lib/hal/swi_uart_samd21_start.c - delete mode 100644 lib/hal/swi_uart_samd21_start.h - delete mode 100644 lib/hal/swi_uart_xmega_a3bu_asf.c - delete mode 100644 lib/hal/swi_uart_xmega_a3bu_asf.h - -diff --git a/lib/hal/hal_at90usb1287_i2c_asf.c b/lib/hal/hal_at90usb1287_i2c_asf.c -deleted file mode 100644 -index 878d82e48470..000000000000 ---- a/lib/hal/hal_at90usb1287_i2c_asf.c -+++ /dev/null -@@ -1,520 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for AT90USB1287 I2C over ASF drivers. -- * -- * Prerequisite: Add I2C Master Polled/Interrupt support to application in Atmel Studio -- * this HAL implementation assumes you've included the ASF I2C libraries in your project, otherwise, -- * the HAL layer will not compile because the ASF I2C drivers are a dependency -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include --#include "atca_hal.h" --#include "hal_at90usb1287_i2c_asf.h" --#include "atca_device.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * using I2C driver of ASF. -- * -- @{ */ -- --/** \brief logical to physical bus mapping structure */ --ATCAI2CMaster_t *i2c_hal_data[MAX_I2C_BUSES]; // map logical, 0-based bus number to index --int i2c_bus_ref_ct = 0; // total in-use count across buses --static twi_master_options_t config_i2c_master; -- -- --/** \brief discover i2c buses available for this hardware -- * this maintains a list of logical to physical bus mappings freeing the application -- * of the prior knowledge -- * \param[in] i2c_buses - an array of logical bus numbers -- * \param[in] max_buses - maximum number of buses the app wants to attempt to discover -- * \return ATCA_SUCCESS -- */ -- --ATCA_STATUS hal_i2c_discover_buses(int i2c_buses[], int max_buses) --{ -- -- // if every PORT was a likely candidate bus, then would need to initialize the entire array to all PORT n numbers. -- // As an optimization and making discovery safer, make assumptions about bus-num / PORT map based on AT90USB1287 -- // If you were using a raw XMEGA on your own board, you would supply your own bus numbers based on your particular hardware configuration. -- // -- -- i2c_buses[0] = 0; /* AT90USB1287 has only one I2C Port */ -- -- return ATCA_SUCCESS; --} -- --/** \brief discover any CryptoAuth devices on a given logical bus number -- * \param[in] busNum - logical bus number on which to look for CryptoAuth devices -- * \param[out] cfg[] - pointer to head of an array of interface config structures which get filled in by this method -- * \param[out] *found - number of devices found on this bus -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_discover_devices(int busNum, ATCAIfaceCfg cfg[], int *found) --{ -- ATCAIfaceCfg *head = cfg; -- uint8_t slaveAddress = 0x01; -- ATCADevice device; -- ATCAIface discoverIface; -- ATCACommand command; -- ATCAPacket packet; -- ATCA_STATUS status; -- uint8_t revs508[1][4] = { { 0x00, 0x00, 0x50, 0x00 } }; -- uint8_t revs108[1][4] = { { 0x80, 0x00, 0x10, 0x01 } }; -- uint8_t revs204[3][4] = { { 0x00, 0x02, 0x00, 0x08 }, -- { 0x00, 0x02, 0x00, 0x09 }, -- { 0x00, 0x04, 0x05, 0x00 } }; -- int i; -- -- /** default configuration, to be reused during discovery process */ -- ATCAIfaceCfg discoverCfg = { -- .iface_type = ATCA_I2C_IFACE, -- .devtype = ATECC508A, -- .atcai2c.slave_address = 0x07, -- .atcai2c.bus = busNum, -- .atcai2c.baud = 400000, -- .wake_delay = 800, -- .rx_retries = 3 -- }; -- -- // build an info command -- packet.param1 = INFO_MODE_REVISION; -- packet.param2 = 0; -- -- device = newATCADevice(&discoverCfg); -- discoverIface = atGetIFace(device); -- command = atGetCommands(device); -- -- // iterate through all addresses on given i2c bus -- // all valid 7-bit addresses go from 0x07 to 0x78 -- for (slaveAddress = 0x08; slaveAddress <= 0x77; slaveAddress++) -- { -- discoverCfg.atcai2c.slave_address = slaveAddress << 1; // turn it into an 8-bit address which is what the rest of the i2c HAL is expecting when a packet is sent -- -- // wake up device -- // If it wakes, send it a dev rev command. Based on that response, determine the device type -- // BTW - this will wake every cryptoauth device living on the same bus (ecc508a, sha204a) -- -- if (hal_i2c_wake(discoverIface) == ATCA_SUCCESS) -- { -- (*found)++; -- memcpy( (uint8_t*)head, (uint8_t*)&discoverCfg, sizeof(ATCAIfaceCfg)); -- -- memset(packet.data, 0x00, sizeof(packet.data)); -- -- // get devrev info and set device type accordingly -- atInfo(command, &packet); -- if ((status = atGetExecTime(packet.opcode, command)) != ATCA_SUCCESS) -- { -- continue; -- } -- -- // send the command -- if ( (status = atsend(discoverIface, (uint8_t*)&packet, packet.txsize)) != ATCA_SUCCESS) -- { -- printf("packet send error\r\n"); -- continue; -- } -- -- // delay the appropriate amount of time for command to execute -- atca_delay_ms((command->execution_time_msec) + 1); -- -- // receive the response -- if ( (status = atreceive(discoverIface, &(packet.data[0]), &(packet.rxsize) )) != ATCA_SUCCESS) -- { -- continue; -- } -- -- if ( (status = isATCAError(packet.data)) != ATCA_SUCCESS) -- { -- printf("command response error\r\n"); -- continue; -- } -- -- // determine device type from common info and dev rev response byte strings -- for (i = 0; i < sizeof(revs508) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs508[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC508A; -- break; -- } -- } -- -- for (i = 0; i < sizeof(revs204) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs204[i], 4) == 0) -- { -- discoverCfg.devtype = ATSHA204A; -- break; -- } -- } -- -- for (i = 0; i < sizeof(revs108) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs108[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC108A; -- break; -- } -- } -- -- atca_delay_ms(15); -- // now the device type is known, so update the caller's cfg array element with it -- head->devtype = discoverCfg.devtype; -- head++; -- } -- -- hal_i2c_idle(discoverIface); -- } -- -- deleteATCADevice(&device); -- -- return ATCA_SUCCESS; --} -- -- -- -- --/** \brief hal_i2c_init manages requests to initialize a physical interface. it manages use counts so when an interface -- * has released the physical layer, it will disable the interface for some other use. -- * You can have multiple ATCAIFace instances using the same bus, and you can have multiple ATCAIFace instances on -- * multiple i2c buses, so hal_i2c_init manages these things and ATCAIFace is abstracted from the physical details. -- */ -- --/** \brief initialize an I2C interface using given config -- * \param[in] hal - opaque ptr to HAL data -- * \param[in] cfg - pointer to interface configuration -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_init(void *hal, ATCAIfaceCfg *cfg) --{ -- int bus = cfg->atcai2c.bus; // 0-based logical bus number -- ATCAHAL_t *phal = (ATCAHAL_t*)hal; -- -- if (i2c_bus_ref_ct == 0) // power up state, no i2c buses will have been used -- { -- for (int i = 0; i < MAX_I2C_BUSES; i++) -- { -- i2c_hal_data[i] = NULL; -- } -- } -- -- i2c_bus_ref_ct++; // total across buses -- -- if (bus >= 0 && bus < MAX_I2C_BUSES) -- { -- // if this is the first time this bus and interface has been created, do the physical work of enabling it -- if (i2c_hal_data[bus] == NULL) -- { -- i2c_hal_data[bus] = malloc(sizeof(ATCAI2CMaster_t) ); -- i2c_hal_data[bus]->ref_ct = 1; // buses are shared, this is the first instance -- -- config_i2c_master.speed = cfg->atcai2c.baud; -- config_i2c_master.chip = 0x50; -- config_i2c_master.baud_reg = TWI_CLOCK_RATE(sysclk_get_cpu_hz(), cfg->atcai2c.baud); -- -- i2c_hal_data[bus]->i2c_master_instance = (int*)&TWBR; -- -- sysclk_enable_peripheral_clock((i2c_hal_data[bus]->i2c_master_instance)); -- twi_master_init((i2c_hal_data[bus]->i2c_master_instance), &config_i2c_master); -- -- // store this for use during the release phase -- i2c_hal_data[bus]->bus_index = bus; -- } -- else -- { -- // otherwise, another interface already initialized the bus, so this interface will share it and any different -- // cfg parameters will be ignored...first one to initialize this sets the configuration -- i2c_hal_data[bus]->ref_ct++; -- } -- -- phal->hal_data = i2c_hal_data[bus]; -- -- return ATCA_SUCCESS; -- } -- -- return ATCA_COMM_FAIL; --} -- --/** \brief HAL implementation of I2C post init -- * \param[in] iface instance -- * \return ATCA_STATUS -- */ --ATCA_STATUS hal_i2c_post_init(ATCAIface iface) --{ -- return ATCA_SUCCESS; --} -- --/** \brief HAL implementation of I2C send over ASF -- * \param[in] iface instance -- * \param[in] txdata pointer to space to bytes to send -- * \param[in] txlength number of bytes to send -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_send(ATCAIface iface, uint8_t *txdata, int txlength) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- -- twi_package_t packet = { -- .addr_length = 0, // TWI slave memory address data size -- .chip = cfg->atcai2c.slave_address, // TWI slave bus address -- .buffer = txdata, // transfer data source buffer -- .length = txlength, // transfer data size (bytes) -- }; -- -- // for this implementation of I2C with CryptoAuth chips, txdata is assumed to have ATCAPacket format -- -- // other device types that don't require i/o tokens on the front end of a command need a different hal_i2c_send and wire it up instead of this one -- // this covers devices such as ATSHA204A and ATECCx08A that require a word address value pre-pended to the packet -- // txdata[0] is using _reserved byte of the ATCAPacket -- txdata[0] = 0x03; // insert the Word Address Value, Command token -- txlength++; // account for word address value byte. -- packet.length = txlength; -- -- if (twi_master_write(i2c_hal_data[bus]->i2c_master_instance, &packet) != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** \brief HAL implementation of I2C receive function for ASF I2C -- * \param[in] iface instance -- * \param[in] rxdata pointer to space to receive the data -- * \param[in] rxlength ptr to expected number of receive bytes to request -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_receive(ATCAIface iface, uint8_t *rxdata, uint16_t *rxlength) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- int retries = cfg->rx_retries; -- int status = !STATUS_OK; -- -- twi_package_t packet = { -- .addr_length = 0, // TWI slave memory address data size -- .chip = cfg->atcai2c.slave_address, // TWI slave bus address -- .buffer = rxdata, // transfer data source buffer -- .length = *rxlength, // transfer data size (bytes) -- }; -- -- while (retries-- > 0 && status != STATUS_OK) -- { -- status = twi_master_read(i2c_hal_data[bus]->i2c_master_instance, &packet); -- } -- -- if (status != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** \brief method to change the bus speed of I2C -- * \param[in] iface interface on which to change bus speed -- * \param[in] speed baud rate (typically 100000 or 400000) -- */ -- --void change_i2c_speed(ATCAIface iface, uint32_t speed) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- -- config_i2c_master.speed = speed; -- config_i2c_master.baud_reg = TWI_CLOCK_RATE(sysclk_get_cpu_hz(), speed); -- -- /*twi_reset();*/ -- -- twi_master_init((i2c_hal_data[bus]->i2c_master_instance), &config_i2c_master); --} -- --/** \brief wake up CryptoAuth device using I2C bus -- * \param[in] iface interface to logical device to wakeup -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_wake(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- int retries = cfg->rx_retries; -- uint32_t bdrt = cfg->atcai2c.baud; -- int status = !STATUS_OK; -- uint8_t data[4], expected[4] = { 0x04, 0x11, 0x33, 0x43 }; -- -- if (bdrt != 100000) // if not already at 100KHz, change it -- { -- change_i2c_speed(iface, 100000); -- } -- -- // Send the wake by writing to an address of 0x00 -- twi_package_t packet = { -- .addr_length = 0, // TWI slave memory address data size -- .chip = 0x00, // TWI slave bus address -- .buffer = &data[0], // transfer data source buffer -- .length = 0 // transfer data size (bytes) -- }; -- -- -- // Send the 00 address as the wake pulse -- twi_master_write(i2c_hal_data[bus]->i2c_master_instance, &packet); // part will NACK, so don't check for status -- -- atca_delay_us(cfg->wake_delay); // wait tWHI + tWLO which is configured based on device type and configuration structure -- -- packet.chip = cfg->atcai2c.slave_address; -- packet.length = 4; -- packet.buffer = data; -- -- while (retries-- > 0 && status != STATUS_OK) -- { -- status = twi_master_read(i2c_hal_data[bus]->i2c_master_instance, &packet); -- } -- -- if (status != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- // if necessary, revert baud rate to what came in. -- if (bdrt != 100000) -- { -- change_i2c_speed(iface, bdrt); -- } -- -- if (memcmp(data, expected, 4) == 0) -- { -- return ATCA_SUCCESS; -- } -- -- return ATCA_COMM_FAIL; --} -- --/** \brief idle CryptoAuth device using I2C bus -- * \param[in] iface interface to logical device to idle -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_idle(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- uint8_t data[4]; -- -- twi_package_t packet = { -- .addr_length = 0, // TWI slave memory address data size -- .chip = cfg->atcai2c.slave_address, // TWI slave bus address -- .buffer = &data[0], // transfer data source buffer -- .length = 1 // transfer data size (bytes) -- }; -- -- data[0] = 0x02; // idle word address value -- if (twi_master_write((i2c_hal_data[bus]->i2c_master_instance), &packet) != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; -- --} -- --/** \brief sleep CryptoAuth device using I2C bus -- * \param[in] iface interface to logical device to sleep -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_sleep(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- uint8_t data[4]; -- -- twi_package_t packet = { -- .addr_length = 0, // TWI slave memory address data size -- .chip = cfg->atcai2c.slave_address, // TWI slave bus address -- .buffer = &data[0], // transfer data source buffer -- .length = 1 // transfer data size (bytes) -- }; -- -- data[0] = 0x01; // sleep word address value -- if (twi_master_write((i2c_hal_data[bus]->i2c_master_instance), &packet) != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** \brief manages reference count on given bus and releases resource if no more refences exist -- * \param[in] hal_data - opaque pointer to hal data structure - known only to the HAL implementation -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_release(void *hal_data) --{ -- ATCAI2CMaster_t *hal = (ATCAI2CMaster_t*)hal_data; -- -- -- if (i2c_bus_ref_ct > 0) -- { -- i2c_bus_ref_ct--; // track total i2c bus interface instances for consistency checking and debugging -- } -- else -- { -- return ATCA_EXECUTION_ERROR; -- } -- -- if (hal->ref_ct <= 0) -- { -- return ATCA_EXECUTION_ERROR; -- } -- -- // if the use count for this bus has gone to 0 references, disable it. protect against an unbracketed release -- if (hal && --(hal->ref_ct) <= 0 && i2c_hal_data[hal->bus_index] != NULL) -- { -- twi_reset(); -- free(i2c_hal_data[hal->bus_index]); -- i2c_hal_data[hal->bus_index] = NULL; -- } -- -- return ATCA_SUCCESS; --} -- --/** @} */ -diff --git a/lib/hal/hal_at90usb1287_i2c_asf.h b/lib/hal/hal_at90usb1287_i2c_asf.h -deleted file mode 100644 -index 82ef65e314e7..000000000000 ---- a/lib/hal/hal_at90usb1287_i2c_asf.h -+++ /dev/null -@@ -1,64 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for AT90USB1287 I2C over ASF drivers. -- * -- * Prerequisite: add I2C Master Polled support to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef HAL_AT90USB1287_I2C_ASF_H_ --#define HAL_AT90USB1287_I2C_ASF_H_ -- --#include --#include "twi_megarf.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * using I2C driver of ASF. -- * -- @{ */ -- -- --#define MAX_I2C_BUSES 1 // AT90USB1287 has only 1 PORT that can be configured as I2C -- --/** \brief this is the hal_data for ATCA HAL created using ASF -- */ --typedef struct atcaI2Cmaster --{ -- /*twi_master_t*/ int* i2c_master_instance; -- int ref_ct; -- // for conveniences during interface release phase -- int bus_index; --} ATCAI2CMaster_t; -- --void change_i2c_speed(ATCAIface iface, uint32_t speed); -- --/** @} */ --#endif /* HAL_AT90USB1287_I2C_ASF_H_ */ -\ No newline at end of file -diff --git a/lib/hal/hal_at90usb1287_timer_asf.c b/lib/hal/hal_at90usb1287_timer_asf.c -deleted file mode 100644 -index bd6260f5b11a..000000000000 ---- a/lib/hal/hal_at90usb1287_timer_asf.c -+++ /dev/null -@@ -1,79 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for AT90USB1287 timer/delay over ASF drivers. -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include "atca_hal.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- -- --/** \brief This function delays for a number of microseconds. -- * -- * \param[in] delay number of microseconds to delay -- */ --void atca_delay_us(uint32_t delay) --{ -- // use ASF supplied delay -- delay_us(delay); --} -- --/** \brief This function delays for a number of tens of microseconds. -- * -- * \param[in] delay number of 0.01 milliseconds to delay -- */ --void atca_delay_10us(uint32_t delay) --{ -- // use ASF supplied delay -- delay_us(delay * 10); -- --} -- --/** \brief This function delays for a number of milliseconds. -- * -- * You can override this function if you like to do -- * something else in your system while delaying. -- * \param[in] delay number of milliseconds to delay -- */ -- --/* ASF already has delay_ms - see delay.h */ --void atca_delay_ms(uint32_t delay) --{ -- // use ASF supplied delay -- delay_ms(delay); --} -- --/** @} */ -diff --git a/lib/hal/hal_i2c_bitbang.c b/lib/hal/hal_i2c_bitbang.c -deleted file mode 100644 -index d25cc9887e03..000000000000 ---- a/lib/hal/hal_i2c_bitbang.c -+++ /dev/null -@@ -1,518 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for I2C bit banging. -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include --#include "atca_hal.h" --#include "atca_device.h" --#include "hal_i2c_bitbang.h" -- -- --/** -- * \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief These methods define the hardware abstraction layer for -- * communicating with a CryptoAuth device using I2C bit banging. -- @{ */ -- --/** -- * \brief Logical to physical bus mapping structure. -- */ --ATCAI2CMaster_t *i2c_hal_data[MAX_I2C_BUSES]; //!< map logical, 0-based bus number to index --int i2c_bus_ref_ct = 0; //!< total in-use count across buses -- -- --/** \brief discover i2c buses available for this hardware -- * this maintains a list of logical to physical bus mappings freeing the application -- * of the prior knowledge -- * \param[in] i2c_buses - an array of logical bus numbers -- * \param[in] max_buses - maximum number of buses the app wants to attempt to discover -- * \return ATCA_SUCCESS -- */ -- --ATCA_STATUS hal_i2c_discover_buses(int i2c_buses[], int max_buses) --{ -- -- i2c_discover_buses(i2c_buses, max_buses); -- -- return ATCA_SUCCESS; -- --} -- -- --/** \brief discover any CryptoAuth devices on a given logical bus number -- * \param[in] busNum - logical bus number on which to look for CryptoAuth devices -- * \param[out] cfg[] - pointer to head of an array of interface config structures which get filled in by this method -- * \param[out] *found - number of devices found on this bus -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_discover_devices(int busNum, ATCAIfaceCfg cfg[], int *found) --{ -- ATCAIfaceCfg *head = cfg; -- uint8_t slaveAddress = 0x01; -- ATCADevice device; -- ATCAIface discoverIface; -- ATCACommand command; -- ATCAPacket packet; -- ATCA_STATUS status; -- uint8_t revs508[1][4] = { { 0x00, 0x00, 0x50, 0x00 } }; -- uint8_t revs108[1][4] = { { 0x80, 0x00, 0x10, 0x01 } }; -- uint8_t revs204[3][4] = { { 0x00, 0x02, 0x00, 0x08 }, -- { 0x00, 0x02, 0x00, 0x09 }, -- { 0x00, 0x04, 0x05, 0x00 } }; -- int i; -- -- /** \brief default configuration, to be reused during discovery process */ -- ATCAIfaceCfg discoverCfg = { -- .iface_type = ATCA_I2C_IFACE, -- .devtype = ATECC508A, -- .atcai2c.slave_address = 0x07, -- .atcai2c.bus = busNum, -- .atcai2c.baud = 400000, -- //.atcai2c.baud = 100000, -- .wake_delay = 800, -- .rx_retries = 3 -- }; -- -- ATCAHAL_t hal; -- -- hal_i2c_init(&hal, &discoverCfg); -- device = newATCADevice(&discoverCfg); -- discoverIface = atGetIFace(device); -- command = atGetCommands(device); -- -- // iterate through all addresses on given i2c bus -- // all valid 7-bit addresses go from 0x07 to 0x78 -- for (slaveAddress = 0x07; slaveAddress <= 0x78; slaveAddress++) -- { -- discoverCfg.atcai2c.slave_address = slaveAddress << 1; // turn it into an 8-bit address which is what the rest of the i2c HAL is expecting when a packet is sent -- -- // wake up device -- // If it wakes, send it a dev rev command. Based on that response, determine the device type -- // BTW - this will wake every cryptoauth device living on the same bus (ecc508a, sha204a) -- -- if (hal_i2c_wake(discoverIface) == ATCA_SUCCESS) -- { -- (*found)++; -- memcpy( (uint8_t*)head, (uint8_t*)&discoverCfg, sizeof(ATCAIfaceCfg)); -- -- memset(packet.data, 0x00, sizeof(packet.data)); -- -- // get devrev info and set device type accordingly -- atInfo(command, &packet); -- if ((status = atGetExecTime(packet.opcode, command)) != ATCA_SUCCESS) -- { -- continue; -- } -- -- // send the command -- if ( (status = atsend(discoverIface, (uint8_t*)&packet, packet.txsize)) != ATCA_SUCCESS) -- { -- printf("packet send error\r\n"); -- continue; -- } -- -- // delay the appropriate amount of time for command to execute -- atca_delay_ms((command->execution_time_msec) + 1); -- -- // receive the response -- if ( (status = atreceive(discoverIface, &(packet.data[0]), &(packet.rxsize) )) != ATCA_SUCCESS) -- { -- continue; -- } -- -- if ( (status = isATCAError(packet.data)) != ATCA_SUCCESS) -- { -- printf("command response error\r\n"); -- continue; -- } -- -- // determine device type from common info and dev rev response byte strings -- for (i = 0; i < (int)sizeof(revs508) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs508[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC508A; -- break; -- } -- } -- -- for (i = 0; i < (int)sizeof(revs204) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs204[i], 4) == 0) -- { -- discoverCfg.devtype = ATSHA204A; -- break; -- } -- } -- -- for (i = 0; i < (int)sizeof(revs108) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs108[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC108A; -- break; -- } -- } -- -- atca_delay_ms(15); -- // now the device type is known, so update the caller's cfg array element with it -- head->devtype = discoverCfg.devtype; -- head++; -- } -- -- hal_i2c_idle(discoverIface); -- } -- -- hal_i2c_release(&hal); -- -- return ATCA_SUCCESS; --} -- --/** -- * \brief This function creates a Start condition and sends the I2C -- * address. -- * -- * \param[in] RorW I2C_READ for reading, I2C_WRITE for writing. -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --static ATCA_STATUS hal_i2c_send_slave_address(ATCAIface iface, uint8_t RorW) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- -- ATCA_STATUS status = ATCA_TX_TIMEOUT; -- -- uint8_t sla = cfg->atcai2c.slave_address | RorW; -- -- i2c_send_start(); -- -- status = i2c_send_byte(sla); -- if (status != ATCA_SUCCESS) -- { -- i2c_send_stop(); -- } -- -- return status; --} -- --/** -- * \brief hal_i2c_init manages requests to initialize a physical -- * interface. It manages use counts so when an interface has -- * released the physical layer, it will disable the interface for -- * some other use. You can have multiple ATCAIFace instances using -- * the same bus, and you can have multiple ATCAIFace instances on -- * multiple i2c buses, so hal_i2c_init manages these things and -- * ATCAIFace is abstracted from the physical details. -- */ -- --/** -- * \brief Initialize an I2C interface using given config. -- * -- * \param[in] hal opaque pointer to HAL data -- * \param[in] cfg interface configuration -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_init(void *hal, ATCAIfaceCfg *cfg) --{ -- ATCAHAL_t *phal = (ATCAHAL_t*)hal; -- -- int bus = cfg->atcai2c.bus; //!< 0-based logical bus number -- -- if (i2c_bus_ref_ct == 0) //!< power up state, no i2c buses will have been used -- -- { -- for (int i = 0; i < MAX_I2C_BUSES; i++) -- { -- i2c_hal_data[i] = NULL; -- } -- } -- -- i2c_bus_ref_ct++; //!< total across buses -- -- if (bus >= 0 && bus < MAX_I2C_BUSES) -- { -- //! if this is the first time this bus and interface has been created, do the physical work of enabling it -- if (i2c_hal_data[bus] == NULL) -- { -- i2c_hal_data[bus] = malloc(sizeof(ATCAI2CMaster_t)); -- i2c_hal_data[bus]->ref_ct = 1; //!< buses are shared, this is the first instance -- -- //! assign GPIO pins -- i2c_hal_data[bus]->pin_sda = i2c_buses_default.pin_sda[bus]; -- i2c_hal_data[bus]->pin_scl = i2c_buses_default.pin_scl[bus]; -- -- i2c_set_pin(i2c_hal_data[bus]->pin_sda, i2c_hal_data[bus]->pin_scl); -- i2c_enable(); -- -- //! store this for use during the release phase -- i2c_hal_data[bus]->bus_index = bus; -- } -- else -- { -- //! otherwise, another interface already initialized the bus, so this interface will share it and any different -- //! cfg parameters will be ignored...first one to initialize this sets the configuration -- i2c_hal_data[bus]->ref_ct++; -- } -- -- phal->hal_data = i2c_hal_data[bus]; -- -- return ATCA_SUCCESS; -- } -- -- return ATCA_COMM_FAIL; --} -- -- -- --/** \brief HAL implementation of I2C post init -- * \param[in] iface instance -- * \return ATCA_STATUS -- */ --ATCA_STATUS hal_i2c_post_init(ATCAIface iface) --{ -- return ATCA_SUCCESS; --} -- --/** -- * \brief HAL implementation of Send byte(s) via I2C. -- * -- * \param[in] iface interface of the logical device to send data to -- * \param[in] txdata pointer to bytes to send -- * \param[in] txlength number of bytes to send -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_send(ATCAIface iface, uint8_t *txdata, int txlength) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- -- ATCA_STATUS status = ATCA_TX_TIMEOUT; -- -- int bus = cfg->atcai2c.bus; -- -- txdata[0] = 0x03; //!< Word Address Value = Command -- txlength++; //!< count Word Address byte towards txlength -- -- //! Set I2C pins -- i2c_set_pin(i2c_hal_data[bus]->pin_sda, i2c_hal_data[bus]->pin_scl); -- -- do -- { -- //! Address the device and indicate that bytes are to be written -- status = hal_i2c_send_slave_address(iface, I2C_WRITE); -- if (status != ATCA_SUCCESS) -- { -- break; -- } -- -- //! Send the remaining bytes -- status = i2c_send_bytes(txlength, txdata); -- } -- while (0); -- -- //! Send STOP regardless of i2c_status -- i2c_send_stop(); -- -- return status; --} -- --/** -- * \brief HAL implementation of Receive byte(s) via I2C. -- * -- * \param[in] iface interface of the logical device to receive data -- * from -- * \param[in] rxdata pointer to where bytes will be received -- * \param[in] rxlength pointer to expected number of receive bytes to -- * request -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_receive(ATCAIface iface, uint8_t *rxdata, uint16_t *rxlength) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- -- ATCA_STATUS status = ATCA_RX_TIMEOUT; -- -- int bus = cfg->atcai2c.bus; -- int retries = cfg->rx_retries; -- uint8_t count; -- -- //! Set I2C pins -- i2c_set_pin(i2c_hal_data[bus]->pin_sda, i2c_hal_data[bus]->pin_scl); -- -- while (retries-- > 0 && status != ATCA_SUCCESS) -- { -- //! Address the device and indicate that bytes are to be read -- status = hal_i2c_send_slave_address(iface, I2C_READ); -- if (status == ATCA_SUCCESS) -- { -- //! Receive count byte -- i2c_receive_byte(rxdata); -- count = rxdata[0]; -- if ((count < ATCA_RSP_SIZE_MIN) || (count > *rxlength)) -- { -- i2c_send_stop(); -- status = ATCA_INVALID_SIZE; -- break; -- } -- -- //! Receive the remaining bytes -- i2c_receive_bytes(count - 1, &rxdata[1]); -- } -- } -- if (status == ATCA_TX_TIMEOUT) -- { -- status = ATCA_RX_NO_RESPONSE; -- } -- -- return status; --} -- -- --/** \brief wake up CryptoAuth device using I2C bus -- * \param[in] iface interface to logical device to wakeup -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_wake(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- -- ATCA_STATUS status = ATCA_WAKE_FAILED; -- -- int bus = cfg->atcai2c.bus; -- uint8_t response[4] = { 0x00, 0x00, 0x00, 0x00 }; -- uint8_t expected_response[4] = { 0x04, 0x11, 0x33, 0x43 }; -- uint16_t response_size = sizeof(response); -- -- //! Set I2C pins -- i2c_set_pin(i2c_hal_data[bus]->pin_sda, i2c_hal_data[bus]->pin_scl); -- -- //! Generate Wake Token -- i2c_send_wake_token(); -- -- //! Wait tWHI + tWLO -- atca_delay_us(cfg->wake_delay); -- -- //! Receive Wake Response -- status = hal_i2c_receive(iface, response, &response_size); -- if (status == ATCA_SUCCESS) -- { -- //! Compare response with expected_response -- if (memcmp(response, expected_response, 4) != 0) -- { -- status = ATCA_WAKE_FAILED; -- } -- } -- -- return status; --} -- --/** \brief idle CryptoAuth device using I2C bus -- * \param[in] iface interface to logical device to idle -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_idle(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- -- ATCA_STATUS status = ATCA_TX_TIMEOUT; -- -- int bus = cfg->atcai2c.bus; -- -- //! Set I2C pins -- i2c_set_pin(i2c_hal_data[bus]->pin_sda, i2c_hal_data[bus]->pin_scl); -- -- //! Address the device and indicate that bytes are to be written -- status = hal_i2c_send_slave_address(iface, I2C_WRITE); -- if (status == ATCA_SUCCESS) -- { -- status = i2c_send_byte(0x02); //!< Word Address Value = Idle -- i2c_send_stop(); -- } -- -- return status; --} -- --/** \brief sleep CryptoAuth device using I2C bus -- * \param[in] iface interface to logical device to sleep -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_sleep(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- -- ATCA_STATUS status = ATCA_TX_TIMEOUT; -- -- int bus = cfg->atcai2c.bus; -- -- //! Set I2C pins -- i2c_set_pin(i2c_hal_data[bus]->pin_sda, i2c_hal_data[bus]->pin_scl); -- -- //! Address the device and indicate that bytes are to be written -- status = hal_i2c_send_slave_address(iface, I2C_WRITE); -- if (status == ATCA_SUCCESS) -- { -- status = i2c_send_byte(0x01); //!< Word Address Value = Sleep -- i2c_send_stop(); -- } -- -- return status; --} -- --/** \brief manages reference count on given bus and releases resource if no more refences exist -- * \param[in] hal_data - opaque pointer to hal data structure - known only to the HAL implementation -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_release(void *hal_data) --{ -- ATCAI2CMaster_t *hal = (ATCAI2CMaster_t*)hal_data; -- -- i2c_bus_ref_ct--; // track total i2c bus interface instances for consistency checking and debugging -- -- // if the use count for this bus has gone to 0 references, disable it. protect against an unbracketed release -- if (hal && --(hal->ref_ct) <= 0 && i2c_hal_data[hal->bus_index] != NULL) -- { -- i2c_set_pin(i2c_hal_data[hal->bus_index]->pin_sda, i2c_hal_data[hal->bus_index]->pin_scl); -- i2c_disable(); -- free(i2c_hal_data[hal->bus_index]); -- i2c_hal_data[hal->bus_index] = NULL; -- } -- -- return ATCA_SUCCESS; --} -- --/** @} */ -\ No newline at end of file -diff --git a/lib/hal/hal_i2c_bitbang.h b/lib/hal/hal_i2c_bitbang.h -deleted file mode 100644 -index 02b33f83babf..000000000000 ---- a/lib/hal/hal_i2c_bitbang.h -+++ /dev/null -@@ -1,78 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for I2C bit banging. -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef HAL_I2C_BITBANG_H_ --#define HAL_I2C_BITBANG_H_ -- -- -- -- -- --#if BOARD == AT88CK9000 --# include "i2c_bitbang_at88ck9000.h" --#endif -- --#if (SAMD21 == 1) --#include "i2c_bitbang_samd21.h" --#endif -- -- --/** -- * \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief These methods define the hardware abstraction layer for -- * communicating with a CryptoAuth device using I2C bit banging. -- @{ */ -- --/** -- * \brief This enumeration lists flags for I2C read or write addressing. -- */ --enum i2c_read_write_flag --{ -- I2C_WRITE = (uint8_t)0x00, //!< write command flag -- I2C_READ = (uint8_t)0x01 //!< read command flag --}; -- --/** -- * \brief This is the hal_data for ATCA HAL. -- */ --typedef struct atcaI2Cmaster --{ -- uint32_t pin_sda; -- uint32_t pin_scl; -- int ref_ct; -- //! for conveniences during interface release phase -- int bus_index; --} ATCAI2CMaster_t; -- --/** @} */ -- --#endif /* HAL_AT88CK900X_I2C_H_ */ -\ No newline at end of file -diff --git a/lib/hal/hal_linux_kit_cdc.c b/lib/hal/hal_linux_kit_cdc.c -deleted file mode 100644 -index 232cefc93b97..000000000000 ---- a/lib/hal/hal_linux_kit_cdc.c -+++ /dev/null -@@ -1,428 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for Linux using kit protocol over a USB CDC device. -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include "atca_hal.h" --#include "kit_phy.h" --#include "hal_linux_kit_cdc.h" --#include "kit_protocol.h" -- --#include --#include --#include --#include --#include --#include --#include -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- --// File scope macros --#ifndef __cplusplus --#define max(a, b) (((a) > (b)) ? (a) : (b)) --#define min(a, b) (((a) < (b)) ? (a) : (b)) --#endif -- --// File scope globals --atcacdc_t _gCdc; -- -- -- --char *dev = "/dev/ttyACM0"; // default device, Atmel CryptoAuth %n --//char *dev = "/dev/ttyATCA0"; // default device, Atmel CryptoAuth %n --int speed = B115200; -- --/** \brief discover cdc buses available for this hardware -- * this maintains a list of logical to physical bus mappings freeing the application -- * of the a-priori knowledge.This function is currently not implemented. -- * \param[in] cdc_buses - an array of logical bus numbers -- * \param[in] max_buses - maximum number of buses the app wants to attempt to discover -- * \return ATCA_UNIMPLEMENTED -- -- */ -- --ATCA_STATUS hal_cdc_discover_buses(int cdc_buses[], int max_buses) --{ -- return ATCA_UNIMPLEMENTED; --} -- --/** \brief discover any CryptoAuth devices on a given logical bus number -- * \param[in] busNum - logical bus number on which to look for CryptoAuth devices -- * \param[out] cfg[] - pointer to head of an array of interface config structures which get filled in by this method -- * \param[out] *found - number of devices found on this bus -- * \return ATCA_UNIMPLEMENTED -- */ -- --ATCA_STATUS hal_cdc_discover_devices(int busNum, ATCAIfaceCfg cfg[], int *found) --{ -- return ATCA_UNIMPLEMENTED; --} -- -- -- --/** \brief HAL implementation of Kit USB CDC init -- * -- * this discovery assumes a udev rule is active which renames the ATCK101 CDC device as a ttyATCA%n -- * the udev rule is: -- * -- * SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2122", MODE:="0777", SYMLINK+="ttyATCA%n" -- * -- * \param[in] hal pointer to HAL specific data that is maintained by this HAL -- * \param[in] cfg pointer to HAL specific configuration data that is used to initialize this HAL -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_cdc_init(void* hal, ATCAIfaceCfg* cfg) --{ -- ATCAHAL_t *phal = NULL; -- struct termios serialTermios; -- uint32_t i = 0; -- uint32_t index = 0; -- int fd; -- -- // Check the input variables -- if ((hal == NULL) || (cfg == NULL)) -- { -- return ATCA_BAD_PARAM; -- } -- -- // Cast the hal to the ATCAHAL_t structure -- phal = (ATCAHAL_t*)hal; -- -- // Initialize the _gCdc structure -- memset(&_gCdc, 0, sizeof(_gCdc)); -- for (i = 0; i < CDC_DEVICES_MAX; i++) -- { -- _gCdc.kits[i].read_handle = INVALID_HANDLE_VALUE; -- _gCdc.kits[i].write_handle = INVALID_HANDLE_VALUE; -- } -- _gCdc.num_kits_found = 0; -- -- // Get the read & write handles -- // todo: perform an actual discovery here... -- if ( (fd = open(dev, O_RDWR | O_NOCTTY)) < 0) -- { -- printf("Failed to open %s ret:%02X\n", dev, fd); -- return ATCA_COMM_FAIL; -- } -- index++; -- // Save the results of this discovery of CDC -- if (index > 0) -- { -- _gCdc.num_kits_found = 1; -- phal->hal_data = &_gCdc; -- } -- -- tcgetattr(fd, &serialTermios); -- cfsetispeed(&serialTermios, speed); -- cfsetospeed(&serialTermios, speed); -- cfmakeraw(&serialTermios); -- -- serialTermios.c_cflag |= CS8 | CLOCAL | CREAD; -- serialTermios.c_iflag = 0; -- serialTermios.c_oflag = 0; -- serialTermios.c_lflag = 0; -- // serialTermios.c_cc[VMIN] = 1; -- // serialTermios.c_cc[VTIME] = 0; -- -- tcsetattr(fd, TCSANOW, &serialTermios); -- -- _gCdc.kits[0].read_handle = fd; -- _gCdc.kits[0].write_handle = fd; -- -- return ATCA_SUCCESS; --} -- --/** \brief HAL implementation of Kit USB CDC post init -- * \param[in] iface instance -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_cdc_post_init(ATCAIface iface) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- atcacdc_t* phaldat = atgetifacehaldat(iface); -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- //int cdcid = cfg->atcauart.port; -- int i = 0; -- -- // Init all kit USB devices -- for (i = 0; i < phaldat->num_kits_found; i++) -- { -- // Set the port -- cfg->atcauart.port = i; -- // Perform the kit protocol init -- status = kit_init(iface); -- if (status != ATCA_SUCCESS) -- { -- return status; -- } -- } -- -- return status; --} -- --/** \brief HAL implementation of kit protocol send .It is called by the top layer. -- * \param[in] iface instance -- * \param[in] txdata pointer to bytes to send -- * \param[in] txlength number of bytes to send -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS kit_phy_send(ATCAIface iface, const char* txdata, int txlength) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int cdcid = cfg->atcauart.port; -- atcacdc_t* pCdc = (atcacdc_t*)atgetifacehaldat(iface); -- size_t bytesWritten = 0; -- --#ifdef KIT_DEBUG -- printf("--> %s", txdata); --#endif -- // Verify the input parameters -- if ((txdata == NULL) || (pCdc == NULL)) -- { -- return ATCA_BAD_PARAM; -- } -- -- // Verify the write handle -- if (pCdc->kits[cdcid].write_handle == INVALID_HANDLE_VALUE) -- { -- return ATCA_COMM_FAIL; -- } -- -- // Write the bytes to the specified com port -- bytesWritten = write(pCdc->kits[cdcid].write_handle, txdata, txlength); -- -- return status; --} -- --/** \brief HAL implementation of kit protocol receive data.It is called by the top layer. -- * \param[in] iface instance -- * \param[out] rxdata pointer to space to receive the data -- * \param[inout] rxsize ptr to expected number of receive bytes to request -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS kit_phy_receive(ATCAIface iface, char* rxdata, int* rxsize) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int cdcid = cfg->atcauart.port; -- atcacdc_t* pCdc = (atcacdc_t*)atgetifacehaldat(iface); -- uint8_t buffer[CDC_BUFFER_MAX] = { 0 }; -- bool continue_read = true; -- int bytes_read = 0; -- uint16_t total_bytes = 0; -- char* location = NULL; -- int bytes_remain = 0; -- int bytes_to_cpy = 0; -- -- do -- { -- // Verify the input variables -- if ((rxdata == NULL) || (rxsize == NULL) || (pCdc == NULL)) -- { -- status = ATCA_BAD_PARAM; -- break; -- } -- // Verify the write handle -- if (pCdc->kits[cdcid].read_handle == INVALID_HANDLE_VALUE) -- { -- status = ATCA_COMM_FAIL; -- break; -- } -- // Read all of the bytes -- while (continue_read == true) -- { -- bytes_read = read(pCdc->kits[cdcid].read_handle, buffer, CDC_BUFFER_MAX); -- -- // Find the location of the '\n' character in read buffer -- // todo: generalize this read... it only applies if there is an ascii protocol with an of \n and if the exists -- location = strchr((char*)&buffer[0], '\n'); -- if (location == NULL) -- { -- // Copy all of the bytes -- bytes_to_cpy = bytes_read; -- } -- else -- { -- // Copy only the bytes remaining in the read buffer to the -- bytes_to_cpy = (uint8_t)(location - (char*)buffer) + 1; -- // The response has been received, stop receiving more data -- continue_read = false; -- } -- // Protect rxdata from overwriting, this will have the result of truncating the returned bytes -- // Remaining space in rxdata -- bytes_remain = (*rxsize - total_bytes); -- // Use the minimum between number of bytes read and remaining space -- bytes_to_cpy = min(bytes_remain, bytes_to_cpy); -- -- // Copy the received data -- memcpy(&rxdata[total_bytes], &buffer[0], bytes_to_cpy); -- total_bytes += bytes_to_cpy; -- } -- -- } -- while (0); -- -- *rxsize = total_bytes; --#ifdef KIT_DEBUG -- printf("<-- %s", rxdata); --#endif -- return status; --} -- --/** \brief Number of USB CDC devices found -- * \param[out] num_found -- * \return ATCA_STATUS -- */ --ATCA_STATUS hal_kit_phy_num_found(int8_t* num_found) --{ -- *num_found = _gCdc.num_kits_found; -- return ATCA_SUCCESS; --} -- --/** \brief HAL implementation of kit protocol send over USB CDC -- * \param[in] iface instance -- * \param[in] txdata pointer to bytes to send -- * \param[in] txlength number of bytes to send -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_cdc_send(ATCAIface iface, uint8_t* txdata, int txlength) --{ -- // Call the hal_kit_send() function that will call hal_phy_send() implemented below -- return kit_send(iface, txdata, txlength); --} -- --/** \brief HAL implementation of kit protocol receive over USB CDC -- * \param[in] iface instance -- * \param[in] rxdata pointer to space to receive the data -- * \param[inout] rxsize ptr to expected number of receive bytes to request -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_cdc_receive(ATCAIface iface, uint8_t* rxdata, uint16_t* rxsize) --{ -- // Call the hal_kit_receive() function that will call hal_phy_receive() implemented below -- return kit_receive(iface, rxdata, rxsize); --} -- --/** \brief Call the wake for kit protocol over USB CDC -- * \param[in] iface ATCAIface instance that is the interface object to send the bytes over -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_cdc_wake(ATCAIface iface) --{ -- // Call the hal_kit_wake() function that will call hal_phy_send() and hal_phy_receive() -- return kit_wake(iface); --} -- --/** \brief Call the idle for kit protocol over USB CDC -- * \param[in] iface ATCAIface instance that is the interface object to send the bytes over -- * \return ATCA_SUCCESS on success, otherwise an error code.S -- */ --ATCA_STATUS hal_kit_cdc_idle(ATCAIface iface) --{ -- // Call the hal_kit_idle() function that will call hal_phy_send() and hal_phy_receive() -- return kit_idle(iface); --} -- --/** \brief Call the sleep for kit protocol over USB CDC -- * \param[in] iface ATCAIface instance that is the interface object to send the bytes over -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_cdc_sleep(ATCAIface iface) --{ -- // Call the hal_kit_sleep() function that will call hal_phy_send() and hal_phy_receive() -- return kit_sleep(iface); --} -- --/** \brief Close the physical port for CDC over USB CDC -- * \param[in] hal_data The hardware abstraction data specific to this HAL -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_cdc_release(void* hal_data) --{ -- int i = 0; -- atcacdc_t* phaldat = (atcacdc_t*)hal_data; -- -- if ((hal_data == NULL)) -- { -- return ATCA_BAD_PARAM; -- } -- -- // Close all kit USB devices -- for (i = 0; i < phaldat->num_kits_found; i++) -- { -- if (phaldat->kits[i].read_handle != INVALID_HANDLE_VALUE) -- { -- close(phaldat->kits[i].read_handle); -- phaldat->kits[i].read_handle = INVALID_HANDLE_VALUE; -- } -- -- if (phaldat->kits[i].write_handle != INVALID_HANDLE_VALUE) -- { -- close(phaldat->kits[i].write_handle); -- phaldat->kits[i].write_handle = INVALID_HANDLE_VALUE; -- } -- } -- return ATCA_SUCCESS; --} -- --/** \brief discover cdc buses available for this hardware -- * this maintains a list of logical to physical bus mappings freeing the application -- * of the a-priori knowledge.This function is currently not implemented. -- * \param[in] cdc_buses - an array of logical bus numbers -- * \param[in] max_buses - maximum number of buses the app wants to attempt to discover -- * \return ATCA_UNIMPLEMENTED -- -- */ --ATCA_STATUS hal_kit_cdc_discover_buses(int cdc_buses[], int max_buses) --{ -- // TODO: Implement -- return ATCA_UNIMPLEMENTED; --} -- --/** \brief discover any CryptoAuth devices on a given logical bus number -- * \param[in] busNum - logical bus number on which to look for CryptoAuth devices -- * \param[out] cfg[] - pointer to head of an array of interface config structures which get filled in by this method -- * \param[out] *found - number of devices found on this bus -- * \return ATCA_UNIMPLEMENTED -- */ -- --ATCA_STATUS hal_kit_cdc_discover_devices(int busNum, ATCAIfaceCfg *cfg, int *found) --{ -- // TODO: Implement -- *found = 0; -- return ATCA_UNIMPLEMENTED; --} --/** @} */ -diff --git a/lib/hal/hal_linux_kit_cdc.h b/lib/hal/hal_linux_kit_cdc.h -deleted file mode 100644 -index c0dcf4ab9801..000000000000 ---- a/lib/hal/hal_linux_kit_cdc.h -+++ /dev/null -@@ -1,67 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for Linux using kit protocol over a USB CDC device. -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef HAL_LINUX_KIT_CDC_H_ --#define HAL_LINUX_KIT_CDC_H_ -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- --// Kit USB defines --#define CDC_DEVICES_MAX 10 //! Maximum number of supported Kit USB devices --#define CDC_BUFFER_MAX 1024 //! Maximum number of bytes read per port read -- -- --// Each device that is found will have a read handle and a write handle --typedef int HANDLE; --#define INVALID_HANDLE_VALUE ((int)(-1)) --typedef struct cdc_device --{ -- HANDLE read_handle; //! The kit USB read file handle -- HANDLE write_handle; //! The kit USB write file handle --} cdc_device_t; -- -- --// A structure to hold CDC information --typedef struct atcacdc --{ -- cdc_device_t kits[CDC_DEVICES_MAX]; -- int8_t num_kits_found; --} atcacdc_t; -- --/** @} */ -- --#endif /* HAL_LINUX_KIT_CDC_H_ */ -- -diff --git a/lib/hal/hal_linux_kit_hid.c b/lib/hal/hal_linux_kit_hid.c -deleted file mode 100644 -index 960d18c7ddea..000000000000 ---- a/lib/hal/hal_linux_kit_hid.c -+++ /dev/null -@@ -1,429 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for Linux using kit protocol over a USB HID device. -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include --#include -- --#include "atca_hal.h" --#include "hal_linux_kit_hid.h" --#include "hal/kit_protocol.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- --// File scope globals --atcahid_t _gHid; -- --/** \brief discover hid buses available for this hardware -- * this maintains a list of logical to physical bus mappings freeing the application -- * of the a-priori knowledge.This function is currently not implemented. -- * \param[in] cdc_buses - an array of logical bus numbers -- * \param[in] max_buses - maximum number of buses the app wants to attempt to discover -- * \return ATCA_UNIMPLEMENTED -- */ -- --ATCA_STATUS hal_kit_hid_discover_buses(int hid_buses[], int max_buses) --{ -- return ATCA_UNIMPLEMENTED; --} -- --/** \brief discover any CryptoAuth devices on a given logical bus number.This function is currently not implemented. -- * \param[in] busNum - logical bus number on which to look for CryptoAuth devices -- * \param[out] cfg[] - pointer to head of an array of interface config structures which get filled in by this method -- * \param[out] *found - number of devices found on this bus -- * \return ATCA_UNIMPLEMENTED -- */ --ATCA_STATUS hal_kit_hid_discover_devices(int busNum, ATCAIfaceCfg cfg[], int *found) --{ -- return ATCA_UNIMPLEMENTED; --} -- --/** \brief HAL implementation of Kit USB HID init -- * \param[in] hal pointer to HAL specific data that is maintained by this HAL -- * \param[in] cfg pointer to HAL specific configuration data that is used to initialize this HAL -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_hid_init(void* hal, ATCAIfaceCfg* cfg) --{ -- ATCAHAL_t *phal = (ATCAHAL_t*)hal; -- int status = 0; -- struct udev *udev = NULL; -- struct udev_enumerate *enumerate = NULL; -- struct udev_list_entry *list = NULL; -- struct udev_list_entry *list_entry = NULL; -- struct udev_device *syspath_device = NULL; -- struct udev_device *device = NULL; -- int i = 0; -- char hid_filter[20]; -- char device_hid[20]; -- FILE *file_descriptor = NULL; -- int index = 0; -- -- // Check the input variables -- if ((cfg == NULL) || (phal == NULL)) -- { -- return ATCA_BAD_PARAM; -- } -- -- // Initialize the _gHid structure -- memset(&_gHid, 0, sizeof(_gHid)); -- for (i = 0; i < HID_DEVICES_MAX; i++) -- { -- _gHid.kits[i].read_handle = NULL; -- _gHid.kits[i].write_handle = NULL; -- } -- -- _gHid.num_kits_found = 0; -- -- // Create the udev object -- udev = udev_new(); -- if (udev == NULL) -- { -- return ATCA_COMM_FAIL; -- } -- -- // Create the enumerate object -- enumerate = udev_enumerate_new(udev); -- if (enumerate == NULL) -- { -- // Free the udev object -- udev_unref(udev); -- -- return ATCA_COMM_FAIL; -- } -- -- // Create the list of available USB devices -- status = udev_enumerate_add_match_subsystem(enumerate, "hidraw"); -- if (status >= 0) -- { -- status = udev_enumerate_scan_devices(enumerate); -- if (status >= 0) -- { -- list = udev_enumerate_get_list_entry(enumerate); -- } -- } -- -- // Create the HID filter string -- memset(hid_filter, 0, sizeof(hid_filter)); -- sprintf(hid_filter, "vid_%04x&pid_%04x", cfg->atcahid.vid, cfg->atcahid.pid); -- -- // Find the available kit USB devices -- udev_list_entry_foreach(list_entry, list) -- { -- // Get the udev device -- syspath_device = udev_device_new_from_syspath(udev, udev_list_entry_get_name(list_entry)); -- device = udev_device_get_parent_with_subsystem_devtype(syspath_device, "usb", "usb_device"); -- -- // Create the device HID string -- memset(device_hid, 0, sizeof(device_hid)); -- sprintf(device_hid, "vid_%s&pid_%s", -- udev_device_get_sysattr_value(device, "idVendor"), -- udev_device_get_sysattr_value(device, "idProduct")); -- -- // Determine if this is the correct kit USB device -- if (strcasecmp(device_hid, hid_filter) == 0) -- { -- // Open the kit USB device for reading and writing -- if (_gHid.kits[index].read_handle != NULL) -- { -- fclose(_gHid.kits[index].read_handle); -- } -- if (_gHid.kits[index].write_handle != NULL) -- { -- fclose(_gHid.kits[index].write_handle); -- } -- -- file_descriptor = fopen(udev_device_get_devnode(syspath_device), "rb+"); -- if (file_descriptor != NULL) -- { -- _gHid.kits[index].read_handle = file_descriptor; -- _gHid.kits[index].write_handle = file_descriptor; -- -- // Increment the opened kit USB device index -- index++; -- --#ifdef KIT_DEBUG -- printf("Kit USB Device Node: %s\n", udev_device_get_devnode(syspath_device)); -- printf(" Manufacturer %s (%s)\n", -- udev_device_get_sysattr_value(device, "manufacturer"), -- udev_device_get_sysattr_value(device, "product")); -- printf(" VID/PID: %s %s\n", -- udev_device_get_sysattr_value(device, "idVendor"), -- udev_device_get_sysattr_value(device, "idProduct")); --#endif // KIT_DEBUG -- } -- else -- { --#ifdef KIT_DEBUG -- printf("fopen(\"%s\") failed with errno=%d\n", -- udev_device_get_devnode(syspath_device), -- errno); --#endif // KIT_DEBUG -- } -- } -- -- // Free the udev device object -- udev_device_unref(syspath_device); -- } -- -- // Save the results of this discovery of HID -- if (index > 0) -- { -- _gHid.num_kits_found = index; -- phal->hal_data = &_gHid; -- } -- -- // Free the enumerator object -- udev_enumerate_unref(enumerate); -- -- // Free the udev object -- udev_unref(udev); -- -- return ATCA_SUCCESS; --} -- --/** \brief HAL implementation of Kit HID post init -- * \param[in] iface instance -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_hid_post_init(ATCAIface iface) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- atcahid_t* pHid = atgetifacehaldat(iface); -- ATCAIfaceCfg *pCfg = atgetifacecfg(iface); -- int i = 0; -- -- if ((pHid == NULL) || (pCfg == NULL)) -- { -- return ATCA_BAD_PARAM; -- } -- -- // Perform the kit protocol init -- for (i = 0; i < pHid->num_kits_found; i++) -- { -- status = kit_init(iface); -- if (status != ATCA_SUCCESS) -- { -- BREAK(status, "kit_init() Failed"); -- } -- } -- -- return status; --} -- --/** \brief HAL implementation of send over Kit protocol.This function is called by the top layer. -- * \param[in] iface instance -- * \param[in] txdata pointer to bytes to send -- * \param[in] txlength number of bytes to send -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS kit_phy_send(ATCAIface iface, uint8_t* txdata, int txlength) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- atcahid_t* pHid = (atcahid_t*)atgetifacehaldat(iface); -- size_t bytes_written = 0; -- -- if ((txdata == NULL) || (cfg == NULL) || (pHid == NULL)) -- { -- return ATCA_BAD_PARAM; -- } -- -- if (pHid->kits[cfg->atcahid.idx].write_handle == NULL) -- { -- return ATCA_COMM_FAIL; -- } -- -- // Send the data to the kit USB device -- if (txlength > 0) -- { -- bytes_written = fwrite(txdata, sizeof(uint8_t), txlength, -- pHid->kits[cfg->atcahid.idx].write_handle); -- if (bytes_written != txlength) -- { -- clearerr(pHid->kits[cfg->atcahid.idx].write_handle); -- return ATCA_TX_FAIL; -- } -- } -- -- return ATCA_SUCCESS; --} -- --/** \brief HAL implementation of kit protocol receive.This function is called by the top layer. -- * \param[in] iface instance -- * \param[out] rxdata pointer to space to receive the data -- * \param[inout] rxsize ptr to expected number of receive bytes to request -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS kit_phy_receive(ATCAIface iface, uint8_t* rxdata, int* rxsize) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- atcahid_t* pHid = (atcahid_t*)atgetifacehaldat(iface); -- bool continue_read = true; -- size_t bytes_read = 0; -- size_t total_bytes_read = 0; -- -- if ((rxdata == NULL) || (rxsize == NULL) || (cfg == NULL) || (pHid == NULL)) -- { -- return ATCA_BAD_PARAM; -- } -- -- if (pHid->kits[cfg->atcahid.idx].read_handle == NULL) -- { -- return ATCA_COMM_FAIL; -- } -- -- // Receive the data from the kit USB device -- do -- { -- bytes_read = fread(&rxdata[total_bytes_read], sizeof(uint8_t), 1, -- pHid->kits[cfg->atcahid.idx].read_handle); -- if (ferror(pHid->kits[cfg->atcahid.idx].read_handle) != 0) -- { -- clearerr(pHid->kits[cfg->atcahid.idx].read_handle); -- return ATCA_RX_FAIL; -- } -- -- total_bytes_read += bytes_read; -- -- // Check if the kit protocol message has been received -- if (strstr((char*)rxdata, "\n") != NULL) -- { -- continue_read = false; -- } -- } -- while (continue_read == true); -- -- // Save the total bytes read -- *rxsize = total_bytes_read; -- -- return ATCA_SUCCESS; --} -- --/** \brief Number of USB HID devices found -- * \param[out] num_found -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS kit_phy_num_found(int8_t* num_found) --{ -- *num_found = _gHid.num_kits_found; -- -- return ATCA_SUCCESS; --} -- --/** \brief HAL implementation of kit protocol send over USB HID -- * \param[in] iface instance -- * \param[in] txdata pointer to bytes to send -- * \param[in] txlength number of bytes to send -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_hid_send(ATCAIface iface, uint8_t* txdata, int txlength) --{ -- // Call the kit_send() function that will call phy_send() implemented below -- return kit_send(iface, txdata, txlength); --} -- --/** \brief HAL implementation of send over USB HID -- * \param[in] iface instance -- * \param[in] rxdata pointer to space to receive the data -- * \param[inout] rxsize ptr to expected number of receive bytes to request -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_hid_receive(ATCAIface iface, uint8_t* rxdata, uint16_t* rxsize) --{ -- // Call the kit_receive() function that will call phy_receive() implemented below -- return kit_receive(iface, rxdata, rxsize); --} -- --/** \brief Call the wake for kit protocol over USB HID -- * \param[in] iface ATCAIface instance that is the interface object to send the bytes over -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_hid_wake(ATCAIface iface) --{ -- // Call the kit_wake() function that will call phy_send() and phy_receive() -- return kit_wake(iface); --} -- --/** \brief Call the idle for kit protocol over USB HID -- * \param[in] iface ATCAIface instance that is the interface object to send the bytes over -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_hid_idle(ATCAIface iface) --{ -- // Call the kit_idle() function that will call phy_send() and phy_receive() -- return kit_idle(iface); --} -- --/** \brief Call the sleep for kit protocol over USB HID -- * \param[in] iface ATCAIface instance that is the interface object to send the bytes over -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_hid_sleep(ATCAIface iface) --{ -- // Call the kit_sleep() function that will call phy_send() and phy_receive() -- return kit_sleep(iface); --} -- --/** \brief Close the physical port for HID -- * \param[in] hal_data The hardware abstraction data specific to this HAL -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_hid_release(void* hal_data) --{ -- atcahid_t* phaldat = (atcahid_t*)hal_data; -- int i = 0; -- -- if (phaldat == NULL) -- { -- return ATCA_BAD_PARAM; -- } -- -- // Close all kit USB devices -- for (i = 0; i < phaldat->num_kits_found; i++) -- { -- if (_gHid.kits[i].read_handle != NULL) -- { -- fclose(_gHid.kits[i].read_handle); -- _gHid.kits[i].read_handle = NULL; -- _gHid.kits[i].write_handle = NULL; -- } -- } -- -- return ATCA_SUCCESS; --} -- --/** @} */ -diff --git a/lib/hal/hal_linux_kit_hid.h b/lib/hal/hal_linux_kit_hid.h -deleted file mode 100644 -index 649aab556668..000000000000 ---- a/lib/hal/hal_linux_kit_hid.h -+++ /dev/null -@@ -1,62 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for Linux using kit protocol over a USB HID device. -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef HAL_LINUX_KIT_HID_H_ --#define HAL_LINUX_KIT_HID_H_ -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- --// Kit USB defines --#define HID_DEVICES_MAX 10 //! Maximum number of supported Kit USB devices --#define HID_PACKET_MAX 512 //! Maximum number of bytes for a HID send/receive packet (typically 64) -- --// Each device that is found will have a read handle and a write handle --typedef struct hid_device --{ -- FILE *read_handle; //! The kit USB read file handle -- FILE *write_handle; //! The kit USB write file handle --} hid_device_t; -- -- --// A structure to hold HID information --typedef struct atcahid --{ -- hid_device_t kits[HID_DEVICES_MAX]; -- int8_t num_kits_found; --} atcahid_t; -- --/** @} */ --#endif /* HAL_LINUX_KIT_HID_H_ */ -diff --git a/lib/hal/hal_pic32mx695f512h_i2c.c b/lib/hal/hal_pic32mx695f512h_i2c.c -deleted file mode 100644 -index 730d782d7e51..000000000000 ---- a/lib/hal/hal_pic32mx695f512h_i2c.c -+++ /dev/null -@@ -1,510 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for PIC32MX695F512H I2C over plib drivers. -- * -- * This code is structured in two parts. Part 1 is the connection of the ATCA HAL API to the physical I2C -- * implementation. Part 2 is the xxx I2C primitives to set up the interface. -- * -- * Prerequisite: -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include -- --#include "hal/atca_hal.h" --#include "hal/hal_pic32mx695f512h_i2c.h" -- -- --/** -- * \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- --/** -- * \brief -- * Logical to physical bus mapping structure -- */ --ATCAI2CMaster_t *i2c_hal_data[MAX_I2C_BUSES]; // map logical, 0-based bus number to index --int i2c_bus_ref_ct = 0; // total in-use count across buses --//twi_options_t opt_twi_master; -- -- --/****** I2C Driver implementation *******/ --static bool StartTransfer(I2C_MODULE i2c_id, bool restart) --{ -- I2C_STATUS status; -- -- // Send the Start (or Restart) signal -- if (restart) -- { -- I2CRepeatStart(i2c_id); -- } -- else -- { -- // Wait for the bus to be idle, then start the transfer -- while (!I2CBusIsIdle(i2c_id)) -- { -- ; -- } -- -- if (I2CStart(i2c_id) != I2C_SUCCESS) -- { -- //DBPRINTF("Error: Bus collision during transfer Start\n"); -- return FALSE; -- } -- } -- -- // Wait for the signal to complete -- do -- { -- status = I2CGetStatus(i2c_id); -- } -- -- while (!(status & I2C_START)); -- -- return TRUE; --} -- --static bool TransmitOneByte(I2C_MODULE i2c_id, uint8_t data) --{ -- // Wait for the transmitter to be ready -- while (!I2CTransmitterIsReady(i2c_id)) -- { -- ; -- } -- -- // Transmit the byte -- if (I2CSendByte(i2c_id, data) == I2C_MASTER_BUS_COLLISION) -- { -- //DBPRINTF("Error: I2C Master Bus Collision\n"); -- return FALSE; -- } -- -- // Wait for the transmission to finish -- while (!I2CTransmissionHasCompleted(i2c_id)) -- { -- ; -- } -- -- return TRUE; --} -- --static uint8_t ReceiveOneByte(I2C_MODULE i2c_id, bool ack) --{ -- uint8_t data; -- -- // Enable I2C receive -- I2CReceiverEnable(i2c_id, TRUE); -- -- // Wait until 1-byte is fully received -- while (!I2CReceivedDataIsAvailable(i2c_id)) -- { -- ; -- } -- -- // Save the byte received -- data = I2CGetByte(i2c_id); -- -- // Perform acknowledgement sequence -- I2CAcknowledgeByte(i2c_id, ack); -- -- // Wait until acknowledgement is successfully sent -- while (!I2CAcknowledgeHasCompleted(i2c_id)) -- { -- ; -- } -- -- return data; --} -- --static void StopTransfer(I2C_MODULE i2c_id) --{ -- I2C_STATUS status; -- -- // Send the Stop signal -- I2CStop(i2c_id); -- -- // Wait for the signal to complete -- do -- { -- status = I2CGetStatus(i2c_id); -- } -- -- while (!(status & I2C_STOP)); --} -- --void i2c_write(I2C_MODULE i2c_id, uint8_t address, uint8_t *data, int len) --{ -- uint8_t i2cBuffer[len + 1]; -- int i; -- -- i2cBuffer[0] = address | 0x00; -- memcpy(&i2cBuffer[1], data, len); -- -- if (!StartTransfer(i2c_id, FALSE)) -- { -- return; -- } -- for (i = 0; i < len + 1; i++) -- { -- if (!TransmitOneByte(i2c_id, i2cBuffer[i])) -- { -- break; -- } -- } -- -- StopTransfer(i2c_id); --} -- --void i2c_read(I2C_MODULE i2c_id, uint8_t address, uint8_t *data, uint16_t len) --{ -- uint16_t i; -- -- if (!StartTransfer(i2c_id, FALSE)) -- { -- return; -- } -- -- if (!TransmitOneByte(i2c_id, (address | 0x01))) -- { -- return; -- } -- -- for (i = 0; i < len; i++) -- { -- if (i < len - 1) // send ACK -- { -- data[i] = ReceiveOneByte(i2c_id, TRUE); -- } -- else // send NACK -- { -- data[i] = ReceiveOneByte(i2c_id, FALSE); -- } -- } -- -- StopTransfer(i2c_id); --} --/****************************************/ -- -- --/** -- * \brief -- * This HAL implementation assumes you've included the Plib libraries in your project, otherwise, -- * the HAL layer will not compile because the Plib drivers are a dependency -- */ -- --/** \brief discover i2c buses available for this hardware -- * this maintains a list of logical to physical bus mappings freeing the application -- * of the a-priori knowledge.This function is currently not implemented. -- * \param[in] i2c_buses - an array of logical bus numbers -- * \param[in] max_buses - maximum number of buses the app wants to attempt to discover -- * \return ATCA_UNIMPLEMENTED -- */ --ATCA_STATUS hal_i2c_discover_buses(int i2c_buses[], int max_buses) --{ -- return ATCA_UNIMPLEMENTED; --} -- --/** \brief discover any CryptoAuth devices on a given logical bus number.This function is currently not implemented. -- * \param[in] busNum - logical bus number on which to look for CryptoAuth devices -- * \param[out] cfg[] - pointer to head of an array of interface config structures which get filled in by this method -- * \param[out] *found - number of devices found on this bus -- * \return ATCA_UNIMPLEMENTED -- */ --ATCA_STATUS hal_i2c_discover_devices(int busNum, ATCAIfaceCfg cfg[], int *found) --{ -- return ATCA_UNIMPLEMENTED; --} -- --/** -- * \brief -- * hal_i2c_init manages requests to initialize a physical interface. It manages use counts so when an interface -- * has released the physical layer, it will disable the interface for some other use. -- * You can have multiple ATCAIFace instances using the same bus, and you can have multiple ATCAIFace instances on -- * multiple i2c buses, so hal_i2c_init manages these things and ATCAIFace is abstracted from the physical details. -- */ -- --/** -- * \brief initialize an I2C interface using given config -- * -- * \param[in] hal - opaque ptr to HAL data -- * \param[in] cfg - interface configuration -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_init(void *hal, ATCAIfaceCfg *cfg) --{ -- int bus = cfg->atcai2c.bus; // 0-based logical bus number -- int i; -- ATCAHAL_t *phal = (ATCAHAL_t*)hal; -- -- if (i2c_bus_ref_ct == 0) // power up state, no i2c buses will have been used -- -- { -- for (i = 0; i < MAX_I2C_BUSES; i++) -- { -- i2c_hal_data[i] = NULL; -- } -- } -- -- i2c_bus_ref_ct++; // total across buses -- -- if (bus >= 0 && bus < MAX_I2C_BUSES) -- { -- //// if this is the first time this bus and interface has been created, do the physical work of enabling it -- if (i2c_hal_data[bus] == NULL) -- { -- i2c_hal_data[bus] = malloc(sizeof(ATCAI2CMaster_t)); -- i2c_hal_data[bus]->ref_ct = 1; // buses are shared, this is the first instance -- -- switch (bus) -- { --// case 0: --// i2c_hal_data[bus]->id = I2C0; --// break; -- case 1: -- i2c_hal_data[bus]->id = I2C1; -- break; --// case 2: --// i2c_hal_data[bus]->id = I2C2; --// break; -- case 3: -- i2c_hal_data[bus]->id = I2C3; -- break; -- } -- -- // Set the I2C baudrate -- I2CSetFrequency(i2c_hal_data[bus]->id, GetPeripheralClock(), cfg->atcai2c.baud); -- -- // Enable the I2C bus -- I2CEnable(i2c_hal_data[bus]->id, TRUE); -- -- // store this for use during the release phase -- i2c_hal_data[bus]->bus_index = bus; -- } -- else -- { -- // otherwise, another interface already initialized the bus, so this interface will share it and any different -- // cfg parameters will be ignored...first one to initialize this sets the configuration -- i2c_hal_data[bus]->ref_ct++; -- } -- -- phal->hal_data = i2c_hal_data[bus]; -- -- return ATCA_SUCCESS; -- } -- -- return ATCA_COMM_FAIL; --} -- --/** -- * \brief HAL implementation of I2C post init -- * -- * \param[in] iface instance -- * -- * \return ATCA_SUCCESS -- */ --ATCA_STATUS hal_i2c_post_init(ATCAIface iface) --{ -- return ATCA_SUCCESS; --} -- --/** -- * \brief HAL implementation of I2C send over ASF -- * -- * \param[in] iface instance -- * \param[in] txdata pointer to space to bytes to send -- * \param[in] txlength number of bytes to send -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_send(ATCAIface iface, uint8_t *txdata, int txlength) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- -- txdata[0] = 0x03; // insert the Word Address Value, Command token -- txlength++; // account for word address value byte. -- -- i2c_write(i2c_hal_data[bus]->id, cfg->atcai2c.slave_address, txdata, txlength); -- -- return ATCA_SUCCESS; --} -- --/** -- * \brief HAL implementation of I2C receive function for ASF I2C -- * -- * \param[in] iface instance -- * \param[in] rxdata pointer to space to receive the data -- * \param[in] rxlength ptr to expected number of receive bytes to request -- * -- * \return ATCA_SUCCESS -- */ --ATCA_STATUS hal_i2c_receive(ATCAIface iface, uint8_t *rxdata, uint16_t *rxlength) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- -- i2c_read(i2c_hal_data[bus]->id, cfg->atcai2c.slave_address, rxdata, *rxlength); -- -- return ATCA_SUCCESS; --} -- --/** -- * \brief method to change the bus speed of I2C -- * -- * \param[in] iface interface on which to change bus speed -- * \param[in] speed baud rate (typically 100000 or 400000) -- */ --void change_i2c_speed(ATCAIface iface, uint32_t speed) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- -- // Disable the I2C bus -- I2CEnable(i2c_hal_data[bus]->id, FALSE); -- -- // Set the I2C baudrate -- I2CSetFrequency(i2c_hal_data[bus]->id, GetPeripheralClock(), speed); -- -- // Enable the I2C bus -- I2CEnable(i2c_hal_data[bus]->id, TRUE); --} -- --/** -- * \brief wake up CryptoAuth device using I2C bus -- * -- * \param[in] iface interface to logical device to wakeup -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_wake(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- uint32_t bdrt = cfg->atcai2c.baud; -- -- uint8_t data[4], expected[4] = { 0x04, 0x11, 0x33, 0x43 }; -- -- if (bdrt != 100000) // if not already at 100KHz, change it -- { -- change_i2c_speed(iface, 100000); -- } -- -- // Send 0x00 as wake pulse -- i2c_write(i2c_hal_data[bus]->id, 0x00, NULL, NULL); -- -- atca_delay_ms(3); // wait tWHI + tWLO which is configured based on device type and configuration structure -- //atca_delay_us(cfg->wake_delay); -- -- // if necessary, revert baud rate to what came in. -- if (bdrt != 100000) -- { -- change_i2c_speed(iface, cfg->atcai2c.baud); -- } -- -- i2c_read(i2c_hal_data[bus]->id, cfg->atcai2c.slave_address, data, 4); -- -- if (memcmp(data, expected, 4) == 0) -- { -- return ATCA_SUCCESS; -- } -- -- return ATCA_COMM_FAIL; --} -- --/** -- * \brief idle CryptoAuth device using I2C bus -- * -- * \param[in] iface interface to logical device to idle -- * -- * \return ATCA_SUCCESS -- */ --ATCA_STATUS hal_i2c_idle(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- uint8_t data[4]; -- -- data[0] = 0x02; // idle word address value -- -- i2c_write(i2c_hal_data[bus]->id, cfg->atcai2c.slave_address, data, 1); -- -- return ATCA_SUCCESS; --} -- --/** -- * \brief sleep CryptoAuth device using I2C bus -- * -- * \param[in] iface interface to logical device to sleep -- * -- * \return ATCA_SUCESS -- */ --ATCA_STATUS hal_i2c_sleep(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- uint8_t data[4]; -- -- data[0] = 0x01; // idle word address value -- -- i2c_write(i2c_hal_data[bus]->id, cfg->atcai2c.slave_address, data, 1); -- -- return ATCA_SUCCESS; --} -- --/** -- * \brief manages reference count on given bus and releases resource if no more refences exist -- * -- * \param[in] hal_data - opaque pointer to hal data structure - known only to the HAL implementation -- * -- * \return ATCA_SUCESS -- */ --ATCA_STATUS hal_i2c_release(void *hal_data) --{ -- ATCAI2CMaster_t *hal = (ATCAI2CMaster_t*)hal_data; -- -- i2c_bus_ref_ct--; // track total i2c bus interface instances for consistency checking and debugging -- -- // if the use count for this bus has gone to 0 references, disable it. protect against an unbracketed release -- if (hal && --(hal->ref_ct) <= 0 && i2c_hal_data[hal->bus_index] != NULL) -- { -- I2CEnable(hal->id, FALSE); -- free(i2c_hal_data[hal->bus_index]); -- i2c_hal_data[hal->bus_index] = NULL; -- } -- -- return ATCA_SUCCESS; --} -- --/** @} */ -\ No newline at end of file -diff --git a/lib/hal/hal_pic32mx695f512h_i2c.h b/lib/hal/hal_pic32mx695f512h_i2c.h -deleted file mode 100644 -index 1b242168b43d..000000000000 ---- a/lib/hal/hal_pic32mx695f512h_i2c.h -+++ /dev/null -@@ -1,74 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for PIC32MX695F512H I2C over xxx drivers. -- * -- * This code is structured in two parts. Part 1 is the connection of the ATCA HAL API to the physical I2C -- * implementation. Part 2 is the xxx I2C primitives to set up the interface. -- * -- * Prerequisite: -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef HAL_PIC32MX695F512H_I2C_ASF_H_ --#define HAL_PIC32MX695F512H_I2C_ASF_H_ -- -- --/** -- * \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- --// Clock Constants --#define GetSystemClock() (80000000ul) --#define GetPeripheralClock() (GetSystemClock() / (1 << OSCCONbits.PBDIV)) --#define GetInstructionClock() (GetSystemClock()) -- --#define MAX_I2C_BUSES 4 // PIC32MX695F512H has 4 TWI -- --/** -- * \brief this is the hal_data for ATCA HAL -- */ --typedef struct atcaI2Cmaster --{ -- I2C_MODULE id; -- int ref_ct; -- // for conveniences during interface release phase -- int bus_index; --} ATCAI2CMaster_t; -- --void i2c_write(I2C_MODULE i2c_id, uint8_t address, uint8_t *data, int len); --void i2c_read(I2C_MODULE i2c_id, uint8_t address, uint8_t *data, uint16_t len); -- --void change_i2c_speed(ATCAIface iface, uint32_t speed); -- --/** @} */ -- --#endif /* HAL_PIC32MX695F512H_I2C_ASF_H_ */ -\ No newline at end of file -diff --git a/lib/hal/hal_pic32mx695f512h_timer.c b/lib/hal/hal_pic32mx695f512h_timer.c -deleted file mode 100644 -index b4963d2d31a8..000000000000 ---- a/lib/hal/hal_pic32mx695f512h_timer.c -+++ /dev/null -@@ -1,106 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for PIC32MX695F512H timer/delay routine -- * -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include -- --#include "hal/atca_hal.h" -- -- --/* ASF already have delay_us and delay_ms - see delay.h */ -- --/** -- * \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- -- -- --#define CPU_CLOCK (80000000UL) --#define us_SCALE ((CPU_CLOCK / 2) / 1000000) -- -- --void delay_us(UINT32 delay) --{ -- UINT32 startCnt = ReadCoreTimer(); -- UINT32 waitCnt = delay * us_SCALE; -- -- while ((ReadCoreTimer() - startCnt) < waitCnt) -- { -- ; -- } -- --} -- -- -- -- --/****************************************/ -- --/** -- * \brief This function delays for a number of microseconds. -- * -- * \param[in] delay number of 0.001 milliseconds to delay -- */ --void atca_delay_us(uint32_t delay) --{ -- delay_us(delay); --} -- --/** -- * \brief This function delays for a number of tens of microseconds. -- * -- * \param[in] delay number of 0.01 milliseconds to delay -- */ --void atca_delay_10us(uint32_t delay) --{ -- atca_delay_us(delay * 10); --} -- --/** -- * \brief This function delays for a number of milliseconds. -- * -- * You can override this function if you like to do -- * something else in your system while delaying. -- * -- * \param[in] delay number of milliseconds to delay -- */ --void atca_delay_ms(uint32_t delay) --{ -- -- atca_delay_us(delay * 1000); -- --} -- --/** @} */ -\ No newline at end of file -diff --git a/lib/hal/hal_sam4s_i2c_asf.c b/lib/hal/hal_sam4s_i2c_asf.c -deleted file mode 100644 -index 619de4d1b6a4..000000000000 ---- a/lib/hal/hal_sam4s_i2c_asf.c -+++ /dev/null -@@ -1,667 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for SAM4S I2C over ASF drivers. -- * -- * This code is structured in two parts. Part 1 is the connection of the ATCA HAL API to the physical I2C -- * implementation. Part 2 is the ASF I2C primitives to set up the interface. -- * -- * Prerequisite: add "TWI - Two-Wire Interface (Common API) (service)" module to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include --#include "atca_hal.h" --#include "hal_sam4s_i2c_asf.h" --#include "atca_device.h" -- -- -- --//!< Uncomment when debugging --/*#define DEBUG_HAL*/ -- --/** -- * \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * using I2C driver of ASF. -- * -- @{ */ -- --/** -- * \brief -- * Logical to physical bus mapping structure -- */ --ATCAI2CMaster_t *i2c_hal_data[MAX_I2C_BUSES]; // map logical, 0-based bus number to index --int i2c_bus_ref_ct = 0; // total in-use count across buses --twi_master_options_t opt_twi_master; -- -- --#ifdef DEBUG_HAL --static void print_array(uint8_t *data, uint32_t data_size) --{ -- uint32_t n; -- -- for (n = 0; n < data_size; n++) -- { -- printf("%.2x ", data[n]); -- if (((n + 1) % 16) == 0) -- { -- printf("\r\n"); -- if ((n + 1) != data_size) -- { -- printf(" "); -- } -- } -- } -- if (data_size % 16 != 0) -- { -- printf("\r\n"); -- } --} --#endif -- --/** -- * \brief -- * This HAL implementation assumes you've included the ASF TWI libraries in your project, otherwise, -- * the HAL layer will not compile because the ASF TWI drivers are a dependency -- */ -- --/** \brief discover i2c buses available for this hardware -- * this maintains a list of logical to physical bus mappings freeing the application -- * of the a-priori knowledge -- * \param[in] i2c_buses - an array of logical bus numbers -- * \param[in] max_buses - maximum number of buses the app wants to attempt to discover -- * \return ATCA_SUCCESS -- */ -- --ATCA_STATUS hal_i2c_discover_buses(int i2c_buses[], int max_buses) --{ -- /* logical bus numbers 0-2 map to the SAM4S i2c buses: -- ID_TWI0 -- ID_TWI1 -- -- TWS0 bus will respond on the SAM4S Xplained Pro board -- -- */ -- int i; -- -- i2c_buses[0] = 0; --#if MAX_I2C_BUSES == 2 -- i2c_buses[1] = -1; --#endif -- return ATCA_SUCCESS; -- --} -- --/** \brief discover any CryptoAuth devices on a given logical bus number -- * \param[in] busNum - logical bus number on which to look for CryptoAuth devices -- * \param[out] cfg[] - pointer to head of an array of interface config structures which get filled in by this method -- * \param[out] *found - number of devices found on this bus -- * \return ATCA_SUCCESS -- */ -- --ATCA_STATUS hal_i2c_discover_devices(int busNum, ATCAIfaceCfg cfg[], int *found) --{ -- ATCAIfaceCfg *head = cfg; -- uint8_t slaveAddress = 0x01; -- ATCADevice device; -- ATCAIface discoverIface; -- ATCACommand command; -- ATCAPacket packet; -- ATCA_STATUS status; -- uint8_t revs508[1][4] = { { 0x00, 0x00, 0x50, 0x00 } }; -- uint8_t revs108[1][4] = { { 0x80, 0x00, 0x10, 0x01 } }; -- uint8_t revs204[3][4] = { { 0x00, 0x02, 0x00, 0x08 }, -- { 0x00, 0x02, 0x00, 0x09 }, -- { 0x00, 0x04, 0x05, 0x00 } }; -- int i; -- -- /** \brief default configuration, to be reused during discovery process */ -- ATCAIfaceCfg discoverCfg = { -- .iface_type = ATCA_I2C_IFACE, -- .devtype = ATECC508A, -- .atcai2c.slave_address = 0x07, -- .atcai2c.bus = busNum, -- .atcai2c.baud = 400000, -- .wake_delay = 800, -- .rx_retries = 3 -- }; -- -- ATCAHAL_t hal; -- -- if (busNum < 0) -- { -- return ATCA_COMM_FAIL; -- } -- -- hal_i2c_init(&hal, &discoverCfg); -- device = newATCADevice(&discoverCfg); -- discoverIface = atGetIFace(device); -- command = atGetCommands(device); -- -- // iterate through all addresses on given i2c bus -- // all valid 7-bit addresses go from 0x07 to 0x78 -- for (slaveAddress = 0x07; slaveAddress <= 0x78; slaveAddress++) -- { -- discoverCfg.atcai2c.slave_address = slaveAddress << 1; // turn it into an 8-bit address which is what the rest of the i2c HAL is expecting when a packet is sent -- -- // wake up device -- // If it wakes, send it a dev rev command. Based on that response, determine the device type -- // BTW - this will wake every cryptoauth device living on the same bus (ecc508a, sha204a) -- -- if (hal_i2c_wake(discoverIface) == ATCA_SUCCESS) -- { -- (*found)++; -- memcpy( (uint8_t*)head, (uint8_t*)&discoverCfg, sizeof(ATCAIfaceCfg)); -- -- memset(packet.data, 0x00, sizeof(packet.data)); -- -- // get devrev info and set device type accordingly -- atInfo(command, &packet); -- if ((status = atGetExecTime(packet.opcode, command)) != ATCA_SUCCESS) -- { -- continue; -- } -- -- // send the command -- if ( (status = atsend(discoverIface, (uint8_t*)&packet, packet.txsize)) != ATCA_SUCCESS) -- { -- printf("packet send error\r\n"); -- continue; -- } -- -- // delay the appropriate amount of time for command to execute -- atca_delay_ms((command->execution_time_msec) + 1); -- -- // receive the response -- if ( (status = atreceive(discoverIface, &(packet.data[0]), &(packet.rxsize) )) != ATCA_SUCCESS) -- { -- continue; -- } -- -- if ( (status = isATCAError(packet.data)) != ATCA_SUCCESS) -- { -- continue; -- } -- -- // determine device type from common info and dev rev response byte strings -- for (i = 0; i < (int)sizeof(revs508) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs508[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC508A; -- break; -- } -- } -- -- for (i = 0; i < (int)sizeof(revs204) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs204[i], 4) == 0) -- { -- discoverCfg.devtype = ATSHA204A; -- break; -- } -- } -- -- for (i = 0; i < (int)sizeof(revs108) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs108[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC108A; -- break; -- } -- } -- -- atca_delay_ms(15); -- // now the device type is known, so update the caller's cfg array element with it -- head->devtype = discoverCfg.devtype; -- head++; -- } -- -- hal_i2c_idle(discoverIface); -- } -- -- //hal_i2c_release(&hal); -- -- return ATCA_SUCCESS; --} -- --/** -- * \brief -- * hal_i2c_init manages requests to initialize a physical interface. It manages use counts so when an interface -- * has released the physical layer, it will disable the interface for some other use. -- * You can have multiple ATCAIFace instances using the same bus, and you can have multiple ATCAIFace instances on -- * multiple i2c buses, so hal_i2c_init manages these things and ATCAIFace is abstracted from the physical details. -- */ -- --/** -- * \brief initialize an I2C interface using given config -- * -- * \param[in] hal - opaque ptr to HAL data -- * \param[in] cfg - interface configuration -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_init(void *hal, ATCAIfaceCfg *cfg) --{ -- // set to default i2c bus -- if (cfg->atcai2c.bus > MAX_I2C_BUSES - 1) -- { -- cfg->atcai2c.bus = 0; -- } -- int bus = cfg->atcai2c.bus; // 0-based logical bus number -- ATCAHAL_t *phal = (ATCAHAL_t*)hal; -- -- if (i2c_bus_ref_ct == 0) // power up state, no i2c buses will have been used -- -- { -- for (int i = 0; i < MAX_I2C_BUSES; i++) -- { -- i2c_hal_data[i] = NULL; -- } -- } -- -- i2c_bus_ref_ct++; // total across buses -- -- if (bus >= 0 && bus < MAX_I2C_BUSES) -- { -- // if this is the first time this bus and interface has been created, do the physical work of enabling it -- if (i2c_hal_data[bus] == NULL) -- { -- i2c_hal_data[bus] = malloc(sizeof(ATCAI2CMaster_t)); -- i2c_hal_data[bus]->ref_ct = 1; // buses are shared, this is the first instance -- -- switch (bus) -- { -- case 0: -- i2c_hal_data[bus]->twi_id = ID_TWI0; -- i2c_hal_data[bus]->twi_master_instance = TWI0; -- break; -- case 1: -- i2c_hal_data[bus]->twi_id = ID_TWI1; -- i2c_hal_data[bus]->twi_master_instance = TWI1; -- // configure TWI1 pins -- gpio_configure_pin(PIO_PB4_IDX, (PIO_PERIPH_A | PIO_PULLUP)); -- gpio_configure_pin(PIO_PB5_IDX, (PIO_PERIPH_A | PIO_PULLUP)); -- // disable JTAG -- MATRIX->CCFG_SYSIO |= (1 << 4) | (1 << 5); -- break; -- } -- -- pmc_enable_periph_clk(i2c_hal_data[bus]->twi_id); -- -- opt_twi_master.master_clk = sysclk_get_cpu_hz(); -- opt_twi_master.speed = cfg->atcai2c.baud; -- opt_twi_master.smbus = 0; -- -- twi_master_init(i2c_hal_data[bus]->twi_master_instance, &opt_twi_master); -- -- // store this for use during the release phase -- i2c_hal_data[bus]->bus_index = bus; -- } -- else -- { -- // otherwise, another interface already initialized the bus, so this interface will share it and any different -- // cfg parameters will be ignored...first one to initialize this sets the configuration -- i2c_hal_data[bus]->ref_ct++; -- } -- -- phal->hal_data = i2c_hal_data[bus]; -- -- return ATCA_SUCCESS; -- } -- -- return ATCA_COMM_FAIL; --} -- --/** -- * \brief HAL implementation of I2C post init -- * -- * \param[in] iface instance -- * -- * \return ATCA_SUCCESS -- */ --ATCA_STATUS hal_i2c_post_init(ATCAIface iface) --{ -- return ATCA_SUCCESS; --} -- --/** -- * \brief HAL implementation of I2C send over ASF -- * -- * \param[in] iface instance -- * \param[in] txdata pointer to space to bytes to send -- * \param[in] txlength number of bytes to send -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_send(ATCAIface iface, uint8_t *txdata, int txlength) --{ --#ifdef DEBUG_HAL -- printf("hal_i2c_send()\r\n"); -- -- printf("\r\nCommand Packet (size:0x%.8x)\r\n", (uint32_t)txlength); -- printf("Count : %.2x\r\n", txdata[1]); -- printf("Opcode : %.2x\r\n", txdata[2]); -- printf("Param1 : %.2x\r\n", txdata[3]); -- printf("Param2 : "); print_array(&txdata[4], 2); -- if (txdata[1] > 7) -- { -- printf("Data : "); print_array(&txdata[6], txdata[1] - 7); -- } -- printf("CRC : "); print_array(&txdata[txdata[1] - 1], 2); -- printf("\r\n"); --#endif -- -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- // set to default i2c bus -- if (cfg->atcai2c.bus > MAX_I2C_BUSES - 1) -- { -- cfg->atcai2c.bus = 0; -- } -- int bus = cfg->atcai2c.bus; -- -- txdata[0] = 0x03; // insert the Word Address Value, Command token -- txlength++; // account for word address value byte. -- -- twi_package_t packet = { -- .chip = cfg->atcai2c.slave_address >> 1, -- .addr = { 0 }, -- .addr_length = 0, -- .buffer = (void*)txdata, -- .length = (uint32_t)txlength //(uint32_t)txdata[1] -- }; -- -- // for this implementation of I2C with CryptoAuth chips, txdata is assumed to have ATCAPacket format -- -- // other device types that don't require i/o tokens on the front end of a command need a different hal_i2c_send and wire it up instead of this one -- // this covers devices such as ATSHA204A and ATECCx08A that require a word address value pre-pended to the packet -- -- if (twi_master_write(i2c_hal_data[bus]->twi_master_instance, &packet) != TWI_SUCCESS) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** -- * \brief HAL implementation of I2C receive function for ASF I2C -- * -- * \param[in] iface instance -- * \param[out] rxdata pointer to space to receive the data -- * \param[in] rxlength ptr to expected number of receive bytes to request -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_receive(ATCAIface iface, uint8_t *rxdata, uint16_t *rxlength) --{ --#ifdef DEBUG_HAL -- printf("hal_i2c_receive()\r\n"); --#endif -- -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- // set to default i2c bus -- if (cfg->atcai2c.bus > MAX_I2C_BUSES - 1) -- { -- cfg->atcai2c.bus = 0; -- } -- int bus = cfg->atcai2c.bus; -- int retries = cfg->rx_retries; -- uint32_t status = !TWI_SUCCESS; -- -- twi_package_t packet = { -- .chip = cfg->atcai2c.slave_address >> 1, -- .addr = { 0 }, -- .addr_length = 0, -- .buffer = (void*)rxdata, -- .length = (uint32_t)*rxlength -- }; -- -- while (retries-- > 0 && status != TWI_SUCCESS) -- { -- status = twi_master_read(i2c_hal_data[bus]->twi_master_instance, &packet); -- } -- if (status != TWI_SUCCESS) -- { -- return ATCA_COMM_FAIL; -- } -- --#ifdef DEBUG_HAL -- printf("\r\nResponse Packet (size:0x%.4x)\r\n", rxlength); -- printf("Count : %.2x\r\n", rxdata[0]); -- if (rxdata[0] > 3) -- { -- printf("Data : "); print_array(&rxdata[1], rxdata[0] - 3); -- printf("CRC : "); print_array(&rxdata[rxdata[0] - 2], 2); -- } -- printf("\r\n"); --#endif -- -- return ATCA_SUCCESS; --} -- --/** -- * \brief method to change the bus speed of I2C -- * -- * \param[in] iface interface on which to change bus speed -- * \param[in] speed baud rate (typically 100000 or 400000) -- */ --void change_i2c_speed(ATCAIface iface, uint32_t speed) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- -- // set to default i2c bus -- if (cfg->atcai2c.bus > MAX_I2C_BUSES - 1) -- { -- cfg->atcai2c.bus = 0; -- } -- int bus = cfg->atcai2c.bus; -- -- pmc_enable_periph_clk(i2c_hal_data[bus]->twi_id); -- -- opt_twi_master.master_clk = sysclk_get_cpu_hz(); -- opt_twi_master.speed = speed; -- opt_twi_master.smbus = 0; -- -- twi_master_init(i2c_hal_data[bus]->twi_master_instance, &opt_twi_master); --} -- --/** -- * \brief wake up CryptoAuth device using I2C bus -- * -- * \param[in] iface interface to logical device to wakeup -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_wake(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- -- // set to default i2c bus -- if (cfg->atcai2c.bus > MAX_I2C_BUSES - 1) -- { -- cfg->atcai2c.bus = 0; -- } -- int bus = cfg->atcai2c.bus; -- int retries = cfg->rx_retries; -- uint32_t bdrt = cfg->atcai2c.baud; -- int status = !TWI_SUCCESS; -- uint8_t data[4], expected[4] = { 0x04, 0x11, 0x33, 0x43 }; -- -- // if not already at 100kHz, change it -- if (bdrt != 100000) -- { -- change_i2c_speed(iface, 100000); -- } -- -- // Send 0x00 as wake pulse -- twi_write_byte(i2c_hal_data[bus]->twi_master_instance, 0x00); -- -- // rounded up to the nearest ms -- atca_delay_ms(((uint32_t)cfg->wake_delay + (1000 - 1)) / 1000); // wait tWHI + tWLO which is configured based on device type and configuration structure -- -- twi_package_t packet = { -- .chip = cfg->atcai2c.slave_address >> 1, -- .addr = { 0 }, -- .addr_length = 0, -- .buffer = (void*)data, -- .length = 4 -- }; -- -- // if necessary, revert baud rate to what came in. -- if (bdrt != 100000) -- { -- change_i2c_speed(iface, bdrt); -- } -- -- while (retries-- > 0 && status != TWI_SUCCESS) -- { -- status = twi_master_read(i2c_hal_data[bus]->twi_master_instance, &packet); -- } -- if (status != TWI_SUCCESS) -- { -- return ATCA_COMM_FAIL; -- } -- -- if (memcmp(data, expected, 4) == 0) -- { -- return ATCA_SUCCESS; -- } -- -- return ATCA_COMM_FAIL; --} -- --/** -- * \brief idle CryptoAuth device using I2C bus -- * -- * \param[in] iface interface to logical device to idle -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_idle(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- -- // set to default i2c bus -- if (cfg->atcai2c.bus > MAX_I2C_BUSES - 1) -- { -- cfg->atcai2c.bus = 0; -- } -- int bus = cfg->atcai2c.bus; -- uint8_t data[4]; -- -- data[0] = 0x02; // idle word address value -- -- twi_package_t packet = { -- .chip = cfg->atcai2c.slave_address >> 1, -- .addr = { 0 }, -- .addr_length = 0, -- .buffer = (void*)data, -- .length = 1 -- }; -- -- if (twi_master_write(i2c_hal_data[bus]->twi_master_instance, &packet) != TWI_SUCCESS) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** -- * \brief sleep CryptoAuth device using I2C bus -- * -- * \param[in] iface interface to logical device to sleep -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_sleep(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- -- // set to default i2c bus -- if (cfg->atcai2c.bus > MAX_I2C_BUSES - 1) -- { -- cfg->atcai2c.bus = 0; -- } -- int bus = cfg->atcai2c.bus; -- uint8_t data[4]; -- -- data[0] = 0x01; // sleep word address value -- -- twi_package_t packet = { -- .chip = cfg->atcai2c.slave_address >> 1, -- .addr = { 0 }, -- .addr_length = 0, -- .buffer = (void*)data, -- .length = 1 -- }; -- -- if (twi_master_write(i2c_hal_data[bus]->twi_master_instance, &packet) != TWI_SUCCESS) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** -- * \brief manages reference count on given bus and releases resource if no more refences exist -- * -- * \param[in] hal_data - opaque pointer to hal data structure - known only to the HAL implementation -- * -- * \return ATCA_SUCCESS -- */ --ATCA_STATUS hal_i2c_release(void *hal_data) --{ -- ATCAI2CMaster_t *hal = (ATCAI2CMaster_t*)hal_data; -- -- // set to default i2c bus -- if (hal->bus_index > MAX_I2C_BUSES - 1) -- { -- hal->bus_index = 0; -- } -- -- i2c_bus_ref_ct--; // track total i2c bus interface instances for consistency checking and debugging -- -- // if the use count for this bus has gone to 0 references, disable it. protect against an unbracketed release -- if (hal && --(hal->ref_ct) <= 0 && i2c_hal_data[hal->bus_index] != NULL) -- { -- twi_reset(hal->twi_master_instance); -- free(i2c_hal_data[hal->bus_index]); -- i2c_hal_data[hal->bus_index] = NULL; -- } -- -- return ATCA_SUCCESS; --} -- --/** @} */ -diff --git a/lib/hal/hal_sam4s_i2c_asf.h b/lib/hal/hal_sam4s_i2c_asf.h -deleted file mode 100644 -index dea016a08be9..000000000000 ---- a/lib/hal/hal_sam4s_i2c_asf.h -+++ /dev/null -@@ -1,67 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for SAM4S I2C over ASF drivers. -- * -- * Prerequisite: add "TWI - Two-Wire Interface (Common API) (service)" module to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef HAL_SAM4S_I2C_ASF_H_ --#define HAL_SAM4S_I2C_ASF_H_ -- --#include -- -- --/** -- * \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * using I2C driver of ASF. -- * -- @{ */ -- --#define MAX_I2C_BUSES 2 // SAM4S has 2 TWI -- --/** -- * \brief this is the hal_data for ATCA HAL -- */ --typedef struct atcaI2Cmaster --{ -- uint32_t twi_id; -- Twi * twi_master_instance; -- int ref_ct; -- // for conveniences during interface release phase -- int bus_index; --} ATCAI2CMaster_t; -- --void change_i2c_speed(ATCAIface iface, uint32_t speed); -- --/** @} */ -- --#endif /* HAL_SAM4S_I2C_ASF_H_ */ -\ No newline at end of file -diff --git a/lib/hal/hal_sam4s_timer_asf.c b/lib/hal/hal_sam4s_timer_asf.c -deleted file mode 100644 -index c3c937c25252..000000000000 ---- a/lib/hal/hal_sam4s_timer_asf.c -+++ /dev/null -@@ -1,86 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for SAM4S I2C over ASF drivers. -- * -- * Prerequisite: add "Delay routines (service)" module to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include "atca_hal.h" -- -- --/* ASF already have delay_us and delay_ms - see delay.h */ -- --/** -- * \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- --/** -- * \brief This function delays for a number of microseconds. -- * -- * \param[in] delay number of 0.001 milliseconds to delay -- */ --void atca_delay_us(uint32_t delay) --{ -- // use ASF supplied delay -- delay_us(delay); --} -- --/** -- * \brief This function delays for a number of tens of microseconds. -- * -- * \param[in] delay number of 0.01 milliseconds to delay -- */ --void atca_delay_10us(uint32_t delay) --{ -- // use ASF supplied delay -- delay_us(delay * 10); -- --} -- --/** -- * \brief This function delays for a number of milliseconds. -- * -- * You can override this function if you like to do -- * something else in your system while delaying. -- * -- * \param[in] delay number of milliseconds to delay -- */ --void atca_delay_ms(uint32_t delay) --{ -- // use ASF supplied delay -- delay_ms(delay); --} -- --/** @} */ -diff --git a/lib/hal/hal_samb11_i2c_asf.c b/lib/hal/hal_samb11_i2c_asf.c -deleted file mode 100644 -index aa12364e62c7..000000000000 ---- a/lib/hal/hal_samb11_i2c_asf.c -+++ /dev/null -@@ -1,485 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for SAMB11 I2C over ASF drivers. -- * -- * This code is structured in two parts. Part 1 is the connection of the ATCA HAL API to the physical I2C -- * implementation. Part 2 is the ASF I2C primitives to set up the interface. -- * -- * Prerequisite: add I2C Master Polled support to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include -- --#include "atca_hal.h" --#include "hal_samb11_i2c_asf.h" --#include "atca_device.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * using I2C driver of ASF. -- * -- @{ */ -- --/** \brief logical to physical bus mapping structure */ --ATCAI2CMaster_t *i2c_hal_data[MAX_I2C_BUSES]; // map logical, 0-based bus number to index --int i2c_bus_ref_ct = 0; // total in-use count across buses --static struct i2c_master_config config_i2c_master; -- --/** \brief discover i2c buses available for this hardware -- * this maintains a list of logical to physical bus mappings freeing the application -- * of the a-priori knowledge -- * \param[in] i2c_buses - an array of logical bus numbers -- * \param[in] max_buses - maximum number of buses the app wants to attempt to discover -- * \return ATCA_SUCCESS -- */ -- --ATCA_STATUS hal_i2c_discover_buses(int i2c_buses[], int max_buses) --{ -- i2c_buses[0] = 0; // b11 bus for xplained pro dev board over EXT1 -- i2c_buses[1] = 1; // b11 bus for MR510CA -- -- return ATCA_SUCCESS; --} -- --/** \brief discover any CryptoAuth devices on a given logical bus number -- * \param[in] busNum logical bus number on which to look for CryptoAuth devices -- * \param[out] cfg pointer to head of an array of interface config structures which get filled in by this method -- * \param[out] found number of devices found on this bus -- * \return ATCA_SUCCESS -- */ -- --ATCA_STATUS hal_i2c_discover_devices(int busNum, ATCAIfaceCfg cfg[], int *found) --{ -- ATCAIfaceCfg *head = cfg; -- uint8_t slaveAddress = 0x01; -- ATCADevice device; -- ATCAIface discoverIface; -- ATCACommand command; -- ATCAPacket packet; -- ATCA_STATUS status; -- uint8_t revs508[1][4] = { { 0x00, 0x00, 0x50, 0x00 } }; -- uint8_t revs108[1][4] = { { 0x80, 0x00, 0x10, 0x01 } }; -- uint8_t revs204[3][4] = { { 0x00, 0x02, 0x00, 0x08 }, -- { 0x00, 0x02, 0x00, 0x09 }, -- { 0x00, 0x04, 0x05, 0x00 } }; -- int i; -- -- -- /** \brief default configuration, to be reused during discovery process */ -- ATCAIfaceCfg discoverCfg = { -- .iface_type = ATCA_I2C_IFACE, -- .devtype = ATECC508A, -- .atcai2c.slave_address = 0x07, -- .atcai2c.bus = busNum, -- .atcai2c.baud = 400000, -- //.atcai2c.baud = 100000, -- .wake_delay = 800, -- .rx_retries = 3 -- }; -- -- ATCAHAL_t hal; -- -- hal_i2c_init(&hal, &discoverCfg); -- device = newATCADevice(&discoverCfg); -- discoverIface = atGetIFace(device); -- command = atGetCommands(device); -- -- for (slaveAddress = 0x07; slaveAddress <= 0x78; slaveAddress++) -- { -- discoverCfg.atcai2c.slave_address = slaveAddress << 1; // turn it into an 8-bit address which is what the rest of the i2c HAL is expecting when a packet is sent -- -- // wake up device -- // If it wakes, send it a dev rev command. Based on that response, determine the device type -- // BTW - this will wake every cryptoauth device living on the same bus (ecc508a, sha204a) -- -- if (hal_i2c_wake(discoverIface) == ATCA_SUCCESS) -- { -- (*found)++; -- memcpy( (uint8_t*)head, (uint8_t*)&discoverCfg, sizeof(ATCAIfaceCfg)); -- -- memset(packet.data, 0x00, sizeof(packet.data)); -- -- // build an info command -- packet.param1 = INFO_MODE_REVISION; -- packet.param2 = 0; -- -- // get devrev info and set device type accordingly -- atInfo(command, &packet); -- if ((status = atGetExecTime(packet.opcode, command)) != ATCA_SUCCESS) -- { -- continue; -- } -- -- // send the command -- if ( (status = atsend(discoverIface, (uint8_t*)&packet, packet.txsize)) != ATCA_SUCCESS) -- { -- printf("packet send error\r\n"); -- continue; -- } -- -- // delay the appropriate amount of time for command to execute -- atca_delay_ms((command->execution_time_msec) + 1); -- -- // receive the response -- if ( (status = atreceive(discoverIface, &(packet.data[0]), &(packet.rxsize) )) != ATCA_SUCCESS) -- { -- continue; -- } -- -- if ( (status = isATCAError(packet.data)) != ATCA_SUCCESS) -- { -- printf("command response error\r\n"); -- continue; -- } -- -- // determine device type from common info and dev rev response byte strings -- for (i = 0; i < (int)sizeof(revs508) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs508[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC508A; -- break; -- } -- } -- -- for (i = 0; i < (int)sizeof(revs204) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs204[i], 4) == 0) -- { -- discoverCfg.devtype = ATSHA204A; -- break; -- } -- } -- -- for (i = 0; i < (int)sizeof(revs108) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs108[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC108A; -- break; -- } -- } -- -- atca_delay_ms(15); -- // now the device type is known, so update the caller's cfg array element with it -- head->devtype = discoverCfg.devtype; -- head++; -- } -- -- hal_i2c_idle(discoverIface); -- } -- -- hal_i2c_release(&hal); -- -- return ATCA_SUCCESS; --} -- --/** \brief -- - this HAL implementation assumes you've included the ASF I2C libraries in your project, otherwise, -- the HAL layer will not compile because the ASF I2C drivers are a dependency * -- */ -- --/** \brief hal_i2c_init manages requests to initialize a physical interface. it manages use counts so when an interface -- * has released the physical layer, it will disable the interface for some other use. -- * You can have multiple ATCAIFace instances using the same bus, and you can have multiple ATCAIFace instances on -- * multiple i2c buses, so hal_i2c_init manages these things and ATCAIFace is abstracted from the physical details. -- */ -- --/** \brief initialize an I2C interface using given config -- * \param[in] hal - opaque ptr to HAL data -- * \param[in] cfg - interface configuration -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_init(void *hal, ATCAIfaceCfg *cfg) --{ -- int bus = cfg->atcai2c.bus; // 0-based logical bus number -- ATCAHAL_t *phal = (ATCAHAL_t*)hal; -- -- if (i2c_bus_ref_ct == 0) // power up state, no i2c buses will have been used -- { -- for (int i = 0; i < MAX_I2C_BUSES; i++) -- { -- i2c_hal_data[i] = NULL; -- } -- } -- -- i2c_bus_ref_ct++; // total across buses -- -- if (bus >= 0 && bus < MAX_I2C_BUSES) -- { -- // if this is the first time this bus and interface has been created, do the physical work of enabling it -- if (i2c_hal_data[bus] == NULL) -- { -- i2c_hal_data[bus] = malloc(sizeof(ATCAI2CMaster_t) ); -- i2c_hal_data[bus]->ref_ct = 1; // buses are shared, this is the first instance -- i2c_master_get_config_defaults(&config_i2c_master); -- -- switch (bus) -- { -- case 0: -- config_i2c_master.pin_number_pad0 = PIN_LP_GPIO_8; -- config_i2c_master.pin_number_pad1 = PIN_LP_GPIO_9; -- config_i2c_master.pinmux_sel_pad0 = PINMUX_LP_GPIO_8_MUX2_I2C0_SDA; -- config_i2c_master.pinmux_sel_pad1 = PINMUX_LP_GPIO_9_MUX2_I2C0_SCL; -- i2c_master_init(&(i2c_hal_data[bus]->i2c_master_instance), I2C0, &config_i2c_master); -- break; -- case 1: -- config_i2c_master.pin_number_pad0 = PIN_LP_GPIO_14; -- config_i2c_master.pin_number_pad1 = PIN_LP_GPIO_15; -- config_i2c_master.pinmux_sel_pad0 = PINMUX_LP_GPIO_14_MUX4_I2C1_SDA; -- config_i2c_master.pinmux_sel_pad1 = PINMUX_LP_GPIO_15_MUX4_I2C1_SCL; -- i2c_master_init(&(i2c_hal_data[bus]->i2c_master_instance), I2C1, &config_i2c_master); -- break; -- } -- -- // store this for use during the release phase -- i2c_hal_data[bus]->bus_index = bus; -- -- i2c_enable((i2c_hal_data[bus]->i2c_master_instance).hw); -- } -- else -- { -- // otherwise, another interface already initialized the bus, so this interface will share it and any different -- // cfg parameters will be ignored...first one to initialize this sets the configuration -- i2c_hal_data[bus]->ref_ct++; -- } -- -- phal->hal_data = i2c_hal_data[bus]; -- -- return ATCA_SUCCESS; -- } -- -- return ATCA_COMM_FAIL; --} -- --/** \brief HAL implementation of I2C post init -- * \param[in] iface instance -- * \return ATCA_SUCCESS -- */ --ATCA_STATUS hal_i2c_post_init(ATCAIface iface) --{ -- return ATCA_SUCCESS; --} -- --/** \brief HAL implementation of I2C send over ASF -- * \param[in] iface instance -- * \param[in] txdata pointer to space to bytes to send -- * \param[in] txlength number of bytes to send -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_send(ATCAIface iface, uint8_t *txdata, int txlength) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- -- struct i2c_master_packet packet = { -- .address = cfg->atcai2c.slave_address >> 1, -- .data_length = txlength, -- .data = txdata, -- }; -- -- // for this implementation of I2C with CryptoAuth chips, txdata is assumed to have ATCAPacket format -- -- // other device types that don't require i/o tokens on the front end of a command need a different hal_i2c_send and wire it up instead of this one -- // this covers devices such as ATSHA204A and ATECCx08A that require a word address value pre-pended to the packet -- // txdata[0] is using _reserved byte of the ATCAPacket -- txdata[0] = 0x03; // insert the Word Address Value, Command token -- txlength++; // account for word address value byte. -- packet.data_length = txlength; -- -- if (i2c_master_write_packet_wait(&(i2c_hal_data[bus]->i2c_master_instance), &packet) != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** \brief HAL implementation of I2C receive function for ASF I2C -- * \param[in] iface instance -- * \param[in] rxdata pointer to space to receive the data -- * \param[in] rxlength ptr to expected number of receive bytes to request -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_receive(ATCAIface iface, uint8_t *rxdata, uint16_t *rxlength) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- int retries = cfg->rx_retries; -- int status = !STATUS_OK; -- -- struct i2c_master_packet packet = { -- .address = cfg->atcai2c.slave_address >> 1, -- .data_length = *rxlength, -- .data = rxdata, -- }; -- -- while (retries-- > 0 && status != STATUS_OK) -- { -- status = i2c_master_read_packet_wait(&(i2c_hal_data[bus]->i2c_master_instance), &packet); -- } -- -- if (status != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** \brief wake up CryptoAuth device using I2C bus -- * \param[in] iface interface to logical device to wakeup -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_wake(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- int retries = cfg->rx_retries; -- int status = !STATUS_OK; -- uint8_t data[4], expected[4] = { 0x04, 0x11, 0x33, 0x43 }; -- -- // Send the wake by writing to an address of 0x00 -- struct i2c_master_packet packet = { -- .address = 0x00, -- .data_length = 0, -- .data = &data[0], -- }; -- -- // Send the 00 address as the wake pulse -- i2c_master_write_packet_wait(&(i2c_hal_data[bus]->i2c_master_instance), &packet); // part will NACK, so don't check for status -- -- atca_delay_us(cfg->wake_delay); // wait tWHI + tWLO which is configured based on device type and configuration structure -- -- packet.address = cfg->atcai2c.slave_address >> 1; -- packet.data_length = 4; -- packet.data = data; -- -- while (retries-- > 0 && status != STATUS_OK) -- { -- status = i2c_master_read_packet_wait(&(i2c_hal_data[bus]->i2c_master_instance), &packet); -- } -- -- -- if (status != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- if (memcmp(data, expected, 4) == 0) -- { -- return ATCA_SUCCESS; -- } -- -- return ATCA_COMM_FAIL; --} -- --/** \brief idle CryptoAuth device using I2C bus -- * \param[in] iface interface to logical device to idle -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_idle(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- uint8_t data[4]; -- -- struct i2c_master_packet packet = { -- .address = cfg->atcai2c.slave_address >> 1, -- .data_length = 1, -- .data = &data[0], -- }; -- -- data[0] = 0x02; // idle word address value -- if (i2c_master_write_packet_wait(&(i2c_hal_data[bus]->i2c_master_instance), &packet) != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; -- --} -- --/** \brief sleep CryptoAuth device using I2C bus -- * \param[in] iface interface to logical device to sleep -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_sleep(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- uint8_t data[4]; -- -- struct i2c_master_packet packet = { -- .address = cfg->atcai2c.slave_address >> 1, -- .data_length = 1, -- .data = data, -- }; -- -- data[0] = 0x01; // sleep word address value -- if (i2c_master_write_packet_wait(&(i2c_hal_data[bus]->i2c_master_instance), &packet) != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** \brief manages reference count on given bus and releases resource if no more references exist -- * \param[in] hal_data - opaque pointer to hal data structure - known only to the HAL implementation -- * \return ATCA_SUCCESS -- */ -- --ATCA_STATUS hal_i2c_release(void *hal_data) --{ -- ATCAI2CMaster_t *hal = (ATCAI2CMaster_t*)hal_data; -- -- i2c_bus_ref_ct--; // track total i2c bus interface instances for consistency checking and debugging -- -- // if the use count for this bus has gone to 0 references, disable it. protect against an unbracketed release -- if (hal && --(hal->ref_ct) <= 0 && i2c_hal_data[hal->bus_index] != NULL) -- { -- i2c_master_reset(&(hal->i2c_master_instance)); -- free(i2c_hal_data[hal->bus_index]); -- i2c_hal_data[hal->bus_index] = NULL; -- } -- -- return ATCA_SUCCESS; --} -- --/** @} */ -diff --git a/lib/hal/hal_samb11_i2c_asf.h b/lib/hal/hal_samb11_i2c_asf.h -deleted file mode 100644 -index 0c2243a3c703..000000000000 ---- a/lib/hal/hal_samb11_i2c_asf.h -+++ /dev/null -@@ -1,60 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for SAMB11 I2C over ASF drivers. -- * -- * Prerequisite: add SERCOM I2C Master Polled support to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef HAL_SAMB11_I2C_ASF_H_ --#define HAL_SAMB11_I2C_ASF_H_ -- --#include -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * using I2C driver of ASF. -- * -- @{ */ -- --#define MAX_I2C_BUSES 2 // SAMB11 has up to 2 I2C address that can be configured as I2C -- --/** \brief this is the hal_data for ATCA HAL for ASF -- */ --typedef struct atcaI2Cmaster --{ -- struct i2c_master_module i2c_master_instance; -- int ref_ct; -- // for conveniences during interface release phase -- int bus_index; --} ATCAI2CMaster_t; -- --/** @} */ --#endif /* HAL_SAMB11_I2C_ASF_H_ */ -\ No newline at end of file -diff --git a/lib/hal/hal_samb11_timer_asf.c b/lib/hal/hal_samb11_timer_asf.c -deleted file mode 100644 -index dd0a21fea7ee..000000000000 ---- a/lib/hal/hal_samb11_timer_asf.c -+++ /dev/null -@@ -1,78 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for SAMB11 timer/delay over ASF drivers. -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include "atca_hal.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- --/** \brief This function delays for a number of microseconds. -- * -- * \param[in] delay number of 0.001 milliseconds to delay -- */ --void atca_delay_us(uint32_t delay) --{ -- // use ASF supplied delay -- delay_us(delay); --} -- --/** \brief This function delays for a number of tens of microseconds. -- * -- * \param[in] delay number of 0.01 milliseconds to delay -- */ --void atca_delay_10us(uint32_t delay) --{ -- // use ASF supplied delay -- delay_us(delay * 10); -- --} -- --/** \brief This function delays for a number of milliseconds. -- * -- * You can override this function if you like to do -- * something else in your system while delaying. -- * \param[in] delay number of milliseconds to delay -- */ -- --/* ASF already has delay_ms - see delay.h */ --void atca_delay_ms(uint32_t delay) --{ -- // use ASF supplied delay -- delay_ms(delay); --} -- --/** @} */ -diff --git a/lib/hal/hal_samd21_i2c_asf.c b/lib/hal/hal_samd21_i2c_asf.c -deleted file mode 100644 -index 841a1fb9125e..000000000000 ---- a/lib/hal/hal_samd21_i2c_asf.c -+++ /dev/null -@@ -1,572 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for SAMD21 I2C over ASF drivers. -- * -- * This code is structured in two parts. Part 1 is the connection of the ATCA HAL API to the physical I2C -- * implementation. Part 2 is the ASF I2C primitives to set up the interface. -- * -- * Prerequisite: add SERCOM I2C Master Polled support to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include -- --#include "atca_hal.h" --#include "hal_samd21_i2c_asf.h" --#include "atca_device.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * using I2C driver of ASF. -- * -- @{ */ -- --/** \brief logical to physical bus mapping structure */ --ATCAI2CMaster_t *i2c_hal_data[MAX_I2C_BUSES]; // map logical, 0-based bus number to index --int i2c_bus_ref_ct = 0; // total in-use count across buses --static struct i2c_master_config config_i2c_master; -- --/** \brief discover i2c buses available for this hardware -- * this maintains a list of logical to physical bus mappings freeing the application -- * of the a-priori knowledge -- * \param[in] i2c_buses - an array of logical bus numbers -- * \param[in] max_buses - maximum number of buses the app wants to attempt to discover -- * \return ATCA_SUCCESS -- */ -- --ATCA_STATUS hal_i2c_discover_buses(int i2c_buses[], int max_buses) --{ -- -- /* if every SERCOM was a likely candidate bus, then would need to initialize the entire array to all SERCOM n numbers. -- * As an optimization and making discovery safer, make assumptions about bus-num / SERCOM map based on D21 Xplained Pro board -- * If you were using a raw D21 on your own board, you would supply your own bus numbers based on your particular hardware configuration. -- */ --#ifdef __SAMR21G18A__ -- i2c_buses[0] = 1; // default r21 for xplained pro dev board --#else -- i2c_buses[0] = 2; // default d21 for xplained pro dev board --#endif -- -- return ATCA_SUCCESS; --} -- --/** \brief discover any CryptoAuth devices on a given logical bus number -- * \param[in] busNum logical bus number on which to look for CryptoAuth devices -- * \param[out] cfg pointer to head of an array of interface config structures which get filled in by this method -- * \param[out] found number of devices found on this bus -- * \return ATCA_SUCCESS -- */ -- --ATCA_STATUS hal_i2c_discover_devices(int busNum, ATCAIfaceCfg cfg[], int *found) --{ -- ATCAIfaceCfg *head = cfg; -- uint8_t slaveAddress = 0x01; -- ATCADevice device; -- ATCAIface discoverIface; -- ATCACommand command; -- ATCAPacket packet; -- ATCA_STATUS status; -- uint8_t revs608[1][4] = { { 0x00, 0x00, 0x60, 0x01 } }; -- uint8_t revs508[1][4] = { { 0x00, 0x00, 0x50, 0x00 } }; -- uint8_t revs108[1][4] = { { 0x80, 0x00, 0x10, 0x01 } }; -- uint8_t revs204[3][4] = { { 0x00, 0x02, 0x00, 0x08 }, -- { 0x00, 0x02, 0x00, 0x09 }, -- { 0x00, 0x04, 0x05, 0x00 } }; -- int i; -- -- /** \brief default configuration, to be reused during discovery process */ -- ATCAIfaceCfg discoverCfg = { -- .iface_type = ATCA_I2C_IFACE, -- .devtype = ATECC508A, -- .atcai2c.slave_address = 0x07, -- .atcai2c.bus = busNum, -- .atcai2c.baud = 400000, -- //.atcai2c.baud = 100000, -- .wake_delay = 800, -- .rx_retries = 3 -- }; -- -- ATCAHAL_t hal; -- -- hal_i2c_init(&hal, &discoverCfg); -- device = newATCADevice(&discoverCfg); -- discoverIface = atGetIFace(device); -- command = atGetCommands(device); -- -- // iterate through all addresses on given i2c bus -- // all valid 7-bit addresses go from 0x07 to 0x78 -- for (slaveAddress = 0x07; slaveAddress <= 0x78; slaveAddress++) -- { -- discoverCfg.atcai2c.slave_address = slaveAddress << 1; // turn it into an 8-bit address which is what the rest of the i2c HAL is expecting when a packet is sent -- -- // wake up device -- // If it wakes, send it a dev rev command. Based on that response, determine the device type -- // BTW - this will wake every cryptoauth device living on the same bus (ecc508a, sha204a) -- -- if (hal_i2c_wake(discoverIface) == ATCA_SUCCESS) -- { -- (*found)++; -- memcpy( (uint8_t*)head, (uint8_t*)&discoverCfg, sizeof(ATCAIfaceCfg)); -- -- memset(&packet, 0x00, sizeof(packet)); -- -- // get devrev info and set device type accordingly -- atInfo(command, &packet); -- -- if ( (status = atGetExecTime(packet.opcode, command)) != ATCA_SUCCESS) -- { -- continue; -- } -- -- -- // send the command -- if ( (status = atsend(discoverIface, (uint8_t*)&packet, packet.txsize)) != ATCA_SUCCESS) -- { -- printf("packet send error\r\n"); -- continue; -- } -- -- // delay the appropriate amount of time for command to execute -- atca_delay_ms((command->execution_time_msec) + 1); -- -- // receive the response -- if ( (status = atreceive(discoverIface, &(packet.data[0]), &(packet.rxsize) )) != ATCA_SUCCESS) -- { -- continue; -- } -- -- if ( (status = isATCAError(packet.data)) != ATCA_SUCCESS) -- { -- printf("command response error\r\n"); -- continue; -- } -- -- // determine device type from common info and dev rev response byte strings -- for (i = 0; i < (int)sizeof(revs608) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs608[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC608A; -- break; -- } -- } -- -- for (i = 0; i < (int)sizeof(revs508) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs508[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC508A; -- break; -- } -- } -- -- for (i = 0; i < (int)sizeof(revs204) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs204[i], 4) == 0) -- { -- discoverCfg.devtype = ATSHA204A; -- break; -- } -- } -- -- for (i = 0; i < (int)sizeof(revs108) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs108[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC108A; -- break; -- } -- } -- -- atca_delay_ms(15); -- // now the device type is known, so update the caller's cfg array element with it -- head->devtype = discoverCfg.devtype; -- head++; -- } -- -- hal_i2c_idle(discoverIface); -- } -- -- hal_i2c_release(&hal); -- -- return ATCA_SUCCESS; --} -- --/** \brief -- - this HAL implementation assumes you've included the ASF SERCOM I2C libraries in your project, otherwise, -- the HAL layer will not compile because the ASF I2C drivers are a dependency * -- */ -- --/** \brief hal_i2c_init manages requests to initialize a physical interface. it manages use counts so when an interface -- * has released the physical layer, it will disable the interface for some other use. -- * You can have multiple ATCAIFace instances using the same bus, and you can have multiple ATCAIFace instances on -- * multiple i2c buses, so hal_i2c_init manages these things and ATCAIFace is abstracted from the physical details. -- */ -- --/** \brief initialize an I2C interface using given config -- * \param[in] hal - opaque ptr to HAL data -- * \param[in] cfg - interface configuration -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_init(void *hal, ATCAIfaceCfg *cfg) --{ -- int bus = cfg->atcai2c.bus; // 0-based logical bus number -- ATCAHAL_t *phal = (ATCAHAL_t*)hal; -- -- if (i2c_bus_ref_ct == 0) // power up state, no i2c buses will have been used -- { -- for (int i = 0; i < MAX_I2C_BUSES; i++) -- { -- i2c_hal_data[i] = NULL; -- } -- } -- -- i2c_bus_ref_ct++; // total across buses -- -- if (bus >= 0 && bus < MAX_I2C_BUSES) -- { -- // if this is the first time this bus and interface has been created, do the physical work of enabling it -- if (i2c_hal_data[bus] == NULL) -- { -- i2c_hal_data[bus] = malloc(sizeof(ATCAI2CMaster_t) ); -- i2c_hal_data[bus]->ref_ct = 1; // buses are shared, this is the first instance -- i2c_master_get_config_defaults(&config_i2c_master); --#ifdef __SAMR21G18A__ -- if (bus == 1) -- { -- config_i2c_master.pinmux_pad0 = PINMUX_PA16C_SERCOM1_PAD0; -- config_i2c_master.pinmux_pad1 = PINMUX_PA17C_SERCOM1_PAD1; -- } --#endif --#ifdef __SAMD21G18A__ -- if (bus == 0) -- { -- // This is to support SAMW25 configs, where the WINC1500 is on SERCOM2 -- config_i2c_master.pinmux_pad0 = PINMUX_PA08C_SERCOM0_PAD0; -- config_i2c_master.pinmux_pad1 = PINMUX_PA09C_SERCOM0_PAD1; -- } --#endif -- -- // config_i2c_master.buffer_timeout = 10000; -- config_i2c_master.baud_rate = cfg->atcai2c.baud / 1000; -- -- switch (bus) -- { -- case 0: i2c_master_init(&(i2c_hal_data[bus]->i2c_master_instance), SERCOM0, &config_i2c_master); break; -- case 1: i2c_master_init(&(i2c_hal_data[bus]->i2c_master_instance), SERCOM1, &config_i2c_master); break; -- case 2: i2c_master_init(&(i2c_hal_data[bus]->i2c_master_instance), SERCOM2, &config_i2c_master); break; -- case 3: i2c_master_init(&(i2c_hal_data[bus]->i2c_master_instance), SERCOM3, &config_i2c_master); break; -- case 4: i2c_master_init(&(i2c_hal_data[bus]->i2c_master_instance), SERCOM4, &config_i2c_master); break; -- case 5: i2c_master_init(&(i2c_hal_data[bus]->i2c_master_instance), SERCOM5, &config_i2c_master); break; -- } -- -- // store this for use during the release phase -- i2c_hal_data[bus]->bus_index = bus; -- i2c_master_enable(&(i2c_hal_data[bus]->i2c_master_instance)); -- } -- else -- { -- // otherwise, another interface already initialized the bus, so this interface will share it and any different -- // cfg parameters will be ignored...first one to initialize this sets the configuration -- i2c_hal_data[bus]->ref_ct++; -- } -- -- phal->hal_data = i2c_hal_data[bus]; -- -- return ATCA_SUCCESS; -- } -- -- return ATCA_COMM_FAIL; --} -- --/** \brief HAL implementation of I2C post init -- * \param[in] iface instance -- * \return ATCA_SUCCESS -- */ --ATCA_STATUS hal_i2c_post_init(ATCAIface iface) --{ -- return ATCA_SUCCESS; --} -- --/** \brief HAL implementation of I2C send over ASF -- * \param[in] iface instance -- * \param[in] txdata pointer to space to bytes to send -- * \param[in] txlength number of bytes to send -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_send(ATCAIface iface, uint8_t *txdata, int txlength) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- -- struct i2c_master_packet packet = { -- .address = cfg->atcai2c.slave_address >> 1, -- .data_length = txlength, -- .data = txdata, -- .ten_bit_address = false, -- .high_speed = false, -- .hs_master_code = 0x0, -- }; -- -- // for this implementation of I2C with CryptoAuth chips, txdata is assumed to have ATCAPacket format -- -- // other device types that don't require i/o tokens on the front end of a command need a different hal_i2c_send and wire it up instead of this one -- // this covers devices such as ATSHA204A and ATECCx08A that require a word address value pre-pended to the packet -- // txdata[0] is using _reserved byte of the ATCAPacket -- txdata[0] = 0x03; // insert the Word Address Value, Command token -- txlength++; // account for word address value byte. -- packet.data_length = txlength; -- -- // statusCode = i2c_master_write_packet_wait(&i2c_master_instance, &packet); -- //if ( i2c_master_write_packet_wait_no_stop( &(i2c_hal_data[bus]->i2c_master_instance), &packet) != STATUS_OK) -- if (i2c_master_write_packet_wait(&(i2c_hal_data[bus]->i2c_master_instance), &packet) != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** \brief HAL implementation of I2C receive function for ASF I2C -- * \param[in] iface instance -- * \param[out] rxdata pointer to space to receive the data -- * \param[in] rxlength ptr to expected number of receive bytes to request -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_receive(ATCAIface iface, uint8_t *rxdata, uint16_t *rxlength) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- int retries = cfg->rx_retries; -- int status = !STATUS_OK; -- -- struct i2c_master_packet packet = { -- .address = cfg->atcai2c.slave_address >> 1, -- .data_length = *rxlength, -- .data = rxdata, -- .ten_bit_address = false, -- .high_speed = false, -- .hs_master_code = 0x0, -- }; -- -- while (retries-- > 0 && status != STATUS_OK) -- { -- status = i2c_master_read_packet_wait(&(i2c_hal_data[bus]->i2c_master_instance), &packet); -- } -- -- if (status != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- if (atCheckCrc(packet.data) != ATCA_SUCCESS) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** \brief method to change the bus speec of I2C -- * \param[in] iface interface on which to change bus speed -- * \param[in] speed baud rate (typically 100000 or 400000) -- */ -- --void change_i2c_speed(ATCAIface iface, uint32_t speed) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- -- config_i2c_master.buffer_timeout = 10000; -- config_i2c_master.baud_rate = speed / 1000; -- -- i2c_master_disable(&(i2c_hal_data[bus]->i2c_master_instance)); -- -- switch (bus) -- { -- case 0: i2c_master_init(&(i2c_hal_data[bus]->i2c_master_instance), SERCOM0, &config_i2c_master); break; -- case 1: i2c_master_init(&(i2c_hal_data[bus]->i2c_master_instance), SERCOM1, &config_i2c_master); break; -- case 2: i2c_master_init(&(i2c_hal_data[bus]->i2c_master_instance), SERCOM2, &config_i2c_master); break; -- case 3: i2c_master_init(&(i2c_hal_data[bus]->i2c_master_instance), SERCOM3, &config_i2c_master); break; -- case 4: i2c_master_init(&(i2c_hal_data[bus]->i2c_master_instance), SERCOM4, &config_i2c_master); break; -- case 5: i2c_master_init(&(i2c_hal_data[bus]->i2c_master_instance), SERCOM5, &config_i2c_master); break; -- } -- -- i2c_master_enable(&(i2c_hal_data[bus]->i2c_master_instance)); --} -- --/** \brief wake up CryptoAuth device using I2C bus -- * \param[in] iface interface to logical device to wakeup -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_wake(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- int retries = cfg->rx_retries; -- uint32_t bdrt = cfg->atcai2c.baud; -- int status = !STATUS_OK; -- uint8_t data[4], expected[4] = { 0x04, 0x11, 0x33, 0x43 }; -- -- if (bdrt != 100000) // if not already at 100KHz, change it -- { -- change_i2c_speed(iface, 100000); -- } -- -- // Send the wake by writing to an address of 0x00 -- struct i2c_master_packet packet = { -- .address = 0x00, -- .data_length = 0, -- .data = &data[0], -- .ten_bit_address = false, -- .high_speed = false, -- .hs_master_code = 0x0, -- }; -- -- // Send the 00 address as the wake pulse -- i2c_master_write_packet_wait(&(i2c_hal_data[bus]->i2c_master_instance), &packet); // part will NACK, so don't check for status -- -- atca_delay_us(cfg->wake_delay); // wait tWHI + tWLO which is configured based on device type and configuration structure -- -- packet.address = cfg->atcai2c.slave_address >> 1; -- packet.data_length = 4; -- packet.data = data; -- -- while (retries-- > 0 && status != STATUS_OK) -- { -- status = i2c_master_read_packet_wait(&(i2c_hal_data[bus]->i2c_master_instance), &packet); -- } -- -- // if necessary, revert baud rate to what came in. -- if (bdrt != 100000) -- { -- change_i2c_speed(iface, bdrt); -- } -- -- if (status != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- if (memcmp(data, expected, 4) == 0) -- { -- return ATCA_SUCCESS; -- } -- -- return ATCA_COMM_FAIL; --} -- --/** \brief idle CryptoAuth device using I2C bus -- * \param[in] iface interface to logical device to idle -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_idle(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- uint8_t data[4]; -- -- struct i2c_master_packet packet = { -- .address = cfg->atcai2c.slave_address >> 1, -- .data_length = 1, -- .data = &data[0], -- .ten_bit_address = false, -- .high_speed = false, -- .hs_master_code = 0x0, -- }; -- -- data[0] = 0x02; // idle word address value -- if (i2c_master_write_packet_wait(&(i2c_hal_data[bus]->i2c_master_instance), &packet) != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; -- --} -- --/** \brief sleep CryptoAuth device using I2C bus -- * \param[in] iface interface to logical device to sleep -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_sleep(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- uint8_t data[4]; -- -- struct i2c_master_packet packet = { -- .address = cfg->atcai2c.slave_address >> 1, -- .data_length = 1, -- .data = &data[0], -- .ten_bit_address = false, -- .high_speed = false, -- .hs_master_code = 0x0, -- }; -- -- data[0] = 0x01; // sleep word address value -- if (i2c_master_write_packet_wait(&(i2c_hal_data[bus]->i2c_master_instance), &packet) != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** \brief manages reference count on given bus and releases resource if no more refences exist -- * \param[in] hal_data - opaque pointer to hal data structure - known only to the HAL implementation -- * return ATCA_SUCCESS -- */ -- --ATCA_STATUS hal_i2c_release(void *hal_data) --{ -- ATCAI2CMaster_t *hal = (ATCAI2CMaster_t*)hal_data; -- -- i2c_bus_ref_ct--; // track total i2c bus interface instances for consistency checking and debugging -- -- // if the use count for this bus has gone to 0 references, disable it. protect against an unbracketed release -- if (hal && --(hal->ref_ct) <= 0 && i2c_hal_data[hal->bus_index] != NULL) -- { -- i2c_master_reset(&(hal->i2c_master_instance)); -- free(i2c_hal_data[hal->bus_index]); -- i2c_hal_data[hal->bus_index] = NULL; -- } -- -- return ATCA_SUCCESS; --} -- --/** @} */ -diff --git a/lib/hal/hal_samd21_i2c_asf.h b/lib/hal/hal_samd21_i2c_asf.h -deleted file mode 100644 -index b8ff14d0123d..000000000000 ---- a/lib/hal/hal_samd21_i2c_asf.h -+++ /dev/null -@@ -1,63 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for SAMD21 I2C over ASF drivers. -- * -- * Prerequisite: add SERCOM I2C Master Polled support to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef HAL_SAMD21_I2C_ASF_H_ --#define HAL_SAMD21_I2C_ASF_H_ -- --#include -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * using I2C driver of ASF. -- * -- @{ */ -- -- --#define MAX_I2C_BUSES 6 // SAMD21 has up to 6 SERCOMS that can be configured as I2C -- --/** \brief this is the hal_data for ATCA HAL for ASF SERCOM -- */ --typedef struct atcaI2Cmaster --{ -- struct i2c_master_module i2c_master_instance; -- int ref_ct; -- // for conveniences during interface release phase -- int bus_index; --} ATCAI2CMaster_t; -- --void change_i2c_speed(ATCAIface iface, uint32_t speed); -- --/** @} */ --#endif /* HAL_SAMD21_I2C_ASF_H_ */ -\ No newline at end of file -diff --git a/lib/hal/hal_samd21_i2c_start.c b/lib/hal/hal_samd21_i2c_start.c -deleted file mode 100644 -index 5bade0768ef0..000000000000 ---- a/lib/hal/hal_samd21_i2c_start.c -+++ /dev/null -@@ -1,545 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for SAMD21 I2C over START drivers. -- * -- * This code is structured in two parts. Part 1 is the connection of the ATCA HAL API to the physical I2C -- * implementation. Part 2 is the START I2C primitives to set up the interface. -- * -- * Prerequisite: add SERCOM I2C Master Polled support to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- #include --#include --#include --#include --#include --#include "atca_hal.h" --#include "atca_device.h" --#include "hal_samd21_i2c_start.h" --#include "peripheral_gclk_config.h" -- --#include "atca_start_config.h" --#include "atca_start_iface.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- --ATCAI2CMaster_t *i2c_hal_data[MAX_I2C_BUSES]; // map logical, 0-based bus number to index --int i2c_bus_ref_ct = 0; // total in-use count across buses -- --/* Notes: -- - this HAL implementation assumes you've included the Atmel START SERCOM I2C libraries in your project, otherwise, -- the HAL layer will not compile because the START I2C drivers are a dependency * -- */ -- --/** \brief discover i2c buses available for this hardware -- * this maintains a list of logical to physical bus mappings freeing the application -- * of the a-priori knowledge -- * \param[in] i2c_buses - an array of logical bus numbers -- * \param[in] max_buses - maximum number of buses the app wants to attempt to discover -- * \return ATCA_SUCCESS -- */ -- --ATCA_STATUS hal_i2c_discover_buses(int i2c_buses[], int max_buses) --{ -- -- /* if every SERCOM was a likely candidate bus, then would need to initialize the entire array to all SERCOM n numbers. -- * As an optimization and making discovery safer, make assumptions about bus-num / SERCOM map based on D21 Xplained Pro board -- * If you were using a raw D21 on your own board, you would supply your own bus numbers based on your particular hardware configuration. -- */ --#ifdef __SAMR21G18A__ -- i2c_buses[0] = 1; // default r21 for xplained pro dev board --#else -- i2c_buses[0] = 2; // default d21 for xplained pro dev board --#endif -- -- return ATCA_SUCCESS; --} -- --/** \brief discover any CryptoAuth devices on a given logical bus number -- * \param[in] busNum logical bus number on which to look for CryptoAuth devices -- * \param[out] cfg pointer to head of an array of interface config structures which get filled in by this method -- * \param[out] found number of devices found on this bus -- * \return ATCA_SUCCESS -- */ -- --ATCA_STATUS hal_i2c_discover_devices(int busNum, ATCAIfaceCfg cfg[], int *found) --{ -- ATCAIfaceCfg *head = cfg; -- uint8_t slaveAddress = 0x01; -- ATCADevice device; -- ATCAIface discoverIface; -- ATCACommand command; -- ATCAPacket packet; -- ATCA_STATUS status; -- uint8_t revs608[1][4] = { { 0x00, 0x00, 0x60, 0x01 } }; -- uint8_t revs508[1][4] = { { 0x00, 0x00, 0x50, 0x00 } }; -- uint8_t revs108[1][4] = { { 0x80, 0x00, 0x10, 0x01 } }; -- uint8_t revs204[3][4] = { { 0x00, 0x02, 0x00, 0x08 }, -- { 0x00, 0x02, 0x00, 0x09 }, -- { 0x00, 0x04, 0x05, 0x00 } }; -- int i; -- -- /** \brief default configuration, to be reused during discovery process */ -- ATCAIfaceCfg discoverCfg = { -- .iface_type = ATCA_I2C_IFACE, -- .devtype = ATECC508A, -- .atcai2c.slave_address = 0x07, -- .atcai2c.bus = busNum, -- .atcai2c.baud = 400000, -- //.atcai2c.baud = 100000, -- .wake_delay = 800, -- .rx_retries = 3 -- }; -- -- ATCAHAL_t hal; -- -- hal_i2c_init(&hal, &discoverCfg); -- device = newATCADevice(&discoverCfg); -- discoverIface = atGetIFace(device); -- command = atGetCommands(device); -- -- // iterate through all addresses on given i2c bus -- // all valid 7-bit addresses go from 0x07 to 0x78 -- for (slaveAddress = 0x07; slaveAddress <= 0x78; slaveAddress++) -- { -- discoverCfg.atcai2c.slave_address = slaveAddress << 1; // turn it into an 8-bit address which is what the rest of the i2c HAL is expecting when a packet is sent -- -- // wake up device -- // If it wakes, send it a dev rev command. Based on that response, determine the device type -- // BTW - this will wake every cryptoauth device living on the same bus (ecc508a, sha204a) -- -- if (hal_i2c_wake(discoverIface) == ATCA_SUCCESS) -- { -- (*found)++; -- memcpy( (uint8_t*)head, (uint8_t*)&discoverCfg, sizeof(ATCAIfaceCfg)); -- -- memset(&packet, 0x00, sizeof(packet)); -- -- // get devrev info and set device type accordingly -- atInfo(command, &packet); -- if ((status = atGetExecTime(packet.opcode, command)) != ATCA_SUCCESS) -- { -- continue; -- } -- -- // send the command -- if ( (status = atsend(discoverIface, (uint8_t*)&packet, packet.txsize)) != ATCA_SUCCESS) -- { -- printf("packet send error\r\n"); -- continue; -- } -- -- // delay the appropriate amount of time for command to execute -- atca_delay_ms((command->execution_time_msec) + 1); -- -- // receive the response -- if ( (status = atreceive(discoverIface, &(packet.data[0]), &(packet.rxsize) )) != ATCA_SUCCESS) -- { -- continue; -- } -- -- if ( (status = isATCAError(packet.data)) != ATCA_SUCCESS) -- { -- printf("command response error\r\n"); -- continue; -- } -- -- // determine device type from common info and dev rev response byte strings -- -- for (i = 0; i < (int)sizeof(revs608) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs608[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC608A; -- break; -- } -- } -- -- for (i = 0; i < (int)sizeof(revs508) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs508[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC508A; -- break; -- } -- } -- -- for (i = 0; i < (int)sizeof(revs204) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs204[i], 4) == 0) -- { -- discoverCfg.devtype = ATSHA204A; -- break; -- } -- } -- -- for (i = 0; i < (int)sizeof(revs108) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs108[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC108A; -- break; -- } -- } -- -- atca_delay_ms(15); -- // now the device type is known, so update the caller's cfg array element with it -- head->devtype = discoverCfg.devtype; -- head++; -- } -- -- hal_i2c_idle(discoverIface); -- } -- -- hal_i2c_release(&hal); -- -- return ATCA_SUCCESS; --} -- -- -- --/** \brief -- - this HAL implementation assumes you've included the START Twi libraries in your project, otherwise, -- the HAL layer will not compile because the START TWI drivers are a dependency * -- */ -- --/** \brief hal_i2c_init manages requests to initialize a physical interface. it manages use counts so when an interface -- * has released the physical layer, it will disable the interface for some other use. -- * You can have multiple ATCAIFace instances using the same bus, and you can have multiple ATCAIFace instances on -- * multiple i2c buses, so hal_i2c_init manages these things and ATCAIFace is abstracted from the physical details. -- */ -- --/** \brief initialize an I2C interface using given config -- * \param[in] hal - opaque ptr to HAL data -- * \param[in] cfg - interface configuration -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_init(void *hal, ATCAIfaceCfg *cfg) --{ -- int bus = cfg->atcai2c.bus; // 0-based logical bus number -- ATCAHAL_t *phal = (ATCAHAL_t*)hal; -- uint32_t freq_constant; // I2C frequency configuration constant in kHz -- -- if (i2c_bus_ref_ct == 0) // power up state, no i2c buses will have been used -- { -- for (int i = 0; i < MAX_I2C_BUSES; i++) -- { -- i2c_hal_data[i] = NULL; -- } -- } -- -- i2c_bus_ref_ct++; // total across buses -- -- if (bus >= 0 && bus < MAX_I2C_BUSES) -- { -- // if this is the first time this bus and interface has been created, do the physical work of enabling it -- if (i2c_hal_data[bus] == NULL) -- { -- i2c_hal_data[bus] = malloc(sizeof(ATCAI2CMaster_t) ); -- i2c_hal_data[bus]->ref_ct = 1; // buses are shared, this is the first instance -- -- // store I2C baudrate in kHz -- freq_constant = cfg->atcai2c.baud / 1000; -- -- switch (bus) -- { -- case 0: break; -- case 1: break; -- case 2: memcpy(&(i2c_hal_data[bus]->i2c_master_instance), &I2C_0, sizeof(struct i2c_m_sync_desc)); break; -- case 3: break; -- case 4: break; -- case 5: break; -- } -- -- // store this for use during the release phase -- i2c_hal_data[bus]->bus_index = bus; -- -- // set I2C baudrate and enable I2C module -- i2c_m_sync_set_baudrate(&(i2c_hal_data[bus]->i2c_master_instance), CONF_GCLK_SERCOM2_CORE_FREQUENCY / 1000, freq_constant); -- i2c_m_sync_enable(&(i2c_hal_data[bus]->i2c_master_instance)); -- -- } -- else -- { -- // otherwise, another interface already initialized the bus, so this interface will share it and any different -- // cfg parameters will be ignored...first one to initialize this sets the configuration -- i2c_hal_data[bus]->ref_ct++; -- } -- phal->hal_data = i2c_hal_data[bus]; -- -- return ATCA_SUCCESS; -- } -- -- return ATCA_COMM_FAIL; --} -- --/** \brief HAL implementation of I2C post init -- * \param[in] iface instance -- * \return ATCA_SUCCESS -- */ --ATCA_STATUS hal_i2c_post_init(ATCAIface iface) --{ -- return ATCA_SUCCESS; --} -- --/** \brief HAL implementation of I2C send over START -- * \param[in] iface instance -- * \param[in] txdata pointer to space to bytes to send -- * \param[in] txlength number of bytes to send -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_send(ATCAIface iface, uint8_t *txdata, int txlength) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- -- struct _i2c_m_msg packet = { -- .addr = cfg->atcai2c.slave_address >> 1, -- .buffer = txdata, -- .flags = I2C_M_SEVEN | I2C_M_STOP, -- }; -- -- // for this implementation of I2C with CryptoAuth chips, txdata is assumed to have ATCAPacket format -- -- // other device types that don't require i/o tokens on the front end of a command need a different hal_i2c_send and wire it up instead of this one -- // this covers devices such as ATSHA204A and ATECCx08A that require a word address value pre-pended to the packet -- // txdata[0] is using _reserved byte of the ATCAPacket -- txdata[0] = 0x03; // insert the Word Address Value, Command token -- txlength++; // account for word address value byte. -- packet.len = txlength; -- -- if (i2c_m_sync_transfer(&(i2c_hal_data[bus]->i2c_master_instance), &packet) != I2C_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** \brief HAL implementation of I2C receive function for START I2C -- * \param[in] iface instance -- * \param[out] rxdata pointer to space to receive the data -- * \param[in] rxlength ptr to expected number of receive bytes to request -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_receive(ATCAIface iface, uint8_t *rxdata, uint16_t *rxlength) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- int retries = cfg->rx_retries; -- int status = !I2C_OK; -- -- struct _i2c_m_msg packet = { -- .addr = cfg->atcai2c.slave_address >> 1, -- .len = *rxlength, -- .buffer = rxdata, -- .flags = I2C_M_SEVEN | I2C_M_RD | I2C_M_STOP, -- }; -- -- while (retries-- > 0 && status != I2C_OK) -- { -- status = i2c_m_sync_transfer(&(i2c_hal_data[bus]->i2c_master_instance), &packet); -- } -- -- if (status != I2C_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** \brief method to change the bus speec of I2C -- * \param[in] iface interface on which to change bus speed -- * \param[in] speed baud rate (typically 100000 or 400000) -- */ -- --void change_i2c_speed(ATCAIface iface, uint32_t speed) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- uint32_t freq_constant; // I2C frequency configuration constant -- -- // disable I2C module -- i2c_m_sync_disable(&(i2c_hal_data[bus]->i2c_master_instance)); -- -- // store I2C baudrate in kHz -- freq_constant = speed / 1000; -- -- // set I2C baudrate and enable I2C module -- i2c_m_sync_set_baudrate(&(i2c_hal_data[bus]->i2c_master_instance), CONF_GCLK_SERCOM2_CORE_FREQUENCY / 1000, freq_constant); -- i2c_m_sync_enable(&(i2c_hal_data[bus]->i2c_master_instance)); --} -- --/** \brief wake up CryptoAuth device using I2C bus -- * \param[in] iface interface to logical device to wakeup -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_wake(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- int retries = cfg->rx_retries; -- uint32_t bdrt = cfg->atcai2c.baud; -- int status = !I2C_OK; -- uint8_t data[4], expected[4] = { 0x04, 0x11, 0x33, 0x43 }; -- -- if (bdrt != 100000) // if not already at 100KHz, change it -- { -- change_i2c_speed(iface, 100000); -- } -- -- // send the wake by writing to an address of 0x00 -- struct _i2c_m_msg packet = { -- .addr = 0x00, -- .len = 0, -- .buffer = NULL, -- .flags = I2C_M_SEVEN | I2C_M_STOP, -- }; -- -- // Send the 00 address as the wake pulse -- status = i2c_m_sync_transfer(&(i2c_hal_data[bus]->i2c_master_instance), &packet); // part will NACK, so don't check for status -- -- delay_us(cfg->wake_delay); // wait tWHI + tWLO which is configured based on device type and configuration structure -- -- // receive the wake up response -- packet.addr = cfg->atcai2c.slave_address >> 1; -- packet.len = 4; -- packet.buffer = data; -- packet.flags = I2C_M_SEVEN | I2C_M_RD | I2C_M_STOP; -- -- while (retries-- > 0 && status != I2C_OK) -- { -- status = i2c_m_sync_transfer(&(i2c_hal_data[bus]->i2c_master_instance), &packet); -- } -- -- if (status == I2C_OK) -- { -- // if necessary, revert baud rate to what came in. -- if (bdrt != 100000) -- { -- change_i2c_speed(iface, bdrt); -- } -- // compare received data with expected value -- if (memcmp(data, expected, 4) == 0) -- { -- return ATCA_SUCCESS; -- } -- } -- -- return ATCA_COMM_FAIL; --} -- --/** \brief idle CryptoAuth device using I2C bus -- * \param[in] iface interface to logical device to idle -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_idle(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- uint8_t data[4]; -- -- struct _i2c_m_msg packet = { -- .addr = cfg->atcai2c.slave_address >> 1, -- .len = 1, -- .buffer = &data[0], -- .flags = I2C_M_SEVEN | I2C_M_STOP, -- }; -- -- data[0] = 0x02; // idle word address value -- -- if (i2c_m_sync_transfer(&(i2c_hal_data[bus]->i2c_master_instance), &packet) != I2C_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** \brief sleep CryptoAuth device using I2C bus -- * \param[in] iface interface to logical device to sleep -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_sleep(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- uint8_t data[4]; -- -- struct _i2c_m_msg packet = { -- .addr = cfg->atcai2c.slave_address >> 1, -- .len = 1, -- .buffer = &data[0], -- .flags = I2C_M_SEVEN | I2C_M_STOP, -- }; -- -- data[0] = 0x01; // sleep word address value -- -- if (i2c_m_sync_transfer(&(i2c_hal_data[bus]->i2c_master_instance), &packet) != I2C_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** \brief manages reference count on given bus and releases resource if no more refences exist -- * \param[in] hal_data - opaque pointer to hal data structure - known only to the HAL implementation -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_release(void *hal_data) --{ -- ATCAI2CMaster_t *hal = (ATCAI2CMaster_t*)hal_data; -- -- i2c_bus_ref_ct--; // track total i2c bus interface instances for consistency checking and debugging -- -- //if the use count for this bus has gone to 0 references, disable it. protect against an unbracketed release -- if (hal && --(hal->ref_ct) <= 0 && i2c_hal_data[hal->bus_index] != NULL) -- { -- i2c_m_sync_disable(&(hal->i2c_master_instance)); -- free(i2c_hal_data[hal->bus_index]); -- i2c_hal_data[hal->bus_index] = NULL; -- } -- -- return ATCA_SUCCESS; --} -- --/** @} */ -diff --git a/lib/hal/hal_samd21_i2c_start.h b/lib/hal/hal_samd21_i2c_start.h -deleted file mode 100644 -index 08a50093dd9a..000000000000 ---- a/lib/hal/hal_samd21_i2c_start.h -+++ /dev/null -@@ -1,64 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for SAMD21 I2C over START drivers. -- * -- * Prerequisite: add SERCOM I2C Master Polled support to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef HAL_SAMD21_I2C_START_H_ --#define HAL_SAMD21_I2C_START_H_ -- --#include "atmel_start.h" --#include -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- -- --#define MAX_I2C_BUSES 6 // SAMD21 has up to 6 SERCOMS that can be configured as I2C -- --/** \brief this is the hal_data for ATCA HAL for Atmel START SERCOM -- */ --typedef struct atcaI2Cmaster --{ -- struct i2c_m_sync_desc i2c_master_instance; -- int ref_ct; -- // for conveniences during interface release phase -- int bus_index; --} ATCAI2CMaster_t; -- --void change_i2c_speed(ATCAIface iface, uint32_t speed); -- --/** @} */ -- --#endif /* HAL_SAMD21_I2C_START_H_ */ -diff --git a/lib/hal/hal_samd21_timer_asf.c b/lib/hal/hal_samd21_timer_asf.c -deleted file mode 100644 -index ba191e400f3c..000000000000 ---- a/lib/hal/hal_samd21_timer_asf.c -+++ /dev/null -@@ -1,79 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for SAMD21 timer/delay over ASF drivers. -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include "atca_hal.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- -- --/** \brief This function delays for a number of microseconds. -- * -- * \param[in] delay number of 0.001 milliseconds to delay -- */ --void atca_delay_us(uint32_t delay) --{ -- // use ASF supplied delay -- delay_us(delay); --} -- --/** \brief This function delays for a number of tens of microseconds. -- * -- * \param[in] delay number of 0.01 milliseconds to delay -- */ --void atca_delay_10us(uint32_t delay) --{ -- // use ASF supplied delay -- delay_us(delay * 10); -- --} -- --/** \brief This function delays for a number of milliseconds. -- * -- * You can override this function if you like to do -- * something else in your system while delaying. -- * \param[in] delay number of milliseconds to delay -- */ -- --/* ASF already has delay_ms - see delay.h */ --void atca_delay_ms(uint32_t delay) --{ -- // use ASF supplied delay -- delay_ms(delay); --} -- --/** @} */ -diff --git a/lib/hal/hal_samd21_timer_start.c b/lib/hal/hal_samd21_timer_start.c -deleted file mode 100644 -index 1204331466ab..000000000000 ---- a/lib/hal/hal_samd21_timer_start.c -+++ /dev/null -@@ -1,80 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for SAMD21 I2C over START drivers. -- * -- * Prerequisite: add SERCOM I2C Master Polled support to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include "atca_hal.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- -- --/** \brief This function delays for a number of microseconds. -- * -- * \param[in] delay number of microseconds to delay -- */ -- --void atca_delay_us(uint32_t delay) --{ -- // use START supplied delay -- delay_us(delay); --} -- --/** \brief This function delays for a number of tens of microseconds. -- * -- * \param[in] delay number of 0.01 milliseconds to delay -- */ -- --void atca_delay_10us(uint32_t delay) --{ -- // use START supplied delay -- delay_us(delay * 10); --} -- --/** \brief This function delays for a number of milliseconds. -- * -- * You can override this function if you like to do -- * something else in your system while delaying. -- * \param[in] delay number of milliseconds to delay -- */ -- --void atca_delay_ms(uint32_t delay) --{ -- // use START supplied delay -- delay_ms(delay); --} -- --/** @} */ -diff --git a/lib/hal/hal_samg55_i2c_asf.c b/lib/hal/hal_samg55_i2c_asf.c -deleted file mode 100644 -index 37a7ddd9348d..000000000000 ---- a/lib/hal/hal_samg55_i2c_asf.c -+++ /dev/null -@@ -1,661 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for SAMG55 I2C over ASF drivers. -- * -- * This code is structured in two parts. Part 1 is the connection of the ATCA HAL API to the physical I2C -- * implementation. Part 2 is the ASF I2C primitives to set up the interface. -- * -- * Prerequisite: add "TWI - Two-Wire Interface (Common API) (service)" module to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include --#include "atca_hal.h" --#include "atca_device.h" --#include "hal_samg55_i2c_asf.h" -- -- --//!< Uncomment when debugging --/*#define DEBUG_HAL*/ -- --/** -- * \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * using I2C driver of ASF. -- * -- @{ */ -- --/** -- * \brief -- * Logical to physical bus mapping structure -- */ --ATCAI2CMaster_t *i2c_hal_data[MAX_I2C_BUSES]; // map logical, 0-based bus number to index --int i2c_bus_ref_ct = 0; // total in-use count across buses --twi_options_t opt_twi_master; -- -- --#ifdef DEBUG_HAL --static void print_array(uint8_t *data, uint32_t data_size) --{ -- uint32_t n; -- -- for (n = 0; n < data_size; n++) -- { -- printf("%.2x ", data[n]); -- if (((n + 1) % 16) == 0) -- { -- printf("\r\n"); -- if ((n + 1) != data_size) -- { -- printf(" "); -- } -- } -- } -- if (data_size % 16 != 0) -- { -- printf("\r\n"); -- } --} --#endif -- --/** -- * \brief -- * This HAL implementation assumes you've included the ASF TWI libraries in your project, otherwise, -- * the HAL layer will not compile because the ASF TWI drivers are a dependency -- */ -- --/** \brief discover i2c buses available for this hardware -- * this maintains a list of logical to physical bus mappings freeing the application -- * of the a-priori knowledge -- * \param[in] i2c_buses - an array of logical bus numbers -- * \param[in] max_buses - maximum number of buses the app wants to attempt to discover -- * return ATCA_SUCCESS -- */ -- --ATCA_STATUS hal_i2c_discover_buses(int i2c_buses[], int max_buses) --{ -- /* logical bus numbers 0-2 map to the samG55 i2c buses: -- */ -- i2c_buses[0] = 0; -- -- return ATCA_SUCCESS; --} -- --/** \brief discover any CryptoAuth devices on a given logical bus number -- * \param[in] busNum - logical bus number on which to look for CryptoAuth devices -- * \param[out] cfg[] - pointer to head of an array of interface config structures which get filled in by this method -- * \param[out] *found - number of devices found on this bus -- * \return ATCA_SUCCESS -- */ -- --ATCA_STATUS hal_i2c_discover_devices(int busNum, ATCAIfaceCfg cfg[], int *found) --{ -- ATCAIfaceCfg *head = cfg; -- uint8_t slaveAddress = 0x01; -- ATCADevice device; -- ATCAIface discoverIface; -- ATCACommand command; -- ATCAPacket packet; -- ATCA_STATUS status; -- uint8_t revs508[1][4] = { { 0x00, 0x00, 0x50, 0x00 } }; -- uint8_t revs108[1][4] = { { 0x80, 0x00, 0x10, 0x01 } }; -- uint8_t revs204[3][4] = { { 0x00, 0x02, 0x00, 0x08 }, -- { 0x00, 0x02, 0x00, 0x09 }, -- { 0x00, 0x04, 0x05, 0x00 } }; -- int i; -- -- /** \brief default configuration, to be reused during discovery process */ -- ATCAIfaceCfg discoverCfg = { -- .iface_type = ATCA_I2C_IFACE, -- .devtype = ATECC508A, -- .atcai2c.slave_address = 0x07, -- .atcai2c.bus = busNum, -- .atcai2c.baud = 400000, -- .wake_delay = 800, -- .rx_retries = 3 -- }; -- -- ATCAHAL_t hal; -- -- if (busNum < 0) -- { -- return ATCA_COMM_FAIL; -- } -- -- hal_i2c_init(&hal, &discoverCfg); -- device = newATCADevice(&discoverCfg); -- discoverIface = atGetIFace(device); -- command = atGetCommands(device); -- -- // iterate through all addresses on given i2c bus -- // all valid 7-bit addresses go from 0x07 to 0x78 -- for (slaveAddress = 0x07; slaveAddress <= 0x78; slaveAddress++) -- { -- discoverCfg.atcai2c.slave_address = slaveAddress << 1; // turn it into an 8-bit address which is what the rest of the i2c HAL is expecting when a packet is sent -- -- // wake up device -- // If it wakes, send it a dev rev command. Based on that response, determine the device type -- // BTW - this will wake every cryptoauth device living on the same bus (ecc508a, sha204a) -- -- if (hal_i2c_wake(discoverIface) == ATCA_SUCCESS) -- { -- (*found)++; -- memcpy( (uint8_t*)head, (uint8_t*)&discoverCfg, sizeof(ATCAIfaceCfg)); -- -- memset(packet.data, 0x00, sizeof(packet.data)); -- -- // get devrev info and set device type accordingly -- atInfo(command, &packet); -- if ((status = atGetExecTime(packet.opcode, command)) != ATCA_SUCCESS) -- { -- continue; -- } -- -- // send the command -- if ( (status = atsend(discoverIface, (uint8_t*)&packet, packet.txsize)) != ATCA_SUCCESS) -- { -- printf("packet send error\r\n"); -- continue; -- } -- -- // delay the appropriate amount of time for command to execute -- atca_delay_ms((command->execution_time_msec) + 1); -- -- // receive the response -- if ( (status = atreceive(discoverIface, &(packet.data[0]), &(packet.rxsize) )) != ATCA_SUCCESS) -- { -- continue; -- } -- -- if ( (status = isATCAError(packet.data)) != ATCA_SUCCESS) -- { -- continue; -- } -- -- // determine device type from common info and dev rev response byte strings -- for (i = 0; i < (int)sizeof(revs508) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs508[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC508A; -- break; -- } -- } -- -- for (i = 0; i < (int)sizeof(revs204) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs204[i], 4) == 0) -- { -- discoverCfg.devtype = ATSHA204A; -- break; -- } -- } -- -- for (i = 0; i < (int)sizeof(revs108) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs108[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC108A; -- break; -- } -- } -- -- atca_delay_ms(15); -- // now the device type is known, so update the caller's cfg array element with it -- head->devtype = discoverCfg.devtype; -- head++; -- } -- -- hal_i2c_idle(discoverIface); -- } -- -- hal_i2c_release(&hal); -- -- return ATCA_SUCCESS; --} -- --/** -- * \brief -- * hal_i2c_init manages requests to initialize a physical interface. It manages use counts so when an interface -- * has released the physical layer, it will disable the interface for some other use. -- * You can have multiple ATCAIFace instances using the same bus, and you can have multiple ATCAIFace instances on -- * multiple i2c buses, so hal_i2c_init manages these things and ATCAIFace is abstracted from the physical details. -- */ -- --/** -- * \brief initialize an I2C interface using given config -- * -- * \param[in] hal - opaque ptr to HAL data -- * \param[in] cfg - interface configuration -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_init(void *hal, ATCAIfaceCfg *cfg) --{ -- // set to default i2c bus -- if (cfg->atcai2c.bus > MAX_I2C_BUSES - 1) -- { -- cfg->atcai2c.bus = 0; -- } -- int bus = cfg->atcai2c.bus; // 0-based logical bus number -- ATCAHAL_t *phal = (ATCAHAL_t*)hal; -- -- if (i2c_bus_ref_ct == 0) // power up state, no i2c buses will have been used -- { -- for (int i = 0; i < MAX_I2C_BUSES; i++) -- { -- i2c_hal_data[i] = NULL; -- } -- } -- -- i2c_bus_ref_ct++; // total across buses -- -- if (bus >= 0 && bus < MAX_I2C_BUSES) -- { -- //// if this is the first time this bus and interface has been created, do the physical work of enabling it -- if (i2c_hal_data[bus] == NULL) -- { -- i2c_hal_data[bus] = malloc(sizeof(ATCAI2CMaster_t)); -- i2c_hal_data[bus]->ref_ct = 1; // buses are shared, this is the first instance -- -- switch (bus) -- { -- case 0: -- i2c_hal_data[bus]->twi_id = ID_FLEXCOM4; -- i2c_hal_data[bus]->twi_master_instance = TWI4; -- break; -- case 1: -- i2c_hal_data[bus]->twi_id = FLEXCOM6; -- i2c_hal_data[bus]->twi_master_instance = TWI6; -- break; -- } -- -- flexcom_enable((Flexcom*)i2c_hal_data[bus]->twi_id); -- flexcom_set_opmode((Flexcom*)i2c_hal_data[bus]->twi_id, FLEXCOM_TWI); -- -- opt_twi_master.master_clk = sysclk_get_cpu_hz(); -- opt_twi_master.speed = cfg->atcai2c.baud; -- opt_twi_master.smbus = 0; -- -- twi_master_init(i2c_hal_data[bus]->twi_master_instance, &opt_twi_master); -- -- // store this for use during the release phase -- i2c_hal_data[bus]->bus_index = bus; -- } -- else -- { -- // otherwise, another interface already initialized the bus, so this interface will share it and any different -- // cfg parameters will be ignored...first one to initialize this sets the configuration -- i2c_hal_data[bus]->ref_ct++; -- } -- -- phal->hal_data = i2c_hal_data[bus]; -- -- return ATCA_SUCCESS; -- } -- -- return ATCA_COMM_FAIL; --} -- --/** -- * \brief HAL implementation of I2C post init -- * -- * \param[in] iface instance -- * -- * \return ATCA_SUCCESS -- */ --ATCA_STATUS hal_i2c_post_init(ATCAIface iface) --{ -- return ATCA_SUCCESS; --} -- --/** -- * \brief HAL implementation of I2C send over ASF -- * -- * \param[in] iface instance -- * \param[in] txdata pointer to space to bytes to send -- * \param[in] txlength number of bytes to send -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_send(ATCAIface iface, uint8_t *txdata, int txlength) --{ --#ifdef DEBUG_HAL -- printf("hal_i2c_send()\r\n"); -- -- printf("\r\nCommand Packet (size:0x%.8x)\r\n", (uint32_t)txlength); -- printf("Count : %.2x\r\n", txdata[1]); -- printf("Opcode : %.2x\r\n", txdata[2]); -- printf("Param1 : %.2x\r\n", txdata[3]); -- printf("Param2 : "); print_array(&txdata[4], 2); -- if (txdata[1] > 7) -- { -- printf("Data : "); print_array(&txdata[6], txdata[1] - 7); -- } -- printf("CRC : "); print_array(&txdata[txdata[1] - 1], 2); -- printf("\r\n"); --#endif -- -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- // set to default i2c bus -- if (cfg->atcai2c.bus > MAX_I2C_BUSES - 1) -- { -- cfg->atcai2c.bus = 0; -- } -- int bus = cfg->atcai2c.bus; -- -- txdata[0] = 0x03; // insert the Word Address Value, Command token -- txlength++; // account for word address value byte. -- -- twi_packet_t packet = { -- .chip = cfg->atcai2c.slave_address >> 1, -- .addr = { 0 }, -- .addr_length = 0, -- .buffer = txdata, -- .length = (uint32_t)txlength //(uint32_t)txdata[1] -- }; -- -- // for this implementation of I2C with CryptoAuth chips, txdata is assumed to have ATCAPacket format -- -- // other device types that don't require i/o tokens on the front end of a command need a different hal_i2c_send and wire it up instead of this one -- // this covers devices such as ATSHA204A and ATECCx08A that require a word address value pre-pended to the packet -- -- if (twi_master_write(i2c_hal_data[bus]->twi_master_instance, &packet) != TWI_SUCCESS) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** -- * \brief HAL implementation of I2C receive function for ASF I2C -- * -- * \param[in] iface instance -- * \param[out] rxdata pointer to space to receive the data -- * \param[in] rxlength ptr to expected number of receive bytes to request -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_receive(ATCAIface iface, uint8_t *rxdata, uint16_t *rxlength) --{ --#ifdef DEBUG_HAL -- printf("hal_i2c_receive()\r\n"); --#endif -- -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- // set to default i2c bus -- if (cfg->atcai2c.bus > MAX_I2C_BUSES - 1) -- { -- cfg->atcai2c.bus = 0; -- } -- int bus = cfg->atcai2c.bus; -- int retries = cfg->rx_retries; -- uint32_t status = !TWI_SUCCESS; -- -- twi_packet_t packet = { -- .chip = cfg->atcai2c.slave_address >> 1, -- .addr = { 0 }, -- .addr_length = 0, -- .buffer = rxdata, -- .length = (uint32_t)*rxlength -- }; -- -- while (retries-- > 0 && status != TWI_SUCCESS) -- { -- status = twi_master_read(i2c_hal_data[bus]->twi_master_instance, &packet); -- } -- if (status != TWI_SUCCESS) -- { -- if (retries <= 0) -- { -- return ATCA_TOO_MANY_COMM_RETRIES; -- } -- -- return ATCA_COMM_FAIL; -- } -- --#ifdef DEBUG_HAL -- printf("\r\nResponse Packet (size:0x%.4x)\r\n", rxlength); -- printf("Count : %.2x\r\n", rxdata[0]); -- if (rxdata[0] > 3) -- { -- printf("Data : "); print_array(&rxdata[1], rxdata[0] - 3); -- printf("CRC : "); print_array(&rxdata[rxdata[0] - 2], 2); -- } -- printf("\r\n"); --#endif -- -- return ATCA_SUCCESS; --} -- --/** -- * \brief method to change the bus speed of I2C -- * -- * \param[in] iface interface on which to change bus speed -- * \param[in] speed baud rate (typically 100000 or 400000) -- */ --void change_i2c_speed(ATCAIface iface, uint32_t speed) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- -- // set to default i2c bus -- if (cfg->atcai2c.bus > MAX_I2C_BUSES - 1) -- { -- cfg->atcai2c.bus = 0; -- } -- int bus = cfg->atcai2c.bus; -- -- pmc_enable_periph_clk(i2c_hal_data[bus]->twi_id); -- -- opt_twi_master.master_clk = sysclk_get_cpu_hz(); -- opt_twi_master.speed = speed; -- opt_twi_master.smbus = 0; -- -- twi_master_init(i2c_hal_data[bus]->twi_master_instance, &opt_twi_master); --} -- --/** -- * \brief wake up CryptoAuth device using I2C bus -- * -- * \param[in] iface interface to logical device to wakeup -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_wake(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- -- //set to default i2c bus -- if (cfg->atcai2c.bus > MAX_I2C_BUSES - 1) -- { -- cfg->atcai2c.bus = 0; -- } -- int bus = cfg->atcai2c.bus; -- int retries = cfg->rx_retries; -- uint32_t bdrt = cfg->atcai2c.baud; -- int status = !TWI_SUCCESS; -- uint8_t data[4], expected[4] = { 0x04, 0x11, 0x33, 0x43 }; -- -- // if not already at 100kHz, change it -- if (bdrt != 100000) -- { -- change_i2c_speed(iface, 100000); -- } -- -- // Send 0x00 as wake pulse -- twi_write_byte(i2c_hal_data[bus]->twi_master_instance, 0x00); -- -- // rounded up to the nearest ms -- atca_delay_ms(((uint32_t)cfg->wake_delay + (1000 - 1)) / 1000); // wait tWHI + tWLO which is configured based on device type and configuration structure -- -- twi_packet_t packet = { -- .chip = cfg->atcai2c.slave_address >> 1, -- .addr = { 0 }, -- .addr_length = 0, -- .buffer = data, -- .length = 4 -- }; -- -- // if necessary, revert baud rate to what came in. -- if (bdrt != 100000) -- { -- change_i2c_speed(iface, bdrt); -- } -- -- while (retries-- > 0 && status != TWI_SUCCESS) -- { -- status = twi_master_read(i2c_hal_data[bus]->twi_master_instance, &packet); -- } -- if (status != TWI_SUCCESS) -- { -- if (retries <= 0) -- { -- return ATCA_TOO_MANY_COMM_RETRIES; -- } -- -- return ATCA_COMM_FAIL; -- } -- -- if (memcmp(data, expected, 4) == 0) -- { -- return ATCA_SUCCESS; -- } -- -- return ATCA_COMM_FAIL; --} -- --/** -- * \brief idle CryptoAuth device using I2C bus -- * -- * \param[in] iface interface to logical device to idle -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_idle(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- -- // set to default i2c bus -- if (cfg->atcai2c.bus > MAX_I2C_BUSES - 1) -- { -- cfg->atcai2c.bus = 0; -- } -- int bus = cfg->atcai2c.bus; -- uint8_t data[4]; -- -- data[0] = 0x02; // idle word address value -- -- twi_packet_t packet = { -- .chip = cfg->atcai2c.slave_address >> 1, -- .addr = { 0 }, -- .addr_length = 0, -- .buffer = data, -- .length = 1 -- }; -- -- if (twi_master_write(i2c_hal_data[bus]->twi_master_instance, &packet) != TWI_SUCCESS) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** -- * \brief sleep CryptoAuth device using I2C bus -- * -- * \param[in] iface interface to logical device to sleep -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_sleep(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- -- //// set to default i2c bus -- if (cfg->atcai2c.bus > MAX_I2C_BUSES - 1) -- { -- cfg->atcai2c.bus = 0; -- } -- int bus = cfg->atcai2c.bus; -- uint8_t data[4]; -- -- data[0] = 0x01; // sleep word address value -- -- twi_packet_t packet = { -- .chip = cfg->atcai2c.slave_address >> 1, -- .addr = { 0 }, -- .addr_length = 0, -- .buffer = data, -- .length = 1 -- }; -- -- if (twi_master_write(i2c_hal_data[bus]->twi_master_instance, &packet) != TWI_SUCCESS) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** -- * \brief manages reference count on given bus and releases resource if no more refences exist -- * -- * \param[in] hal_data - opaque pointer to hal data structure - known only to the HAL implementation -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_release(void *hal_data) --{ -- ATCAI2CMaster_t *hal = (ATCAI2CMaster_t*)hal_data; -- -- // set to default i2c bus -- if (hal->bus_index > MAX_I2C_BUSES - 1) -- { -- hal->bus_index = 0; -- } -- -- i2c_bus_ref_ct--; // track total i2c bus interface instances for consistency checking and debugging -- -- // if the use count for this bus has gone to 0 references, disable it. protect against an unbracketed release -- if (hal && --(hal->ref_ct) <= 0 && i2c_hal_data[hal->bus_index] != NULL) -- { -- twi_reset(hal->twi_master_instance); -- free(i2c_hal_data[hal->bus_index]); -- i2c_hal_data[hal->bus_index] = NULL; -- } -- -- return ATCA_SUCCESS; --} -- --/** @} */ -diff --git a/lib/hal/hal_samg55_i2c_asf.h b/lib/hal/hal_samg55_i2c_asf.h -deleted file mode 100644 -index a3c545c72d43..000000000000 ---- a/lib/hal/hal_samg55_i2c_asf.h -+++ /dev/null -@@ -1,67 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for SAMG55 I2C over ASF drivers. -- * -- * Prerequisite: add "TWI - Two-Wire Interface (Common API) (service)" module to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef HAL_SAMG55_I2C_ASF_H_ --#define HAL_SAMG55_I2C_ASF_H_ -- --#include -- -- --/** -- * \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * using I2C driver of ASF. -- * -- @{ */ -- --#define MAX_I2C_BUSES 2 // SAMG55 has 2 TWI -- --/** -- * \brief this is the hal_data for ATCA HAL -- */ --typedef struct atcaI2Cmaster --{ -- uint32_t twi_id; -- Twi * twi_master_instance; -- int ref_ct; -- // for conveniences during interface release phase -- int bus_index; --} ATCAI2CMaster_t; -- --void change_i2c_speed(ATCAIface iface, uint32_t speed); -- --/** @} */ -- --#endif /* HAL_SAMG55_I2C_ASF_H_ */ -\ No newline at end of file -diff --git a/lib/hal/hal_samg55_timer_asf.c b/lib/hal/hal_samg55_timer_asf.c -deleted file mode 100644 -index 6b5a27ce1dbf..000000000000 ---- a/lib/hal/hal_samg55_timer_asf.c -+++ /dev/null -@@ -1,86 +0,0 @@ --/** -- * \file -- * \brief -- * -- * Prerequisite: add "Delay routines (service)" module to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include "atca_hal.h" -- -- --/* ASF already have delay_us and delay_ms - see delay.h */ -- --/** -- * \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- --/** -- * \brief This function delays for a number of microseconds. -- * -- * \param[in] delay number of 0.001 milliseconds to delay -- */ --void atca_delay_us(uint32_t delay) --{ -- // use ASF supplied delay -- delay_us(delay); --} -- --/** -- * \brief This function delays for a number of tens of microseconds. -- * -- * \param[in] delay number of 0.01 milliseconds to delay -- */ --void atca_delay_10us(uint32_t delay) --{ -- // use ASF supplied delay -- delay_us(delay * 10); -- --} -- --/** -- * \brief This function delays for a number of milliseconds. -- * -- * You can override this function if you like to do -- * something else in your system while delaying. -- * -- * \param[in] delay number of milliseconds to delay -- */ --void atca_delay_ms(uint32_t delay) --{ -- // use ASF supplied delay -- delay_ms(delay); --} -- --/** @} */ -diff --git a/lib/hal/hal_samv71_i2c_asf.c b/lib/hal/hal_samv71_i2c_asf.c -deleted file mode 100644 -index 7da38807d998..000000000000 ---- a/lib/hal/hal_samv71_i2c_asf.c -+++ /dev/null -@@ -1,583 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for SAMV71 I2C over ASF drivers. -- * -- * This code is structured in two parts. Part 1 is the connection of the ATCA HAL API to the physical I2C -- * implementation. Part 2 is the ASF I2C primitives to set up the interface. -- * -- * Prerequisite: add SERCOM I2C Master Polled support to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include -- --#include "atca_hal.h" --#include "hal_samv71_i2c_asf.h" --#include "atca_device.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * using I2C driver of ASF. -- * -- @{ */ -- --/** \brief logical to physical bus mapping structure */ --ATCAI2CMaster_t *i2c_hal_data[MAX_I2C_BUSES]; // map logical, 0-based bus number to index --int i2c_bus_ref_ct = 0; // total in-use count across buses -- --/** \brief discover i2c buses available for this hardware -- * this maintains a list of logical to physical bus mappings freeing the application -- * of the a-priori knowledge -- * \param[in] i2c_buses - an array of logical bus numbers -- * \param[in] max_buses - maximum number of buses the app wants to attempt to discover -- * \return ATCA_SUCCESS -- */ -- --ATCA_STATUS hal_i2c_discover_buses(int i2c_buses[], int max_buses) --{ -- /* logical bus numbers 0-2 map to the V71 i2c buses: -- ID_TWIHS0 -- ID_TWIHS1 -- ID_TWIHS2 -- -- until ASF driver supports timeouts, only the TWIHS0 bus will respond on the SAMV71 Xplained Pro board -- otherwise, driver hangs on waiting for txready. -- for( i = 0; i < MAX_I2C_BUSES && i < max_buses; i++ ) -- i2c_buses[i] = i; -- */ -- i2c_buses[0] = 0; --#if MAX_I2C_BUSES == 3 -- i2c_buses[1] = -1; -- i2c_buses[2] = -1; --#endif -- return ATCA_SUCCESS; --} -- --/** \brief discover any CryptoAuth devices on a given logical bus number -- * \param[in] bus_num Logical bus number on which to look for CryptoAuth devices -- * \param[out] cfg Pointer to head of an array of interface config structures which get filled in by this method -- * \param[out] found Number of devices found on this bus -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_discover_devices(int bus_num, ATCAIfaceCfg cfg[], int *found) --{ -- ATCAIfaceCfg *head = cfg; -- uint8_t slave_address = 0x01; -- ATCADevice device; -- ATCAIface discover_iface; -- ATCACommand command; -- ATCAPacket packet; -- ATCA_STATUS status; -- uint8_t revs608[1][4] = { { 0x00, 0x00, 0x60, 0x01 } }; -- uint8_t revs508[1][4] = { { 0x00, 0x00, 0x50, 0x00 } }; -- uint8_t revs108[1][4] = { { 0x80, 0x00, 0x10, 0x01 } }; -- uint8_t revs204[3][4] = { { 0x00, 0x02, 0x00, 0x08 }, -- { 0x00, 0x02, 0x00, 0x09 }, -- { 0x00, 0x04, 0x05, 0x00 } }; -- int i; -- -- /** \brief default configuration, to be reused during discovery process */ -- ATCAIfaceCfg discoverCfg = { -- .iface_type = ATCA_I2C_IFACE, -- .devtype = ATECC508A, -- .atcai2c.slave_address = 0x07, -- .atcai2c.bus = bus_num, -- .atcai2c.baud = 400000, -- .wake_delay = 800, -- .rx_retries = 3 -- }; -- -- ATCAHAL_t hal; -- -- if (bus_num < 0) -- { -- return ATCA_COMM_FAIL; -- } -- -- hal_i2c_init(&hal, &discoverCfg); -- device = newATCADevice(&discoverCfg); -- discover_iface = atGetIFace(device); -- command = atGetCommands(device); -- -- // iterate through all addresses on given i2c bus -- // all valid 7-bit addresses go from 0x07 to 0x78 -- for (slave_address = 0x07; slave_address <= 0x78; slave_address++) -- { -- discoverCfg.atcai2c.slave_address = slave_address << 1; // turn it into an 8-bit address which is what the rest of the i2c HAL is expecting when a packet is sent -- -- // wake up device -- // If it wakes, send it a dev rev command. Based on that response, determine the device type -- // BTW - this will wake every cryptoauth device living on the same bus (ecc508a, sha204a) -- -- if (hal_i2c_wake(discover_iface) == ATCA_SUCCESS) -- { -- (*found)++; -- memcpy( (uint8_t*)head, (uint8_t*)&discoverCfg, sizeof(ATCAIfaceCfg)); -- -- memset(&packet, 0x00, sizeof(packet)); -- -- // get devrev info and set device type accordingly -- atInfo(command, &packet); -- if ((status = atGetExecTime(packet.opcode, command)) != ATCA_SUCCESS) -- { -- continue; -- } -- -- // send the command -- if ( (status = atsend(discover_iface, (uint8_t*)&packet, packet.txsize)) != ATCA_SUCCESS) -- { -- printf("packet send error\r\n"); -- continue; -- } -- -- // delay the appropriate amount of time for command to execute -- atca_delay_ms((command->execution_time_msec) + 1); -- -- // receive the response -- if ( (status = atreceive(discover_iface, &(packet.data[0]), &(packet.rxsize) )) != ATCA_SUCCESS) -- { -- continue; -- } -- -- if ( (status = isATCAError(packet.data)) != ATCA_SUCCESS) -- { -- continue; -- } -- -- // determine device type from common info and dev rev response byte strings -- for (i = 0; i < (int)sizeof(revs608) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs608[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC608A; -- break; -- } -- } -- -- for (i = 0; i < (int)sizeof(revs508) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs508[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC508A; -- break; -- } -- } -- -- for (i = 0; i < (int)sizeof(revs204) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs204[i], 4) == 0) -- { -- discoverCfg.devtype = ATSHA204A; -- break; -- } -- } -- -- for (i = 0; i < (int)sizeof(revs108) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs108[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC108A; -- break; -- } -- } -- -- atca_delay_ms(15); -- // now the device type is known, so update the caller's cfg array element with it -- head->devtype = discoverCfg.devtype; -- head++; -- } -- -- hal_i2c_idle(discover_iface); -- } -- -- // hal_i2c_release(&hal); -- -- return ATCA_SUCCESS; --} -- --/** \brief -- - this HAL implementation assumes you've included the ASF Twi libraries in your project, otherwise, -- the HAL layer will not compile because the ASF TWI drivers are a dependency * -- */ -- --/** \brief hal_i2c_init manages requests to initialize a physical interface. it manages use counts so when an interface -- * has released the physical layer, it will disable the interface for some other use. -- * You can have multiple ATCAIFace instances using the same bus, and you can have multiple ATCAIFace instances on -- * multiple i2c buses, so hal_i2c_init manages these things and ATCAIFace is abstracted from the physical details. -- */ -- --/** \brief initialize an I2C interface using given config -- * \param[in] hal - opaque ptr to HAL data -- * \param[in] cfg - interface configuration -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_init(void *hal, ATCAIfaceCfg *cfg) --{ -- int bus = cfg->atcai2c.bus; // 0-based logical bus number -- ATCAHAL_t *phal = (ATCAHAL_t*)hal; -- twihs_options_t twi_options; -- -- if (i2c_bus_ref_ct == 0) // power up state, no i2c buses will have been used -- { -- for (int i = 0; i < MAX_I2C_BUSES; i++) -- { -- i2c_hal_data[i] = NULL; -- } -- } -- -- i2c_bus_ref_ct++; // total across buses -- -- if (bus >= 0 && bus < MAX_I2C_BUSES) -- { -- // if this is the first time this bus and interface has been created, do the physical work of enabling it -- if (i2c_hal_data[bus] == NULL) -- { -- i2c_hal_data[bus] = malloc(sizeof(ATCAI2CMaster_t) ); -- i2c_hal_data[bus]->ref_ct = 1; // buses are shared, this is the first instance -- -- /* Configure the options of TWI driver */ -- twi_options.master_clk = sysclk_get_cpu_hz() / CONFIG_SYSCLK_DIV; -- twi_options.speed = cfg->atcai2c.baud; -- -- switch (bus) -- { -- case 0: /* Enable the peripheral clock for TWI */ -- pmc_enable_periph_clk(ID_TWIHS0); -- if (twihs_master_init(TWIHS0, &twi_options) != TWIHS_SUCCESS) -- { -- return ATCA_COMM_FAIL; -- } -- i2c_hal_data[bus]->twi_module = (uint32_t)TWIHS0; -- break; -- -- case 1: /* Enable the peripheral clock for TWI */ -- pmc_enable_periph_clk(ID_TWIHS1); -- if (twihs_master_init(TWIHS1, &twi_options) != TWIHS_SUCCESS) -- { -- return ATCA_COMM_FAIL; -- } -- i2c_hal_data[bus]->twi_module = (uint32_t)TWIHS1; -- break; -- -- case 2: /* Enable the peripheral clock for TWI */ -- pmc_enable_periph_clk(ID_TWIHS2); -- if (twihs_master_init(TWIHS2, &twi_options) != TWIHS_SUCCESS) -- { -- return ATCA_COMM_FAIL; -- } -- i2c_hal_data[bus]->twi_module = (uint32_t)TWIHS2; -- break; -- } -- -- // store this for use during the release phase -- i2c_hal_data[bus]->bus_index = bus; -- } -- else -- { -- // otherwise, another interface already initialized the bus, so this interface will share it and any different -- // cfg parameters will be ignored...first one to initialize this sets the configuration -- i2c_hal_data[bus]->ref_ct++; -- } -- -- phal->hal_data = i2c_hal_data[bus]; -- -- return ATCA_SUCCESS; -- } -- -- return ATCA_COMM_FAIL; --} -- --/** \brief HAL implementation of I2C post init -- * \param[in] iface instance -- * \return ATCA_SUCCESS -- */ --ATCA_STATUS hal_i2c_post_init(ATCAIface iface) --{ -- return ATCA_SUCCESS; --} -- -- --/** \brief HAL implementation of I2C send over ASF -- * \param[in] iface instance -- * \param[in] txdata pointer to space to bytes to send -- * \param[in] txlength number of bytes to send -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_send(ATCAIface iface, uint8_t *txdata, int txlength) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- Twihs *twihs_device = (Twihs*)(i2c_hal_data[bus]->twi_module); -- -- twihs_packet_t packet = { -- .addr[0] = 0, -- .addr[1] = 0, -- .addr_length = 0, //very important, since cryptoauthdevices do not require addressing; -- .chip = cfg->atcai2c.slave_address >> 1, -- .buffer = txdata, -- }; -- -- // for this implementation of I2C with CryptoAuth chips, txdata is assumed to have ATCAPacket format -- -- // other device types that don't require i/o tokens on the front end of a command need a different hal_i2c_send and wire it up instead of this one -- // this covers devices such as ATSHA204A and ATECCx08A that require a word address value pre-pended to the packet -- // txdata[0] is using _reserved byte of the ATCAPacket -- txdata[0] = 0x03; // insert the Word Address Value, Command token -- txlength++; // account for word address value byte. -- packet.length = txlength; -- -- if (twihs_master_write(twihs_device, &packet) != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** \brief HAL implementation of I2C receive function for ASF I2C -- * \param[in] iface instance -- * \param[out] rxdata pointer to space to receive the data -- * \param[in] rxlength ptr to expected number of receive bytes to request -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_receive(ATCAIface iface, uint8_t *rxdata, uint16_t *rxlength) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- int retries = cfg->rx_retries; -- int status = !STATUS_OK; -- Twihs *twihs_device = (Twihs*)(i2c_hal_data[bus]->twi_module); -- -- twihs_packet_t packet = { -- .chip = cfg->atcai2c.slave_address >> 1, // use 7-bit address -- .buffer = rxdata, -- .length = *rxlength -- }; -- -- while (retries-- > 0 && status != STATUS_OK) -- { -- if (twihs_master_read(twihs_device, &packet) != TWIHS_SUCCESS) -- { -- status = ATCA_COMM_FAIL; -- } -- else -- { -- status = ATCA_SUCCESS; -- } -- } -- -- if (status != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** \brief method to change the bus speed of I2C -- * \param[in] iface interface on which to change bus speed -- * \param[in] speed baud rate (typically 100000 or 400000) -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS change_i2c_speed(ATCAIface iface, uint32_t speed) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- Twihs *twihs_device = (Twihs*)(i2c_hal_data[bus]->twi_module); -- -- // if necessary, revert baud rate to what came in. -- if (twihs_set_speed(twihs_device, speed, sysclk_get_cpu_hz() / CONFIG_SYSCLK_DIV) == FAIL) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** \brief wake up CryptoAuth device using I2C bus -- * \param[in] iface interface to logical device to wakeup -- * \return ATCA_SUCCESS on success, otherwise an error code. -- -- */ -- --ATCA_STATUS hal_i2c_wake(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- uint16_t rxlength; -- uint32_t bdrt = cfg->atcai2c.baud; -- int status = !STATUS_OK; -- uint8_t data[4], expected[4] = { 0x04, 0x11, 0x33, 0x43 }; -- Twihs *twihs_device = (Twihs*)(i2c_hal_data[bus]->twi_module); -- -- if (bdrt != 100000) // if not already at 100KHz, change it -- -- { -- if (twihs_set_speed(twihs_device, 100000, sysclk_get_cpu_hz() / CONFIG_SYSCLK_DIV) == FAIL) -- { -- return ATCA_COMM_FAIL; -- } -- } -- -- twihs_packet_t packet = { -- .addr[0] = 0, -- .addr[1] = 0, -- .addr_length = 0, //very important, since cryptoauthdevices do not require addressing; -- .chip = cfg->atcai2c.slave_address >> 1, -- .buffer = &data[0], -- .length = 1 -- }; -- -- twihs_master_write(twihs_device, &packet); -- -- atca_delay_us(cfg->wake_delay); // wait tWHI + tWLO which is configured based on device type and configuration structure -- -- // look for wake response -- rxlength = 4; -- memset(data, 0x00, rxlength); -- status = hal_i2c_receive(iface, data, &rxlength); -- -- // if necessary, revert baud rate to what came in. -- if (bdrt != 100000) -- { -- if (twihs_set_speed(twihs_device, bdrt, sysclk_get_cpu_hz() / CONFIG_SYSCLK_DIV) == FAIL) -- { -- return ATCA_COMM_FAIL; -- } -- } -- -- if (status != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- if (memcmp(data, expected, 4) == 0) -- { -- return ATCA_SUCCESS; -- } -- -- return ATCA_COMM_FAIL; --} -- -- --/** \brief idle CryptoAuth device using I2C bus -- * \param[in] iface interface to logical device to idle -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_idle(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- uint8_t data[4]; -- Twihs *twihs_device = (Twihs*)(i2c_hal_data[bus]->twi_module); -- -- data[0] = 0x02; // idle word address value -- -- twihs_packet_t packet = { -- .addr[0] = 0, -- .addr[1] = 0, -- .addr_length = 0, //very important, since cryptoauthdevices do not require addressing; -- .chip = cfg->atcai2c.slave_address >> 1, -- .buffer = data, -- }; -- -- packet.length = 1; -- -- if (twihs_master_write(twihs_device, &packet) != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** \brief sleep CryptoAuth device using I2C bus -- * \param[in] iface interface to logical device to sleep -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_sleep(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- uint8_t data[4]; -- Twihs *twihs_device = (Twihs*)(i2c_hal_data[bus]->twi_module); -- -- data[0] = 0x01; // sleep word address value -- -- twihs_packet_t packet = { -- .addr[0] = 0, -- .addr[1] = 0, -- .addr_length = 0, //very important, since cryptoauthdevices do not require addressing; -- .chip = cfg->atcai2c.slave_address >> 1, -- .buffer = data, -- }; -- -- packet.length = 1; -- -- if (twihs_master_write(twihs_device, &packet) != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** \brief manages reference count on given bus and releases resource if no more refences exist -- * \param[in] hal_data - opaque pointer to hal data structure - known only to the HAL implementation -- * \return ATCA_SUCCESS -- */ -- --ATCA_STATUS hal_i2c_release(void *hal_data) --{ -- ATCAI2CMaster_t *hal = (ATCAI2CMaster_t*)hal_data; -- int bus = hal->bus_index; -- Twihs *twihs_device = (Twihs*)(i2c_hal_data[bus]->twi_module); -- -- i2c_bus_ref_ct--; // track total i2c bus interface instances for consistency checking and debugging -- -- // if the use count for this bus has gone to 0 references, disable it. protect against an unbracketed release -- if (hal && --(hal->ref_ct) <= 0 && i2c_hal_data[bus] != NULL) -- { -- twihs_disable_master_mode(twihs_device); -- free(i2c_hal_data[hal->bus_index]); -- i2c_hal_data[hal->bus_index] = NULL; -- } -- -- return ATCA_SUCCESS; --} -- --/** @} */ -diff --git a/lib/hal/hal_samv71_i2c_asf.h b/lib/hal/hal_samv71_i2c_asf.h -deleted file mode 100644 -index 7efcb52b8b17..000000000000 ---- a/lib/hal/hal_samv71_i2c_asf.h -+++ /dev/null -@@ -1,63 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for SAMV71 I2C over ASF drivers. -- * -- * Prerequisite: add SERCOM I2C Master Polled support to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef HAL_SAMV71_I2C_ASF_H_ --#define HAL_SAMV71_I2C_ASF_H_ -- --#include -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * using I2C driver of ASF. -- * -- @{ */ -- -- --#define MAX_I2C_BUSES 3 -- --/** \brief this is the hal_data for ATCA HAL for ASF SERCOM -- */ --typedef struct atcaI2Cmaster --{ -- int ref_ct; -- // for conveniences during interface release phase -- int bus_index; -- uint32_t twi_module; --} ATCAI2CMaster_t; -- --ATCA_STATUS change_i2c_speed(ATCAIface iface, uint32_t speed); -- --/** @} */ --#endif /* HAL_SAMD21_I2C_ASF_H_ */ -\ No newline at end of file -diff --git a/lib/hal/hal_samv71_timer_asf.c b/lib/hal/hal_samv71_timer_asf.c -deleted file mode 100644 -index 1090a2d26f70..000000000000 ---- a/lib/hal/hal_samv71_timer_asf.c -+++ /dev/null -@@ -1,79 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for SAMD21 timer/delay over ASF drivers. -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include "atca_hal.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- -- --/** \brief This function delays for a number of microseconds. -- * -- * \param[in] delay number of 0.001 milliseconds to delay -- */ --void atca_delay_us(uint32_t delay) --{ -- // use ASF supplied delay -- delay_us(delay); --} -- --/** \brief This function delays for a number of tens of microseconds. -- * -- * \param[in] delay number of 0.01 milliseconds to delay -- */ --void atca_delay_10us(uint32_t delay) --{ -- // use ASF supplied delay -- delay_us(delay * 10); -- --} -- --/** \brief This function delays for a number of milliseconds. -- * -- * You can override this function if you like to do -- * something else in your system while delaying. -- * \param[in] delay number of milliseconds to delay -- */ -- --/* ASF already has delay_ms - see delay.h */ --void atca_delay_ms(uint32_t delay) --{ -- // use ASF supplied delay -- delay_ms(delay); --} -- --/** @} */ -diff --git a/lib/hal/hal_swi_bitbang.c b/lib/hal/hal_swi_bitbang.c -deleted file mode 100644 -index 412b393d9bd0..000000000000 ---- a/lib/hal/hal_swi_bitbang.c -+++ /dev/null -@@ -1,347 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for SWI bit banging. -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include --#include "atca_hal.h" --#include "hal_swi_bitbang.h" --#include "atca_device.h" -- -- --/** -- * \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief These methods define the hardware abstraction layer for -- * communicating with a CryptoAuth device using SWI bit banging. -- @{ */ -- --/** -- * \brief Logical to physical bus mapping structure. -- */ --ATCASWIMaster_t *swi_hal_data[MAX_SWI_BUSES]; //!< map logical, 0-based bus number to index --int swi_bus_ref_ct = 0; //!< total in-use count across buses -- --/** \brief discover swi buses available for this hardware -- * this maintains a list of logical to physical bus mappings freeing the application.This function is currently not supported. -- * of the a-priori knowledge -- * \param[in] swi_buses - an array of logical bus numbers -- * \param[in] max_buses - maximum number of buses the app wants to attempt to discover -- * \return ATCA_UNIMPLEMENTED -- */ --ATCA_STATUS hal_swi_discover_buses(int swi_buses[], int max_buses) --{ -- -- return ATCA_UNIMPLEMENTED; -- --} -- --/** \brief discover any CryptoAuth devices on a given logical bus number.This function is curently not supported. -- * \param[in] busNum - logical bus number on which to look for CryptoAuth devices -- * \param[out] cfg[] - pointer to head of an array of interface config structures which get filled in by this method -- * \param[out] *found - number of devices found on this bus -- * \return ATCA_UNIMPLEMENTED -- */ -- --ATCA_STATUS hal_swi_discover_devices(int busNum, ATCAIfaceCfg cfg[], int *found) --{ -- return ATCA_UNIMPLEMENTED; -- --} -- -- -- --/** -- * \brief hal_swi_init manages requests to initialize a physical -- * interface. It manages use counts so when an interface has -- * released the physical layer, it will disable the interface for -- * some other use. You can have multiple ATCAIFace instances using -- * the same bus, and you can have multiple ATCAIFace instances on -- * multiple swi buses, so hal_swi_init manages these things and -- * ATCAIFace is abstracted from the physical details. -- */ -- --/** -- * \brief Initialize an SWI interface using given config. -- * -- * \param[in] hal opaque pointer to HAL data -- * \param[in] cfg interface configuration -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_swi_init(void *hal, ATCAIfaceCfg *cfg) --{ -- ATCAHAL_t *phal = (ATCAHAL_t*)hal; -- -- int bus = cfg->atcaswi.bus; //!< 0-based logical bus number -- -- if (swi_bus_ref_ct == 0) //!< power up state, no swi buses will have been used -- -- { -- for (int i = 0; i < MAX_SWI_BUSES; i++) -- { -- swi_hal_data[i] = NULL; -- } -- } -- swi_bus_ref_ct++; //!< total across buses -- -- if (bus >= 0 && bus < MAX_SWI_BUSES) -- { -- //! if this is the first time this bus and interface has been created, do the physical work of enabling it -- if (swi_hal_data[bus] == NULL) -- { -- swi_hal_data[bus] = malloc(sizeof(ATCASWIMaster_t)); -- -- //! assign GPIO pin -- swi_hal_data[bus]->pin_sda = swi_buses_default.pin_sda[bus]; -- -- swi_set_pin(swi_hal_data[bus]->pin_sda); -- swi_enable(); -- -- //! store this for use during the release phase -- swi_hal_data[bus]->bus_index = bus; -- } -- else -- { -- //! otherwise, another interface already initialized the bus, any different -- //! cfg parameters will be ignored...first one to initialize this sets the configuration -- } -- -- phal->hal_data = swi_hal_data[bus]; -- -- return ATCA_SUCCESS; -- } -- -- return ATCA_COMM_FAIL; --} -- --/** -- * \brief HAL implementation of SWI post init. -- * -- * \param[in] iface ATCAIface instance -- * -- * \return ATCA_SUCCESS -- */ --ATCA_STATUS hal_swi_post_init(ATCAIface iface) --{ -- return ATCA_SUCCESS; --} -- --/** -- * \brief Send byte(s) via SWI. -- * -- * \param[in] iface interface of the logical device to send data to -- * \param[in] txdata pointer to bytes to send -- * \param[in] txlength number of bytes to send -- * \return ATCA_SUCCESS -- */ --ATCA_STATUS hal_swi_send(ATCAIface iface, uint8_t *txdata, int txlength) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- -- int bus = cfg->atcaswi.bus; -- -- //! Skip the Word Address data as SWI doesn't use it -- txdata++; -- -- //! Set SWI pin -- swi_set_pin(swi_hal_data[bus]->pin_sda); -- -- //! Send Command Flag -- swi_send_byte(SWI_FLAG_CMD); -- -- //! Send the remaining bytes -- swi_send_bytes(txlength, txdata); -- -- return ATCA_SUCCESS; --} -- --/** -- * \brief Receive byte(s) via SWI. -- * -- * \param[in] iface interface of the logical device to receive data -- * from -- * \param[out] rxdata pointer to where bytes will be received -- * \param[in] rxlength pointer to expected number of receive bytes to -- * request -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_swi_receive(ATCAIface iface, uint8_t *rxdata, uint16_t *rxlength) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- -- ATCA_STATUS status = ATCA_RX_TIMEOUT; -- -- int bus = cfg->atcaswi.bus; -- int retries = cfg->rx_retries; -- uint16_t count; -- -- //! Set SWI pin -- swi_set_pin(swi_hal_data[bus]->pin_sda); -- -- while (retries-- > 0 && status != ATCA_SUCCESS) -- { -- swi_send_byte(SWI_FLAG_TX); -- -- status = swi_receive_bytes(*rxlength, rxdata); -- if (status == ATCA_RX_FAIL) -- { -- count = rxdata[0]; -- if ((count < ATCA_RSP_SIZE_MIN) || (count > *rxlength)) -- { -- status = ATCA_INVALID_SIZE; -- break; -- } -- else -- { -- status = ATCA_SUCCESS; -- } -- } -- else if (status == ATCA_RX_TIMEOUT) -- { -- status = ATCA_RX_NO_RESPONSE; -- } -- } -- -- return status; --} -- --/** -- * \brief Send Wake flag via SWI. -- * -- * \param[in] iface interface of the logical device to wake up -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_swi_wake(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- -- ATCA_STATUS status = ATCA_WAKE_FAILED; -- -- int bus = cfg->atcaswi.bus; -- uint8_t response[4] = { 0x00, 0x00, 0x00, 0x00 }; -- uint8_t expected_response[4] = { 0x04, 0x11, 0x33, 0x43 }; -- uint16_t rxlength = sizeof(response); -- -- //! Set SWI pin -- swi_set_pin(swi_hal_data[bus]->pin_sda); -- -- //! Generate Wake Token -- swi_send_wake_token(); -- -- //! Wait tWHI + tWLO -- atca_delay_us(cfg->wake_delay); -- -- status = hal_swi_receive(iface, response, &rxlength); -- if (status == ATCA_SUCCESS) -- { -- //! Compare response with expected_response -- if (memcmp(response, expected_response, 4) != 0) -- { -- status = ATCA_WAKE_FAILED; -- } -- } -- -- return status; --} -- --/** -- * \brief Send Idle flag via SWI. -- * -- * \param[in] iface interface of the logical device to idle -- * -- * \return ATCA_SUCCES -- */ --ATCA_STATUS hal_swi_idle(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- -- int bus = cfg->atcaswi.bus; -- -- //! Set SWI pin -- swi_set_pin(swi_hal_data[bus]->pin_sda); -- -- swi_send_byte(SWI_FLAG_IDLE); -- -- return ATCA_SUCCESS; --} -- --/** -- * \brief Send Sleep flag via SWI. -- * -- * \param[in] iface interface of the logical device to sleep -- * -- * \return ATCA_SUCCESS -- */ --ATCA_STATUS hal_swi_sleep(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- -- int bus = cfg->atcaswi.bus; -- -- //! Set SWI pin -- swi_set_pin(swi_hal_data[bus]->pin_sda); -- -- swi_send_byte(SWI_FLAG_SLEEP); -- -- return ATCA_SUCCESS; --} -- --/** -- * \brief Manages reference count on given bus and releases resource if -- * no more reference(s) exist. -- * -- * \param[in] hal_data opaque pointer to hal data structure - known only -- * to the HAL implementation -- * -- * \return ATCA_SUCCESS -- */ --ATCA_STATUS hal_swi_release(void *hal_data) --{ -- ATCASWIMaster_t *hal = (ATCASWIMaster_t*)hal_data; -- -- swi_bus_ref_ct--; //!< track total SWI instances -- -- //! if the use count for this bus has gone to 0 references, disable it. protect against an unbracketed release -- if (hal && swi_hal_data[hal->bus_index] != NULL) -- { -- swi_set_pin(swi_hal_data[hal->bus_index]->pin_sda); -- swi_disable(); -- free(swi_hal_data[hal->bus_index]); -- swi_hal_data[hal->bus_index] = NULL; -- } -- -- return ATCA_SUCCESS; --} -- --/** @} */ -\ No newline at end of file -diff --git a/lib/hal/hal_swi_bitbang.h b/lib/hal/hal_swi_bitbang.h -deleted file mode 100644 -index b981a6fc99ff..000000000000 ---- a/lib/hal/hal_swi_bitbang.h -+++ /dev/null -@@ -1,76 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for SWI bit banging. -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef HAL_SWI_BITBANG_H_ --#define HAL_SWI_BITBANG_H_ -- -- --#if BOARD == AT88CK9000 --#include "swi_bitbang_at88ck9000.h" --#endif -- --#if (SAMD21 == 1) --#include "swi_bitbang_samd21.h" --#endif -- -- -- --/** -- * \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief These methods define the hardware abstraction layer for -- * communicating with a CryptoAuth device using SWI bit banging. -- @{ */ -- --/** -- * \brief This enumeration lists flags for SWI. -- */ --enum swi_flag --{ -- SWI_FLAG_CMD = (uint8_t)0x77, //!< flag preceding a command -- SWI_FLAG_TX = (uint8_t)0x88, //!< flag requesting a response -- SWI_FLAG_IDLE = (uint8_t)0xBB, //!< flag requesting to go into Idle mode -- SWI_FLAG_SLEEP = (uint8_t)0xCC //!< flag requesting to go into Sleep mode --}; -- --/** -- * \brief This is the hal_data for ATCA HAL. -- */ --typedef struct atcaSWImaster --{ -- uint8_t pin_sda; -- //! for conveniences during interface release phase -- int bus_index; --} ATCASWIMaster_t; -- --/** @} */ -- --#endif /* HAL_SWI_BITBANG_H_ */ -\ No newline at end of file -diff --git a/lib/hal/hal_swi_uart.c b/lib/hal/hal_swi_uart.c -deleted file mode 100644 -index f379d9abcd5e..000000000000 ---- a/lib/hal/hal_swi_uart.c -+++ /dev/null -@@ -1,527 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for SWI over UART drivers. -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include "atca_hal.h" --#include "hal_swi_uart.h" --#include "atca_device.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * using SWI Interface. -- * -- @{ */ -- --/** \brief logical to physical bus mapping structure */ --ATCASWIMaster_t *swi_hal_data[MAX_SWI_BUSES]; // map logical, 0-based bus number to index --int swi_bus_ref_ct = 0; // total in-use count across buses -- --#ifdef DEBUG_HAL --static void print_array(uint8_t *data, uint32_t data_size) --{ -- // printf("%.4x\r\n", data_size); -- -- uint32_t n; -- -- for (n = 0; n < data_size; n++) -- { -- printf("%.2x ", data[n]); -- if (((n + 1) % 16) == 0) -- { -- printf("\r\n"); -- if ((n + 1) != data_size) -- { -- printf(" "); -- } -- } -- } -- if (data_size % 16 != 0) -- { -- printf("\r\n"); -- } --} --#endif -- -- --/** \brief discover swi buses available for this hardware -- * this maintains a list of logical to physical bus mappings freeing the application -- * of the a-priori knowledge -- * \param[in] swi_buses - an array of logical bus numbers -- * \param[in] max_buses - maximum number of buses the app wants to attempt to discover -- * \return ATCA_SUCCESS -- */ -- --ATCA_STATUS hal_swi_discover_buses(int swi_buses[], int max_buses) --{ -- swi_uart_discover_buses(swi_buses, max_buses); -- -- return ATCA_SUCCESS; --} -- --/** \brief discover any CryptoAuth devices on a given logical bus number -- * \param[in] busNum - logical bus number on which to look for CryptoAuth devices -- * \param[out] cfg[] - pointer to head of an array of interface config structures which get filled in by this method -- * \param[out] *found - number of devices found on this bus -- * \return ATCA_SUCCESS -- */ -- --ATCA_STATUS hal_swi_discover_devices(int busNum, ATCAIfaceCfg cfg[], int *found) --{ -- ATCAIfaceCfg *head = cfg; -- ATCADevice device; -- ATCAIface discoverIface; -- ATCACommand command; -- ATCAPacket packet; -- ATCA_STATUS status; -- uint8_t revs508[1][4] = { { 0x00, 0x00, 0x50, 0x00 } }; -- uint8_t revs108[1][4] = { { 0x80, 0x00, 0x10, 0x01 } }; -- uint8_t revs204[3][4] = { { 0x00, 0x02, 0x00, 0x08 }, -- { 0x00, 0x02, 0x00, 0x09 }, -- { 0x00, 0x04, 0x05, 0x00 } }; -- unsigned int i; -- -- /** \brief default configuration, to be reused during discovery process */ -- ATCAIfaceCfg discoverCfg = { -- .iface_type = ATCA_SWI_IFACE, -- .devtype = ATECC508A, -- .atcaswi.bus = busNum, -- .wake_delay = 800, -- .rx_retries = 3 -- }; -- -- // build an info command -- packet.param1 = INFO_MODE_REVISION; -- packet.param2 = 0; -- -- device = newATCADevice(&discoverCfg); -- discoverIface = atGetIFace(device); -- command = atGetCommands(device); -- -- // wake up device -- // If it wakes, send it a dev rev command. Based on that response, determine the device type -- // BTW - this will wake every cryptoauth device living on the same bus (ecc508a, sha204a) -- -- if (hal_swi_wake(discoverIface) == ATCA_SUCCESS) -- { -- (*found)++; -- memcpy( (uint8_t*)head, (uint8_t*)&discoverCfg, sizeof(ATCAIfaceCfg)); -- -- memset(packet.data, 0x00, sizeof(packet.data)); -- -- // get devrev info and set device type accordingly -- atInfo(command, &packet); -- if ((status = atGetExecTime(packet.opcode, command)) != ATCA_SUCCESS) -- { -- return status; -- } -- -- // send the command -- if ( (status = atsend(discoverIface, (uint8_t*)&packet, packet.txsize)) != ATCA_SUCCESS) -- { -- printf("packet send error\r\n"); -- } -- -- // delay the appropriate amount of time for command to execute -- atca_delay_ms((command->execution_time_msec) + 1); -- -- // receive the response -- if ( (status = atreceive(discoverIface, &(packet.data[0]), &(packet.rxsize) )) != ATCA_SUCCESS) -- { -- } -- -- if ( (status = isATCAError(packet.data)) != ATCA_SUCCESS) -- { -- printf("command response error\r\n"); -- } -- -- // determine device type from common info and dev rev response byte strings -- for (i = 0; i < sizeof(revs508) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs508[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC508A; -- break; -- } -- } -- -- for (i = 0; i < sizeof(revs204) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs204[i], 4) == 0) -- { -- discoverCfg.devtype = ATSHA204A; -- break; -- } -- } -- -- for (i = 0; i < sizeof(revs108) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs108[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC108A; -- break; -- } -- } -- -- atca_delay_ms(15); -- // now the device type is known, so update the caller's cfg array element with it -- head->devtype = discoverCfg.devtype; -- -- hal_swi_idle(discoverIface); -- } -- -- deleteATCADevice(&device); -- -- return ATCA_SUCCESS; --} -- --/** \brief hal_swi_init manages requests to initialize a physical interface. it manages use counts so when an interface -- * has released the physical layer, it will disable the interface for some other use. -- * You can have multiple ATCAIFace instances using the same bus, and you can have multiple ATCAIFace instances on -- * multiple swi buses, so hal_swi_init manages these things and ATCAIFace is abstracted from the physical details. -- */ -- --/** \brief initialize an SWI interface using given config -- * \param[in] hal - opaque ptr to HAL data -- * \param[in] cfg - interface configuration -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_swi_init(void *hal, ATCAIfaceCfg *cfg) --{ -- int bus = cfg->atcaswi.bus; // 0-based logical bus number -- ATCAHAL_t *phal = (ATCAHAL_t*)hal; -- -- if (swi_bus_ref_ct == 0) // power up state, no swi buses will have been used -- { -- for (int i = 0; i < MAX_SWI_BUSES; i++) -- { -- swi_hal_data[i] = NULL; -- } -- swi_bus_ref_ct++; // total across buses become 1 -- } -- -- if (bus >= 0 && bus < MAX_SWI_BUSES) -- { -- // if this is the first time this bus and interface has been created, do the physical work of enabling it -- if (swi_hal_data[bus] == NULL) -- { -- swi_hal_data[bus] = malloc(sizeof(ATCASWIMaster_t) ); -- // store this for use during the release phase -- swi_hal_data[bus]->bus_index = bus; -- // initialize UART module for SWI interface -- swi_uart_init(swi_hal_data[bus]); -- } -- else -- { -- // otherwise, another interface already initialized the bus, any different -- // cfg parameters will be ignored...first one to initialize this sets the configuration -- } -- phal->hal_data = swi_hal_data[bus]; -- -- return ATCA_SUCCESS; -- } -- return ATCA_COMM_FAIL; --} -- --/** \brief HAL implementation of SWI post init -- * \param[in] iface instance -- * \return ATCA_SUCCESS -- */ -- --ATCA_STATUS hal_swi_post_init(ATCAIface iface) --{ -- return ATCA_SUCCESS; --} -- --/** \brief HAL implementation of SWI send one byte over UART -- * \param[in] iface instance -- * \param[in] data bytes to send -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_swi_send_flag(ATCAIface iface, uint8_t data) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcaswi.bus; -- uint8_t bit_mask, bit_data; -- -- for (bit_mask = 1; bit_mask > 0; bit_mask <<= 1) -- { -- // Send one byte that represent one bit, 0x7F for one or 0x7D for zero -- // The LSB (least significant bit) is sent first. -- bit_data = (bit_mask & data) ? 0x7F : 0x7D; -- status |= swi_uart_send_byte(swi_hal_data[bus], bit_data); -- -- } -- if (status != ATCA_SUCCESS) -- { -- return ATCA_COMM_FAIL; -- } -- else -- { -- return ATCA_SUCCESS; -- } --} -- --/** \brief HAL implementation of SWI send command over UART -- * \param[in] iface instance -- * \param[in] txdata pointer to space to bytes to send -- * \param[in] txlength number of bytes to send -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_swi_send(ATCAIface iface, uint8_t *txdata, int txlength) --{ -- --#ifdef DEBUG_HAL -- printf("hal_swi_send()\r\n"); -- -- printf("\r\nCommand Packet (size:0x%.4x)\r\n", txlength); -- printf("Count : %.2x\r\n", txdata[1]); -- printf("Opcode : %.2x\r\n", txdata[2]); -- printf("Param1 : %.2x\r\n", txdata[3]); -- printf("Param2 : "); print_array(&txdata[4], 2); -- if (txdata[1] > 7) -- { -- printf("Data : "); print_array(&txdata[6], txdata[1] - 7); -- } -- printf("CRC : "); print_array(&txdata[txdata[1] - 1], 2); -- printf("\r\n"); --#endif -- ATCA_STATUS status = ATCA_SUCCESS; -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcaswi.bus; -- uint8_t i, bit_mask, bit_data; -- -- //Skip the Word Address data as SWI doesn't use it -- txdata++; -- -- status = hal_swi_send_flag(iface, SWI_FLAG_CMD); -- if (status == ATCA_SUCCESS) -- { -- for (i = 0; i < txlength; i++) -- { -- for (bit_mask = 1; bit_mask > 0; bit_mask <<= 1) -- { -- // Send one byte that represent one bit, 0x7F for one or 0x7D for zero -- // The LSB (least significant bit) is sent first. -- bit_data = (bit_mask & *txdata) ? 0x7F : 0x7D; -- status = swi_uart_send_byte(swi_hal_data[bus], bit_data); -- if (status != ATCA_SUCCESS) -- { -- return ATCA_COMM_FAIL; -- } -- } -- txdata++; -- } -- return ATCA_SUCCESS; -- } -- return ATCA_COMM_FAIL; --} -- --/** \brief HAL implementation of SWI receive function over UART -- * \param[in] iface instance -- * \param[out] rxdata pointer to space to receive the data -- * \param[in] rxlength ptr to expected number of receive bytes to request -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_swi_receive(ATCAIface iface, uint8_t *rxdata, uint16_t *rxlength) --{ --#ifdef DEBUG_HAL -- printf("hal_swi_receive()\r\n"); --#endif -- ATCA_STATUS status = ATCA_COMM_FAIL; -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcaswi.bus; -- int retries = cfg->rx_retries; -- uint8_t bit_mask, *head_buff, bit_data; -- uint16_t i = 0; -- -- while ((status != ATCA_SUCCESS) && (retries >= 0x00)) -- { -- retries--; -- head_buff = rxdata; -- -- status = hal_swi_send_flag(iface, SWI_FLAG_TX); -- -- // Set SWI to receive mode. -- swi_uart_mode(swi_hal_data[bus], RECEIVE_MODE); --#ifdef SAMD21_ASF -- RX_DELAY --#else -- atca_delay_us(RX_DELAY); // Must be configured to sync with response from device --#endif -- if (status == ATCA_SUCCESS) -- { -- for (i = 0; i < *rxlength; i++) -- { -- *head_buff = 0x00; -- for (bit_mask = 1; bit_mask > 0; bit_mask <<= 1) -- { -- bit_data = 0; -- status = swi_uart_receive_byte(swi_hal_data[bus], &bit_data); -- if ((i == 0) && (bit_mask == 1) && (status != ATCA_SUCCESS)) -- { -- break; -- } -- // Sometimes bit data from device is stretched -- // When the device sends a "one" bit, it is read as 0x7E or 0x7F. -- // When the device sends a "zero" bit, it is read as 0x7A, 0x7B, or 7D. -- if ((bit_data ^ 0x7F) < 2) -- { -- // Received "one" bit. -- *head_buff |= bit_mask; -- } -- } -- if ((i == 0) && (bit_mask == 1) && (status != ATCA_SUCCESS)) -- { -- break; -- } -- head_buff++; -- } -- // Set SWI to transmit mode. -- swi_uart_mode(swi_hal_data[bus], TRANSMIT_MODE); -- atca_delay_us(TX_DELAY); // Must be configured to sync with response from device -- } -- // The Response shorter than expected -- if ((i >= 4) && (status == ATCA_TIMEOUT)) -- { -- status = ATCA_SUCCESS; -- } -- } --#ifdef DEBUG_HAL -- printf("\r\nResponse Packet (size:0x%.4x)\r\n", *rxlength); -- printf("Count : %.2x\r\n", rxdata[0]); -- if (rxdata[0] > 3) -- { -- printf("Data : "); print_array(&rxdata[1], rxdata[0] - 3); -- printf("CRC : "); print_array(&rxdata[rxdata[0] - 2], 2); -- } -- printf("\r\n"); --#endif -- return status; --} -- -- --/** \brief wake up CryptoAuth device using SWI interface -- * \param[in] iface interface to logical device to wakeup -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_swi_wake(ATCAIface iface) --{ --#ifdef DEBUG_HAL -- printf("hal_swi_wake()\r\n"); --#endif -- ATCA_STATUS status = ATCA_COMM_FAIL; -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcaswi.bus; -- int retries = cfg->rx_retries; -- uint16_t datalength = 4; -- uint8_t data[4] = { 0x00, 0x00, 0x00, 0x00 }, expected[4] = { 0x04, 0x11, 0x33, 0x43 }; -- -- while ((status != ATCA_SUCCESS) && (retries >= 0x00)) -- { -- retries--; -- // Change baudrate to 115200 to get low signal more than 60us -- swi_uart_setbaud(swi_hal_data[bus], 115200); -- // Send byte 0x00 -- status = swi_uart_send_byte(swi_hal_data[bus], SWI_WAKE_TOKEN); -- // Change baudrate back to 230400 -- swi_uart_setbaud(swi_hal_data[bus], 230400); -- } -- -- if (!status) -- { -- atca_delay_us(cfg->wake_delay); // wait tWHI + tWLO which is configured based on device type and configuration structure -- status = hal_swi_receive(iface, data, &datalength); -- } -- -- if ((retries == 0x00) && (status != ATCA_SUCCESS) ) -- { -- return ATCA_TIMEOUT; -- } -- -- if (memcmp(data, expected, 4) == 0) -- { -- return ATCA_SUCCESS; -- } -- -- return ATCA_COMM_FAIL; --} -- --/** \brief idle CryptoAuth device using SWI interface -- * \param[in] iface interface to logical device to idle -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_swi_idle(ATCAIface iface) --{ -- return hal_swi_send_flag(iface, SWI_FLAG_IDLE); --} -- --/** \brief sleep CryptoAuth device using SWI interface -- * \param[in] iface interface to logical device to sleep -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_swi_sleep(ATCAIface iface) --{ -- return hal_swi_send_flag(iface, SWI_FLAG_SLEEP); --} -- --/** \brief manages reference count on given bus and releases resource if no more refences exist -- * \param[in] hal_data - opaque pointer to hal data structure - known only to the HAL implementation -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_swi_release(void *hal_data) --{ -- ATCASWIMaster_t *hal = (ATCASWIMaster_t*)hal_data; -- -- swi_bus_ref_ct--; // track total SWI instances -- -- // if the use count for this bus has gone to 0 references, disable it. protect against an unbracketed release -- if (hal && swi_hal_data[hal->bus_index] != NULL) -- { -- swi_uart_deinit(swi_hal_data[hal->bus_index]); -- free(swi_hal_data[hal->bus_index]); -- swi_hal_data[hal->bus_index] = NULL; -- } -- return ATCA_SUCCESS; --} -- --/** @} */ -diff --git a/lib/hal/hal_swi_uart.h b/lib/hal/hal_swi_uart.h -deleted file mode 100644 -index 75274a7d4f2e..000000000000 ---- a/lib/hal/hal_swi_uart.h -+++ /dev/null -@@ -1,62 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for SWI over UART drivers. -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef HAL_SWI_UART_H_ --#define HAL_SWI_UART_H_ -- --#ifdef SAMD21_START -- #include "swi_uart_samd21_start.h" --#elif defined (SAMD21_ASF) -- #include "swi_uart_samd21_asf.h" --#elif defined (XMEGA_ASF) -- #include "swi_uart_xmega_a3bu_asf.h" --#elif defined (AT90USB_ASF) -- #include "swi_uart_at90usb1287_asf.h" --#endif -- -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * using SWI interface. -- * -- @{ */ --#define SWI_WAKE_TOKEN ((uint8_t)0x00) //!< flag preceding a command --#define SWI_FLAG_CMD ((uint8_t)0x77) //!< flag preceding a command --#define SWI_FLAG_TX ((uint8_t)0x88) //!< flag requesting a response --#define SWI_FLAG_IDLE ((uint8_t)0xBB) //!< flag requesting to go into Idle mode --#define SWI_FLAG_SLEEP ((uint8_t)0xCC) //!< flag requesting to go into Sleep mode -- --ATCA_STATUS hal_swi_send_flag(ATCAIface iface, uint8_t flag); -- --/** @} */ --#endif /* HAL_SWI_UART_H_ */ -\ No newline at end of file -diff --git a/lib/hal/hal_win_kit_cdc.c b/lib/hal/hal_win_kit_cdc.c -deleted file mode 100644 -index be3664f3df3b..000000000000 ---- a/lib/hal/hal_win_kit_cdc.c -+++ /dev/null -@@ -1,556 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for Windows using kit protocol over a USB CDC device. -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --//#include "atca_basic.h" --#include "atca_hal.h" --#include "kit_phy.h" --#include "hal_win_kit_cdc.h" --#include "kit_protocol.h" -- --#include --#include --#include --#include -- -- --// File scope globals --atcacdc_t _gCdc; -- -- -- --/** \brief HAL implementation of Kit USB CDC init -- * \param[in] hal pointer to HAL specific data that is maintained by this HAL -- * \param[in] cfg pointer to HAL specific configuration data that is used to initialize this HAL -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_cdc_init(void* hal, ATCAIfaceCfg* cfg) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- ATCAHAL_t *phal = NULL; -- GUID *pcdc_guid = NULL; -- HDEVINFO dev_info; -- SP_DEVINFO_DATA dev_data; -- DWORD device_index = 0; -- DWORD required_size = 0; -- HKEY reg_key; -- DWORD reg_type = 0; -- TCHAR reg_data[256]; -- TCHAR cdc_data[256]; -- BOOL result = FALSE; -- LONG reg_result = 0; -- DCB dcb_settings; -- COMMTIMEOUTS comm_timeouts; -- int i = 0; -- int index = 0; -- -- // Check the input variables -- if ((hal == NULL) || (cfg == NULL)) -- { -- return ATCA_BAD_PARAM; -- } -- -- // Cast the hal to the ATCAHAL_t strucure -- phal = (ATCAHAL_t*)hal; -- -- // Initialize the _gCdc structure -- memset(&_gCdc, 0, sizeof(_gCdc)); -- for (i = 0; i < CDC_DEVICES_MAX; i++) -- { -- _gCdc.kits[i].read_handle = INVALID_HANDLE_VALUE; -- _gCdc.kits[i].write_handle = INVALID_HANDLE_VALUE; -- } -- -- _gCdc.num_kits_found = 0; -- -- // Get the number of available GUIDs -- result = SetupDiClassGuidsFromName(_T("Ports"), NULL, 0, &required_size); -- if (required_size == 0) -- { -- return ATCA_COMM_FAIL; -- } -- -- // Allocated the memory the GUID list -- pcdc_guid = malloc(required_size * sizeof(GUID)); -- -- // Get the number of available GUIDs -- result = SetupDiClassGuidsFromName(_T("Ports"), pcdc_guid, required_size, &required_size); -- if (result == TRUE) -- { -- //Query the devices -- dev_info = SetupDiGetClassDevs(pcdc_guid, NULL, NULL, DIGCF_PRESENT); -- if (dev_info != INVALID_HANDLE_VALUE) -- { -- // Initialize the dev_data object -- memset(&dev_data, 0, sizeof(SP_DEVINFO_DATA)); -- dev_data.cbSize = sizeof(SP_DEVINFO_DATA); -- -- while (SetupDiEnumDeviceInfo(dev_info, device_index, &dev_data)) -- { -- // Get the USB CDC friendly name -- required_size = sizeof(reg_data); -- result = SetupDiGetDeviceRegistryProperty(dev_info, &dev_data, SPDRP_FRIENDLYNAME, ®_type, -- (PBYTE)reg_data, required_size, &required_size); -- if (result == TRUE) -- { -- // Determine if this is the correct kit USB CDC device -- if ((_tcsstr(reg_data, _T("AT90USB"))) || -- (_tcsstr(reg_data, _T("XPLAINED"))) || -- (_tcsstr(reg_data, _T("Class ASF")))) -- { -- // Get the registry key for the kit USB CDC device -- reg_key = SetupDiOpenDevRegKey(dev_info, &dev_data, DICS_FLAG_GLOBAL, -- 0, DIREG_DEV, KEY_QUERY_VALUE); -- if (reg_key != INVALID_HANDLE_VALUE) -- { -- // Get the port used with this kit USB CDC device -- required_size = sizeof(reg_data); -- reg_result = RegQueryValueEx(reg_key, _T("PortName"), NULL, NULL, -- (LPBYTE)reg_data, &required_size); -- if (reg_result == ERROR_SUCCESS) -- { -- _sntprintf_s(cdc_data, sizeof(cdc_data) / sizeof(cdc_data[0]), _TRUNCATE, _T("\\\\.\\%s"), reg_data); -- -- // Open the kit USB device for reading and writing -- if (_gCdc.kits[index].read_handle != INVALID_HANDLE_VALUE) -- { -- CloseHandle(_gCdc.kits[index].read_handle); -- } -- _gCdc.kits[index].read_handle = INVALID_HANDLE_VALUE; -- _gCdc.kits[index].write_handle = INVALID_HANDLE_VALUE; -- -- _gCdc.kits[index].read_handle = CreateFile(cdc_data, -- GENERIC_READ | GENERIC_WRITE, -- 0, -- NULL, -- OPEN_EXISTING, -- FILE_ATTRIBUTE_NORMAL, -- NULL); -- _gCdc.kits[index].write_handle = _gCdc.kits[index].read_handle; -- -- if (_gCdc.kits[index].read_handle != INVALID_HANDLE_VALUE) -- { -- // Get the comm settings -- dcb_settings.DCBlength = sizeof(DCB); -- result = GetCommState(_gCdc.kits[index].read_handle, &dcb_settings); -- if (result == FALSE) -- { -- continue; -- } -- -- // Set the comm settings -- dcb_settings.BaudRate = cfg->atcauart.baud; -- dcb_settings.ByteSize = cfg->atcauart.wordsize; -- dcb_settings.StopBits = cfg->atcauart.stopbits; -- -- switch (cfg->atcauart.parity) -- { -- case 0: dcb_settings.Parity = EVENPARITY; -- case 1: dcb_settings.Parity = ODDPARITY; -- case 2: dcb_settings.Parity = NOPARITY; -- default: dcb_settings.Parity = NOPARITY; -- } -- -- result = SetCommState(_gCdc.kits[index].read_handle, &dcb_settings); -- if (result == FALSE) -- { -- continue; -- } -- -- // Set the comm timeout settings -- comm_timeouts.ReadIntervalTimeout = 3; -- comm_timeouts.ReadTotalTimeoutMultiplier = 3; -- comm_timeouts.ReadTotalTimeoutConstant = 2; -- comm_timeouts.WriteTotalTimeoutMultiplier = 3; -- comm_timeouts.WriteTotalTimeoutConstant = 2; -- -- SetCommTimeouts(_gCdc.kits[index].read_handle, &comm_timeouts); -- } -- -- // Increment the opened kit USB device index -- index++; -- } -- -- // Close the registry key -- RegCloseKey(reg_key); -- } -- } -- } -- -- // Break the while loop, if the maximum number of supported -- // kit USB devices have been found -- if (index == CDC_DEVICES_MAX) -- { -- break; -- } -- -- // Increment the device member index -- device_index++; -- } -- } -- -- // Delete device info now that we're done -- SetupDiDestroyDeviceInfoList(dev_info); -- } -- -- // Free allocated memory -- free(pcdc_guid); -- -- // Save the results of this discovery of HID -- if (index > 0) -- { -- _gCdc.num_kits_found = index; -- phal->hal_data = &_gCdc; -- return status; -- } -- return ATCA_NO_DEVICES; --} -- --/** \brief discover all CDC kits available.This function is currently not implemented. -- * this maintains a list of logical to physical bus mappings freeing the application -- * of the a-priori knowledge -- * \param[in] i2c_buses - an array of logical bus numbers -- * \param[in] max_buses - maximum number of buses the app wants to attempt to discover -- * \return ATCA_UNIMPLEMENTED -- */ -- --ATCA_STATUS hal_cdc_discover_buses(int i2c_buses[], int max_buses) --{ -- // TODO: This should be set to the com port index(s) -- return ATCA_UNIMPLEMENTED; --} -- --/** \brief discover any CryptoAuth devices on a given logical bus number.This function is currently not implemented. -- * \param[in] busNum - logical bus number on which to look for CryptoAuth devices -- * \param[out] cfg[] - pointer to head of an array of interface config structures which get filled in by this method -- * \param[out] *found - number of devices found on this bus -- * \return ATCA_UNIMPLEMENTED -- */ --ATCA_STATUS hal_cdc_discover_devices(int busNum, ATCAIfaceCfg cfg[], int *found) --{ -- // TODO: Add kitg protocol calls to discover all devices -- return ATCA_UNIMPLEMENTED; --} -- -- --/** \brief HAL implementation of Kit USB CDC post init -- * \param[in] iface instance -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_cdc_post_init(ATCAIface iface) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- atcacdc_t* pHalDat = atgetifacehaldat(iface); -- ATCAIfaceCfg *pCfg = atgetifacecfg(iface); -- int i = 0; -- -- do -- { -- // Check the pointers -- if (pHalDat == NULL || pCfg == NULL) -- { -- status = ATCA_BAD_PARAM; -- BREAK(status, "NULL pointers in hal_kit_cdc_post_init"); -- } -- // Init all kit USB devices -- for (i = 0; i < pHalDat->num_kits_found; i++) -- { -- // Set the port -- pCfg->atcauart.port = i; -- // Perform the kit protocol init -- status = kit_init(iface); -- if (status != ATCA_SUCCESS) -- { -- BREAK(status, "kit_init() Failed"); -- } -- } -- } -- while (0); -- return status; --} -- --/** \brief HAL implementation of kit protocol send .It is called by the top layer. -- * \param[in] iface instance -- * \param[in] txdata pointer to bytes to send -- * \param[in] txlength number of bytes to send -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS kit_phy_send(ATCAIface iface, const char* txdata, int txlength) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int cdcid = cfg->atcauart.port; -- atcacdc_t* pCdc = (atcacdc_t*)atgetifacehaldat(iface); -- uint8_t buffer[CDC_BUFFER_MAX]; -- DWORD bytes_to_send = 0; -- DWORD bytes_left = 0; -- DWORD bytes_sent = 0; -- BOOL result = FALSE; -- -- if ((txdata == NULL) || (pCdc == NULL)) -- { -- return ATCA_BAD_PARAM; -- } -- -- if (pCdc->kits[cdcid].write_handle == INVALID_HANDLE_VALUE) -- { -- return ATCA_COMM_FAIL; -- } -- -- bytes_left = txlength; -- -- while (bytes_left > 0) -- { -- memset(buffer, 0, CDC_BUFFER_MAX); -- -- if (bytes_left >= CDC_BUFFER_MAX) -- { -- bytes_to_send = CDC_BUFFER_MAX; -- } -- else -- { -- bytes_to_send = bytes_left; -- } -- -- memcpy(&buffer[0], &txdata[(txlength - bytes_left)], bytes_to_send); -- -- result = WriteFile(pCdc->kits[cdcid].write_handle, buffer, bytes_to_send, &bytes_sent, NULL); -- if (result == FALSE) -- { -- return ATCA_TX_FAIL; -- } -- -- bytes_left -= bytes_sent; -- } -- return status; --} -- -- --/** \brief HAL implementation of kit protocol receive data.It is called by the top layer. -- * \param[in] iface instance -- * \param[out] rxdata pointer to space to receive the data -- * \param[inout] rxsize ptr to expected number of receive bytes to request -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS kit_phy_receive(ATCAIface iface, char* rxdata, int* rxsize) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int cdcid = cfg->atcauart.port; -- atcacdc_t* pCdc = (atcacdc_t*)atgetifacehaldat(iface); -- uint8_t buffer[CDC_BUFFER_MAX] = { 0 }; -- BOOL continue_read = TRUE; -- DWORD bytes_read = 0; -- DWORD total_bytes = 0; -- BOOL result = true; -- uint8_t* location = NULL; -- int bytes_remain = 0; -- int bytes_to_copy = 0; -- int size_adjust = 0; -- -- // Verify the input variables -- if ((rxdata == NULL) || (rxsize == NULL) || (pCdc == NULL)) -- { -- return ATCA_BAD_PARAM; -- } -- -- if (pCdc->kits[cdcid].read_handle == INVALID_HANDLE_VALUE) -- { -- return ATCA_COMM_FAIL; -- } -- -- DWORD start_time_ms = GetTickCount(); -- while (continue_read == true) -- { -- // If the CDC port disappears while trying to read, ReadFile will continue to report -- // success and return 0 bytes. Same as when we're waiting for a reply. This lets the -- // operation timeout. -- if (GetTickCount() - start_time_ms > 3000) -- { -- // Close handles to force a quicker failure. -- CloseHandle(pCdc->kits[cdcid].read_handle); -- pCdc->kits[cdcid].read_handle = INVALID_HANDLE_VALUE; -- pCdc->kits[cdcid].write_handle = INVALID_HANDLE_VALUE; -- return ATCA_COMM_FAIL; -- } -- -- result = ReadFile(pCdc->kits[cdcid].read_handle, buffer, CDC_BUFFER_MAX, &bytes_read, NULL); -- if (result == FALSE) -- { -- return ATCA_RX_FAIL; -- } -- -- // Find the location of the '\n' character in read buffer -- // todo: generalize this read... it only applies if there is an ascii protocol with an of \n and if the exists -- location = strchr((char*)&buffer[0], '\n'); -- if (location == NULL) -- { -- // Copy all of the bytes -- bytes_to_copy = bytes_read; -- } -- else -- { -- // Copy only the bytes remaining in the read buffer to the -- bytes_to_copy = (int)(location - (char*)buffer); -- -- // The response has been received, stop receiving more data -- continue_read = false; -- } -- // Protect rxdata from overwriting, this will have the result of truncating the returned bytes -- // Remaining space in rxdata -- bytes_remain = (*rxsize - total_bytes); -- // Use the minimum between number of bytes read and remaining space -- bytes_to_copy = min(bytes_remain, bytes_to_copy); -- -- // Copy the received data -- memcpy(&rxdata[total_bytes], &buffer[0], bytes_to_copy); -- total_bytes += bytes_to_copy - size_adjust; -- } -- *rxsize = total_bytes; -- return ATCA_SUCCESS; --} -- --/** \brief Number of USB CDC devices found -- * \param[out] num_found Number of USB CDC devices found returned here -- * \return ATCA_SUCCESS -- */ --ATCA_STATUS hal_kit_phy_num_found(int8_t* num_found) --{ -- *num_found = _gCdc.num_kits_found; -- return ATCA_SUCCESS; --} -- --/** \brief HAL implementation of kit protocol send over USB CDC -- * \param[in] iface instance -- * \param[in] txdata pointer to bytes to send -- * \param[in] txlength number of bytes to send -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_cdc_send(ATCAIface iface, uint8_t* txdata, int txlength) --{ -- // Call the hal_kit_send() function that will call hal_phy_send() implemented below -- return kit_send(iface, txdata, txlength); --} -- --/** \brief HAL implementation of kit protocol receive over USB CDC -- * \param[in] iface instance -- * \param[in] rxdata pointer to space to receive the data -- * \param[inout] rxsize ptr to expected number of receive bytes to request -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_cdc_receive(ATCAIface iface, uint8_t* rxdata, uint16_t* rxsize) --{ -- // Call the hal_kit_receive() function that will call hal_phy_receive() implemented below -- return kit_receive(iface, rxdata, rxsize); --} -- --/** \brief Call the wake for kit protocol over USB CDC -- * \param[in] iface ATCAIface instance that is the interface object to send the bytes over -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_cdc_wake(ATCAIface iface) --{ -- // Call the hal_kit_wake() function that will call hal_phy_send() and hal_phy_receive() -- return kit_wake(iface); --} -- --/** \brief Call the idle for kit protocol over USB CDC -- * \param[in] iface ATCAIface instance that is the interface object to send the bytes over -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_cdc_idle(ATCAIface iface) --{ -- // Call the hal_kit_idle() function that will call hal_phy_send() and hal_phy_receive() -- return kit_idle(iface); --} -- --/** \brief Call the sleep for kit protocol over USB CDC -- * \param[in] iface ATCAIface instance that is the interface object to send the bytes over -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_cdc_sleep(ATCAIface iface) --{ -- // Call the hal_kit_sleep() function that will call hal_phy_send() and hal_phy_receive() -- return kit_sleep(iface); --} -- --/** \brief Close the physical port for CDC -- * \param[in] hal_data The hardware abstraction data specific to this HAL -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_cdc_release(void* hal_data) --{ -- int i = 0; -- atcacdc_t* phaldat = (atcacdc_t*)hal_data; -- -- if ((hal_data == NULL)) -- { -- return ATCA_BAD_PARAM; -- } -- -- // Close all kit USB devices -- for (i = 0; i < phaldat->num_kits_found; i++) -- { -- if (phaldat->kits[i].read_handle != INVALID_HANDLE_VALUE) -- { -- CloseHandle(phaldat->kits[i].read_handle); -- phaldat->kits[i].read_handle = INVALID_HANDLE_VALUE; -- phaldat->kits[i].write_handle = INVALID_HANDLE_VALUE; -- } -- } -- return ATCA_SUCCESS; --} -- --/** \brief discover cdc buses available for this hardware -- * this maintains a list of logical to physical bus mappings freeing the application -- * of the a-priori knowledge.This function is currently not implemented. -- * \param[in] cdc_buses - an array of logical bus numbers -- * \param[in] max_buses - maximum number of buses the app wants to attempt to discover -- * \return ATCA_UNIMPLEMENTED -- */ -- --ATCA_STATUS hal_kit_cdc_discover_buses(int cdc_buses[], int max_buses) --{ -- // TODO: Implement -- return ATCA_UNIMPLEMENTED; --} -- -- --/** \brief discover any CryptoAuth devices on a given logical bus number -- * \param[in] busNum - logical bus number on which to look for CryptoAuth devices -- * \param[out] cfg[] - pointer to head of an array of interface config structures which get filled in by this method -- * \param[out] *found - number of devices found on this bus -- * \return ATCA_UNIMPLEMENTED -- */ --ATCA_STATUS hal_kit_cdc_discover_devices(int busNum, ATCAIfaceCfg *cfg, int *found) --{ -- // TODO: Implement -- *found = 0; -- return ATCA_UNIMPLEMENTED; --} -\ No newline at end of file -diff --git a/lib/hal/hal_win_kit_cdc.h b/lib/hal/hal_win_kit_cdc.h -deleted file mode 100644 -index 8970d54965e2..000000000000 ---- a/lib/hal/hal_win_kit_cdc.h -+++ /dev/null -@@ -1,58 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for Windows using kit protocol over a USB CDC device. -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef HAL_WIN_KIT_CDC_H_ --#define HAL_WIN_KIT_CDC_H_ -- --#include -- --// Kit USB defines --#define CDC_DEVICES_MAX 10 //! Maximum number of supported Kit USB devices --#define CDC_BUFFER_MAX 1024 //! Maximum number of bytes read per port read -- -- --// Each device that is found will have a read handle and a write handle --typedef struct cdc_device --{ -- HANDLE read_handle; //! The kit USB read file handle -- HANDLE write_handle; //! The kit USB write file handle --} cdc_device_t; -- -- --// A structure to hold CDC information --typedef struct atcacdc --{ -- cdc_device_t kits[CDC_DEVICES_MAX]; -- int8_t num_kits_found; --} atcacdc_t; -- --#endif /* HAL_WIN_KIT_CDC_H_ */ -- -diff --git a/lib/hal/hal_win_kit_hid.c b/lib/hal/hal_win_kit_hid.c -deleted file mode 100644 -index 44b52120bbee..000000000000 ---- a/lib/hal/hal_win_kit_hid.c -+++ /dev/null -@@ -1,469 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for Windows using kit protocol over a USB HID device. -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include "atca_hal.h" --#include "hal_win_kit_hid.h" --#include "kit_protocol.h" --#include "kit_phy.h" --#include --#include --#include --#include -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- --// File scope globals --atcahid_t _gHid; -- --// The HID GUID filter --#define HID_GUID { 0x4d1e55b2, 0xf16f, 0x11cf, 0x88, 0xcb, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 } -- -- -- --/** \brief HAL implementation of Kit USB HID init -- * \param[in] hal pointer to HAL specific data that is maintained by this HAL -- * \param[in] cfg pointer to HAL specific configuration data that is used to initialize this HAL -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_hid_init(void* hal, ATCAIfaceCfg* cfg) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- ATCAHAL_t *phal = NULL; -- GUID hid_guid = HID_GUID; -- HDEVINFO dev_info; -- SP_DEVICE_INTERFACE_DATA dev_data; -- PSP_DEVICE_INTERFACE_DETAIL_DATA dev_detail_data; -- DWORD required_size = 0; -- BOOL result = FALSE; -- DWORD device_index = 0; -- int i = 0; -- int index = 0; -- TCHAR hid_filter[32]; -- -- // Check the input variables -- if ((hal == NULL) || (cfg == NULL)) -- { -- return ATCA_BAD_PARAM; -- } -- -- // Cast the hal to the ATCAHAL_t strucure -- phal = (ATCAHAL_t*)hal; -- -- // Initialize the _gHid structure -- memset(&_gHid, 0, sizeof(_gHid)); -- for (i = 0; i < HID_DEVICES_MAX; i++) -- { -- _gHid.kits[i].read_handle = INVALID_HANDLE_VALUE; -- _gHid.kits[i].write_handle = INVALID_HANDLE_VALUE; -- } -- -- _gHid.num_kits_found = 0; -- -- // Initialize the GUID --// UuidFromString(cfg->atcahid.guid, &hid_guid); -- -- // Query the devices -- dev_info = SetupDiGetClassDevs(&hid_guid, NULL, NULL, (DIGCF_PRESENT | DIGCF_DEVICEINTERFACE)); -- if (dev_info == INVALID_HANDLE_VALUE) -- { -- return ATCA_COMM_FAIL; -- } -- -- // Initialize the dev_data object -- memset(&dev_data, 0, sizeof(SP_DEVICE_INTERFACE_DATA)); -- dev_data.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); -- -- // Construct the filter string -- memset(hid_filter, 0, sizeof(hid_filter)); -- _stprintf(hid_filter, _T("vid_%04x&pid_%04x"), cfg->atcahid.vid, cfg->atcahid.pid); -- -- // Find the Atmel kit USB devices -- while (SetupDiEnumDeviceInterfaces(dev_info, NULL, &hid_guid, device_index, &dev_data)) -- { -- // Get the required buffer size of the detailed data -- SetupDiGetDeviceInterfaceDetail(dev_info, &dev_data, NULL, 0, &required_size, NULL); -- -- // Allocate the required space for the detailed interface data -- dev_detail_data = (PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(required_size); -- -- // Retrieve the detailed interface data -- dev_detail_data->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); -- result = SetupDiGetDeviceInterfaceDetail(dev_info, &dev_data, dev_detail_data, -- required_size, &required_size, NULL); -- -- // Determine if this is the correct kit USB device -- -- if (_tcsstr(dev_detail_data->DevicePath, hid_filter) != NULL) -- { -- // Open the kit USB device for reading and writing -- if (_gHid.kits[index].read_handle != INVALID_HANDLE_VALUE) -- { -- CloseHandle(_gHid.kits[index].read_handle); -- } -- if (_gHid.kits[index].write_handle != INVALID_HANDLE_VALUE) -- { -- CloseHandle(_gHid.kits[index].write_handle); -- } -- -- _gHid.kits[index].read_handle = CreateFile(dev_detail_data->DevicePath, -- GENERIC_READ, -- (FILE_SHARE_READ | FILE_SHARE_WRITE), -- NULL, -- OPEN_EXISTING, -- 0, -- NULL); -- _gHid.kits[index].write_handle = CreateFile(dev_detail_data->DevicePath, -- GENERIC_WRITE, -- (FILE_SHARE_READ | FILE_SHARE_WRITE), -- NULL, -- OPEN_EXISTING, -- 0, -- NULL); -- -- // Increment the opened kit USB device index -- index++; -- } -- // Deallocate the required space for the detailed interface data -- free(dev_detail_data); -- -- // Break the while loop, if the maximum number of supported -- // kit USB devices have been found -- if (index == HID_DEVICES_MAX) -- { -- break; -- } -- -- // Increment the device member index -- device_index++; -- } -- -- // Delete device info now that we're done -- SetupDiDestroyDeviceInfoList(dev_info); -- -- // Save the results of this discovery of HID -- if (index > 0) -- { -- _gHid.num_kits_found = index; -- phal->hal_data = &_gHid; -- } -- return status; --} -- -- --/** \brief discover all HID kits available.This function is currently not implemented. -- * this maintains a list of logical to physical bus mappings freeing the application -- * of the a-priori knowledge -- * \param[in] cdc_buses an array of logical bus numbers -- * \param[in] max_buses maximum number of buses the app wants to attempt to discover -- * \return ATCA_UNIMPLEMENTED -- */ --ATCA_STATUS hal_kit_hid_discover_buses(int cdc_buses[], int max_buses) --{ -- // TODO: This should be set to the com port index(s) -- return ATCA_UNIMPLEMENTED; --} -- --/** \brief discover any CryptoAuth devices on a given logical bus number.This function is currently not implemented. -- * \param[in] busNum - logical bus number on which to look for CryptoAuth devices -- * \param[out] cfg[] - pointer to head of an array of interface config structures which get filled in by this method -- * \param[out] *found - number of devices found on this bus -- * \return ATCA_UNIMPLEMENTED -- */ --ATCA_STATUS hal_kit_hid_discover_devices(int busNum, ATCAIfaceCfg cfg[], int *found) --{ -- // TODO: Add kitg protocol calls to discover all devices -- return ATCA_UNIMPLEMENTED; --} -- --/** \brief HAL implementation of Kit HID post init -- * \param[in] iface instance -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_hid_post_init(ATCAIface iface) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- atcahid_t* pHid = atgetifacehaldat(iface); -- ATCAIfaceCfg *pCfg = atgetifacecfg(iface); -- int i = 0; -- -- do -- { -- // Check the pointers -- if (pHid == NULL || pCfg == NULL) -- { -- status = ATCA_BAD_PARAM; -- BREAK(status, "NULL pointers in hal_kit_hid_post_init"); -- } -- // Init all kit USB HID devices -- for (i = 0; i < pHid->num_kits_found; i++) -- { -- // Perform the kit protocol init -- status = kit_init(iface); -- if (status != ATCA_SUCCESS) -- { -- BREAK(status, "kit_init() Failed"); -- } -- } -- -- } -- while (0); -- return status; --} -- --/** \brief HAL implementation of kit protocol send .It is called by the top layer. -- * \param[in] iface instance -- * \param[in] txdata pointer to bytes to send -- * \param[in] txlength number of bytes to send -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS kit_phy_send(ATCAIface iface, const char* txdata, int txlength) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int hidid = cfg->atcahid.idx; -- atcahid_t* pHid = (atcahid_t*)atgetifacehaldat(iface); -- uint8_t buffer[HID_PACKET_MAX]; -- DWORD bytes_to_send = 0; -- DWORD bytes_left = 0; -- DWORD bytes_sent = 0; -- BOOL result = FALSE; -- -- if ((txdata == NULL) || (pHid == NULL)) -- { -- return ATCA_BAD_PARAM; -- } -- -- if (pHid->kits[hidid].write_handle == INVALID_HANDLE_VALUE) -- { -- return ATCA_COMM_FAIL; -- } -- -- bytes_left = txlength; -- -- while (bytes_left > 0) -- { -- memset(buffer, 0, (HID_PACKET_MAX)); -- -- if (bytes_left >= cfg->atcahid.packetsize) -- { -- bytes_to_send = cfg->atcahid.packetsize; -- } -- else -- { -- bytes_to_send = bytes_left; -- } -- -- memcpy(&buffer[1], &txdata[(txlength - bytes_left)], bytes_to_send); -- -- result = WriteFile(pHid->kits[hidid].write_handle, buffer, (cfg->atcahid.packetsize + 1), &bytes_sent, NULL); -- if (result == FALSE) -- { -- return ATCA_TX_FAIL; -- } -- -- bytes_left -= bytes_to_send; -- } -- return status; --} -- --/** \brief HAL implementation of kit protocol receive data.It is called by the top layer. -- * \param[in] iface instance -- * \param[out] rxdata pointer to space to receive the data -- * \param[inout] rxsize ptr to expected number of receive bytes to request -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS kit_phy_receive(ATCAIface iface, char* rxdata, int* rxsize) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int hidid = cfg->atcahid.idx; -- atcahid_t* pHid = (atcahid_t*)atgetifacehaldat(iface); -- uint8_t buffer[HID_PACKET_MAX] = { 0 }; -- BOOL continue_read = TRUE; -- DWORD bytes_read = 0; -- DWORD total_bytes = 0; -- BOOL result = true; -- char* location = NULL; -- int bytes_remain = 0; -- int bytes_to_cpy = 0; -- int size_adjust = 0; -- -- // Verify the input variables -- if ((rxdata == NULL) || (rxsize == NULL) || (pHid == NULL)) -- { -- return ATCA_BAD_PARAM; -- } -- -- if (pHid->kits[hidid].read_handle == INVALID_HANDLE_VALUE) -- { -- return ATCA_COMM_FAIL; -- } -- -- while (continue_read == true) -- { -- result = ReadFile(pHid->kits[hidid].read_handle, buffer, (cfg->atcahid.packetsize + 1), &bytes_read, NULL); -- if (result == false) -- { -- return ATCA_RX_FAIL; -- } -- // Find the location of the '\n' character in read buffer -- // todo: generalize this read... it only applies if there is an ascii protocol with an of \n and if the exists -- location = strchr((char*)&buffer[1], '\n'); -- if (location == NULL) -- { -- // Copy all of the bytes -- bytes_to_cpy = bytes_read; -- // An extra byte is prepended to HID communication -- size_adjust = 1; -- } -- else -- { -- // Copy only the bytes remaining in the read buffer to the -- bytes_to_cpy = (uint8_t)(location - (char*)buffer); -- size_adjust = 0; -- // The response has been received, stop receiving more data -- continue_read = false; -- } -- // Protect rxdata from overwriting, this will have the result of truncating the returned bytes -- // Remaining space in rxdata -- bytes_remain = (*rxsize - total_bytes); -- // Use the minimum between number of bytes read and remaining space -- bytes_to_cpy = min(bytes_remain, bytes_to_cpy); -- -- // Copy the received data -- memcpy(&rxdata[total_bytes], &buffer[1], bytes_to_cpy); -- total_bytes += bytes_to_cpy - size_adjust; -- } -- *rxsize = total_bytes; -- return ATCA_SUCCESS; --} -- --/** \brief Number of USB HID devices found -- * \param[out] num_found -- * \return SUCCESS -- */ --ATCA_STATUS kit_phy_num_found(int8_t* num_found) --{ -- *num_found = _gHid.num_kits_found; -- return ATCA_SUCCESS; --} -- --/** \brief HAL implementation of kit protocol send over USB HID -- * \param[in] iface instance -- * \param[in] txdata pointer to bytes to send -- * \param[in] txlength number of bytes to send -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_hid_send(ATCAIface iface, uint8_t* txdata, int txlength) --{ -- // Call the kit_send() function that will call phy_send() implemented below -- return kit_send(iface, txdata, txlength); --} -- --/** \brief HAL implementation of send over USB HID -- * \param[in] iface instance -- * \param[in] rxdata pointer to space to receive the data -- * \param[inout] rxsize ptr to expected number of receive bytes to request -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_hid_receive(ATCAIface iface, uint8_t* rxdata, uint16_t* rxsize) --{ -- // Call the kit_receive() function that will call phy_receive() implemented below -- return kit_receive(iface, rxdata, rxsize); --} -- --/** \brief Call the wake for kit protocol over USB HID -- * \param[in] iface ATCAIface instance that is the interface object to send the bytes over -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_hid_wake(ATCAIface iface) --{ -- // Call the kit_wake() function that will call phy_send() and phy_receive() -- return kit_wake(iface); --} -- --/** \brief Call the idle for kit protocol over USB HID -- * \param[in] iface ATCAIface instance that is the interface object to send the bytes over -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_hid_idle(ATCAIface iface) --{ -- // Call the kit_idle() function that will call phy_send() and phy_receive() -- return kit_idle(iface); --} -- --/** \brief Call the sleep for kit protocol over USB HID -- * \param[in] iface ATCAIface instance that is the interface object to send the bytes over -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_hid_sleep(ATCAIface iface) --{ -- // Call the kit_sleep() function that will call phy_send() and phy_receive() -- return kit_sleep(iface); --} -- --/** \brief Close the physical port for HID -- * \param[in] hal_data The hardware abstraction data specific to this HAL -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_kit_hid_release(void* hal_data) --{ -- int i = 0; -- atcahid_t* phaldat = (atcahid_t*)hal_data; -- -- if ((hal_data == NULL)) -- { -- return ATCA_BAD_PARAM; -- } -- -- // Close all kit USB devices -- for (i = 0; i < phaldat->num_kits_found; i++) -- { -- if (phaldat->kits[i].read_handle != INVALID_HANDLE_VALUE) -- { -- CloseHandle(phaldat->kits[i].read_handle); -- phaldat->kits[i].read_handle = INVALID_HANDLE_VALUE; -- } -- -- if (phaldat->kits[i].write_handle != INVALID_HANDLE_VALUE) -- { -- CloseHandle(phaldat->kits[i].write_handle); -- phaldat->kits[i].write_handle = INVALID_HANDLE_VALUE; -- } -- } -- return ATCA_SUCCESS; --} -- --/** @} */ -diff --git a/lib/hal/hal_win_kit_hid.h b/lib/hal/hal_win_kit_hid.h -deleted file mode 100644 -index e3523272d33a..000000000000 ---- a/lib/hal/hal_win_kit_hid.h -+++ /dev/null -@@ -1,64 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for Windows using kit protocol over a USB HID device. -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef HAL_WIN_KIT_HID_H_ --#define HAL_WIN_KIT_HID_H_ -- --#include -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- --// Kit USB defines --#define HID_DEVICES_MAX 10 //! Maximum number of supported Kit USB devices --#define HID_PACKET_MAX 512 //! Maximum number of bytes for a HID send/receive packet (typically 64) -- --// Each device that is found will have a read handle and a write handle --typedef struct hid_device --{ -- HANDLE read_handle; //! The kit USB read file handle -- HANDLE write_handle; //! The kit USB write file handle --} hid_device_t; -- -- --// A structure to hold HID information --typedef struct atcahid --{ -- hid_device_t kits[HID_DEVICES_MAX]; -- int8_t num_kits_found; --} atcahid_t; -- --/** @} */ --#endif /* HAL_WIN_KIT_HID_H_ */ -\ No newline at end of file -diff --git a/lib/hal/hal_win_timer.c b/lib/hal/hal_win_timer.c -deleted file mode 100644 -index 71c431b4354b..000000000000 ---- a/lib/hal/hal_win_timer.c -+++ /dev/null -@@ -1,86 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for windows timer functions. -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include "atca_hal.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- -- --/** \brief This function delays for a number of microseconds. -- * -- * \param[in] delay number of microseconds to delay -- */ --void atca_delay_us(uint32_t delay) --{ -- // divide by 1000 to convert us to ms -- // todo: use a timer with us accuracy -- long ms = (long)(delay / 1.0e3 + 0.5); // Miliseconds -- -- // use Windows supplied delay -- Sleep(delay); --} -- --/** \brief This function delays for a number of tens of microseconds. -- * -- * \param[in] delay number of 0.01 milliseconds to delay -- */ --void atca_delay_10us(uint32_t delay) --{ -- // divide by 100 to convert 10's of us to ms -- // todo: use a timer with us accuracy -- long ms = (long)(delay / 1.0e2 + 0.5); // Miliseconds -- -- // use Windows supplied delay -- Sleep(delay); --} -- --/** \brief This function delays for a number of milliseconds. -- * -- * You can override this function if you like to do -- * something else in your system while delaying. -- * \param[in] delay number of milliseconds to delay -- */ -- --/* ASF already has delay_ms - see delay.h */ --void atca_delay_ms(uint32_t delay) --{ -- // use Windows supplied delay -- Sleep(delay); --} -- --/** @} */ -diff --git a/lib/hal/hal_xmega_a3bu_i2c_asf.c b/lib/hal/hal_xmega_a3bu_i2c_asf.c -deleted file mode 100644 -index 2d8fa71c9b21..000000000000 ---- a/lib/hal/hal_xmega_a3bu_i2c_asf.c -+++ /dev/null -@@ -1,520 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for XMEGA-A3BU I2C over ASF drivers. -- * -- * Prerequisite: add I2C Master Polled support to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include --#include "atca_hal.h" --#include "hal_xmega_a3bu_i2c_asf.h" --#include "atca_device.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * using I2C driver of ASF. -- * -- @{ */ -- --/** \brief logical to physical bus mapping structure */ --ATCAI2CMaster_t *i2c_hal_data[MAX_I2C_BUSES]; // map logical, 0-based bus number to index --int i2c_bus_ref_ct = 0; // total in-use count across buses --static twi_master_options_t config_i2c_master; -- -- --/** \brief discover i2c buses available for this hardware -- * this maintains a list of logical to physical bus mappings freeing the application -- * of the a-priori knowledge -- * \param[in] i2c_buses - an array of logical bus numbers -- * \param[in] max_buses - maximum number of buses the app wants to attempt to discover -- * \return ATCA_SUCCESS -- */ -- --ATCA_STATUS hal_i2c_discover_buses(int i2c_buses[], int max_buses) --{ -- -- /* if every PORT was a likely candidate bus, then would need to initialize the entire array to all PORT n numbers. -- * As an optimization and making discovery safer, make assumptions about bus-num / PORT map based on XMEGA-A3BU Xplained Pro board -- * If you were using a raw XMEGA on your own board, you would supply your own bus numbers based on your particular hardware configuration. -- */ -- i2c_buses[0] = 2; // default xmega-a3bu for xplained dev board -- -- return ATCA_SUCCESS; --} -- --/** \brief discover any CryptoAuth devices on a given logical bus number -- * \param[in] busNum - logical bus number on which to look for CryptoAuth devices -- * \param[out] cfg[] - pointer to head of an array of interface config structures which get filled in by this method -- * \param[out] *found - number of devices found on this bus -- * \return ATCA_SUCCESS -- */ -- --ATCA_STATUS hal_i2c_discover_devices(int busNum, ATCAIfaceCfg cfg[], int *found) --{ -- ATCAIfaceCfg *head = cfg; -- uint8_t slaveAddress = 0x01; -- ATCADevice device; -- ATCAIface discoverIface; -- ATCACommand command; -- ATCAPacket packet; -- ATCA_STATUS status; -- uint8_t revs508[1][4] = { { 0x00, 0x00, 0x50, 0x00 } }; -- uint8_t revs108[1][4] = { { 0x80, 0x00, 0x10, 0x01 } }; -- uint8_t revs204[3][4] = { { 0x00, 0x02, 0x00, 0x08 }, -- { 0x00, 0x02, 0x00, 0x09 }, -- { 0x00, 0x04, 0x05, 0x00 } }; -- int i; -- -- /** \brief default configuration, to be reused during discovery process */ -- ATCAIfaceCfg discoverCfg = { -- .iface_type = ATCA_I2C_IFACE, -- .devtype = ATECC508A, -- .atcai2c.slave_address = 0x07, -- .atcai2c.bus = busNum, -- .atcai2c.baud = 400000, -- //.atcai2c.baud = 100000, -- .wake_delay = 800, -- .rx_retries = 3 -- }; -- -- // build an info command -- packet.param1 = INFO_MODE_REVISION; -- packet.param2 = 0; -- -- device = newATCADevice(&discoverCfg); -- discoverIface = atGetIFace(device); -- command = atGetCommands(device); -- -- // iterate through all addresses on given i2c bus -- // all valid 7-bit addresses go from 0x07 to 0x78 -- for (slaveAddress = 0x07; slaveAddress <= 0x78; slaveAddress++) -- { -- discoverCfg.atcai2c.slave_address = slaveAddress << 1; // turn it into an 8-bit address which is what the rest of the i2c HAL is expecting when a packet is sent -- -- // wake up device -- // If it wakes, send it a dev rev command. Based on that response, determine the device type -- // BTW - this will wake every cryptoauth device living on the same bus (ecc508a, sha204a) -- -- if (hal_i2c_wake(discoverIface) == ATCA_SUCCESS) -- { -- (*found)++; -- memcpy( (uint8_t*)head, (uint8_t*)&discoverCfg, sizeof(ATCAIfaceCfg)); -- -- memset(packet.data, 0x00, sizeof(packet.data)); -- -- // get devrev info and set device type accordingly -- atInfo(command, &packet); -- if ((status = atGetExecTime(packet.opcode, command)) != ATCA_SUCCESS) -- { -- continue; -- } -- -- // send the command -- if ( (status = atsend(discoverIface, (uint8_t*)&packet, packet.txsize)) != ATCA_SUCCESS) -- { -- printf("packet send error\r\n"); -- continue; -- } -- -- // delay the appropriate amount of time for command to execute -- atca_delay_ms((command->execution_time_msec) + 1); -- -- // receive the response -- if ( (status = atreceive(discoverIface, &(packet.data[0]), &(packet.rxsize) )) != ATCA_SUCCESS) -- { -- continue; -- } -- -- if ( (status = isATCAError(packet.data)) != ATCA_SUCCESS) -- { -- printf("command response error\r\n"); -- continue; -- } -- -- // determine device type from common info and dev rev response byte strings -- for (i = 0; i < sizeof(revs508) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs508[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC508A; -- break; -- } -- } -- -- for (i = 0; i < sizeof(revs204) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs204[i], 4) == 0) -- { -- discoverCfg.devtype = ATSHA204A; -- break; -- } -- } -- -- for (i = 0; i < sizeof(revs108) / 4; i++) -- { -- if (memcmp(&packet.data[1], &revs108[i], 4) == 0) -- { -- discoverCfg.devtype = ATECC108A; -- break; -- } -- } -- -- atca_delay_ms(15); -- // now the device type is known, so update the caller's cfg array element with it -- head->devtype = discoverCfg.devtype; -- head++; -- } -- -- hal_i2c_idle(discoverIface); -- } -- -- deleteATCADevice(&device); -- -- return ATCA_SUCCESS; --} -- -- --/** \brief -- - this HAL implementation assumes you've included the ASF I2C libraries in your project, otherwise, -- the HAL layer will not compile because the ASF I2C drivers are a dependency * -- */ -- --/** \brief hal_i2c_init manages requests to initialize a physical interface. it manages use counts so when an interface -- * has released the physical layer, it will disable the interface for some other use. -- * You can have multiple ATCAIFace instances using the same bus, and you can have multiple ATCAIFace instances on -- * multiple i2c buses, so hal_i2c_init manages these things and ATCAIFace is abstracted from the physical details. -- */ -- --/** \brief initialize an I2C interface using given config -- * \param[in] hal - opaque ptr to HAL data -- * \param[in] cfg - interface configuration -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS hal_i2c_init(void *hal, ATCAIfaceCfg *cfg) --{ -- int bus = cfg->atcai2c.bus; // 0-based logical bus number -- ATCAHAL_t *phal = (ATCAHAL_t*)hal; -- -- if (i2c_bus_ref_ct == 0) // power up state, no i2c buses will have been used -- { -- for (int i = 0; i < MAX_I2C_BUSES; i++) -- { -- i2c_hal_data[i] = NULL; -- } -- } -- -- i2c_bus_ref_ct++; // total across buses -- -- if (bus >= 0 && bus < MAX_I2C_BUSES) -- { -- // if this is the first time this bus and interface has been created, do the physical work of enabling it -- if (i2c_hal_data[bus] == NULL) -- { -- i2c_hal_data[bus] = malloc(sizeof(ATCAI2CMaster_t) ); -- i2c_hal_data[bus]->ref_ct = 1; // buses are shared, this is the first instance -- -- config_i2c_master.speed = cfg->atcai2c.baud; -- config_i2c_master.chip = 0x50; -- config_i2c_master.speed_reg = TWI_BAUD(sysclk_get_cpu_hz(), cfg->atcai2c.baud); -- switch (bus) -- { -- case 0: i2c_hal_data[bus]->i2c_master_instance = &TWIC; break; -- //case 1: i2c_hal_data[bus]->i2c_master_instance = &TWID; break; // for XMEGA-A1 -- case 2: i2c_hal_data[bus]->i2c_master_instance = &TWIE; break; -- //case 3: i2c_hal_data[bus]->i2c_master_instance = &TWIF; break; // for XMEGA-A1 -- } -- -- twi_master_setup((i2c_hal_data[bus]->i2c_master_instance), &config_i2c_master); -- // store this for use during the release phase -- i2c_hal_data[bus]->bus_index = bus; -- twi_master_enable(i2c_hal_data[bus]->i2c_master_instance); -- } -- else -- { -- // otherwise, another interface already initialized the bus, so this interface will share it and any different -- // cfg parameters will be ignored...first one to initialize this sets the configuration -- i2c_hal_data[bus]->ref_ct++; -- } -- -- phal->hal_data = i2c_hal_data[bus]; -- -- return ATCA_SUCCESS; -- } -- -- return ATCA_COMM_FAIL; --} -- --/** \brief HAL implementation of I2C post init -- * \param[in] iface instance -- * \return ATCA_SUCCESS -- */ --ATCA_STATUS hal_i2c_post_init(ATCAIface iface) --{ -- return ATCA_SUCCESS; --} -- --/** \brief HAL implementation of I2C send over ASF -- * \param[in] iface instance -- * \param[in] txdata pointer to space to bytes to send -- * \param[in] txlength number of bytes to send -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_send(ATCAIface iface, uint8_t *txdata, int txlength) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- -- twi_package_t packet = { -- .addr_length = 0, // TWI slave memory address data size -- .chip = cfg->atcai2c.slave_address >> 1, // TWI slave bus address -- .buffer = txdata, // transfer data source buffer -- .length = txlength, // transfer data size (bytes) -- }; -- -- // for this implementation of I2C with CryptoAuth chips, txdata is assumed to have ATCAPacket format -- -- // other device types that don't require i/o tokens on the front end of a command need a different hal_i2c_send and wire it up instead of this one -- // this covers devices such as ATSHA204A and ATECCx08A that require a word address value pre-pended to the packet -- // txdata[0] is using _reserved byte of the ATCAPacket -- txdata[0] = 0x03; // insert the Word Address Value, Command token -- txlength++; // account for word address value byte. -- packet.length = txlength; -- -- if (twi_master_write(i2c_hal_data[bus]->i2c_master_instance, &packet) != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** \brief HAL implementation of I2C receive function for ASF I2C -- * \param[in] iface instance -- * \param[out] rxdata pointer to space to receive the data -- * \param[in] rxlength ptr to expected number of receive bytes to request -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_receive(ATCAIface iface, uint8_t *rxdata, uint16_t *rxlength) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- int retries = cfg->rx_retries; -- int status = !STATUS_OK; -- -- twi_package_t packet = { -- .addr_length = 0, // TWI slave memory address data size -- .chip = cfg->atcai2c.slave_address >> 1, // TWI slave bus address -- .buffer = rxdata, // transfer data source buffer -- .length = *rxlength, // transfer data size (bytes) -- }; -- -- while (retries-- > 0 && status != STATUS_OK) -- { -- status = twi_master_read(i2c_hal_data[bus]->i2c_master_instance, &packet); -- } -- -- if (status != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** \brief method to change the bus speec of I2C -- * \param[in] iface interface on which to change bus speed -- * \param[in] speed baud rate (typically 100000 or 400000) -- */ -- --void change_i2c_speed(ATCAIface iface, uint32_t speed) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- -- config_i2c_master.speed = speed; -- config_i2c_master.speed_reg = TWI_BAUD(sysclk_get_cpu_hz(), speed); -- -- twi_master_disable(i2c_hal_data[bus]->i2c_master_instance); -- -- switch (bus) -- { -- case 0: i2c_hal_data[bus]->i2c_master_instance = &TWIC; break; -- case 2: i2c_hal_data[bus]->i2c_master_instance = &TWIE; break; -- } -- -- twi_master_setup((i2c_hal_data[bus]->i2c_master_instance), &config_i2c_master); -- -- twi_master_enable(i2c_hal_data[bus]->i2c_master_instance); --} -- --/** \brief wake up CryptoAuth device using I2C bus -- * \param[in] iface interface to logical device to wakeup -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_wake(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- int retries = cfg->rx_retries; -- uint32_t bdrt = cfg->atcai2c.baud; -- int status = !STATUS_OK; -- uint8_t data[4], expected[4] = { 0x04, 0x11, 0x33, 0x43 }; -- -- if (bdrt != 100000) // if not already at 100KHz, change it -- { -- change_i2c_speed(iface, 100000); -- } -- -- // Send the wake by writing to an address of 0x00 -- twi_package_t packet = { -- .addr_length = 0, // TWI slave memory address data size -- .chip = 0x00, // TWI slave bus address -- .buffer = &data[0], // transfer data source buffer -- .length = 0 // transfer data size (bytes) -- }; -- -- -- // Send the 00 address as the wake pulse -- twi_master_write(i2c_hal_data[bus]->i2c_master_instance, &packet); // part will NACK, so don't check for status -- -- atca_delay_us(cfg->wake_delay); // wait tWHI + tWLO which is configured based on device type and configuration structure -- -- packet.chip = cfg->atcai2c.slave_address >> 1; -- packet.length = 4; -- packet.buffer = data; -- -- while (retries-- > 0 && status != STATUS_OK) -- { -- status = twi_master_read(i2c_hal_data[bus]->i2c_master_instance, &packet); -- } -- -- if (status != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- // if necessary, revert baud rate to what came in. -- if (bdrt != 100000) -- { -- change_i2c_speed(iface, bdrt); -- } -- -- if (memcmp(data, expected, 4) == 0) -- { -- return ATCA_SUCCESS; -- } -- -- return ATCA_COMM_FAIL; --} -- --/** \brief idle CryptoAuth device using I2C bus -- * \param[in] iface interface to logical device to idle -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_idle(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- uint8_t data[4]; -- -- twi_package_t packet = { -- .addr_length = 0, // TWI slave memory address data size -- .chip = cfg->atcai2c.slave_address >> 1, // TWI slave bus address -- .buffer = &data[0], // transfer data source buffer -- .length = 1 // transfer data size (bytes) -- }; -- -- data[0] = 0x02; // idle word address value -- if (twi_master_write((i2c_hal_data[bus]->i2c_master_instance), &packet) != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; -- --} -- --/** \brief sleep CryptoAuth device using I2C bus -- * \param[in] iface interface to logical device to sleep -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_sleep(ATCAIface iface) --{ -- ATCAIfaceCfg *cfg = atgetifacecfg(iface); -- int bus = cfg->atcai2c.bus; -- uint8_t data[4]; -- -- twi_package_t packet = { -- .addr_length = 0, // TWI slave memory address data size -- .chip = cfg->atcai2c.slave_address >> 1, // TWI slave bus address -- .buffer = &data[0], // transfer data source buffer -- .length = 1 // transfer data size (bytes) -- }; -- -- data[0] = 0x01; // sleep word address value -- if (twi_master_write((i2c_hal_data[bus]->i2c_master_instance), &packet) != STATUS_OK) -- { -- return ATCA_COMM_FAIL; -- } -- -- return ATCA_SUCCESS; --} -- --/** \brief manages reference count on given bus and releases resource if no more refences exist -- * \param[in] hal_data - opaque pointer to hal data structure - known only to the HAL implementation -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ -- --ATCA_STATUS hal_i2c_release(void *hal_data) --{ -- ATCAI2CMaster_t *hal = (ATCAI2CMaster_t*)hal_data; -- -- i2c_bus_ref_ct--; // track total i2c bus interface instances for consistency checking and debugging -- -- // if the use count for this bus has gone to 0 references, disable it. protect against an unbracketed release -- if (hal && --(hal->ref_ct) <= 0 && i2c_hal_data[hal->bus_index] != NULL) -- { -- twi_master_disable(hal->i2c_master_instance); -- free(i2c_hal_data[hal->bus_index]); -- i2c_hal_data[hal->bus_index] = NULL; -- } -- -- return ATCA_SUCCESS; --} -- --/** @} */ -diff --git a/lib/hal/hal_xmega_a3bu_i2c_asf.h b/lib/hal/hal_xmega_a3bu_i2c_asf.h -deleted file mode 100644 -index 4617c739245d..000000000000 ---- a/lib/hal/hal_xmega_a3bu_i2c_asf.h -+++ /dev/null -@@ -1,64 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for XMEGA-A3BU I2C over ASF drivers. -- * -- * Prerequisite: add I2C Master Polled support to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef HAL_XMEGA_A3BU_I2C_ASF_H_ --#define HAL_XMEGA_A3BU_I2C_ASF_H_ -- --#include --#include "twi_master.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * using I2C driver of ASF. -- * -- @{ */ -- -- --#define MAX_I2C_BUSES 4 // XMEGA A3BU has up to 4 PORT that can be configured as I2C -- --/** \brief this is the hal_data for ATCA HAL created using ASF -- */ --typedef struct atcaI2Cmaster --{ -- twi_master_t i2c_master_instance; -- int ref_ct; -- // for conveniences during interface release phase -- int bus_index; --} ATCAI2CMaster_t; -- --void change_i2c_speed(ATCAIface iface, uint32_t speed); -- --/** @} */ --#endif /* HAL_XMEGA_A3BU_I2C_ASF_H_ */ -\ No newline at end of file -diff --git a/lib/hal/hal_xmega_a3bu_timer_asf.c b/lib/hal/hal_xmega_a3bu_timer_asf.c -deleted file mode 100644 -index e2f4a4337e03..000000000000 ---- a/lib/hal/hal_xmega_a3bu_timer_asf.c -+++ /dev/null -@@ -1,78 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer for SAMD21 timer/delay over ASF drivers. -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include "atca_hal.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- --/** \brief This function delays for a number of microseconds. -- * -- * \param[in] delay number of 0.001 milliseconds to delay -- */ --void atca_delay_us(uint32_t delay) --{ -- // use ASF supplied delay -- delay_us(delay); --} -- --/** \brief This function delays for a number of tens of microseconds. -- * -- * \param[in] delay number of 0.01 milliseconds to delay -- */ --void atca_delay_10us(uint32_t delay) --{ -- // use ASF supplied delay -- delay_us(delay * 10); -- --} -- --/** \brief This function delays for a number of milliseconds. -- * -- * You can override this function if you like to do -- * something else in your system while delaying. -- * \param[in] delay number of milliseconds to delay -- */ -- --/* ASF already has delay_ms - see delay.h */ --void atca_delay_ms(uint32_t delay) --{ -- // use ASF supplied delay -- delay_ms(delay); --} -- --/** @} */ -diff --git a/lib/hal/i2c_bitbang_samd21.c b/lib/hal/i2c_bitbang_samd21.c -deleted file mode 100644 -index 0cdac42912b9..000000000000 ---- a/lib/hal/i2c_bitbang_samd21.c -+++ /dev/null -@@ -1,262 +0,0 @@ --/** -- * \file -- * \brief Hardware Interface Functions - I2C bit-bang for SAMd21 -- * \author Atmel Crypto Group -- * \date November 18, 2015 -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include "i2c_bitbang_samd21.h" --#define DEFAULT_I2C_BUS 2 -- -- --I2CBuses i2c_buses_default = { -- { EXT3_PIN_3, EXT3_PIN_9, EXT3_PIN_I2C_SDA, EXT3_PIN_13, EXT2_PIN_3, EXT2_PIN_5, EXT2_PIN_7, EXT2_PIN_9, EXT2_PIN_13, EXT2_PIN_15, EXT2_PIN_17, EXT1_PIN_3, EXT1_PIN_5, EXT1_PIN_7, EXT1_PIN_9, EXT1_PIN_13, EXT1_PIN_15, EXT1_PIN_17 }, -- { EXT3_PIN_7, EXT3_PIN_10, EXT3_PIN_I2C_SCL, EXT3_PIN_14, EXT2_PIN_4, EXT2_PIN_6, EXT2_PIN_8, EXT2_PIN_10, EXT2_PIN_14, EXT2_PIN_16, EXT2_PIN_18, EXT1_PIN_4, EXT1_PIN_6, EXT1_PIN_8, EXT1_PIN_10, EXT1_PIN_14, EXT1_PIN_16, EXT1_PIN_18 } --}; -- --uint8_t pin_sda, pin_scl; -- --void i2c_discover_buses(int i2c_bitbang_buses[], int max_buses) --{ -- -- i2c_bitbang_buses[0] = DEFAULT_I2C_BUS; -- --} -- --void i2c_set_pin(uint8_t sda, uint8_t scl) --{ -- pin_sda = sda; -- pin_scl = scl; --} -- --void i2c_enable(void) --{ -- I2C_ENABLE(); -- I2C_DATA_HIGH(); -- I2C_CLOCK_HIGH(); --} -- --void i2c_disable(void) --{ -- I2C_DISABLE(); --} -- -- --void i2c_send_start(void) --{ -- //! Set clock high in case we re-start. -- I2C_CLOCK_HIGH(); -- I2C_SET_OUTPUT_HIGH(); -- I2C_DATA_LOW(); -- I2C_HOLD_DELAY(); -- I2C_CLOCK_LOW(); --} -- --void i2c_send_ack(uint8_t ack) --{ -- if (ack) -- { -- I2C_SET_OUTPUT_LOW(); //!< Low data line indicates an ACK. -- while (I2C_DATA_IN()) -- { -- ; -- } -- } -- else -- { -- I2C_SET_OUTPUT_HIGH(); //!< High data line indicates a NACK. -- while (!I2C_DATA_IN()) -- { -- ; -- } -- } -- -- //! Clock out acknowledgment. -- I2C_CLOCK_HIGH(); -- I2C_CLOCK_DELAY_SEND_ACK(); -- I2C_CLOCK_LOW(); --} -- --void i2c_send_stop(void) --{ -- I2C_SET_OUTPUT_LOW(); -- I2C_CLOCK_DELAY_WRITE_LOW(); -- I2C_CLOCK_HIGH(); -- I2C_HOLD_DELAY(); -- I2C_DATA_HIGH(); --} -- -- --void i2c_send_wake_token(void) --{ -- I2C_DATA_LOW(); -- delay_us(80); -- I2C_DATA_HIGH(); --} -- --ATCA_STATUS i2c_send_byte(uint8_t i2c_byte) --{ -- ATCA_STATUS status = ATCA_TX_TIMEOUT; -- -- uint8_t i; -- -- DISABLE_INTERRUPT(); -- -- //! This avoids spikes but adds an if condition. -- //! We could parametrize the call to I2C_SET_OUTPUT -- //! and translate the msb to OUTSET or OUTCLR, -- //! but then the code would become target specific. -- if (i2c_byte & 0x80) -- { -- I2C_SET_OUTPUT_HIGH(); -- } -- else -- { -- I2C_SET_OUTPUT_LOW(); -- } -- -- //! Send 8 bits of data. -- for (i = 0; i < 8; i++) -- { -- I2C_CLOCK_LOW(); -- if (i2c_byte & 0x80) -- { -- I2C_DATA_HIGH(); -- } -- else -- { -- I2C_DATA_LOW(); -- } -- I2C_CLOCK_DELAY_WRITE_LOW(); -- -- //! Clock out the data bit. -- I2C_CLOCK_HIGH(); -- -- //! Shifting while clock is high compensates for the time it -- //! takes to evaluate the bit while clock is low. -- //! That way, the low and high time of the clock pin is -- //! almost equal. -- i2c_byte <<= 1; -- I2C_CLOCK_DELAY_WRITE_HIGH(); -- } -- //! Clock in last data bit. -- I2C_CLOCK_LOW(); -- -- //! Set data line to be an input. -- I2C_SET_INPUT(); -- -- I2C_CLOCK_DELAY_READ_LOW(); -- //! Wait for the ack. -- I2C_CLOCK_HIGH(); -- for (i = 0; i < I2C_ACK_TIMEOUT; i++) -- { -- if (!I2C_DATA_IN()) -- { -- status = ATCA_SUCCESS; -- I2C_CLOCK_DELAY_READ_HIGH(); -- break; -- } -- } -- I2C_CLOCK_LOW(); -- -- ENABLE_INTERRUPT(); -- -- return status; --} -- --ATCA_STATUS i2c_send_bytes(uint8_t count, uint8_t *data) --{ -- ATCA_STATUS status = ATCA_TX_TIMEOUT; -- -- uint8_t i; -- -- for (i = 0; i < count; i++) -- { -- status = i2c_send_byte(data[i]); -- if (status != ATCA_SUCCESS) -- { -- if (i > 0) -- { -- status = ATCA_TX_FAIL; -- } -- break; -- } -- } -- -- return status; --} -- --uint8_t i2c_receive_one_byte(uint8_t ack) --{ -- uint8_t i2c_byte; -- uint8_t i; -- -- DISABLE_INTERRUPT(); -- -- I2C_SET_INPUT(); -- for (i = 0x80, i2c_byte = 0; i; i >>= 1) -- { -- I2C_CLOCK_HIGH(); -- I2C_CLOCK_DELAY_READ_HIGH(); -- if (I2C_DATA_IN()) -- { -- i2c_byte |= i; -- } -- I2C_CLOCK_LOW(); -- if (i > 1) -- { -- //! We don't need to delay after the last bit because -- //! it takes time to switch the pin to output for acknowledging. -- I2C_CLOCK_DELAY_READ_LOW(); -- } -- } -- i2c_send_ack(ack); -- -- ENABLE_INTERRUPT(); -- -- return i2c_byte; --} -- --void i2c_receive_byte(uint8_t *data) --{ -- *data = i2c_receive_one_byte(1); --} -- --void i2c_receive_bytes(uint8_t count, uint8_t *data) --{ -- while (--count) -- { -- *data++ = i2c_receive_one_byte(1); -- } -- *data = i2c_receive_one_byte(0); -- -- i2c_send_stop(); --} -\ No newline at end of file -diff --git a/lib/hal/i2c_bitbang_samd21.h b/lib/hal/i2c_bitbang_samd21.h -deleted file mode 100644 -index 00fc7977e305..000000000000 ---- a/lib/hal/i2c_bitbang_samd21.h -+++ /dev/null -@@ -1,195 +0,0 @@ --/** -- * \file -- * \brief definitions for bit-banged I2C -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef I2C_BITBANG_SAMD21_H_ --#define I2C_BITBANG_SAMD21_H_ -- --#include "atca_status.h" --#include -- -- --#define MAX_I2C_BUSES 18 //The MAX_I2C_BUSES is the number of free pins in samd21 xplained pro -- -- --typedef struct --{ -- uint8_t pin_sda[MAX_I2C_BUSES]; -- uint8_t pin_scl[MAX_I2C_BUSES]; --} I2CBuses; -- --extern I2CBuses i2c_buses_default; -- --extern uint8_t pin_sda; --extern uint8_t pin_scl; -- --# define I2C_ENABLE() { struct port_config pin_conf; \ -- port_get_config_defaults(&pin_conf); \ -- pin_conf.direction = PORT_PIN_DIR_OUTPUT_WTH_READBACK; \ -- port_pin_set_config(pin_sda, &pin_conf); \ -- pin_conf.direction = PORT_PIN_DIR_OUTPUT; \ -- port_pin_set_config(pin_scl, &pin_conf); } --# define I2C_DISABLE() { struct port_config pin_conf; \ -- port_get_config_defaults(&pin_conf); \ -- pin_conf.direction = PORT_PIN_DIR_INPUT; \ -- pin_conf.input_pull = PORT_PIN_PULL_UP; \ -- port_pin_set_config(pin_sda, &pin_conf); \ -- port_pin_set_config(pin_scl, &pin_conf); } --# define I2C_CLOCK_LOW() port_pin_set_output_level(pin_scl, false) --# define I2C_CLOCK_HIGH() port_pin_set_output_level(pin_scl, true) --# define I2C_DATA_LOW() port_pin_set_output_level(pin_sda, false) --# define I2C_DATA_HIGH() port_pin_set_output_level(pin_sda, true) --# define I2C_DATA_IN() port_pin_get_input_level(pin_sda) --# define I2C_SET_OUTPUT() { struct port_config pin_conf; \ -- port_get_config_defaults(&pin_conf); \ -- pin_conf.direction = PORT_PIN_DIR_OUTPUT_WTH_READBACK; \ -- port_pin_set_config(pin_sda, &pin_conf); } --# define I2C_SET_OUTPUT_HIGH() { I2C_SET_OUTPUT(); I2C_DATA_HIGH(); } --# define I2C_SET_OUTPUT_LOW() { I2C_SET_OUTPUT(); I2C_DATA_LOW(); } --# define I2C_SET_INPUT() { struct port_config pin_conf; \ -- port_get_config_defaults(&pin_conf); \ -- pin_conf.direction = PORT_PIN_DIR_INPUT; \ -- port_pin_set_config(pin_sda, &pin_conf); } --# define DISABLE_INTERRUPT() cpu_irq_disable() --# define ENABLE_INTERRUPT() cpu_irq_enable() -- -- --#define I2C_CLOCK_DELAY_WRITE_LOW() delay_us(1) --#define I2C_CLOCK_DELAY_WRITE_HIGH() delay_us(1) --#define I2C_CLOCK_DELAY_READ_LOW() delay_us(1) --#define I2C_CLOCK_DELAY_READ_HIGH() delay_us(1) --#define I2C_CLOCK_DELAY_SEND_ACK() delay_us(1) --//! This delay is inserted to make the Start and Stop hold time at least 250 ns. --#define I2C_HOLD_DELAY() delay_us(1) -- -- -- -- --//! loop count when waiting for an acknowledgment --#define I2C_ACK_TIMEOUT (4) -- -- --/** -- * \brief Set I2C data and clock pin. -- * Other functions will use these pins. -- * -- * \param[in] sda definition of GPIO pin to be used as data pin -- * \param[in] scl definition of GPIO pin to be used as clock pin -- */ --void i2c_set_pin(uint8_t sda, uint8_t scl); -- -- --/** -- * \brief Assigns the logical bus number for discovering the devices -- * -- * -- * \param[in] i2c_bitbang_buses The logical bus numbers are assigned to the variables. -- * \param[in] max_buses Maximum number of bus used for discovering. -- */ -- --void i2c_discover_buses(int i2c_bitbang_buses[], int max_buses); -- --/** -- * \brief Configure GPIO pins for I2C clock and data as output. -- */ --void i2c_enable(void); -- --/** -- * \brief Configure GPIO pins for I2C clock and data as input. -- */ --void i2c_disable(void); -- -- --/** -- * \brief Send a START condition. -- */ --void i2c_send_start(void); -- --/** -- * \brief Send an ACK or NACK (after receive). -- * -- * \param[in] ack 0: NACK, else: ACK -- */ --void i2c_send_ack(uint8_t ack); -- --/** -- * \brief Send a STOP condition. -- */ --void i2c_send_stop(void); -- --/** -- * \brief Send a Wake Token. -- */ --void i2c_send_wake_token(void); -- --/** -- * \brief Send one byte. -- * -- * \param[in] i2c_byte byte to write -- * -- * \return ATCA_STATUS -- */ --ATCA_STATUS i2c_send_byte(uint8_t i2c_byte); -- --/** -- * \brief Send a number of bytes. -- * -- * \param[in] count number of bytes to send -- * \param[in] data pointer to buffer containing bytes to send -- * -- * \return ATCA_STATUS -- */ --ATCA_STATUS i2c_send_bytes(uint8_t count, uint8_t *data); -- --/** -- * \brief Receive one byte (MSB first). -- * -- * \param[in] ack 0:NACK, else:ACK -- * -- * \return Number of bytes received -- */ --uint8_t i2c_receive_one_byte(uint8_t ack); -- --/** -- * \brief Receive one byte and send ACK. -- * -- * \param[out] data pointer to received byte -- */ --void i2c_receive_byte(uint8_t *data); -- --/** -- * \brief Receive a number of bytes. -- * -- * \param[out] data pointer to receive buffer -- * \param[in] count number of bytes to receive -- */ --void i2c_receive_bytes(uint8_t count, uint8_t *data); -- --#endif /* I2C_BITBANG_SAMD21_H_ */ -\ No newline at end of file -diff --git a/lib/hal/kit_phy.h b/lib/hal/kit_phy.h -deleted file mode 100644 -index f0b6ecd35f90..000000000000 ---- a/lib/hal/kit_phy.h -+++ /dev/null -@@ -1,62 +0,0 @@ --/** -- * \file -- * \brief ATCA Hardware abstraction layer physical send & receive function definitions. -- * -- * This is included for kit protocol implementations. -- * It is included in the kit protocol callback to actually send and recieve bytes. -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef KIT_PHY_H_ --#define KIT_PHY_H_ -- --#include "cryptoauthlib.h" -- -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- --#ifdef __cplusplus --extern "C" { --#endif -- --ATCA_STATUS kit_phy_num_found(int8_t* num_found); --ATCA_STATUS kit_phy_send(ATCAIface iface, const char *txdata, int txlength); --ATCA_STATUS kit_phy_receive(ATCAIface iface, char* rxdata, int* rxlength); -- --#ifdef __cplusplus --} --#endif -- --/** @} */ -- --#endif /* ATCA_HAL_PHY_H_ */ -diff --git a/lib/hal/kit_protocol.c b/lib/hal/kit_protocol.c -deleted file mode 100644 -index 55f8708d1d94..000000000000 ---- a/lib/hal/kit_protocol.c -+++ /dev/null -@@ -1,430 +0,0 @@ --/** -- * \file -- * -- * \brief Microchip Crypto Auth hardware interface object -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include "kit_phy.h" --#include "kit_protocol.h" --#include "basic/atca_helpers.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- -- -- --/** \brief HAL implementation of kit protocol init. This function calls back to the physical protocol to send the bytes -- * \param[in] iface instance -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS kit_init(ATCAIface iface) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- uint8_t kitstatus = 0; -- char address[] = "board:device(00)\n"; -- int addresssize = sizeof(address); -- char reply[KIT_RX_WRAP_SIZE + 4]; -- int replysize = sizeof(reply); -- uint8_t rxdata[2]; -- int rxsize = sizeof(rxdata); -- char selectaddress[KIT_MSG_SIZE]; -- int selectaddresssize = sizeof(selectaddress); -- char selectaddresspre[] = "s:physical:select("; -- char selectaddresspost[] = ")\n"; -- int copysize = 0; -- -- // Send the address bytes -- status = kit_phy_send(iface, address, addresssize); -- -- // Receive the reply to address "...(C0)\n" -- memset(reply, 0, replysize); -- status = kit_phy_receive(iface, reply, &replysize); -- if (status != ATCA_SUCCESS) -- { -- return ATCA_GEN_FAIL; -- } -- -- if (replysize == 4) -- { -- // Probably an error -- status = kit_parse_rsp(reply, replysize, &kitstatus, rxdata, &rxsize); -- if (status != ATCA_SUCCESS) -- { -- return status; -- } -- if (kitstatus != 0) -- { -- return ATCA_NO_DEVICES; -- } -- } -- rxsize = 2; -- memcpy(rxdata, strchr(reply, '(') + 1, rxsize); -- -- // Send the select address bytes -- memset(selectaddress, 0, selectaddresssize); -- copysize = sizeof(selectaddresspre); -- memcpy(&selectaddress[0], selectaddresspre, copysize); -- memcpy(&selectaddress[(copysize - 1)], rxdata, rxsize); -- copysize = (sizeof(selectaddresspre) + rxsize); -- memcpy(&selectaddress[(copysize - 1)], selectaddresspost, sizeof(selectaddresspost)); -- copysize = (sizeof(selectaddresspre) + rxsize + sizeof(selectaddresspost)); -- status = kit_phy_send(iface, selectaddress, copysize); -- -- // Receive the reply to select address "00()\n" -- memset(reply, 0, replysize); -- status = kit_phy_receive(iface, reply, &replysize); -- if (status != ATCA_SUCCESS) -- { -- return ATCA_GEN_FAIL; -- } -- -- return status; --} -- --/** \brief HAL implementation of kit protocol send. This function calls back to the physical protocol to send the bytes -- * \param[in] iface instance -- * \param[in] txdata pointer to bytes to send -- * \param[in] txlength number of bytes to send -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS kit_send(ATCAIface iface, const uint8_t* txdata, int txlength) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- int nkitbuf = txlength * 2 + KIT_TX_WRAP_SIZE; -- char* pkitbuf = NULL; -- -- // Check the pointers -- if ((txdata == NULL)) -- { -- return ATCA_BAD_PARAM; -- } -- // Wrap in kit protocol -- pkitbuf = malloc(nkitbuf); -- memset(pkitbuf, 0, nkitbuf); -- status = kit_wrap_cmd(&txdata[1], txlength, pkitbuf, &nkitbuf); -- if (status != ATCA_SUCCESS) -- { -- free(pkitbuf); -- return ATCA_GEN_FAIL; -- } -- // Send the bytes -- status = kit_phy_send(iface, pkitbuf, nkitbuf); -- --#ifdef KIT_DEBUG -- // Print the bytes -- printf("\nKit Write: %s", pkitbuf); --#endif -- -- // Free the bytes -- free(pkitbuf); -- -- return status; --} -- --/** \brief HAL implementation to receive bytes and unwrap from kit protocol. This function calls back to the physical protocol to receive the bytes -- * \param[in] iface instance -- * \param[in] rxdata pointer to space to receive the data -- * \param[inout] rxsize ptr to expected number of receive bytes to request -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS kit_receive(ATCAIface iface, uint8_t* rxdata, uint16_t* rxsize) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- uint8_t kitstatus = 0; -- int nkitbuf = 0; -- int dataSize = 0; -- char* pkitbuf = NULL; -- -- // Check the pointers -- if ((rxdata == NULL) || (rxsize == NULL)) -- { -- return ATCA_BAD_PARAM; -- } -- -- // Adjust the read buffer size -- dataSize = *rxsize; -- nkitbuf = dataSize * 2 + KIT_RX_WRAP_SIZE; -- pkitbuf = malloc(nkitbuf); -- memset(pkitbuf, 0, nkitbuf); -- -- // Receive the bytes -- status = kit_phy_receive(iface, pkitbuf, &nkitbuf); -- if (status != ATCA_SUCCESS) -- { -- free(pkitbuf); -- return ATCA_GEN_FAIL; -- } -- --#ifdef KIT_DEBUG -- // Print the bytes -- printf("Kit Read: %s\r", pkitbuf); --#endif -- -- // Unwrap from kit protocol -- memset(rxdata, 0, *rxsize); -- status = kit_parse_rsp(pkitbuf, nkitbuf, &kitstatus, rxdata, &dataSize); -- *rxsize = dataSize; -- -- // Free the bytes -- free(pkitbuf); -- -- return status; --} -- --/** \brief Call the wake for kit protocol -- * \param[in] iface the interface object to send the bytes over -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS kit_wake(ATCAIface iface) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- uint8_t kitstatus = 0; -- char wake[] = "s:w()\n"; -- int wakesize = sizeof(wake); -- char reply[KIT_RX_WRAP_SIZE + 4]; -- int replysize = sizeof(reply); -- uint8_t rxdata[10]; -- int rxsize = sizeof(rxdata); -- -- // Send the bytes -- status = kit_phy_send(iface, wake, wakesize); -- --#ifdef KIT_DEBUG -- // Print the bytes -- printf("\nKit Write: %s", wake); --#endif -- -- // Receive the reply to wake "00(04...)\n" -- memset(reply, 0, replysize); -- status = kit_phy_receive(iface, reply, &replysize); -- if (status != ATCA_SUCCESS) -- { -- return ATCA_GEN_FAIL; -- } -- --#ifdef KIT_DEBUG -- // Print the bytes -- printf("Kit Read: %s\n", reply); --#endif -- -- // Unwrap from kit protocol -- memset(rxdata, 0, rxsize); -- status = kit_parse_rsp(reply, replysize, &kitstatus, rxdata, &rxsize); -- -- return status; --} -- --/** \brief Call the idle for kit protocol -- * \param[in] iface the interface object to send the bytes over -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS kit_idle(ATCAIface iface) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- uint8_t kitstatus = 0; -- char idle[] = "s:i()\n"; -- int idlesize = sizeof(idle); -- char reply[KIT_RX_WRAP_SIZE]; -- int replysize = sizeof(reply); -- uint8_t rxdata[10]; -- int rxsize = sizeof(rxdata); -- -- // Send the bytes -- status = kit_phy_send(iface, idle, idlesize); -- --#ifdef KIT_DEBUG -- // Print the bytes -- printf("\nKit Write: %s", idle); --#endif -- -- // Receive the reply to sleep "00()\n" -- memset(reply, 0, replysize); -- status = kit_phy_receive(iface, reply, &replysize); -- if (status != ATCA_SUCCESS) -- { -- return ATCA_GEN_FAIL; -- } -- --#ifdef KIT_DEBUG -- // Print the bytes -- printf("Kit Read: %s\r", reply); --#endif -- -- // Unwrap from kit protocol -- memset(rxdata, 0, rxsize); -- status = kit_parse_rsp(reply, replysize, &kitstatus, rxdata, &rxsize); -- -- return status; --} -- --/** \brief Call the sleep for kit protocol -- * \param[in] iface the interface object to send the bytes over -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS kit_sleep(ATCAIface iface) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- uint8_t kitstatus = 0; -- -- char sleep[] = "s:s()\n"; -- int sleepsize = sizeof(sleep); -- char reply[KIT_RX_WRAP_SIZE]; -- int replysize = sizeof(reply); -- uint8_t rxdata[10]; -- int rxsize = sizeof(rxdata); -- -- // Send the bytes -- status = kit_phy_send(iface, sleep, sleepsize); -- --#ifdef KIT_DEBUG -- // Print the bytes -- printf("\nKit Write: %s", sleep); --#endif -- -- // Receive the reply to sleep "00()\n" -- memset(reply, 0, replysize); -- status = kit_phy_receive(iface, reply, &replysize); -- if (status != ATCA_SUCCESS) -- { -- return ATCA_GEN_FAIL; -- } -- --#ifdef KIT_DEBUG -- // Print the bytes -- printf("Kit Read: %s\r", reply); --#endif -- -- // Unwrap from kit protocol -- memset(rxdata, 0, rxsize); -- status = kit_parse_rsp(reply, replysize, &kitstatus, rxdata, &rxsize); -- -- return status; --} -- --/** \brief Wrap binary bytes in ascii kit protocol -- * \param[in] txdata pointer to the binary data to wrap -- * \param[in] txlen length of the binary data to wrap -- * \param[out] pkitcmd pointer to binary data converted to ascii kit protocol -- * \param[inout] nkitcmd pointer to the size of the binary data converted to ascii kit protocol -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS kit_wrap_cmd(const uint8_t* txdata, int txlen, char* pkitcmd, int* nkitcmd) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- char cmdpre[] = "s:t("; // sha:talk( -- char cmdpost[] = ")\n"; --// char* pkitcmd = NULL; -- int cmdAsciiLen = txlen * 2; -- int cmdlen = txlen * 2 + sizeof(cmdpre) + sizeof(cmdpost) + 1; -- int cpylen = 0; -- int cpyindex = 0; -- -- // Check the variables -- if (txdata == NULL || pkitcmd == NULL || nkitcmd == NULL) -- { -- return ATCA_BAD_PARAM; -- } -- if (*nkitcmd > cmdlen) -- { -- return ATCA_BAD_PARAM; -- } -- -- // Wrap in kit protocol -- memset(pkitcmd, 0, *nkitcmd); -- -- // Copy the prefix -- cpylen = (int)strlen(cmdpre); -- memcpy(&pkitcmd[cpyindex], cmdpre, cpylen); -- cpyindex += cpylen; -- -- // Copy the ascii binary bytes -- status = atcab_bin2hex_(txdata, txlen, &pkitcmd[cpyindex], &cmdAsciiLen, false); -- if (status != ATCA_SUCCESS) -- { -- return status; -- } -- cpyindex += cmdAsciiLen; -- -- // Copy the postfix -- cpylen = (int)strlen(cmdpost); -- memcpy(&pkitcmd[cpyindex], cmdpost, cpylen); -- cpyindex += cpylen; -- -- *nkitcmd = cpyindex; -- -- return status; --} -- --/** \brief Parse the response ascii from the kit -- * \param[out] pkitbuf pointer to ascii kit protocol data to parse -- * \param[in] nkitbuf length of the ascii kit protocol data -- * \param[in] kitstatus status of the ascii device -- * \param[in] rxdata pointer to the binary data buffer -- * \param[in] datasize size of the pointer to the binary data buffer -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS kit_parse_rsp(const char* pkitbuf, int nkitbuf, uint8_t* kitstatus, uint8_t* rxdata, int* datasize) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- int statusId = 0; -- int dataId = 3; -- int binSize = 1; -- int asciiDataSize = 0; -- char* endDataPtr = 0; -- -- // First get the kit status -- status = atcab_hex2bin(&pkitbuf[statusId], 2, kitstatus, &binSize); -- if (status != ATCA_SUCCESS) -- { -- return status; -- } -- -- // Next get the binary data bytes -- endDataPtr = strchr((char*)pkitbuf, ')'); -- if (endDataPtr < (&pkitbuf[dataId])) -- { -- return ATCA_GEN_FAIL; -- } -- asciiDataSize = (int)(endDataPtr - (&pkitbuf[dataId])); -- status = atcab_hex2bin(&pkitbuf[dataId], asciiDataSize, rxdata, datasize); -- if (status != ATCA_SUCCESS) -- { -- return status; -- } -- -- return ATCA_SUCCESS; --} -- --/** @} */ -diff --git a/lib/hal/kit_protocol.h b/lib/hal/kit_protocol.h -deleted file mode 100644 -index 84f7fee454cb..000000000000 ---- a/lib/hal/kit_protocol.h -+++ /dev/null -@@ -1,77 +0,0 @@ --/** -- * \file -- * -- * \brief Atmel Crypto Auth hardware interface object -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef KIT_PROTOCOL_H_ --#define KIT_PROTOCOL_H_ -- --#include "cryptoauthlib.h" -- --// Define this for debugging communication --//#define KIT_DEBUG -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- --// The number of bytes to wrap a command in kit protocol. sizeof("s:t()\n") --#define KIT_TX_WRAP_SIZE (7) -- --// The number of bytes to wrap a response in kit protocol. sizeof("00()\n") --#define KIT_MSG_SIZE (32) --#define KIT_RX_WRAP_SIZE (KIT_MSG_SIZE + 6) -- --#ifdef __cplusplus --extern "C" { --#endif -- --ATCA_STATUS kit_init(ATCAIface iface); -- --ATCA_STATUS kit_send(ATCAIface iface, const uint8_t* txdata, int txlength); --ATCA_STATUS kit_receive(ATCAIface iface, uint8_t* rxdata, uint16_t* rxsize); -- --ATCA_STATUS kit_wrap_cmd(const uint8_t* txdata, int txlength, char* pkitbuf, int* nkitbuf); --ATCA_STATUS kit_parse_rsp(const char* pkitbuf, int nkitbuf, uint8_t* kitstatus, uint8_t* rxdata, int* nrxdata); -- --ATCA_STATUS kit_wake(ATCAIface iface); --ATCA_STATUS kit_idle(ATCAIface iface); --ATCA_STATUS kit_sleep(ATCAIface iface); -- --#ifdef __cplusplus --} --#endif -- --/** @} */ -- --#endif // KIT_PROTOCOL_H -diff --git a/lib/hal/swi_bitbang_samd21.c b/lib/hal/swi_bitbang_samd21.c -deleted file mode 100644 -index 3c540109cb4c..000000000000 ---- a/lib/hal/swi_bitbang_samd21.c -+++ /dev/null -@@ -1,272 +0,0 @@ --/** -- * \file -- * \brief Hardware Interface Functions - SWI bit-banged -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include "swi_bitbang_samd21.h" -- -- -- -- -- --SWIBuses swi_buses_default = { -- { EXT3_PIN_3, EXT3_PIN_9, EXT3_PIN_I2C_SDA, EXT3_PIN_13, EXT2_PIN_3, EXT2_PIN_5, EXT2_PIN_7, EXT2_PIN_9, EXT2_PIN_13, EXT2_PIN_15, EXT2_PIN_17, EXT1_PIN_3, EXT1_PIN_5, EXT1_PIN_7, EXT1_PIN_9, EXT1_PIN_13, EXT1_PIN_15, EXT1_PIN_17, EXT3_PIN_7, EXT3_PIN_10, EXT3_PIN_I2C_SCL, EXT3_PIN_14, EXT2_PIN_4, EXT2_PIN_6, EXT2_PIN_8, EXT2_PIN_10, EXT2_PIN_14, EXT2_PIN_16, EXT2_PIN_18, EXT1_PIN_4, EXT1_PIN_6, EXT1_PIN_8, EXT1_PIN_10, EXT1_PIN_14, EXT1_PIN_16, EXT1_PIN_18 } -- --}; -- -- --//! declaration of the variable indicating which pin the selected device is connected to --static uint8_t device_pin; -- -- --void swi_set_pin(uint8_t id) --{ -- device_pin = id; --} -- -- -- --void swi_enable(void) --{ -- struct port_config pin_conf; -- -- port_get_config_defaults(&pin_conf); -- pin_conf.direction = PORT_PIN_DIR_OUTPUT; -- port_pin_set_config(device_pin, &pin_conf); --} -- --void swi_disable(void) --{ -- struct port_config pin_conf; -- -- port_get_config_defaults(&pin_conf); -- port_pin_set_config(device_pin, &pin_conf); --} -- -- --void swi_set_signal_pin(uint8_t is_high) --{ -- if (is_high) -- { -- port_pin_set_output_level(device_pin, true); -- } -- else -- { -- port_pin_set_output_level(device_pin, false); -- } --} -- --void swi_send_wake_token(void) --{ -- swi_set_signal_pin(0); -- delay_us(60); -- swi_set_signal_pin(1); --} -- --void swi_send_bytes(uint8_t count, uint8_t *buffer) --{ -- uint8_t i, bit_mask; -- struct port_config pin_conf; -- -- port_get_config_defaults(&pin_conf); -- pin_conf.direction = PORT_PIN_DIR_OUTPUT; -- port_pin_set_config(device_pin, &pin_conf); -- -- //! Wait turn around time. -- RX_TX_DELAY; -- cpu_irq_disable(); -- -- -- for (i = 0; i < count; i++) -- { -- for (bit_mask = 1; bit_mask > 0; bit_mask <<= 1) -- { -- if (bit_mask & buffer[i]) //!< Send Logic 1 (7F) -- { -- port_pin_set_output_level(device_pin, false); -- BIT_DELAY_1L; -- port_pin_set_output_level(device_pin, true); -- BIT_DELAY_7; -- } -- else //!< Send Logic 0 (7D) -- { -- port_pin_set_output_level(device_pin, false); -- BIT_DELAY_1L; -- port_pin_set_output_level(device_pin, true); -- BIT_DELAY_1H; -- port_pin_set_output_level(device_pin, false); -- BIT_DELAY_1L; -- port_pin_set_output_level(device_pin, true); -- BIT_DELAY_5; -- } -- } -- } -- cpu_irq_enable(); -- -- -- --} -- -- --void swi_send_byte(uint8_t byte) --{ -- swi_send_bytes(1, &byte); -- --} -- -- -- -- --ATCA_STATUS swi_receive_bytes(uint8_t count, uint8_t *buffer) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- -- uint8_t i; -- uint8_t bit_mask; -- uint8_t pulse_count; -- uint16_t timeout_count; -- struct port_config pin_conf; -- -- -- port_get_config_defaults(&pin_conf); -- port_pin_set_config(device_pin, &pin_conf); -- -- -- cpu_irq_disable(); -- //! Receive bits and store in buffer. -- for (i = 0; i < count; i++) -- { -- buffer[i] = 0; -- for (bit_mask = 1; bit_mask > 0; bit_mask <<= 1) -- { -- pulse_count = 0; -- -- -- timeout_count = START_PULSE_TIME_OUT; -- //! Detect start bit. -- -- while (--timeout_count > 0) -- { -- //! Wait for falling edge. -- if (port_pin_get_input_level(device_pin) == 0) -- { -- -- break; -- } -- } -- if (timeout_count == 0) -- { -- status = ATCA_RX_TIMEOUT; -- break; -- } -- -- timeout_count = START_PULSE_TIME_OUT; -- -- do -- { -- //! Wait for rising edge. -- if (port_pin_get_input_level(device_pin) != 0) -- { -- pulse_count = 1; -- -- break; -- } -- } -- while (--timeout_count > 0); -- -- if (pulse_count == 0) -- { -- status = ATCA_RX_TIMEOUT; -- break; -- } -- -- //! let's just wait the maximum time for the falling edge of a zero bit -- //! to arrive after we have detected the rising edge of the start bit. -- timeout_count = ZERO_PULSE_TIME_OUT; -- -- //! Detect possible edge indicating zero bit. -- do -- { -- if (port_pin_get_input_level(device_pin) == 0) -- { -- pulse_count = 2; -- break; -- } -- } -- while (--timeout_count > 0); -- -- -- //! Wait for rising edge of zero pulse before returning. Otherwise we might interpret -- //! its rising edge as the next start pulse. -- if (pulse_count == 2) -- { -- timeout_count = ZERO_PULSE_TIME_OUT; -- -- do -- { -- if (port_pin_get_input_level(device_pin) != 0) -- { -- break; -- } -- } -- -- while (timeout_count-- > 0); -- -- } -- //! Update byte at current buffer index. -- else -- //! received "one" bit -- { -- buffer[i] |= bit_mask; -- } -- } -- -- -- if (status != ATCA_SUCCESS) -- { -- break; -- } -- } -- -- if (status == ATCA_RX_TIMEOUT) -- { -- if (i > 0) -- { -- //! Indicate that we timed out after having received at least one byte. -- status = ATCA_RX_FAIL; -- } -- } -- -- cpu_irq_enable(); -- -- -- return status; --} -\ No newline at end of file -diff --git a/lib/hal/swi_bitbang_samd21.h b/lib/hal/swi_bitbang_samd21.h -deleted file mode 100644 -index b6d20f6153ba..000000000000 ---- a/lib/hal/swi_bitbang_samd21.h -+++ /dev/null -@@ -1,148 +0,0 @@ --/** -- * \file -- * \brief Hardware Interface Functions - SWI bit-banged -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef SWI_BITBANG_SAMD21_H_ --#define SWI_BITBANG_SAMD21_H_ -- --#include "atca_status.h" --#include -- -- --#define MAX_SWI_BUSES 36 //!< SAMD21 xplainned pro has 36 free GPIO pins available -- -- --typedef struct --{ -- uint32_t pin_sda[MAX_SWI_BUSES]; --} SWIBuses; -- --extern SWIBuses swi_buses_default; -- -- --/** -- * \name Macros for Bit-Banged SWI Timing -- * -- * Times to drive bits at 230.4 kbps. -- @{ */ -- --//! delay macro for width of one pulse (start pulse or zero pulse) --//! should be 4.34 us, is 4.05 us -- --#define BIT_DELAY_1L delay_us(3) --//! should be 4.34 us, is 4.05us --#define BIT_DELAY_1H delay_us(3) -- --//! time to keep pin high for five pulses plus stop bit (used to bit-bang CryptoAuth 'zero' bit) --//! should be 26.04 us, is 26.92 us --#define BIT_DELAY_5 delay_us(26) // considering pin set delay -- --//! time to keep pin high for seven bits plus stop bit (used to bit-bang CryptoAuth 'one' bit) --//! should be 34.72 us, is 35.13 us --#define BIT_DELAY_7 delay_us(34) // considering pin set delay -- --//! turn around time when switching from receive to transmit --//! should be 15 us, is 15.58 us --#define RX_TX_DELAY delay_us(15) -- -- --//! Lets set the timeout value for start pulse detection to the uint8_t maximum. --//! This value is decremented while waiting for the falling edge of a start pulse. --#define START_PULSE_TIME_OUT (600) -- --//! Maximum time between rising edge of start pulse --//! and falling edge of zero pulse is 8.6 us. Therefore, a value of 40 (around 15 us) --//! gives ample time to detect a zero pulse and also leaves enough time to detect --//! the following start pulse. --//! This value is decremented while waiting for the falling edge of a zero pulse. --#define ZERO_PULSE_TIME_OUT (40) -- --/** @} */ -- -- --/** -- * \brief Set SWI signal pin. -- * Other functions will use this pin. -- * -- * \param[in] id definition of GPIO pin to be used -- */ --void swi_set_pin(uint8_t id); -- -- -- --/** -- * \brief Configure GPIO pin for SWI signal as output. -- */ --void swi_enable(void); -- --/** -- * \brief Configure GPIO pin for SWI signal as input. -- */ --void swi_disable(void); -- --/** -- * \brief Set signal pin Low or High. -- * -- * \param[in] is_high 0: Low, else: High. -- */ --void swi_set_signal_pin(uint8_t is_high); -- --/** -- * \brief Send a Wake Token. -- */ --void swi_send_wake_token(void); -- --/** -- * \brief Send a number of bytes.This function should not be called directly ,instead should use hal_swi_send() which call this function. -- * -- * \param[in] count number of bytes to send. -- * \param[in] buffer pointer to buffer containing bytes to send -- */ --void swi_send_bytes(uint8_t count, uint8_t *buffer); -- --/** -- * \brief Send one byte. -- * -- * \param[in] byte byte to send -- */ --void swi_send_byte(uint8_t byte); -- --/** -- * \brief Receive a number of bytes.This function should not be called directly ,instead should use hal_swi_receive() which call this function. -- * -- * \param[in] count number of bytes to receive -- * \param[out] buffer pointer to receive buffer -- * -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS swi_receive_bytes(uint8_t count, uint8_t *buffer); -- -- --#endif /* SWI_BITBANG_SAMD21_H_ */ -\ No newline at end of file -diff --git a/lib/hal/swi_uart_at90usb1287_asf.c b/lib/hal/swi_uart_at90usb1287_asf.c -deleted file mode 100644 -index 68efbf61eec5..000000000000 ---- a/lib/hal/swi_uart_at90usb1287_asf.c -+++ /dev/null -@@ -1,260 +0,0 @@ --/** -- * \file -- * \brief ATXMEGA's ATCA Hardware abstraction layer for SWI interface over AT90USB1287 UART drivers. -- * -- * Prerequisite: add UART Polled support to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include "usart_serial.h" --#include "swi_uart_at90usb1287_asf.h" --#include "basic/atca_helpers.h" -- --/*#define DEBUG_PIN*/ -- --#ifdef DEBUG_PIN -- #define DEBUG_PIN_1 IOPORT_CREATE_PIN(PORTB, 0) -- #define DEBUG_PIN_2 IOPORT_CREATE_PIN(PORTB, 1) --#endif -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- --/** \brief usart configuration struct */ --static usart_serial_options_t config_usart; --/** \brief sysclk_get_per_hz value */ --static uint32_t u32sysclk; -- --/** \brief -- - this HAL implementation assumes you've included the ASF SERCOM UART libraries in your project, otherwise, -- the HAL layer will not compile because the ASF UART drivers are a dependency * -- */ -- --/** \brief Implementation of SWI UART init. -- * \param[in] instance instance -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS swi_uart_init(ATCASWIMaster_t *instance) --{ --#ifdef DEBUG_PIN -- ioport_init(); -- ioport_set_pin_dir(DEBUG_PIN_1, IOPORT_DIR_OUTPUT); -- ioport_set_pin_dir(DEBUG_PIN_2, IOPORT_DIR_OUTPUT); -- gpio_set_pin_high(DEBUG_PIN_1); -- gpio_set_pin_high(DEBUG_PIN_2); --#endif -- ATCA_STATUS status = ATCA_SUCCESS; -- -- //Save sysclk_get_per_hz value -- u32sysclk = sysclk_get_source_clock_hz(); -- // Set data size to 7 -- config_usart.charlength = USART_CHSIZE_7BIT_gc; -- // Set parity to no parity -- config_usart.paritytype = USART_PMODE_DISABLED_gc; -- // Set data byte to one stopbit -- config_usart.stopbits = false; -- // Set baudrate to 230400 -- config_usart.baudrate = 230400; -- -- switch (instance->bus_index) -- { -- case 0: instance->usart_instance = &USARTA1; break; // AT90USB1287 has only 1 UART channel which maps to ATMEGARF's UART 1 -- } -- status = usart_serial_init(instance->usart_instance, &config_usart); -- return status; --} -- --/** \brief Implementation of SWI UART deinit. -- * \param[in] instance instance -- * \return ATCA_SUCCESS -- */ --ATCA_STATUS swi_uart_deinit(ATCASWIMaster_t *instance) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- -- instance->usart_instance = NULL; -- return status; --} -- --/** \brief implementation of SWI UART change baudrate. -- * \param[in] instance instance -- * \param[in] baudrate (typically 230400 , 160000 or 115200) -- */ --void swi_uart_setbaud(ATCASWIMaster_t *instance, uint32_t baudrate) --{ -- /*usart_double_baud_enable(instance->usart_instance);*/ -- // Set baudrate for UART module -- usart_set_baudrate(instance->usart_instance, baudrate, u32sysclk); --} -- -- --/** \brief implementation of SWI UART change mode. -- * \param[in] instance instance -- * \param[in] mode (TRANSMIT_MODE or RECEIVE_MODE) -- */ --void swi_uart_mode(ATCASWIMaster_t *instance, uint8_t mode) --{ -- switch (mode) -- { -- case TRANSMIT_MODE: -- swi_uart_setbaud(instance, 230400); -- break; -- case RECEIVE_MODE: -- //Reset UART RX buffer. -- usart_rx_disable(instance->usart_instance); -- usart_rx_enable(instance->usart_instance); -- break; -- default: -- break; -- } -- --} -- --/** \brief discover UART buses available for this hardware -- * this maintains a list of logical to physical bus mappings freeing the application -- * of the a-priori knowledge -- * \param[in] swi_uart_buses - an array of logical bus numbers -- * \param[in] max_buses - maximum number of buses the app wants to attempt to discover -- */ --void swi_uart_discover_buses(int swi_uart_buses[], int max_buses) --{ -- /* if every PORT was a likely candidate bus, then would need to initialize the entire array to all PORT n numbers. -- * As an optimization and making discovery safer, make assumptions about bus-num / PORT map based on AT90USB1287 -- * If you were using a raw XMEGA on your own board, you would supply your own bus numbers based on your particular hardware configuration. -- */ -- swi_uart_buses[0] = 0; // AT90USB1287 supports single UART channel --} -- --/** \brief HAL implementation of SWI UART send byte over ASF. This function send one byte over UART -- * \param[in] instance instance -- * \param[in] data byte to send -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS swi_uart_send_byte(ATCASWIMaster_t *instance, uint8_t data) --{ -- int8_t timeout = 0x7F; -- bool data_reg_empty = false; -- ATCA_STATUS status = ATCA_EXECUTION_ERROR /*ATCA_CMD_FAIL*/; -- -- // Send one byte over UART module --#ifdef DEBUG_PIN -- gpio_toggle_pin(DEBUG_PIN_1); --#endif -- -- // Send one byte over UART module -- timeout = 0x7F; -- -- while ((timeout > 0) && (data_reg_empty == false)) -- { -- data_reg_empty = usart_data_register_is_empty(instance->usart_instance); -- timeout--; -- } -- -- if (data_reg_empty) -- { -- usart_serial_putchar(instance->usart_instance, data); -- while (!usart_tx_is_complete(instance->usart_instance)) -- { -- ; -- } -- usart_clear_tx_complete(instance->usart_instance); -- status = ATCA_SUCCESS; -- } -- --#ifdef DEBUG_PIN -- gpio_toggle_pin(DEBUG_PIN_1); --#endif -- if (timeout > 0) -- { -- return status; -- } -- else -- { -- return ATCA_TIMEOUT; -- } --} -- --/** \brief HAL implementation of SWI UART receive bytes over ASF. This function receive one byte over UART -- * \param[in] instance instance -- * \param[inout] data pointer to space to receive the data -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS swi_uart_receive_byte(ATCASWIMaster_t *instance, uint8_t *data) --{ -- int8_t timeout, retries = 0x2; // This retry is used to compensate the baudrate that do not match when receiving response -- -- *data = 0xFF; -- bool rx_complete = false; -- ATCA_STATUS status = ATCA_EXECUTION_ERROR /*ATCA_CMD_FAIL*/; --#ifdef DEBUG_PIN -- gpio_toggle_pin(DEBUG_PIN_2); --#endif -- // Receive one byte over UART module -- while ((retries > 0) && (status != ATCA_SUCCESS)) -- { -- timeout = 0x7F; retries--; -- while ((timeout > 0) && (rx_complete == false)) -- { -- rx_complete = usart_rx_is_complete(instance->usart_instance); -- timeout--; -- } -- -- if (rx_complete) -- { -- usart_serial_getchar(instance->usart_instance, data); -- //if ((*data == 0x7D) || (*data == 0x7F)) -- if ((*data >= 0x70) && (*data <= 0x7F)) -- { -- status = ATCA_SUCCESS; -- } -- else -- { -- status = ATCA_EXECUTION_ERROR /*ATCA_CMD_FAIL*/; -- } -- } -- } --#ifdef DEBUG_PIN -- gpio_toggle_pin(DEBUG_PIN_2); --#endif -- if (timeout > 0) -- { -- return status; -- } -- else -- { -- return ATCA_TIMEOUT; -- } --} -- --/** @} */ -diff --git a/lib/hal/swi_uart_at90usb1287_asf.h b/lib/hal/swi_uart_at90usb1287_asf.h -deleted file mode 100644 -index 2b11b2467937..000000000000 ---- a/lib/hal/swi_uart_at90usb1287_asf.h -+++ /dev/null -@@ -1,83 +0,0 @@ --/** -- * \file -- * \brief ATMEGA's ATCA Hardware abstraction layer for SWI interface over AT90USB1287 UART drivers. -- * -- * Prerequisite: add UART Polled support to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef SWI_UART_AT90USB1287_ASF_H --#define SWI_UART_AT90USB1287_ASF_H -- --#include --#include "cryptoauthlib.h" --#include "serial.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- -- --/** \brief -- - this HAL implementation assumes you've included the ASF UART libraries in your project, otherwise, -- the HAL layer will not compile because the ASF UART drivers are a dependency * -- */ -- --#define MAX_SWI_BUSES 1 // AT90USB1287 has only 1 port -- --#define RECEIVE_MODE 0 // UART Receive mode, RX enabled --#define TRANSMIT_MODE 1 // UART Transmit mode, RX disabled --#define RX_DELAY 10 // Delay before responses come --#define TX_DELAY 90 // Delay before new flag is sent -- --/** \brief this is the hal_data for ATCA HAL for SWI UART -- */ --typedef struct atcaSWImaster --{ -- // struct usart_module for Atmel SWI interface -- usart_if usart_instance; -- // for conveniences during interface release phase -- int bus_index; --} ATCASWIMaster_t; -- -- --ATCA_STATUS swi_uart_init(ATCASWIMaster_t *instance); --ATCA_STATUS swi_uart_deinit(ATCASWIMaster_t *instance); --void swi_uart_setbaud(ATCASWIMaster_t *instance, uint32_t baudrate); --void swi_uart_mode(ATCASWIMaster_t *instance, uint8_t mode); --void swi_uart_discover_buses(int swi_uart_buses[], int max_buses); -- --ATCA_STATUS swi_uart_send_byte(ATCASWIMaster_t *instance, uint8_t data); --ATCA_STATUS swi_uart_receive_byte(ATCASWIMaster_t *instance, uint8_t *data); -- --/** @} */ -- --#endif // SWI_UART_AT90USB1287_ASF_H -diff --git a/lib/hal/swi_uart_samd21_asf.c b/lib/hal/swi_uart_samd21_asf.c -deleted file mode 100644 -index 1a5b698381e0..000000000000 ---- a/lib/hal/swi_uart_samd21_asf.c -+++ /dev/null -@@ -1,238 +0,0 @@ --/** -- * \file -- * \brief ATXMEGA's ATCA Hardware abstraction layer for SWI interface over UART drivers. -- * -- * Prerequisite: add UART Polled support to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include "swi_uart_samd21_asf.h" --#include "basic/atca_helpers.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- --/** \brief usart configuration struct */ --static struct usart_config config_usart; --struct port_config pin_conf; //for DEBUG purpose -- -- --/** \brief -- - this HAL implementation assumes you've included the ASF SERCOM UART libraries in your project, otherwise, -- the HAL layer will not compile because the ASF UART drivers are a dependency * -- */ -- --/** \brief Implementation of SWI UART init. -- * \param[in] instance instance -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS swi_uart_init(ATCASWIMaster_t *instance) --{ --#ifdef DEBUG_PIN -- port_get_config_defaults(&pin_conf); -- pin_conf.direction = PORT_PIN_DIR_OUTPUT; -- port_pin_set_config(DEBUG_PIN_1, &pin_conf); -- port_pin_set_config(DEBUG_PIN_2, &pin_conf); -- port_pin_set_output_level(DEBUG_PIN_1, HIGH); -- port_pin_set_output_level(DEBUG_PIN_2, HIGH); --#endif -- -- ATCA_STATUS status = ATCA_SUCCESS; -- usart_get_config_defaults(&config_usart); -- // Set data size to 7 -- config_usart.character_size = USART_CHARACTER_SIZE_7BIT; -- // Set parity to no parity -- config_usart.parity = USART_PARITY_NONE; -- // Set data byte to one stopbit -- config_usart.stopbits = USART_STOPBITS_1; -- // Set baudrate to 230400 -- config_usart.baudrate = 230400; --#ifdef __SAMD21J18A__ -- config_usart.mux_setting = EXT3_UART_SERCOM_MUX_SETTING; -- config_usart.pinmux_pad0 = EXT3_UART_SERCOM_PINMUX_PAD0; -- config_usart.pinmux_pad1 = EXT3_UART_SERCOM_PINMUX_PAD1; -- config_usart.pinmux_pad2 = EXT3_UART_SERCOM_PINMUX_PAD2; -- config_usart.pinmux_pad3 = EXT3_UART_SERCOM_PINMUX_PAD3; --#endif --#ifdef __SAMR21G18A__ -- config_usart.mux_setting = EXT1_UART_SERCOM_MUX_SETTING; -- config_usart.pinmux_pad0 = EXT1_UART_SERCOM_PINMUX_PAD0; -- config_usart.pinmux_pad1 = EXT1_UART_SERCOM_PINMUX_PAD1; -- config_usart.pinmux_pad2 = EXT1_UART_SERCOM_PINMUX_PAD2; -- config_usart.pinmux_pad3 = EXT1_UART_SERCOM_PINMUX_PAD3; --#endif -- switch (instance->bus_index) -- { -- case 0: status = usart_init(&(instance->usart_instance), SERCOM0, &config_usart); break; -- case 1: status = usart_init(&(instance->usart_instance), SERCOM1, &config_usart); break; -- case 2: status = usart_init(&(instance->usart_instance), SERCOM2, &config_usart); break; -- case 3: status = usart_init(&(instance->usart_instance), SERCOM3, &config_usart); break; -- case 4: status = usart_init(&(instance->usart_instance), SERCOM4, &config_usart); break; -- case 5: status = usart_init(&(instance->usart_instance), SERCOM5, &config_usart); break; -- } -- usart_enable(&(instance->usart_instance)); -- return status; --} -- --/** \brief Implementation of SWI UART deinit. -- * \param[in] instance instance -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS swi_uart_deinit(ATCASWIMaster_t *instance) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- -- usart_reset(&(instance->usart_instance)); -- return status; --} -- --/** \brief implementation of SWI UART change baudrate. -- * \param[in] instance instance -- * \param[in] baudrate (typically 230400 , 160000 or 115200) -- */ --void swi_uart_setbaud(ATCASWIMaster_t *instance, uint32_t baudrate) --{ -- // Disable UART module -- usart_disable(&(instance->usart_instance)); -- // Set baudrate for UART module -- config_usart.baudrate = baudrate; -- switch (instance->bus_index) -- { -- case 0: usart_init(&(instance->usart_instance), SERCOM0, &config_usart); break; -- case 1: usart_init(&(instance->usart_instance), SERCOM1, &config_usart); break; -- case 2: usart_init(&(instance->usart_instance), SERCOM2, &config_usart); break; -- case 3: usart_init(&(instance->usart_instance), SERCOM3, &config_usart); break; -- case 4: usart_init(&(instance->usart_instance), SERCOM4, &config_usart); break; -- case 5: usart_init(&(instance->usart_instance), SERCOM5, &config_usart); break; -- } -- usart_enable(&(instance->usart_instance)); --} -- -- --/** \brief implementation of SWI UART change mode. -- * \param[in] instance instance -- * \param[in] mode (TRANSMIT_MODE or RECEIVE_MODE) -- */ --void swi_uart_mode(ATCASWIMaster_t *instance, uint8_t mode) --{ -- usart_disable(&(instance->usart_instance)); -- // Do nothing as the available time is not enough for setting the baudrate in ASF -- usart_enable(&(instance->usart_instance)); --} -- --/** \brief discover UART buses available for this hardware -- * this maintains a list of logical to physical bus mappings freeing the application -- * of the a-priori knowledge -- * \param[in] swi_uart_buses - an array of logical bus numbers -- * \param[in] max_buses - maximum number of buses the app wants to attempt to discover -- */ --void swi_uart_discover_buses(int swi_uart_buses[], int max_buses) --{ -- /* if every SERCOM was a likely candidate bus, then would need to initialize the entire array to all SERCOM n numbers. -- * As an optimization and making discovery safer, make assumptions about bus-num / SERCOM map based on SAMD21 Xplained Pro board -- * If you were using a raw SAMD21 on your own board, you would supply your own bus numbers based on your particular hardware configuration. -- */ -- swi_uart_buses[0] = 4; // default samd21 for xplained dev board --} -- -- --/** \brief HAL implementation of SWI UART send byte over ASF. This function send one byte over UART -- * \param[in] instance instance -- * \param[in] data number of byte to send -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS swi_uart_send_byte(ATCASWIMaster_t *instance, uint8_t data) --{ -- int8_t retries = 90; -- uint16_t bitdata = (uint16_t)data; -- -- // Send one byte over UART module --#ifdef DEBUG_PIN -- port_pin_toggle_output_level(DEBUG_PIN_1); --#endif -- -- while ((retries > 0) && (usart_write_wait(&(instance->usart_instance), bitdata) != STATUS_OK)) -- { -- retries--; -- } -- --#ifdef DEBUG_PIN -- port_pin_toggle_output_level(DEBUG_PIN_1); --#endif -- -- if (retries <= 0x00) -- { -- return ATCA_TIMEOUT; -- } -- else -- { -- return ATCA_SUCCESS; -- } --} -- --/** \brief HAL implementation of SWI UART receive bytes over ASF. This function receive one byte over UART -- * \param[in] instance instance -- * \param[out] data pointer to space to receive the data -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS swi_uart_receive_byte(ATCASWIMaster_t *instance, uint8_t *data) --{ -- uint8_t retries = 100; // This retry is used to compensate the baudrate that do not match when receiving response -- uint16_t bitdata = 0x00; -- --#ifdef DEBUG_PIN -- port_pin_toggle_output_level(DEBUG_PIN_2); --#endif -- // Receive one byte over UART module -- while ((retries > 0) && (usart_read_wait(&(instance->usart_instance), &bitdata) != STATUS_OK)) -- { -- retries--; -- } -- --#ifdef DEBUG_PIN -- port_pin_toggle_output_level(DEBUG_PIN_2); --#endif -- -- *data = bitdata; -- if (retries <= 0x00) -- { -- return ATCA_TIMEOUT; -- } -- else -- { -- return ATCA_SUCCESS; -- } --} -- --/** @} */ -diff --git a/lib/hal/swi_uart_samd21_asf.h b/lib/hal/swi_uart_samd21_asf.h -deleted file mode 100644 -index eb518a3430fd..000000000000 ---- a/lib/hal/swi_uart_samd21_asf.h -+++ /dev/null -@@ -1,84 +0,0 @@ --/** -- * \file -- * \brief ATXMEGA's ATCA Hardware abstraction layer for SWI interface over UART drivers. -- * -- * Prerequisite: add UART Polled support to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef SWI_UART_SAMD21_ASF_H_ --#define SWI_UART_SAMD21_ASF_H_ -- --#include --#include "cryptoauthlib.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- -- --/** \brief -- - this HAL implementation assumes you've included the ASF SERCOM UART libraries in your project, otherwise, -- the HAL layer will not compile because the ASF UART drivers are a dependency * -- */ -- --#define MAX_SWI_BUSES 6 // SAMD21 has up to 6 SERCOMS that can be configured as UART -- --#define RECEIVE_MODE 0 // UART Receive mode, RX enabled --#define TRANSMIT_MODE 1 // UART Transmit mode, RX disabled --#define RX_DELAY { volatile uint8_t delay = 90; while (delay--) { __asm__ (""); } } --#define TX_DELAY 90 -- --#define DEBUG_PIN_1 EXT2_PIN_5 --#define DEBUG_PIN_2 EXT2_PIN_6 --/** \brief this is the hal_data for ATCA HAL for ASF SERCOM -- */ --typedef struct atcaSWImaster --{ -- // struct usart_module for Atmel SWI interface -- struct usart_module usart_instance; -- // for conveniences during interface release phase -- int bus_index; --} ATCASWIMaster_t; -- -- --ATCA_STATUS swi_uart_init(ATCASWIMaster_t *instance); --ATCA_STATUS swi_uart_deinit(ATCASWIMaster_t *instance); --void swi_uart_setbaud(ATCASWIMaster_t *instance, uint32_t baudrate); --void swi_uart_mode(ATCASWIMaster_t *instance, uint8_t mode); --void swi_uart_discover_buses(int swi_uart_buses[], int max_buses); -- --ATCA_STATUS swi_uart_send_byte(ATCASWIMaster_t *instance, uint8_t data); --ATCA_STATUS swi_uart_receive_byte(ATCASWIMaster_t *instance, uint8_t *data); -- --/** @} */ -- --#endif // SWI_UART_ASF_H -diff --git a/lib/hal/swi_uart_samd21_start.c b/lib/hal/swi_uart_samd21_start.c -deleted file mode 100644 -index 0bf4650afaa0..000000000000 ---- a/lib/hal/swi_uart_samd21_start.c -+++ /dev/null -@@ -1,208 +0,0 @@ --/** -- * \file -- * -- * \brief Atmel Crypto Auth hardware interface object -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include "swi_uart_samd21_start.h" --#include "basic/atca_helpers.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- --/** \brief -- - this HAL implementation assumes you've included the START SERCOM UART libraries in your project, otherwise, -- the HAL layer will not compile because the START UART drivers are a dependency * -- */ -- --/** \brief HAL implementation of SWI UART init. -- * \param[in] instance instance -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS swi_uart_init(ATCASWIMaster_t *instance) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- -- instance->USART_SWI = USART_1; -- -- status |= usart_sync_set_mode(&(instance->USART_SWI), USART_MODE_ASYNCHRONOUS); -- // Set data size to 7 -- status |= usart_sync_set_character_size(&(instance->USART_SWI), USART_CHARACTER_SIZE_7BITS); -- // Set parity to no parity -- status |= usart_sync_set_parity(&(instance->USART_SWI), USART_PARITY_NONE); -- // Set data byte to one stopbit -- status |= usart_sync_set_stopbits(&(instance->USART_SWI), USART_STOP_BITS_ONE); -- // Set baudrate to 230400 -- status |= usart_sync_set_baud_rate(&(instance->USART_SWI), 230400); -- // Enable SWI UART -- status |= usart_sync_enable(&(instance->USART_SWI)); -- return status; --} -- --/** \brief HAL implementation of SWI UART deinit. -- * \param[in] instance instance -- * \return ATCA_SUCCESS -- */ --ATCA_STATUS swi_uart_deinit(ATCASWIMaster_t *instance) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- -- usart_sync_disable(&(instance->USART_SWI)); -- -- return status; --} -- --/** \brief HAL implementation of SWI UART change baudrate. -- * \param[in] instance instance -- * \param[in] baudrate (typically 230400 or 115200) -- */ --void swi_uart_setbaud(ATCASWIMaster_t *instance, uint32_t baudrate) --{ -- // Set baudrate for UART module -- delay_us(50); -- usart_sync_set_baud_rate(&(instance->USART_SWI), baudrate); -- --} -- -- --/** \brief HAL implementation of SWI UART change mode. -- * \param[in] instance instance -- * \param[in] mode (TRANSMIT_MODE or RECEIVE_MODE) -- */ --void swi_uart_mode(ATCASWIMaster_t *instance, uint8_t mode) --{ -- -- usart_sync_disable(&(instance->USART_SWI)); -- -- if (mode == TRANSMIT_MODE) -- { -- // Set baudrate to 230400 -- usart_sync_set_baud_rate(&(instance->USART_SWI), 230400); -- // Disable Receiver -- hri_sercomusart_clear_CTRLB_RXEN_bit(&(instance->USART_SWI.device.hw)); -- hri_sercomusart_set_CTRLB_TXEN_bit(&(instance->USART_SWI.device.hw)); -- } -- else if (mode == RECEIVE_MODE) -- { -- // Set baudrate to 160000 -- usart_sync_set_baud_rate(&(instance->USART_SWI), 160000); -- // Enable Receiver -- hri_sercomusart_clear_CTRLB_TXEN_bit(&(instance->USART_SWI.device.hw)); -- hri_sercomusart_set_CTRLB_RXEN_bit(&(instance->USART_SWI.device.hw)); -- } -- usart_sync_enable(&(instance->USART_SWI)); -- instance->bus_index &= 0x07; --} -- --/** \brief discover UART buses available for this hardware -- * this maintains a list of logical to physical bus mappings freeing the application -- * of the a-priori knowledge -- * \param[in] swi_uart_buses - an array of logical bus numbers -- * \param[in] max_buses - maximum number of buses the app wants to attempt to discover -- */ --void swi_uart_discover_buses(int swi_uart_buses[], int max_buses) --{ -- /* if every SERCOM was a likely candidate bus, then would need to initialize the entire array to all SERCOM n numbers. -- * As an optimization and making discovery safer, make assumptions about bus-num / SERCOM map based on SAMD21 Xplained Pro board -- * If you were using a raw SAMD21 on your own board, you would supply your own bus numbers based on your particular hardware configuration. -- */ -- swi_uart_buses[0] = 4; // default samd21 for xplained dev board --} -- --/** \brief HAL implementation of SWI UART send byte over ASF. This function send one byte over UART -- * \param[in] instance instance -- * \param[in] data number of byte to send -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS swi_uart_send_byte(ATCASWIMaster_t *instance, uint8_t data) --{ -- uint8_t retries = 2; -- int32_t byte_sent = 0; -- --#ifdef DEBUG_PIN -- gpio_toggle_pin_level(PA20); --#endif -- // Send one byte over UART module -- while ((retries > 0) && (byte_sent < 1)) -- { -- byte_sent = io_write(&(instance->USART_SWI.io), &data, 1); -- retries--; -- } --#ifdef DEBUG_PIN -- gpio_toggle_pin_level(PA20); --#endif -- if (byte_sent <= 0) -- { -- return ATCA_TIMEOUT; -- } -- else -- { -- return ATCA_SUCCESS; -- } --} -- --/** \brief HAL implementation of SWI UART receive bytes over ASF. This function receive one byte over UART -- * \param[in] instance instance -- * \param[out] data pointer to space to receive the data -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS swi_uart_receive_byte(ATCASWIMaster_t *instance, uint8_t *data) --{ -- int32_t byte_sent = 0; -- uint8_t retries = 2; -- --#ifdef DEBUG_PIN -- gpio_toggle_pin_level(PA21); --#endif -- // Receive one byte over UART module -- while ((retries > 0) && (byte_sent < 1)) -- { -- byte_sent = io_read(&(instance->USART_SWI.io), data, 1); -- retries--; -- } --#ifdef DEBUG_PIN -- gpio_toggle_pin_level(PA21); --#endif -- if (byte_sent <= 0) -- { -- return ATCA_TIMEOUT; -- } -- else -- { -- return ATCA_SUCCESS; -- } --} -- --/** @} */ -diff --git a/lib/hal/swi_uart_samd21_start.h b/lib/hal/swi_uart_samd21_start.h -deleted file mode 100644 -index e039228ef7c3..000000000000 ---- a/lib/hal/swi_uart_samd21_start.h -+++ /dev/null -@@ -1,80 +0,0 @@ --/** -- * \file -- * -- * \brief Atmel Crypto Auth hardware interface object -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef SWI_UART_SAMD21_START_H_ --#define SWI_UART_SAMD21_START_H_ -- --#include --#include --#include "atmel_start.h" --#include "cryptoauthlib.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- -- --/** \brief -- - this HAL implementation assumes you've included the ASF SERCOM UART libraries in your project, otherwise, -- the HAL layer will not compile because the ASF UART drivers are a dependency * -- */ -- --#define MAX_SWI_BUSES 6 // SAMD21 has up to 6 SERCOMS that can be configured as UART -- --#define RECEIVE_MODE 0 // UART Receive mode, RX enabled --#define TRANSMIT_MODE 1 // UART Transmit mode, RX disabled --#define RX_DELAY 10 --#define TX_DELAY 93 --/** \brief this is the hal_data for ATCA HAL for ASF SERCOM -- */ --typedef struct atcaSWImaster --{ -- // struct usart_module for Atmel SWI interface -- struct usart_sync_descriptor USART_SWI; -- // for conveniences during interface release phase -- int bus_index; --} ATCASWIMaster_t; -- --ATCA_STATUS swi_uart_init(ATCASWIMaster_t *instance); --ATCA_STATUS swi_uart_deinit(ATCASWIMaster_t *instance); --void swi_uart_setbaud(ATCASWIMaster_t *instance, uint32_t baudrate); --void swi_uart_mode(ATCASWIMaster_t *instance, uint8_t mode); --void swi_uart_discover_buses(int swi_uart_buses[], int max_buses); -- --ATCA_STATUS swi_uart_send_byte(ATCASWIMaster_t *instance, uint8_t data); --ATCA_STATUS swi_uart_receive_byte(ATCASWIMaster_t *instance, uint8_t *data); --/** @} */ -- --#endif // SWI_UART_ASF_H -diff --git a/lib/hal/swi_uart_xmega_a3bu_asf.c b/lib/hal/swi_uart_xmega_a3bu_asf.c -deleted file mode 100644 -index 26785cd795ee..000000000000 ---- a/lib/hal/swi_uart_xmega_a3bu_asf.c -+++ /dev/null -@@ -1,258 +0,0 @@ --/** -- * \file -- * \brief ATXMEGA's ATCA Hardware abstraction layer for SWI interface over XMEGA UART drivers. -- * -- * Prerequisite: add UART Polled support to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#include --#include --#include "swi_uart_xmega_a3bu_asf.h" --#include "basic/atca_helpers.h" -- --#define DEBUG_PIN 1 -- --#ifdef DEBUG_PIN -- #define DEBUG_PIN_1 IOPORT_CREATE_PIN(PORTB, 0) -- #define DEBUG_PIN_2 IOPORT_CREATE_PIN(PORTB, 1) --#endif --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- --/** \brief usart configuration struct */ --static usart_serial_options_t config_usart; --/** \brief sysclk_get_per_hz value */ --static uint32_t u32sysclk; -- -- --/** \brief -- - this HAL implementation assumes you've included the ASF SERCOM UART libraries in your project, otherwise, -- the HAL layer will not compile because the ASF UART drivers are a dependency * -- */ -- --/** \brief Implementation of SWI UART init. -- * \param[in] instance instance -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS swi_uart_init(ATCASWIMaster_t *instance) --{ --#ifdef DEBUG_PIN -- ioport_init(); -- ioport_set_pin_dir(DEBUG_PIN_1, IOPORT_DIR_OUTPUT); -- ioport_set_pin_dir(DEBUG_PIN_2, IOPORT_DIR_OUTPUT); -- gpio_set_pin_high(DEBUG_PIN_1); -- gpio_set_pin_high(DEBUG_PIN_2); --#endif -- ATCA_STATUS status = ATCA_SUCCESS; -- -- //Save sysclk_get_per_hz value -- u32sysclk = sysclk_get_per_hz(); -- // Set data size to 7 -- config_usart.charlength = USART_CHSIZE_7BIT_gc; -- // Set parity to no parity -- config_usart.paritytype = USART_PMODE_DISABLED_gc; -- // Set data byte to one stopbit -- config_usart.stopbits = false; -- // Set baudrate to 230400 -- config_usart.baudrate = 230400; -- -- switch (instance->bus_index) -- { -- case 0: instance->usart_instance = &USARTC0; break; -- case 1: instance->usart_instance = &USARTC1; break; -- case 2: instance->usart_instance = &USARTD0; break; -- case 3: instance->usart_instance = &USARTD1; break; -- case 4: instance->usart_instance = &USARTE0; break; -- case 5: instance->usart_instance = &USARTF0; break; -- } -- status = usart_serial_init(instance->usart_instance, &config_usart); -- return status; --} -- --/** \brief Implementation of SWI UART deinit. -- * \param[in] instance instance -- * \return ATCA_SUCCESS -- */ --ATCA_STATUS swi_uart_deinit(ATCASWIMaster_t *instance) --{ -- ATCA_STATUS status = ATCA_SUCCESS; -- -- instance->usart_instance = NULL; -- return status; --} -- --/** \brief implementation of SWI UART change baudrate. -- * \param[in] instance instance -- * \param[in] baudrate (typically 230400 , 160000 or 115200) -- */ --void swi_uart_setbaud(ATCASWIMaster_t *instance, uint32_t baudrate) --{ -- // Set baudrate for UART module -- usart_set_baudrate(instance->usart_instance, baudrate, u32sysclk); --} -- -- --/** \brief implementation of SWI UART change mode. -- * \param[in] instance instance -- * \param[in] mode (TRANSMIT_MODE or RECEIVE_MODE) -- */ --void swi_uart_mode(ATCASWIMaster_t *instance, uint8_t mode) --{ -- switch (mode) -- { -- case TRANSMIT_MODE: -- usart_set_baudrate(instance->usart_instance, 230400, u32sysclk); -- break; -- case RECEIVE_MODE: -- //Reset UART RX buffer. -- usart_rx_disable(instance->usart_instance); -- usart_rx_enable(instance->usart_instance); -- break; -- default: -- break; -- } -- --} -- --/** \brief discover UART buses available for this hardware -- * this maintains a list of logical to physical bus mappings freeing the application -- * of the a-priori knowledge -- * \param[in] swi_uart_buses - an array of logical bus numbers -- * \param[in] max_buses - maximum number of buses the app wants to attempt to discover -- */ --void swi_uart_discover_buses(int swi_uart_buses[], int max_buses) --{ -- /* if every PORT was a likely candidate bus, then would need to initialize the entire array to all PORT n numbers. -- * As an optimization and making discovery safer, make assumptions about bus-num / PORT map based on XMEGA-A3BU Xplained board -- * If you were using a raw XMEGA on your own board, you would supply your own bus numbers based on your particular hardware configuration. -- */ -- swi_uart_buses[0] = 4; // default xmega-a3bu for xplained dev board --} -- --/** \brief HAL implementation of SWI UART send byte over ASF. This function send one byte over UART -- * \param[in] instance instance -- * \param[in] data byte to send -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS swi_uart_send_byte(ATCASWIMaster_t *instance, uint8_t data) --{ -- int8_t timeout = 0x7F; -- bool data_reg_empty = false; -- ATCA_STATUS status = ATCA_COMM_FAIL; -- -- // Send one byte over UART module --#ifdef DEBUG_PIN -- gpio_toggle_pin(DEBUG_PIN_1); --#endif -- // Send one byte over UART module -- timeout = 0x7F; -- while ((timeout > 0) && (data_reg_empty == false)) -- { -- data_reg_empty = usart_data_register_is_empty(instance->usart_instance); -- timeout--; -- } -- if (data_reg_empty) -- { -- usart_put(instance->usart_instance, data); -- while (!usart_tx_is_complete(instance->usart_instance)) -- { -- ; -- } -- usart_clear_tx_complete(instance->usart_instance); -- status = ATCA_SUCCESS; -- } --#ifdef DEBUG_PIN -- gpio_toggle_pin(DEBUG_PIN_1); --#endif -- if (timeout > 0) -- { -- return status; -- } -- else -- { -- return ATCA_TIMEOUT; -- } --} -- --/** \brief HAL implementation of SWI UART receive bytes over ASF. This function receive one byte over UART -- * \param[in] instance instance -- * \param[out] data pointer to space to receive the data -- * \return ATCA_SUCCESS on success, otherwise an error code. -- */ --ATCA_STATUS swi_uart_receive_byte(ATCASWIMaster_t *instance, uint8_t *data) --{ -- int8_t timeout, retries = 0x2; // This retry is used to compensate the baudrate that do not match when receiving response -- -- *data = 0xFF; -- bool rx_complete = false; -- ATCA_STATUS status = ATCA_COMM_FAIL; --#ifdef DEBUG_PIN -- gpio_toggle_pin(DEBUG_PIN_2); --#endif -- // Receive one byte over UART module -- while ((retries > 0) && (status != ATCA_SUCCESS)) -- { -- timeout = 0x7F; retries--; -- while ((timeout > 0) && (rx_complete == false)) -- { -- rx_complete = usart_rx_is_complete(instance->usart_instance); -- timeout--; -- } -- -- if (rx_complete) -- { -- *data = usart_get(instance->usart_instance); -- if ((*data >= 0x70) && (*data <= 0x7F)) -- { -- status = ATCA_SUCCESS; -- } -- else -- { -- status = ATCA_COMM_FAIL; -- } -- } -- } --#ifdef DEBUG_PIN -- gpio_toggle_pin(DEBUG_PIN_2); --#endif -- if (timeout > 0) -- { -- return status; -- } -- else -- { -- return ATCA_TIMEOUT; -- } --} -- --/** @} */ -diff --git a/lib/hal/swi_uart_xmega_a3bu_asf.h b/lib/hal/swi_uart_xmega_a3bu_asf.h -deleted file mode 100644 -index e9bfffc58fc6..000000000000 ---- a/lib/hal/swi_uart_xmega_a3bu_asf.h -+++ /dev/null -@@ -1,83 +0,0 @@ --/** -- * \file -- * \brief ATXMEGA's ATCA Hardware abstraction layer for SWI interface over XMEGA UART drivers. -- * -- * Prerequisite: add UART Polled support to application in Atmel Studio -- * -- * \copyright (c) 2017 Microchip Technology Inc. and its subsidiaries. -- * You may use this software and any derivatives exclusively with -- * Microchip products. -- * -- * \page License -- * -- * (c) 2017 Microchip Technology Inc. and its subsidiaries. You may use this -- * software and any derivatives exclusively with Microchip products. -- * -- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -- * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -- * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A -- * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION -- * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. -- * -- * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, -- * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND -- * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS -- * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -- * FULLEST EXTENT ALLOWED BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN -- * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -- * -- * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE -- * TERMS. -- */ -- --#ifndef SWI_UART_XMEGA_A3BU_ASF_H_ --#define SWI_UART_XMEGA_A3BU_ASF_H_ -- --#include --#include "cryptoauthlib.h" --#include "serial.h" -- --/** \defgroup hal_ Hardware abstraction layer (hal_) -- * -- * \brief -- * These methods define the hardware abstraction layer for communicating with a CryptoAuth device -- * -- @{ */ -- -- --/** \brief -- - this HAL implementation assumes you've included the ASF UART libraries in your project, otherwise, -- the HAL layer will not compile because the ASF UART drivers are a dependency * -- */ -- --#define MAX_SWI_BUSES 6 // XMEGA A3BU has up to 6 ports -- --#define RECEIVE_MODE 0 // UART Receive mode, RX enabled --#define TRANSMIT_MODE 1 // UART Transmit mode, RX disabled --#define RX_DELAY 10 // Delay before responses come --#define TX_DELAY 90 // Delay before new flag is sent -- --/** \brief this is the hal_data for ATCA HAL for SWI UART -- */ --typedef struct atcaSWImaster --{ -- // struct usart_module for Atmel SWI interface -- usart_if usart_instance; -- // for conveniences during interface release phase -- int bus_index; --} ATCASWIMaster_t; -- -- --ATCA_STATUS swi_uart_init(ATCASWIMaster_t *instance); --ATCA_STATUS swi_uart_deinit(ATCASWIMaster_t *instance); --void swi_uart_setbaud(ATCASWIMaster_t *instance, uint32_t baudrate); --void swi_uart_mode(ATCASWIMaster_t *instance, uint8_t mode); --void swi_uart_discover_buses(int swi_uart_buses[], int max_buses); -- --ATCA_STATUS swi_uart_send_byte(ATCASWIMaster_t *instance, uint8_t data); --ATCA_STATUS swi_uart_receive_byte(ATCASWIMaster_t *instance, uint8_t *data); -- --/** @} */ -- --#endif // SWI_UART_XMEGA_A3BU_ASF_H diff --git a/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0002-lib-apply-library-version-number-to-CMake-VERSION-pr.patch b/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0002-lib-apply-library-version-number-to-CMake-VERSION-pr.patch new file mode 100644 index 000000000..031d2033e --- /dev/null +++ b/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0002-lib-apply-library-version-number-to-CMake-VERSION-pr.patch @@ -0,0 +1,30 @@ +From: Gabriel Valcazar +Date: Mon, 4 Nov 2019 16:11:48 +0100 +Subject: [PATCH 2/6] lib: apply library version number to CMake VERSION + property + +This way, CMake will generate a shared library with the version number and an +additional symlink without it. This avoids bitbake errors that appear when +creating *-dev packages, as Yocto development packages should only include +the soname symlinks instead of the actual library file. + +https://jira.digi.com/browse/DEL-6826 + +Signed-off-by: Gabriel Valcazar +--- + lib/CMakeLists.txt | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt +index b198d1f..88533f1 100644 +--- a/lib/CMakeLists.txt ++++ b/lib/CMakeLists.txt +@@ -93,6 +93,8 @@ endif() + + add_library(cryptoauth ${CRYPTOAUTH_SRC} ${ATCACERT_DEF_SRC}) + ++set_property(TARGET cryptoauth PROPERTY VERSION "${VERSION}") ++ + set_property(TARGET cryptoauth PROPERTY C_STANDARD 99) + + if(ATCA_PRINTF) diff --git a/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0003-Build-cryptochip-cmd-processor-application-along-wit.patch b/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0003-Build-cryptochip-cmd-processor-application-along-wit.patch deleted file mode 100644 index e25c35d85..000000000 --- a/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0003-Build-cryptochip-cmd-processor-application-along-wit.patch +++ /dev/null @@ -1,50 +0,0 @@ -From: Gabriel Valcazar -Date: Mon, 26 Feb 2018 11:42:50 +0100 -Subject: [PATCH 1/2] Build cryptochip-cmd-processor application along with the - library - -This new test application is more complete than ecc-test-main. It includes a -command line with different test runs for the chip's basic functionality, -helper functions, certificate functions and allows the configuration to be -read, among other things. - -Hardcode the app to use the ATECC508A and remove all code that is specific for -other chips. - -https://jira.digi.com/browse/DEL-5763 - -Signed-off-by: Gabriel Valcazar ---- - Makefile | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -diff --git a/Makefile b/Makefile -index a471428..c57b1bf 100644 ---- a/Makefile -+++ b/Makefile -@@ -7,7 +7,7 @@ SUBDIRS= lib test - - .PHONY: tgt_lib tgt_test clean - --all: tgt_lib tgt_test ecc-test -+all: tgt_lib tgt_test ecc-test cmd-processor - - %.o: %.c - $(CC) $(CFLAGS) -o $@ -c $< -@@ -22,11 +22,15 @@ ecc-test: tgt_lib tgt_test - $(CC) -c ecc-test-main.c $(CFLAGS) $(LDFLAGS) -I ./lib/ -I ./test/ - $(CC) -o ecc-test-main ecc-test-main.o $(LDFLAGS) test/tls/atcatls_tests.o -L lib -L test -lm -lc -lrt -lcryptoauth -lunity - -+cmd-processor: tgt_lib tgt_test -+ $(CC) -o cryptochip-cmd-processor test/*.o $(LDFLAGS) test/*/*.o -L lib -L test -lcryptoauth -+ - install: - for a in $(SUBDIRS); do $(MAKE) -C $$a $@; done - install -d $(DESTDIR)/usr/bin - install -m 0755 ecc-test-main $(DESTDIR)/usr/bin/ -+ install -m 0755 cryptochip-cmd-processor $(DESTDIR)/usr/bin - - clean: -- rm -f *.o *.a ecc-test-main -+ rm -f *.o *.a ecc-test-main cryptochip-cmd-processor - $(foreach subdir,$(basename $(SUBDIRS)),$(MAKE) -w -C $(subdir) clean;) diff --git a/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0003-pkcs11-rename-template-configuration-file-to-its-int.patch b/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0003-pkcs11-rename-template-configuration-file-to-its-int.patch new file mode 100644 index 000000000..a92d49e14 --- /dev/null +++ b/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0003-pkcs11-rename-template-configuration-file-to-its-int.patch @@ -0,0 +1,84 @@ +From: Gabriel Valcazar +Date: Thu, 7 Nov 2019 13:43:53 +0100 +Subject: [PATCH 3/6] pkcs11: rename template configuration file to its + intended name + +Otherwise, users will need to manually rename the file in the rootfs to use +the pkcs11 feature. + +https://jira.digi.com/browse/DEL-6835 + +Signed-off-by: Gabriel Valcazar +--- + CMakeLists.txt | 4 ++-- + app/pkcs11/0.conf | 19 +++++++++++++++++++ + app/pkcs11/slot.conf.tmpl | 19 ------------------- + 3 files changed, 21 insertions(+), 21 deletions(-) + create mode 100644 app/pkcs11/0.conf + delete mode 100644 app/pkcs11/slot.conf.tmpl + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 9326fd1..00214d3 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -80,8 +80,8 @@ install(CODE " + install(DIRECTORY DESTINATION ${DEFAULT_STORE_PATH}) + install(CODE "execute_process(COMMAND chmod 1777 ${DEFAULT_STORE_PATH})") + install(CODE " +- if(NOT EXISTS ${DEFAULT_STORE_PATH}/slot.conf.tmpl) +- file(INSTALL ${PROJECT_SOURCE_DIR}/app/pkcs11/slot.conf.tmpl ++ if(NOT EXISTS ${DEFAULT_STORE_PATH}/0.conf) ++ file(INSTALL ${PROJECT_SOURCE_DIR}/app/pkcs11/0.conf + DESTINATION ${DEFAULT_STORE_PATH}) + endif() + ") +diff --git a/app/pkcs11/0.conf b/app/pkcs11/0.conf +new file mode 100644 +index 0000000..b637abd +--- /dev/null ++++ b/app/pkcs11/0.conf +@@ -0,0 +1,19 @@ ++# Reserved Configuration for a device ++# The objects in this file will be created and marked as undeletable ++# These are processed in order. Configuration parameters must be comma ++# delimited and may not contain spaces ++ ++interface = i2c,0xB0 ++freeslots = 1,2,3 ++ ++# Slot 0 is the primary private key ++object = private,device,0 ++ ++# Slot 10 is the certificate data for the device's public key ++#object = certificate,device,10 ++ ++# Slot 12 is the intermedate/signer certificate data ++#object = certificate,signer,12 ++ ++# Slot 15 is a public key ++object = public,root,15 +diff --git a/app/pkcs11/slot.conf.tmpl b/app/pkcs11/slot.conf.tmpl +deleted file mode 100644 +index b637abd..0000000 +--- a/app/pkcs11/slot.conf.tmpl ++++ /dev/null +@@ -1,19 +0,0 @@ +-# Reserved Configuration for a device +-# The objects in this file will be created and marked as undeletable +-# These are processed in order. Configuration parameters must be comma +-# delimited and may not contain spaces +- +-interface = i2c,0xB0 +-freeslots = 1,2,3 +- +-# Slot 0 is the primary private key +-object = private,device,0 +- +-# Slot 10 is the certificate data for the device's public key +-#object = certificate,device,10 +- +-# Slot 12 is the intermedate/signer certificate data +-#object = certificate,signer,12 +- +-# Slot 15 is a public key +-object = public,root,15 diff --git a/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0004-lib-install-pkg-config-file-and-header-files.patch b/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0004-lib-install-pkg-config-file-and-header-files.patch new file mode 100644 index 000000000..82f33a002 --- /dev/null +++ b/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0004-lib-install-pkg-config-file-and-header-files.patch @@ -0,0 +1,82 @@ +From: Gabriel Valcazar +Date: Thu, 7 Nov 2019 14:16:53 +0100 +Subject: [PATCH 4/6] lib: install pkg-config file and header files + +These are needed to be able to develop using cryptoauthlib. + +https://jira.digi.com/browse/DEL-6826 + +Signed-off-by: Gabriel Valcazar +--- + CMakeLists.txt | 15 +++++++++++++++ + lib/CMakeLists.txt | 4 ++++ + lib/cryptoauthlib.pc.in | 11 +++++++++++ + 3 files changed, 30 insertions(+) + create mode 100644 lib/cryptoauthlib.pc.in + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 00214d3..f95736d 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -33,6 +33,10 @@ set(DEFAULT_CONF_PATH "${CMAKE_INSTALL_FULL_SYSCONFDIR}/${PROJECT_NAME}" CACHE + STRING "The default location of ${PROJECT_NAME}.conf") + set(DEFAULT_STORE_PATH "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/${PROJECT_NAME}" CACHE + STRING "The default location of the filestore directory") ++set(DEFAULT_PKGCONFIG_PATH "${DEFAULT_LIB_PATH}/pkgconfig" CACHE ++ STRING "The default location of the library's pkg-config file") ++set(DEFAULT_INCLUDE_PATH "${CMAKE_INSTALL_FULL_INCLUDEDIR}" CACHE ++ STRING "The default location of the library's header files") + endif() + + set(DEFAULT_CONF_FILE_NAME "${PROJECT_NAME}.conf" CACHE +@@ -49,6 +53,9 @@ endif() + # Set up a default configuration file to install + configure_file(${PROJECT_SOURCE_DIR}/app/pkcs11/cryptoauthlib.conf.in ${PROJECT_BINARY_DIR}/${DEFAULT_CONF_FILE_NAME}) + ++# Set up the pkg-config file ++configure_file(${PROJECT_SOURCE_DIR}/lib/${PROJECT_NAME}.pc.in ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY) ++ + message(STATUS "Building Configuration: ${CMAKE_BUILD_TYPE}") + + # Packaging +@@ -86,3 +93,11 @@ install(CODE " + endif() + ") + ++install(DIRECTORY DESTINATION ${DEFAULT_PKGCONFIG_PATH}) ++install(CODE " ++ if(NOT EXISTS ${DEFAULT_PKGCONFIG_PATH}/${PROJECT_NAME}.pc) ++ file(INSTALL ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pc ++ DESTINATION ${DEFAULT_PKGCONFIG_PATH}) ++ endif() ++ ") ++ +diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt +index 88533f1..d4749ec 100644 +--- a/lib/CMakeLists.txt ++++ b/lib/CMakeLists.txt +@@ -128,3 +128,7 @@ endif() + if(DEFAULT_LIB_PATH) + install(TARGETS ${PROJECT_NAME} DESTINATION ${DEFAULT_LIB_PATH}) + endif() ++ ++if(DEFAULT_INCLUDE_PATH) ++install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" DESTINATION "${DEFAULT_INCLUDE_PATH}" FILES_MATCHING PATTERN "*.h") ++endif() +diff --git a/lib/cryptoauthlib.pc.in b/lib/cryptoauthlib.pc.in +new file mode 100644 +index 0000000..e682913 +--- /dev/null ++++ b/lib/cryptoauthlib.pc.in +@@ -0,0 +1,11 @@ ++prefix=/usr ++exec_prefix=${prefix} ++libdir=@CMAKE_INSTALL_FULL_LIBDIR@ ++includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ ++ ++Name: @PROJECT_NAME@ ++Description: Atmel Cryptochip library for ATECC508A ++Version: @VERSION@ ++ ++Libs: -L${libdir} -lcryptoauth ++Cflags: -I${includedir} -I${includedir}/@PROJECT_NAME@ diff --git a/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0005-test-add-CMakeLists.txt.patch b/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0005-test-add-CMakeLists.txt.patch new file mode 100644 index 000000000..2a6eb5d44 --- /dev/null +++ b/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0005-test-add-CMakeLists.txt.patch @@ -0,0 +1,96 @@ +From: Gabriel Valcazar +Date: Thu, 7 Nov 2019 16:36:35 +0100 +Subject: [PATCH 5/6] test: add CMakeLists.txt + +This file was ported form the master branch to be able to compile the +cryptoauth_test app. Additional installation instructions were added as well. + +Move the ATCA_HAL_I2C build option to the root CMake file to enable it for both +the library and the test app. + +https://jira.digi.com/browse/DEL-6826 + +Signed-off-by: Gabriel Valcazar +--- + CMakeLists.txt | 3 +++ + lib/CMakeLists.txt | 1 - + test/CMakeLists.txt | 44 ++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 47 insertions(+), 1 deletion(-) + create mode 100644 test/CMakeLists.txt + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 429c06c..a490557 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,6 +1,9 @@ + cmake_minimum_required(VERSION 2.6.4) + project (cryptoauthlib) + ++# Enable the I2C build option at a global level by default to use it for both the library and the test app ++option(ATCA_HAL_I2C "Include the I2C Hal Driver - Linux & MCU only" ON) ++ + # Set the current release version + set(VERSION "2018.10.26") + set(VERSION_MAJOR 2028) +diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt +index 88533f1..6a00f7c 100644 +--- a/lib/CMakeLists.txt ++++ b/lib/CMakeLists.txt +@@ -3,7 +3,6 @@ project(cryptoauth) + + # Various Options for Build + option(ATCA_HAL_KIT_HID "Include the HID HAL Driver") +-option(ATCA_HAL_I2C "Include the I2C Hal Driver - Linux & MCU only" ON) + option(ATCA_HAL_CUSTOM "Include support for Custom/Plug-in Hal Driver" ON) + option(ATCA_PRINTF "Enable Debug print statements in library") + option(ATCA_PKCS11 "Build PKCS11 Library") +diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt +new file mode 100644 +index 0000000..7155f38 +--- /dev/null ++++ b/test/CMakeLists.txt +@@ -0,0 +1,44 @@ ++cmake_minimum_required(VERSION 2.6.4) ++project (cryptoauth_test) ++ ++file(GLOB TEST_ATCACERT_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "atcacert/*.c") ++file(GLOB TEST_JWT_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "jwt/*.c") ++file(GLOB TEST_TNG_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "tng/*.c") ++file(GLOB TEST_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c") ++ ++if(ATCA_HAL_KIT_HID) ++add_definitions(-DATCA_HAL_KIT_HID) ++endif(ATCA_HAL_KIT_HID) ++ ++if(ATCA_HAL_KIT_CDC) ++add_definitions(-DATCA_HAL_KIT_CDC) ++endif(ATCA_HAL_KIT_CDC) ++ ++if(ATCA_HAL_I2C) ++add_definitions(-DATCA_HAL_I2C) ++endif(ATCA_HAL_I2C) ++ ++if(ATCA_HAL_CUSTOM) ++add_definitions(-DATCA_HAL_CUSTOM) ++endif() ++ ++add_executable(cryptoauth_test ${TEST_SRC} ${TEST_TNG_SRC} ${TEST_JWT_SRC} ${TEST_ATCACERT_SRC}) ++ ++include_directories(cryptoauth_test ${CMAKE_CURRENT_SOURCE_DIR}/../ ${CMAKE_CURRENT_SOURCE_DIR}/../lib) ++ ++target_link_libraries(cryptoauth_test cryptoauth) ++ ++if(UNIX) ++target_link_libraries(cryptoauth_test pthread) ++endif() ++ ++set(DEFAULT_BIN_PATH "${CMAKE_INSTALL_FULL_BINDIR}" CACHE ++ STRING "The default absolute test app path") ++ ++install(DIRECTORY DESTINATION ${DEFAULT_BIN_PATH}) ++install(CODE " ++ if(NOT EXISTS ${DEFAULT_BIN_PATH}/cryptoauth_test) ++ file(INSTALL ${PROJECT_BINARY_DIR}/cryptoauth_test ++ DESTINATION ${DEFAULT_BIN_PATH}) ++ endif() ++ ") diff --git a/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0004-Remove-unnecessary-code-from-cryptochip-cmd-processo.patch b/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0006-Remove-unnecessary-code-from-cryptoauth_test.patch similarity index 84% rename from meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0004-Remove-unnecessary-code-from-cryptochip-cmd-processo.patch rename to meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0006-Remove-unnecessary-code-from-cryptoauth_test.patch index cd9f30cf1..b30dc4204 100644 --- a/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0004-Remove-unnecessary-code-from-cryptochip-cmd-processo.patch +++ b/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib/0006-Remove-unnecessary-code-from-cryptoauth_test.patch @@ -1,24 +1,27 @@ From: Gabriel Valcazar -Date: Fri, 23 Feb 2018 13:50:29 +0100 -Subject: [PATCH 2/2] Remove unnecessary code from cryptochip-cmd-processor +Date: Thu, 31 Oct 2019 16:15:30 +0100 +Subject: [PATCH 6/6] Remove unnecessary code from cryptoauth_test Some test commands apply to chips other than the ATECC508A, and can cause errors when used incorrectly. Remove all code that doesn't apply to our platforms. -https://jira.digi.com/browse/DEL-5763 +https://jira.digi.com/browse/DEL-6826 Signed-off-by: Gabriel Valcazar --- - test/cmd-processor.c | 348 ++------------------------------------------------- - 1 file changed, 13 insertions(+), 335 deletions(-) + test/cmd-processor.c | 360 ++------------------------------------------------- + 1 file changed, 12 insertions(+), 348 deletions(-) diff --git a/test/cmd-processor.c b/test/cmd-processor.c -index c8c60e0..592157e 100644 +index c0f819f..07ecf2a 100644 --- a/test/cmd-processor.c +++ b/test/cmd-processor.c -@@ -92,10 +92,6 @@ static void sernum(void); - static void discover(void); +@@ -61,13 +61,8 @@ static void lock_config(void); + static void lock_data(void); + static void info(void); + static void sernum(void); +-static void discover(void); static void select_device(ATCADeviceType device_type); static int run_test(void* fptest); -static void select_204(void); @@ -28,7 +31,7 @@ index c8c60e0..592157e 100644 static void run_basic_tests(void); static void run_unit_tests(void); static void run_otpzero_tests(void); -@@ -103,20 +99,11 @@ static void run_helper_tests(void); +@@ -75,10 +70,6 @@ static void run_helper_tests(void); static void help(void); static int parse_cmd(const char *command); static void run_all_tests(void); @@ -36,43 +39,41 @@ index c8c60e0..592157e 100644 -static void set_clock_divider_m0(void); -static void set_clock_divider_m1(void); -static void set_clock_divider_m2(void); + static void tng22_tests(void); + static void tngtn_tests(void); - static const char* argv[] = { "manual", "-v" }; +@@ -87,11 +78,6 @@ static const char* argv[] = { "manual", "-v" }; static t_menu_info mas_menu_info[] = { - { "help", "Display Menu", help }, -- { "discover", "Discover Buses and Devices", discover }, -- { "204", "Set Target Device to ATECC204A", select_204 }, -- { "108", "Set Target Device to ATECC108A", select_108 }, -- { "508", "Set Target Device to ATECC508A", select_508 }, -- { "608", "Set Target Device to ATECC608A", select_608 }, - { "info", "Get the Chip Revision", info }, - { "sernum", "Get the Chip Serial Number", sernum }, - { "basic", "Run Basic Test on Selected Device", run_basic_tests }, -@@ -135,12 +122,9 @@ static t_menu_info mas_menu_info[] = - { "cio", "Run Unit Test on Cert I/O", (fp_menu_handler)certio_unit_tests }, + { "help", "Display Menu", help }, +- { "discover", "Discover Buses and Devices", discover }, +- { "204", "Set Target Device to ATSHA204A", select_204 }, +- { "108", "Set Target Device to ATECC108A", select_108 }, +- { "508", "Set Target Device to ATECC508A", select_508 }, +- { "608", "Set Target Device to ATECC608A", select_608 }, + { "info", "Get the Chip Revision", info }, + { "sernum", "Get the Chip Serial Number", sernum }, + { "rand", "Generate Some Random Numbers", (fp_menu_handler)do_randoms }, +@@ -107,9 +93,6 @@ static t_menu_info mas_menu_info[] = + { "unit", "Run Unit Test on Selected Device", run_unit_tests }, + { "otpzero", "Zero Out OTP Zone", run_otpzero_tests }, + { "util", "Run Helper Function Tests", run_helper_tests }, +- { "clkdivm0", "Set ATECC608A to ClockDivider M0(0x00)", set_clock_divider_m0 }, +- { "clkdivm1", "Set ATECC608A to ClockDivider M1(0x05)", set_clock_divider_m1 }, +- { "clkdivm2", "Set ATECC608A to ClockDivider M2(0x0D)", set_clock_divider_m2 }, #endif - #ifdef TEST_SW_CRYPTO -- { "crypto", "Run Unit Tests for Software Crypto Functions", atca_crypto_sw_tests }, -+ { "crypto", "Run Unit Tests for Software Crypto Functions", (fp_menu_handler)atca_crypto_sw_tests }, - #endif - { "all", "Run all unit tests, locking as needed.", run_all_tests }, -- { "clkdivm0", "Set ATECC608A to ClockDivider M0(0x00)", set_clock_divider_m0}, -- { "clkdivm1", "Set ATECC608A to ClockDivider M1(0x05)", set_clock_divider_m1}, -- { "clkdivm2", "Set ATECC608A to ClockDivider M2(0x0D)", set_clock_divider_m2}, - { NULL, NULL, NULL }, - }; - -@@ -160,6 +144,8 @@ int main(int argc, char* argv[]) - return 1; - } + #ifndef DO_NOT_TEST_CERT + { "cd", "Run Unit Tests on Cert Data", (fp_menu_handler)certdata_unit_tests }, +@@ -130,6 +113,8 @@ int main(int argc, char* argv[]) + { + char buffer[1024]; + select_device(ATECC508A); + while (true) { printf("$ "); -@@ -230,96 +216,13 @@ static void help(void) +@@ -202,101 +187,13 @@ static void help(void) } } @@ -136,7 +137,7 @@ index c8c60e0..592157e 100644 - return status; - } - -- do +- do - { - // Read current config values - status = atcab_read_bytes_zone(ATCA_ZONE_CONFIG, 0, ATCA_CHIPMODE_OFFSET, &chip_mode, 1); @@ -148,8 +149,9 @@ index c8c60e0..592157e 100644 - - // Update the ATECC608A test config data so all the unit tests will run with the new chip mode - update_chip_mode(&test_ecc608_configdata[ATCA_CHIPMODE_OFFSET], 0xFF, 0xFF, chip_mode & ATCA_CHIPMODE_WATCHDOG_MASK, chip_mode & ATCA_CHIPMODE_CLOCK_DIV_MASK); -- -- } while (0); +- +- } +- while (0); - - atcab_release(); - return status; @@ -158,21 +160,26 @@ index c8c60e0..592157e 100644 static void run_basic_tests(void) { - if (gCfg->devtype == ATECC608A) +- { - check_clock_divider(); +- } run_test(RunAllBasicTests); } static void run_unit_tests(void) { - if (gCfg->devtype == ATECC608A) +- { - check_clock_divider(); +- } run_test(RunAllFeatureTests); } static void run_otpzero_tests(void) -@@ -453,37 +356,6 @@ static ATCA_STATUS do_randoms(void) +@@ -431,38 +328,6 @@ static ATCA_STATUS do_randoms(void) return status; } +- -static void discover(void) -{ - ATCAIfaceCfg ifaceCfgs[10]; @@ -185,7 +192,7 @@ index c8c60e0..592157e 100644 - ifaceCfgs[i].iface_type = ATCA_UNKNOWN_IFACE; - } - -- printf("Searching..."); +- printf("Searching...\r\n"); - atcab_cfg_discover(ifaceCfgs, sizeof(ifaceCfgs) / sizeof(ATCAIfaceCfg)); - for (i = 0; i < (int)(sizeof(ifaceCfgs) / sizeof(ATCAIfaceCfg)); i++) - { @@ -207,7 +214,7 @@ index c8c60e0..592157e 100644 static void info(void) { ATCA_STATUS status; -@@ -636,18 +508,7 @@ static ATCA_STATUS get_serial_no(uint8_t *sernum) +@@ -640,18 +505,7 @@ static ATCA_STATUS get_serial_no(uint8_t *sernum) static void select_device(ATCADeviceType device_type) { @@ -227,17 +234,19 @@ index c8c60e0..592157e 100644 } static int run_test(void* fptest) -@@ -670,9 +531,6 @@ static void run_all_tests(void) +@@ -674,11 +528,6 @@ static void run_all_tests(void) bool is_data_locked = false; int fails = 0; - if (gCfg->devtype == ATECC608A) +- { - check_clock_divider(); +- } - - status = is_device_locked(LOCK_ZONE_CONFIG, &is_config_locked); - if (status != ATCA_SUCCESS) - { -@@ -814,204 +672,24 @@ static ATCA_STATUS set_test_config(ATCADeviceType deviceType) + info(); + sernum(); + do_randoms(); +@@ -826,212 +675,27 @@ static ATCA_STATUS set_test_config(ATCADeviceType deviceType) gCfg->devtype = ATCA_DEV_UNKNOWN; gCfg->iface_type = ATCA_UNKNOWN_IFACE; @@ -260,23 +269,32 @@ index c8c60e0..592157e 100644 - break; - - case ATECC108A: --#if defined(ATCA_HAL_I2C) + #if defined(ATCA_HAL_I2C) - *gCfg = cfg_ateccx08a_i2c_default; - gCfg->devtype = deviceType; --#elif defined(ATCA_HAL_SWI) ++ *gCfg = cfg_ateccx08a_i2c_default; ++ gCfg->devtype = deviceType; + #elif defined(ATCA_HAL_SWI) - *gCfg = cfg_ateccx08a_swi_default; - gCfg->devtype = deviceType; --#elif defined(ATCA_HAL_KIT_HID) ++ *gCfg = cfg_ateccx08a_swi_default; ++ gCfg->devtype = deviceType; + #elif defined(ATCA_HAL_KIT_HID) - *gCfg = cfg_ateccx08a_kithid_default; - gCfg->devtype = deviceType; --#elif defined(ATCA_HAL_KIT_CDC) ++ *gCfg = cfg_ateccx08a_kithid_default; ++ gCfg->devtype = deviceType; + #elif defined(ATCA_HAL_KIT_CDC) - *gCfg = cfg_ateccx08a_kitcdc_default; - gCfg->devtype = deviceType; --#elif defined(ATCA_HAL_CUSTOM) ++ *gCfg = cfg_ateccx08a_kitcdc_default; ++ gCfg->devtype = deviceType; + #elif defined(ATCA_HAL_CUSTOM) - *gCfg = g_cfg_atecc108a_custom; --#else --#error "HAL interface is not selected"; --#endif ++ *gCfg = g_cfg_atecc508a_custom; + #else + #error "HAL interface is not selected"; + #endif - break; - - case ATECC508A: @@ -300,32 +318,23 @@ index c8c60e0..592157e 100644 - break; - - case ATECC608A: - #if defined(ATCA_HAL_I2C) +-#if defined(ATCA_HAL_I2C) - *gCfg = cfg_ateccx08a_i2c_default; - gCfg->devtype = deviceType; -+ *gCfg = cfg_ateccx08a_i2c_default; -+ gCfg->devtype = deviceType; - #elif defined(ATCA_HAL_SWI) +-#elif defined(ATCA_HAL_SWI) - *gCfg = cfg_ateccx08a_swi_default; - gCfg->devtype = deviceType; -+ *gCfg = cfg_ateccx08a_swi_default; -+ gCfg->devtype = deviceType; - #elif defined(ATCA_HAL_KIT_HID) +-#elif defined(ATCA_HAL_KIT_HID) - *gCfg = cfg_ateccx08a_kithid_default; - gCfg->devtype = deviceType; -+ *gCfg = cfg_ateccx08a_kithid_default; -+ gCfg->devtype = deviceType; - #elif defined(ATCA_HAL_KIT_CDC) +-#elif defined(ATCA_HAL_KIT_CDC) - *gCfg = cfg_ateccx08a_kitcdc_default; - gCfg->devtype = deviceType; -+ *gCfg = cfg_ateccx08a_kitcdc_default; -+ gCfg->devtype = deviceType; - #elif defined(ATCA_HAL_CUSTOM) +-#elif defined(ATCA_HAL_CUSTOM) - *gCfg = g_cfg_atecc608a_custom; -+ *gCfg = g_cfg_atecc508a_custom; - #else - #error "HAL interface is not selected"; - #endif +-#else +-#error "HAL interface is not selected"; +-#endif - break; - - default: @@ -372,7 +381,7 @@ index c8c60e0..592157e 100644 - return status; - } - -- do +- do - { - // Read current config values - status = atcab_read_bytes_zone(ATCA_ZONE_CONFIG, 0, 16, config_word, 4); @@ -416,8 +425,9 @@ index c8c60e0..592157e 100644 - - // Update the ATECC608A test config data so all the unit tests will run with the new chip mode - update_chip_mode(&test_ecc608_configdata[ATCA_CHIPMODE_OFFSET], i2c_user_extra_add, ttl_enable, watchdog, clock_divider); -- -- } while (0); +- +- } +- while (0); - - atcab_release(); - return status; @@ -426,6 +436,7 @@ index c8c60e0..592157e 100644 -static void set_clock_divider_m0(void) -{ - ATCA_STATUS status = set_chip_mode(0xFF, 0xFF, ATCA_CHIPMODE_WATCHDOG_SHORT, ATCA_CHIPMODE_CLOCK_DIV_M0); +- - if (status == ATCA_SUCCESS) - { - printf("Set device to clock divider M0 (0x%02X) and watchdog to 1.3s nominal.\r\n", ATCA_CHIPMODE_CLOCK_DIV_M0 >> 3); @@ -435,6 +446,7 @@ index c8c60e0..592157e 100644 -static void set_clock_divider_m1(void) -{ - ATCA_STATUS status = set_chip_mode(0xFF, 0xFF, ATCA_CHIPMODE_WATCHDOG_SHORT, ATCA_CHIPMODE_CLOCK_DIV_M1); +- - if (status == ATCA_SUCCESS) - { - printf("Set device to clock divider M1 (0x%02X) and watchdog to 1.3s nominal.\r\n", ATCA_CHIPMODE_CLOCK_DIV_M1 >> 3); @@ -446,9 +458,13 @@ index c8c60e0..592157e 100644 - // Additionally set watchdog to long settings (~13s) as some commands - // can't complete in time on the faster watchdog setting. - ATCA_STATUS status = set_chip_mode(0xFF, 0xFF, ATCA_CHIPMODE_WATCHDOG_LONG, ATCA_CHIPMODE_CLOCK_DIV_M2); +- - if (status == ATCA_SUCCESS) - { - printf("Set device to clock divider M2 (0x%02X) and watchdog to 13s nominal.\r\n", ATCA_CHIPMODE_CLOCK_DIV_M2 >> 3); - } -} -\ No newline at end of file +- + static void tng22_tests(void) + { + ATCA_STATUS status; diff --git a/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib_git.bb b/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib_git.bb index 1ba3edc2b..43a41a7e0 100644 --- a/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib_git.bb +++ b/meta-digi-arm/recipes-digi/cryptoauthlib/cryptoauthlib_git.bb @@ -1,21 +1,22 @@ -# Copyright (C) 2017, 2018 Digi International Inc. +# Copyright (C) 2017-2020 Digi International Inc. SUMMARY = "Microchip CryptoAuthentication Library" SECTION = "libs" LICENSE = "MICROCHIP_CRYPTOAUTHLIB_LICENSE" -LIC_FILES_CHKSUM = "file://license.txt;endline=19;md5=5bcd26c644867b127c2cce82960fae7b" +LIC_FILES_CHKSUM = "file://license.txt;md5=84f2905dc39d2f8cdffb00af6f9e6d4e" -SRCBRANCH = "master" -SRCREV = "c6da3358a102c10d954372598c6efef8ad84c9ee" +SRCREV = "a0007d2f6c42fddab5dca1575e0f404788829ddc" GIT_URI ?= "git://github.com/MicrochipTech/cryptoauthlib.git;protocol=https" SRC_URI = " \ ${GIT_URI};nobranch=1 \ - file://0001-Port-changes-from-the-cryptoauth-engine-repo-to-the-.patch \ - file://0002-Remove-unused-HAL-implementations.patch \ - file://0003-Build-cryptochip-cmd-processor-application-along-wit.patch \ - file://0004-Remove-unnecessary-code-from-cryptochip-cmd-processo.patch \ + file://0001-lib-add-parameters-to-be-able-to-modify-default-I2C-.patch \ + file://0002-lib-apply-library-version-number-to-CMake-VERSION-pr.patch \ + file://0003-pkcs11-rename-template-configuration-file-to-its-int.patch \ + file://0004-lib-install-pkg-config-file-and-header-files.patch \ + file://0005-test-add-CMakeLists.txt.patch \ + file://0006-Remove-unnecessary-code-from-cryptoauth_test.patch \ " S = "${WORKDIR}/git" @@ -24,20 +25,30 @@ I2C_BUS = "" I2C_BUS_ccimx6qpsbc = "1" I2C_BUS_ccimx6ul = "0" I2C_BUS_ccimx8x = "0" +I2C_BUS_ccimx8mn = "0" I2C_SPEED ?= "100000" -CFLAGS += "-DATCA_HAL_I2C_BUS=${I2C_BUS} -DATCA_HAL_I2C_SPEED=${I2C_SPEED}" +EXTRA_OECMAKE += "-DATCA_HAL_I2C_BUS=${I2C_BUS} -DATCA_HAL_I2C_SPEED=${I2C_SPEED} -DBUILD_TESTS=on" -do_patch[prefuncs] = "change_line_endings" +inherit cmake -change_line_endings() { - find ${S} -type f -name '*.[ch]' -print0 | xargs -0 sed -i -e 's/\r//g' +do_install_append() { + # Rename the folder containing the header files to be more package-specific + mv ${D}${includedir}/lib ${D}${includedir}/cryptoauthlib + + # Remove RPATH from the executable + chrpath -d ${D}${bindir}/cryptoauth_test + chmod +x ${D}${bindir}/cryptoauth_test } -do_install() { - oe_runmake DESTDIR=${D} install -} +PACKAGES =+ "${PN}-test" + +FILES_${PN}-test = "${bindir}/cryptoauth_test" + +RDEPENDS_${PN} = "libp11" +RDEPENDS_${PN}-test = "${PN}" +RRECOMMENDS_${PN} = "${PN}-test" PACKAGE_ARCH = "${MACHINE_ARCH}" -COMPATIBLE_MACHINE = "(ccimx6qpsbc|ccimx6ul|ccimx8x)" +COMPATIBLE_MACHINE = "(ccimx6qpsbc|ccimx6ul|ccimx8x|ccimx8m)" diff --git a/meta-digi-arm/recipes-digi/mca/mca-tool_1.18.bb b/meta-digi-arm/recipes-digi/mca/mca-tool_1.20.bb similarity index 50% rename from meta-digi-arm/recipes-digi/mca/mca-tool_1.18.bb rename to meta-digi-arm/recipes-digi/mca/mca-tool_1.20.bb index d410e90fb..0e5e7bf00 100644 --- a/meta-digi-arm/recipes-digi/mca/mca-tool_1.18.bb +++ b/meta-digi-arm/recipes-digi/mca/mca-tool_1.20.bb @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2019 Digi International. +# Copyright (C) 2016-2020 Digi International. SUMMARY = "MCA firmware management tool" SECTION = "console/tools" @@ -8,13 +8,13 @@ PKGNAME = "mca_tool" # ARM tarball SRC_URI_arm = "${DIGI_PKG_SRC}/${PKGNAME}-${PV}-${TUNE_ARCH}.tar.gz;name=arm" -SRC_URI[arm.md5sum] = "aa2037b93dadafe160824f7d63dd8582" -SRC_URI[arm.sha256sum] = "7dbc07672d5cce52e3ec611a1bcef1b6c0aed278fbcd6a150b3f528d8da66065" +SRC_URI[arm.md5sum] = "2007a858cd8f82ae2ddbff43f437335a" +SRC_URI[arm.sha256sum] = "d9a0c1ca1c9f20041602edd585c31bd79b75bc8d8a74648d1809350e731af3d5" # AARCH64 tarball SRC_URI_aarch64 = "${DIGI_PKG_SRC}/${PKGNAME}-${PV}-${TUNE_ARCH}.tar.gz;name=aarch64" -SRC_URI[aarch64.md5sum] = "40d8113353daf8e426597c289f6659d8" -SRC_URI[aarch64.sha256sum] = "a0f7d8bae72f9dcdb1102bcf3e42a4b66d4f66b4bef43f80a4fd63282562a9d4" +SRC_URI[aarch64.md5sum] = "600451f7312a130c63f3b3b5c7abdbb6" +SRC_URI[aarch64.sha256sum] = "1acc7498943662e7e5bd26a67d2733a4814823170ba0756313459cb0e68e6e5f" S = "${WORKDIR}/${PKGNAME}-${PV}" @@ -22,4 +22,4 @@ inherit bin_package INSANE_SKIP_${PN} = "already-stripped" -COMPATIBLE_MACHINE = "(ccimx6ul|ccimx8x)" +COMPATIBLE_MACHINE = "(ccimx6ul|ccimx8x|ccimx8m)" diff --git a/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/encrypt_uimage b/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/encrypt_hab similarity index 100% rename from meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/encrypt_uimage rename to meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/encrypt_hab diff --git a/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/sign_ahab b/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/sign_ahab new file mode 100644 index 000000000..839649e77 --- /dev/null +++ b/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/sign_ahab @@ -0,0 +1,23 @@ +# The syntax for this file is documented in the HAB Code Signing Tool +# User's Guid which is included in the CST package distributed by NXP +[Header] + Target = AHAB + Version = 1.0 + +[Install SRK] + # SRK table generated by srktool + File = "%srk_table%" + # Public key certificate in PEM format + Source = "%cert_img%" + # Index of the public key certificate within the SRK table (0 .. 3) + Source index = %key_index% + # Type of SRK set (NXP or OEM) + Source set = OEM + # bitmask of the revoked SRKs + Revocations = 0x%key_index% + +[Authenticate Data] + # Binary to be signed generated by mkimage + File = "%kernel-img%" + # Offsets = Container header Signature block (printed out by mkimage) + Offsets = %container_offset% %block_offset% \ No newline at end of file diff --git a/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/sign_uimage b/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/sign_hab similarity index 100% rename from meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/sign_uimage rename to meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/sign_hab diff --git a/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/trustfence-sign-kernel.sh b/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/trustfence-sign-kernel.sh index 93e0629fd..9b25083c7 100755 --- a/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/trustfence-sign-kernel.sh +++ b/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools/trustfence-sign-kernel.sh @@ -1,9 +1,9 @@ #!/bin/sh #=============================================================================== # -# trustfence_sign_uimage.sh +# trustfence-sign-kernel.sh # -# Copyright (C) 2016 by Digi International Inc. +# Copyright (C) 2016-2020 by Digi International Inc. # All rights reserved. # # This program is free software; you can redistribute it and/or modify it @@ -54,7 +54,7 @@ Usage: ${SCRIPT_NAME} [OPTIONS] input-unsigned-image output-signed-image -i sign/encrypt initramfs -l sign/encrypt Linux image -Supported platforms: ccimx6, ccimx6ul +Supported platforms: ccimx6, ccimx6ul, ccimx8x EOF } @@ -64,14 +64,16 @@ if [ "${#}" != "2" ]; then exit 1 fi -# Negative offset with respect to CONFIG_RAM_START in which U-Boot -# copies the DEK blob. -DEK_BLOB_OFFSET="0x100" -CONFIG_CSF_SIZE="0x4000" - UIMAGE_PATH="$(readlink -e ${1})" TARGET="$(readlink -m ${2})" +# Negative offset with respect to CONFIG_RAM_START in which U-Boot +# copies the DEK blob. +if [ "${SIGN_MODE}" = "HAB" ]; then + DEK_BLOB_OFFSET="0x100" + CONFIG_CSF_SIZE="0x4000" +fi + # Read user configuration file (if used) [ -f .config ] && . ./.config @@ -81,43 +83,45 @@ if [ -z "${CONFIG_SIGN_KEYS_PATH}" ]; then fi [ -d "${CONFIG_SIGN_KEYS_PATH}" ] || mkdir "${CONFIG_SIGN_KEYS_PATH}" -if [ -n "${CONFIG_DEK_PATH}" ]; then - if [ ! -f "${CONFIG_DEK_PATH}" ]; then - echo "DEK not found. Generating random 256 bit DEK." - [ -d $(dirname ${CONFIG_DEK_PATH}) ] || mkdir -p $(dirname ${CONFIG_DEK_PATH}) - dd if=/dev/urandom of="${CONFIG_DEK_PATH}" bs=32 count=1 >/dev/null 2>&1 +if [ "${SIGN_MODE}" = "HAB" ]; then + if [ -n "${CONFIG_DEK_PATH}" ]; then + if [ ! -f "${CONFIG_DEK_PATH}" ]; then + echo "DEK not found. Generating random 256 bit DEK." + [ -d $(dirname ${CONFIG_DEK_PATH}) ] || mkdir -p $(dirname ${CONFIG_DEK_PATH}) + dd if=/dev/urandom of="${CONFIG_DEK_PATH}" bs=32 count=1 >/dev/null 2>&1 + fi + dek_size="$((8 * $(stat -L -c %s ${CONFIG_DEK_PATH})))" + if [ "${dek_size}" != "128" ] && [ "${dek_size}" != "192" ] && [ "${dek_size}" != "256" ]; then + echo "Invalid DEK size: ${dek_size} bits. Valid sizes are 128, 192 and 256 bits" + exit 1 + fi + ENCRYPT="true" fi - dek_size="$((8 * $(stat -L -c %s ${CONFIG_DEK_PATH})))" - if [ "${dek_size}" != "128" ] && [ "${dek_size}" != "192" ] && [ "${dek_size}" != "256" ]; then - echo "Invalid DEK size: ${dek_size} bits. Valid sizes are 128, 192 and 256 bits" + + if [ "${PLATFORM}" = "ccimx6" ]; then + CONFIG_FDT_LOADADDR="0x18000000" + CONFIG_RAMDISK_LOADADDR="0x19000000" + CONFIG_KERNEL_LOADADDR="0x12000000" + elif [ "${PLATFORM}" = "ccimx6ul" ]; then + CONFIG_FDT_LOADADDR="0x83000000" + CONFIG_RAMDISK_LOADADDR="0x83800000" + CONFIG_KERNEL_LOADADDR="0x80800000" + else + echo "Invalid platform: ${PLATFORM}" + echo "Supported platforms: ccimx6, ccimx6ul" exit 1 fi - ENCRYPT="true" -fi -if [ "${PLATFORM}" = "ccimx6" ]; then - CONFIG_FDT_LOADADDR="0x18000000" - CONFIG_RAMDISK_LOADADDR="0x19000000" - CONFIG_KERNEL_LOADADDR="0x12000000" -elif [ "${PLATFORM}" = "ccimx6ul" ]; then - CONFIG_FDT_LOADADDR="0x83000000" - CONFIG_RAMDISK_LOADADDR="0x83800000" - CONFIG_KERNEL_LOADADDR="0x80800000" -else - echo "Invalid platform: ${PLATFORM}" - echo "Supported platforms: ccimx6, ccimx6ul" - exit 1 -fi + [ "${ARTIFACT_DTB}" = "y" ] && CONFIG_RAM_START="${CONFIG_FDT_LOADADDR}" + [ "${ARTIFACT_INITRAMFS}" = "y" ] && CONFIG_RAM_START="${CONFIG_RAMDISK_LOADADDR}" + [ "${ARTIFACT_KERNEL}" = "y" ] && CONFIG_RAM_START="${CONFIG_KERNEL_LOADADDR}" + # bootscripts are loaded to $loadaddr, just like the kernel + [ "${ARTIFACT_BOOTSCRIPT}" = "y" ] && CONFIG_RAM_START="${CONFIG_KERNEL_LOADADDR}" -[ "${ARTIFACT_DTB}" = "y" ] && CONFIG_RAM_START="${CONFIG_FDT_LOADADDR}" -[ "${ARTIFACT_INITRAMFS}" = "y" ] && CONFIG_RAM_START="${CONFIG_RAMDISK_LOADADDR}" -[ "${ARTIFACT_KERNEL}" = "y" ] && CONFIG_RAM_START="${CONFIG_KERNEL_LOADADDR}" -# bootscripts are loaded to $loadaddr, just like the kernel -[ "${ARTIFACT_BOOTSCRIPT}" = "y" ] && CONFIG_RAM_START="${CONFIG_KERNEL_LOADADDR}" - -if [ -z "${CONFIG_RAM_START}" ]; then - echo "Specify the type of image to process (-b, -i, -d, or -l)" - exit 1 + if [ -z "${CONFIG_RAM_START}" ]; then + echo "Specify the type of image to process (-b, -i, -d, or -l)" + exit 1 + fi fi # Default values @@ -125,135 +129,197 @@ fi CONFIG_KEY_INDEX_1="$((CONFIG_KEY_INDEX + 1))" SRK_KEYS="$(echo ${CONFIG_SIGN_KEYS_PATH}/crts/SRK*crt.pem | sed s/\ /\,/g)" -CERT_CSF="$(echo ${CONFIG_SIGN_KEYS_PATH}/crts/CSF${CONFIG_KEY_INDEX_1}*crt.pem)" -CERT_IMG="$(echo ${CONFIG_SIGN_KEYS_PATH}/crts/IMG${CONFIG_KEY_INDEX_1}*crt.pem)" +if [ "${SIGN_MODE}" = "HAB" ]; then + CERT_CSF="$(echo ${CONFIG_SIGN_KEYS_PATH}/crts/CSF${CONFIG_KEY_INDEX_1}*crt.pem)" + CERT_IMG="$(echo ${CONFIG_SIGN_KEYS_PATH}/crts/IMG${CONFIG_KEY_INDEX_1}*crt.pem)" +fi n_commas="$(echo ${SRK_KEYS} | grep -o "," | wc -l)" -if [ "${n_commas}" -eq 3 ] && [ -f "${CERT_CSF}" ] && [ -f "${CERT_IMG}" ]; then - # PKI tree already exists. - echo "Using existing PKI tree" -elif [ "${n_commas}" -eq 0 ] || [ ! -f "${CERT_CSF}" ] || [ ! -f "${CERT_IMG}" ]; then - # Generate PKI - trustfence-gen-pki.sh "${CONFIG_SIGN_KEYS_PATH}" +if [ "${SIGN_MODE}" = "HAB" ]; then + if [ "${n_commas}" -eq 3 ] && [ -f "${CERT_CSF}" ] && [ -f "${CERT_IMG}" ]; then + # PKI tree already exists. + echo "Using existing PKI tree" + elif [ "${n_commas}" -eq 0 ] || [ ! -f "${CERT_CSF}" ] || [ ! -f "${CERT_IMG}" ]; then + # Generate PKI + trustfence-gen-pki.sh "${CONFIG_SIGN_KEYS_PATH}" - SRK_KEYS="$(echo ${CONFIG_SIGN_KEYS_PATH}/crts/SRK*crt.pem | sed s/\ /\,/g)" - CERT_CSF="$(echo ${CONFIG_SIGN_KEYS_PATH}/crts/CSF${CONFIG_KEY_INDEX_1}*crt.pem)" - CERT_IMG="$(echo ${CONFIG_SIGN_KEYS_PATH}/crts/IMG${CONFIG_KEY_INDEX_1}*crt.pem)" -else - echo "Inconsistent CST folder." - exit 1 + SRK_KEYS="$(echo ${CONFIG_SIGN_KEYS_PATH}/crts/SRK*crt.pem | sed s/\ /\,/g)" + CERT_CSF="$(echo ${CONFIG_SIGN_KEYS_PATH}/crts/CSF${CONFIG_KEY_INDEX_1}*crt.pem)" + CERT_IMG="$(echo ${CONFIG_SIGN_KEYS_PATH}/crts/IMG${CONFIG_KEY_INDEX_1}*crt.pem)" + else + echo "Inconsistent CST folder." + exit 1 + fi +elif [ "${SIGN_MODE}" = "AHAB" ]; then + if [ "${n_commas}" -eq 3 ] && [ "${SIGN_MODE}" = "AHAB" ]; then + # PKI tree already exists. Do nothing + echo "Using existing PKI tree" + elif [ "${n_commas}" -eq 0 ] && [ "${SIGN_MODE}" = "AHAB" ]; then + # Generate PKI + trustfence-gen-pki.sh "${CONFIG_SIGN_KEYS_PATH}" + + SRK_KEYS="$(echo ${CONFIG_SIGN_KEYS_PATH}/crts/SRK*crt.pem | sed s/\ /\,/g)" + else + echo "Inconsistent CST folder." + exit 1 + fi fi SRK_TABLE="$(pwd)/SRK_table.bin" +if [ "${SIGN_MODE}" = "HAB" ]; then + HAB_VER="hab_ver 4" + DIGEST="digest" + DIGEST_ALGO="sha256" + SRK_EFUSES="/dev/null" -# Other constants -GAP_FILLER="0x00" + # Other constants + GAP_FILLER="0x00" -# The DEK blob is placed by U-Boot just before the kernel image -dek_blob_offset="$((CONFIG_KERNEL_LOADADDR - DEK_BLOB_OFFSET))" + # The DEK blob is placed by U-Boot just before the kernel image + dek_blob_offset="$((CONFIG_KERNEL_LOADADDR - DEK_BLOB_OFFSET))" -# Compute the layout: sizes and offsets. -uimage_size="$(stat -L -c %s ${UIMAGE_PATH})" -uimage_offset="0x0" -pad_len="$(((uimage_size + 0x1000 - 1) & ~(0x1000 - 1)))" -auth_len="$((pad_len + 0x20))" -sig_len="$((auth_len + CONFIG_CSF_SIZE))" + # Compute the layout: sizes and offsets. + uimage_size="$(stat -L -c %s ${UIMAGE_PATH})" + uimage_offset="0x0" + pad_len="$(((uimage_size + 0x1000 - 1) & ~(0x1000 - 1)))" + auth_len="$((pad_len + 0x20))" + sig_len="$((auth_len + CONFIG_CSF_SIZE))" -ivt_uimage_start="$((auth_len - 0x20))" -ivt_ram_start="$((CONFIG_RAM_START + ivt_uimage_start))" -ivt_size="0x20" -csf_ram_start="$((ivt_ram_start + ivt_size))" -entrypoint_uimage_offset="0x100" -entrypoint_ram_start="$((CONFIG_RAM_START + entrypoint_uimage_offset))" -entrypoint_size="0x20" -header_uimage_offset="0x0" -header_ram_start="${CONFIG_RAM_START}" -header_size="0x40" + ivt_uimage_start="$((auth_len - 0x20))" + ivt_ram_start="$((CONFIG_RAM_START + ivt_uimage_start))" + ivt_size="0x20" + csf_ram_start="$((ivt_ram_start + ivt_size))" + entrypoint_uimage_offset="0x100" + entrypoint_ram_start="$((CONFIG_RAM_START + entrypoint_uimage_offset))" + entrypoint_size="0x20" + header_uimage_offset="0x0" + header_ram_start="${CONFIG_RAM_START}" + header_size="0x40" -r1_uimage_offset="${header_size}" -r1_ram_start="$((CONFIG_RAM_START + r1_uimage_offset))" -r1_size="$((entrypoint_uimage_offset - header_size ))" -r2_uimage_offset="$((entrypoint_uimage_offset + entrypoint_size))" -r2_ram_start="$((CONFIG_RAM_START + r2_uimage_offset))" -r2_size="$((ivt_uimage_start - (entrypoint_uimage_offset + entrypoint_size)))" + r1_uimage_offset="${header_size}" + r1_ram_start="$((CONFIG_RAM_START + r1_uimage_offset))" + r1_size="$((entrypoint_uimage_offset - header_size ))" + r2_uimage_offset="$((entrypoint_uimage_offset + entrypoint_size))" + r2_ram_start="$((CONFIG_RAM_START + r2_uimage_offset))" + r2_size="$((ivt_uimage_start - (entrypoint_uimage_offset + entrypoint_size)))" -# Generate actual CSF descriptor file from template -if [ "${ENCRYPT}" = "true" ]; then - sed -e "s,%ram_start%,${CONFIG_RAM_START},g" \ - -e "s,%srk_table%,${SRK_TABLE},g " \ - -e "s,%cert_csf%,${CERT_CSF},g" \ - -e "s,%cert_img%,${CERT_IMG},g" \ - -e "s,%uimage_path%,${TARGET},g" \ - -e "s,%key_index%,${CONFIG_KEY_INDEX},g" \ - -e "s,%dek_len%,${dek_size},g" \ - -e "s,%dek_path%,${CONFIG_DEK_PATH},g" \ - -e "s,%dek_offset%,${dek_blob_offset},g" \ - -e "s,%ivt_uimage_start%,${ivt_uimage_start},g" \ - -e "s,%ivt_ram_start%,${ivt_ram_start},g" \ - -e "s,%ivt_size%,${ivt_size},g" \ - -e "s,%entrypoint_uimage_offset%,${entrypoint_uimage_offset},g" \ - -e "s,%entrypoint_ram_start%,${entrypoint_ram_start},g" \ - -e "s,%entrypoint_size%,${entrypoint_size},g" \ - -e "s,%header_uimage_offset%,${header_uimage_offset},g" \ - -e "s,%header_ram_start%,${header_ram_start},g" \ - -e "s,%header_size%,${header_size},g" \ - -e "s,%r1_uimage_offset%,${r1_uimage_offset},g" \ - -e "s,%r1_ram_start%,${r1_ram_start},g" \ - -e "s,%r1_size%,${r1_size},g" \ - -e "s,%r2_uimage_offset%,${r2_uimage_offset},g" \ - -e "s,%r2_ram_start%,${r2_ram_start},g" \ - -e "s,%r2_size%,${r2_size},g" \ - "${SCRIPT_PATH}/csf_templates/encrypt_uimage" > csf_descriptor + # Generate actual CSF descriptor file from template + if [ "${ENCRYPT}" = "true" ]; then + sed -e "s,%ram_start%,${CONFIG_RAM_START},g" \ + -e "s,%srk_table%,${SRK_TABLE},g " \ + -e "s,%cert_csf%,${CERT_CSF},g" \ + -e "s,%cert_img%,${CERT_IMG},g" \ + -e "s,%uimage_path%,${TARGET},g" \ + -e "s,%key_index%,${CONFIG_KEY_INDEX},g" \ + -e "s,%dek_len%,${dek_size},g" \ + -e "s,%dek_path%,${CONFIG_DEK_PATH},g" \ + -e "s,%dek_offset%,${dek_blob_offset},g" \ + -e "s,%ivt_uimage_start%,${ivt_uimage_start},g" \ + -e "s,%ivt_ram_start%,${ivt_ram_start},g" \ + -e "s,%ivt_size%,${ivt_size},g" \ + -e "s,%entrypoint_uimage_offset%,${entrypoint_uimage_offset},g" \ + -e "s,%entrypoint_ram_start%,${entrypoint_ram_start},g" \ + -e "s,%entrypoint_size%,${entrypoint_size},g" \ + -e "s,%header_uimage_offset%,${header_uimage_offset},g" \ + -e "s,%header_ram_start%,${header_ram_start},g" \ + -e "s,%header_size%,${header_size},g" \ + -e "s,%r1_uimage_offset%,${r1_uimage_offset},g" \ + -e "s,%r1_ram_start%,${r1_ram_start},g" \ + -e "s,%r1_size%,${r1_size},g" \ + -e "s,%r2_uimage_offset%,${r2_uimage_offset},g" \ + -e "s,%r2_ram_start%,${r2_ram_start},g" \ + -e "s,%r2_size%,${r2_size},g" \ + "${SCRIPT_PATH}/csf_templates/encrypt_hab" > csf_descriptor + else + sed -e "s,%ram_start%,${CONFIG_RAM_START},g" \ + -e "s,%srk_table%,${SRK_TABLE},g" \ + -e "s,%image_offset%,${uimage_offset},g" \ + -e "s,%auth_len%,${auth_len},g" \ + -e "s,%cert_csf%,${CERT_CSF},g" \ + -e "s,%cert_img%,${CERT_IMG},g" \ + -e "s,%uimage_path%,${TARGET},g" \ + -e "s,%key_index%,${CONFIG_KEY_INDEX},g" \ + "${SCRIPT_PATH}/csf_templates/sign_hab" > csf_descriptor + fi else - sed -e "s,%ram_start%,${CONFIG_RAM_START},g" \ - -e "s,%srk_table%,${SRK_TABLE},g" \ - -e "s,%image_offset%,${uimage_offset},g" \ - -e "s,%auth_len%,${auth_len},g" \ - -e "s,%cert_csf%,${CERT_CSF},g" \ - -e "s,%cert_img%,${CERT_IMG},g" \ - -e "s,%uimage_path%,${TARGET},g" \ - -e "s,%key_index%,${CONFIG_KEY_INDEX},g" \ - "${SCRIPT_PATH}/csf_templates/sign_uimage" > csf_descriptor + SRK_EFUSES="$(pwd)/SRK_efuses.bin" + + # Other constants + KERNEL_START_OFFSET="0x0" + KERNEL_SIG_BLOCK_OFFSET="0x90" + KERNEL_NAME="${1}" + + HAB_VER="ahab" + DIGEST="sign_digest" + DIGEST_ALGO="sha512" + + # Compute the layout: sizes and offsets. + container_header_offset="${KERNEL_START_OFFSET}" + signature_block_offset="${KERNEL_SIG_BLOCK_OFFSET}" + + SRK_CERT_KEY_IMG="$(echo ${CONFIG_SIGN_KEYS_PATH}/crts/SRK${CONFIG_KEY_INDEX_1}*crt.pem | sed s/\ /\,/g)" + + sed -e "s,%srk_table%,${SRK_TABLE},g" \ + -e "s,%cert_img%,${SRK_CERT_KEY_IMG},g" \ + -e "s,%kernel-img%,${KERNEL_NAME},g" \ + -e "s,%key_index%,${CONFIG_KEY_INDEX},g" \ + -e "s,%container_offset%,${container_header_offset},g" \ + -e "s,%block_offset%,${signature_block_offset},g" \ + "${SCRIPT_PATH}/csf_templates/sign_ahab" > csf_descriptor + + if [ "${ENCRYPT}" = "true" ]; then + echo "[ERROR] Environment encryption is not supported." + exit 1 + fi fi # Generate SRK tables -srktool --hab_ver 4 --certs "${SRK_KEYS}" --table "${SRK_TABLE}" --efuses /dev/null --digest sha256 +srktool --${HAB_VER} --certs "${SRK_KEYS}" --table "${SRK_TABLE}" --efuses "${SRK_EFUSES}" --${DIGEST} "${DIGEST_ALGO}" if [ $? -ne 0 ]; then echo "[ERROR] Could not generate SRK tables" exit 1 fi -# Pad to IVT -objcopy -I binary -O binary --pad-to "${pad_len}" --gap-fill="${GAP_FILLER}" "${UIMAGE_PATH}" "${TARGET}" +if [ "${SIGN_MODE}" = "HAB" ]; then + # Pad to IVT + objcopy -I binary -O binary --pad-to "${pad_len}" --gap-fill="${GAP_FILLER}" "${UIMAGE_PATH}" "${TARGET}" -# Generate and attach IVT -# Fields: header, jump location, reserved (0), DCD pointer (null) -# boot data (null), self pointer, CSF pointer, reserved (0) -PRINTF="$(which printf)" -IVT_HEADER="0x402000D1" -{ - ${PRINTF} $(${PRINTF} "%08x" ${IVT_HEADER} | sed 's/.\{2\}/&\n/g' | tac | sed 's,^,\\x,g' | tr -d '\n') - ${PRINTF} $(${PRINTF} "%08x" ${entrypoint_ram_start} | sed 's/.\{2\}/&\n/g' | tac | sed 's,^,\\x,g' | tr -d '\n') - ${PRINTF} $(${PRINTF} "%08x" 0 | sed 's/.\{2\}/&\n/g' | tac | sed 's,^,\\x,g' | tr -d '\n') - ${PRINTF} $(${PRINTF} "%08x" 0 | sed 's/.\{2\}/&\n/g' | tac | sed 's,^,\\x,g' | tr -d '\n') - ${PRINTF} $(${PRINTF} "%08x" 0 | sed 's/.\{2\}/&\n/g' | tac | sed 's,^,\\x,g' | tr -d '\n') - ${PRINTF} $(${PRINTF} "%08x" ${ivt_ram_start} | sed 's/.\{2\}/&\n/g' | tac | sed 's,^,\\x,g' | tr -d '\n') - ${PRINTF} $(${PRINTF} "%08x" ${csf_ram_start} | sed 's/.\{2\}/&\n/g' | tac | sed 's,^,\\x,g' | tr -d '\n') - ${PRINTF} $(${PRINTF} "%08x" 0 | sed 's/.\{2\}/&\n/g' | tac | sed 's,^,\\x,g' | tr -d '\n') -} >> "${TARGET}" + # Generate and attach IVT + # Fields: header, jump location, reserved (0), DCD pointer (null) + # boot data (null), self pointer, CSF pointer, reserved (0) + PRINTF="$(which printf)" + IVT_HEADER="0x402000D1" + { + ${PRINTF} $(${PRINTF} "%08x" ${IVT_HEADER} | sed 's/.\{2\}/&\n/g' | tac | sed 's,^,\\x,g' | tr -d '\n') + ${PRINTF} $(${PRINTF} "%08x" ${entrypoint_ram_start} | sed 's/.\{2\}/&\n/g' | tac | sed 's,^,\\x,g' | tr -d '\n') + ${PRINTF} $(${PRINTF} "%08x" 0 | sed 's/.\{2\}/&\n/g' | tac | sed 's,^,\\x,g' | tr -d '\n') + ${PRINTF} $(${PRINTF} "%08x" 0 | sed 's/.\{2\}/&\n/g' | tac | sed 's,^,\\x,g' | tr -d '\n') + ${PRINTF} $(${PRINTF} "%08x" 0 | sed 's/.\{2\}/&\n/g' | tac | sed 's,^,\\x,g' | tr -d '\n') + ${PRINTF} $(${PRINTF} "%08x" ${ivt_ram_start} | sed 's/.\{2\}/&\n/g' | tac | sed 's,^,\\x,g' | tr -d '\n') + ${PRINTF} $(${PRINTF} "%08x" ${csf_ram_start} | sed 's/.\{2\}/&\n/g' | tac | sed 's,^,\\x,g' | tr -d '\n') + ${PRINTF} $(${PRINTF} "%08x" 0 | sed 's/.\{2\}/&\n/g' | tac | sed 's,^,\\x,g' | tr -d '\n') + } >> "${TARGET}" -CURRENT_PATH="$(pwd)" -cst -o "${CURRENT_PATH}/csf.bin" -i "${CURRENT_PATH}/csf_descriptor" >/dev/null -if [ $? -ne 0 ]; then - echo "[ERROR] Could not generate CSF" - exit 1 + CURRENT_PATH="$(pwd)" + cst -o "${CURRENT_PATH}/csf.bin" -i "${CURRENT_PATH}/csf_descriptor" >/dev/null + if [ $? -ne 0 ]; then + echo "[ERROR] Could not generate CSF" + exit 1 + fi + + cat csf.bin >> "${TARGET}" + + objcopy -I binary -O binary --pad-to "${sig_len}" --gap-fill="${GAP_FILLER}" "${TARGET}" +else + CURRENT_PATH="$(pwd)" + cst -o "${TARGET}" -i "${CURRENT_PATH}/csf_descriptor" >/dev/null + if [ $? -ne 0 ]; then + echo "[ERROR] Could not generate CSF $?" + exit 1 + fi fi -cat csf.bin >> "${TARGET}" - -objcopy -I binary -O binary --pad-to "${sig_len}" --gap-fill="${GAP_FILLER}" "${TARGET}" - [ "${ENCRYPT}" = "true" ] && ENCRYPTED_MSG="and encrypted " echo "Signed ${ENCRYPTED_MSG}image ready: ${TARGET}" rm -f "${SRK_TABLE}" csf_descriptor csf.bin 2> /dev/null diff --git a/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools_git.bb b/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools_git.bb index 9aff645ff..c9985bc75 100644 --- a/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools_git.bb +++ b/meta-digi-arm/recipes-digi/trustfence/trustfence-sign-tools_git.bb @@ -6,6 +6,7 @@ LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425 DEPENDS = "trustfence-cst coreutils util-linux" SRCBRANCH = "v2017.03/maint" +SRCBRANCH_ccimx8x = "v2019.04/master" SRCREV = "${AUTOREV}" S = "${WORKDIR}" @@ -16,8 +17,9 @@ UBOOT_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${DIGI_GIT SRC_URI = " \ ${UBOOT_GIT_URI};branch=${SRCBRANCH} \ file://trustfence-sign-kernel.sh;name=kernel-script \ - file://sign_uimage;name=kernel-sign \ - file://encrypt_uimage;name=kernel-encrypt \ + file://sign_hab;name=kernel-sign \ + file://encrypt_hab;name=kernel-encrypt \ + file://sign_ahab;name=kernel-sign \ " do_configure[noexec] = "1" @@ -25,12 +27,19 @@ do_compile[noexec] = "1" do_install() { install -d ${D}${bindir}/csf_templates + if [ "${SIGN_MODE}" = "AHAB" ]; then + install -m 0755 sign_ahab ${D}${bindir}/csf_templates/ + install -m 0755 git/scripts/sign.sh ${D}${bindir}/trustfence-sign-ahab-uboot.sh + elif [ "${SIGN_MODE}" = "HAB" ]; then + install -m 0755 sign_hab ${D}${bindir}/csf_templates/ + install -m 0755 encrypt_hab ${D}${bindir}/csf_templates/ + install -m 0755 git/scripts/sign.sh ${D}${bindir}/trustfence-sign-uboot.sh + else + bberror "Unkown SIGN_MODE value" + exit 1 + fi install -m 0755 trustfence-sign-kernel.sh ${D}${bindir}/ - install -m 0755 sign_uimage ${D}${bindir}/csf_templates/ - install -m 0755 encrypt_uimage ${D}${bindir}/csf_templates/ - install -m 0755 git/scripts/sign.sh ${D}${bindir}/trustfence-sign-uboot.sh - install -m 0755 git/scripts/csf_templates/sign_uboot ${D}${bindir}/csf_templates - install -m 0755 git/scripts/csf_templates/encrypt_uboot ${D}${bindir}/csf_templates + install -m 0755 git/scripts/csf_templates/* ${D}${bindir}/csf_templates } FILES_${PN} = "${bindir}" diff --git a/meta-digi-arm/recipes-kernel/kernel-module-qualcomm/kernel-module-qualcomm.bb b/meta-digi-arm/recipes-kernel/kernel-module-qualcomm/kernel-module-qualcomm.bb index ce2fe5e89..73d8df971 100644 --- a/meta-digi-arm/recipes-kernel/kernel-module-qualcomm/kernel-module-qualcomm.bb +++ b/meta-digi-arm/recipes-kernel/kernel-module-qualcomm/kernel-module-qualcomm.bb @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2019 Digi International. +# Copyright (C) 2016-2020 Digi International. SUMMARY = "Qualcomm's wireless driver for qca65xx" DESCRIPTION = "qcacld-2.0 module" @@ -6,11 +6,9 @@ LICENSE = "ISC" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/ISC;md5=f3b90e78ea0cffb20bf5cca7947a896d" # Reference Qualcomm tag/version -PV = "v4.2.89.63" -PV_ccimx8x = "v4.0.11.208Q" +PV = "v4.0.11.213X" -SRCBRANCH = "qca6564/dey-2.6/maint" -SRCBRANCH_ccimx8x = "qca6574/dey-2.6/maint" +SRCBRANCH = "qca65X4/master" SRCREV = "${AUTOREV}" QCOM_GIT_URI = "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${DIGI_MTK_GIT}linux/qcacld-2.0.git;protocol=ssh', '${DIGI_GITHUB_GIT}/qcacld-2.0.git;protocol=https', d)}" @@ -84,4 +82,4 @@ FILES_${PN} += " \ ${base_libdir}/firmware/wlan/qcom_cfg.ini \ " -COMPATIBLE_MACHINE = "(ccimx6qpsbc|ccimx6ul|ccimx8x)" +COMPATIBLE_MACHINE = "(ccimx6qpsbc|ccimx6ul|ccimx8x|ccimx8m)" diff --git a/meta-digi-arm/recipes-kernel/kernel-module-qualcomm/kernel-module-qualcomm/qualcomm.sh b/meta-digi-arm/recipes-kernel/kernel-module-qualcomm/kernel-module-qualcomm/qualcomm.sh index 2a8980b9a..d196ff416 100644 --- a/meta-digi-arm/recipes-kernel/kernel-module-qualcomm/kernel-module-qualcomm/qualcomm.sh +++ b/meta-digi-arm/recipes-kernel/kernel-module-qualcomm/kernel-module-qualcomm/qualcomm.sh @@ -21,6 +21,34 @@ log() { printf "<$1>qca65x4: $2\n" >/dev/kmsg } +# Get the permissions of the filesystem containing the given path +get_filesystem_access() { + [ -z "${1}" ] && return + + fs_device="$(df ${1} | awk 'NR==2 { print $1 }')" + fs_access="$(awk -v dev="${fs_device}" '$0 ~ dev { print substr($4,1,2) }' < /proc/mounts)" + echo ${fs_access} +} + +# Get the mount point of the filesystem containing the given path +get_filesystem_mount_point() { + [ -z "${1}" ] && return + + fs_device="$(df ${1} | awk 'NR==2 { print $1 }')" + fs_mount_point="$(awk -v dev="${fs_device}" '$0 ~ dev { print $2 }' < /proc/mounts)" + echo ${fs_mount_point} +} + +# Remount the filesystem containing the given path as 'read-write' if it was +# mounted as 'read-only'. +set_filesystem_rw_access() { + [ -z "${1}" ] && return + + if [ "$(get_filesystem_access ${1})" = "ro" ]; then + mount -o remount,rw $(get_filesystem_mount_point ${1}) + fi +} + # Do nothing if the wireless node does not exist on the device tree [ -d "/proc/device-tree/wireless" ] || exit 0 @@ -30,6 +58,7 @@ grep -qws 'wlan' /proc/modules && exit 0 FIRMWARE_DIR="/lib/firmware" MACFILE="${FIRMWARE_DIR}/wlan/wlan_mac.bin" TMP_MACFILE="$(mktemp -t wlan_mac.XXXXXX)" +FS_ORIGINAL_ACCESS="$(get_filesystem_access ${FIRMWARE_DIR})" # Read the MACs from DeviceTree. We can have up to four wireless interfaces # The only required one is wlan0 that is mapped with device tree mac address @@ -47,86 +76,26 @@ done # Override the MAC firmware file only if the MAC file has changed. if ! cmp -s ${TMP_MACFILE} ${MACFILE}; then - if [ ! -w ${MACFILE} ]; then - mount_point="$(df $(dirname "${MACFILE}") | awk '!/^Filesystem/{ print $6 }')" - log "6" "[INFO] ${MACFILE} is not writable, remounting '${mount_point}' as rw" - mount -o remount,rw ${mount_point} - fi - + set_filesystem_rw_access ${FIRMWARE_DIR} cp ${TMP_MACFILE} ${MACFILE} || log "3" "[ERROR] Could not create ${MACFILE}" fi rm -f "${TMP_MACFILE}" -OTP_REGION_CODE="$(cat /proc/device-tree/digi,hwid,cert 2>/dev/null | tr -d '\0')" -DTB_REGION_CODE="$(cat /proc/device-tree/wireless/regulatory-domain 2>/dev/null | tr -d '\0')" -US_CODE="0x0" -WW_CODE="0x1" -JP_CODE="0x2" -# Check if the DTB_REGION_CODE is in the list of valid codes, -# if not use the OTP programmed value. -case "${DTB_REGION_CODE}" in - ${US_CODE} | ${WW_CODE} | ${JP_CODE}) - REGULATORY_DOMAIN="${DTB_REGION_CODE}";; - *) - if [ -n "${DTB_REGION_CODE}" ]; then - log "5" "[WARN] Invalid region code in device tree, using OTP value" - fi - REGULATORY_DOMAIN="${OTP_REGION_CODE}";; -esac - - # Create symbolic links to the proper FW files depending on the country region # Use a sub-shell here to change to firmware directory ( cd "${FIRMWARE_DIR}" - if [ -f "bdwlan30_US.bin" ] || [ -f "bdwlan30_World.bin" ]; then - BDATA_US="bdwlan30_US.bin" - BDATA_WW="bdwlan30_World.bin" - BDATA_LINK="bdwlan30.bin" - UTFBDATA_LINK="utfbd30.bin" - elif [ -f "fakeboar_US.bin" ] || [ -f "fakeboar_World.bin" ]; then - BDATA_US="fakeboar_US.bin" - BDATA_WW="fakeboar_World.bin" - # Use different links for propietary and community drivers - if [ -f "board.bin" ]; then - BDATA_LINK="board.bin" - else - BDATA_LINK="fakeboar.bin" - fi - else - log "5" "[ERROR] Could not locate board data files" - exit 1 - fi - - BDATA_SOURCE="${BDATA_US}" - case "${REGULATORY_DOMAIN}" in - ${US_CODE}) - log "5" "Setting US wireless region";; - ${WW_CODE}|${JP_CODE}) - if [ -f "${BDATA_WW}" ]; then - log "5" "Setting WW (world wide) wireless region" - BDATA_SOURCE="${BDATA_WW}" - else - log "5" "[WARN] No WW (worldwide) board data file, using US" - fi - ;; - "") - log "5" "[WARN] region code not found, using US";; - *) - log "5" "[WARN] Invalid region code, using US";; - esac + BDATA_SOURCE="bdwlan30_US.bin" + log "5" "Setting US wireless region" # When defined, update the links only if they are wrong so we don't # rewrite the internal memory every time we boot - if [ -n "${BDATA_LINK}" ] && - ([ ! -f "${BDATA_LINK}" ] || - ! cmp -s "${BDATA_LINK}" "${BDATA_SOURCE}"); then + BDATA_LINK="bdwlan30.bin" + UTFBDATA_LINK="utfbd30.bin" + if ([ ! -f "${BDATA_LINK}" ] || ! cmp -s "${BDATA_LINK}" "${BDATA_SOURCE}"); then + set_filesystem_rw_access ${FIRMWARE_DIR} ln -sf "${BDATA_SOURCE}" "${BDATA_LINK}" - fi - if [ -n "${UTFBDATA_LINK}" ] && - ([ ! -f "${UTFBDATA_LINK}" ] || - ! cmp -s "${UTFBDATA_LINK}" "${BDATA_SOURCE}"); then ln -sf "${BDATA_SOURCE}" "${UTFBDATA_LINK}" fi ) @@ -139,3 +108,9 @@ modprobe wlan # Verify the interface is present [ -d "/sys/class/net/wlan0" ] || log "3" "[ERROR] Loading wlan module" + +# Restore the filesystem with the original access permissions if it has been +# changed inside the script. +if [ "$(get_filesystem_access ${FIRMWARE_DIR})" != "${FS_ORIGINAL_ACCESS}" ]; then + mount -o remount,${FS_ORIGINAL_ACCESS} $(get_filesystem_mount_point ${FIRMWARE_DIR}) +fi diff --git a/meta-digi-arm/recipes-kernel/linux/linux-dey.inc b/meta-digi-arm/recipes-kernel/linux/linux-dey.inc index 0575fb967..66db01319 100644 --- a/meta-digi-arm/recipes-kernel/linux/linux-dey.inc +++ b/meta-digi-arm/recipes-kernel/linux/linux-dey.inc @@ -24,23 +24,49 @@ trustfence_sign() { [ -n "${TRUSTFENCE_DEK_PATH}" ] && [ "${TRUSTFENCE_DEK_PATH}" != "0" ] && export CONFIG_DEK_PATH="${TRUSTFENCE_DEK_PATH}" # Sign/encrypt the kernel images - for type in ${KERNEL_IMAGETYPES}; do - KERNEL_IMAGE="${type}-${KERNEL_IMAGE_NAME}.bin" - TMP_KERNEL_IMAGE_SIGNED="$(mktemp ${KERNEL_IMAGE}-signed.XXXXXX)" - trustfence-sign-kernel.sh -p "${DIGI_FAMILY}" -l "${KERNEL_IMAGE}" "${TMP_KERNEL_IMAGE_SIGNED}" - mv "${TMP_KERNEL_IMAGE_SIGNED}" "${KERNEL_IMAGE}" - done + if [ "${SIGN_MODE}" = "HAB" ]; then + for type in ${KERNEL_IMAGETYPES}; do + KERNEL_IMAGE="${type}-${KERNEL_IMAGE_NAME}.bin" + TMP_KERNEL_IMAGE_SIGNED="$(mktemp ${KERNEL_IMAGE}-signed.XXXXXX)" + trustfence-sign-kernel.sh -p "${DIGI_FAMILY}" -l "${KERNEL_IMAGE}" "${TMP_KERNEL_IMAGE_SIGNED}" + mv "${TMP_KERNEL_IMAGE_SIGNED}" "${KERNEL_IMAGE}" + done - # Sign/encrypt the device tree blobs - for DTB in ${KERNEL_DEVICETREE}; do - DTB=`normalize_dtb "${DTB}"` - DTB_EXT=${DTB##*.} - DTB_BASE_NAME=`basename ${DTB} ."${DTB_EXT}"` - DTB_IMAGE="${DTB_BASE_NAME}-${KERNEL_IMAGE_NAME}.${DTB_EXT}" - TMP_DTB_IMAGE_SIGNED="$(mktemp ${DTB_IMAGE}-signed.XXXXXX)" - trustfence-sign-kernel.sh -p "${DIGI_FAMILY}" -d "${DTB_IMAGE}" "${TMP_DTB_IMAGE_SIGNED}" - mv "${TMP_DTB_IMAGE_SIGNED}" "${DTB_IMAGE}" - done + # Sign/encrypt the device tree blobs + for DTB in ${KERNEL_DEVICETREE}; do + DTB=`normalize_dtb "${DTB}"` + DTB_EXT=${DTB##*.} + DTB_BASE_NAME=`basename ${DTB} ."${DTB_EXT}"` + DTB_IMAGE="${DTB_BASE_NAME}-${KERNEL_IMAGE_NAME}.${DTB_EXT}" + TMP_DTB_IMAGE_SIGNED="$(mktemp ${DTB_IMAGE}-signed.XXXXXX)" + trustfence-sign-kernel.sh -p "${DIGI_FAMILY}" -d "${DTB_IMAGE}" "${TMP_DTB_IMAGE_SIGNED}" + mv "${TMP_DTB_IMAGE_SIGNED}" "${DTB_IMAGE}" + done + elif [ "${SIGN_MODE}" = "AHAB" ]; then + # Sign the kernel images + for type in ${KERNEL_IMAGETYPES}; do + KERNEL_IMAGE="${type}-${KERNEL_IMAGE_NAME}.bin" + ${DEPLOY_DIR_IMAGE}/imx-boot-tools/mkimage_imx8 -soc ${MX8_SOC_VAR} -rev ${MX8_CHIP_REV} -c -ap ${WORKDIR}/build/arch/arm64/boot/Image a35 ${RAM_CONTAINER_LOC_BOOT} -out flash_os.bin + trustfence-sign-kernel.sh -p "${DIGI_FAMILY}" -l "flash_os.bin" "${type}-${MACHINE}-signed.bin" + gzip ${type}-${MACHINE}-signed.bin + mv ${type}-${MACHINE}-signed.bin.gz "${KERNEL_IMAGE}" + done + + # Sign/encrypt the device tree blobs + for DTB in ${KERNEL_DEVICETREE}; do + DTB=`normalize_dtb "${DTB}"` + DTB_EXT=${DTB##*.} + DTB_BASE_NAME=`basename ${DTB} ."${DTB_EXT}"` + DTB_IMAGE="${DTB_BASE_NAME}-${KERNEL_IMAGE_NAME}.${DTB_EXT}" + ${DEPLOY_DIR_IMAGE}/imx-boot-tools/mkimage_imx8 -soc ${MX8_SOC_VAR} -rev ${MX8_CHIP_REV} -c -ap ${DTB_IMAGE} a35 ${RAM_CONTAINER_LOC_DTB} -out ${DTB_IMAGE}-mkimg-signed + trustfence-sign-kernel.sh -p "${DIGI_FAMILY}" -d "${DTB_IMAGE}-mkimg-signed" "${DTB_IMAGE}-signed" + mv "${DTB_IMAGE}-signed" "${DTB_IMAGE}" + rm -f ${DTB_IMAGE}-mkimg-signed + done + else + bberror "Unkown SIGN_MODE value" + exit 1 + fi } trustfence_sign[dirs] = "${DEPLOYDIR}" diff --git a/meta-digi-arm/recipes-kernel/linux/linux-dey_4.14.bb b/meta-digi-arm/recipes-kernel/linux/linux-dey_4.14.bb index bfa3cd0de..2e0a739f1 100644 --- a/meta-digi-arm/recipes-kernel/linux/linux-dey_4.14.bb +++ b/meta-digi-arm/recipes-kernel/linux/linux-dey_4.14.bb @@ -1,5 +1,5 @@ -# Copyright (C) 2019 Digi International +# Copyright (C) 2019,2020 Digi International require recipes-kernel/linux/linux-dey.inc -COMPATIBLE_MACHINE = "(ccimx6ul|ccimx8x)" +COMPATIBLE_MACHINE = "(ccimx6ul|ccimx8x|ccimx8m)" diff --git a/meta-digi-arm/recipes-kernel/linux/linux-imx-headers_4.14.bb b/meta-digi-arm/recipes-kernel/linux/linux-imx-headers_4.14.bb index 5e834e8f6..0689a2ae5 100644 --- a/meta-digi-arm/recipes-kernel/linux/linux-imx-headers_4.14.bb +++ b/meta-digi-arm/recipes-kernel/linux/linux-imx-headers_4.14.bb @@ -1,5 +1,5 @@ -# Copyright (C) 2019 Digi International +# Copyright (C) 2019,2020 Digi International require recipes-kernel/linux/linux-imx-headers.inc -COMPATIBLE_MACHINE = "(ccimx6ul|ccimx8x)" +COMPATIBLE_MACHINE = "(ccimx6ul|ccimx8x|ccimx8m)" diff --git a/meta-digi-dey/classes/dey-image.bbclass b/meta-digi-dey/classes/dey-image.bbclass index a7679ca67..04690e451 100644 --- a/meta-digi-dey/classes/dey-image.bbclass +++ b/meta-digi-dey/classes/dey-image.bbclass @@ -34,15 +34,18 @@ DEY_IMAGE_INSTALLER ?= "0" inherit ${@oe.utils.conditional("DEY_IMAGE_INSTALLER", "1", "dey-image-installer", "", d)} # -# Create a dey-version file when populating the toolchain/SDK +# Create a dey-version file when populating the toolchain/SDK and modify the +# default SDK installation path so it includes the proper 'IMAGE_BASENAME' +# value. # # 'SDK_POSTPROCESS_COMMAND' variable is originally defined in populate_sdk_base # class: poky/meta/classes/populate_sdk_base.bbclass -# It is redefined here to be able to tweak the resulting SDK before packaging, -# using the proper 'IMAGE_BASENAME' value. +# It is redefined here to be able to tweak the resulting SDK before and after +# packaging, using the proper 'IMAGE_BASENAME' value. # SDK_PREPACKAGING_COMMAND ?= "toolchain_create_sdk_dey_version" -SDK_POSTPROCESS_COMMAND = " create_sdk_files; check_sdk_sysroots; ${SDK_PREPACKAGING_COMMAND}; tar_sdk; ${SDK_PACKAGING_COMMAND} " +SDK_POSTPACKAGING_COMMAND ?= "toolchain_modify_default_path" +SDK_POSTPROCESS_COMMAND = " create_sdk_files; check_sdk_sysroots; ${SDK_PREPACKAGING_COMMAND}; tar_sdk; ${SDK_PACKAGING_COMMAND} ${SDK_POSTPACKAGING_COMMAND}; " # This function creates a DEY version information file fakeroot toolchain_create_sdk_dey_version() { @@ -56,3 +59,9 @@ fakeroot toolchain_create_sdk_dey_version() { } toolchain_create_sdk_dey_version[vardepsexclude] = "DATETIME" +# This function appends IMAGE_BASENAME to the default installation path +fakeroot toolchain_modify_default_path() { + sed -i -e 's#^DEFAULT_INSTALL_DIR="${SDKPATH}"#DEFAULT_INSTALL_DIR="${SDKPATH}/${IMAGE_BASENAME}"#g' \ + ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.sh +} + diff --git a/meta-digi-dey/classes/trustfence.bbclass b/meta-digi-dey/classes/trustfence.bbclass index c9e391132..c54b3b933 100644 --- a/meta-digi-dey/classes/trustfence.bbclass +++ b/meta-digi-dey/classes/trustfence.bbclass @@ -36,10 +36,6 @@ python () { import hashlib import os - if ("ccimx8x" in d.getVar("MACHINE", True)): - bb.fatal("Trustfence is not currently supported on the ccimx8x SOM") - return - # Secure console configuration if (d.getVar("TRUSTFENCE_CONSOLE_DISABLE", True) == "1"): d.appendVar("UBOOT_EXTRA_CONF", "CONFIG_CONSOLE_DISABLE=y ") @@ -67,7 +63,11 @@ python () { if (d.getVar("TRUSTFENCE_DEK_PATH", True) not in [None, "0"]): d.appendVar("UBOOT_EXTRA_CONF", 'CONFIG_DEK_PATH=\\"%s\\" ' % d.getVar("TRUSTFENCE_DEK_PATH", True)) if (d.getVar("TRUSTFENCE_ENCRYPT_ENVIRONMENT", True) == "1"): - d.appendVar("UBOOT_EXTRA_CONF", 'CONFIG_ENV_AES=y CONFIG_ENV_AES_CAAM_KEY=y') + if ("ccimx8x" in d.getVar("MACHINE", True)): + bb.fatal("Environment encryption is not currently supported on the ccimx8x SOM") + return + else: + d.appendVar("UBOOT_EXTRA_CONF", 'CONFIG_ENV_AES=y CONFIG_ENV_AES_CAAM_KEY=y') # Provide sane default values for SWUPDATE class in case Trustfence is enabled if (d.getVar("TRUSTFENCE_SIGN", True) == "1"): @@ -84,7 +84,12 @@ python () { key_index_1 = key_index + 1 # Set the private key template, it will be expanded later in 'swu' recipes once keys are generated. - d.setVar("SWUPDATE_PRIVATE_KEY_TEMPLATE", keys_path + "/keys/IMG" + str(key_index_1) + "*key.pem") + if (d.getVar("SIGN_MODE", "") == "AHAB"): + d.setVar("SWUPDATE_PRIVATE_KEY_TEMPLATE", keys_path + "/keys/SRK" + str(key_index_1) + "*key.pem") + d.setVar("CONFIG_SIGN_MODE", "AHAB") + else: + d.setVar("SWUPDATE_PRIVATE_KEY_TEMPLATE", keys_path + "/keys/IMG" + str(key_index_1) + "*key.pem") + d.setVar("CONFIG_SIGN_MODE", "HAB") # Set the key password. d.setVar("SWUPDATE_PASSWORD_FILE", keys_path + "/keys/key_pass.txt") diff --git a/meta-digi-dey/conf/distro/dey.conf b/meta-digi-dey/conf/distro/dey.conf index 2b1380cb3..b8bff7a3b 100644 --- a/meta-digi-dey/conf/distro/dey.conf +++ b/meta-digi-dey/conf/distro/dey.conf @@ -1,6 +1,6 @@ DISTRO = "dey" DISTRO_NAME = "Digi Embedded Yocto" -DISTRO_VERSION = "2.6-r2" +DISTRO_VERSION = "2.6-r3" DISTRO_CODENAME = "thud" SDK_VENDOR = "-deysdk" SDK_VERSION := "${@'${DISTRO_VERSION}'}" @@ -70,7 +70,7 @@ PREFERRED_VERSION_libsoc = "git" PREFERRED_PROVIDER_opencl-headers ?= "imx-gpu-viv" SDK_NAME = "${DISTRO}-${TCLIBC}-${SDK_ARCH}-${IMAGE_BASENAME}-${TUNE_PKGARCH}" -SDKPATH = "/opt/${DISTRO}/${SDK_VERSION}" +SDKPATH = "/opt/${DISTRO}/${SDK_VERSION}/${MACHINE}" DISTRO_EXTRA_RDEPENDS += " ${POKY_DEFAULT_EXTRA_RDEPENDS}" DISTRO_EXTRA_RRECOMMENDS += " ${POKY_DEFAULT_EXTRA_RRECOMMENDS}" diff --git a/meta-digi-dey/conf/layer.conf b/meta-digi-dey/conf/layer.conf index 3cb92d433..3da920142 100644 --- a/meta-digi-dey/conf/layer.conf +++ b/meta-digi-dey/conf/layer.conf @@ -15,6 +15,7 @@ BBFILE_PATTERN_digi-dey := "^${LAYERDIR}/" BBFILE_PRIORITY_digi-dey = "6" BBMASK += "meta-freescale/recipes-graphics/drm/libdrm_%.bbappend" +BBMASK += "meta-freescale/recipes-graphics/wayland/weston-init.bbappend" LAYERDEPENDS_digi-dey = "core digi-arm" LAYERDEPENDS_digi-dey += "openembedded-layer networking-layer webserver qt5-layer swupdate" @@ -26,7 +27,7 @@ DIGI_EULA_FILE = "${LAYERDIR}/DIGI_EULA" DIGI_OPEN_EULA_FILE = "${LAYERDIR}/DIGI_OPEN_EULA" # Digi mirror for packages vanished upstream -DIGI_MIRROR ?= "ftp://ftp1.digi.com/support/digiembeddedyocto/mirror/" +DIGI_MIRROR ?= "https://ftp1.digi.com/support/digiembeddedyocto/mirror/" MIRRORS += "\ ftp://.*/.* ${DIGI_MIRROR} \n \ http://.*/.* ${DIGI_MIRROR} \n \ diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5-5.50/ccimx8mn/bluetooth-init b/meta-digi-dey/recipes-connectivity/bluez/bluez5-5.50/ccimx8mn/bluetooth-init new file mode 100644 index 000000000..01f57c95f --- /dev/null +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5-5.50/ccimx8mn/bluetooth-init @@ -0,0 +1,69 @@ +#!/bin/sh +#=============================================================================== +# +# Copyright (C) 2018,2019 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: Initialize bluetooth hardware +# +#=============================================================================== + +bluetooth_init() { + # Get MAC address from the device tree. Use a default value if it has not been set. + BT_MACADDR="$(hexdump -ve '1/1 "%02X" ":"' /proc/device-tree/bluetooth/mac-address 2>/dev/null | sed 's/:$//g')" + if [ -z "${BT_MACADDR}" ] || [ "${BT_MACADDR}" = "00:00:00:00:00:00" ]; then + BT_MACADDR="00:04:F3:FF:FF:BB" + fi + + # Start the Bluetooth driver and bring up the interface + HCIATTACH_LOG="/var/log/hciattach.log" + + for RETRY in $(seq 1 5) + do + killproc hciattach + modprobe btdigi + if hciattach ttyBt qca ${BT_RATE:-3000000} -t30 ${BT_FLOW:-flow} unused ${BT_MACADDR} >${HCIATTACH_LOG} 2>&1; then + return + fi + rmmod btdigi + sleep 1 + done + BT_ERROR="FAIL (hciattach)" +} + +# Source function library +. /etc/init.d/functions + +case "$1" in + start) + if [ -d "/proc/device-tree/bluetooth" ]; then + if [ "$(tr -d '\0' 2>/dev/null -Date: Thu, 31 Jan 2019 18:01:02 +0100 -Subject: [PATCH] Modify openssl.cnf to automatically load the cryptochip - engine - -https://jira.digi.com/browse/DEL-5592 - -Signed-off-by: Gabriel Valcazar -Signed-off-by: Arturo Buzarra ---- - apps/openssl.cnf | 13 +++++++++++++ - 1 file changed, 13 insertions(+) - -diff --git a/apps/openssl.cnf b/apps/openssl.cnf -index 6df2878d50..762582f4d0 100644 ---- a/apps/openssl.cnf -+++ b/apps/openssl.cnf -@@ -3,6 +3,8 @@ - # This is mostly being used for generation of certificate requests. - # - -+openssl_conf = openssl_init -+ - # Note that you can include other files from the main configuration - # file using the .include directive. - #.include filename -@@ -348,3 +350,14 @@ ess_cert_id_chain = no # Must the ESS cert id chain be included? - # (optional, default: no) - ess_cert_id_alg = sha1 # algorithm to compute certificate - # identifier (optional, default: sha1) -+ -+[ openssl_init ] -+engines = engine_section -+ -+[ engine_section ] -+ateccx08 = ateccx08_config -+ -+[ ateccx08_config ] -+engine_id = ateccx08 -+dynamic_path = /usr/lib/ssl/engines/libateccssl.so -+init = 0 diff --git a/meta-digi-dey/recipes-connectivity/openssl/openssl/0001-Modify-openssl.cnf-to-automatically-load-the-pkcs11-.patch b/meta-digi-dey/recipes-connectivity/openssl/openssl/0001-Modify-openssl.cnf-to-automatically-load-the-pkcs11-.patch new file mode 100644 index 000000000..51b599551 --- /dev/null +++ b/meta-digi-dey/recipes-connectivity/openssl/openssl/0001-Modify-openssl.cnf-to-automatically-load-the-pkcs11-.patch @@ -0,0 +1,40 @@ +From: Gabriel Valcazar +Date: Tue, 12 Nov 2019 12:00:07 +0100 +Subject: [PATCH] Modify openssl.cnf to automatically load the pkcs11 engine + +https://jira.digi.com/browse/DEL-6835 + +Signed-off-by: Gabriel Valcazar +--- + apps/openssl.cnf | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/apps/openssl.cnf b/apps/openssl.cnf +index 4acca4b..2261048 100644 +--- a/apps/openssl.cnf ++++ b/apps/openssl.cnf +@@ -7,6 +7,8 @@ + # file using the .include directive. + #.include filename + ++openssl_conf = openssl_init ++ + # This definition stops the following lines choking if HOME isn't + # defined. + HOME = . +@@ -348,3 +350,15 @@ ess_cert_id_chain = no # Must the ESS cert id chain be included? + # (optional, default: no) + ess_cert_id_alg = sha1 # algorithm to compute certificate + # identifier (optional, default: sha1) ++ ++[ openssl_init ] ++engines = engine_section ++ ++[ engine_section ] ++pkcs11 = pkcs11_config ++ ++[ pkcs11_config ] ++engine_id = pkcs11 ++dynamic_path = /usr/lib/engines-1.1/pkcs11.so ++MODULE_PATH = /usr/lib/libcryptoauth.so.2018.10.26 ++init = 0 diff --git a/meta-digi-dey/recipes-connectivity/openssl/openssl_%.bbappend b/meta-digi-dey/recipes-connectivity/openssl/openssl_%.bbappend index f8db537bf..e87c828c6 100644 --- a/meta-digi-dey/recipes-connectivity/openssl/openssl_%.bbappend +++ b/meta-digi-dey/recipes-connectivity/openssl/openssl_%.bbappend @@ -3,7 +3,7 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" CRYPTOCHIP_COMMON_PATCHES = " \ - file://0001-Modify-openssl.cnf-to-automatically-load-the-cryptoc.patch \ + file://0001-Modify-openssl.cnf-to-automatically-load-the-pkcs11-.patch \ " SRC_URI_remove = " \ diff --git a/meta-digi-dey/recipes-connectivity/packagegroups/packagegroup-dey-wireless.bb b/meta-digi-dey/recipes-connectivity/packagegroups/packagegroup-dey-wireless.bb index d4e779518..369d627c4 100644 --- a/meta-digi-dey/recipes-connectivity/packagegroups/packagegroup-dey-wireless.bb +++ b/meta-digi-dey/recipes-connectivity/packagegroups/packagegroup-dey-wireless.bb @@ -1,5 +1,5 @@ # -# Copyright (C) 2012-2019 Digi International. +# Copyright (C) 2012-2020 Digi International. # SUMMARY = "Wireless packagegroup for DEY image" @@ -8,12 +8,11 @@ inherit packagegroup RDEPENDS_${PN} = "\ crda \ + hostapd \ iw \ wpa-supplicant \ wpa-supplicant-cli \ wpa-supplicant-passphrase \ " -RDEPENDS_${PN}_append_ccimx6ul = " hostapd" -RDEPENDS_${PN}_append_ccimx6qpsbc = " hostapd" -RDEPENDS_${PN}_append_ccimx8x = " hostapd" +RDEPENDS_${PN}_remove_ccimx6sbc = "hostapd" diff --git a/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx6qpsbc/wpa_supplicant.conf-sane b/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx6qpsbc/wpa_supplicant.conf-sane deleted file mode 100644 index c58546a06..000000000 --- a/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx6qpsbc/wpa_supplicant.conf-sane +++ /dev/null @@ -1,18 +0,0 @@ -ctrl_interface=/var/run/wpa_supplicant -ctrl_interface_group=0 -fast_reauth=1 -update_config=1 - -ap_scan=1 - -# Static scheduled scan interval time in seconds -# -# The wpa-supplicant dynamically adjusts the scheduled scan time interval. On -# occassions, fixing the interval time is helpful, for example on DFS channels. -#sched_scan_interval=2 - -network={ - scan_ssid=1 - ssid="" - key_mgmt=NONE -} diff --git a/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx6qpsbc/wpa_supplicant_p2p.conf b/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx6qpsbc/wpa_supplicant_p2p.conf deleted file mode 100644 index c6d16f32d..000000000 --- a/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx6qpsbc/wpa_supplicant_p2p.conf +++ /dev/null @@ -1,8 +0,0 @@ -ctrl_interface=/var/run/wpa_supplicant -update_config=1 -device_name=ccimx6qp-p2p -manufacturer=QCA -model_name=McK -device_type=1-0050F204-1 -config_methods=display keypad push_button -persistent_reconnect=1 diff --git a/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx6sbc/wpa_supplicant_p2p.conf b/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx6sbc/wpa_supplicant_p2p.conf index c1146257f..36d8277bf 100644 --- a/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx6sbc/wpa_supplicant_p2p.conf +++ b/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx6sbc/wpa_supplicant_p2p.conf @@ -1,6 +1,6 @@ ctrl_interface=/var/run/wpa_supplicant ctrl_interface_group=0 -device_name=ccimx6-p2p +device_name=##WLAN_P2P_DEVICE_NAME## device_type=10-0050F204-5 config_methods=virtual_push_button keypad display pin persistent_reconnect=1 diff --git a/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx6ul/wpa_supplicant.conf-sane b/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx6ul/wpa_supplicant.conf-sane deleted file mode 100644 index c58546a06..000000000 --- a/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx6ul/wpa_supplicant.conf-sane +++ /dev/null @@ -1,18 +0,0 @@ -ctrl_interface=/var/run/wpa_supplicant -ctrl_interface_group=0 -fast_reauth=1 -update_config=1 - -ap_scan=1 - -# Static scheduled scan interval time in seconds -# -# The wpa-supplicant dynamically adjusts the scheduled scan time interval. On -# occassions, fixing the interval time is helpful, for example on DFS channels. -#sched_scan_interval=2 - -network={ - scan_ssid=1 - ssid="" - key_mgmt=NONE -} diff --git a/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx6ul/wpa_supplicant_p2p.conf b/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx6ul/wpa_supplicant_p2p.conf deleted file mode 100644 index 30a6699e6..000000000 --- a/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx6ul/wpa_supplicant_p2p.conf +++ /dev/null @@ -1,8 +0,0 @@ -ctrl_interface=/var/run/wpa_supplicant -update_config=1 -device_name=ccimx6ul-p2p -manufacturer=QCA -model_name=McK -device_type=1-0050F204-1 -config_methods=display keypad push_button -persistent_reconnect=1 diff --git a/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx8x/wpa_supplicant.conf-sane b/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx8x/wpa_supplicant.conf-sane deleted file mode 100644 index c58546a06..000000000 --- a/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx8x/wpa_supplicant.conf-sane +++ /dev/null @@ -1,18 +0,0 @@ -ctrl_interface=/var/run/wpa_supplicant -ctrl_interface_group=0 -fast_reauth=1 -update_config=1 - -ap_scan=1 - -# Static scheduled scan interval time in seconds -# -# The wpa-supplicant dynamically adjusts the scheduled scan time interval. On -# occassions, fixing the interval time is helpful, for example on DFS channels. -#sched_scan_interval=2 - -network={ - scan_ssid=1 - ssid="" - key_mgmt=NONE -} diff --git a/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/wpa_supplicant.conf-sane b/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/wpa_supplicant.conf-sane index ac94bd5c7..c58546a06 100644 --- a/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/wpa_supplicant.conf-sane +++ b/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/wpa_supplicant.conf-sane @@ -3,22 +3,16 @@ ctrl_interface_group=0 fast_reauth=1 update_config=1 -## -- Example MANAGED network -ap_scan=1 # MANAGED mode +ap_scan=1 + +# Static scheduled scan interval time in seconds +# +# The wpa-supplicant dynamically adjusts the scheduled scan time interval. On +# occassions, fixing the interval time is helpful, for example on DFS channels. +#sched_scan_interval=2 + network={ scan_ssid=1 ssid="" key_mgmt=NONE } - -# -- SoftAP mode -# ap_scan=2 -# network={ -# ssid="ath6kl-ap" -# mode=2 -# frequency=2412 -# key_mgmt=WPA-PSK -# proto=RSN -# pairwise=CCMP -# psk="12345678" -# } diff --git a/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx8x/wpa_supplicant_p2p.conf b/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/wpa_supplicant_p2p.conf similarity index 82% rename from meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx8x/wpa_supplicant_p2p.conf rename to meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/wpa_supplicant_p2p.conf index af04ee92b..b3ba3b1f7 100644 --- a/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/ccimx8x/wpa_supplicant_p2p.conf +++ b/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant/wpa_supplicant_p2p.conf @@ -1,6 +1,6 @@ ctrl_interface=/var/run/wpa_supplicant update_config=1 -device_name=ccimx8x-p2p +device_name=##WLAN_P2P_DEVICE_NAME## manufacturer=QCA model_name=McK device_type=1-0050F204-1 diff --git a/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant_%.bbappend b/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant_%.bbappend index 7867dd56c..8fc798194 100644 --- a/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant_%.bbappend +++ b/meta-digi-dey/recipes-connectivity/wpa-supplicant/wpa-supplicant_%.bbappend @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2019 Digi International. +# Copyright (C) 2013-2020 Digi International. FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" @@ -12,6 +12,27 @@ SRC_URI += " \ do_install_append() { install -m 600 ${WORKDIR}/wpa_supplicant_p2p.conf ${D}${sysconfdir}/wpa_supplicant_p2p.conf + sed -i -e "s,##WLAN_P2P_DEVICE_NAME##,${WLAN_P2P_DEVICE_NAME},g" \ + ${D}${sysconfdir}/wpa_supplicant_p2p.conf +} + +do_install_append_ccimx6sbc() { + # Customize supplicant file + cat <>${D}${sysconfdir}/wpa_supplicant.conf + +# -- SoftAP mode +# ap_scan=2 +# network={ +# ssid="ath6kl-ap" +# mode=2 +# frequency=2412 +# key_mgmt=WPA-PSK +# proto=RSN +# pairwise=CCMP +# psk="12345678" +# } + +EOF } PACKAGE_ARCH = "${MACHINE_ARCH}" diff --git a/meta-digi-dey/recipes-connectivity/xbee/xbee.bb b/meta-digi-dey/recipes-connectivity/xbee/xbee.bb index 8bf090b99..35f768c2a 100644 --- a/meta-digi-dey/recipes-connectivity/xbee/xbee.bb +++ b/meta-digi-dey/recipes-connectivity/xbee/xbee.bb @@ -1,4 +1,4 @@ -# Copyright (C) 2019 Digi International Inc. +# Copyright (C) 2019,2020 Digi International Inc. SUMMARY = "Digi XBee initialization" DESCRIPTION = "Initialization scripts for XBee hardware of Digi boards" @@ -12,12 +12,14 @@ SRC_URI = " \ " S = "${WORKDIR}" +inherit systemd update-rc.d + do_install() { install -d ${D}${sysconfdir}/init.d/ install -m 0755 ${WORKDIR}/xbee-init ${D}${sysconfdir}/ ln -sf /etc/xbee-init ${D}${sysconfdir}/init.d/xbee-init - sed -i -e "s,##XBEE_RESET_N_GPIO##,${XBEE_RESET_N_GPIO},g" \ - -e "s,##XBEE_SLEEP_RQ_GPIO##,${XBEE_SLEEP_RQ_GPIO},g" \ + sed -i -e "s/##XBEE_RESET_N_GPIO##/${XBEE_RESET_N_GPIO}/g" \ + -e "s/##XBEE_SLEEP_RQ_GPIO##/${XBEE_SLEEP_RQ_GPIO}/g" \ ${D}${sysconfdir}/xbee-init install -d ${D}${systemd_unitdir}/system/ @@ -34,7 +36,8 @@ INITSCRIPT_PACKAGES += "${PN}-init" INITSCRIPT_NAME_${PN}-init = "xbee-init" INITSCRIPT_PARAMS_${PN}-init = "start 19 2 3 4 5 . stop 21 0 1 6 ." +SYSTEMD_PACKAGES = "${PN}-init" SYSTEMD_SERVICE_${PN}-init = "xbee-init.service" PACKAGE_ARCH = "${MACHINE_ARCH}" -COMPATIBLE_MACHINE = "(ccimx8x)" +COMPATIBLE_MACHINE = "(ccimx8x|ccimx8m)" diff --git a/meta-digi-dey/recipes-connectivity/xbee/xbee/xbee-init b/meta-digi-dey/recipes-connectivity/xbee/xbee/xbee-init index 9236a2dc6..19909cf5a 100644 --- a/meta-digi-dey/recipes-connectivity/xbee/xbee/xbee-init +++ b/meta-digi-dey/recipes-connectivity/xbee/xbee/xbee-init @@ -33,29 +33,47 @@ set_gpio_value() { xbee_init() { # Power cycle XBEE_RESET_N - request_gpio_out ${XBEE_RESET_N_GPIO} - set_gpio_value ${XBEE_RESET_N_GPIO} 0 - set_gpio_value ${XBEE_RESET_N_GPIO} 1 + request_gpio_out ${1} + set_gpio_value ${1} 0 + set_gpio_value ${1} 1 # Set low XBEE_SLEEP_RQ - request_gpio_out ${XBEE_SLEEP_RQ_GPIO} - set_gpio_value ${XBEE_SLEEP_RQ_GPIO} 0 + request_gpio_out ${2} + set_gpio_value ${2} 0 } xbee_stop() { - free_gpio ${XBEE_RESET_N_GPIO} - free_gpio ${XBEE_SLEEP_RQ_GPIO} + free_gpio ${1} + free_gpio ${2} +} + +xbee_iterate_list() { + i=0 + for RESET in $(echo ${XBEE_RESET_N_GPIO} | sed "s/,/ /g"); do + j=0 + for SLEEP in $(echo ${XBEE_SLEEP_RQ_GPIO} | sed "s/,/ /g"); do + if [ "${i}" = "${j}" ]; then + if [ "${1}" = "start" ]; then + xbee_init ${RESET} ${SLEEP} + elif [ "${1}" = "stop" ]; then + xbee_stop ${RESET} ${SLEEP} + fi + fi + j="$((j + 1))" + done + i="$((i + 1))" + done } case "$1" in start) echo -n "Starting XBee hardware: " - xbee_init + xbee_iterate_list start echo "done." ;; stop) echo -n "Stopping XBee hardware: " - xbee_stop + xbee_iterate_list stop echo "done." ;; restart) diff --git a/meta-digi-dey/recipes-core/busybox/busybox/ccimx8mn/acpid.map b/meta-digi-dey/recipes-core/busybox/busybox/ccimx8mn/acpid.map new file mode 100644 index 000000000..f3940541e --- /dev/null +++ b/meta-digi-dey/recipes-core/busybox/busybox/ccimx8mn/acpid.map @@ -0,0 +1,3 @@ +#s_type n_type(hex) s_code n_code value description +EV_KEY 0x01 KEY_SLEEP 142 1 pswitch-standby +EV_KEY 0x01 KEY_POWER 116 1 pswitch-poweroff diff --git a/meta-digi-dey/recipes-core/busybox/busybox/ccimx8mn/standby b/meta-digi-dey/recipes-core/busybox/busybox/ccimx8mn/standby new file mode 100755 index 000000000..e86e1c0a1 --- /dev/null +++ b/meta-digi-dey/recipes-core/busybox/busybox/ccimx8mn/standby @@ -0,0 +1,116 @@ +#!/bin/sh +#=============================================================================== +# +# standby +# +# Copyright (C) 2020 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: suspend system to RAM +# +#=============================================================================== + +scriptname="$(basename $(readlink -f ${0}))" +syspower="/sys/power/state" +lockfile="/var/lock/${scriptname}.lock" +lockfd="9" + +BT_INIT="/etc/init.d/bluetooth-init" +BT_DAEMON="/etc/init.d/bluetooth" +NM_DAEMON="/etc/init.d/networkmanager" + +usage() { + printf "\nSuspend system to RAM memory\n" + printf "\nUsage: ${scriptname} [OPTIONS]\n + -h Show this help + \n" +} + +suspend_interfaces() { + # Stop NetworkManager before suspend + ${NM_DAEMON} stop + + # Suspend wireless interfaces + if [ -d "/proc/device-tree/wireless" ]; then + for i in $(sed -ne 's,^\(wlan[0-9]\)=.*,\1,g;T;p' /var/run/ifstate | sort -r); do + ifdown "${i}" && RESUME_IFACES="${RESUME_IFACES:+${RESUME_IFACES} }${i}" + done + grep -qs '^wlan' /proc/modules && rmmod wlan + fi + + # Suspend bluetooth interface + if [ -d "/proc/device-tree/bluetooth" ]; then + hciconfig hci0 2>&1 | grep -qs UP && up_bt_on_resume="1" + ${BT_DAEMON} stop >/dev/null + ${BT_INIT} stop >/dev/null + fi +} + +resume_interfaces() { + # Resume wireless interfaces + if [ -d "/proc/device-tree/wireless" ]; then + # Trigger wireless module loading event, and wait until the interface exists + udevadm trigger --action=add --attr-match="modalias=sdio:c00v0271d050A" + timeout -t 5 sh -c "while [ ! -d /sys/class/net/wlan0 ]; do sleep .2; done" 2>/dev/null + + # Bring up the interfaces that were bring down on suspend + for i in $(echo ${RESUME_IFACES} | tr ' ' '\n' | sort); do + grep -qs "^${i}" /var/run/ifstate || ifup "${i}" + done + fi + + # Resume bluetooth interface + if [ -d "/proc/device-tree/bluetooth" ]; then + if [ -n "${up_bt_on_resume}" ]; then + ${BT_INIT} start >/dev/null + ${BT_DAEMON} start >/dev/null + fi + fi + + # Resume NetworkManager after suspend + ${NM_DAEMON} start +} + +enter_critical_section() { + # Create lock file + eval "exec ${lockfd}>${lockfile}" + + # Acquire the lock in non blocking mode. Otherwise, additional calls + # to the script will be queued and the system will endlessly go in + # and out of suspend to ram + flock -n "${lockfd}" || exit 0 +} + +exit_critical_section() { + # Release the lock + flock -u "${lockfd}" +} + +while getopts "h" c; do + case "${c}" in + h) usage; exit;; + esac +done + +if [ -f "${syspower}" ]; then + # Avoid running multiple instances of this script in parallel + enter_critical_section + + # Pre-suspend actions + suspend_interfaces + + # Suspend the device + printf "mem" > ${syspower} + + # Post-resume actions + resume_interfaces + + exit_critical_section +else + printf "\n[ERROR] File ${syspower} not found\n\n" +fi diff --git a/meta-digi-dey/recipes-core/busybox/busybox/ccimx8mn/standby-actions b/meta-digi-dey/recipes-core/busybox/busybox/ccimx8mn/standby-actions new file mode 100644 index 000000000..987e9d3b4 --- /dev/null +++ b/meta-digi-dey/recipes-core/busybox/busybox/ccimx8mn/standby-actions @@ -0,0 +1,64 @@ +#!/bin/sh +#=============================================================================== +# +# standby-actions +# +# Copyright (C) 2020 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: manage interfaces before suspending and after resuming from +# suspend +# +#=============================================================================== + +if [ "${1}" == "pre" ]; then + # Stop NetworkManager before suspend + systemctl stop NetworkManager + + # Suspend wireless interfaces + if [ -d "/proc/device-tree/wireless" ]; then + for i in $(sed -ne 's,^\(wlan[0-9]\)=.*,\1,g;T;p' /var/run/ifstate | sort -r); do + ifdown "${i}" && RESUME_IFACES="${RESUME_IFACES:+${RESUME_IFACES} }${i}" + done + + echo ${RESUME_IFACES} > /tmp/suspend_wlan_ifaces + grep -qs '^wlan' /proc/modules && rmmod wlan + fi + + # Suspend bluetooth interface + if [ -d "/proc/device-tree/bluetooth" ]; then + hciconfig hci0 2>&1 | grep -qs UP && touch /tmp/up_bt_on_resume + systemctl stop bluetooth + systemctl stop bluetooth-init + fi +elif [ "${1}" == "post" ]; then + # Resume wireless interfaces + if [ -d "/proc/device-tree/wireless" ]; then + # Trigger wireless module loading event, and wait until the interface exists + udevadm trigger --action=add --attr-match="modalias=sdio:c00v0271d050A" + timeout -t 5 sh -c "while [ ! -d /sys/class/net/wlan0 ]; do sleep .2; done" 2>/dev/null + + # Bring up the interfaces that were brought down on suspend + for i in $(cat /tmp/suspend_wlan_ifaces | tr ' ' '\n' | sort); do + grep -qs "^${i}" /var/run/ifstate || ifup "${i}" + done + rm -f /tmp/suspend_wlan_ifaces + fi + + # Resume NetworkManager after suspend + systemctl start NetworkManager + + # Resume bluetooth interface + if [ -d "/proc/device-tree/bluetooth" ]; then + if [ -e "/tmp/up_bt_on_resume" ]; then + systemctl start bluetooth-init + systemctl start bluetooth + rm -f /tmp/up_bt_on_resume + fi + fi +fi diff --git a/meta-digi-dey/recipes-core/images/dey-image-recovery-initramfs.bb b/meta-digi-dey/recipes-core/images/dey-image-recovery-initramfs.bb index a568846e8..15cc4481e 100644 --- a/meta-digi-dey/recipes-core/images/dey-image-recovery-initramfs.bb +++ b/meta-digi-dey/recipes-core/images/dey-image-recovery-initramfs.bb @@ -1,10 +1,12 @@ -# Copyright (C) 2016-2017, Digi International Inc. +# Copyright (C) 2016-2020, Digi International Inc. DESCRIPTION = "Recovery initramfs image" LICENSE = "MIT" PACKAGE_INSTALL = " \ busybox \ + ${@bb.utils.contains('STORAGE_MEDIA', 'mmc', 'e2fsprogs-mke2fs', '', d)} \ + ${@bb.utils.contains('STORAGE_MEDIA', 'mtd', 'mtd-utils-ubifs', '', d)} \ psplash \ recovery-initramfs \ swupdate \ @@ -13,10 +15,6 @@ PACKAGE_INSTALL = " \ wipe \ " -PACKAGE_INSTALL_append_ccimx6 = " e2fsprogs-mke2fs" -PACKAGE_INSTALL_append_ccimx6ul = " mtd-utils-ubifs" -PACKAGE_INSTALL_append_ccimx8x = " e2fsprogs-mke2fs" - # Do not pollute the initrd image with rootfs features IMAGE_FEATURES = "" IMAGE_LINGUAS = "" 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 d64563721..0a84fd155 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 @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2019 Digi International Inc. +# Copyright (C) 2013-2020 Digi International Inc. FILESEXTRAPATHS_prepend := "${THISDIR}/${BP}:" @@ -7,30 +7,19 @@ INITSCRIPT_PARAMS = "start 03 2 3 4 5 . stop 80 0 6 1 ." inherit systemd +WIFI_VIRTWLANS_FILES = " \ + file://interfaces.wlan1.static \ + file://interfaces.wlan1.dhcp \ + file://virtwlans \ +" + SRC_URI_append = " \ file://ifupdown.service \ file://interfaces.br0.example \ file://interfaces.p2p \ file://p2plink \ file://resolv \ -" - -SRC_URI_append_ccimx6qpsbc = "\ - file://interfaces.wlan1.static \ - file://interfaces.wlan1.dhcp \ - file://virtwlans \ -" - -SRC_URI_append_ccimx6ul = "\ - file://interfaces.wlan1.static \ - file://interfaces.wlan1.dhcp \ - file://virtwlans \ -" - -SRC_URI_append_ccimx8x = "\ - file://interfaces.wlan1.static \ - file://interfaces.wlan1.dhcp \ - file://virtwlans \ + ${@oe.utils.conditional('HAS_WIFI_VIRTWLANS', 'true', '${WIFI_VIRTWLANS_FILES}', '', d)} \ " SYSTEMD_SERVICE_${PN} = "ifupdown.service" @@ -69,6 +58,12 @@ do_install_append() { sed -i -e "s,##WPA_DRIVER##,${WPA_DRIVER},g" ${D}${sysconfdir}/network/interfaces cat ${WORKDIR}/interfaces.br0.example >> ${D}${sysconfdir}/network/interfaces + + # Install virtual wlans files + if ${HAS_WIFI_VIRTWLANS}; then + install_virtwlans + install_wlan1 + fi } install_virtwlans() { @@ -101,21 +96,6 @@ install_wlan1() { sed -i -e "s,##WLAN1_PRE_DOWN_ACTION##,${WLAN1_PRE_DOWN_ACTION},g" ${D}${sysconfdir}/network/interfaces } -do_install_append_ccimx6qpsbc() { - install_virtwlans - install_wlan1 -} - -do_install_append_ccimx6ul() { - install_virtwlans - install_wlan1 -} - -do_install_append_ccimx8x() { - install_virtwlans - install_wlan1 -} - # Disable wireless interfaces on first boot for non-wireless variants pkg_postinst_ontarget_${PN}() { if [ ! -d "/proc/device-tree/wireless" ]; then diff --git a/meta-digi-dey/recipes-core/recovery/recovery-initramfs.bb b/meta-digi-dey/recipes-core/recovery/recovery-initramfs.bb index 119339830..2df871b24 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-initramfs.bb +++ b/meta-digi-dey/recipes-core/recovery/recovery-initramfs.bb @@ -40,7 +40,14 @@ do_install() { KEY_INDEX_1=$(expr ${KEY_INDEX} + 1) # Find the certificate to use. - CERT_IMG="$(echo ${TRUSTFENCE_SIGN_KEYS_PATH}/crts/IMG${KEY_INDEX_1}*crt.pem)" + if [ "${SIGN_MODE}" = "HAB" ]; then + CERT_IMG="$(echo ${TRUSTFENCE_SIGN_KEYS_PATH}/crts/IMG${KEY_INDEX_1}*crt.pem)" + elif [ "${SIGN_MODE}" = "AHAB" ]; then + CERT_IMG="$(echo ${TRUSTFENCE_SIGN_KEYS_PATH}/crts/SRK${KEY_INDEX_1}*_ca_crt.pem)" + else + bberror "Unkown SIGN_MODE value" + exit 1 + fi # Extract the public key from the certificate. install -d ${D}${sysconfdir}/ssl/certs @@ -53,6 +60,4 @@ PACKAGES = "${PN}" FILES_${PN} = "/" -RDEPENDS_${PN}_append_ccimx6sbc = " cryptsetup" -RDEPENDS_${PN}_append_ccimx6qpsbc = " cryptsetup" -RDEPENDS_${PN}_append_ccimx8x = " cryptsetup" +RDEPENDS_${PN}_append = "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', ' cryptsetup', '', d)}" diff --git a/meta-digi-dey/recipes-core/systemd/systemd-conf.bbappend b/meta-digi-dey/recipes-core/systemd/systemd-conf.bbappend new file mode 100644 index 000000000..f0a949fef --- /dev/null +++ b/meta-digi-dey/recipes-core/systemd/systemd-conf.bbappend @@ -0,0 +1,7 @@ +# Copyright (C) 2019 by Digi International Inc. + +FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" + +SRC_URI += "\ + file://0001-system.conf-reduce-default-stop-timeout-to-15-second.patch \ +" diff --git a/meta-digi-dey/recipes-core/systemd/systemd-conf/0001-system.conf-reduce-default-stop-timeout-to-15-second.patch b/meta-digi-dey/recipes-core/systemd/systemd-conf/0001-system.conf-reduce-default-stop-timeout-to-15-second.patch new file mode 100644 index 000000000..0b210dfd8 --- /dev/null +++ b/meta-digi-dey/recipes-core/systemd/systemd-conf/0001-system.conf-reduce-default-stop-timeout-to-15-second.patch @@ -0,0 +1,29 @@ +From: Gabriel Valcazar +Date: Thu, 17 Oct 2019 09:45:31 +0200 +Subject: [PATCH] system.conf: reduce default stop timeout to 15 seconds + +We currently don't have any services that, under normal circumstances, take +over 10 seconds to stop. In exceptional cases where services hang when stopping +due to unknown circumstances, make the timeout happen earlier to avoid stalling +the entire poweroff process for 90 seconds. + +https://jira.digi.com/browse/DEL-6794 + +Signed-off-by: Gabriel Valcazar +--- + src/core/system.conf.in | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/core/system.conf.in b/src/core/system.conf.in +index f0a59a7..c25257d 100644 +--- a/src/core/system.conf.in ++++ b/src/core/system.conf.in +@@ -35,6 +35,8 @@ + #DefaultStandardError=inherit + #DefaultTimeoutStartSec=90s + #DefaultTimeoutStopSec=90s ++# Digi-specific ++DefaultTimeoutStopSec=15s + #DefaultRestartSec=100ms + #DefaultStartLimitIntervalSec=10s + #DefaultStartLimitBurst=5 diff --git a/meta-digi-dey/recipes-core/systemd/systemd/0001-Revert-udev-remove-userspace-firmware-loading-suppor.patch b/meta-digi-dey/recipes-core/systemd/systemd/0001-Revert-udev-remove-userspace-firmware-loading-suppor.patch new file mode 100644 index 000000000..d37134abb --- /dev/null +++ b/meta-digi-dey/recipes-core/systemd/systemd/0001-Revert-udev-remove-userspace-firmware-loading-suppor.patch @@ -0,0 +1,374 @@ +From 6c0e15dd6c65b64ca773ce756a8f0356ea5229e9 Mon Sep 17 00:00:00 2001 +From: Chen Qi +Date: Wed, 28 Feb 2018 21:05:39 -0800 +Subject: [PATCH] Revert "udev: remove userspace firmware loading support" + +This reverts commit be2ea723b1d023b3d385d3b791ee4607cbfb20ca. +Userspace firmware loading support is needed for Linux < 3.7. + +Upstream-Status: Inappropriate [OE specific] + +Signed-off-by: Jonathan Liu +Signed-off-by: Khem Raj +Signed-off-by: Chen Qi +--- + README | 4 +- + TODO | 1 + + meson.build | 7 ++ + meson_options.txt | 2 + + rules/meson.build | 4 + + src/udev/meson.build | 4 + + src/udev/udev-builtin-firmware.c | 154 +++++++++++++++++++++++++++++++++++++++ + src/udev/udev-builtin.c | 3 + + src/udev/udev.h | 6 ++ + src/udev/udevd.c | 12 +++ + 10 files changed, 195 insertions(+), 2 deletions(-) + create mode 100644 src/udev/udev-builtin-firmware.c + +diff --git a/README b/README +index 2cde08c..c8cc573 100644 +--- a/README ++++ b/README +@@ -58,8 +58,8 @@ REQUIREMENTS: + Legacy hotplug slows down the system and confuses udev: + CONFIG_UEVENT_HELPER_PATH="" + +- Userspace firmware loading is not supported and should +- be disabled in the kernel: ++ Userspace firmware loading is deprecated, will go away, and ++ sometimes causes problems: + CONFIG_FW_LOADER_USER_HELPER=n + + Some udev rules and virtualization detection relies on it: +diff --git a/TODO b/TODO +index ff1008a..7949333 100644 +--- a/TODO ++++ b/TODO +@@ -844,6 +844,7 @@ Features: + * initialize the hostname from the fs label of /, if /etc/hostname does not exist? + + * udev: ++ - remove src/udev/udev-builtin-firmware.c (CONFIG_FW_LOADER_USER_HELPER=n) + - move to LGPL + - kill scsi_id + - add trigger --subsystem-match=usb/usb_device device +diff --git a/meson.build b/meson.build +index b283d1e..39dee74 100644 +--- a/meson.build ++++ b/meson.build +@@ -66,6 +66,10 @@ sysvrcnd_path = get_option('sysvrcnd-path') + conf.set10('HAVE_SYSV_COMPAT', sysvinit_path != '' and sysvrcnd_path != '', + description : 'SysV init scripts and rcN.d links are supported') + ++firmware_path = get_option('firmware-path') ++conf.set10('HAVE_FIRMWARE', firmware_path != '', ++ description : 'Userspace firmware loading is supported') ++ + # join_paths ignore the preceding arguments if an absolute component is + # encountered, so this should canonicalize various paths when they are + # absolute or relative. +@@ -180,6 +184,7 @@ conf.set_quoted('SYSTEM_CONFIG_UNIT_PATH', join_paths(pkgsysc + conf.set_quoted('SYSTEM_DATA_UNIT_PATH', systemunitdir) + conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path) + conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path) ++conf.set_quoted('FIRMWARE_PATH', firmware_path) + conf.set_quoted('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local')) + conf.set_quoted('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local')) + +@@ -267,6 +272,7 @@ substs.set('SYSTEMCTL', join_paths(rootbin + substs.set('RANDOM_SEED', join_paths(randomseeddir, 'random-seed')) + substs.set('SYSTEM_SYSVINIT_PATH', sysvinit_path) + substs.set('SYSTEM_SYSVRCND_PATH', sysvrcnd_path) ++substs.set('FIRMWARE_PATH', firmware_path) + substs.set('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local')) + substs.set('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local')) + substs.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default ? 'yes' : 'no') +@@ -2820,6 +2826,7 @@ status = [ + 'rootlib directory: @0@'.format(rootlibdir), + 'SysV init scripts: @0@'.format(sysvinit_path), + 'SysV rc?.d directories: @0@'.format(sysvrcnd_path), ++ 'firmware path: @0@'.format(firmware_path), + 'PAM modules directory: @0@'.format(pamlibdir), + 'PAM configuration directory: @0@'.format(pamconfdir), + 'RPM macros directory: @0@'.format(rpmmacrosdir), +diff --git a/meson_options.txt b/meson_options.txt +index a396ce3..9f7f1b1 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -109,6 +109,8 @@ option('tmpfiles', type : 'boolean', + description : 'support for tmpfiles.d') + option('importd', type : 'combo', choices : ['auto', 'true', 'false'], + description : 'install the systemd-importd daemon') ++option('firmware-path', type : 'string', value : '', ++ description : 'Firmware search path') + option('hwdb', type : 'boolean', + description : 'support for the hardware database') + option('rfkill', type : 'boolean', +diff --git a/rules/meson.build b/rules/meson.build +index b6a32ba..d3f3214 100644 +--- a/rules/meson.build ++++ b/rules/meson.build +@@ -26,6 +26,10 @@ rules = files(''' + install_data(rules, + install_dir : udevrulesdir) + ++if conf.get('HAVE_FIRMWARE') == 1 ++ install_data('50-firmware.rules', install_dir : udevrulesdir) ++endif ++ + all_rules = rules + + rules_in = ''' +diff --git a/src/udev/meson.build b/src/udev/meson.build +index 3bcd2bd..0dd4022 100644 +--- a/src/udev/meson.build ++++ b/src/udev/meson.build +@@ -52,6 +52,10 @@ if conf.get('HAVE_ACL') == 1 + sd_login_c] + endif + ++if conf.get('HAVE_FIRMWARE') == 1 ++ libudev_core_sources += ['udev-builtin-firmware.c'] ++endif ++ + ############################################################ + + generate_keyboard_keys_list = find_program('generate-keyboard-keys-list.sh') +diff --git a/src/udev/udev-builtin-firmware.c b/src/udev/udev-builtin-firmware.c +new file mode 100644 +index 0000000..bd8c2fb +--- /dev/null ++++ b/src/udev/udev-builtin-firmware.c +@@ -0,0 +1,154 @@ ++/* ++ * firmware - Kernel firmware loader ++ * ++ * Copyright (C) 2009 Piter Punk ++ * Copyright (C) 2009-2011 Kay Sievers ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License as ++ * published by the Free Software Foundation; either version 2 of the ++ * License, or (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, but ++ * WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * General Public License for more details:* ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "udev.h" ++ ++static bool set_loading(struct udev *udev, char *loadpath, const char *state) { ++ FILE *ldfile; ++ ++ ldfile = fopen(loadpath, "we"); ++ if (ldfile == NULL) { ++ log_error("error: can not open '%s'", loadpath); ++ return false; ++ }; ++ fprintf(ldfile, "%s\n", state); ++ fclose(ldfile); ++ return true; ++} ++ ++static bool copy_firmware(struct udev *udev, const char *source, const char *target, size_t size) { ++ char *buf; ++ FILE *fsource = NULL, *ftarget = NULL; ++ bool ret = false; ++ ++ buf = malloc(size); ++ if (buf == NULL) { ++ log_error("No memory available to load firmware file"); ++ return false; ++ } ++ ++ log_debug("writing '%s' (%zi) to '%s'", source, size, target); ++ ++ fsource = fopen(source, "re"); ++ if (fsource == NULL) ++ goto exit; ++ ftarget = fopen(target, "we"); ++ if (ftarget == NULL) ++ goto exit; ++ if (fread(buf, size, 1, fsource) != 1) ++ goto exit; ++ if (fwrite(buf, size, 1, ftarget) == 1) ++ ret = true; ++exit: ++ if (ftarget != NULL) ++ fclose(ftarget); ++ if (fsource != NULL) ++ fclose(fsource); ++ free(buf); ++ return ret; ++} ++ ++static int builtin_firmware(struct udev_device *dev, int argc, char *argv[], bool test) { ++ struct udev *udev = udev_device_get_udev(dev); ++ static const char *searchpath[] = { FIRMWARE_PATH }; ++ char loadpath[UTIL_PATH_SIZE]; ++ char datapath[UTIL_PATH_SIZE]; ++ char fwpath[UTIL_PATH_SIZE]; ++ const char *firmware; ++ FILE *fwfile = NULL; ++ struct utsname kernel; ++ struct stat statbuf; ++ unsigned int i; ++ int rc = EXIT_SUCCESS; ++ ++ firmware = udev_device_get_property_value(dev, "FIRMWARE"); ++ if (firmware == NULL) { ++ log_error("firmware parameter missing"); ++ rc = EXIT_FAILURE; ++ goto exit; ++ } ++ ++ /* lookup firmware file */ ++ uname(&kernel); ++ for (i = 0; i < ELEMENTSOF(searchpath); i++) { ++ strscpyl(fwpath, sizeof(fwpath), searchpath[i], kernel.release, "/", firmware, NULL); ++ fwfile = fopen(fwpath, "re"); ++ if (fwfile != NULL) ++ break; ++ ++ strscpyl(fwpath, sizeof(fwpath), searchpath[i], firmware, NULL); ++ fwfile = fopen(fwpath, "re"); ++ if (fwfile != NULL) ++ break; ++ } ++ ++ strscpyl(loadpath, sizeof(loadpath), udev_device_get_syspath(dev), "/loading", NULL); ++ ++ if (fwfile == NULL) { ++ log_debug("did not find firmware file '%s'", firmware); ++ rc = EXIT_FAILURE; ++ /* ++ * Do not cancel the request in the initrd, the real root might have ++ * the firmware file and the 'coldplug' run in the real root will find ++ * this pending request and fulfill or cancel it. ++ * */ ++ if (!in_initrd()) ++ set_loading(udev, loadpath, "-1"); ++ goto exit; ++ } ++ ++ if (stat(fwpath, &statbuf) < 0 || statbuf.st_size == 0) { ++ if (!in_initrd()) ++ set_loading(udev, loadpath, "-1"); ++ rc = EXIT_FAILURE; ++ goto exit; ++ } ++ ++ if (!set_loading(udev, loadpath, "1")) ++ goto exit; ++ ++ strscpyl(datapath, sizeof(datapath), udev_device_get_syspath(dev), "/data", NULL); ++ if (!copy_firmware(udev, fwpath, datapath, statbuf.st_size)) { ++ log_error("error sending firmware '%s' to device", firmware); ++ set_loading(udev, loadpath, "-1"); ++ rc = EXIT_FAILURE; ++ goto exit; ++ }; ++ ++ set_loading(udev, loadpath, "0"); ++exit: ++ if (fwfile) ++ fclose(fwfile); ++ return rc; ++} ++ ++const struct udev_builtin udev_builtin_firmware = { ++ .name = "firmware", ++ .cmd = builtin_firmware, ++ .help = "kernel firmware loader", ++ .run_once = true, ++}; +diff --git a/src/udev/udev-builtin.c b/src/udev/udev-builtin.c +index 576d83d..e58f772 100644 +--- a/src/udev/udev-builtin.c ++++ b/src/udev/udev-builtin.c +@@ -14,6 +14,9 @@ static const struct udev_builtin *builtins[] = { + [UDEV_BUILTIN_BLKID] = &udev_builtin_blkid, + #endif + [UDEV_BUILTIN_BTRFS] = &udev_builtin_btrfs, ++#if HAVE_FIRMWARE ++ [UDEV_BUILTIN_FIRMWARE] = &udev_builtin_firmware, ++#endif + [UDEV_BUILTIN_HWDB] = &udev_builtin_hwdb, + [UDEV_BUILTIN_INPUT_ID] = &udev_builtin_input_id, + [UDEV_BUILTIN_KEYBOARD] = &udev_builtin_keyboard, +diff --git a/src/udev/udev.h b/src/udev/udev.h +index 4596d0e..c800ef5 100644 +--- a/src/udev/udev.h ++++ b/src/udev/udev.h +@@ -138,6 +138,9 @@ enum udev_builtin_cmd { + UDEV_BUILTIN_BLKID, + #endif + UDEV_BUILTIN_BTRFS, ++#if HAVE_FIRMWARE ++ UDEV_BUILTIN_FIRMWARE, ++#endif + UDEV_BUILTIN_HWDB, + UDEV_BUILTIN_INPUT_ID, + UDEV_BUILTIN_KEYBOARD, +@@ -166,6 +169,9 @@ struct udev_builtin { + extern const struct udev_builtin udev_builtin_blkid; + #endif + extern const struct udev_builtin udev_builtin_btrfs; ++#if HAVE_FIRMWARE ++extern const struct udev_builtin udev_builtin_firmware; ++#endif + extern const struct udev_builtin udev_builtin_hwdb; + extern const struct udev_builtin udev_builtin_input_id; + extern const struct udev_builtin udev_builtin_keyboard; +diff --git a/src/udev/udevd.c b/src/udev/udevd.c +index 34f6a95..b132db7 100644 +--- a/src/udev/udevd.c ++++ b/src/udev/udevd.c +@@ -114,6 +114,9 @@ struct event { + bool is_block; + sd_event_source *timeout_warning; + sd_event_source *timeout; ++#if HAVE_FIRMWARE ++ bool nodelay; ++#endif + }; + + static void event_queue_cleanup(Manager *manager, enum event_state type); +@@ -604,6 +607,10 @@ static int event_queue_insert(Manager *manager, struct udev_device *dev) { + event->devnum = udev_device_get_devnum(dev); + event->is_block = streq("block", udev_device_get_subsystem(dev)); + event->ifindex = udev_device_get_ifindex(dev); ++#if HAVE_FIRMWARE ++ if (streq(udev_device_get_subsystem(dev), "firmware")) ++ event->nodelay = true; ++#endif + + log_debug("seq %llu queued, '%s' '%s'", udev_device_get_seqnum(dev), + udev_device_get_action(dev), udev_device_get_subsystem(dev)); +@@ -687,6 +694,11 @@ static bool is_devpath_busy(Manager *manager, struct event *event) { + return true; + } + ++#if HAVE_FIRMWARE ++ /* allow to bypass the dependency tracking */ ++ if (event->nodelay) ++ continue; ++#endif + /* parent device event found */ + if (event->devpath[common] == '/') { + event->delaying_seqnum = loop_event->seqnum; +-- +2.7.4 + diff --git a/meta-digi-dey/recipes-core/systemd/systemd/0007-Revert-rules-remove-firmware-loading-rules.patch b/meta-digi-dey/recipes-core/systemd/systemd/0007-Revert-rules-remove-firmware-loading-rules.patch new file mode 100644 index 000000000..bb12d30a4 --- /dev/null +++ b/meta-digi-dey/recipes-core/systemd/systemd/0007-Revert-rules-remove-firmware-loading-rules.patch @@ -0,0 +1,28 @@ +From 35d6d384e83ac38077603611bb791969ef95fe68 Mon Sep 17 00:00:00 2001 +From: Jonathan Liu +Date: Thu, 19 Mar 2015 15:01:29 +1100 +Subject: [PATCH 07/31] Revert "rules: remove firmware loading rules" + +This reverts commit 70e7d754ddb356fb1a2942b262f8cee9650e2a19. +Userspace firmware loading support is needed for Linux < 3.7. + +Upstream-Status: Inappropriate [OE specific] + +Signed-off-by: Jonathan Liu +--- + rules/50-firmware.rules | 3 +++ + 1 file changed, 3 insertions(+) + create mode 100644 rules/50-firmware.rules + +diff --git a/rules/50-firmware.rules b/rules/50-firmware.rules +new file mode 100644 +index 000000000..f0ae68451 +--- /dev/null ++++ b/rules/50-firmware.rules +@@ -0,0 +1,3 @@ ++# do not edit this file, it will be overwritten on update ++ ++SUBSYSTEM=="firmware", ACTION=="add", RUN{builtin}="firmware" +-- +2.13.0 + diff --git a/meta-digi-dey/recipes-core/systemd/systemd_%.bbappend b/meta-digi-dey/recipes-core/systemd/systemd_%.bbappend index 8c2d079c4..a8a9ca6ce 100644 --- a/meta-digi-dey/recipes-core/systemd/systemd_%.bbappend +++ b/meta-digi-dey/recipes-core/systemd/systemd_%.bbappend @@ -1,12 +1,12 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" SRC_URI += " \ + file://0001-Revert-udev-remove-userspace-firmware-loading-suppor.patch \ file://0001-udev-use-the-usual-set-of-load-paths-for-udev-rules.patch \ file://0002-sd-resolve-forcefully-cancel-worker-threads-during-r.patch \ + file://0007-Revert-rules-remove-firmware-loading-rules.patch \ " -#FIX-it: Workaround as missing ending slash in FIRMWARE_PATH [YOCIMX-2831] -EXTRA_OEMESON_remove = "-Dfirmware-path=${nonarch_base_libdir}/firmware " EXTRA_OEMESON += "-Dfirmware-path=${nonarch_base_libdir}/firmware/ " # Remove systemd-networkd from our images, since we already use NetworkManager diff --git a/meta-digi-dey/recipes-core/trustfence/trustfence-initramfs.bb b/meta-digi-dey/recipes-core/trustfence/trustfence-initramfs.bb index b4060ba2c..b5d7ac002 100644 --- a/meta-digi-dey/recipes-core/trustfence/trustfence-initramfs.bb +++ b/meta-digi-dey/recipes-core/trustfence/trustfence-initramfs.bb @@ -1,17 +1,22 @@ -# Copyright (C) 2016, 2017 Digi International Inc. +# Copyright (C) 2016-2020 Digi International Inc. SUMMARY = "Trustfence initramfs required files" LICENSE = "GPL-2.0" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" SRC_URI = " \ - file://trustfence-initramfs-init \ + ${@bb.utils.contains('STORAGE_MEDIA', 'mmc', 'file://trustfence-initramfs-init_mmc', '', d)} \ + ${@bb.utils.contains('STORAGE_MEDIA', 'mtd', 'file://trustfence-initramfs-init_mtd', '', d)} \ " S = "${WORKDIR}" do_install() { - install -m 0755 trustfence-initramfs-init ${D}/init + if [ "${STORAGE_MEDIA}" = "mmc" ]; then + install -m 0755 trustfence-initramfs-init_mmc ${D}/init + else + install -m 0755 trustfence-initramfs-init_mtd ${D}/init + fi } # Do not create debug/devel packages @@ -21,23 +26,13 @@ FILES_${PN} = "/" # Runtime packages used in 'trustfence-initramfs-init' RDEPENDS_${PN} = " \ + ${@bb.utils.contains('STORAGE_MEDIA', 'mmc', 'cryptsetup', '', d)} \ + ${@bb.utils.contains('STORAGE_MEDIA', 'mtd', 'mtd-utils-ubifs', '', d)} \ trustfence-tool \ util-linux-findfs \ wipe \ u-boot-fw-utils \ " -RDEPENDS_${PN}_append_ccimx6 = " \ - cryptsetup \ -" - -RDEPENDS_${PN}_append_ccimx6ul = " \ - mtd-utils-ubifs \ -" - -RDEPENDS_${PN}_append_ccimx8x = " \ - cryptsetup \ -" - PACKAGE_ARCH = "${MACHINE_ARCH}" -COMPATIBLE_MACHINE = "(ccimx6|ccimx6ul|ccimx8x)" \ No newline at end of file +COMPATIBLE_MACHINE = "(ccimx6|ccimx6ul|ccimx8x|ccimx8m)" diff --git a/meta-digi-dey/recipes-core/trustfence/trustfence-initramfs/ccimx6/trustfence-initramfs-init b/meta-digi-dey/recipes-core/trustfence/trustfence-initramfs/ccimx6/trustfence-initramfs-init deleted file mode 100644 index 3d763a48c..000000000 --- a/meta-digi-dey/recipes-core/trustfence/trustfence-initramfs/ccimx6/trustfence-initramfs-init +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/sh -#=============================================================================== -# -# trustfence-initramfs-init -# -# Copyright (C) 2016, 2017 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: Init script for Trustfence initramfs -# -#=============================================================================== - -POWEROFF_TIME="10" - -error() { - [ "${#}" != "0" ] && printf "\n[ERROR]: %s\n\n" "${1}" - echo "The system will poweroff in ${POWEROFF_TIME} seconds" - sleep "${POWEROFF_TIME}" - sync && poweroff -f -} - -# Main -#------------------------------------------------------------------------------ -# Setup the environment. -export PATH=/bin:/sbin:/usr/bin:/usr/sbin - -mkdir -p /proc /sys /dev -mount -t proc proc /proc -mount -t sysfs sysfs /sys -mount -t devtmpfs devtmpfs /dev - -# Set kernel console loglevel -LOGLEVEL="$(sysctl -n kernel.printk)" -sysctl -q -w kernel.printk=4 - -for arg in $(cat /proc/cmdline); do - case "${arg}" in - init=*|rescue=1|root=*) eval ${arg};; - esac -done - -# Translate "PARTUUID=..." to real device -root="$(findfs ${root})" - -# Jump to a rescue shell if requested -if [ -n "${rescue}" ]; then - # Expand console and respawn if exited - while true; do - setsid cttyhack sh -l - sleep 1 - done -fi - -# Open LUKS encrypted device -if trustfence-tool ${root} cryptroot; then - # Reset root variable to the decrypted mapped device - root="/dev/mapper/cryptroot" -else - error "unable to open encrypted partition." -fi - -# Mount mapped device -mkdir -p /newroot -FSTYPE="$(blkid ${root} | sed -e 's,.*TYPE="\([^"]\+\)".*,\1,g')" -mount ${FSTYPE:+-t ${FSTYPE}} ${root} /newroot - -# -# Clean-up and do the switch_root to the final rootfs -# -# - restore previous kernel console loglevel -# - umount virtual filesystems -# -[ -n "${LOGLEVEL}" ] && sysctl -q -w kernel.printk="${LOGLEVEL}" -mount --move /dev /newroot/dev -umount /sys /proc -exec switch_root /newroot ${init:-/sbin/init} diff --git a/meta-digi-dey/recipes-core/trustfence/trustfence-initramfs/ccimx8x/trustfence-initramfs-init b/meta-digi-dey/recipes-core/trustfence/trustfence-initramfs/trustfence-initramfs-init_mmc similarity index 100% rename from meta-digi-dey/recipes-core/trustfence/trustfence-initramfs/ccimx8x/trustfence-initramfs-init rename to meta-digi-dey/recipes-core/trustfence/trustfence-initramfs/trustfence-initramfs-init_mmc diff --git a/meta-digi-dey/recipes-core/trustfence/trustfence-initramfs/ccimx6ul/trustfence-initramfs-init b/meta-digi-dey/recipes-core/trustfence/trustfence-initramfs/trustfence-initramfs-init_mtd similarity index 100% rename from meta-digi-dey/recipes-core/trustfence/trustfence-initramfs/ccimx6ul/trustfence-initramfs-init rename to meta-digi-dey/recipes-core/trustfence/trustfence-initramfs/trustfence-initramfs-init_mtd diff --git a/meta-digi-dey/recipes-devtools/python3-xbee/python3-xbee.inc b/meta-digi-dey/recipes-devtools/python3-xbee/python3-xbee.inc index 48022327f..9ab2020b6 100644 --- a/meta-digi-dey/recipes-devtools/python3-xbee/python3-xbee.inc +++ b/meta-digi-dey/recipes-devtools/python3-xbee/python3-xbee.inc @@ -3,7 +3,7 @@ SUMMARY = "Python library to interact with Digi International's XBee radio frequency modules." HOMEPAGE = "https://github.com/digidotcom/python-xbee" -LICENSE = "MPL2.0" +LICENSE = "MPL-2.0" PYPI_PACKAGE = "digi-xbee" diff --git a/meta-digi-dey/recipes-digi/cryptoauth-openssl-engine/cryptoauth-openssl-engine/0001-Digi-modifications-to-the-cryptoauth-OpenSSL-engine.patch b/meta-digi-dey/recipes-digi/cryptoauth-openssl-engine/cryptoauth-openssl-engine/0001-Digi-modifications-to-the-cryptoauth-OpenSSL-engine.patch deleted file mode 100644 index cc4f1196e..000000000 --- a/meta-digi-dey/recipes-digi/cryptoauth-openssl-engine/cryptoauth-openssl-engine/0001-Digi-modifications-to-the-cryptoauth-OpenSSL-engine.patch +++ /dev/null @@ -1,228 +0,0 @@ -From: Gabriel Valcazar -Date: Fri, 27 Apr 2018 13:24:49 +0200 -Subject: [PATCH] Digi modifications to the cryptoauth OpenSSL engine - -https://jira.digi.com/browse/DEL-5592 - -Signed-off-by: Gabriel Valcazar ---- - Makefile | 1 + - cryptoauthlib/Makefile | 40 +++++++++++++++------------ - cryptoauthlib/lib/atca_cfgs.c | 16 +++++++++-- - cryptoauthlib/lib/openssl/eccx08_eckey_meth.c | 16 +++++------ - cryptoauthlib/lib/openssl/eccx08_engine.h | 4 +++ - 5 files changed, 49 insertions(+), 28 deletions(-) - create mode 100644 Makefile - -diff --git a/Makefile b/Makefile -new file mode 100644 -index 0000000..3025439 ---- /dev/null -+++ b/Makefile -@@ -0,0 +1 @@ -+include cryptoauthlib/Makefile -diff --git a/cryptoauthlib/Makefile b/cryptoauthlib/Makefile -index 399db53..b2596bb 100644 ---- a/cryptoauthlib/Makefile -+++ b/cryptoauthlib/Makefile -@@ -1,8 +1,11 @@ - .PHONY: all libcryptoauth libateccssl libpkcs11 dist install clean - --OPTIONS := ATCAPRINTF ATCA_HAL_KIT_CDC ENGINE_DYNAMIC_SUPPORT USE_ECCX08 ECC_DEBUG -+OPTIONS := ATCAPRINTF ATCA_HAL_I2C ENGINE_DYNAMIC_SUPPORT USE_ECCX08 ECC_DEBUG - --SYSTEM_INCLUDES := /usr/include -+SYSTEM_INCLUDES := $(DESTDIR)/usr/include -+ -+TARGET_ARCH = Linux -+TARGET_HAL = I2C - - # Check platform - ifeq ($(OS),Windows_NT) -@@ -38,7 +41,7 @@ endif - endif - - ifeq ($(uname_S),Linux) --CFLAGS += -g -O1 -m64 -Wall -fPIC $(addprefix -D,$(OPTIONS)) -+CFLAGS += -g -O1 -Wall -fPIC $(addprefix -D,$(OPTIONS)) - TARGET_ARCH := Linux - endif - # ifeq ($(uname_S),Darwin) -@@ -55,32 +58,32 @@ endif - # CCFLAGS += -D ARM - # endif - --OPENSSLDIR = /usr/include/openssl -+OPENSSLDIR = $(DESTDIR)/usr/include/openssl - --OUTDIR := $(abspath .build) -+OUTDIR := $(abspath cryptoauthlib/.build) - - DEPFLAGS = -MT $@ -MMD -MP -MF $(OUTDIR)/$*.d - ARFLAGS = rcs - - - # Wildcard all the sources and headers --SOURCES := $(call FIND,lib,*.c) --INCLUDE := $(sort $(dir $(call FIND, lib, *.h))) -+SOURCES := $(call FIND,cryptoauthlib/lib,*.c) -+INCLUDE := $(sort $(dir $(call FIND, cryptoauthlib/lib, *.h))) - - # Gather OpenSSL Engine objects --LIBATECCSSL_OBJECTS := $(filter $(abspath lib/openssl)/%, $(SOURCES)) -+LIBATECCSSL_OBJECTS := $(filter $(abspath cryptoauthlib/lib/openssl)/%, $(SOURCES)) - # Example if statically linking in the certificate definition - #LIBATECCSSL_OBJECTS += cert_def_1_signer.c cert_def_2_signer.c - LIBATECCSSL_OBJECTS := $(addprefix $(OUTDIR)/,$(notdir $(LIBATECCSSL_OBJECTS:.c=.o))) - - # Gather PKCS11 Objects --LIBPKCS11_OBJECTS := $(filter $(abspath lib/pkcs11)/%, $(SOURCES)) -+LIBPKCS11_OBJECTS := $(filter $(abspath cryptoauthlib/lib/pkcs11)/%, $(SOURCES)) - LIBPKCS11_OBJECTS := $(addprefix $(OUTDIR)/,$(notdir $(LIBPKCS11_OBJECTS:.c=.o))) - - # Gather libcryptoauth objects --LIBCRYPTOAUTH_OBJECTS := $(filter-out $(abspath lib/hal)/%, $(SOURCES)) --LIBCRYPTOAUTH_OBJECTS := $(filter-out $(abspath lib/pkcs11)/%, $(LIBCRYPTOAUTH_OBJECTS)) --LIBCRYPTOAUTH_OBJECTS := $(filter-out $(abspath lib/openssl)/%, $(LIBCRYPTOAUTH_OBJECTS)) -+LIBCRYPTOAUTH_OBJECTS := $(filter-out $(abspath cryptoauthlib/lib/hal)/%, $(SOURCES)) -+LIBCRYPTOAUTH_OBJECTS := $(filter-out $(abspath cryptoauthlib/lib/pkcs11)/%, $(LIBCRYPTOAUTH_OBJECTS)) -+LIBCRYPTOAUTH_OBJECTS := $(filter-out $(abspath cryptoauthlib/lib/openssl)/%, $(LIBCRYPTOAUTH_OBJECTS)) - LIBCRYPTOAUTH_OBJECTS += atca_hal.c - - ifeq ($(TARGET_ARCH),Windows) -@@ -101,9 +104,9 @@ LIBCRYPTOAUTH_OBJECTS += hal_linux_kit_cdc.c kit_protocol.c - endif - endif - --TEST_SOURCES := $(call FIND,test,*.c) -+TEST_SOURCES := $(call FIND,cryptoauthlib/test,*.c) - #TEST_INCLUDE := $(sort $(dir $(call FIND, test, *.h))) --TEST_INCLUDE := $(abspath .) -+TEST_INCLUDE := $(abspath cryptoauthlib/.) - TEST_OBJECTS := $(addprefix $(OUTDIR)/,$(notdir $(TEST_SOURCES:.c=.o))) - - LIBCRYPTOAUTH_OBJECTS := $(addprefix $(OUTDIR)/,$(notdir $(LIBCRYPTOAUTH_OBJECTS:.c=.o))) -@@ -126,7 +129,7 @@ $(OUTDIR)/libcryptoauth.a: $(LIBCRYPTOAUTH_OBJECTS) | $(OUTDIR) - $(AR) $(ARFLAGS) $@ $(LIBCRYPTOAUTH_OBJECTS) - - $(OUTDIR)/libateccssl.so: $(LIBATECCSSL_OBJECTS) $(LIBCRYPTOAUTH_OBJECTS) | $(OUTDIR) -- $(LD) -dll -shared $(LIBATECCSSL_OBJECTS) $(LIBCRYPTOAUTH_OBJECTS) -o $@ -lcrypto -lrt -+ $(CC) -dll -shared $(LIBATECCSSL_OBJECTS) $(LIBCRYPTOAUTH_OBJECTS) -o $@ -lcrypto -lrt - - $(OUTDIR)/test: $(OUTDIR)/libateccssl.so $(TEST_OBJECTS) | $(OUTDIR) - $(CC) -o $@ $(TEST_OBJECTS) -L$(OUTDIR) -lateccssl -lcrypto -lssl -@@ -142,7 +145,10 @@ libcryptoauth: $(OUTDIR)/libcryptoauth.a | $(OUTDIR) - all: $(LIBCRYPTOAUTH_OBJECTS) $(LIBATECCSSL_OBJECTS) $(LIBPKCS11_OBJECTS) | $(OUTDIR) - - test: $(OUTDIR)/test | $(OUTDIR) -- env LD_LIBRARY_PATH=$(OUTDIR) $(OUTDIR)/test -+ -+install: libateccssl | $(OUTDIR) -+ install -d $(DESTDIR)/usr/lib/ssl/engines -+ install -m 0755 $(OUTDIR)/libateccssl.so $(DESTDIR)/usr/lib/ssl/engines - - clean: -- rm -r $(OUTDIR) -+ rm -rf $(OUTDIR) -diff --git a/cryptoauthlib/lib/atca_cfgs.c b/cryptoauthlib/lib/atca_cfgs.c -index a8f6b68..5775f91 100644 ---- a/cryptoauthlib/lib/atca_cfgs.c -+++ b/cryptoauthlib/lib/atca_cfgs.c -@@ -47,14 +47,24 @@ - - /* if the number of these configurations grows large, we can #ifdef them based on required device support */ - -+/* Default I2C configuration */ -+#ifndef ATCA_HAL_I2C_BUS -+#define ATCA_HAL_I2C_BUS 0 -+#warning "Using default value for ATCA_HAL_I2C_BUS: 0" -+#endif -+ -+#ifndef ATCA_HAL_I2C_SPEED -+#define ATCA_HAL_I2C_SPEED 400000 -+#warning "Using default value for ATCA_HAL_I2C_SPEED: 400000" -+#endif -+ - /** \brief default configuration for an ECCx08A device */ - ATCAIfaceCfg cfg_ateccx08a_i2c_default = { - .iface_type = ATCA_I2C_IFACE, - .devtype = ATECC508A, - .atcai2c.slave_address = 0xC0, -- .atcai2c.bus = 2, -- .atcai2c.baud = 400000, -- //.atcai2c.baud = 100000, -+ .atcai2c.bus = ATCA_HAL_I2C_BUS, -+ .atcai2c.baud = ATCA_HAL_I2C_SPEED, - .wake_delay = 1500, - .rx_retries = 20 - }; -diff --git a/cryptoauthlib/lib/openssl/eccx08_eckey_meth.c b/cryptoauthlib/lib/openssl/eccx08_eckey_meth.c -index a857a92..f79a98f 100644 ---- a/cryptoauthlib/lib/openssl/eccx08_eckey_meth.c -+++ b/cryptoauthlib/lib/openssl/eccx08_eckey_meth.c -@@ -818,7 +818,7 @@ int eccx08_pmeth_selector(ENGINE *e, EVP_PKEY_METHOD **pkey_meth, - #if ATCA_OPENSSL_OLD_API - /* These are from the OpenSSL 1.1.x API */ - --static void EVP_PKEY_meth_get_init(EVP_PKEY_METHOD *pmeth, -+static void ECCX08_PKEY_meth_get_init(EVP_PKEY_METHOD *pmeth, - int(**pinit) (EVP_PKEY_CTX *ctx)) - { - if (pmeth && pinit) -@@ -827,7 +827,7 @@ static void EVP_PKEY_meth_get_init(EVP_PKEY_METHOD *pmeth, - } - } - --static void EVP_PKEY_meth_get_keygen(EVP_PKEY_METHOD *pmeth, -+static void ECCX08_PKEY_meth_get_keygen(EVP_PKEY_METHOD *pmeth, - int(**pkeygen_init) (EVP_PKEY_CTX *ctx), - int(**pkeygen) (EVP_PKEY_CTX *ctx, - EVP_PKEY *pkey)) -@@ -845,7 +845,7 @@ static void EVP_PKEY_meth_get_keygen(EVP_PKEY_METHOD *pmeth, - } - } - --static void EVP_PKEY_meth_get_sign(EVP_PKEY_METHOD *pmeth, -+static void ECCX08_PKEY_meth_get_sign(EVP_PKEY_METHOD *pmeth, - int(**psign_init) (EVP_PKEY_CTX *ctx), - int(**psign) (EVP_PKEY_CTX *ctx, - unsigned char *sig, size_t *siglen, -@@ -865,7 +865,7 @@ static void EVP_PKEY_meth_get_sign(EVP_PKEY_METHOD *pmeth, - } - } - --static void EVP_PKEY_meth_get_derive(EVP_PKEY_METHOD *pmeth, -+static void ECCX08_PKEY_meth_get_derive(EVP_PKEY_METHOD *pmeth, - int(**pderive_init) (EVP_PKEY_CTX *ctx), - int(**pderive) (EVP_PKEY_CTX *ctx, - unsigned char *key, -@@ -951,10 +951,10 @@ int eccx08_pkey_meth_init(void) - EVP_PKEY_meth_copy(eccx08_pkey_meth, defaults); - - /* Retain default methods we'll be replacing */ -- EVP_PKEY_meth_get_init(defaults, &eccx08_pkey_def_f.init); -- EVP_PKEY_meth_get_keygen(defaults, &eccx08_pkey_def_f.keygen_init, &eccx08_pkey_def_f.keygen); -- EVP_PKEY_meth_get_sign(defaults, &eccx08_pkey_def_f.sign_init, &eccx08_pkey_def_f.sign); -- EVP_PKEY_meth_get_derive(defaults, &eccx08_pkey_def_f.derive_init, &eccx08_pkey_def_f.derive); -+ ECCX08_PKEY_meth_get_init(defaults, &eccx08_pkey_def_f.init); -+ ECCX08_PKEY_meth_get_keygen(defaults, &eccx08_pkey_def_f.keygen_init, &eccx08_pkey_def_f.keygen); -+ ECCX08_PKEY_meth_get_sign(defaults, &eccx08_pkey_def_f.sign_init, &eccx08_pkey_def_f.sign); -+ ECCX08_PKEY_meth_get_derive(defaults, &eccx08_pkey_def_f.derive_init, &eccx08_pkey_def_f.derive); - - /* Replace those we need to intercept */ - EVP_PKEY_meth_set_init(eccx08_pkey_meth, eccx08_pkey_ec_init); -diff --git a/cryptoauthlib/lib/openssl/eccx08_engine.h b/cryptoauthlib/lib/openssl/eccx08_engine.h -index 0df331f..90f9673 100644 ---- a/cryptoauthlib/lib/openssl/eccx08_engine.h -+++ b/cryptoauthlib/lib/openssl/eccx08_engine.h -@@ -52,6 +52,10 @@ - - /* Configuration options */ - -+#define ATCA_OPENSSL_ENGINE_STATIC_CONFIG (0) -+#define ATCA_OPENSSL_ENGINE_ENABLE_RAND (1) -+#define ATCA_OPENSSL_ENGINE_ENABLE_SHA256 (1) -+ - /** \brief Advertize RNG to OpenSSL*/ - #ifndef ATCA_OPENSSL_ENGINE_ENABLE_RAND - #define ATCA_OPENSSL_ENGINE_ENABLE_RAND (0) diff --git a/meta-digi-dey/recipes-digi/cryptoauth-openssl-engine/cryptoauth-openssl-engine_git.bb b/meta-digi-dey/recipes-digi/cryptoauth-openssl-engine/cryptoauth-openssl-engine_git.bb deleted file mode 100644 index 073184dc8..000000000 --- a/meta-digi-dey/recipes-digi/cryptoauth-openssl-engine/cryptoauth-openssl-engine_git.bb +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (C) 2018 Digi International Inc. - -SUMMARY = "Microchip CryptoAuthentication OpenSSL engine" -SECTION = "libs" -LICENSE = "MICROCHIP_ENGINE_LICENSE" -LIC_FILES_CHKSUM = "file://LICENSE;md5=3fdaa96f37898a0641820700bbf5f7b8" - -SRCBRANCH = "master" -SRCREV = "a69a4f92af6bee9cb13035c2f859912744796380" - -GIT_URI ?= "git://github.com/MicrochipTech/cryptoauth-openssl-engine.git;protocol=https" - -SRC_URI = " \ - ${GIT_URI};nobranch=1 \ - file://0001-Digi-modifications-to-the-cryptoauth-OpenSSL-engine.patch \ -" - -S = "${WORKDIR}/git" - -I2C_BUS ?= "0" -I2C_BUS_ccimx6qpsbc = "1" - -I2C_SPEED ?= "100000" - -CFLAGS += "-DATCA_HAL_I2C_BUS=${I2C_BUS} -DATCA_HAL_I2C_SPEED=${I2C_SPEED}" - -do_install() { - oe_runmake DESTDIR=${D} install -} - -DEPENDS += "openssl" - -TARGET_CC_ARCH += "${LDFLAGS}" -FILES_${PN} += "${libdir}/ssl/engines/libateccssl.so" - -PACKAGE_ARCH = "${MACHINE_ARCH}" -COMPATIBLE_MACHINE = "(ccimx6qpsbc|ccimx6ul|ccimx8x)" diff --git a/meta-digi-dey/recipes-digi/dey-examples/dey-examples-adc-cmp.bb b/meta-digi-dey/recipes-digi/dey-examples/dey-examples-adc-cmp.bb index 1e996de50..eda8ff25d 100644 --- a/meta-digi-dey/recipes-digi/dey-examples/dey-examples-adc-cmp.bb +++ b/meta-digi-dey/recipes-digi/dey-examples/dey-examples-adc-cmp.bb @@ -1,4 +1,4 @@ -# Copyright (C) 2017-2018 Digi International. +# Copyright (C) 2017-2020 Digi International. SUMMARY = "DEY examples: Analog Comparator test application" SECTION = "examples" @@ -15,4 +15,4 @@ do_install() { } PACKAGE_ARCH = "${MACHINE_ARCH}" -COMPATIBLE_MACHINE = "(ccimx6ul|ccimx8x)" +COMPATIBLE_MACHINE = "(ccimx6ul|ccimx8x|ccimx8m)" diff --git a/meta-digi-dey/recipes-digi/dey-examples/dey-examples-cryptochip.bb b/meta-digi-dey/recipes-digi/dey-examples/dey-examples-cryptochip.bb index 685ba4fc4..3a0aecb07 100644 --- a/meta-digi-dey/recipes-digi/dey-examples/dey-examples-cryptochip.bb +++ b/meta-digi-dey/recipes-digi/dey-examples/dey-examples-cryptochip.bb @@ -1,4 +1,4 @@ -# Copyright (C) 2017-2019, Digi International Inc. +# Copyright (C) 2017-2020, Digi International Inc. require recipes-digi/dey-examples/dey-examples-src.inc @@ -18,4 +18,4 @@ do_install() { } PACKAGE_ARCH = "${MACHINE_ARCH}" -COMPATIBLE_MACHINE = "(ccimx6qpsbc|ccimx6ul|ccimx8x)" +COMPATIBLE_MACHINE = "(ccimx6qpsbc|ccimx6ul|ccimx8x|ccimx8m)" diff --git a/meta-digi-dey/recipes-digi/dey-examples/dey-examples-v4l2.bb b/meta-digi-dey/recipes-digi/dey-examples/dey-examples-v4l2.bb index f233abfbe..d10a2a52d 100644 --- a/meta-digi-dey/recipes-digi/dey-examples/dey-examples-v4l2.bb +++ b/meta-digi-dey/recipes-digi/dey-examples/dey-examples-v4l2.bb @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2018 Digi International. +# Copyright (C) 2013-2020 Digi International. SUMMARY = "DEY examples: V4L2 test application" SECTION = "examples" @@ -24,4 +24,4 @@ do_install() { PACKAGE_ARCH = "${MACHINE_ARCH}" -COMPATIBLE_MACHINE = "(ccimx6$|ccimx8x)" +COMPATIBLE_MACHINE = "(ccimx6$|ccimx8x|ccimx8m)" diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/adc_cmp_sample/adc_cmp_sample.c b/meta-digi-dey/recipes-digi/dey-examples/files/adc_cmp_sample/adc_cmp_sample.c index 578bc249e..25d721904 100644 --- a/meta-digi-dey/recipes-digi/dey-examples/files/adc_cmp_sample/adc_cmp_sample.c +++ b/meta-digi-dey/recipes-digi/dey-examples/files/adc_cmp_sample/adc_cmp_sample.c @@ -1,7 +1,7 @@ /* - * ConnectCore 6UL Analog Comparator sample application. + * ConnectCore Analog Comparator sample application. * - * Copyright (c) 2017 Digi International Inc. + * Copyright (c) 2017-2020 Digi International Inc. * All rights reserved. * * Based on iio_event_monitor.c from the tools/iio directory, of the linux @@ -32,7 +32,7 @@ "Usage:\n" \ "adc_cmp_sample -c channel [options]\n\n" \ "Options:\n" \ - " -t : ADC_type ('MCA-CC6UL', 'MCA-CC8X')\n" \ + " -t : ADC_type ('MCA-CC6UL', 'MCA-CC8X', 'MCA-CC8M')\n" \ " -c : channel number to read from\n" \ " -h : Threshold_high higher limit of the comparator window\n" \ " -l : Threshold_low lower limit of the comparator window\n" \ @@ -44,6 +44,7 @@ enum adc_type { ADC_TYPE_UNKNOWN, ADC_TYPE_MCA_CC6UL, ADC_TYPE_MCA_CC8X, + ADC_TYPE_MCA_CC8M, }; struct adc_data { @@ -66,6 +67,12 @@ struct adc_data adc_list[] = { .dev_name = "mca-cc8x-adc", .nbits = 12, }, + { + .type = ADC_TYPE_MCA_CC8M, + .name = "MCA-CC8M", + .dev_name = "mca-cc8m-adc", + .nbits = 12, + }, }; typedef struct cmp { diff --git a/meta-digi-dey/recipes-digi/libdigiapix/libdigiapix-git/ccimx8mn-dvk/libdigiapix.conf b/meta-digi-dey/recipes-digi/libdigiapix/libdigiapix-git/ccimx8mn-dvk/libdigiapix.conf new file mode 100644 index 000000000..e2c401ab4 --- /dev/null +++ b/meta-digi-dey/recipes-digi/libdigiapix/libdigiapix-git/ccimx8mn-dvk/libdigiapix.conf @@ -0,0 +1,36 @@ +[board] +model = Digi International ConnectCore 8M Nano DVK. + +[GPIO] + +# USER LED1 - MCA_IO12 +USER_LED = 505 +USER_LED1 = 505 + +# USER_LED2 - MCA_IO18 +USER_LED2 = 511 + +# USER_LED3 - GPIO2_IO19 +USER_LED3 = 51 + +# USER BUTTON1 - MCA_IO10 +USER_BUTTON = 503 +USER_BUTTON1 = 503 + +# USER BUTTON2 - GPIO2_IO20 +USER_BUTTON2 = 52 + +[I2C] + +# I2C-4 on Expansion connector. +DEFAULT_I2C_BUS = 4 + +[PWM] + +# PWM0 channel 1 USER_LED1. +DEFAULT_PWM = 0,1 + +[ADC] + +# MCA_IO1 (channel 1) at XBEE1_UART_TX. Not enabled by default. +DEFAULT_ADC = 0,1 diff --git a/meta-digi-dey/recipes-digi/libdigiapix/libdigiapix-git/ccimx8x-sbc-pro/libdigiapix.conf b/meta-digi-dey/recipes-digi/libdigiapix/libdigiapix-git/ccimx8x-sbc-pro/libdigiapix.conf index 5dc776e25..021aa99ca 100644 --- a/meta-digi-dey/recipes-digi/libdigiapix/libdigiapix-git/ccimx8x-sbc-pro/libdigiapix.conf +++ b/meta-digi-dey/recipes-digi/libdigiapix/libdigiapix-git/ccimx8x-sbc-pro/libdigiapix.conf @@ -10,8 +10,8 @@ USER_LED0 = 223 # USER_LED1 - MCA_IO10 USER_LED1 = 215 -# USER BUTTON - MCA_IO05 -USER_BUTTON = 210 +# USER BUTTON - MCA_IO07 +USER_BUTTON = 212 [I2C] @@ -25,7 +25,7 @@ DEFAULT_SPI = 32766,0 [PWM] -# MCA PWM1 channel 0 on Expansion connector (MCA_IO5) +# MCA PWM2 channel 0 on Expansion connector (MCA_IO7) DEFAULT_PWM = 7,0 [ADC] 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 2e428dea3..8668c9b82 100644 --- a/meta-digi-dey/recipes-digi/packagegroups/packagegroup-dey-examples.bb +++ b/meta-digi-dey/recipes-digi/packagegroups/packagegroup-dey-examples.bb @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2019, Digi International Inc. +# Copyright (C) 2013-2020, Digi International Inc. SUMMARY = "DEY examples packagegroup" @@ -38,4 +38,10 @@ RDEPENDS_${PN}_append_ccimx8x = "\ dey-examples-v4l2 \ " -COMPATIBLE_MACHINE = "(ccimx6$|ccimx6ul|ccimx8x)" +RDEPENDS_${PN}_append_ccimx8m = "\ + dey-examples-adc-cmp \ + dey-examples-tamper \ + dey-examples-v4l2 \ +" + +COMPATIBLE_MACHINE = "(ccimx6$|ccimx6ul|ccimx8x|ccimx8m)" diff --git a/meta-digi-dey/recipes-digi/swu-images/files/ccimx6/preinstall_swu.sh b/meta-digi-dey/recipes-digi/swu-images/files/ccimx6/preinstall_swu.sh deleted file mode 100644 index 8723cfc11..000000000 --- a/meta-digi-dey/recipes-digi/swu-images/files/ccimx6/preinstall_swu.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/sh -#=============================================================================== -# -# preinstall_swu.sh -# -# Copyright (C) 2017 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: SWUpdate pre-install script to open the virtual mapped device -# -# SWUpdate calls this script before installing the image. -# -#=============================================================================== - -# Functions. -#------------------------------------------------------------------------------ -# Function - psplash_message -# -# Shows the given message in the psplash screen. -# -# @param ${1} - Message to show. -#------------------------------------------------------------------------------ -psplash_message() { - echo "MSG ${1}" > /tmp/psplash_fifo - sleep 0.2 -} - -#------------------------------------------------------------------------------ -# Function - psplash_progress -# -# Sets the psplash progress bar percentage to the given one. -# -# @param ${1} - Progress percentage. -#------------------------------------------------------------------------------ -psplash_progress() { - echo "PROGRESS ${1}" > /tmp/psplash_fifo - sleep 0.2 -} - -#------------------------------------------------------------------------------ -# Function - log -# -# Prints the given text in the console. -# -# @param ${1} - Text to print. -#------------------------------------------------------------------------------ -log() { - echo "[FW UPDATE] ${1}" -} - -#------------------------------------------------------------------------------ -# Function - log_error -# -# Prints the given text in the console as an error. -# -# @param ${1} - Error text to print. -#------------------------------------------------------------------------------ -log_error() { - log "[ERROR] ${1}" - psplash_message "ERROR: ${1}" - psplash_progress "0" -} - -# Main -#------------------------------------------------------------------------------ -# Check if encrypted device is already open. -if [ -b /dev/mapper/cryptroot ]; then - exit 0 -fi - -rootfs_block="/dev/mmcblk0p$(fdisk -l /dev/mmcblk0 | sed -ne "s,^[^0-9]*\([0-9]\+\).*\.*,\1,g;T;p")" - -# Open LUKS encrypted device -trustfence-tool ${rootfs_block} cryptroot -if [ "$?" != "0" ]; then - log_error "Error executing the firmware update, cannot open virtual device" - exit 1 -fi - diff --git a/meta-digi-dey/recipes-digi/swu-images/files/ccimx8x/sw-description b/meta-digi-dey/recipes-digi/swu-images/files/ccimx8x/sw-description deleted file mode 100644 index cde521bf2..000000000 --- a/meta-digi-dey/recipes-digi/swu-images/files/ccimx8x/sw-description +++ /dev/null @@ -1,20 +0,0 @@ -software = -{ - version = "##SW_VERSION##"; - - images: ( - { - filename = "##BOOTIMG_NAME##"; - device = "##BOOT_DEV##"; - type = "raw"; - sha256 = "@##BOOTIMG_NAME##"; - }, - { - filename = "##ROOTIMG_NAME##"; - device = "##ROOTFS_DEV##"; - type = "raw"; - sha256 = "@##ROOTIMG_NAME##"; - } - ); - ##PREINSTALL_SCRIPT## -} diff --git a/meta-digi-dey/recipes-digi/swu-images/files/ccimx8x/preinstall_swu.sh b/meta-digi-dey/recipes-digi/swu-images/files/preinstall_swu.sh similarity index 100% rename from meta-digi-dey/recipes-digi/swu-images/files/ccimx8x/preinstall_swu.sh rename to meta-digi-dey/recipes-digi/swu-images/files/preinstall_swu.sh diff --git a/meta-digi-dey/recipes-digi/swu-images/files/ccimx6/sw-description b/meta-digi-dey/recipes-digi/swu-images/files/sw-description similarity index 100% rename from meta-digi-dey/recipes-digi/swu-images/files/ccimx6/sw-description rename to meta-digi-dey/recipes-digi/swu-images/files/sw-description diff --git a/meta-digi-dey/recipes-digi/swu-images/swu.inc b/meta-digi-dey/recipes-digi/swu-images/swu.inc index 391bc4685..48bd622d1 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, 2017 Digi International Inc. +# Copyright (C) 2016-2020 Digi International Inc. SUMMARY = "Generate update package for SWUpdate" SECTION = "base" LICENSE = "GPL-2.0" @@ -8,6 +8,7 @@ SRC_URI = "file://sw-description" SRC_URI_append_ccimx6 = " ${@oe.utils.ifelse(d.getVar('TRUSTFENCE_INITRAMFS_IMAGE', True), 'file://preinstall_swu.sh', '')}" SRC_URI_append_ccimx6ul = " ${@oe.utils.ifelse(d.getVar('TRUSTFENCE_INITRAMFS_IMAGE', True), '', 'file://preinstall_swu.sh')}" SRC_URI_append_ccimx8x = " ${@oe.utils.ifelse(d.getVar('TRUSTFENCE_INITRAMFS_IMAGE', True), 'file://preinstall_swu.sh', '')}" +SRC_URI_append_ccimx8m = " ${@oe.utils.ifelse(d.getVar('TRUSTFENCE_INITRAMFS_IMAGE', True), 'file://preinstall_swu.sh', '')}" inherit swupdate @@ -36,6 +37,7 @@ PREINST_SCRIPT_DESC = "" PREINST_SCRIPT_DESC_ccimx6 = "${@oe.utils.ifelse(d.getVar('TRUSTFENCE_INITRAMFS_IMAGE', True), '${PREINST_SCRIPT_TEMPLATE}', '')}" PREINST_SCRIPT_DESC_ccimx6ul = "${@oe.utils.ifelse(d.getVar('TRUSTFENCE_INITRAMFS_IMAGE', True), '', '${PREINST_SCRIPT_TEMPLATE}')}" PREINST_SCRIPT_DESC_ccimx8x = "${@oe.utils.ifelse(d.getVar('TRUSTFENCE_INITRAMFS_IMAGE', True), '${PREINST_SCRIPT_TEMPLATE}', '')}" +PREINST_SCRIPT_DESC_ccimx8m = "${@oe.utils.ifelse(d.getVar('TRUSTFENCE_INITRAMFS_IMAGE', True), '${PREINST_SCRIPT_TEMPLATE}', '')}" python () { img_fstypes = d.getVar('BOOTFS_EXT', True) + " " + d.getVar('ROOTFS_EXT', True) diff --git a/meta-digi-dey/recipes-digi/sysinfo/sysinfo/sysinfo b/meta-digi-dey/recipes-digi/sysinfo/sysinfo/sysinfo index 1f85877fb..4a542fd84 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-2018 by Digi International Inc. +# Copyright (C) 2016-2020 by Digi International Inc. # All rights reserved. # # This program is free software; you can redistribute it and/or modify it @@ -229,6 +229,25 @@ make_report(){ fi printf "\n\n" + echo "--------------------------------------" + echo "- -" + echo "- OTP values -" + echo "- -" + echo "--------------------------------------" + echo "" + if [ -d /sys/fsl_otp ]; then + for f in /sys/fsl_otp/*; do + echo -e "$f:\t$(cat $f)" + done + echo "" + fi + for d in /sys/bus/nvmem/devices/*; do + [ -e $d ] || continue + echo "$d:" + hexdump -C $d/nvmem + echo "" + done + echo "--------------------------------------" echo "- -" echo "- TrustFence -" @@ -270,7 +289,7 @@ BOARD_ID="$(cat /proc/device-tree/digi,carrierboard,id | tr -d '\0')" if grep -qs '\' /proc/device-tree/compatible; then MCA_NODE="/sys/bus/i2c/devices/0-007e" -elif grep -qs '\' /proc/device-tree/compatible; then +elif grep -qs '\' /proc/device-tree/compatible; then MCA_NODE="/sys/bus/i2c/devices/0-0063" fi if [ -d "$MCA_NODE" ]; then diff --git a/meta-digi-dey/recipes-graphics/clutter/clutter-1.0_%.bbappend b/meta-digi-dey/recipes-graphics/clutter/clutter-1.0_%.bbappend deleted file mode 100644 index bf03d1297..000000000 --- a/meta-digi-dey/recipes-graphics/clutter/clutter-1.0_%.bbappend +++ /dev/null @@ -1,5 +0,0 @@ -PACKAGECONFIG_imxgpu3d ??= " \ - ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland egl', \ - bb.utils.contains('DISTRO_FEATURES', 'x11', 'glx x11', \ - '', d), d)} \ -" diff --git a/meta-digi-dey/recipes-graphics/cogl/cogl-1.0_%.bbappend b/meta-digi-dey/recipes-graphics/cogl/cogl-1.0_%.bbappend deleted file mode 100644 index afbaee432..000000000 --- a/meta-digi-dey/recipes-graphics/cogl/cogl-1.0_%.bbappend +++ /dev/null @@ -1,5 +0,0 @@ -PACKAGECONFIG_imxgpu3d ??= " \ - cogl-pango gles2 \ - ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'egl-wayland', \ - bb.utils.contains('DISTRO_FEATURES', 'x11', 'egl-x11', \ - '', d), d)}" diff --git a/meta-digi-dey/recipes-graphics/glm/glm/Fixed-GCC-7.3-compile.patch b/meta-digi-dey/recipes-graphics/glm/glm/Fixed-GCC-7.3-compile.patch new file mode 100644 index 000000000..1332cbfda --- /dev/null +++ b/meta-digi-dey/recipes-graphics/glm/glm/Fixed-GCC-7.3-compile.patch @@ -0,0 +1,22 @@ +diff --git a/glm/simd/platform.h b/glm/simd/platform.h +index a5510beb..b54d8a34 100644 +--- a/glm/simd/platform.h ++++ b/glm/simd/platform.h +@@ -111,6 +111,7 @@ + #define GLM_COMPILER_GCC70 0x02000A00 + #define GLM_COMPILER_GCC71 0x02000B00 + #define GLM_COMPILER_GCC72 0x02000C00 ++#define GLM_COMPILER_GCC7X 0x02000C01 + #define GLM_COMPILER_GCC80 0x02000D00 + + // CUDA +@@ -283,6 +284,8 @@ + # define GLM_COMPILER (GLM_COMPILER_GCC71) + # elif (__GNUC__ == 7) && (__GNUC_MINOR__ == 2) + # define GLM_COMPILER (GLM_COMPILER_GCC72) ++# elif (__GNUC__ == 7) ++# define GLM_COMPILER (GLM_COMPILER_GCC7X) + # elif (__GNUC__ >= 8) + # define GLM_COMPILER (GLM_COMPILER_GCC80) + # else + \ No newline at end of file diff --git a/meta-digi-dey/recipes-graphics/glm/glm_0.9.8.4.bb b/meta-digi-dey/recipes-graphics/glm/glm_0.9.8.5.bb similarity index 74% rename from meta-digi-dey/recipes-graphics/glm/glm_0.9.8.4.bb rename to meta-digi-dey/recipes-graphics/glm/glm_0.9.8.5.bb index 2d2e9ade4..c5fed924c 100644 --- a/meta-digi-dey/recipes-graphics/glm/glm_0.9.8.4.bb +++ b/meta-digi-dey/recipes-graphics/glm/glm_0.9.8.5.bb @@ -10,13 +10,14 @@ SECTION = "libs" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://copying.txt;md5=4431606d144252143c9c3df384a74cad" -SRC_URI = "git://github.com/g-truc/glm;protocol=https" - -SRCREV = "5dcc56489e1b66dfd5bca751fa9b8dc68059e008" - +SRC_URI = "git://github.com/g-truc/glm;branch=0.9.8 \ + file://Fixed-GCC-7.3-compile.patch" +SRCREV = "6fa203eeb7fbcbb6f620501fad40359c8a456049" S = "${WORKDIR}/git" inherit cmake FILES_${PN}-dev += "${libdir}/cmake" RDEPENDS_${PN}-dev = "" + +BBCLASSEXTEND = "native" diff --git a/meta-digi-dey/recipes-graphics/imx-dpu-g2d/imx-dpu-g2d_1.7.1.bb b/meta-digi-dey/recipes-graphics/imx-dpu-g2d/imx-dpu-g2d_1.7.4.bb similarity index 80% rename from meta-digi-dey/recipes-graphics/imx-dpu-g2d/imx-dpu-g2d_1.7.1.bb rename to meta-digi-dey/recipes-graphics/imx-dpu-g2d/imx-dpu-g2d_1.7.4.bb index b71eea828..f936a9a75 100644 --- a/meta-digi-dey/recipes-graphics/imx-dpu-g2d/imx-dpu-g2d_1.7.1.bb +++ b/meta-digi-dey/recipes-graphics/imx-dpu-g2d/imx-dpu-g2d_1.7.4.bb @@ -4,7 +4,7 @@ DESCRIPTION = "GPU G2D library and apps for i.MX with 2D GPU and DPU" LICENSE = "Proprietary" -LIC_FILES_CHKSUM = "file://COPYING;md5=72c0f70181bb6e83eee6aab8de12a9f3" +LIC_FILES_CHKSUM = "file://COPYING;md5=fd4b227530cd88a82af6a5982cfb724d" RDEPENDS_${PN} = "libgal-imx libdrm" @@ -16,8 +16,8 @@ S="${WORKDIR}/${PN}-${PV}" inherit fsl-eula-unpack -SRC_URI[md5sum] = "cb59630320d91c4a11306e60a682781d" -SRC_URI[sha256sum] = "cee8b44509d15b9eb0dbf736d25c080d151602849a5e621be13e9b8f7b501f04" +SRC_URI[md5sum] = "111e89e33fe80be50ef526546c6b362b" +SRC_URI[sha256sum] = "4744a210af15c2d9ae9138c90e4ccc56138c9b03611286d781ac17d5a676c8ec" do_install () { diff --git a/meta-digi-dey/recipes-graphics/imx-gpu-g2d/imx-gpu-g2d_6.2.4.p4.2.bb b/meta-digi-dey/recipes-graphics/imx-gpu-g2d/imx-gpu-g2d_6.2.4.p4.6.bb similarity index 70% rename from meta-digi-dey/recipes-graphics/imx-gpu-g2d/imx-gpu-g2d_6.2.4.p4.2.bb rename to meta-digi-dey/recipes-graphics/imx-gpu-g2d/imx-gpu-g2d_6.2.4.p4.6.bb index b9688af78..c0d78dd82 100644 --- a/meta-digi-dey/recipes-graphics/imx-gpu-g2d/imx-gpu-g2d_6.2.4.p4.2.bb +++ b/meta-digi-dey/recipes-graphics/imx-gpu-g2d/imx-gpu-g2d_6.2.4.p4.6.bb @@ -5,7 +5,7 @@ DESCRIPTION = "GPU G2D library and apps for i.MX with 2D GPU and no DPU" LICENSE = "Proprietary" -LIC_FILES_CHKSUM = "file://COPYING;md5=72c0f70181bb6e83eee6aab8de12a9f3" +LIC_FILES_CHKSUM = "file://COPYING;md5=fd4b227530cd88a82af6a5982cfb724d" DEPENDS += "libgal-imx" PROVIDES += "virtual/libg2d" @@ -13,10 +13,10 @@ PROVIDES += "virtual/libg2d" FSLBIN_NAME = "${PN}-${PV}-${TARGET_ARCH}" SRC_URI = "${FSL_MIRROR}/${FSLBIN_NAME}.bin;name=${TARGET_ARCH};fsl-eula=true" -SRC_URI[aarch64.md5sum] = "a2d9e2b0f373a14bb41621a1cded3112" -SRC_URI[aarch64.sha256sum] = "b5bd824386c30fbe167a529344a3e6f7c87adf9e9bdd4184680e28968d1e9853" -SRC_URI[arm.md5sum] = "83777eac2bcd959894ca964f9cb5c9a0" -SRC_URI[arm.sha256sum] = "2210c5590a822a764838dfdefed08c882c70c14dc29fba04c255cee8b4df5196" +SRC_URI[aarch64.md5sum] = "a7c573ba8bea4850d60dfadead54fda8" +SRC_URI[aarch64.sha256sum] = "4964f799a4eb735689cdfd25f95ecc88140366986d8f48dfd0cf05264773d072" +SRC_URI[arm.md5sum] = "4789b83df4429ddfd649040c1c84efdc" +SRC_URI[arm.sha256sum] = "02756a63afb59f58445e9c9f08ec68cd0292b75ab7b99daad09eb06d020a7f54" S="${WORKDIR}/${FSLBIN_NAME}" diff --git a/meta-digi-dey/recipes-graphics/imx-gpu-viv/imx-gpu-viv-v6.inc b/meta-digi-dey/recipes-graphics/imx-gpu-viv/imx-gpu-viv-v6.inc index 9b00659b6..849648aa3 100644 --- a/meta-digi-dey/recipes-graphics/imx-gpu-viv/imx-gpu-viv-v6.inc +++ b/meta-digi-dey/recipes-graphics/imx-gpu-viv/imx-gpu-viv-v6.inc @@ -300,7 +300,9 @@ FILES_libegl-imx-dev = "${includedir}/EGL ${includedir}/KHR ${libdir}/pkgconfig/ FILES_libgal-imx = "${libdir}/libGAL${SOLIBS} ${libdir}/libGAL_egl${SOLIBS}" FILES_libgal-imx-dev = "${libdir}/libGAL${SOLIBSDEV} ${includedir}/HAL" -RDEPENDS_libgal-imx += "kernel-module-imx-gpu-viv" +# Digi custom change: we include the imx-gpu-viv driver as built-in in the +# kernel, so this dependency isn't necessary +#RDEPENDS_libgal-imx += "kernel-module-imx-gpu-viv" RPROVIDES_libgal-imx += "libgal-imx" INSANE_SKIP_libgal-imx += "build-deps" diff --git a/meta-digi-dey/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.2.4.p4.2-aarch32.bb b/meta-digi-dey/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.2.4.p4.2-aarch32.bb deleted file mode 100644 index 8761a980f..000000000 --- a/meta-digi-dey/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.2.4.p4.2-aarch32.bb +++ /dev/null @@ -1,8 +0,0 @@ -require imx-gpu-viv-v6.inc - -LIC_FILES_CHKSUM = "file://COPYING;md5=72c0f70181bb6e83eee6aab8de12a9f3" - -SRC_URI[md5sum] = "db096170c024aee88c48dd5b627e54b9" -SRC_URI[sha256sum] = "aa53c15c34b7af3b05876a0dfe4046ed4b864464d1bc9f10dcc0978e448f12a2" - -COMPATIBLE_MACHINE = "(mx6q|mx6dl|mx6sx|mx6sl|mx7ulp)" diff --git a/meta-digi-dey/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.2.4.p4.2-aarch64.bb b/meta-digi-dey/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.2.4.p4.2-aarch64.bb deleted file mode 100644 index 66e2da76f..000000000 --- a/meta-digi-dey/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.2.4.p4.2-aarch64.bb +++ /dev/null @@ -1,8 +0,0 @@ -require imx-gpu-viv-v6.inc - -LIC_FILES_CHKSUM = "file://COPYING;md5=72c0f70181bb6e83eee6aab8de12a9f3" - -SRC_URI[md5sum] = "fd50ff48725e6dd44aab2e08aeb87717" -SRC_URI[sha256sum] = "a36cea6116f3e04ef0fbaf880965eed71b093a065e25c91b2b494df0f944792b" - -COMPATIBLE_MACHINE = "(mx8)" diff --git a/meta-digi-dey/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.2.4.p4.6-aarch32.bb b/meta-digi-dey/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.2.4.p4.6-aarch32.bb new file mode 100644 index 000000000..c19e182c6 --- /dev/null +++ b/meta-digi-dey/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.2.4.p4.6-aarch32.bb @@ -0,0 +1,8 @@ +require imx-gpu-viv-v6.inc + +LIC_FILES_CHKSUM = "file://COPYING;md5=fd4b227530cd88a82af6a5982cfb724d" + +SRC_URI[md5sum] = "24b5cd3a0bec8f91d82f404c61c6f7a7" +SRC_URI[sha256sum] = "59ab4f99cb8455cdfabd9228e2066190bbc229f758425846c60e853c2f70c26f" + +COMPATIBLE_MACHINE = "(mx6q|mx6dl|mx6sx|mx6sl|mx7ulp)" diff --git a/meta-digi-dey/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.2.4.p4.6-aarch64.bb b/meta-digi-dey/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.2.4.p4.6-aarch64.bb new file mode 100644 index 000000000..40ecd825c --- /dev/null +++ b/meta-digi-dey/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.2.4.p4.6-aarch64.bb @@ -0,0 +1,8 @@ +require imx-gpu-viv-v6.inc + +LIC_FILES_CHKSUM = "file://COPYING;md5=fd4b227530cd88a82af6a5982cfb724d" + +SRC_URI[md5sum] = "c0e0431e8d67e57301b7fa91369cd6c5" +SRC_URI[sha256sum] = "0b7eda7d702c06a2b5274b93d870e8370bc85961f6e98b8d41afcfc86e384d80" + +COMPATIBLE_MACHINE = "(mx8)" diff --git a/meta-digi-dey/recipes-graphics/mesa/mesa-demos/Add-OpenVG-demos-to-support-wayland.patch b/meta-digi-dey/recipes-graphics/mesa/mesa-demos/Add-OpenVG-demos-to-support-wayland.patch deleted file mode 100644 index 19bcca98c..000000000 --- a/meta-digi-dey/recipes-graphics/mesa/mesa-demos/Add-OpenVG-demos-to-support-wayland.patch +++ /dev/null @@ -1,84 +0,0 @@ -From 8aba54422d9a77383c150f9f70240b18b6e1918e Mon Sep 17 00:00:00 2001 -From: Prabhu Sundararaj -Date: Thu, 9 Apr 2015 15:47:21 -0500 -Subject: [PATCH] Add OpenVG demos to support wayland. - -Upstream-Status: Pending - -Signed-off-by: Prabhu Sundararaj ---- - src/egl/Makefile.am | 6 +++--- - src/egl/openvg/Makefile.am | 33 +++++++++++++++++++++++++++++---- - 2 files changed, 32 insertions(+), 7 deletions(-) - -Index: mesa-demos-8.2.0/src/egl/Makefile.am -=================================================================== ---- mesa-demos-8.2.0.orig/src/egl/Makefile.am 2016-05-09 11:45:51.479100180 -0500 -+++ mesa-demos-8.2.0/src/egl/Makefile.am 2016-05-09 11:45:51.475100160 -0500 -@@ -26,10 +26,10 @@ - eglut \ - opengles1 \ - opengles2 \ -- oes_vg -+ oes_vg \ -+ openvg - - if HAVE_GLU - SUBDIRS += \ -- opengl \ -- openvg -+ opengl - endif -Index: mesa-demos-8.2.0/src/egl/openvg/Makefile.am -=================================================================== ---- mesa-demos-8.2.0.orig/src/egl/openvg/Makefile.am 2016-05-09 11:45:51.479100180 -0500 -+++ mesa-demos-8.2.0/src/egl/openvg/Makefile.am 2016-05-09 12:39:30.000000000 -0500 -@@ -47,13 +47,26 @@ - endif - endif - -+if HAVE_WAYLAND -+EGL_WL_DEMOS = \ -+ lion_wayland \ -+ sp_wayland -+ -+if HAVE_FREETYPE2 -+EGL_WL_DEMOS += \ -+ vgtext_wayland -+endif -+endif -+ - if HAVE_EGL - if HAVE_VG - bin_PROGRAMS = \ -- $(EGL_X11_DEMOS) -+ $(EGL_X11_DEMOS) \ -+ $(EGL_WL_DEMOS) - endif - endif - -+if HAVE_X11 - lion_x11_SOURCES = lion.c lion-render.c lion-render.h - sp_x11_SOURCES = sp.c - -@@ -63,6 +76,20 @@ - text_SOURCES = text.c - text_CFLAGS = $(AM_CFLAGS) @FREETYPE2_CFLAGS@ - text_LDADD = @FREETYPE2_LIBS@ ../eglut/libeglut_x11.la -+endif -+ -+if HAVE_WAYLAND -+lion_wayland_SOURCES = lion.c lion-render.c lion-render.h -+lion_wayland_LDADD = ../eglut/libeglut_wayland.la -+ -+sp_wayland_SOURCES = sp.c -+sp_wayland_LDADD = ../eglut/libeglut_wayland.la -+ -+vgtext_wayland_SOURCES = text.c -+vgtext_wayland_CFLAGS = $(AM_CFLAGS) @FREETYPE2_CFLAGS@ -+vgtext_wayland_LDADD = @FREETYPE2_LIBS@ ../eglut/libeglut_wayland.la -+ -+endif - - SUBDIRS = \ - trivial diff --git a/meta-digi-dey/recipes-graphics/mesa/mesa-demos/Additional-eglSwapBuffer-calling-makes-wrong-throttl.patch b/meta-digi-dey/recipes-graphics/mesa/mesa-demos/Additional-eglSwapBuffer-calling-makes-wrong-throttl.patch deleted file mode 100644 index 180a9d84e..000000000 --- a/meta-digi-dey/recipes-graphics/mesa/mesa-demos/Additional-eglSwapBuffer-calling-makes-wrong-throttl.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 010af1952d935352764389636b7165283e6c9e3f Mon Sep 17 00:00:00 2001 -From: Prabhu Sundararaj -Date: Tue, 7 Apr 2015 17:58:45 -0500 -Subject: [PATCH] Additional eglSwapBuffer calling makes wrong throttling - -Upstream Status: Pending - -Signed-off-by: Prabhu Sundararaj ---- - src/egl/eglut/eglut_wayland.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/egl/eglut/eglut_wayland.c b/src/egl/eglut/eglut_wayland.c -index 968b33f..5664d35 100644 ---- a/src/egl/eglut/eglut_wayland.c -+++ b/src/egl/eglut/eglut_wayland.c -@@ -155,7 +155,7 @@ draw(void *data, struct wl_callback *callback, uint32_t time) - - if (win->display_cb) - win->display_cb(); -- eglSwapBuffers(_eglut->dpy, win->surface); -+ /*eglSwapBuffers(_eglut->dpy, win->surface);*/ - - if (callback) - wl_callback_destroy(callback); --- -2.3.5 - diff --git a/meta-digi-dey/recipes-graphics/mesa/mesa-demos/Replace-glWindowPos2iARB-calls-with-glWindowPos2i.patch b/meta-digi-dey/recipes-graphics/mesa/mesa-demos/Replace-glWindowPos2iARB-calls-with-glWindowPos2i.patch deleted file mode 100644 index d899540fb..000000000 --- a/meta-digi-dey/recipes-graphics/mesa/mesa-demos/Replace-glWindowPos2iARB-calls-with-glWindowPos2i.patch +++ /dev/null @@ -1,355 +0,0 @@ -From 757649a766f90e745f24df1d191caeef15c71399 Mon Sep 17 00:00:00 2001 -From: Otavio Salvador -Date: Tue, 4 Jun 2013 09:28:51 -0300 -Subject: [PATCH] Replace glWindowPos2iARB calls with glWindowPos2i - -Vivante libGL does not provide the glWindowPos2iARB symbol, but -glWindowPos2i. Use this instead. - -Upstream-Status: Inapropriate [embedded specific] - -Reported-by: Jeremy Stashluk -Signed-off-by: Otavio Salvador ---- - src/demos/copypix.c | 4 ++-- - src/demos/engine.c | 2 +- - src/demos/fogcoord.c | 4 ++-- - src/glsl/shadow_sampler.c | 2 +- - src/tests/auxbuffer.c | 2 +- - src/tests/copypixrate.c | 2 +- - src/tests/drawbuffers.c | 2 +- - src/tests/drawbuffers2.c | 2 +- - src/tests/fbotest1.c | 2 +- - src/tests/fbotest2.c | 4 ++-- - src/tests/fbotest3.c | 2 +- - src/tests/readrate.c | 10 +++++----- - src/tests/viewmemory.c | 2 +- - src/trivial/clear-fbo-scissor.c | 2 +- - src/trivial/clear-fbo-tex.c | 2 +- - src/trivial/clear-fbo.c | 2 +- - src/trivial/readpixels.c | 2 +- - src/trivial/tri-fbo.c | 2 +- - src/xdemos/glxsnoop.c | 2 +- - src/xdemos/wincopy.c | 4 ++-- - 20 files changed, 28 insertions(+), 28 deletions(-) - -diff --git a/src/demos/copypix.c b/src/demos/copypix.c -index 286c5a9..041b567 100644 ---- a/src/demos/copypix.c -+++ b/src/demos/copypix.c -@@ -54,7 +54,7 @@ static void Display( void ) - glClear( GL_COLOR_BUFFER_BIT ); - - /* draw original image */ -- glWindowPos2iARB(dx, dy); -+ glWindowPos2i(dx, dy); - glDrawPixels(ImgWidth, ImgHeight, ImgFormat, GL_UNSIGNED_BYTE, Image); - - if (Scissor) -@@ -71,7 +71,7 @@ static void Display( void ) - - /* draw copy */ - glPixelZoom(Xzoom, Yzoom); -- glWindowPos2iARB(Xpos, Ypos); -+ glWindowPos2i(Xpos, Ypos); - glCopyPixels(dx, dy, ImgWidth, ImgHeight, GL_COLOR); - glPixelZoom(1, 1); - -diff --git a/src/demos/engine.c b/src/demos/engine.c -index 928fcbb..beace4c 100644 ---- a/src/demos/engine.c -+++ b/src/demos/engine.c -@@ -971,7 +971,7 @@ Draw(void) - glDisable(GL_LIGHTING); - glDisable(GL_TEXTURE_2D); - glColor3f(1, 1 , 1); -- glWindowPos2iARB(10, 10); -+ glWindowPos2i(10, 10); - PrintString(s); - if (lit) - glEnable(GL_LIGHTING); -diff --git a/src/demos/fogcoord.c b/src/demos/fogcoord.c -index 567eec0..e833009 100644 ---- a/src/demos/fogcoord.c -+++ b/src/demos/fogcoord.c -@@ -68,14 +68,14 @@ PrintInfo(void) - - sprintf(s, "Mode(m): %s Start(s/S): %g End(e/E): %g Density(d/D): %g", - ModeStr, fogStart, fogEnd, fogDensity); -- glWindowPos2iARB(5, 20); -+ glWindowPos2i(5, 20); - PrintString(s); - - sprintf(s, "Arrays(a): %s glFogCoord(c): %s EyeZ(z/z): %g", - (Arrays ? "Yes" : "No"), - (fogCoord ? "Yes" : "No"), - camz); -- glWindowPos2iARB(5, 5); -+ glWindowPos2i(5, 5); - PrintString(s); - } - -diff --git a/src/glsl/shadow_sampler.c b/src/glsl/shadow_sampler.c -index b830030..eb82d8b 100644 ---- a/src/glsl/shadow_sampler.c -+++ b/src/glsl/shadow_sampler.c -@@ -85,7 +85,7 @@ Redisplay(void) - glPopMatrix(); - - glUseProgram(0); -- glWindowPos2iARB(80, 20); -+ glWindowPos2i(80, 20); - PrintString("white black white black"); - - { -diff --git a/src/tests/auxbuffer.c b/src/tests/auxbuffer.c -index 5fa399a..0cd5f47 100644 ---- a/src/tests/auxbuffer.c -+++ b/src/tests/auxbuffer.c -@@ -419,7 +419,7 @@ event_loop(Display *dpy, Window win) - /* Copy aux buffer image to back color buffer */ - glReadBuffer(GL_AUX0); - glDrawBuffer(GL_BACK); -- glWindowPos2iARB(0, 0); -+ glWindowPos2i(0, 0); - glDisable(GL_DEPTH_TEST); - glCopyPixels(0, 0, WinWidth, WinHeight, GL_COLOR); - glEnable(GL_DEPTH_TEST); -diff --git a/src/tests/copypixrate.c b/src/tests/copypixrate.c -index 2f64e0a..df1f9b0 100644 ---- a/src/tests/copypixrate.c -+++ b/src/tests/copypixrate.c -@@ -91,7 +91,7 @@ BlitOne(void) - else - #endif - { -- glWindowPos2iARB(x, y); -+ glWindowPos2i(x, y); - glCopyPixels(0, 0, ImgWidth, ImgHeight, GL_COLOR); - } - } -diff --git a/src/tests/drawbuffers.c b/src/tests/drawbuffers.c -index fa2f8a7..cd5033f 100644 ---- a/src/tests/drawbuffers.c -+++ b/src/tests/drawbuffers.c -@@ -88,7 +88,7 @@ Display(void) - glUseProgram(0); - glDisable(GL_DEPTH_TEST); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); -- glWindowPos2iARB(0, 0); -+ glWindowPos2i(0, 0); - glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); - - free(buffer); -diff --git a/src/tests/drawbuffers2.c b/src/tests/drawbuffers2.c -index 5bcf0b2..84d444b 100644 ---- a/src/tests/drawbuffers2.c -+++ b/src/tests/drawbuffers2.c -@@ -112,7 +112,7 @@ Display(void) - glUseProgram(0); - glDisable(GL_DEPTH_TEST); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); -- glWindowPos2iARB(0, 0); -+ glWindowPos2i(0, 0); - glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); - - free(buffer); -diff --git a/src/tests/fbotest1.c b/src/tests/fbotest1.c -index 161903c..5930a6d 100644 ---- a/src/tests/fbotest1.c -+++ b/src/tests/fbotest1.c -@@ -61,7 +61,7 @@ Display( void ) - - /* draw to window */ - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); -- glWindowPos2iARB(0, 0); -+ glWindowPos2i(0, 0); - glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); - - free(buffer); -diff --git a/src/tests/fbotest2.c b/src/tests/fbotest2.c -index 6ef7f12..11c867e 100644 ---- a/src/tests/fbotest2.c -+++ b/src/tests/fbotest2.c -@@ -72,7 +72,7 @@ Display( void ) - - glDisable(GL_DEPTH_TEST); /* in case window has depth buffer */ - -- glWindowPos2iARB(0, 0); -+ glWindowPos2i(0, 0); - glCopyPixels(0, 0, Width, Height, GL_COLOR); - } - else if (blitPix) { -@@ -95,7 +95,7 @@ Display( void ) - /* draw to window */ - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - glDisable(GL_DEPTH_TEST); /* in case window has depth buffer */ -- glWindowPos2iARB(0, 0); -+ glWindowPos2i(0, 0); - glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); - - free(buffer); -diff --git a/src/tests/fbotest3.c b/src/tests/fbotest3.c -index 19f684d..e6d7710 100644 ---- a/src/tests/fbotest3.c -+++ b/src/tests/fbotest3.c -@@ -79,7 +79,7 @@ Display( void ) - /* draw to window */ - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - glDisable(GL_DEPTH_TEST); /* in case window has depth buffer */ -- glWindowPos2iARB(0, 0); -+ glWindowPos2i(0, 0); - glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); - - free(buffer); -diff --git a/src/tests/readrate.c b/src/tests/readrate.c -index 3859cf4..81eb8a3 100644 ---- a/src/tests/readrate.c -+++ b/src/tests/readrate.c -@@ -85,7 +85,7 @@ MeasureFormat(struct format_type *fmt, GLint width, GLint height, GLuint pbo) - glEnd(); - - #if DRAW -- glWindowPos2iARB(0,0); -+ glWindowPos2i(0,0); - glDrawPixels(width, height, - fmt->Format, fmt->Type, Buffer); - glFinish(); -@@ -137,21 +137,21 @@ Draw(void) - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - -- glWindowPos2iARB(10, y); -+ glWindowPos2i(10, y); - sprintf(str, "ReadPixels size: %d x %d", width, height); - PrintString(str); - y -= 14; - -- glWindowPos2iARB(10, y); -+ glWindowPos2i(10, y); - PrintString("Press up/down/left/right to change image size."); - y -= 14; - -- glWindowPos2iARB(10, y); -+ glWindowPos2i(10, y); - PrintString("Press 'b' to run benchmark test."); - y -= 14; - - if (Benchmark) { -- glWindowPos2iARB(10, y); -+ glWindowPos2i(10, y); - PrintString("Testing..."); - } - -diff --git a/src/tests/viewmemory.c b/src/tests/viewmemory.c -index 16044b9..3584c33 100644 ---- a/src/tests/viewmemory.c -+++ b/src/tests/viewmemory.c -@@ -95,7 +95,7 @@ Draw(void) - - glDisable(GL_TEXTURE_2D); - glColor3f(0, 1, 0); -- glWindowPos2iARB(10, 10); -+ glWindowPos2i(10, 10); - PrintString(s); - - glutSwapBuffers(); -diff --git a/src/trivial/clear-fbo-scissor.c b/src/trivial/clear-fbo-scissor.c -index a30935c..5c15200 100644 ---- a/src/trivial/clear-fbo-scissor.c -+++ b/src/trivial/clear-fbo-scissor.c -@@ -182,7 +182,7 @@ Draw(void) - - /* draw to window */ - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); -- glWindowPos2iARB(0, 0); -+ glWindowPos2i(0, 0); - glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); - - free(buffer); -diff --git a/src/trivial/clear-fbo-tex.c b/src/trivial/clear-fbo-tex.c -index de84f98..f0fbdf6 100644 ---- a/src/trivial/clear-fbo-tex.c -+++ b/src/trivial/clear-fbo-tex.c -@@ -140,7 +140,7 @@ static void Draw( void ) - glClearColor(0.8, 0.8, 0, 0.0); - glClear(GL_COLOR_BUFFER_BIT); - -- glWindowPos2iARB(30, 30); -+ glWindowPos2i(30, 30); - glDrawPixels(Width-60, Height-60, GL_RGBA, GL_UNSIGNED_BYTE, buffer); - - free(buffer); -diff --git a/src/trivial/clear-fbo.c b/src/trivial/clear-fbo.c -index 10d830b..3fee3e3 100644 ---- a/src/trivial/clear-fbo.c -+++ b/src/trivial/clear-fbo.c -@@ -116,7 +116,7 @@ Draw(void) - glClearColor(0.8, 0.8, 0, 0.0); - glClear(GL_COLOR_BUFFER_BIT); - -- glWindowPos2iARB(30, 30); -+ glWindowPos2i(30, 30); - glDrawPixels(Width-60, Height-60, GL_RGBA, GL_UNSIGNED_BYTE, buffer); - - free(buffer); -diff --git a/src/trivial/readpixels.c b/src/trivial/readpixels.c -index ccce4ed..74e0546 100644 ---- a/src/trivial/readpixels.c -+++ b/src/trivial/readpixels.c -@@ -71,7 +71,7 @@ static void Draw(void) - printf("Pixel(0,0) = %f, %f, %f, %f\n", - image[0], image[1], image[2], image[3]); - /* draw to right half of window */ -- glWindowPos2iARB(Width, 0); -+ glWindowPos2i(Width, 0); - glPixelZoom(Zoom, Zoom); - glDrawPixels(Width, Height, GL_RGBA, GL_FLOAT, image); - free(image); -diff --git a/src/trivial/tri-fbo.c b/src/trivial/tri-fbo.c -index d5800b2..dd1f21a 100644 ---- a/src/trivial/tri-fbo.c -+++ b/src/trivial/tri-fbo.c -@@ -119,7 +119,7 @@ static void Draw( void ) - glClearColor(0.8, 0.8, 0, 0.0); - glClear(GL_COLOR_BUFFER_BIT); - -- glWindowPos2iARB(30, 30); -+ glWindowPos2i(30, 30); - glDrawPixels(Width-60, Height-60, GL_RGBA, GL_UNSIGNED_BYTE, buffer); - - -diff --git a/src/xdemos/glxsnoop.c b/src/xdemos/glxsnoop.c -index 2215cfd..13d2b2d 100644 ---- a/src/xdemos/glxsnoop.c -+++ b/src/xdemos/glxsnoop.c -@@ -91,7 +91,7 @@ redraw(Display *dpy, Window srcWin, Window dstWin ) - } - - glXMakeCurrent(dpy, dstWin, Context); -- glWindowPos2iARB(0, 0); -+ glWindowPos2i(0, 0); - glDrawBuffer(GL_FRONT); - glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, image); - glFlush(); -diff --git a/src/xdemos/wincopy.c b/src/xdemos/wincopy.c -index f670983..d010085 100644 ---- a/src/xdemos/wincopy.c -+++ b/src/xdemos/wincopy.c -@@ -156,11 +156,11 @@ Redraw(void) - glClear(GL_COLOR_BUFFER_BIT); - - if (TestClipping) { -- glWindowPos2iARB(-2, -2); -+ glWindowPos2i(-2, -2); - glCopyPixels(-2, -2, Width[0] + 4, Height[0] + 4, GL_COLOR); - } - else { -- glWindowPos2iARB(0, 0); -+ glWindowPos2i(0, 0); - glCopyPixels(0, 0, Width[0], Height[0], GL_COLOR); - } - --- -1.8.1 - diff --git a/meta-digi-dey/recipes-graphics/mesa/mesa-demos/fix-clear-build-break.patch b/meta-digi-dey/recipes-graphics/mesa/mesa-demos/fix-clear-build-break.patch deleted file mode 100644 index eb541d658..000000000 --- a/meta-digi-dey/recipes-graphics/mesa/mesa-demos/fix-clear-build-break.patch +++ /dev/null @@ -1,17 +0,0 @@ -mesa-demos: Add extension header to fix build break now that gl1 is removed - -Upstream Status: Pending - -diff --git a/src/egl/opengles1/clear.c b/src/egl/opengles1/clear.c -index 9fe1b5291e1905fd6fe572063ed707d59ce45a81..ca9954a21b5f475709dbdef07f90b900962fcbc7 100644 ---- a/src/egl/opengles1/clear.c -+++ b/src/egl/opengles1/clear.c -@@ -34,7 +34,7 @@ - #include - #include - #include -- -+#include - #include "eglut.h" - - typedef void (GL_APIENTRY *type_ClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); diff --git a/meta-digi-dey/recipes-graphics/mesa/mesa-demos_%.bbappend b/meta-digi-dey/recipes-graphics/mesa/mesa-demos_%.bbappend deleted file mode 100644 index 3aebea0de..000000000 --- a/meta-digi-dey/recipes-graphics/mesa/mesa-demos_%.bbappend +++ /dev/null @@ -1,24 +0,0 @@ -FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" - -DEPENDS = "mesa" - -SRC_URI_append_imxgpu = " file://Replace-glWindowPos2iARB-calls-with-glWindowPos2i.patch \ - file://fix-clear-build-break.patch \ - file://Additional-eglSwapBuffer-calling-makes-wrong-throttl.patch \ - file://Add-OpenVG-demos-to-support-wayland.patch" - -PACKAGECONFIG_IMX_REMOVE_IF_2D_ONLY = "" -PACKAGECONFIG_IMX_REMOVE_IF_2D_ONLY_imxgpu2d = "gles1 gles2" -PACKAGECONFIG_IMX_REMOVE_IF_2D_ONLY_imxgpu3d = "" - -PACKAGECONFIG_remove_imxgpu = " \ - ${PACKAGECONFIG_IMX_REMOVE_IF_2D_ONLY} \ - ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'glu x11', '', d)} \ -" - -PACKAGECONFIG_append_imxgpu = " \ - ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland vg', '', d)} \ - ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'glut', '', d)} \ -" - -PACKAGECONFIG[glut] = "--with-glut=${STAGING_EXECPREFIXDIR},--without-glut,freeglut" diff --git a/meta-digi-dey/recipes-graphics/mesa/mesa_%.bbappend b/meta-digi-dey/recipes-graphics/mesa/mesa_%.bbappend deleted file mode 100644 index 916f3a300..000000000 --- a/meta-digi-dey/recipes-graphics/mesa/mesa_%.bbappend +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (C) 2018 Digi International -PROVIDES_remove_imxgpu = "virtual/egl" -PROVIDES_remove_imxgpu3d = "virtual/libgl virtual/libgles1 virtual/libgles2" - -PACKAGECONFIG_remove_imxgpu = "egl gbm" -PACKAGECONFIG_remove_imxgpu3d = "gles" - -BACKEND = \ - "${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland', \ - bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', \ - 'fb', d), d)}" -do_install_append_imxgpu3d () { - rm -f ${D}${includedir}/GL/glx.h \ - ${D}${includedir}/GL/glxext.h - if [ "${BACKEND}" = "x11" ]; then - rm -f ${D}${libdir}/pkgconfig/gl.pc - fi -} - -do_install_append_imxgpu () { - rm -f ${D}${includedir}/KHR -} - -do_install_append () { - if [ "${BACKEND}" = "wayland" ]; then - rm -f ${D}${libdir}/pkgconfig/wayland-egl.pc - rm -f ${D}${libdir}/libwayland-egl* - fi -} diff --git a/meta-digi-dey/recipes-graphics/packagegroups/packagegroup-dey-qt.bb b/meta-digi-dey/recipes-graphics/packagegroups/packagegroup-dey-qt.bb index e0922e4a3..4a5171676 100644 --- a/meta-digi-dey/recipes-graphics/packagegroups/packagegroup-dey-qt.bb +++ b/meta-digi-dey/recipes-graphics/packagegroups/packagegroup-dey-qt.bb @@ -28,7 +28,7 @@ QT5_RDEPENDS_imxgpu2d = "${@bb.utils.contains('DISTRO_FEATURES', 'x11','${QT5_RD 'qtbase qtbase-plugins', d)}" QT5_RDEPENDS_imxpxp = "${@bb.utils.contains('DISTRO_FEATURES', 'x11','${QT5_RDEPENDS_common}', \ - 'qtbase qtbase-examples qtbase-plugins', d)}" + 'qtbase qtbase-examples qtbase-plugins qtquickcontrols2 qtquickcontrols2-qmlplugins', d)}" QT5_RDEPENDS_imxgpu3d = " \ ${QT5_RDEPENDS_common} \ diff --git a/meta-digi-dey/recipes-graphics/vulkan/vulkan-demos/0001-Don-t-build-demos-with-questionably-licensed-data.patch b/meta-digi-dey/recipes-graphics/vulkan/vulkan-demos/0001-Don-t-build-demos-with-questionably-licensed-data.patch new file mode 100644 index 000000000..d32c8f280 --- /dev/null +++ b/meta-digi-dey/recipes-graphics/vulkan/vulkan-demos/0001-Don-t-build-demos-with-questionably-licensed-data.patch @@ -0,0 +1,91 @@ +From 55770fb07c42fe410cf8d09f8f5976babc89b9ef Mon Sep 17 00:00:00 2001 +From: Jussi Kukkonen +Date: Tue, 4 Jul 2017 17:13:45 +0300 +Subject: [PATCH] Don't build demos with questionably licensed data + +Some of the models don't have open source compatible licenses: +don't build demos using those. Also don't build demos that need +resources that are not included. + +ssao: +scenerendering: + Sibenik model, no license found + +deferred: +deferredmultisampling: +deferredshadows: + armor model, CC-BY-3.0 + +vulkanscene: +imgui: +shadowmapping: + vulkanscene model, no license found + +indirectdraw: + plant model, no license found + +hdr: +pbribl: +pbrtexture: + Require external Vulkan Asset Pack + +Upstream-Status: Inappropriate [configuration] +Signed-off-by: Jussi Kukkonen +--- + CMakeLists.txt | 13 ------------- + 1 file changed, 13 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4958fff..0f9d3e4 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -150,17 +150,11 @@ set(EXAMPLES + computeparticles + computeshader + debugmarker +- deferred +- deferredmultisampling +- deferredshadows + displacement + distancefieldfonts + dynamicuniformbuffer + gears + geometryshader +- hdr +- imgui +- indirectdraw + instancing + mesh + multisampling +@@ -170,20 +164,14 @@ set(EXAMPLES + parallaxmapping + particlefire + pbrbasic +- pbribl +- pbrtexture + pipelines + pushconstants + radialblur + raytracing +- scenerendering + screenshot +- shadowmapping +- shadowmappingomni + skeletalanimation + specializationconstants + sphericalenvmapping +- ssao + subpasses + terraintessellation + tessellation +@@ -196,7 +184,6 @@ set(EXAMPLES + texturesparseresidency + triangle + viewportarray +- vulkanscene + ) + + buildExamples() +-- +2.13.2 + diff --git a/meta-digi-dey/recipes-graphics/vulkan/vulkan-demos/0001-Fix-build-on-x86.patch b/meta-digi-dey/recipes-graphics/vulkan/vulkan-demos/0001-Fix-build-on-x86.patch new file mode 100644 index 000000000..681b3422d --- /dev/null +++ b/meta-digi-dey/recipes-graphics/vulkan/vulkan-demos/0001-Fix-build-on-x86.patch @@ -0,0 +1,41 @@ +From b0495efb6c3ea3a530fcbaddac86da57ecce5a66 Mon Sep 17 00:00:00 2001 +From: Jussi Kukkonen +Date: Mon, 10 Jul 2017 13:11:12 +0300 +Subject: [PATCH] Fix build on x86 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +| func_common.inl:193:51: error: wrong number of template arguments +| (5, should be 6) struct compute_sign + +The fix is backported from the upstream glm project. + +Upstream-Status: Pending [https://github.com/SaschaWillems/Vulkan/issues/356] +Signed-off-by: Jussi Kukkonen +--- + external/glm/glm/detail/func_common.inl | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/external/glm/glm/detail/func_common.inl b/external/glm/glm/detail/func_common.inl +index cafaed5..2dd94e1 100644 +--- a/external/glm/glm/detail/func_common.inl ++++ b/external/glm/glm/detail/func_common.inl +@@ -190,12 +190,12 @@ namespace detail + + # if GLM_ARCH == GLM_ARCH_X86 + template class vecType, bool Aligned> +- struct compute_sign ++ struct compute_sign + { + GLM_FUNC_QUALIFIER static vecType call(vecType const & x) + { + T const Shift(static_cast(sizeof(T) * 8 - 1)); +- vecType const y(vecType::type, P>(-x) >> typename make_unsigned::type(Shift)); ++ vecType const y(vecType::type, P>(-x) >> typename make_unsigned::type(Shift)); + + return (x >> Shift) | y; + } +-- +2.1.4 + diff --git a/meta-digi-dey/recipes-graphics/vulkan/vulkan-demos/0001-Support-installing-demos-support-out-of-tree-builds.patch b/meta-digi-dey/recipes-graphics/vulkan/vulkan-demos/0001-Support-installing-demos-support-out-of-tree-builds.patch new file mode 100644 index 000000000..4addea3bf --- /dev/null +++ b/meta-digi-dey/recipes-graphics/vulkan/vulkan-demos/0001-Support-installing-demos-support-out-of-tree-builds.patch @@ -0,0 +1,85 @@ +From edca667684764cfcc0460e448e834fadf623a887 Mon Sep 17 00:00:00 2001 +From: Jussi Kukkonen +Date: Mon, 3 Jul 2017 14:49:18 +0300 +Subject: [PATCH] Support installing demos, support out-of-tree builds + +This is especially useful for cross-compile situation where testing +happens on target. + +-DRESOURCE_INSTALL_DIR= decides where data is installed (and +where the binaries will load the data from): if it's left empty, +then nothing will be installed and binaries will load the data from +CMAKE_SOURCE_DIR. + +Binaries are now correctly built in CMAKE_BINARY_DIR. + +Upstream-Status: Submitted [https://github.com/SaschaWillems/Vulkan/pull/352] +Signed-off-by: Jussi Kukkonen +--- + CMakeLists.txt | 15 ++++++++++++++- + base/vulkanexamplebase.cpp | 2 +- + 2 files changed, 15 insertions(+), 2 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b9886bc..4958fff 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -16,6 +16,8 @@ include_directories(base) + OPTION(USE_D2D_WSI "Build the project using Direct to Display swapchain" OFF) + OPTION(USE_WAYLAND_WSI "Build the project using Wayland swapchain" OFF) + ++set(RESOURCE_INSTALL_DIR "" CACHE PATH "Path to install resources to (leave empty for running uninstalled)") ++ + # Use FindVulkan module added with CMAKE 3.7 + if (NOT CMAKE_VERSION VERSION_LESS 3.7.0) + message(STATUS "Using module to find Vulkan") +@@ -108,6 +110,10 @@ function(buildExample EXAMPLE_NAME) + add_executable(${EXAMPLE_NAME} ${MAIN_CPP} ${SOURCE} ${SHADERS}) + target_link_libraries(${EXAMPLE_NAME} ${Vulkan_LIBRARY} ${ASSIMP_LIBRARIES} ${WAYLAND_CLIENT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) + endif(WIN32) ++ ++ if(RESOURCE_INSTALL_DIR) ++ install(TARGETS ${EXAMPLE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) ++ endif() + endfunction(buildExample) + + # Build all examples +@@ -117,6 +123,13 @@ function(buildExamples) + endforeach(EXAMPLE) + endfunction(buildExamples) + ++if(RESOURCE_INSTALL_DIR) ++ add_definitions(-DVK_EXAMPLE_DATA_DIR=\"${RESOURCE_INSTALL_DIR}/\") ++ install(DIRECTORY data/ DESTINATION ${RESOURCE_INSTALL_DIR}/) ++else() ++ add_definitions(-DVK_EXAMPLE_DATA_DIR=\"${CMAKE_SOURCE_DIR}/data/\") ++endif() ++ + # Compiler specific stuff + IF(MSVC) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") +@@ -128,7 +141,7 @@ ELSE(WIN32) + link_libraries(${XCB_LIBRARIES} ${Vulkan_LIBRARY}) + ENDIF(WIN32) + +-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/") ++set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/") + + set(EXAMPLES + bloom +diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp +index 647368a..a0f28a5 100644 +--- a/base/vulkanexamplebase.cpp ++++ b/base/vulkanexamplebase.cpp +@@ -84,7 +84,7 @@ const std::string VulkanExampleBase::getAssetPath() + #if defined(__ANDROID__) + return ""; + #else +- return "./../data/"; ++ return VK_EXAMPLE_DATA_DIR; + #endif + } + #endif +-- +2.13.2 + diff --git a/meta-digi-dey/recipes-graphics/vulkan/vulkan-demos_%.bbappend b/meta-digi-dey/recipes-graphics/vulkan/vulkan-demos_%.bbappend index a11dfbd09..11cd87903 100644 --- a/meta-digi-dey/recipes-graphics/vulkan/vulkan-demos_%.bbappend +++ b/meta-digi-dey/recipes-graphics/vulkan/vulkan-demos_%.bbappend @@ -1,3 +1,20 @@ +# Copyright (C) 2020 Digi International + +# Use the sources in poky's sumo recipe +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" +LIC_FILES_CHKSUM = "file://LICENSE.md;md5=dcf473723faabf17baa9b5f2207599d0 \ + file://triangle/triangle.cpp;endline=12;md5=bccd1bf9cadd9e10086cf7872157e4fa" + +SRC_URI = "git://github.com/SaschaWillems/Vulkan.git \ + file://0001-Support-installing-demos-support-out-of-tree-builds.patch \ + file://0001-Don-t-build-demos-with-questionably-licensed-data.patch \ + file://0001-Fix-build-on-x86.patch \ +" +SRCREV = "18df00c7b4677b0889486e16977857aa987947e2" DEPENDS_remove = "vulkan" DEPENDS_append = " vulkan-headers vulkan-loader" + +# The vulkan-validationlayers package is necessary for the demos to work +RDEPENDS_${PN} = "vulkan-validationlayers" + diff --git a/meta-digi-dey/recipes-graphics/wayland/libinput/touchpad-serial-synaptics-need-to-fake-new-touches-on-TRIPLETAP.patch b/meta-digi-dey/recipes-graphics/wayland/libinput/touchpad-serial-synaptics-need-to-fake-new-touches-on-TRIPLETAP.patch deleted file mode 100644 index b52b4962b..000000000 --- a/meta-digi-dey/recipes-graphics/wayland/libinput/touchpad-serial-synaptics-need-to-fake-new-touches-on-TRIPLETAP.patch +++ /dev/null @@ -1,72 +0,0 @@ -This is a workaround upstream suggests for use with kernel 4.1. - -Upstream-Status: Inappropriate [temporary work-around] -Signed-off-by: Jussi Kukkonen - - - -From: Peter Hutterer -Date: Mon Aug 3 18:23:12 PDT 2015 -Subject: [PATCH v3 libinput] touchpad: serial synaptics need to fake new touches on TRIPLETAP - -On the 4.1 kernels synaptics pretends to have 3 slots (the serial fw only does -2). This was added to avoid cursor jumps but has since been reverted for 4.2 -(kernel commit dbf3c37086, 4.1.3 is still buggy). In some cases a TRIPLETAP -may be triggered without slot 2 ever activating. - -While there are still those kernels out there, work around this bug by opening -a new touch point where none exists if the fake finger count exceeds the slot -count. - -Reported-by: Jan Alexander Steffens -Signed-off-by: Peter Hutterer -Tested-by: Jan Alexander Steffens -Reviewed-by: Hans de Goede ---- -Changes to v2: -- split out the handling instead of having a tmp state variable, see Hans' - comments from v2 - -Mainly sending this to the list again so I have a link to point people to. -If you're on 4.1.x add this patch to your distribution package. - - src/evdev-mt-touchpad.c | 22 ++++++++++++++++------ - 1 file changed, 16 insertions(+), 6 deletions(-) - -diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c -index a683d9a..5ef03d5 100644 ---- a/src/evdev-mt-touchpad.c -+++ b/src/evdev-mt-touchpad.c -@@ -369,13 +369,23 @@ tp_restore_synaptics_touches(struct tp_dispatch *tp, - for (i = 0; i < tp->num_slots; i++) { - struct tp_touch *t = tp_get_touch(tp, i); - -- if (t->state != TOUCH_END) -+ switch(t->state) { -+ case TOUCH_HOVERING: -+ case TOUCH_BEGIN: -+ case TOUCH_UPDATE: - continue; -- -- /* new touch, move it through begin to update immediately */ -- tp_new_touch(tp, t, time); -- tp_begin_touch(tp, t, time); -- t->state = TOUCH_UPDATE; -+ case TOUCH_NONE: -+ /* new touch, move it through to begin immediately */ -+ tp_new_touch(tp, t, time); -+ tp_begin_touch(tp, t, time); -+ break; -+ case TOUCH_END: -+ /* touch just ended ,we need need to restore it to update */ -+ tp_new_touch(tp, t, time); -+ tp_begin_touch(tp, t, time); -+ t->state = TOUCH_UPDATE; -+ break; -+ } - } - } - --- -2.4.3 - diff --git a/meta-digi-dey/recipes-graphics/wayland/libinput_1.6.1.bb b/meta-digi-dey/recipes-graphics/wayland/libinput_1.6.1.bb deleted file mode 100644 index c8714f23e..000000000 --- a/meta-digi-dey/recipes-graphics/wayland/libinput_1.6.1.bb +++ /dev/null @@ -1,25 +0,0 @@ -SUMMARY = "Library to handle input devices in Wayland compositors" -HOMEPAGE = "http://www.freedesktop.org/wiki/Software/libinput/" -SECTION = "libs" - -LICENSE = "MIT" -LIC_FILES_CHKSUM = "file://COPYING;md5=2184aef38ff137ed33ce9a63b9d1eb8f" - -DEPENDS = "libevdev udev mtdev" - -SRC_URI = "http://www.freedesktop.org/software/${BPN}/${BP}.tar.xz \ - file://touchpad-serial-synaptics-need-to-fake-new-touches-on-TRIPLETAP.patch \ -" -SRC_URI[md5sum] = "7e282344f8ed7ec5cf87ca9fc22674fb" -SRC_URI[sha256sum] = "9d816f13eee63bcca0e9c3bb652c52ab55f39be4d1b90b54e4bfd1dc92ef55a8" - -inherit autotools pkgconfig - -PACKAGECONFIG ??= "" -PACKAGECONFIG[libunwind] = "--with-libunwind,--without-libunwind,libunwind" -PACKAGECONFIG[libwacom] = "--enable-libwacom,--disable-libwacom,libwacom" -PACKAGECONFIG[gui] = "--enable-event-gui,--disable-event-gui,cairo gtk+3" - -UDEVDIR = "`pkg-config --variable=udevdir udev`" - -EXTRA_OECONF += "--with-udev-dir=${UDEVDIR}" diff --git a/meta-digi-dey/recipes-graphics/wayland/weston-init.bbappend b/meta-digi-dey/recipes-graphics/wayland/weston-init.bbappend index abaa1ef2f..87c974938 100644 --- a/meta-digi-dey/recipes-graphics/wayland/weston-init.bbappend +++ b/meta-digi-dey/recipes-graphics/wayland/weston-init.bbappend @@ -1,23 +1,31 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" -REQUIRED_DISTRO_FEATURES_remove_mx6sl = "opengl" +# OpenGL is not required for parts with GPU support for 2D but not 3D +IMX_REQUIRED_DISTRO_FEATURES_REMOVE = "" +IMX_REQUIRED_DISTRO_FEATURES_REMOVE_imxgpu2d = "opengl" +IMX_REQUIRED_DISTRO_FEATURES_REMOVE_imxgpu3d = "" +REQUIRED_DISTRO_FEATURES_remove = "${IMX_REQUIRED_DISTRO_FEATURES_REMOVE}" -SRC_URI_append = " file://profile" -SRC_URI_append = " ${@bb.utils.contains('DISTRO_FEATURES', 'systemd wayland x11', 'file://weston.config', '', d)}" +SRC_URI_append_mx6sl = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd wayland x11', 'file://weston.config', '', d)}" HAS_SYSTEMD = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}" -HAS_XWAYLAND = "${@bb.utils.contains('DISTRO_FEATURES', 'wayland x11', 'true', 'false', d)}" do_install_append() { - install -Dm0755 ${WORKDIR}/profile ${D}${sysconfdir}/profile.d/weston.sh if ${HAS_SYSTEMD}; then sed -i \ -e 's,/usr/bin,${bindir},g' \ -e 's,/etc,${sysconfdir},g' \ -e 's,/var,${localstatedir},g' \ ${D}${systemd_system_unitdir}/weston.service - if ${HAS_XWAYLAND}; then - install -Dm0755 ${WORKDIR}/weston.config ${D}${sysconfdir}/default/weston - fi + fi + if [ -f ${WORKDIR}/weston.config ]; then + install -Dm0755 ${WORKDIR}/weston.config ${D}${sysconfdir}/default/weston fi } + +# Add profile support not accepted by upstream +SRC_URI += "file://profile" + +do_install_append() { + install -Dm0755 ${WORKDIR}/profile ${D}${sysconfdir}/profile.d/weston.sh +} diff --git a/meta-digi-dey/recipes-graphics/wayland/weston-init/imxdrm/weston.config b/meta-digi-dey/recipes-graphics/wayland/weston-init/imxdrm/weston.config deleted file mode 100644 index 7c92cf110..000000000 --- a/meta-digi-dey/recipes-graphics/wayland/weston-init/imxdrm/weston.config +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -OPTARGS="--xwayland" diff --git a/meta-digi-dey/recipes-graphics/wayland/weston-init/mx6sl/weston.config b/meta-digi-dey/recipes-graphics/wayland/weston-init/mx6sl/weston.config new file mode 100755 index 000000000..58749b289 --- /dev/null +++ b/meta-digi-dey/recipes-graphics/wayland/weston-init/mx6sl/weston.config @@ -0,0 +1,2 @@ +#!/bin/sh +FB_MULTI_BUFFER=1 diff --git a/meta-digi-dey/recipes-graphics/wayland/weston-init/weston.config b/meta-digi-dey/recipes-graphics/wayland/weston-init/weston.config deleted file mode 100644 index 7c92cf110..000000000 --- a/meta-digi-dey/recipes-graphics/wayland/weston-init/weston.config +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -OPTARGS="--xwayland" diff --git a/meta-digi-dey/recipes-graphics/wayland/weston_5.0.0.imx.bb b/meta-digi-dey/recipes-graphics/wayland/weston_5.0.0.imx.bb index 6e3426145..7e4ea7824 100644 --- a/meta-digi-dey/recipes-graphics/wayland/weston_5.0.0.imx.bb +++ b/meta-digi-dey/recipes-graphics/wayland/weston_5.0.0.imx.bb @@ -17,7 +17,7 @@ SRC_URI = "${WESTON_SRC};branch=${SRCBRANCH} \ file://0001-weston-launch-Provide-a-default-version-that-doesn-t.patch \ file://0003-weston-touch-calibrator-Advertise-the-touchscreen-ca.patch \ " -SRCREV = "b85441fbc9e321931fb7ca833555d740beca054d" +SRCREV = "73a26456e43b6d4f72f0a995d437590065cafb15" S = "${WORKDIR}/git" UPSTREAM_CHECK_URI = "https://wayland.freedesktop.org/releases.html" @@ -155,6 +155,9 @@ do_install_append() { uncomment "use-g2d=1" weston.ini ;; esac + if "${@bb.utils.contains('PACKAGECONFIG', 'xwayland', 'true', 'false', d)}"; then + uncomment "xwayland=true" weston.ini + fi cd - fi } diff --git a/meta-digi-dey/recipes-multimedia/alsa/imx-alsa-plugins_git.bb b/meta-digi-dey/recipes-multimedia/alsa/imx-alsa-plugins_git.bb index a642c563b..b258d398b 100644 --- a/meta-digi-dey/recipes-multimedia/alsa/imx-alsa-plugins_git.bb +++ b/meta-digi-dey/recipes-multimedia/alsa/imx-alsa-plugins_git.bb @@ -18,7 +18,7 @@ LIC_FILES_CHKSUM = "file://COPYING.GPL;md5=94d55d512a9ba36caa9b7df079bae19f" inherit autotools pkgconfig use-imx-headers IMXALSA_SRC ?= "git://source.codeaurora.org/external/imx/imx-alsa-plugins.git;protocol=https" -SRCBRANCH = "MM_04.04.07_1906_L4.14.98" +SRCBRANCH = "MM_04.05.02_1911_L4.14.98" SRC_URI = "${IMXALSA_SRC};branch=${SRCBRANCH}" SRCREV = "cde60d68ab2acee913dbfacb8aabb53d87dd3e38" diff --git a/meta-digi-dey/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.14.imx.bb b/meta-digi-dey/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.14.imx.bb index faf07b248..07e2bc565 100644 --- a/meta-digi-dey/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.14.imx.bb +++ b/meta-digi-dey/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.14.imx.bb @@ -41,7 +41,7 @@ SRC_URI_remove = "file://0001-Prepend-PKG_CONFIG_SYSROOT_DIR-to-pkg-config-outpu EXTRA_OECONF_remove = "WAYLAND_PROTOCOLS_SYSROOT_DIR=${RECIPE_SYSROOT}" GST1.0-PLUGINS-BAD_SRC ?= "gitsm://source.codeaurora.org/external/imx/gst-plugins-bad.git;protocol=https" -SRCBRANCH = "MM_04.04.07_1906_L4.14.98" +SRCBRANCH = "MM_04.05.02_1911_L4.14.98" SRC_URI = " \ ${GST1.0-PLUGINS-BAD_SRC};branch=${SRCBRANCH} \ diff --git a/meta-digi-dey/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_1.14.imx.bb b/meta-digi-dey/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_1.14.imx.bb index 2f5f47aed..af8174263 100644 --- a/meta-digi-dey/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_1.14.imx.bb +++ b/meta-digi-dey/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_1.14.imx.bb @@ -24,7 +24,7 @@ PACKAGECONFIG[gio-unix-2.0] = "" EXTRA_OECONF_append = " --disable-opengl --enable-wayland" GST1.0-PLUGINS-BASE_SRC ?= "gitsm://source.codeaurora.org/external/imx/gst-plugins-base.git;protocol=https" -SRCBRANCH = "MM_04.04.07_1906_L4.14.98" +SRCBRANCH = "MM_04.05.02_1911_L4.14.98" SRC_URI = " \ ${GST1.0-PLUGINS-BASE_SRC};branch=${SRCBRANCH} \ diff --git a/meta-digi-dey/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good_1.14.imx.bb b/meta-digi-dey/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good_1.14.imx.bb index 1b9c35857..a58ff23f9 100644 --- a/meta-digi-dey/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good_1.14.imx.bb +++ b/meta-digi-dey/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good_1.14.imx.bb @@ -8,12 +8,12 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=a6f89e2100d9b6cdffcea4f398e37343 \ DEPENDS += "libdrm" GST1.0-PLUGINS-GOOD_SRC ?= "gitsm://source.codeaurora.org/external/imx/gst-plugins-good.git;protocol=https" -SRCBRANCH = "MM_04.04.07_1906_L4.14.98" +SRCBRANCH = "MM_04.05.02_1911_L4.14.98" SRC_URI = " \ ${GST1.0-PLUGINS-GOOD_SRC};branch=${SRCBRANCH} \ " -SRCREV = "36d46a8a9a7dcf173f9a0a0145b6cfa44f879670" +SRCREV = "604bc57870878c76a6735db74ff7f15c1802ba4c" EXTRA_AUTORECONF = "" PACKAGECONFIG_append = " vpx" diff --git a/meta-digi-dey/recipes-multimedia/gstreamer/gstreamer1.0_1.14.imx.bb b/meta-digi-dey/recipes-multimedia/gstreamer/gstreamer1.0_1.14.imx.bb index 6369454f2..c07608513 100644 --- a/meta-digi-dey/recipes-multimedia/gstreamer/gstreamer1.0_1.14.imx.bb +++ b/meta-digi-dey/recipes-multimedia/gstreamer/gstreamer1.0_1.14.imx.bb @@ -8,7 +8,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=6762ed442b3822387a51c92d928ead0d \ # Use i.MX fork of GST for customizations GST1.0_SRC ?= "gitsm://source.codeaurora.org/external/imx/gstreamer.git;protocol=https" -SRCBRANCH = "MM_04.04.07_1906_L4.14.98" +SRCBRANCH = "MM_04.05.02_1911_L4.14.98" SRC_URI = " ${GST1.0_SRC};branch=${SRCBRANCH}" SRCREV = "d42548da09724ad8cc1aa4f1944607920be2f4c0" diff --git a/meta-digi-dey/recipes-multimedia/gstreamer/imx-gst1.0-plugin/0002-imx-gst1.0-plugin-fix-build-using-MUSL-C-library.patch b/meta-digi-dey/recipes-multimedia/gstreamer/imx-gst1.0-plugin/0002-imx-gst1.0-plugin-fix-build-using-MUSL-C-library.patch new file mode 100644 index 000000000..e9f7dc60b --- /dev/null +++ b/meta-digi-dey/recipes-multimedia/gstreamer/imx-gst1.0-plugin/0002-imx-gst1.0-plugin-fix-build-using-MUSL-C-library.patch @@ -0,0 +1,36 @@ +From: Javier Viguera +Date: Thu, 2 Jan 2020 16:49:51 +0100 +Subject: [PATCH] imx-gst1.0-plugin: fix build using MUSL C library + +Signed-off-by: Javier Viguera +--- + tools/gplay2/gplay2.c | 1 - + tools/grecorder/grecorder.c | 2 ++ + 2 files changed, 2 insertions(+), 1 deletion(-) + +diff --git a/tools/gplay2/gplay2.c b/tools/gplay2/gplay2.c +index 3fa056a86307..a6e5db5535d2 100755 +--- a/tools/gplay2/gplay2.c ++++ b/tools/gplay2/gplay2.c +@@ -26,7 +26,6 @@ + */ + + +-#include + #include + #include + #include +diff --git a/tools/grecorder/grecorder.c b/tools/grecorder/grecorder.c +index 1fec19f900fe..dc912d36e056 100644 +--- a/tools/grecorder/grecorder.c ++++ b/tools/grecorder/grecorder.c +@@ -24,7 +24,9 @@ + #include + #include + #include ++#include + #define __USE_LARGEFILE64 ++#define _GNU_SOURCE # For MUSL statvfs64 + #include + + #include "recorder_engine.h" diff --git a/meta-digi-dey/recipes-multimedia/gstreamer/imx-gst1.0-plugin_%.bbappend b/meta-digi-dey/recipes-multimedia/gstreamer/imx-gst1.0-plugin_%.bbappend index 90696801e..1e1c8de7e 100644 --- a/meta-digi-dey/recipes-multimedia/gstreamer/imx-gst1.0-plugin_%.bbappend +++ b/meta-digi-dey/recipes-multimedia/gstreamer/imx-gst1.0-plugin_%.bbappend @@ -1,6 +1,9 @@ -# Copyright (C) 2016-2018 Digi International +# Copyright (C) 2016-2020 Digi International Inc. FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" -SRC_URI += "file://0001-gstimxv4l2-map-dev-video1-to-dev-fb0.patch" +SRC_URI += " \ + file://0001-gstimxv4l2-map-dev-video1-to-dev-fb0.patch \ + file://0002-imx-gst1.0-plugin-fix-build-using-MUSL-C-library.patch \ +" SRC_URI_append_ccimx6 = " file://0002-imx_2d_device_g2d-define-a-G2D_AMPHION_INTERLACED-ma.patch" diff --git a/meta-digi-dey/recipes-multimedia/gstreamer/imx-gst1.0-plugin_4.4.7.bb b/meta-digi-dey/recipes-multimedia/gstreamer/imx-gst1.0-plugin_4.5.2.bb similarity index 97% rename from meta-digi-dey/recipes-multimedia/gstreamer/imx-gst1.0-plugin_4.4.7.bb rename to meta-digi-dey/recipes-multimedia/gstreamer/imx-gst1.0-plugin_4.5.2.bb index 42f4a959e..d994dc068 100644 --- a/meta-digi-dey/recipes-multimedia/gstreamer/imx-gst1.0-plugin_4.4.7.bb +++ b/meta-digi-dey/recipes-multimedia/gstreamer/imx-gst1.0-plugin_4.5.2.bb @@ -21,12 +21,12 @@ LIC_FILES_CHKSUM = "file://COPYING-LGPL-2;md5=5f30f0716dfdd0d91eb439ebec522ec2 \ file://COPYING-LGPL-2.1;md5=fbc093901857fcd118f065f900982c24" IMXGST_SRC ?= "git://source.codeaurora.org/external/imx/imx-gst1.0-plugin.git;protocol=https" -SRCBRANCH = "MM_04.04.07_1906_L4.14.98" +SRCBRANCH = "MM_04.05.02_1911_L4.14.98" SRC_URI = "${IMXGST_SRC};branch=${SRCBRANCH} \ file://0001-imx-gst1.0-plugin-Update-KERNEL_VERSION-check.patch \ " -SRCREV = "aeebe91727c3228723015cd3086c449ea23e1a5d" +SRCREV = "a975ecbe1ad86d4951198ddd97d66309e526f7b2" S = "${WORKDIR}/git" diff --git a/meta-digi-dey/recipes-multimedia/imx-codec/imx-codec.inc b/meta-digi-dey/recipes-multimedia/imx-codec/imx-codec.inc index c14866db3..aed38adec 100644 --- a/meta-digi-dey/recipes-multimedia/imx-codec/imx-codec.inc +++ b/meta-digi-dey/recipes-multimedia/imx-codec/imx-codec.inc @@ -49,6 +49,11 @@ python __set_insane_skip() { if p == 'imx-codec-test-bin': # FIXME: includes the DUT .so files so we need to deploy those d.setVar("INSANE_SKIP_%s" % p, "ldflags textrel libdir") + + # Skip 'file-rdeps' for builds with MUSL C library + overrides = d.getVar("OVERRIDES").split(":") + if "libc-musl" in overrides: + d.appendVar("INSANE_SKIP_%s" % p, " file-rdeps") else: d.setVar("INSANE_SKIP_%s" % p, "ldflags textrel") } diff --git a/meta-digi-dey/recipes-multimedia/imx-codec/imx-codec_4.4.7.bb b/meta-digi-dey/recipes-multimedia/imx-codec/imx-codec_4.4.7.bb deleted file mode 100644 index 546f0e0ba..000000000 --- a/meta-digi-dey/recipes-multimedia/imx-codec/imx-codec_4.4.7.bb +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (C) 2013-2016 Freescale Semiconductor -# Copyright 2017-2018 NXP -# Released under the MIT license (see COPYING.MIT for the terms) - -require imx-codec.inc - -LIC_FILES_CHKSUM = "file://COPYING;md5=72c0f70181bb6e83eee6aab8de12a9f3" - -SRC_URI[md5sum] = "d8935dbc7b10e3f09c93bc0100c5eb03" -SRC_URI[sha256sum] = "baacda3525fa402dbdfc3bf1ee8cfb6fa3ac493c89511548ca8e095267366253" - -COMPATIBLE_MACHINE = "(mx6|mx7|mx8)" diff --git a/meta-digi-dey/recipes-multimedia/imx-codec/imx-codec_4.5.2.bb b/meta-digi-dey/recipes-multimedia/imx-codec/imx-codec_4.5.2.bb new file mode 100644 index 000000000..b1023d998 --- /dev/null +++ b/meta-digi-dey/recipes-multimedia/imx-codec/imx-codec_4.5.2.bb @@ -0,0 +1,12 @@ +# Copyright (C) 2013-2016 Freescale Semiconductor +# Copyright 2017-2018 NXP +# Released under the MIT license (see COPYING.MIT for the terms) + +require imx-codec.inc + +LIC_FILES_CHKSUM = "file://COPYING;md5=fd4b227530cd88a82af6a5982cfb724d" + +SRC_URI[md5sum] = "c6458ce98a0a6d5bd94df7917335d959" +SRC_URI[sha256sum] = "edcccf2cf29a7ae70d3d55c48a5985e583bf508baf29177b0474d68c7af2858e" + +COMPATIBLE_MACHINE = "(mx6|mx7|mx8)" diff --git a/meta-digi-dey/recipes-multimedia/imx-parser/imx-parser_4.4.7.bb b/meta-digi-dey/recipes-multimedia/imx-parser/imx-parser_4.4.7.bb deleted file mode 100644 index 89156896d..000000000 --- a/meta-digi-dey/recipes-multimedia/imx-parser/imx-parser_4.4.7.bb +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (C) 2013-2016 Freescale Semiconductor -# Copyright 2017-2018 NXP -# Released under the MIT license (see COPYING.MIT for the terms) - -include imx-parser.inc - -LIC_FILES_CHKSUM = "file://COPYING;md5=72c0f70181bb6e83eee6aab8de12a9f3" - -SRC_URI[md5sum] = "1a6ae5be5389c23aaf2571e8fd7731ac" -SRC_URI[sha256sum] = "2cfab5311994669ad3bf6e84f4ffe6a89f6796149d6f88e316ecb34d46e44ab0" - -COMPATIBLE_MACHINE = "(mx6|mx7|mx8)" diff --git a/meta-digi-dey/recipes-multimedia/imx-parser/imx-parser_4.5.2.bb b/meta-digi-dey/recipes-multimedia/imx-parser/imx-parser_4.5.2.bb new file mode 100644 index 000000000..cea189af1 --- /dev/null +++ b/meta-digi-dey/recipes-multimedia/imx-parser/imx-parser_4.5.2.bb @@ -0,0 +1,12 @@ +# Copyright (C) 2013-2016 Freescale Semiconductor +# Copyright 2017-2018 NXP +# Released under the MIT license (see COPYING.MIT for the terms) + +include imx-parser.inc + +LIC_FILES_CHKSUM = "file://COPYING;md5=fd4b227530cd88a82af6a5982cfb724d" + +SRC_URI[md5sum] = "9e0911bca999ad17a2c1d04379e8075a" +SRC_URI[sha256sum] = "e6d00ef760a7779846809b44dfbfabaee90678b229bc9a300c175088b7b2b537" + +COMPATIBLE_MACHINE = "(mx6|mx7|mx8)" diff --git a/meta-digi-dey/recipes-multimedia/packagegroups/packagegroup-dey-gstreamer.bb b/meta-digi-dey/recipes-multimedia/packagegroups/packagegroup-dey-gstreamer.bb index 7eb4206dc..29ab48764 100644 --- a/meta-digi-dey/recipes-multimedia/packagegroups/packagegroup-dey-gstreamer.bb +++ b/meta-digi-dey/recipes-multimedia/packagegroups/packagegroup-dey-gstreamer.bb @@ -30,7 +30,7 @@ MACHINE_GSTREAMER_1_0_PKGS_ccimx6ul = " \ " MACHINE_GSTREAMER_1_0_EXTRA_INSTALL ?= "" -MACHINE_GSTREAMER_1_0_EXTRA_INSTALL_imxgpu2d ?= " \ +MACHINE_GSTREAMER_1_0_EXTRA_INSTALL_imxgpu ?= " \ gstreamer1.0-plugins-bad-meta \ gstreamer1.0-plugins-ugly-meta \ gstreamer1.0-rtsp-server-meta \ diff --git a/meta-digi-dey/recipes-qt/qt5/gstreamer1.0-plugins-good-qt_1.14.imx.bb b/meta-digi-dey/recipes-qt/qt5/gstreamer1.0-plugins-good-qt_1.14.imx.bb index 1993b194a..e2b11704d 100644 --- a/meta-digi-dey/recipes-qt/qt5/gstreamer1.0-plugins-good-qt_1.14.imx.bb +++ b/meta-digi-dey/recipes-qt/qt5/gstreamer1.0-plugins-good-qt_1.14.imx.bb @@ -6,13 +6,13 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=a6f89e2100d9b6cdffcea4f398e37343 \ file://gst/replaygain/rganalysis.c;beginline=1;endline=23;md5=b60ebefd5b2f5a8e0cab6bfee391a5fe" GST1.0-PLUGINS-GOOD_SRC ?= "gitsm://source.codeaurora.org/external/imx/gst-plugins-good.git;protocol=https" -SRCBRANCH = "MM_04.04.07_1906_L4.14.98" +SRCBRANCH = "MM_04.05.02_1911_L4.14.98" SRC_URI = " \ ${GST1.0-PLUGINS-GOOD_SRC};branch=${SRCBRANCH} \ file://0001-configure.ac-Add-prefix-to-correct-the-QT_PATH.patch \ " -SRCREV = "36d46a8a9a7dcf173f9a0a0145b6cfa44f879670" +SRCREV = "604bc57870878c76a6735db74ff7f15c1802ba4c" DEPENDS += "gstreamer1.0-plugins-base virtual/kernel \ ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'qtwayland', '', d)} \ diff --git a/meta-digi-dey/recipes-qt/qt5/qtbase/0001-egl.prf-Fix-build-error-when-egl-headers-need-platfo.patch b/meta-digi-dey/recipes-qt/qt5/qtbase/0001-egl.prf-Fix-build-error-when-egl-headers-need-platfo.patch deleted file mode 100644 index c99c04704..000000000 --- a/meta-digi-dey/recipes-qt/qt5/qtbase/0001-egl.prf-Fix-build-error-when-egl-headers-need-platfo.patch +++ /dev/null @@ -1,30 +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. - -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/recipes-qt/qt5/qtbase/0014-Add-IMX-GPU-support.patch b/meta-digi-dey/recipes-qt/qt5/qtbase/0014-Add-IMX-GPU-support.patch deleted file mode 100644 index 370a2fc8a..000000000 --- a/meta-digi-dey/recipes-qt/qt5/qtbase/0014-Add-IMX-GPU-support.patch +++ /dev/null @@ -1,22 +0,0 @@ -From bd9d14bbb7cc121d97d7f9e3b49509d8491a9aaa Mon Sep 17 00:00:00 2001 -From: Tom Hochstein -Date: Tue, 2 May 2017 22:17:34 -0500 - ---- - mkspecs/linux-oe-g++/qmake.conf | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/mkspecs/linux-oe-g++/qmake.conf b/mkspecs/linux-oe-g++/qmake.conf -index 30d31ed..7a93f2b 100644 ---- a/mkspecs/linux-oe-g++/qmake.conf -+++ b/mkspecs/linux-oe-g++/qmake.conf -@@ -38,5 +38,9 @@ isEmpty(QMAKE_QT_CONFIG):QMAKE_QT_CONFIG = $$(OE_QMAKE_QT_CONFIG) - - 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/recipes-qt/qt5/qtbase/0015-Add-eglfs-to-IMX-GPU.patch b/meta-digi-dey/recipes-qt/qt5/qtbase/0015-Add-eglfs-to-IMX-GPU.patch deleted file mode 100644 index 794fa6222..000000000 --- a/meta-digi-dey/recipes-qt/qt5/qtbase/0015-Add-eglfs-to-IMX-GPU.patch +++ /dev/null @@ -1,13 +0,0 @@ -Index: git/mkspecs/linux-oe-g++/qmake.conf -=================================================================== ---- git.orig/mkspecs/linux-oe-g++/qmake.conf 2016-12-14 17:03:17.000000000 -0600 -+++ git/mkspecs/linux-oe-g++/qmake.conf 2016-12-14 17:06:23.000000000 -0600 -@@ -39,6 +39,8 @@ - - include(../oe-device-extra.pri) - -+EGLFS_DEVICE_INTEGRATION = eglfs_viv -+ - QMAKE_LIBS_EGL += -lEGL - QMAKE_LIBS_OPENGL_ES2 += -lEGL -lGLESv2 - QMAKE_LIBS_OPENVG += -lEGL -lOpenVG diff --git a/meta-digi-dey/recipes-qt/qt5/qtbase/0016-Configure-eglfs-with-egl-pkg-config.patch b/meta-digi-dey/recipes-qt/qt5/qtbase/0016-Configure-eglfs-with-egl-pkg-config.patch deleted file mode 100644 index a245d79aa..000000000 --- a/meta-digi-dey/recipes-qt/qt5/qtbase/0016-Configure-eglfs-with-egl-pkg-config.patch +++ /dev/null @@ -1,13 +0,0 @@ -Index: git/src/plugins/platforms/eglfs/eglfs-plugin.pro -=================================================================== ---- git.orig/src/plugins/platforms/eglfs/eglfs-plugin.pro 2017-01-04 16:54:05.000000000 -0600 -+++ git/src/plugins/platforms/eglfs/eglfs-plugin.pro 2017-01-04 16:56:25.000000000 -0600 -@@ -2,6 +2,8 @@ - - QT += platformsupport-private eglfs_device_lib-private - -+CONFIG += egl -+ - SOURCES += $$PWD/qeglfsmain.cpp - - OTHER_FILES += $$PWD/eglfs.json diff --git a/meta-digi-dey/recipes-qt/qt5/qtbase/ccimx8mn/qt5.sh b/meta-digi-dey/recipes-qt/qt5/qtbase/ccimx8mn/qt5.sh new file mode 100644 index 000000000..16c8e26d7 --- /dev/null +++ b/meta-digi-dey/recipes-qt/qt5/qtbase/ccimx8mn/qt5.sh @@ -0,0 +1,9 @@ +#!/bin/sh +export QT_QPA_PLATFORM="wayland" + +[ -f "/etc/profile.d/weston.sh" ] && return + +export QT_QPA_PLATFORM="xcb" + +# Use EGLFS platform plugin for images without XWayland and X11 +[ -f "/etc/xserver-nodm/Xserver" ] || export QT_QPA_PLATFORM="eglfs" diff --git a/meta-digi-dey/recipes-qt/qt5/qtbase_%.bbappend b/meta-digi-dey/recipes-qt/qt5/qtbase_%.bbappend index 8b78e6616..3e243fdf1 100644 --- a/meta-digi-dey/recipes-qt/qt5/qtbase_%.bbappend +++ b/meta-digi-dey/recipes-qt/qt5/qtbase_%.bbappend @@ -8,6 +8,17 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" SRC_URI_append = " file://qt5.sh" +# Technically, we should add the following patches to imxgpu platforms, but +# doing so duplicates them for imxgpu2d platforms and causes build errors. +# As of now, the only SoC that is imxgpu and not imxgpu2d is the i.MX8MN, so +# append the patches to that SoC only. +SRC_URI_append_mx8mn = " \ + file://0014-Add-IMX-GPU-support.patch \ + file://0001-egl.prf-Fix-build-error-when-egl-headers-need-platfo.patch \ +" + +SRC_URI_remove_imxgpu3d = "file://0016-Configure-eglfs-with-egl-pkg-config.patch" + PACKAGECONFIG_GL_imxpxp = "gles2" PACKAGECONFIG_GL_imxgpu2d = "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'gl', '', d)}" PACKAGECONFIG_GL_imxgpu3d = "gles2" diff --git a/meta-digi-dey/recipes-support/libp11/libp11_0.4.10.bb b/meta-digi-dey/recipes-support/libp11/libp11_0.4.10.bb new file mode 100644 index 000000000..b40223e8a --- /dev/null +++ b/meta-digi-dey/recipes-support/libp11/libp11_0.4.10.bb @@ -0,0 +1,26 @@ +SUMMARY = "Library for using PKCS" +DESCRIPTION = "\ +Libp11 is a library implementing a small layer on top of PKCS \ +make using PKCS" +HOMEPAGE = "https://github.com/OpenSC/libp11" +BUGTRACKER = "https://github.com/OpenSC/libp11/issues" +SECTION = "Development/Libraries" +LICENSE = "LGPLv2+" +LIC_FILES_CHKSUM = "file://COPYING;md5=fad9b3332be894bab9bc501572864b29" +DEPENDS = "libtool openssl" + +SRC_URI = "git://github.com/OpenSC/libp11.git" +SRCREV = "973d31f3f58d5549ddd8b1f822ce8f72186f9d68" + +S = "${WORKDIR}/git" + +inherit autotools pkgconfig + +EXTRA_OECONF = "--disable-static" + +do_install_append () { + rm -rf ${D}${docdir}/${BPN} +} + +FILES_${PN} += "${libdir}/engines*/pkcs11.so" +FILES_${PN}-dev += "${libdir}/engines*/libpkcs11${SOLIBSDEV}" diff --git a/sdk/build-github.sh b/sdk/build-github.sh index fbb5750cb..5bda75c98 100755 --- a/sdk/build-github.sh +++ b/sdk/build-github.sh @@ -3,7 +3,7 @@ # # build-github.sh # -# Copyright (C) 2015-2018 by Digi International Inc. +# Copyright (C) 2015-2019 by Digi International Inc. # All rights reserved. # # This program is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ set -e -AVAILABLE_PLATFORMS="ccimx8x-sbc-pro ccimx8x-sbc-express ccimx6qpsbc ccimx6sbc ccimx6ulsbc ccimx6ulstarter" +AVAILABLE_PLATFORMS="ccimx8mn-dvk ccimx8x-sbc-pro ccimx8x-sbc-express ccimx6qpsbc ccimx6sbc ccimx6ulsbc ccimx6ulstarter" MANIFEST_URL="https://github.com/digi-embedded/dey-manifest.git" @@ -121,6 +121,7 @@ while read _pl _tgt; do # the fly with underscores. eval "${_pl//-/_}_tgt=\"${_tgt//,/ }\"" done<<-_EOF_ + ccimx8mn-dvk dey-image-qt ccimx8x-sbc-pro dey-image-qt ccimx8x-sbc-express dey-image-qt ccimx6qpsbc dey-image-qt diff --git a/sdk/build.sh b/sdk/build.sh index 43177f2ce..de92967ce 100755 --- a/sdk/build.sh +++ b/sdk/build.sh @@ -3,7 +3,7 @@ # # build.sh # -# Copyright (C) 2013-2018 by Digi International Inc. +# Copyright (C) 2013-2019 by Digi International Inc. # All rights reserved. # # This program is free software; you can redistribute it and/or modify it @@ -171,6 +171,7 @@ while read _pl _var _tgt; do eval "${_pl//-/_}_var=\"${_var//,/ }\"" eval "${_pl//-/_}_tgt=\"${_tgt//,/ }\"" done<<-_EOF_ + ccimx8mn-dvk DONTBUILDVARIANTS dey-image-qt,dey-image-aws ccimx8x-sbc-pro DONTBUILDVARIANTS dey-image-qt,dey-image-aws ccimx8x-sbc-express DONTBUILDVARIANTS dey-image-qt,dey-image-aws ccimx6qpsbc DONTBUILDVARIANTS dey-image-qt,dey-image-aws @@ -183,6 +184,7 @@ _EOF_ YOCTO_IMGS_DIR="${WORKSPACE}/images" YOCTO_INST_DIR="${WORKSPACE}/digi-yocto-sdk.$(echo ${DY_REVISION} | tr '/' '_')" +YOCTO_DOWNLOAD_DIR="${WORKSPACE}/downloads" YOCTO_PROJ_DIR="${WORKSPACE}/projects" CPUS="$(grep -c processor /proc/cpuinfo)" @@ -211,8 +213,16 @@ if pushd ${YOCTO_INST_DIR}; then popd fi -# Create projects and build +# Clean downloads directory +if [ "${DY_RM_DOWNLOADS}" = "true" ]; then + printf "\n[INFO] Removing the downloads folder.\n" + rm -rf ${YOCTO_DOWNLOAD_DIR} +fi + +# Clean images and projects folders rm -rf ${YOCTO_IMGS_DIR} ${YOCTO_PROJ_DIR} + +# Create projects and build for platform in ${DY_PLATFORMS}; do # The variables _var|tgt got their dashes converted to # underscores, so we must convert also the ones in ${platform}. @@ -235,7 +245,7 @@ for platform in ${DY_PLATFORMS}; do export TEMPLATECONF="${TEMPLATECONF:+${TEMPLATECONF}/${platform}}" MKP_PAGER="" . ${YOCTO_INST_DIR}/mkproject.sh -p ${platform} ${MACHINES_LAYER} ${_this_var_arg} <<< "y" # Set a common DL_DIR and SSTATE_DIR for all platforms - sed -i -e "/^#DL_DIR ?=/cDL_DIR ?= \"${YOCTO_PROJ_DIR}/downloads\"" \ + sed -i -e "/^#DL_DIR ?=/cDL_DIR ?= \"${YOCTO_DOWNLOAD_DIR}\"" \ -e "/^#SSTATE_DIR ?=/cSSTATE_DIR ?= \"${YOCTO_PROJ_DIR}/sstate-cache\"" \ conf/local.conf # Set the DISTRO and remove 'meta-digi-dey' layer if distro is not DEY based @@ -263,6 +273,9 @@ for platform in ${DY_PLATFORMS}; do if [ "${DY_MFG_IMAGE}" = "true" ] && ! grep -qs "meta-digi-mfg" conf/bblayers.conf; then sed -i -e "/meta-digi-dey/a\ ${YOCTO_INST_DIR}/sources/meta-digi-mfg \\\\" conf/bblayers.conf fi + printf "\n[INFO] Show customized local.conf.\n" + cat conf/local.conf + for target in ${platform_targets}; do printf "\n[INFO] Building the ${target} target.\n" time bitbake ${target} $(swu_recipe_name ${target}) diff --git a/sdk/config/ccimx8mn-dvk/bblayers.conf.sample b/sdk/config/ccimx8mn-dvk/bblayers.conf.sample new file mode 100644 index 000000000..bc2ef9645 --- /dev/null +++ b/sdk/config/ccimx8mn-dvk/bblayers.conf.sample @@ -0,0 +1,22 @@ +# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf +# changes incompatibly +POKY_BBLAYERS_CONF_VERSION = "2" + +BBPATH = "${TOPDIR}" +BBFILES ?= "" + +BBLAYERS ?= " \ + ##OEROOT##/meta \ + ##OEROOT##/meta-poky \ + ##OEROOT##/meta-yocto-bsp \ + ##DIGIBASE##/meta-openembedded/meta-oe \ + ##DIGIBASE##/meta-openembedded/meta-python \ + ##DIGIBASE##/meta-openembedded/meta-networking \ + ##DIGIBASE##/meta-openembedded/meta-webserver \ + ##DIGIBASE##/meta-qt5 \ + ##DIGIBASE##/meta-swupdate \ + ##DIGIBASE##/meta-freescale \ + ##DIGIBASE##/meta-fsl-demos \ + ##DIGIBASE##/meta-digi/meta-digi-arm \ + ##DIGIBASE##/meta-digi/meta-digi-dey \ + " diff --git a/sdk/config/ccimx8mn-dvk/conf-notes.txt b/sdk/config/ccimx8mn-dvk/conf-notes.txt new file mode 100644 index 000000000..6085b7217 --- /dev/null +++ b/sdk/config/ccimx8mn-dvk/conf-notes.txt @@ -0,0 +1,18 @@ +Digi Embedded Yocto provides the following image recipes: + + * dey-image-qt: graphical QT image + + By default the image is XWayland-based so it provides a full Weston + desktop environment. + + To compile the image for the framebuffer (instead of XWayland) add + the following line to the project's conf/local.conf: + + DISTRO_FEATURES_remove = "x11 wayland vulkan" + + * dey-image-aws: console-only image supporting Amazon Web Services IoT + + This image includes the AWS Greengrass Core and an AWS IoT platform + example application. For more information on AWS support in Digi + Embedded Yocto see the online documentation. + diff --git a/sdk/config/ccimx8mn-dvk/local.conf.sample b/sdk/config/ccimx8mn-dvk/local.conf.sample new file mode 100644 index 000000000..be7803074 --- /dev/null +++ b/sdk/config/ccimx8mn-dvk/local.conf.sample @@ -0,0 +1,266 @@ +# +# This file is your local configuration file and is where all local user settings +# are placed. The comments in this file give some guide to the options a new user +# to the system might want to change but pretty much any configuration option can +# be set in this file. More adventurous users can look at local.conf.extended +# which contains other examples of configuration which can be placed in this file +# but new users likely won't need any of them initially. +# +# Lines starting with the '#' character are commented out and in some cases the +# default values are provided as comments to show people example syntax. Enabling +# the option is a question of removing the # character and making any change to the +# variable as required. + +# +# Machine Selection +# +# You need to select a specific machine to target the build with. There are a selection +# of emulated machines available which can boot and run in the QEMU emulator: +# +#MACHINE ?= "qemuarm" +#MACHINE ?= "qemuarm64" +#MACHINE ?= "qemumips" +#MACHINE ?= "qemumips64" +#MACHINE ?= "qemuppc" +#MACHINE ?= "qemux86" +#MACHINE ?= "qemux86-64" +# +# There are also the following hardware board target machines included for +# demonstration purposes: +# +#MACHINE ?= "beaglebone-yocto" +#MACHINE ?= "genericx86" +#MACHINE ?= "genericx86-64" +#MACHINE ?= "mpc8315e-rdb" +#MACHINE ?= "edgerouter" +# +# This sets the default machine to be qemux86 if no other machine is selected: +#MACHINE ??= "qemux86" + +MACHINE = "ccimx8mn-dvk" + +# +# Use Digi's internal git repositories +# +#DIGI_INTERNAL_GIT ?= "1" + +# +# Where to place downloads +# +# During a first build the system will download many different source code tarballs +# from various upstream projects. This can take a while, particularly if your network +# connection is slow. These are all stored in DL_DIR. When wiping and rebuilding you +# can preserve this directory to speed up this part of subsequent builds. This directory +# is safe to share between multiple builds on the same machine too. +# +# The default is a downloads directory under TOPDIR which is the build directory. +# +#DL_DIR ?= "${TOPDIR}/downloads" + +# +# Where to place shared-state files +# +# BitBake has the capability to accelerate builds based on previously built output. +# This is done using "shared state" files which can be thought of as cache objects +# and this option determines where those files are placed. +# +# You can wipe out TMPDIR leaving this directory intact and the build would regenerate +# from these files if no changes were made to the configuration. If changes were made +# to the configuration, only shared state files where the state was still valid would +# be used (done using checksums). +# +# The default is a sstate-cache directory under TOPDIR. +# +#SSTATE_DIR ?= "${TOPDIR}/sstate-cache" + +# +# Where to place the build output +# +# This option specifies where the bulk of the building work should be done and +# where BitBake should place its temporary files and output. Keep in mind that +# this includes the extraction and compilation of many applications and the toolchain +# which can use Gigabytes of hard disk space. +# +# The default is a tmp directory under TOPDIR. +# +#TMPDIR = "${TOPDIR}/tmp" + +# +# Default policy config +# +# The distribution setting controls which policy settings are used as defaults. +# The default value is fine for general Yocto project use, at least initially. +# Ultimately when creating custom policy, people will likely end up subclassing +# these defaults. +# +DISTRO ?= "dey" +# As an example of a subclass there is a "bleeding" edge policy configuration +# where many versions are set to the absolute latest code from the upstream +# source control systems. This is just mentioned here as an example, its not +# useful to most new users. +# DISTRO ?= "poky-bleeding" + +# +# Package Management configuration +# +# This variable lists which packaging formats to enable. Multiple package backends +# can be enabled at once and the first item listed in the variable will be used +# to generate the root filesystems. +# Options are: +# - 'package_deb' for debian style deb files +# - 'package_ipk' for ipk files are used by opkg (a debian style embedded package manager) +# - 'package_rpm' for rpm style packages +# E.g.: PACKAGE_CLASSES ?= "package_rpm package_deb package_ipk" +# We default to rpm: +PACKAGE_CLASSES ?= "package_rpm" + +# +# SDK target architecture +# +# This variable specifies the architecture to build SDK items for and means +# you can build the SDK packages for architectures other than the machine you are +# running the build on (i.e. building i686 packages on an x86_64 host). +# Supported values are i686 and x86_64 +#SDKMACHINE ?= "i686" + +# +# Extra image configuration defaults +# +# The EXTRA_IMAGE_FEATURES variable allows extra packages to be added to the generated +# images. Some of these options are added to certain image types automatically. The +# variable can contain the following options: +# "dbg-pkgs" - add -dbg packages for all installed packages +# (adds symbol information for debugging/profiling) +# "dev-pkgs" - add -dev packages for all installed packages +# (useful if you want to develop against libs in the image) +# "ptest-pkgs" - add -ptest packages for all ptest-enabled packages +# (useful if you want to run the package test suites) +# "tools-sdk" - add development tools (gcc, make, pkgconfig etc.) +# "tools-debug" - add debugging tools (gdb, strace) +# "eclipse-debug" - add Eclipse remote debugging support +# "tools-profile" - add profiling tools (oprofile, lttng, valgrind) +# "tools-testapps" - add useful testing tools (ts_print, aplay, arecord etc.) +# "debug-tweaks" - make an image suitable for development +# e.g. ssh root access has a blank password +# There are other application targets that can be used here too, see +# meta/classes/image.bbclass and meta/classes/core-image.bbclass for more details. +# We default to enabling the debugging tweaks. +EXTRA_IMAGE_FEATURES ?= "debug-tweaks" + +# +# Additional image features +# +# The following is a list of additional classes to use when building images which +# enable extra features. Some available options which can be included in this variable +# are: +# - 'buildstats' collect build statistics +# - 'image-mklibs' to reduce shared library files size for an image +# - 'image-prelink' in order to prelink the filesystem image +# NOTE: if listing mklibs & prelink both, then make sure mklibs is before prelink +# NOTE: mklibs also needs to be explicitly enabled for a given image, see local.conf.extended +USER_CLASSES ?= "buildstats image-mklibs image-prelink" + +# +# Runtime testing of images +# +# The build system can test booting virtual machine images under qemu (an emulator) +# after any root filesystems are created and run tests against those images. It can also +# run tests against any SDK that are built. To enable this uncomment these lines. +# See classes/test{image,sdk}.bbclass for further details. +#IMAGE_CLASSES += "testimage testsdk" +#TESTIMAGE_AUTO_qemuall = "1" + +# +# Interactive shell configuration +# +# Under certain circumstances the system may need input from you and to do this it +# can launch an interactive shell. It needs to do this since the build is +# multithreaded and needs to be able to handle the case where more than one parallel +# process may require the user's attention. The default is iterate over the available +# terminal types to find one that works. +# +# Examples of the occasions this may happen are when resolving patches which cannot +# be applied, to use the devshell or the kernel menuconfig +# +# Supported values are auto, gnome, xfce, rxvt, screen, konsole (KDE 3.x only), none +# Note: currently, Konsole support only works for KDE 3.x due to the way +# newer Konsole versions behave +#OE_TERMINAL = "auto" +# By default disable interactive patch resolution (tasks will just fail instead): +PATCHRESOLVE = "noop" + +# +# Disk Space Monitoring during the build +# +# Monitor the disk space during the build. If there is less that 1GB of space or less +# than 100K inodes in any key build location (TMPDIR, DL_DIR, SSTATE_DIR), gracefully +# shutdown the build. If there is less that 100MB or 1K inodes, perform a hard abort +# of the build. The reason for this is that running completely out of space can corrupt +# files and damages the build in ways which may not be easily recoverable. +# It's necesary to monitor /tmp, if there is no space left the build will fail +# with very exotic errors. +BB_DISKMON_DIRS ??= "\ + STOPTASKS,${TMPDIR},1G,100K \ + STOPTASKS,${DL_DIR},1G,100K \ + STOPTASKS,${SSTATE_DIR},1G,100K \ + STOPTASKS,/tmp,100M,100K \ + ABORT,${TMPDIR},100M,1K \ + ABORT,${DL_DIR},100M,1K \ + ABORT,${SSTATE_DIR},100M,1K \ + ABORT,/tmp,10M,1K" + +# +# Shared-state files from other locations +# +# As mentioned above, shared state files are prebuilt cache data objects which can +# used to accelerate build time. This variable can be used to configure the system +# to search other mirror locations for these objects before it builds the data itself. +# +# This can be a filesystem directory, or a remote url such as http or ftp. These +# would contain the sstate-cache results from previous builds (possibly from other +# machines). This variable works like fetcher MIRRORS/PREMIRRORS and points to the +# cache locations to check for the shared objects. +# NOTE: if the mirror uses the same structure as SSTATE_DIR, you need to add PATH +# at the end as shown in the examples below. This will be substituted with the +# correct path within the directory structure. +#SSTATE_MIRRORS ?= "\ +#file://.* http://someserver.tld/share/sstate/PATH;downloadfilename=PATH \n \ +#file://.* file:///some/local/dir/sstate/PATH" + +# +# Yocto Project SState Mirror +# +# The Yocto Project has prebuilt artefacts available for its releases, you can enable +# use of these by uncommenting the following line. This will mean the build uses +# the network to check for artefacts at the start of builds, which does slow it down +# equally, it will also speed up the builds by not having to build things if they are +# present in the cache. It assumes you can download something faster than you can build it +# which will depend on your network. +# +#SSTATE_MIRRORS ?= "file://.* http://sstate.yoctoproject.org/2.5/PATH;downloadfilename=PATH" + +# +# Qemu configuration +# +# By default qemu will build with a builtin VNC server where graphical output can be +# seen. The two lines below enable the SDL backend too. By default libsdl2-native will +# be built, if you want to use your host's libSDL instead of the minimal libsdl built +# by libsdl2-native then uncomment the ASSUME_PROVIDED line below. +PACKAGECONFIG_append_pn-qemu-native = " sdl" +PACKAGECONFIG_append_pn-nativesdk-qemu = " sdl" +#ASSUME_PROVIDED += "libsdl2-native" + +# CONF_VERSION is increased each time build/conf/ changes incompatibly and is used to +# track the version of this file when it was generated. This can safely be ignored if +# this doesn't mean anything to you. +CONF_VERSION = "1" + +# +# Enable local PR server +# +PRSERV_HOST = "localhost:0" + +# +# Some libraries and packages are covered by NXP EULA +# +#ACCEPT_FSL_EULA = "1"