summaryrefslogtreecommitdiffstats
path: root/defaultenv
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-02-25 15:38:07 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2014-02-28 08:14:14 +0100
commit24ae621e17e23f758fdbb2efe3d6bb8eb2c68634 (patch)
tree0cb1afca8aad979dd4bee087b8e50569df6c7e4c /defaultenv
parent991a12da04e85c58bf404637b4ad6c6d2ba018fe (diff)
downloadbarebox-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 'defaultenv')
-rw-r--r--defaultenv/Makefile1
-rw-r--r--defaultenv/defaultenv-2-dfu/boot/dfu39
-rw-r--r--defaultenv/defaultenv.c2
3 files changed, 42 insertions, 0 deletions
diff --git a/defaultenv/Makefile b/defaultenv/Makefile
index d449e02..fc679eb 100644
--- a/defaultenv/Makefile
+++ b/defaultenv/Makefile
@@ -1,5 +1,6 @@
bbenv-$(CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW) += defaultenv-2-base
bbenv-$(CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW_MENU) += defaultenv-2-menu
+bbenv-$(CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW_DFU) += defaultenv-2-dfu
bbenv-$(CONFIG_DEFAULT_ENVIRONMENT_GENERIC) += defaultenv-1
obj-$(CONFIG_DEFAULT_ENVIRONMENT) += defaultenv.o
extra-y += barebox_default_env barebox_default_env.h barebox_default_env$(DEFAULT_COMPRESSION_SUFFIX)
diff --git a/defaultenv/defaultenv-2-dfu/boot/dfu b/defaultenv/defaultenv-2-dfu/boot/dfu
new file mode 100644
index 0000000..c9463b6
--- /dev/null
+++ b/defaultenv/defaultenv-2-dfu/boot/dfu
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+ boot-menu-add-entry "$0" "Device Firmware upgrade (DFU)"
+ exit
+fi
+
+if [ -d /dfutmp ]; then
+ rm -r /dfutmp
+fi
+
+mkdir -p /dfutmp
+
+kernel="/dfutmp/kernel"
+dtb="/dfutmp/dtb"
+cmdline="/dfutmp/cmdline"
+
+global.bootm.image="$kernel"
+
+dfu $kernel(kernel)c,$dtb(dtb)c,$cmdline(cmdline)c
+if [ $? != 0 ]; then
+ exit 1
+fi
+
+if [ ! -f "$kernel" ]; then
+ echo "No kernel uploaded. Aborting"
+ exit 1
+fi
+
+if [ -f "$cmdline" ]; then
+ global linux.bootargs.dyn.dfu
+ readf $cmdline global.linux.bootargs.dyn.dfu
+fi
+
+if [ -f "$dtb" ]; then
+ global.bootm.oftree="$dtb"
+fi
+
+true
diff --git a/defaultenv/defaultenv.c b/defaultenv/defaultenv.c
index 3f517b4..dc0e484 100644
--- a/defaultenv/defaultenv.c
+++ b/defaultenv/defaultenv.c
@@ -46,6 +46,8 @@ static void defaultenv_add_base(void)
defaultenv_append_directory(defaultenv_2_base);
if (IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW_MENU))
defaultenv_append_directory(defaultenv_2_menu);
+ if (IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW_DFU))
+ defaultenv_append_directory(defaultenv_2_dfu);
if (IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT_GENERIC))
defaultenv_append_directory(defaultenv_1);