From patchwork Tue Feb 24 02:48:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siarhei Siamashka X-Patchwork-Id: 442759 X-Patchwork-Delegate: hdegoede@redhat.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 01E94140157 for ; Tue, 24 Feb 2015 13:49:07 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4FB2C4A047; Tue, 24 Feb 2015 03:49:06 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WzjHYBXv1Q6F; Tue, 24 Feb 2015 03:49:05 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9861E4A03C; Tue, 24 Feb 2015 03:49:05 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5784B4A03C for ; Tue, 24 Feb 2015 03:49:00 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YCaGESnity1L for ; Tue, 24 Feb 2015 03:49:00 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com [209.85.215.53]) by theia.denx.de (Postfix) with ESMTPS id 1E7BB4A036 for ; Tue, 24 Feb 2015 03:48:57 +0100 (CET) Received: by lams18 with SMTP id s18so22936103lam.11 for ; Mon, 23 Feb 2015 18:48:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=F8iu0QBAZfhIT5p22/36QEfE5VLo78+GT8gVEPK5AM8=; b=P445vhJ59eU1n9Ok3Kj8oRA+EFzboTaYqloiQnCe1TDX741QYWKxCyQUyrVWSMwcxE yZ5JLYAR7kjhExRiXZU8nUe5jWSM7McE4ev/XV1jr8C62k2FmQ8X3Ys34dG5CYRl2WD0 r5+im4AE12WUudccKTEwgqORqRad/BuLpcKHCwgoE4ZTPjtUv+ELig/W9IKNWXMldYkc tYxi719zS/tL7W2k2qFESdr3jEinALpZFqUJheBVDe8CCyQibHcQsn3B6NBjhQwCJqER /Q7VU/PFJOaD4gfb1gQNDJSry480hKHrvg92J6DDmafboqH0K07bTizJymrDCk5m6cLm m/Mw== X-Received: by 10.152.6.100 with SMTP id z4mr12286862laz.114.1424746136594; Mon, 23 Feb 2015 18:48:56 -0800 (PST) Received: from localhost.localdomain (85-76-149-175-nat.elisa-mobile.fi. [85.76.149.175]) by mx.google.com with ESMTPSA id w9sm789022lae.35.2015.02.23.18.48.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Feb 2015 18:48:55 -0800 (PST) From: Siarhei Siamashka To: u-boot@lists.denx.de Date: Tue, 24 Feb 2015 04:48:51 +0200 Message-Id: <1424746131-11740-1-git-send-email-siarhei.siamashka@gmail.com> X-Mailer: git-send-email 2.0.5 Cc: Ian Campbell Subject: [U-Boot] [RFC] sunxi: Support uploading 'boot.scr' to RAM over USB OTG in FEL mode X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "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 --- 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 @@ -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