From: Rob Herring Date: Thu, 17 Mar 2016 16:21:23 +0000 (+0100) Subject: fastboot: allow retrieving fastboot variables from env X-Git-Tag: v2016.05-rc1~94 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=74322201dde4593dc3194c702e95e5760e6b497a;p=oweals%2Fu-boot.git fastboot: allow retrieving fastboot variables from env Some boards need to expose device specific variable through fastboot (to adpat the flashing script depending on hardware revision for example). Provide a way to expose custom fastboot variables. Note that all variables meant to be exposed through fastboot should be be prefixed with 'fastboot.', the variable should not exceed 32 bytes (including the prefix and the trailing '\0') and the variable content should fit in the response buffer (60 bytes excluding the 'OKAY' prefix and the trailing '\0'). Signed-off-by: Rob Herring [Boris Brezillon: add a commit message] Signed-off-by: Boris Brezillon Signed-off-by: Boris Brezillon Acked-by: Steve Rae --- diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index a54b4eebcc..2e87feeece 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -413,8 +413,16 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) else strcpy(response, "FAILValue not set"); } else { - printf("WARNING: unknown variable: %s\n", cmd); - strcpy(response, "FAILVariable not implemented"); + char envstr[32]; + + snprintf(envstr, sizeof(envstr) - 1, "fastboot.%s", cmd); + s = getenv(envstr); + if (s) { + strncat(response, s, chars_left); + } else { + printf("WARNING: unknown variable: %s\n", cmd); + strcpy(response, "FAILVariable not implemented"); + } } fastboot_tx_write_str(response); }