Skip to contentSkip to conversation

Calao dfu upload kernel or uImage and boot it

PATCH In review Jean-Christophe PLAGNIOL-VILLARD 2 participants 9 messages Jan 15, 2012 – Feb 9, 2012 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

cover Calao dfu upload kernel or uImage and boot it

HI,

this patch serie add the support to boot a uImage or kernel over dfu on calao boards

this also add the support to defaultenv/boot to specify via getopt the mode or kernel/rootfs and ip

The following changes since commit 87428167719cd9e28b61cc19fab4984f31750930:

Merge branch 'pu/jean-codesize' into next (2012-01-13 09:33:36 +0100)

are available in the git repository at:

git://uboot.jcrosoft.org/barebox.git calao-boot

Jean-Christophe PLAGNIOL-VILLARD (5):
dfu: add description how to specify the "description" to the long help defaultenv/boot: add getopt option support to select boot mode defaultenv/boot: add boot the kernel from the mem
filetype: add command support
usb-926x: add dfu mem options support

 arch/arm/boards/usb-a926x/env/bin/init_board |   10 ++++++-
 arch/arm/configs/usb_a9260_defconfig         |    1 +
 arch/arm/configs/usb_a9263_128mib_defconfig  |    1 +
 arch/arm/configs/usb_a9263_defconfig         |    1 +
 arch/arm/configs/usb_a9g20_128mib_defconfig  |    1 +
 arch/arm/configs/usb_a9g20_defconfig         |    1 +
 commands/Kconfig                             |    5 +++
 commands/Makefile                            |    1 +
 commands/dfu.c                               |    4 ++
 commands/filetype.c                          |   39 ++++++++++++++++++++++++++
 defaultenv/bin/_boot_help                    |   18 ++++++++++++
 defaultenv/bin/boot                          |   30 ++++++++++++++++----
 12 files changed, 105 insertions(+), 7 deletions(-)
 create mode 100644 commands/filetype.c
 create mode 100644 defaultenv/bin/_boot_help

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#1 lore raw

PATCH 1/5 dfu: add description how to specify the "description" to the long help

---
 commands/dfu.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
commands/dfu.c +4 -0
index 385fd89..7f2dfed 100644
@@ -169,6 +169,10 @@ BAREBOX_CMD_HELP_OPT  ("-m <str>",  "Manufacturer string (barebox)\n")
 BAREBOX_CMD_HELP_OPT  ("-p <str>",  "product string (" CONFIG_BOARDINFO ")\n")
 BAREBOX_CMD_HELP_OPT  ("-V <id>",   "vendor id\n")
 BAREBOX_CMD_HELP_OPT  ("-P <id>",   "product id\n")
+BAREBOX_CMD_HELP_OPT  ("<description>",
+	"device1(name1)[sr],device2(name2)[sr]\n"
+	"'s' means 'safe mode' (download the complete image before flashing) and\n"
+	"'r' that readback of the firmware is allowed.\n")
 BAREBOX_CMD_HELP_END
 
 /**
Signature · 7 lines
1.7.7


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 2/5 defaultenv/boot: add getopt option support to select boot mode

In reply to Jean-Christophe PLAGNIOL-VILLARD

boot: boot [-m <mode>] [-k <kernel_option>] [-r <rootfs_option>] [-i <ip_mode>]

options

 - kernel        nand, nor, nfs, tftp, disk
 - rootfs        nand, nor, net, disk
 - ip            dhcp, none, empty

mode option

   mode       kernel      rootfs
   nand       nand        nand
   nor        nor         nor
   nfs        nfs         net
   tftp       fttp        net
   disk       disk        disk

default mode are used from the /env/config

---
 defaultenv/bin/_boot_help |   18 ++++++++++++++++++
 defaultenv/bin/boot       |   26 +++++++++++++++++++++-----
 2 files changed, 39 insertions(+), 5 deletions(-)
 create mode 100644 defaultenv/bin/_boot_help
defaultenv/bin/_boot_help new file +18 -0
new file mode 100644
index 0000000..e7f7f16
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+echo "boot: boot [-m <mode>] [-k <kernel_option>] [-r <rootfs_option>] [-i <ip_mode>]"
+echo ""
+echo "options"
+echo " - kernel        nand, nor, nfs, tftp, disk"
+echo " - rootfs        nand, nor, net, disk"
+echo " - ip            dhcp, none, empty"
+echo ""
+echo "mode option"
+echo "   mode       kernel      rootfs"
+echo "   nand       nand        nand"
+echo "   nor        nor         nor"
+echo "   nfs        nfs         net"
+echo "   tftp       fttp        net"
+echo "   disk       disk        disk"
+echo ""
+echo "default mode are used from the /env/config"
defaultenv/bin/boot +21 -5
index 1120757..d37eca8 100644
@@ -6,19 +6,35 @@ if [ x$kernel_loc = xnet ]; then
 	kernel_loc=tftp
 fi
 
-if [ x$1 = xnand ]; then
+while getopt "hk:r:i:m:" Option
+do
+if [ ${Option} = k ]; then
+	kernel_loc=${OPTARG}
+elif [ ${Option} = r ]; then
+	rootfs_loc=${OPTARG}
+elif [ ${Option} = i ]; then
+	ip=${OPTARG}
+elif [ ${Option} = m ]; then
+	mode=${OPTARG}
+else
+	. /env/bin/_boot_help
+	exit 0
+fi
+done
+
+if [ x$mode = xnand ]; then
 	rootfs_loc=nand
 	kernel_loc=nand
-elif [ x$1 = xnor ]; then
+elif [ x$mode = xnor ]; then
 	rootfs_loc=nor
 	kernel_loc=nor
-elif [ x$1 = xnfs ]; then
+elif [ x$mode = xnfs ]; then
 	rootfs_loc=net
 	kernel_loc=nfs
-elif [ x$1 = xtftp ]; then
+elif [ x$mode = xtftp ]; then
 	rootfs_loc=net
 	kernel_loc=tftp
-elif [ x$1 = xdisk ]; then
+elif [ x$mode = xdisk ]; then
 	rootfs_loc=disk
 	kernel_loc=disk
 fi
Signature · 7 lines
1.7.7


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

Re: [PATCH 2/5] defaultenv/boot: add getopt option support to select boot mode

Quoted 15 lines · Jean-Christophe PLAGNIOL-VILLARD

boot: boot [-m <mode>] [-k <kernel_option>] [-r <rootfs_option>] [-i <ip_mode>]

options

 - kernel        nand, nor, nfs, tftp, disk
 - rootfs        nand, nor, net, disk
 - ip            dhcp, none, empty

mode option

   mode       kernel      rootfs
   nand       nand        nand
   nor        nor         nor
   nfs        nfs         net
   tftp       fttp        net
   disk       disk        disk
Quoted 3 lines

default mode are used from the /env/config

can we have patch 1 and 2 applied

Best Regards,
J.

Quoted 77 lines
---
 defaultenv/bin/_boot_help |   18 ++++++++++++++++++
 defaultenv/bin/boot       |   26 +++++++++++++++++++++-----
 2 files changed, 39 insertions(+), 5 deletions(-)
 create mode 100644 defaultenv/bin/_boot_help
defaultenv/bin/_boot_help new file +18 -0
new file mode 100644
index 0000000..e7f7f16
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+echo "boot: boot [-m <mode>] [-k <kernel_option>] [-r <rootfs_option>] [-i <ip_mode>]"
+echo ""
+echo "options"
+echo " - kernel        nand, nor, nfs, tftp, disk"
+echo " - rootfs        nand, nor, net, disk"
+echo " - ip            dhcp, none, empty"
+echo ""
+echo "mode option"
+echo "   mode       kernel      rootfs"
+echo "   nand       nand        nand"
+echo "   nor        nor         nor"
+echo "   nfs        nfs         net"
+echo "   tftp       fttp        net"
+echo "   disk       disk        disk"
+echo ""
+echo "default mode are used from the /env/config"
defaultenv/bin/boot +21 -5
index 1120757..d37eca8 100644
@@ -6,19 +6,35 @@ if [ x$kernel_loc = xnet ]; then
 	kernel_loc=tftp
 fi
 
-if [ x$1 = xnand ]; then
+while getopt "hk:r:i:m:" Option
+do
+if [ ${Option} = k ]; then
+	kernel_loc=${OPTARG}
+elif [ ${Option} = r ]; then
+	rootfs_loc=${OPTARG}
+elif [ ${Option} = i ]; then
+	ip=${OPTARG}
+elif [ ${Option} = m ]; then
+	mode=${OPTARG}
+else
+	. /env/bin/_boot_help
+	exit 0
+fi
+done
+
+if [ x$mode = xnand ]; then
 	rootfs_loc=nand
 	kernel_loc=nand
-elif [ x$1 = xnor ]; then
+elif [ x$mode = xnor ]; then
 	rootfs_loc=nor
 	kernel_loc=nor
-elif [ x$1 = xnfs ]; then
+elif [ x$mode = xnfs ]; then
 	rootfs_loc=net
 	kernel_loc=nfs
-elif [ x$1 = xtftp ]; then
+elif [ x$mode = xtftp ]; then
 	rootfs_loc=net
 	kernel_loc=tftp
-elif [ x$1 = xdisk ]; then
+elif [ x$mode = xdisk ]; then
 	rootfs_loc=disk
 	kernel_loc=disk
 fi
Signature · 1 line
1.7.7

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#4 lore raw

PATCH 3/5 defaultenv/boot: add boot the kernel from the mem

In reply to Jean-Christophe PLAGNIOL-VILLARD

as example uploaded via dfu

---
 defaultenv/bin/_boot_help |    2 +-
 defaultenv/bin/boot       |    4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
defaultenv/bin/_boot_help +1 -1
index e7f7f16..660dbf4 100644
@@ -3,7 +3,7 @@
 echo "boot: boot [-m <mode>] [-k <kernel_option>] [-r <rootfs_option>] [-i <ip_mode>]"
 echo ""
 echo "options"
-echo " - kernel        nand, nor, nfs, tftp, disk"
+echo " - kernel        nand, nor, nfs, tftp, disk, mem"
 echo " - rootfs        nand, nor, net, disk"
 echo " - ip            dhcp, none, empty"
 echo ""
defaultenv/bin/boot +3 -1
index d37eca8..538f506 100644
@@ -94,6 +94,8 @@ if [ x$kernel_loc = xnfs -o x$kernel_loc = xtftp ]; then
 	fi
 	kdev=/image
 	$kernel_loc $kernelimage $kdev || exit 1
+elif [ x$kernel_loc = xmem ]; then
+	kdev="/dev/ram0.kernel"
 elif [ x$kernel_loc = xnor ]; then
 	kdev="/dev/nor0.kernel"
 elif [ x$kernel_loc = xnand ]; then
@@ -101,7 +103,7 @@ elif [ x$kernel_loc = xnand ]; then
 elif [ x$kernel_loc = xdisk ]; then
 	kdev="/dev/$kernel_part"
 else
-	echo "error: set kernel_loc to one of 'tftp', 'nfs', 'nand', 'nor' or 'disk'"
+	echo "error: set kernel_loc to one of 'tftp', 'nfs', 'nand', 'nor' , 'mem' or 'disk'"
 	exit 1
 fi
 
Signature · 7 lines
1.7.7


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

PATCH 4/5 filetype: add command support

In reply to Jean-Christophe PLAGNIOL-VILLARD

this will allow to detect the filetype of a file and export it as filetype

---
 commands/Kconfig    |    5 +++++
 commands/Makefile   |    1 +
 commands/filetype.c |   39 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 45 insertions(+), 0 deletions(-)
 create mode 100644 commands/filetype.c
commands/Kconfig +5 -0
index 766428c..c613e22 100644
@@ -181,6 +181,11 @@ config CMD_NANDTEST
 	select PARTITION_NEED_MTD
 	prompt "nandtest"
 
+config CMD_FILETYPE
+	tristate
+	depends on FILETYPE
+	prompt "filetype"
+
 endmenu
 
 menu "console                       "
commands/Makefile +1 -0
index 31442b5..a91eed2 100644
@@ -64,3 +64,4 @@ obj-$(CONFIG_CMD_OFTREE)	+= oftree.o
 obj-$(CONFIG_CMD_MAGICVAR)	+= magicvar.o
 obj-$(CONFIG_CMD_IOMEM)		+= iomem.o
 obj-$(CONFIG_CMD_LINUX_EXEC)	+= linux_exec.o
+obj-$(CONFIG_CMD_FILETYPE)	+= filetype.o
commands/filetype.c new file +39 -0
new file mode 100644
index 0000000..7c5e907
@@ -0,0 +1,39 @@
+/*
+ * (C) Copyright 2012 Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
+ *
+ * Under GPLv2 Only
+ */
+
+#include <common.h>
+#include <command.h>
+#include <fs.h>
+#include <filetype.h>
+#include <environment.h>
+
+static int do_filetype(struct command *cmdtp, int argc, char *argv[])
+{
+	enum filetype type;
+
+	if (argc < 2)
+		return COMMAND_ERROR_USAGE;
+
+	type = file_name_detect_type(argv[1]);
+
+	printf("%s: %s detected\n", argv[1], file_type_to_string(type));
+
+	export_env_ull("filetype" , type);
+
+	return 0;
+}
+
+BAREBOX_CMD_HELP_START(filetype)
+BAREBOX_CMD_HELP_USAGE("filetype file\n")
+BAREBOX_CMD_HELP_USAGE("export filetype\n")
+BAREBOX_CMD_HELP_SHORT("detect file type\n")
+BAREBOX_CMD_HELP_END
+
+BAREBOX_CMD_START(filetype)
+	.cmd		= do_filetype,
+	.usage		= "detect file type",
+	BAREBOX_CMD_HELP(cmd_filetype_help)
+BAREBOX_CMD_END
Signature · 7 lines
1.7.7


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#6 lore raw

Re: [PATCH 4/5] filetype: add command support

Quoted 53 lines · Jean-Christophe PLAGNIOL-VILLARD

this will allow to detect the filetype of a file and export it as filetype

---
 commands/Kconfig    |    5 +++++
 commands/Makefile   |    1 +
 commands/filetype.c |   39 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 45 insertions(+), 0 deletions(-)
 create mode 100644 commands/filetype.c
commands/Kconfig +5 -0
index 766428c..c613e22 100644
@@ -181,6 +181,11 @@ config CMD_NANDTEST
 	select PARTITION_NEED_MTD
 	prompt "nandtest"
 
+config CMD_FILETYPE
+	tristate
+	depends on FILETYPE
+	prompt "filetype"
+
 endmenu
 
 menu "console                       "
commands/Makefile +1 -0
index 31442b5..a91eed2 100644
@@ -64,3 +64,4 @@ obj-$(CONFIG_CMD_OFTREE)	+= oftree.o
 obj-$(CONFIG_CMD_MAGICVAR)	+= magicvar.o
 obj-$(CONFIG_CMD_IOMEM)		+= iomem.o
 obj-$(CONFIG_CMD_LINUX_EXEC)	+= linux_exec.o
+obj-$(CONFIG_CMD_FILETYPE)	+= filetype.o
commands/filetype.c new file +12 -0
new file mode 100644
index 0000000..7c5e907
@@ -0,0 +1,39 @@
+/*
+ * (C) Copyright 2012 Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
+ *
+ * Under GPLv2 Only
+ */
+
+#include <common.h>
+#include <command.h>
+#include <fs.h>
+#include <filetype.h>
+#include <environment.h>
+

commands/filetype.c line 22

Quoted 10 lines
commands/filetype.c new file +10 -0
+static int do_filetype(struct command *cmdtp, int argc, char *argv[])
+{
+	enum filetype type;
+
+	if (argc < 2)
+		return COMMAND_ERROR_USAGE;
+
+	type = file_name_detect_type(argv[1]);
+
+	printf("%s: %s detected\n", argv[1], file_type_to_string(type));

As this is likely to be used in scripts it's probably useful to be able to suppress this output.

commands/filetype.c line 24

Quoted 2 lines
commands/filetype.c new file +2 -0
+
+	export_env_ull("filetype" , type);

magicvar description?

Also, with exporting the filetype as integer we export the numbers currently only known in sourcecode. We should add a switch to this command to dump the number <-> string relationship.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#7 lore raw

PATCH 5/5 usb-926x: add dfu mem options support

In reply to Jean-Christophe PLAGNIOL-VILLARD

this will allow to upload a bootable image in memory and boot it boot with the rootfs via nfs

the image will must be 16MiB max

---
 arch/arm/boards/usb-a926x/env/bin/init_board |   10 +++++++++-
 arch/arm/configs/usb_a9260_defconfig         |    1 +
 arch/arm/configs/usb_a9263_128mib_defconfig  |    1 +
 arch/arm/configs/usb_a9263_defconfig         |    1 +
 arch/arm/configs/usb_a9g20_128mib_defconfig  |    1 +
 arch/arm/configs/usb_a9g20_defconfig         |    1 +
 6 files changed, 14 insertions(+), 1 deletions(-)
arch/arm/boards/usb-a926x/env/bin/init_board +9 -1
index 0a6baf7..4c906f0 100644
@@ -6,7 +6,7 @@ button_wait=5
 product_id=0x1234
 vendor_id=0x4321
 
-dfu_config="/dev/nand0.barebox.bb(barebox)sr,/dev/nand0.kernel.bb(kernel)r,/dev/nand0.rootfs.bb(rootfs)r"
+dfu_config="/dev/nand0.barebox.bb(barebox)sr,/dev/nand0.kernel.bb(kernel)r,/dev/nand0.rootfs.bb(rootfs)r,/dev/ram0.kernel(mem)r"
 
 if [ $at91_udc0.vbus != 1 ]
 then
@@ -46,4 +46,12 @@ echo ""
 echo "Start DFU Mode"
 echo ""
 
+addpart /dev/ram0 16M@8M(kernel)
 dfu ${dfu_config} -P ${product_id} -V ${vendor_id}
+
+filetype /dev/ram0.kernel
+
+if [ $filetype -eq 1 -o $filetype -eq 3 -o $filetype -eq 4 ]
+then
+	boot -k mem -r net
+fi
arch/arm/configs/usb_a9260_defconfig +1 -0
index 9073d04..861c62d 100644
@@ -27,6 +27,7 @@ CONFIG_CMD_READLINE=y
 CONFIG_CMD_MENU=y
 CONFIG_CMD_MENU_MANAGEMENT=y
 CONFIG_CMD_PASSWD=y
+CONFIG_CMD_FILETYPE=y
 CONFIG_CMD_ECHO_E=y
 CONFIG_CMD_LOADB=y
 CONFIG_CMD_MEMINFO=y
arch/arm/configs/usb_a9263_128mib_defconfig +1 -0
index 457b25c..2c54743 100644
@@ -28,6 +28,7 @@ CONFIG_CMD_READLINE=y
 CONFIG_CMD_MENU=y
 CONFIG_CMD_MENU_MANAGEMENT=y
 CONFIG_CMD_PASSWD=y
+CONFIG_CMD_FILETYPE=y
 CONFIG_CMD_ECHO_E=y
 CONFIG_CMD_LOADB=y
 CONFIG_CMD_MEMINFO=y
arch/arm/configs/usb_a9263_defconfig +1 -0
index 6a7ded7..eb9ad9a 100644
@@ -27,6 +27,7 @@ CONFIG_CMD_READLINE=y
 CONFIG_CMD_MENU=y
 CONFIG_CMD_MENU_MANAGEMENT=y
 CONFIG_CMD_PASSWD=y
+CONFIG_CMD_FILETYPE=y
 CONFIG_CMD_ECHO_E=y
 CONFIG_CMD_LOADB=y
 CONFIG_CMD_MEMINFO=y
arch/arm/configs/usb_a9g20_128mib_defconfig +1 -0
index 3d44f39..cb17d71 100644
@@ -28,6 +28,7 @@ CONFIG_CMD_READLINE=y
 CONFIG_CMD_MENU=y
 CONFIG_CMD_MENU_MANAGEMENT=y
 CONFIG_CMD_PASSWD=y
+CONFIG_CMD_FILETYPE=y
 CONFIG_CMD_ECHO_E=y
 CONFIG_CMD_LOADB=y
 CONFIG_CMD_MEMINFO=y
arch/arm/configs/usb_a9g20_defconfig +1 -0
index 7abcd95..edce2cf 100644
@@ -27,6 +27,7 @@ CONFIG_CMD_READLINE=y
 CONFIG_CMD_MENU=y
 CONFIG_CMD_MENU_MANAGEMENT=y
 CONFIG_CMD_PASSWD=y
+CONFIG_CMD_FILETYPE=y
 CONFIG_CMD_ECHO_E=y
 CONFIG_CMD_LOADB=y
 CONFIG_CMD_MEMINFO=y
Signature · 7 lines
1.7.7


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#8 lore raw

Re: [PATCH 5/5] usb-926x: add dfu mem options support

Quoted 20 lines · Jean-Christophe PLAGNIOL-VILLARD

this will allow to upload a bootable image in memory and boot it boot with the rootfs via nfs

the image will must be 16MiB max

---
 arch/arm/boards/usb-a926x/env/bin/init_board |   10 +++++++++-
 arch/arm/configs/usb_a9260_defconfig         |    1 +
 arch/arm/configs/usb_a9263_128mib_defconfig  |    1 +
 arch/arm/configs/usb_a9263_defconfig         |    1 +
 arch/arm/configs/usb_a9g20_128mib_defconfig  |    1 +
 arch/arm/configs/usb_a9g20_defconfig         |    1 +
 6 files changed, 14 insertions(+), 1 deletions(-)
arch/arm/boards/usb-a926x/env/bin/init_board +0 -0
index 0a6baf7..4c906f0 100644

arch/arm/boards/usb-a926x/env/bin/init_board button_wait=5 · line 9

Quoted 5 lines
arch/arm/boards/usb-a926x/env/bin/init_board +1 -1
@@ -6,7 +6,7 @@ button_wait=5
 product_id=0x1234
 vendor_id=0x4321
 
-dfu_config="/dev/nand0.barebox.bb(barebox)sr,/dev/nand0.kernel.bb(kernel)r,/dev/nand0.rootfs.bb(rootfs)r"
+dfu_config="/dev/nand0.barebox.bb(barebox)sr,/dev/nand0.kernel.bb(kernel)r,/dev/nand0.rootfs.bb(rootfs)r,/dev/ram0.kernel(mem)r"

I really want to discourage usage of /dev/ram0 for 'official' use. Can't you use a regular file instead? From what I see only the O_CREAT flag is missing in the dfu driver.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox