Skip to contentSkip to conversation

usb: dwc3: gadget: Fix match_ep callback for NXP UUU tool

PATCH In review Marek Vasut 4 participants 15 messages Mar 19, 2025 – Apr 14, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: dwc3: gadget: Fix match_ep callback for NXP UUU tool

The UUU tool excepts the interrupt-in endpoint to be ep1in, otherwise it crashes. This is a result of the previous hard-coded EP setup in drivers/usb/gadget/epautoconf.c which did special-case EP allocation for SPL builds, and which was since converted to this callback, but without the special-case EP allocation in SPL part.

This reinstates the SPL part in an isolated manner, only for NXP iMX SoCs, only for SPL builds, and only for the ep1in interrupt-in endpoint.

Fixes 1918b8010c32 ("usb: dwc3: gadget: Convert epautoconf workaround to match_ep callback")

---
Cc: Alexander Sverdlin <[email protected]>
Cc: Felipe Balbi <[email protected]>
Cc: Lukasz Majewski <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Mattijs Korpershoek <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Thinh Nguyen <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
---
NOTE: This should go into master as a bugfix.

---
 drivers/usb/dwc3/gadget.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/usb/dwc3/gadget.c +18 -1
index e5a383407a2..477ecd02098 100644
@@ -1631,8 +1631,25 @@ usb_ep *dwc3_gadget_match_ep(struct usb_gadget *gadget,
 		return dwc3_find_ep(gadget, "ep1in");
 	if (usb_endpoint_is_bulk_out(desc))
 		return dwc3_find_ep(gadget, "ep2out");
-	if (usb_endpoint_is_int_in(desc))
+	if (usb_endpoint_is_int_in(desc)) {
+		/*
+		 * Special workaround for NXP UUU tool in SPL.
+		 *
+		 * The tool excepts the interrupt-in endpoint to be ep1in,
+		 * otherwise it crashes. This is a result of the previous
+		 * hard-coded EP setup in drivers/usb/gadget/epautoconf.c
+		 * which did special-case EP allocation for SPL builds,
+		 * and which was since converted to this callback, but
+		 * without the special-case EP allocation in SPL part.
+		 *
+		 * This reinstates the SPL part in an isolated manner,
+		 * only for NXP iMX SoCs, only for SPL builds, and only
+		 * for the ep1in interrupt-in endpoint.
+		 */
+		if (IS_ENABLED(CONFIG_MACH_IMX) && IS_ENABLED(CONFIG_XPL_BUILD))
+			return dwc3_find_ep(gadget, "ep1in");
 		return dwc3_find_ep(gadget, "ep3in");
+	}
 
 	return NULL;
 }
Signature · 1 line
2.47.2
Reviewed-by on v1 1/1
#1 lore raw

Hi Marek,

Thank you for the patch.

Quoted 23 lines · Marek Vasut

The UUU tool excepts the interrupt-in endpoint to be ep1in, otherwise it crashes. This is a result of the previous hard-coded EP setup in drivers/usb/gadget/epautoconf.c which did special-case EP allocation for SPL builds, and which was since converted to this callback, but without the special-case EP allocation in SPL part.

This reinstates the SPL part in an isolated manner, only for NXP iMX SoCs, only for SPL builds, and only for the ep1in interrupt-in endpoint.

Fixes 1918b8010c32 ("usb: dwc3: gadget: Convert epautoconf workaround to match_ep callback")

---
Cc: Alexander Sverdlin <[email protected]>
Cc: Felipe Balbi <[email protected]>
Cc: Lukasz Majewski <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Mattijs Korpershoek <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Thinh Nguyen <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
---
NOTE: This should go into master as a bugfix.

Quoted 3 lines
---
 drivers/usb/dwc3/gadget.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

Good catch. I'll submit this to u-boot-dfu (for master)

Quoted 34 lines
drivers/usb/dwc3/gadget.c +18 -1
index e5a383407a2..477ecd02098 100644
@@ -1631,8 +1631,25 @@ usb_ep *dwc3_gadget_match_ep(struct usb_gadget *gadget,
 		return dwc3_find_ep(gadget, "ep1in");
 	if (usb_endpoint_is_bulk_out(desc))
 		return dwc3_find_ep(gadget, "ep2out");
-	if (usb_endpoint_is_int_in(desc))
+	if (usb_endpoint_is_int_in(desc)) {
+		/*
+		 * Special workaround for NXP UUU tool in SPL.
+		 *
+		 * The tool excepts the interrupt-in endpoint to be ep1in,
+		 * otherwise it crashes. This is a result of the previous
+		 * hard-coded EP setup in drivers/usb/gadget/epautoconf.c
+		 * which did special-case EP allocation for SPL builds,
+		 * and which was since converted to this callback, but
+		 * without the special-case EP allocation in SPL part.
+		 *
+		 * This reinstates the SPL part in an isolated manner,
+		 * only for NXP iMX SoCs, only for SPL builds, and only
+		 * for the ep1in interrupt-in endpoint.
+		 */
+		if (IS_ENABLED(CONFIG_MACH_IMX) && IS_ENABLED(CONFIG_XPL_BUILD))
+			return dwc3_find_ep(gadget, "ep1in");
 		return dwc3_find_ep(gadget, "ep3in");
+	}
 
 	return NULL;
 }
Signature · 1 line
2.47.2
#2 lore raw

Hello Mattijs, Marek

Quoted 10 lines · Mattijs Korpershoek
Quoted 8 lines · Marek Vasut

The UUU tool excepts the interrupt-in endpoint to be ep1in, otherwise it crashes. This is a result of the previous hard-coded EP setup in drivers/usb/gadget/epautoconf.c which did special-case EP allocation for SPL builds, and which was since converted to this callback, but without the special-case EP allocation in SPL part.

This reinstates the SPL part in an isolated manner, only for NXP iMX SoCs, only for SPL builds, and only for the ep1in interrupt-in endpoint.

UUU can (and in our case is) used also on non-NXP i.MX platforms. What should we do?

Francesco

#3 lore raw

Hi Francesco,

Quoted 11 lines · Francesco Dolcini

Hello Mattijs, Marek

Quoted 8 lines · Mattijs Korpershoek
Quoted 6 lines · Marek Vasut

The UUU tool excepts the interrupt-in endpoint to be ep1in, otherwise it crashes. This is a result of the previous hard-coded EP setup in drivers/usb/gadget/epautoconf.c which did special-case EP allocation for SPL builds, and which was since converted to this callback, but without the special-case EP allocation in SPL part.

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

This reinstates the SPL part in an isolated manner, only for NXP iMX SoCs, only for SPL builds, and only for the ep1in interrupt-in endpoint.

UUU can (and in our case is) used also on non-NXP i.MX platforms. What should we do?

Do reproduce the problem (UUU tool crashes) on those platforms with recent U-Boot versions (v2024.10+) ?

Quoted 2 lines

Francesco

#4 lore raw
Quoted 15 lines · Mattijs Korpershoek

Hi Francesco,

Quoted 11 lines · Francesco Dolcini

Hello Mattijs, Marek

Quoted 8 lines · Mattijs Korpershoek
Quoted 6 lines · Marek Vasut

The UUU tool excepts the interrupt-in endpoint to be ep1in, otherwise it crashes. This is a result of the previous hard-coded EP setup in drivers/usb/gadget/epautoconf.c which did special-case EP allocation for SPL builds, and which was since converted to this callback, but without the special-case EP allocation in SPL part.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

This reinstates the SPL part in an isolated manner, only for NXP iMX SoCs, only for SPL builds, and only for the ep1in interrupt-in endpoint.

UUU can (and in our case is) used also on non-NXP i.MX platforms. What should we do?

Do reproduce the problem (UUU tool crashes) on those platforms with recent U-Boot versions (v2024.10+) ?

Not tested, my comment is purely based on the code and the commit message. Older U-Boot versions (up to v2024.04, included) are working fine, with UUU used with TI K3 SoCs (AM69, AM62, AM62P).

Francesco

#5 lore raw
Quoted 22 lines · Francesco Dolcini
Quoted 21 lines · Mattijs Korpershoek

Hi Francesco,

Quoted 16 lines · Francesco Dolcini

Hello Mattijs, Marek

Quoted 10 lines · Mattijs Korpershoek
Quoted 8 lines · Marek Vasut

The UUU tool excepts the interrupt-in endpoint to be ep1in, otherwise it crashes. This is a result of the previous hard-coded EP setup in drivers/usb/gadget/epautoconf.c which did special-case EP allocation for SPL builds, and which was since converted to this callback, but without the special-case EP allocation in SPL part.

This reinstates the SPL part in an isolated manner, only for NXP iMX SoCs, only for SPL builds, and only for the ep1in interrupt-in endpoint.

UUU can (and in our case is) used also on non-NXP i.MX platforms. What should we do?

Quoted 6 lines
Quoted 2 lines

Do reproduce the problem (UUU tool crashes) on those platforms with recent U-Boot versions (v2024.10+) ?

Not tested, my comment is purely based on the code and the commit message. Older U-Boot versions (up to v2024.04, included) are working fine, with UUU used with TI K3 SoCs (AM69, AM62, AM62P).

Are you talking about the NXP UUU ?

https://github.com/NXPmicro/mfgtools.git

#6 lore raw
Quoted 23 lines · Marek Vasut
Quoted 22 lines · Francesco Dolcini
Quoted 21 lines · Mattijs Korpershoek

Hi Francesco,

Quoted 16 lines · Francesco Dolcini

Hello Mattijs, Marek

Quoted 10 lines · Mattijs Korpershoek
Quoted 8 lines · Marek Vasut

The UUU tool excepts the interrupt-in endpoint to be ep1in, otherwise it crashes. This is a result of the previous hard-coded EP setup in drivers/usb/gadget/epautoconf.c which did special-case EP allocation for SPL builds, and which was since converted to this callback, but without the special-case EP allocation in SPL part.

This reinstates the SPL part in an isolated manner, only for NXP iMX SoCs, only for SPL builds, and only for the ep1in interrupt-in endpoint.

UUU can (and in our case is) used also on non-NXP i.MX platforms. What should we do?

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

Do reproduce the problem (UUU tool crashes) on those platforms with recent U-Boot versions (v2024.10+) ?

Not tested, my comment is purely based on the code and the commit message. Older U-Boot versions (up to v2024.04, included) are working fine, with UUU used with TI K3 SoCs (AM69, AM62, AM62P).

Are you talking about the NXP UUU ?

yes, it works just fine on not-NXP SoC.

Francesco

#7 lore raw
Quoted 27 lines · Francesco Dolcini
Quoted 26 lines · Marek Vasut
Quoted 25 lines · Francesco Dolcini
Quoted 23 lines · Mattijs Korpershoek

Hi Francesco,

Quoted 11 lines · Francesco Dolcini

Hello Mattijs, Marek

Quoted 8 lines · Mattijs Korpershoek
Quoted 6 lines · Marek Vasut

The UUU tool excepts the interrupt-in endpoint to be ep1in, otherwise it crashes. This is a result of the previous hard-coded EP setup in drivers/usb/gadget/epautoconf.c which did special-case EP allocation for SPL builds, and which was since converted to this callback, but without the special-case EP allocation in SPL part.

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

This reinstates the SPL part in an isolated manner, only for NXP iMX SoCs, only for SPL builds, and only for the ep1in interrupt-in endpoint.

UUU can (and in our case is) used also on non-NXP i.MX platforms. What should we do?

Do reproduce the problem (UUU tool crashes) on those platforms with recent U-Boot versions (v2024.10+) ?

Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

Not tested, my comment is purely based on the code and the commit message. Older U-Boot versions (up to v2024.04, included) are working fine, with UUU used with TI K3 SoCs (AM69, AM62, AM62P).

Are you talking about the NXP UUU ?

yes, it works just fine on not-NXP SoC.

Then please test if it still works, and if not, this patch needs to be expanded to cover TI ... or apply unconditionally in SPL (sigh).

#8 lore raw
Quoted 28 lines · Marek Vasut
Quoted 27 lines · Francesco Dolcini
Quoted 26 lines · Marek Vasut
Quoted 25 lines · Francesco Dolcini
Quoted 23 lines · Mattijs Korpershoek

Hi Francesco,

Quoted 11 lines · Francesco Dolcini

Hello Mattijs, Marek

Quoted 8 lines · Mattijs Korpershoek
Quoted 6 lines · Marek Vasut

The UUU tool excepts the interrupt-in endpoint to be ep1in, otherwise it crashes. This is a result of the previous hard-coded EP setup in drivers/usb/gadget/epautoconf.c which did special-case EP allocation for SPL builds, and which was since converted to this callback, but without the special-case EP allocation in SPL part.

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

This reinstates the SPL part in an isolated manner, only for NXP iMX SoCs, only for SPL builds, and only for the ep1in interrupt-in endpoint.

UUU can (and in our case is) used also on non-NXP i.MX platforms. What should we do?

Do reproduce the problem (UUU tool crashes) on those platforms with recent U-Boot versions (v2024.10+) ?

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

Not tested, my comment is purely based on the code and the commit message. Older U-Boot versions (up to v2024.04, included) are working fine, with UUU used with TI K3 SoCs (AM69, AM62, AM62P).

Are you talking about the NXP UUU ?

yes, it works just fine on not-NXP SoC.

Then please test if it still works, and if not, this patch needs to be expanded to cover TI ... or apply unconditionally in SPL (sigh).

I just found the time to check some logs from our CI in which we execute such a workflow. We do use UUU only from U-Boot proper, so we are not going to be affected by this SPL specific change.

However I found this error in the logs, on both a TI AM62 and an i.MX8MP

```
Starting download of 40524455 bytes
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
..........................................................................
..........................................................................
..........................................................................
..........................................................................
.............
downloading of 40524455 bytes finished
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
Starting download of 1675 bytes
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
downloading of 1675 bytes finished
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
Starting download of 82 bytes
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
downloading of 82 bytes finished
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
```

the download is successful however, despite those error messages. Any idea? Is this related to this topic?

Francesco

#9 lore raw
Quoted 67 lines · Francesco Dolcini
Quoted 28 lines · Marek Vasut
Quoted 27 lines · Francesco Dolcini
Quoted 26 lines · Marek Vasut
Quoted 25 lines · Francesco Dolcini
Quoted 23 lines · Mattijs Korpershoek

Hi Francesco,

Quoted 11 lines · Francesco Dolcini

Hello Mattijs, Marek

Quoted 8 lines · Mattijs Korpershoek
Quoted 6 lines · Marek Vasut

The UUU tool excepts the interrupt-in endpoint to be ep1in, otherwise it crashes. This is a result of the previous hard-coded EP setup in drivers/usb/gadget/epautoconf.c which did special-case EP allocation for SPL builds, and which was since converted to this callback, but without the special-case EP allocation in SPL part.

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

This reinstates the SPL part in an isolated manner, only for NXP iMX SoCs, only for SPL builds, and only for the ep1in interrupt-in endpoint.

UUU can (and in our case is) used also on non-NXP i.MX platforms. What should we do?

Do reproduce the problem (UUU tool crashes) on those platforms with recent U-Boot versions (v2024.10+) ?

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

Not tested, my comment is purely based on the code and the commit message. Older U-Boot versions (up to v2024.04, included) are working fine, with UUU used with TI K3 SoCs (AM69, AM62, AM62P).

Are you talking about the NXP UUU ?

yes, it works just fine on not-NXP SoC.

Then please test if it still works, and if not, this patch needs to be expanded to cover TI ... or apply unconditionally in SPL (sigh).

I just found the time to check some logs from our CI in which we execute such a workflow. We do use UUU only from U-Boot proper, so we are not going to be affected by this SPL specific change.

However I found this error in the logs, on both a TI AM62 and an i.MX8MP

```
Starting download of 40524455 bytes
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
..........................................................................
..........................................................................
..........................................................................
..........................................................................
.............
downloading of 40524455 bytes finished
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
Starting download of 1675 bytes
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
downloading of 1675 bytes finished
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
Starting download of 82 bytes
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
downloading of 82 bytes finished
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
```
Quoted 2 lines

the download is successful however, despite those error messages. Any idea? Is this related to this topic?

I have a feeling it is the UUU which should be fixed to not depend on the ep1-in , really.

You could however quickly try and apply the change in this patch not only to SPL, but to U-Boot on your board as well, and see if those warnings disappear.

#10 lore raw
Quoted 68 lines · Marek Vasut
Quoted 67 lines · Francesco Dolcini
Quoted 28 lines · Marek Vasut
Quoted 27 lines · Francesco Dolcini
Quoted 26 lines · Marek Vasut
Quoted 25 lines · Francesco Dolcini
Quoted 23 lines · Mattijs Korpershoek

Hi Francesco,

Quoted 11 lines · Francesco Dolcini

Hello Mattijs, Marek

Quoted 8 lines · Mattijs Korpershoek
Quoted 6 lines · Marek Vasut

The UUU tool excepts the interrupt-in endpoint to be ep1in, otherwise it crashes. This is a result of the previous hard-coded EP setup in drivers/usb/gadget/epautoconf.c which did special-case EP allocation for SPL builds, and which was since converted to this callback, but without the special-case EP allocation in SPL part.

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

This reinstates the SPL part in an isolated manner, only for NXP iMX SoCs, only for SPL builds, and only for the ep1in interrupt-in endpoint.

UUU can (and in our case is) used also on non-NXP i.MX platforms. What should we do?

Do reproduce the problem (UUU tool crashes) on those platforms with recent U-Boot versions (v2024.10+) ?

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

Not tested, my comment is purely based on the code and the commit message. Older U-Boot versions (up to v2024.04, included) are working fine, with UUU used with TI K3 SoCs (AM69, AM62, AM62P).

Are you talking about the NXP UUU ?

yes, it works just fine on not-NXP SoC.

Then please test if it still works, and if not, this patch needs to be expanded to cover TI ... or apply unconditionally in SPL (sigh).

I just found the time to check some logs from our CI in which we execute such a workflow. We do use UUU only from U-Boot proper, so we are not going to be affected by this SPL specific change.

However I found this error in the logs, on both a TI AM62 and an i.MX8MP

```
Starting download of 40524455 bytes
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
..........................................................................
..........................................................................
..........................................................................
..........................................................................
.............
downloading of 40524455 bytes finished
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
Starting download of 1675 bytes
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
downloading of 1675 bytes finished
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
Starting download of 82 bytes
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
downloading of 82 bytes finished
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
```
Quoted 8 lines
Quoted 2 lines

the download is successful however, despite those error messages. Any idea? Is this related to this topic?

I have a feeling it is the UUU which should be fixed to not depend on the ep1-in , really.

You could however quickly try and apply the change in this patch not only to SPL, but to U-Boot on your board as well, and see if those warnings disappear.

So, I did a quick test and the issue is still there.

And looking better at the error now, this is about ep1in-bulk, that is not affected by this change at all.

drivers/usb/dwc3/gadget.c +1 -17
index 477ecd020985..55b248505de5 100644
@@ -1632,23 +1632,7 @@ usb_ep *dwc3_gadget_match_ep(struct usb_gadget *gadget,
        if (usb_endpoint_is_bulk_out(desc))
                return dwc3_find_ep(gadget, "ep2out");
        if (usb_endpoint_is_int_in(desc)) {
-               /*
-                * Special workaround for NXP UUU tool in SPL.
-                *
-                * The tool excepts the interrupt-in endpoint to be ep1in,
-                * otherwise it crashes. This is a result of the previous
-                * hard-coded EP setup in drivers/usb/gadget/epautoconf.c
-                * which did special-case EP allocation for SPL builds,
-                * and which was since converted to this callback, but
-                * without the special-case EP allocation in SPL part.
-                *
-                * This reinstates the SPL part in an isolated manner,
-                * only for NXP iMX SoCs, only for SPL builds, and only
-                * for the ep1in interrupt-in endpoint.
-                */
-               if (IS_ENABLED(CONFIG_MACH_IMX) && IS_ENABLED(CONFIG_XPL_BUILD))
-                       return dwc3_find_ep(gadget, "ep1in");
-               return dwc3_find_ep(gadget, "ep3in");
+               return dwc3_find_ep(gadget, "ep1in");
        }
 
        return NULL;
#11 lore raw
Quoted 101 lines · Francesco Dolcini
Quoted 68 lines · Marek Vasut
Quoted 67 lines · Francesco Dolcini
Quoted 28 lines · Marek Vasut
Quoted 27 lines · Francesco Dolcini
Quoted 26 lines · Marek Vasut
Quoted 25 lines · Francesco Dolcini
Quoted 23 lines · Mattijs Korpershoek

Hi Francesco,

Quoted 11 lines · Francesco Dolcini

Hello Mattijs, Marek

Quoted 8 lines · Mattijs Korpershoek
Quoted 6 lines · Marek Vasut

The UUU tool excepts the interrupt-in endpoint to be ep1in, otherwise it crashes. This is a result of the previous hard-coded EP setup in drivers/usb/gadget/epautoconf.c which did special-case EP allocation for SPL builds, and which was since converted to this callback, but without the special-case EP allocation in SPL part.

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

This reinstates the SPL part in an isolated manner, only for NXP iMX SoCs, only for SPL builds, and only for the ep1in interrupt-in endpoint.

UUU can (and in our case is) used also on non-NXP i.MX platforms. What should we do?

Do reproduce the problem (UUU tool crashes) on those platforms with recent U-Boot versions (v2024.10+) ?

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

Not tested, my comment is purely based on the code and the commit message. Older U-Boot versions (up to v2024.04, included) are working fine, with UUU used with TI K3 SoCs (AM69, AM62, AM62P).

Are you talking about the NXP UUU ?

yes, it works just fine on not-NXP SoC.

Then please test if it still works, and if not, this patch needs to be expanded to cover TI ... or apply unconditionally in SPL (sigh).

I just found the time to check some logs from our CI in which we execute such a workflow. We do use UUU only from U-Boot proper, so we are not going to be affected by this SPL specific change.

However I found this error in the logs, on both a TI AM62 and an i.MX8MP

```
Starting download of 40524455 bytes
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
..........................................................................
..........................................................................
..........................................................................
..........................................................................
.............
downloading of 40524455 bytes finished
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
Starting download of 1675 bytes
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
downloading of 1675 bytes finished
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
Starting download of 82 bytes
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
downloading of 82 bytes finished
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
```
Quoted 8 lines
Quoted 2 lines

the download is successful however, despite those error messages. Any idea? Is this related to this topic?

I have a feeling it is the UUU which should be fixed to not depend on the ep1-in , really.

You could however quickly try and apply the change in this patch not only to SPL, but to U-Boot on your board as well, and see if those warnings disappear.

So, I did a quick test and the issue is still there.

And looking better at the error now, this is about ep1in-bulk, that is not affected by this change at all.

drivers/usb/dwc3/gadget.c +0 -9
index 477ecd020985..55b248505de5 100644
@@ -1632,23 +1632,7 @@ usb_ep *dwc3_gadget_match_ep(struct usb_gadget *gadget,
         if (usb_endpoint_is_bulk_out(desc))
                 return dwc3_find_ep(gadget, "ep2out");
         if (usb_endpoint_is_int_in(desc)) {
-               /*
-                * Special workaround for NXP UUU tool in SPL.
-                *
-                * The tool excepts the interrupt-in endpoint to be ep1in,
-                * otherwise it crashes. This is a result of the previous
-                * hard-coded EP setup in drivers/usb/gadget/epautoconf.c
-                * which did special-case EP allocation for SPL builds,
-                * and which was since converted to this callback, but
-                * without the special-case EP allocation in SPL part.

drivers/usb/dwc3/gadget.c usb_ep *dwc3_gadget_match_ep(struct usb_gadget *gadget, · line 1636

Quoted 10 lines
drivers/usb/dwc3/gadget.c +1 -8
-                *
-                * This reinstates the SPL part in an isolated manner,
-                * only for NXP iMX SoCs, only for SPL builds, and only
-                * for the ep1in interrupt-in endpoint.
-                */
-               if (IS_ENABLED(CONFIG_MACH_IMX) && IS_ENABLED(CONFIG_XPL_BUILD))
-                       return dwc3_find_ep(gadget, "ep1in");
-               return dwc3_find_ep(gadget, "ep3in");
+               return dwc3_find_ep(gadget, "ep1in");
         }

This should really be fixed in the UUU tool, not worked around in U-Boot. Can you try and see if the UUU tool can be fixed and not hard-code ep1 ?

#12 lore raw
Quoted 106 lines · Marek Vasut
Quoted 105 lines · Francesco Dolcini
Quoted 68 lines · Marek Vasut
Quoted 67 lines · Francesco Dolcini
Quoted 28 lines · Marek Vasut
Quoted 27 lines · Francesco Dolcini
Quoted 26 lines · Marek Vasut
Quoted 25 lines · Francesco Dolcini
Quoted 23 lines · Mattijs Korpershoek

Hi Francesco,

Quoted 11 lines · Francesco Dolcini

Hello Mattijs, Marek

Quoted 8 lines · Mattijs Korpershoek
Quoted 6 lines · Marek Vasut

The UUU tool excepts the interrupt-in endpoint to be ep1in, otherwise it crashes. This is a result of the previous hard-coded EP setup in drivers/usb/gadget/epautoconf.c which did special-case EP allocation for SPL builds, and which was since converted to this callback, but without the special-case EP allocation in SPL part.

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

This reinstates the SPL part in an isolated manner, only for NXP iMX SoCs, only for SPL builds, and only for the ep1in interrupt-in endpoint.

UUU can (and in our case is) used also on non-NXP i.MX platforms. What should we do?

Do reproduce the problem (UUU tool crashes) on those platforms with recent U-Boot versions (v2024.10+) ?

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

Not tested, my comment is purely based on the code and the commit message. Older U-Boot versions (up to v2024.04, included) are working fine, with UUU used with TI K3 SoCs (AM69, AM62, AM62P).

Are you talking about the NXP UUU ?

yes, it works just fine on not-NXP SoC.

Then please test if it still works, and if not, this patch needs to be expanded to cover TI ... or apply unconditionally in SPL (sigh).

I just found the time to check some logs from our CI in which we execute such a workflow. We do use UUU only from U-Boot proper, so we are not going to be affected by this SPL specific change.

However I found this error in the logs, on both a TI AM62 and an i.MX8MP

```
Starting download of 40524455 bytes
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
..........................................................................
..........................................................................
..........................................................................
..........................................................................
.............
downloading of 40524455 bytes finished
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
Starting download of 1675 bytes
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
downloading of 1675 bytes finished
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
Starting download of 82 bytes
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
downloading of 82 bytes finished
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
dwc3-generic-peripheral usb@31000000: request 0000000099f219c0 was not queued to ep1in-bulk
```
Quoted 8 lines
Quoted 2 lines

the download is successful however, despite those error messages. Any idea? Is this related to this topic?

I have a feeling it is the UUU which should be fixed to not depend on the ep1-in , really.

You could however quickly try and apply the change in this patch not only to SPL, but to U-Boot on your board as well, and see if those warnings disappear.

So, I did a quick test and the issue is still there.

And looking better at the error now, this is about ep1in-bulk, that is not affected by this change at all.

drivers/usb/dwc3/gadget.c +0 -13
index 477ecd020985..55b248505de5 100644
@@ -1632,23 +1632,7 @@ usb_ep *dwc3_gadget_match_ep(struct usb_gadget *gadget,
         if (usb_endpoint_is_bulk_out(desc))
                 return dwc3_find_ep(gadget, "ep2out");
         if (usb_endpoint_is_int_in(desc)) {
-               /*
-                * Special workaround for NXP UUU tool in SPL.
-                *
-                * The tool excepts the interrupt-in endpoint to be ep1in,
-                * otherwise it crashes. This is a result of the previous
-                * hard-coded EP setup in drivers/usb/gadget/epautoconf.c
-                * which did special-case EP allocation for SPL builds,
-                * and which was since converted to this callback, but
-                * without the special-case EP allocation in SPL part.
-                *
-                * This reinstates the SPL part in an isolated manner,
-                * only for NXP iMX SoCs, only for SPL builds, and only
-                * for the ep1in interrupt-in endpoint.
Quoted 8 lines

drivers/usb/dwc3/gadget.c usb_ep *dwc3_gadget_match_ep(struct usb_gadget *gadget, · line 1636

Quoted 6 lines
drivers/usb/dwc3/gadget.c +1 -4
-                */
-               if (IS_ENABLED(CONFIG_MACH_IMX) && IS_ENABLED(CONFIG_XPL_BUILD))
-                       return dwc3_find_ep(gadget, "ep1in");
-               return dwc3_find_ep(gadget, "ep3in");
+               return dwc3_find_ep(gadget, "ep1in");
         }

This should really be fixed in the UUU tool, not worked around in U-Boot. Can you try and see if the UUU tool can be fixed and not hard-code ep1 ?

I do not have time to look into that at the moment, I created an issue
https://github.com/nxp-imx/mfgtools/issues/472, hopefully NXP will have a look.

Francesco

#13 lore raw
In reply to Marek Vasut
Quoted 32 lines · Marek Vasut

The UUU tool excepts the interrupt-in endpoint to be ep1in, otherwise it crashes. This is a result of the previous hard-coded EP setup in drivers/usb/gadget/epautoconf.c which did special-case EP allocation for SPL builds, and which was since converted to this callback, but without the special-case EP allocation in SPL part.

This reinstates the SPL part in an isolated manner, only for NXP iMX SoCs, only for SPL builds, and only for the ep1in interrupt-in endpoint.

Fixes 1918b8010c32 ("usb: dwc3: gadget: Convert epautoconf workaround to match_ep callback")

---
Cc: Alexander Sverdlin <[email protected]>
Cc: Felipe Balbi <[email protected]>
Cc: Lukasz Majewski <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Mattijs Korpershoek <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Thinh Nguyen <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
---
NOTE: This should go into master as a bugfix.

---
  drivers/usb/dwc3/gadget.c | 19 ++++++++++++++++++-
  1 file changed, 18 insertions(+), 1 deletion(-)
drivers/usb/dwc3/gadget.c +0 -0
index e5a383407a2..477ecd02098 100644

drivers/usb/dwc3/gadget.c usb_ep *dwc3_gadget_match_ep(struct usb_gadget *gadget, · line 1638

Quoted 9 lines
drivers/usb/dwc3/gadget.c +5 -1
@@ -1631,8 +1631,25 @@ usb_ep *dwc3_gadget_match_ep(struct usb_gadget *gadget,
  		return dwc3_find_ep(gadget, "ep1in");
  	if (usb_endpoint_is_bulk_out(desc))
  		return dwc3_find_ep(gadget, "ep2out");
-	if (usb_endpoint_is_int_in(desc))
+	if (usb_endpoint_is_int_in(desc)) {
+		/*
+		 * Special workaround for NXP UUU tool in SPL.
+		 *
+		 * The tool excepts the interrupt-in endpoint to be ep1in,

Small nit: expects

Quoted 17 lines
drivers/usb/dwc3/gadget.c +13 -0
+		 * otherwise it crashes. This is a result of the previous
+		 * hard-coded EP setup in drivers/usb/gadget/epautoconf.c
+		 * which did special-case EP allocation for SPL builds,
+		 * and which was since converted to this callback, but
+		 * without the special-case EP allocation in SPL part.
+		 *
+		 * This reinstates the SPL part in an isolated manner,
+		 * only for NXP iMX SoCs, only for SPL builds, and only
+		 * for the ep1in interrupt-in endpoint.
+		 */
+		if (IS_ENABLED(CONFIG_MACH_IMX) && IS_ENABLED(CONFIG_XPL_BUILD))
+			return dwc3_find_ep(gadget, "ep1in");
  		return dwc3_find_ep(gadget, "ep3in");
+	}
 
  	return NULL;
  }
#14 lore raw

Hi Neil,

Quoted 28 lines · Neil Armstrong
Quoted 27 lines · Marek Vasut

The UUU tool excepts the interrupt-in endpoint to be ep1in, otherwise it crashes. This is a result of the previous hard-coded EP setup in drivers/usb/gadget/epautoconf.c which did special-case EP allocation for SPL builds, and which was since converted to this callback, but without the special-case EP allocation in SPL part.

This reinstates the SPL part in an isolated manner, only for NXP iMX SoCs, only for SPL builds, and only for the ep1in interrupt-in endpoint.

Fixes 1918b8010c32 ("usb: dwc3: gadget: Convert epautoconf workaround to match_ep callback")

---
Cc: Alexander Sverdlin <[email protected]>
Cc: Felipe Balbi <[email protected]>
Cc: Lukasz Majewski <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Mattijs Korpershoek <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Thinh Nguyen <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
---
NOTE: This should go into master as a bugfix.

---
  drivers/usb/dwc3/gadget.c | 19 ++++++++++++++++++-
  1 file changed, 18 insertions(+), 1 deletion(-)
Quoted 16 lines
Quoted 5 lines
drivers/usb/dwc3/gadget.c +0 -0
index e5a383407a2..477ecd02098 100644

drivers/usb/dwc3/gadget.c usb_ep *dwc3_gadget_match_ep(struct usb_gadget *gadget, · line 1638

Quoted 9 lines
drivers/usb/dwc3/gadget.c +5 -1
@@ -1631,8 +1631,25 @@ usb_ep *dwc3_gadget_match_ep(struct usb_gadget *gadget,
  		return dwc3_find_ep(gadget, "ep1in");
  	if (usb_endpoint_is_bulk_out(desc))
  		return dwc3_find_ep(gadget, "ep2out");
-	if (usb_endpoint_is_int_in(desc))
+	if (usb_endpoint_is_int_in(desc)) {
+		/*
+		 * Special workaround for NXP UUU tool in SPL.
+		 *
+		 * The tool excepts the interrupt-in endpoint to be ep1in,

Small nit: expects

Argh, I missed this :( The code already landed in master:
https://source.denx.de/u-boot/u-boot/-/commit/0916053ebc566245b06d0a179533f6622b6ad392

If we have to modify this again we can fixup the comment typo at the same time.

Thanks for catching it!

Quoted 18 lines
Quoted 18 lines
drivers/usb/dwc3/gadget.c +13 -0
+		 * otherwise it crashes. This is a result of the previous
+		 * hard-coded EP setup in drivers/usb/gadget/epautoconf.c
+		 * which did special-case EP allocation for SPL builds,
+		 * and which was since converted to this callback, but
+		 * without the special-case EP allocation in SPL part.
+		 *
+		 * This reinstates the SPL part in an isolated manner,
+		 * only for NXP iMX SoCs, only for SPL builds, and only
+		 * for the ep1in interrupt-in endpoint.
+		 */
+		if (IS_ENABLED(CONFIG_MACH_IMX) && IS_ENABLED(CONFIG_XPL_BUILD))
+			return dwc3_find_ep(gadget, "ep1in");
  		return dwc3_find_ep(gadget, "ep3in");
+	}
 
  	return NULL;
  }