summaryrefslogtreecommitdiff
path: root/recipes-bsp
diff options
context:
space:
mode:
authorMax Krummenacher <max.krummenacher@toradex.com>2023-02-21 20:44:37 +0100
committerMax Krummenacher <max.krummenacher@toradex.com>2023-02-22 17:53:12 +0100
commitb73a0250328d0b4f154b9f4d08b8a3225695c256 (patch)
treeb9da2a2105af4f01c42fe6a04e3ea15241f83028 /recipes-bsp
parentb9b9c2a195a66622ab80f24b507acbe6acfcd937 (diff)
dfu-metadata: add recipe
This adds scripts for installing a Verdin AM62 over DFU. - PC loads tiboot-dfu over DFU and executes it - tiboot initializes the RAM and goes to DFU - PC loads tispl and u-boot.img over DFU and executes them - u-boot boots to u-boot proper, detects DFU boot and goes to DFU - PC loads tiboot, tispl, u-boot.img to eMMC boot area and resets DFU - u-boot goes to UMS - PC uses bmaptool to flash eMMC user area - User resets the board Related-to: ELB-5045 Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
Diffstat (limited to 'recipes-bsp')
-rw-r--r--recipes-bsp/dfu-metadata/dfu-metadata_0.1.bb41
-rwxr-xr-xrecipes-bsp/dfu-metadata/files/bmaptool.sh66
-rwxr-xr-xrecipes-bsp/dfu-metadata/files/recovery-linux.sh32
3 files changed, 139 insertions, 0 deletions
diff --git a/recipes-bsp/dfu-metadata/dfu-metadata_0.1.bb b/recipes-bsp/dfu-metadata/dfu-metadata_0.1.bb
new file mode 100644
index 0000000..c09151d
--- /dev/null
+++ b/recipes-bsp/dfu-metadata/dfu-metadata_0.1.bb
@@ -0,0 +1,41 @@
+DESCRIPTION = "DFU installer tarball"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+SRC_URI = " \
+ file://recovery-linux.sh \
+ file://bmaptool.sh \
+"
+
+DFU_DEPLOYDIR = "${DEPLOYDIR}/${BPN}"
+
+inherit deploy nopackages
+
+DEPENDS = "bmap-tools-native dfu-util-native"
+do_deploy[mcdepends] = "mc::k3r5:ti-sci-fw:do_deploy"
+
+do_deploy () {
+ install -d ${DFU_DEPLOYDIR}/recovery/bmaptools/
+ install -m 755 ${WORKDIR}/recovery-linux.sh ${DFU_DEPLOYDIR}/
+ install -m 755 ${RECIPE_SYSROOT_NATIVE}/usr/bin/dfu-util ${DFU_DEPLOYDIR}/recovery/
+ install -m 755 ${RECIPE_SYSROOT_NATIVE}/usr/bin/bmaptool ${DFU_DEPLOYDIR}/recovery/
+ install -m 644 ${RECIPE_SYSROOT_NATIVE}/usr/lib/python3.10/site-packages/bmaptools/*.py ${DFU_DEPLOYDIR}/recovery/bmaptools/
+ install -m 644 ${WORKDIR}/bmaptool.sh ${DFU_DEPLOYDIR}/recovery/
+ install -m 644 ${DEPLOY_DIR_IMAGE}/tiboot3-am62x-gp-evm.bin-dfu ${DFU_DEPLOYDIR}
+ install -m 644 ${DEPLOY_DIR_IMAGE}//tiboot3.bin ${DFU_DEPLOYDIR}/
+ install -m 644 ${DEPLOY_DIR_IMAGE}/tispl.bin ${DFU_DEPLOYDIR}/
+ install -m 644 ${DEPLOY_DIR_IMAGE}/u-boot.img ${DFU_DEPLOYDIR}/
+
+ # fixup oe specific #!
+ sed -i 's%.usr.bin.env.*python.*%/usr/bin/env python%' ${DFU_DEPLOYDIR}/recovery/bmaptool
+
+ # fixup oe specific dynamic loader path
+ INTERPRETER=$(patchelf-uninative --print-interpreter $(which bash))
+ patchelf-uninative --set-interpreter $INTERPRETER ${DFU_DEPLOYDIR}/recovery/dfu-util
+}
+
+addtask deploy before do_build after do_install
+
+COMPATIBLE_MACHINE = "(verdin-am62)"
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
diff --git a/recipes-bsp/dfu-metadata/files/bmaptool.sh b/recipes-bsp/dfu-metadata/files/bmaptool.sh
new file mode 100755
index 0000000..3f589a3
--- /dev/null
+++ b/recipes-bsp/dfu-metadata/files/bmaptool.sh
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+Usage() {
+ echo "Writes a diskimage to a block device"
+ echo ""
+ echo "Usage: $0 <wic.gz> <block-device>"
+ echo " eg: $0 Apalis-iMX8_Qt5-X11-Image.rootfs.wic.gz /dev/mmcblk0"
+ echo "There must be a wic.bmap file at the same place as the wic.gz file"
+ echo "You need the bmap tools installed and the variable BMAPTOOL must point to it"
+ exit 0
+}
+
+[ -z "$BMAPTOOL" ] && BMAPTOOL="/opt/bmap-tools/bmaptool"
+if [ ! -x $BMAPTOOL ];
+then
+ echo "$BMAPTOOL" is not an executable
+ exit 1
+fi
+echo "$BMAPTOOL"
+
+while getopts "h" Option ; do
+ case $Option in
+ h) Usage
+ exit 0
+ ;;
+ esac
+done
+
+# test for exact 2 arguments
+if [ $# -ne 2 ];
+then
+ Usage
+ exit 1
+fi
+
+WIC=$1
+BLK=$2
+
+if [ ! -e $WIC ];
+then
+ echo $WIC does not exist
+ exit 1
+fi
+
+BMAP=`dirname $WIC`/`basename -s .gz $WIC`.bmap
+if [ ! -e $BMAP ];
+then
+ BMAP=`dirname $WIC`/`basename -s .xz $WIC`.bmap
+ if [ ! -e $BMAP ];
+ then
+ echo $BMAP does not exist, creating it
+ bmaptool create -o $BMAP $WIC
+ fi
+fi
+
+# test if the blk device might not be a SD-Card
+lsblk $BLK -do name,tran | egrep "(usb|mmcblk)" > /dev/null
+if [ $? -ne 0 ];
+then
+ echo $BLK seems to not be removable storage
+ lsblk -do name,rm,tran
+ exit 1
+fi
+
+sudo umount ${BLK}?
+sudo $BMAPTOOL copy --bmap $BMAP $WIC $2
diff --git a/recipes-bsp/dfu-metadata/files/recovery-linux.sh b/recipes-bsp/dfu-metadata/files/recovery-linux.sh
new file mode 100755
index 0000000..7144074
--- /dev/null
+++ b/recipes-bsp/dfu-metadata/files/recovery-linux.sh
@@ -0,0 +1,32 @@
+if which dfu-util 2>&1 > /dev/null
+then
+ DFU_UTIL=$(which dfu-util) 2>&1 > /dev/null
+else
+ echo "Install dfu-util from your distro should the provided one not work with your distro"
+ DFU_UTIL=recovery/dfu-util
+fi
+
+# boot to U-Boot from USB
+sudo $DFU_UTIL -w -R -a bootloader --device 0451:6165 -D tiboot3-am62x-gp-evm.bin-dfu
+sudo $DFU_UTIL -w -R -a tispl.bin --device 0451:6165 -D tispl.bin
+sudo $DFU_UTIL -w -R -a u-boot.img --device 0451:6165 -D u-boot.img
+
+# U-Boot starts DFU, flash U-Boot to eMMC
+sudo $DFU_UTIL -w -a tiboot3.bin.raw --device 0451:6165 -D tiboot3.bin
+sudo $DFU_UTIL -w -a tispl.bin.raw --device 0451:6165 -D tispl.bin
+sudo $DFU_UTIL -w -R -a u-boot.img.raw --device 0451:6165 -D u-boot.img
+
+# U-Boot starts UMS, wait for the device to appear
+UMS_DEV=$(lsblk -I 8 -dp --output "MODEL,NAME" | grep UMS | sed 's#.*\(/dev/sd[a-z]\).*#\1#')
+while [ -z $UMS_DEV ]; do
+ sleep 1;
+ echo 'Waiting for UMS...';
+ UMS_DEV=$(lsblk -I 8 -dp --output "MODEL,NAME" | grep UMS | sed 's#.*\(/dev/sd[a-z]\).*#\1#')
+done
+# give it some time to settle in.
+sleep 2
+sudo umount ${UMS_DEV}?*
+
+WIC=$(ls *.wic.??)
+# use bmap-tool to flash eMMC user area
+BMAPTOOL=$(realpath recovery/bmaptool) bmaptool.sh $WIC $UMS_DEV