[U-Boot] [RFC PATCH] fastboot: Implement fetching uboot env variables via fastboot getvar
Priit Laes
plaes at plaes.org
Tue Jul 9 11:52:56 UTC 2019
From: Priit Laes <priit.laes at paf.com>
Add u-boot specific getvar "extension" to fetch u-boot environment
variables via `fastboot getvar uboot:var`. This makes it possible
to gather certain data (like mac addresses) in an automated way
during initial fastboot flashing for inventory purposes:
$ fastboot getvar uboot:ethaddr
uboot:ethaddr: 12:23:45:56:78:90
Output is currently truncated at 64 bytes, but this is good enough
for my own requirements.
Signed-off-by: Priit Laes <priit.laes at paf.com>
---
drivers/fastboot/fb_getvar.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/fastboot/fb_getvar.c b/drivers/fastboot/fb_getvar.c
index bf957e8326..d78ca0af42 100644
--- a/drivers/fastboot/fb_getvar.c
+++ b/drivers/fastboot/fb_getvar.c
@@ -20,6 +20,7 @@ static void getvar_product(char *var_parameter, char *response);
static void getvar_platform(char *var_parameter, char *response);
static void getvar_current_slot(char *var_parameter, char *response);
static void getvar_slot_suffixes(char *var_parameter, char *response);
+static void getvar_ubootenv(char *var_parameter, char *response);
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
static void getvar_has_slot(char *var_parameter, char *response);
#endif
@@ -67,6 +68,9 @@ static const struct {
}, {
.variable = "slot-suffixes",
.dispatch = getvar_slot_suffixes
+ }, {
+ .variable = "uboot",
+ .dispatch = getvar_ubootenv
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
}, {
.variable = "has-slot",
@@ -131,6 +135,16 @@ static void getvar_version(char *var_parameter, char *response)
fastboot_okay(FASTBOOT_VERSION, response);
}
+static void getvar_ubootenv(char *var_parameter, char *response)
+{
+ const char *value = env_get(var_parameter);
+
+ if (value)
+ fastboot_okay(value, response);
+ else
+ fastboot_fail("Variable is not set", response);
+}
+
static void getvar_bootloader_version(char *var_parameter, char *response)
{
fastboot_okay(U_BOOT_VERSION, response);
--
2.11.0
More information about the U-Boot
mailing list