diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2014-02-25 15:38:07 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-02-28 08:14:14 +0100 |
commit | 24ae621e17e23f758fdbb2efe3d6bb8eb2c68634 (patch) | |
tree | 0cb1afca8aad979dd4bee087b8e50569df6c7e4c /scripts | |
parent | 991a12da04e85c58bf404637b4ad6c6d2ba018fe (diff) | |
download | barebox-24ae621e17e23f758fdbb2efe3d6bb8eb2c68634.tar.gz |
defaultenv: Add boot option for DFU
DFU is for device firmware upgrade, but for development purposes it's
sometmes useful to just start a kernel vie DFU. This adds a boot option
for doing this and also the corresponding counterpart on the host. With
this it's possible to boot a system with:
scripts/dfuboot.sh -k linuximage -d dtb -c "root=ubi0:root ubi.mtd=ubi rootfstype=ubifs ignore_loglevel"
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/dfuboot.sh | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/scripts/dfuboot.sh b/scripts/dfuboot.sh new file mode 100755 index 0000000000..524113b613 --- /dev/null +++ b/scripts/dfuboot.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +DEVICETREE= +KERNEL= +CMDLINE= + +usage() { + echo "usage: $0 [OPTIONS]" + echo "This script uploads a kernel and optionally a devicetree" + echo "and a kernel commandline to barebox via DFU running the" + echo "'boot dfu' command." + echo "OPTIONS:" + echo " -k <kernel> kernelimage to upload" + echo " -d <dtb> devicetree binary blob to upload" + echo " -c \"cmdline\" kernel commandline" + echo " -h This help text" + + exit 0 +} + +while getopts "k:d:c:h" opt +do + case "$opt" in + h) + usage + ;; + d) + DEVICETREE="$OPTARG" + ;; + k) + KERNEL="$OPTARG" + ;; + c) + CMDLINE="$OPTARG" + ;; + esac +done + +dfu-util -D "${KERNEL}" -a kernel +if [ $? != 0 ]; then + echo "Failed to upload kernel" + exit 1 +fi + +if [ -n "$DEVICETREE" ]; then + dfu-util -D "${DEVICETREE}" -a dtb + if [ $? != 0 ]; then + echo "Failed to upload devicetree" + exit 1 + fi +fi + +if [ -n "$CMDLINE" ]; then + cmdlinefile=$(mktemp) + + echo -e "$CMDLINE" > "${cmdlinefile}" + + dfu-util -D "${cmdlinefile}" -a cmdline -R + result=$? + + rm -f "${cmdlinefile}" + + if [ $result != 0 ]; then + echo "Failed to upload cmdline" + exit 1 + fi + +fi |