summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWadim Egorov <w.egorov@phytec.de>2018-07-27 14:28:26 +0200
committerStefan Müller-Klieser <s.mueller-klieser@phytec.de>2018-09-07 11:22:45 +0200
commit6762b51d9fe9c8d79938d1052c8d84a542e90a66 (patch)
tree2dd2dfc9e3eea5d9fc0b94e7e2445151d4d7a577
parentbecde4f87972060fdde598fe47ed09aa9b387013 (diff)
downloadmeta-phytec-6762b51d9fe9c8d79938d1052c8d84a542e90a66.tar.bz2
meta-phytec-6762b51d9fe9c8d79938d1052c8d84a542e90a66.zip
bbu: Introduce the barebox update script for the userspace
The bbu.sh script allows us to update our bootloaders from the userspace. At the moment, we only support updates for AM335x based machines. Usage: bbu_nand.sh <MLO> <BOOTLOADER> MLO - AM335x CH image format BOOTLOADER - barebox image format Signed-off-by: Wadim Egorov <w.egorov@phytec.de> Signed-off-by: Stefan Müller-Klieser <s.mueller-klieser@phytec.de>
-rw-r--r--recipes-devtools/bbu/bbu.bb24
-rw-r--r--recipes-devtools/bbu/bbu/bbu.sh73
2 files changed, 97 insertions, 0 deletions
diff --git a/recipes-devtools/bbu/bbu.bb b/recipes-devtools/bbu/bbu.bb
new file mode 100644
index 0000000..92c3196
--- /dev/null
+++ b/recipes-devtools/bbu/bbu.bb
@@ -0,0 +1,24 @@
+DESCRIPTION = "The barebox update script is intended to be the userspace tool \
+ for barebox updates in our BSP."
+HOMEPAGE = "http://www.phytec.de"
+LICENSE = "GPL-2.0"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"
+SECTION = "devel"
+PR = "r0"
+
+SRC_URI = "file://bbu.sh"
+
+S = "${WORKDIR}"
+
+# Depends on tools like hexdump, tr, grep, awk which are part of our
+# busybox configuration
+RDEPENDS_${PN} = "busybox mtd-utils"
+
+do_install() {
+ install -d ${D}${bindir}
+ install -m 0755 bbu.sh ${D}${bindir}
+}
+
+FILES_${PN} = "${bindir}"
+
+COMPATIBLE_MACHINE = "ti33x"
diff --git a/recipes-devtools/bbu/bbu/bbu.sh b/recipes-devtools/bbu/bbu/bbu.sh
new file mode 100644
index 0000000..a48bf59
--- /dev/null
+++ b/recipes-devtools/bbu/bbu/bbu.sh
@@ -0,0 +1,73 @@
+#!/bin/sh
+# Copyright 2018 PHYTEC Messtechnik GmbH
+
+usage() {
+ echo "$0 <MLO> <BOOTLOADER>"
+ echo "MLO - AM335x CH image format"
+ echo "BOOTLOADER - barebox image format"
+}
+
+update_mtd_part() {
+
+ FILE_SIZE=`wc -c < $2`
+
+ echo "Flashing $2 to $1 partition"
+ flash_erase /dev/$1 0 0 -q
+ # Use -p which adds padding to match the NAND page size
+ if ! nandwrite /dev/$1 $2 -p -q ; then
+ echo "nandwrite failed"
+ exit 1
+ fi
+
+ # Verify flashed content
+ MD5_SUM1=`md5sum $2 | awk '{print $1}'`
+ MD5_SUM2=`nanddump /dev/$1 -l $FILE_SIZE -q | md5sum | awk '{print $1}'`
+ if [ "$MD5_SUM1" != "$MD5_SUM2" ]; then
+ echo "MD5 missmatch for $1"
+ exit 1
+ fi
+}
+
+if [ "$#" -ne 2 ]; then
+ echo "Illegal number of parameters"
+ usage
+ exit 1
+fi
+
+# Verify omap CH image format
+if ! hexdump -C $1 -s 0x14 -n 10 | grep -q "CHSETTINGS"; then
+ echo "$1 is not a CH Image format"
+ usage
+ exit 1
+fi
+
+# Verify barebox image format
+if ! hexdump -C $2 -s 0x20 -n 8 | grep -q "barebox"; then
+ echo "$2 is not a barebox Image format"
+ usage
+ exit 1
+fi
+
+# List all xload mtd partitions
+xload_nand_slots=`cat /proc/mtd | grep xload | awk '{print $1}' | tr -d :`
+xload_nand_slots=`echo $xload_nand_slots | tr " "`
+
+for slot in $xload_nand_slots
+do
+ nand=`mtdinfo /dev/$slot | grep Type | awk '{print $2}'`
+ if [ "$nand" = "nand" ]; then
+ update_mtd_part $slot $1
+ fi
+done
+
+# Update barebox
+barebox_part=`cat /proc/mtd | grep -v bareboxenv | grep barebox | awk '{print $1}' | tr -d :`
+barebox_part=`echo $barebox_part | tr " "`
+
+for part in $barebox_part
+do
+ nand=`mtdinfo /dev/$part | grep Type | awk '{print $2}'`
+ if [ "$nand" = "nand" ]; then
+ update_mtd_part $part $2
+ fi
+done