Skip to contentSkip to conversation

usb: gadget: f_sdp: Provide filesize env variable for downloaded images

PATCH Superseded Petr Štetiar 4 participants 5 messages Nov 23, 2018 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: gadget: f_sdp: Provide filesize env variable for downloaded images

Currently it's not possible to get filesize of downloaded images and it's impossible to automate some tasks in scripts.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Stefan Agner <[email protected]>
---
 drivers/usb/gadget/f_sdp.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/usb/gadget/f_sdp.c +5 -0
index 00a9f88..ae97ab2 100644
@@ -100,6 +100,7 @@ struct f_sdp {
 	enum sdp_state			state;
 	enum sdp_state			next_state;
 	u32				dnl_address;
+	u32				dnl_bytes;
 	u32				dnl_bytes_remaining;
 	u32				jmp_address;
 	bool				always_send_status;
@@ -276,6 +277,7 @@ static void sdp_rx_command_complete(struct usb_ep *ep, struct usb_request *req)
 		sdp->state = SDP_STATE_RX_FILE_DATA;
 		sdp->dnl_address = be32_to_cpu(cmd->addr);
 		sdp->dnl_bytes_remaining = be32_to_cpu(cmd->cnt);
+		sdp->dnl_bytes = sdp->dnl_bytes_remaining;
 		sdp->next_state = SDP_STATE_IDLE;
 
 		printf("Downloading file of size %d to 0x%08x... ",
@@ -355,6 +357,9 @@ static void sdp_rx_data_complete(struct usb_ep *ep, struct usb_request *req)
 	if (sdp->dnl_bytes_remaining)
 		return;
 
+#ifndef CONFIG_SPL_BUILD
+	env_set_hex("filesize", sdp->dnl_bytes);
+#endif
 	printf("done\n");
 
 	switch (sdp->state) {
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 usb: gadget: f_sdp: Provide filesize env variable for downloaded images

Quoted 32 lines · On Fri, 23 Nov 2018 10:21:24 +0100 Petr Štetiar <[email protected]> wrote:

Currently it's not possible to get filesize of downloaded images and it's impossible to automate some tasks in scripts.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Stefan Agner <[email protected]>
---
 drivers/usb/gadget/f_sdp.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/usb/gadget/f_sdp.c +2 -0
index 00a9f88..ae97ab2 100644
@@ -100,6 +100,7 @@ struct f_sdp {
 	enum sdp_state			state;
 	enum sdp_state			next_state;
 	u32				dnl_address;
+	u32				dnl_bytes;
 	u32				dnl_bytes_remaining;
 	u32				jmp_address;
 	bool				always_send_status;
@@ -276,6 +277,7 @@ static void sdp_rx_command_complete(struct usb_ep
 *ep, struct usb_request *req) sdp->state = SDP_STATE_RX_FILE_DATA;
 		sdp->dnl_address = be32_to_cpu(cmd->addr);
 		sdp->dnl_bytes_remaining = be32_to_cpu(cmd->cnt);
+		sdp->dnl_bytes = sdp->dnl_bytes_remaining;
 		sdp->next_state = SDP_STATE_IDLE;
 
 		printf("Downloading file of size %d to 0x%08x... ",

drivers/usb/gadget/f_sdp.c static void sdp_rx_data_complete(struct usb_ep · line 365

Quoted 9 lines
drivers/usb/gadget/f_sdp.c +3 -0
@@ -355,6 +357,9 @@ static void sdp_rx_data_complete(struct usb_ep
 *ep, struct usb_request *req) if (sdp->dnl_bytes_remaining)
 		return;
 
+#ifndef CONFIG_SPL_BUILD
+	env_set_hex("filesize", sdp->dnl_bytes);
+#endif
 	printf("done\n");
 
 	switch (sdp->state) {

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181123/9cbfd4a0/attachment.sig>

#2 lore raw

PATCH 1/1 usb: gadget: f_sdp: Provide filesize env variable for downloaded images

In reply to Petr Štetiar
Quoted 2 lines · Petr Štetiar

Currently it's not possible to get filesize of downloaded images and it's impossible to automate some tasks in scripts.

... so ... what does this patch do about it ? That sort of thing should be in the commit message.

Quoted 39 lines
Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Stefan Agner <[email protected]>
---
 drivers/usb/gadget/f_sdp.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/usb/gadget/f_sdp.c +5 -0
index 00a9f88..ae97ab2 100644
@@ -100,6 +100,7 @@ struct f_sdp {
 	enum sdp_state			state;
 	enum sdp_state			next_state;
 	u32				dnl_address;
+	u32				dnl_bytes;
 	u32				dnl_bytes_remaining;
 	u32				jmp_address;
 	bool				always_send_status;
@@ -276,6 +277,7 @@ static void sdp_rx_command_complete(struct usb_ep *ep, struct usb_request *req)
 		sdp->state = SDP_STATE_RX_FILE_DATA;
 		sdp->dnl_address = be32_to_cpu(cmd->addr);
 		sdp->dnl_bytes_remaining = be32_to_cpu(cmd->cnt);
+		sdp->dnl_bytes = sdp->dnl_bytes_remaining;
 		sdp->next_state = SDP_STATE_IDLE;
 
 		printf("Downloading file of size %d to 0x%08x... ",
@@ -355,6 +357,9 @@ static void sdp_rx_data_complete(struct usb_ep *ep, struct usb_request *req)
 	if (sdp->dnl_bytes_remaining)
 		return;
 
+#ifndef CONFIG_SPL_BUILD
+	env_set_hex("filesize", sdp->dnl_bytes);
+#endif
 	printf("done\n");
 
 	switch (sdp->state) {
Signature · 2 lines
Best regards,
Marek Vasut
#3 lore raw

PATCH v2 1/1 usb: gadget: f_sdp: Provide filesize env variable for downloaded images

Currently it's not possible to get filesize of downloaded images and it's impossible to automate some tasks in scripts. So this patch adds filesize environment variable with size (as hex number in bytes) of the last successfully downloaded file via sdp command.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Stefan Agner <[email protected]>

---

Changes since v1:
* added more details to the commit message

 drivers/usb/gadget/f_sdp.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/usb/gadget/f_sdp.c +5 -0
index 00a9f88..ae97ab2 100644
@@ -100,6 +100,7 @@ struct f_sdp {
 	enum sdp_state			state;
 	enum sdp_state			next_state;
 	u32				dnl_address;
+	u32				dnl_bytes;
 	u32				dnl_bytes_remaining;
 	u32				jmp_address;
 	bool				always_send_status;
@@ -276,6 +277,7 @@ static void sdp_rx_command_complete(struct usb_ep *ep, struct usb_request *req)
 		sdp->state = SDP_STATE_RX_FILE_DATA;
 		sdp->dnl_address = be32_to_cpu(cmd->addr);
 		sdp->dnl_bytes_remaining = be32_to_cpu(cmd->cnt);
+		sdp->dnl_bytes = sdp->dnl_bytes_remaining;
 		sdp->next_state = SDP_STATE_IDLE;
 
 		printf("Downloading file of size %d to 0x%08x... ",
@@ -355,6 +357,9 @@ static void sdp_rx_data_complete(struct usb_ep *ep, struct usb_request *req)
 	if (sdp->dnl_bytes_remaining)
 		return;
 
+#ifndef CONFIG_SPL_BUILD
+	env_set_hex("filesize", sdp->dnl_bytes);
+#endif
 	printf("done\n");
 
 	switch (sdp->state) {
Signature · 1 line
1.9.1
#4 lore raw

PATCH v2 1/1 usb: gadget: f_sdp: Provide filesize env variable for downloaded images

Quoted 4 lines · Petr Štetiar

Currently it's not possible to get filesize of downloaded images and it's impossible to automate some tasks in scripts. So this patch adds filesize environment variable with size (as hex number in bytes) of the last successfully downloaded file via sdp command.

Nice addition!

Looks good to me:

--

Stefan

Quoted 43 lines
Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Stefan Agner <[email protected]>

---

Changes since v1:
* added more details to the commit message

 drivers/usb/gadget/f_sdp.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/usb/gadget/f_sdp.c +5 -0
index 00a9f88..ae97ab2 100644
@@ -100,6 +100,7 @@ struct f_sdp {
 	enum sdp_state			state;
 	enum sdp_state			next_state;
 	u32				dnl_address;
+	u32				dnl_bytes;
 	u32				dnl_bytes_remaining;
 	u32				jmp_address;
 	bool				always_send_status;
@@ -276,6 +277,7 @@ static void sdp_rx_command_complete(struct usb_ep *ep, struct usb_request *req)
 		sdp->state = SDP_STATE_RX_FILE_DATA;
 		sdp->dnl_address = be32_to_cpu(cmd->addr);
 		sdp->dnl_bytes_remaining = be32_to_cpu(cmd->cnt);
+		sdp->dnl_bytes = sdp->dnl_bytes_remaining;
 		sdp->next_state = SDP_STATE_IDLE;
 
 		printf("Downloading file of size %d to 0x%08x... ",
@@ -355,6 +357,9 @@ static void sdp_rx_data_complete(struct usb_ep *ep, struct usb_request *req)
 	if (sdp->dnl_bytes_remaining)
 		return;
 
+#ifndef CONFIG_SPL_BUILD
+	env_set_hex("filesize", sdp->dnl_bytes);
+#endif
 	printf("done\n");
 
 	switch (sdp->state) {