public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [RFC] sunxi: Support uploading 'boot.scr' to RAM over USB OTG in FEL mode
@ 2015-02-24  2:48 Siarhei Siamashka
  2015-02-27 16:39 ` Ian Campbell
  0 siblings, 1 reply; 6+ messages in thread
From: Siarhei Siamashka @ 2015-02-24  2:48 UTC (permalink / raw)
  To: u-boot

In order to fully support booting the whole system over USB OTG
without relying on anything else (MMC, SATA, USB sticks, ...), it
is possible to upload the 'boot.scr' file to DRAM using the 'fel'
tool. But U-Boot still needs to be able to pick it up there before
checking any other boot media.

Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
---

The patch might be not the best way to implement this. But it would
be great if U-Boot had out of the box support for:
    http://linux-sunxi.org/index.php?title=FEL/USBBoot&oldid=13134#Boot_the_whole_system_over_USB_.28u-boot_.2B_kernel_.2B_initramfs.29

One of the bad things about this patch is that the "scriptaddr"
variable needs to be hardcoded and protected agaist modifications
(if this address is to be used from the SPL).

Also I'm not sure how this all could fit into the
"config_distro_bootcmd.h" model, so I even have not tried
that yet.

 arch/arm/cpu/armv7/sunxi/board.c |  3 +++
 board/sunxi/board.c              | 16 ++++++++++++++++
 include/configs/sunxi-common.h   |  4 +++-
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c
index c02c015..8966245 100644
--- a/arch/arm/cpu/armv7/sunxi/board.c
+++ b/arch/arm/cpu/armv7/sunxi/board.c
@@ -112,6 +112,9 @@ void s_init(void)
  */
 u32 spl_boot_device(void)
 {
+	/* Erase any potential boot.scr remnants in DRAM */
+	writel(0, CONFIG_SCRIPTADDR);
+
 #ifdef CONFIG_SPL_FEL
 	/*
 	 * This is the legacy compile time configuration for a special FEL
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index b70e00c..866dbce 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -235,6 +235,7 @@ static struct musb_hdrc_platform_data musb_plat = {
 int misc_init_r(void)
 {
 	unsigned int sid[4];
+	char *boot_targets;
 
 	if (!getenv("ethaddr") && sunxi_get_sid(sid) == 0 &&
 			sid[0] != 0 && sid[3] != 0) {
@@ -250,6 +251,21 @@ int misc_init_r(void)
 		eth_setenv_enetaddr("ethaddr", mac_addr);
 	}
 
+	boot_targets = getenv("boot_targets");
+	if (boot_targets) {
+		char *prefix = "fel ";
+		char *new_boot_targets = malloc(strlen(prefix) +
+						strlen(boot_targets) + 1);
+		if (new_boot_targets) {
+			strcpy(new_boot_targets, prefix);
+			strcat(new_boot_targets, boot_targets);
+			setenv("boot_targets", new_boot_targets);
+			free(new_boot_targets);
+		}
+	}
+
+	setenv_hex("scriptaddr", CONFIG_SCRIPTADDR);
+
 #if defined(CONFIG_MUSB_HOST) || defined(CONFIG_MUSB_GADGET)
 	musb_register(&musb_plat, NULL, (void *)SUNXI_USB0_BASE);
 #endif
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 7779b1f..e7c3322 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -297,6 +297,8 @@
 #define CONFIG_MISC_INIT_R
 #define CONFIG_SYS_CONSOLE_IS_IN_ENV
 
+#define CONFIG_SCRIPTADDR 0x43100000
+
 #ifndef CONFIG_SPL_BUILD
 #include <config_distro_defaults.h>
 
@@ -315,7 +317,6 @@
 	"bootm_size=0xf000000\0" \
 	"kernel_addr_r=0x42000000\0" \
 	"fdt_addr_r=0x43000000\0" \
-	"scriptaddr=0x43100000\0" \
 	"pxefile_addr_r=0x43200000\0" \
 	"ramdisk_addr_r=0x43300000\0"
 
@@ -372,6 +373,7 @@
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	CONSOLE_ENV_SETTINGS \
 	MEM_LAYOUT_ENV_SETTINGS \
+	"bootcmd_fel=source ${scriptaddr}\0" \
 	"fdtfile=" CONFIG_FDTFILE "\0" \
 	"console=ttyS0,115200\0" \
 	BOOTENV
-- 
2.0.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-03-05  7:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-24  2:48 [U-Boot] [RFC] sunxi: Support uploading 'boot.scr' to RAM over USB OTG in FEL mode Siarhei Siamashka
2015-02-27 16:39 ` Ian Campbell
2015-03-01 21:37   ` Siarhei Siamashka
2015-03-03  8:31     ` Ian Campbell
2015-03-04 14:18       ` Siarhei Siamashka
2015-03-05  7:42         ` Ian Campbell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox