summaryrefslogtreecommitdiff
path: root/board/sunxi/board.c
diff options
context:
space:
mode:
authorBernhard Nortmann <bernhard.nortmann@web.de>2016-06-09 05:37:35 (GMT)
committerHans de Goede <hdegoede@redhat.com>2016-07-15 06:34:34 (GMT)
commit320e0570e67efbd093d7750655a758c66e9d5528 (patch)
tree5d438c122ac6c34dd49e6b9857a59f641f270ff2 /board/sunxi/board.c
parent19e99fb4ff73f648f2b316d0ddd8ee3c01496bd4 (diff)
downloadu-boot-320e0570e67efbd093d7750655a758c66e9d5528.tar.xz
sunxi: FEL - Add the ability to recognize and auto-import uEnv-style data
The patch converts one of the "reserved" fields in the sunxi SPL header to a fel_uEnv_length entry. When booting over USB ("FEL mode"), this enables the sunxi-fel utility to pass the string length of uEnv.txt compatible data; at the same time requesting that this data be imported into the U-Boot environment. If parse_spl_header() in the sunxi board.c encounters a non-zero value in this header field, it will therefore call himport_r() to merge the string (lines) passed via FEL into the default settings. Environment vars can be changed this way even before U-Boot will attempt to autoboot - specifically, this also allows overriding "bootcmd". With fel_script_addr set and a zero fel_uEnv_length, U-Boot is safe to assume that data in .scr format (a mkimage-type script) was passed at fel_script_addr, and will handle it using the existing mechanism ("bootcmd_fel"). Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de> Acked-by: Siarhei Siamashka <siarhei.siamashka@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'board/sunxi/board.c')
-rw-r--r--board/sunxi/board.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index c8bf316..78dfda5 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -573,6 +573,7 @@ void get_board_serial(struct tag_serialnr *serialnr)
#if !defined(CONFIG_SPL_BUILD)
#include <asm/arch/spl.h>
+#include <environment.h>
/*
* Check the SPL header for the "sunxi" variant. If found: parse values
@@ -582,17 +583,29 @@ void get_board_serial(struct tag_serialnr *serialnr)
static void parse_spl_header(const uint32_t spl_addr)
{
struct boot_file_head *spl = (void *)(ulong)spl_addr;
- if (memcmp(spl->spl_signature, SPL_SIGNATURE, 3) == 0) {
- uint8_t spl_header_version = spl->spl_signature[3];
- if (spl_header_version == SPL_HEADER_VERSION) {
- if (spl->fel_script_address)
- setenv_hex("fel_scriptaddr",
- spl->fel_script_address);
- return;
- }
+ if (memcmp(spl->spl_signature, SPL_SIGNATURE, 3) != 0)
+ return; /* signature mismatch, no usable header */
+
+ uint8_t spl_header_version = spl->spl_signature[3];
+ if (spl_header_version != SPL_HEADER_VERSION) {
printf("sunxi SPL version mismatch: expected %u, got %u\n",
SPL_HEADER_VERSION, spl_header_version);
+ return;
+ }
+ if (!spl->fel_script_address)
+ return;
+
+ if (spl->fel_uEnv_length != 0) {
+ /*
+ * data is expected in uEnv.txt compatible format, so "env
+ * import -t" the string(s) at fel_script_address right away.
+ */
+ himport_r(&env_htab, (char *)spl->fel_script_address,
+ spl->fel_uEnv_length, '\n', H_NOCLEAR, 0, 0, NULL);
+ return;
}
+ /* otherwise assume .scr format (mkimage-type script) */
+ setenv_hex("fel_scriptaddr", spl->fel_script_address);
}
#endif