Skip to contentSkip to conversation

fastboot: allow retrieving fastboot variables from env

PATCH In review Boris Brezillon 4 participants 6 messages Mar 17, 2016 – Apr 2, 2016 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fastboot: allow retrieving fastboot variables from env

From: Rob Herring <[email protected]>

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').

[Boris Brezillon: add a commit message]
---
 drivers/usb/gadget/f_fastboot.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/usb/gadget/f_fastboot.c +10 -2
index a54b4ee..2e87fee 100644
@@ -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);
 }
Signature · 1 line
2.5.0
#1 lore raw

PATCH 1/1 fastboot: allow retrieving fastboot variables from env

Quoted 13 lines · On Thu, 17 Mar 2016 17:21:23 +0100 Boris Brezillon…

From: Rob Herring <[email protected]>

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').

Quoted 5 lines
[Boris Brezillon: add a commit message]

Sorry for the duplicated SoB.

Quoted 27 lines
---
 drivers/usb/gadget/f_fastboot.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/usb/gadget/f_fastboot.c +10 -2
index a54b4ee..2e87fee 100644
@@ -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);
 }
Signature · 3 lines
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#2 lore raw

PATCH 1/1 fastboot: allow retrieving fastboot variables from env

Quoted 65 lines · Boris Brezillon
Quoted 13 lines · On Thu, 17 Mar 2016 17:21:23 +0100 Boris Brezillon…

From: Rob Herring <[email protected]>

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').

Quoted 5 lines
[Boris Brezillon: add a commit message]

Sorry for the duplicated SoB.

Review

Quoted 5 lines
---
 drivers/usb/gadget/f_fastboot.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/usb/gadget/f_fastboot.c

drivers/usb/gadget/f_fastboot.c static void cb_getvar(struct usb_ep *ep, struct

Quoted 4 lines

index a54b4ee..2e87fee 100644

drivers/usb/gadget/f_fastboot.c +0 -0
@@ -413,8 +413,16 @@ static void cb_getvar(struct usb_ep *ep, struct

usb_request *req)

Quoted 8 lines
drivers/usb/gadget/f_fastboot.c +3 -2
              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);

drivers/usb/gadget/f_fastboot.c static void cb_getvar(struct usb_ep *ep, struct usb_request *req) · line 428

Quoted 10 lines
drivers/usb/gadget/f_fastboot.c +7 -0
+             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);
 }

--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#3 lore raw

PATCH 1/1 fastboot: allow retrieving fastboot variables from env

In reply to Boris Brezillon
Quoted 28 lines · Boris Brezillon
Quoted 13 lines · On Thu, 17 Mar 2016 17:21:23 +0100 Boris Brezillon…

From: Rob Herring <[email protected]>

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').

Quoted 5 lines
[Boris Brezillon: add a commit message]

Sorry for the duplicated SoB.

Quoted 4 lines
---
 drivers/usb/gadget/f_fastboot.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
Quoted 27 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/usb/gadget/f_fastboot.c

drivers/usb/gadget/f_fastboot.c static void cb_getvar(struct usb_ep *ep, struct

Quoted 4 lines

index a54b4ee..2e87fee 100644

drivers/usb/gadget/f_fastboot.c +0 -0
@@ -413,8 +413,16 @@ static void cb_getvar(struct usb_ep *ep, struct

usb_request *req)

Quoted 18 lines
drivers/usb/gadget/f_fastboot.c +10 -2
              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);
 }
Quoted 11 lines

--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#4 lore raw

PATCH 1/1 fastboot: allow retrieving fastboot variables from env

In reply to Boris Brezillon
Quoted 16 lines · Boris Brezillon
Quoted 13 lines · On Thu, 17 Mar 2016 17:21:23 +0100 Boris Brezillon…

From: Rob Herring <[email protected]>

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').

Quoted 7 lines
Quoted 5 lines
[Boris Brezillon: add a commit message]

Sorry for the duplicated SoB.

Dropped the double-SoB and applied, thanks!

Best regards,
Marek Vasut

#5 lore raw
In reply to Boris Brezillon
Quoted 13 lines · Boris BREZILLON

From: Rob Herring <[email protected]>

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').

Quoted 6 lines
[Boris Brezillon: add a commit message]

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160401/d77bfca5/attachment.sig>