Skip to contentSkip to conversation

imx: add macro to detect whether USB has been initialized

PATCH New Stefan Agner 4 participants 18 messages Sep 5, 2017

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

PATCH 1/2 imx: add macro to detect whether USB has been initialized

From: Stefan Agner <[email protected]>

This macro allows to detect whether the boot ROM initialized USB already (serial downloader). This is helpful to reliably detect if the system has been recovered via USB serial downloader.

---
Hi Stefano,

I noted already in my initial post that detection of serial downloader mode is somewhat brittle:
https://lists.denx.de/pipermail/u-boot/2017-August/301952.html

This came up quite fast now also for other boards:
https://www.mail-archive.com/u-boot at lists.denx.de/msg262234.html

We use this patches since quite some time. Also NXP uses this detection method to start their mfgr tools... Altough a hack, maybe we should still add it upstream?

--
Stefan

 arch/arm/include/asm/arch-mx6/imx-regs.h | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/include/asm/arch-mx6/imx-regs.h +7 -0
index 86e267087a..895ef4de83 100644
@@ -985,5 +985,12 @@ struct pwm_regs {
 	u32	pr;
 	u32	cnr;
 };
+
+/*
+ * If ROM fell back to USB recover mode, USBPH0_PWD will be clear to use USB
+ * If boot from the other mode, USB0_PWD will keep reset value
+ */
+#define	is_boot_from_usb(void) (!(readl(USB_PHY0_BASE_ADDR) & (1<<20)))
+
 #endif /* __ASSEMBLER__*/
 #endif /* __ASM_ARCH_MX6_IMX_REGS_H__ */
Signature · 1 line
2.14.1
#1 lore raw

PATCH 2/2 imx_common: detect USB serial downloader reliably

From: Stefan Agner <[email protected]>

The current mechanism using SCR/GPR registers work well when the serial downloader boot mode has been selected explicitly (either via boot mode pins or using bmode command). However, in case the system entered boot ROM due to unbootable primary boot devices (e.g. empty eMMC), the SPL fails to detect that it has been downloaded through serial loader and tries to continue booting from eMMC:
Trying to boot from MMC1
mmc_load_image_raw_sector: mmc block read error
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

The only known way to reliably detect USB serial downloader is by checking the USB PHY receiver block power state...

---

 arch/arm/mach-imx/spl.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/mach-imx/spl.c +4 -0
index 258578ac25..8e8e2f755b 100644
@@ -31,6 +31,10 @@ u32 spl_boot_device(void)
 	if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */
 		return BOOT_DEVICE_BOARD;
 
+	/* Check USB state in case we entered serial downloader as fallback */
+	if (is_boot_from_usb())
+		return BOOT_DEVICE_BOARD;
+
 	/* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */
 	switch ((reg & IMX6_BMODE_MASK) >> IMX6_BMODE_SHIFT) {
 	 /* EIM: See 8.5.1, Table 8-9 */
Signature · 1 line
2.14.1
reviewer
#2 lore raw

PATCH 2/2 imx_common: detect USB serial downloader reliably

Quoted 14 lines · Stefan Agner

From: Stefan Agner <[email protected]>

The current mechanism using SCR/GPR registers work well when the serial downloader boot mode has been selected explicitly (either via boot mode pins or using bmode command). However, in case the system entered boot ROM due to unbootable primary boot devices (e.g. empty eMMC), the SPL fails to detect that it has been downloaded through serial loader and tries to continue booting from eMMC:
Trying to boot from MMC1
mmc_load_image_raw_sector: mmc block read error
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

Quoted 5 lines

The only known way to reliably detect USB serial downloader is by checking the USB PHY receiver block power state...

This allows Serial Download Protocol to work on imx6q sabresd:

#3 lore raw

PATCH 1/2 imx: add macro to detect whether USB has been initialized

In reply to Stefan Agner

Hi Stefan,

Quoted 34 lines · Stefan Agner

From: Stefan Agner <[email protected]>

This macro allows to detect whether the boot ROM initialized USB already (serial downloader). This is helpful to reliably detect if the system has been recovered via USB serial downloader.

---
Hi Stefano,

I noted already in my initial post that detection of serial downloader mode is somewhat brittle:
https://lists.denx.de/pipermail/u-boot/2017-August/301952.html

This came up quite fast now also for other boards:
https://www.mail-archive.com/u-boot at lists.denx.de/msg262234.html

We use this patches since quite some time. Also NXP uses this detection method to start their mfgr tools... Altough a hack, maybe we should still add it upstream?

--
Stefan

  arch/arm/include/asm/arch-mx6/imx-regs.h | 7 +++++++
  1 file changed, 7 insertions(+)
arch/arm/include/asm/arch-mx6/imx-regs.h +0 -0
index 86e267087a..895ef4de83 100644

arch/arm/include/asm/arch-mx6/imx-regs.h struct pwm_regs { · line 987

Quoted 3 lines
arch/arm/include/asm/arch-mx6/imx-regs.h +0 -0
@@ -985,5 +985,12 @@ struct pwm_regs {
  	u32	pr;
  	u32	cnr;
  };

It seems as if you've already named a constant, so you might as well #define and use it (USBPH0_PWD or USB0_PWD).

The reference manual seems to call it RXPWDRX though.

arch/arm/include/asm/arch-mx6/imx-regs.h struct pwm_regs { · line 996

Quoted 10 lines
arch/arm/include/asm/arch-mx6/imx-regs.h +7 -0
+
+/*
+ * If ROM fell back to USB recover mode, USBPH0_PWD will be clear to use USB
+ * If boot from the other mode, USB0_PWD will keep reset value
+ */
+#define	is_boot_from_usb(void) (!(readl(USB_PHY0_BASE_ADDR) & (1<<20)))
+
  #endif /* __ASSEMBLER__*/
  #endif /* __ASM_ARCH_MX6_IMX_REGS_H__ */

If I'm reading your comment correctly, the RXPWDRX bit will be set (the PHY will be powered down) unless it was enabled by the Boot ROM.

Won't this also be clear if you've run 'usb start' under U-Boot?

Please advise,

Eric

#4 lore raw

PATCH 1/2 imx: add macro to detect whether USB has been initialized

Quoted 32 lines · Eric Nelson

Hi Stefan,

Quoted 29 lines · Stefan Agner

From: Stefan Agner <[email protected]>

This macro allows to detect whether the boot ROM initialized USB already (serial downloader). This is helpful to reliably detect if the system has been recovered via USB serial downloader.

---
Hi Stefano,

I noted already in my initial post that detection of serial downloader mode is somewhat brittle:
https://lists.denx.de/pipermail/u-boot/2017-August/301952.html

This came up quite fast now also for other boards:
https://www.mail-archive.com/u-boot at lists.denx.de/msg262234.html

We use this patches since quite some time. Also NXP uses this detection method to start their mfgr tools... Altough a hack, maybe we should still add it upstream?

--
Stefan

  arch/arm/include/asm/arch-mx6/imx-regs.h | 7 +++++++
  1 file changed, 7 insertions(+)
Quoted 11 lines

arch/arm/include/asm/arch-mx6/imx-regs.h struct pwm_regs { · line 987

Quoted 8 lines
arch/arm/include/asm/arch-mx6/imx-regs.h +0 -0
index 86e267087a..895ef4de83 100644
@@ -985,5 +985,12 @@ struct pwm_regs {
  	u32	pr;
  	u32	cnr;
  };

It seems as if you've already named a constant, so you might as well #define and use it (USBPH0_PWD or USB0_PWD).

Agreed.

Quoted 2 lines

The reference manual seems to call it RXPWDRX though.

I guess taking the latest naming from the manual make sense. Will update in v2.

Before I send out v2, I'd like to know from Stefano whether he agrees with the general direction of the patch.

Quoted 14 lines

arch/arm/include/asm/arch-mx6/imx-regs.h struct pwm_regs { · line 996

Quoted 11 lines
arch/arm/include/asm/arch-mx6/imx-regs.h +7 -0
+
+/*
+ * If ROM fell back to USB recover mode, USBPH0_PWD will be clear to use USB
+ * If boot from the other mode, USB0_PWD will keep reset value
+ */
+#define	is_boot_from_usb(void) (!(readl(USB_PHY0_BASE_ADDR) & (1<<20)))
+
  #endif /* __ASSEMBLER__*/
  #endif /* __ASM_ARCH_MX6_IMX_REGS_H__ */

If I'm reading your comment correctly, the RXPWDRX bit will be set (the PHY will be powered down) unless it was enabled by the Boot ROM.

Quoted 1 line

Won't this also be clear if you've run 'usb start' under U-Boot?

Yes, this only works before a USB initialization...

This should be fine for the use case I have in mind (see patch 2).

Note this idea is borrowed from NXP downstream and seems to work here:
http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/tree/arch/arm/include/asm/arch-mx7/imx-regs.h?h=imx_v2016.03_4.1.15_2.0.0_ga#n1204

--
Stefan

#5 lore raw

PATCH 1/2 imx: add macro to detect whether USB has been initialized

Hi Stefan, Eric,

Quoted 48 lines · Stefan Agner
Quoted 32 lines · Eric Nelson

Hi Stefan,

Quoted 29 lines · Stefan Agner

From: Stefan Agner <[email protected]>

This macro allows to detect whether the boot ROM initialized USB already (serial downloader). This is helpful to reliably detect if the system has been recovered via USB serial downloader.

---
Hi Stefano,

I noted already in my initial post that detection of serial downloader mode is somewhat brittle:
https://lists.denx.de/pipermail/u-boot/2017-August/301952.html

This came up quite fast now also for other boards:
https://www.mail-archive.com/u-boot at lists.denx.de/msg262234.html

We use this patches since quite some time. Also NXP uses this detection method to start their mfgr tools... Altough a hack, maybe we should still add it upstream?

--
Stefan

  arch/arm/include/asm/arch-mx6/imx-regs.h | 7 +++++++
  1 file changed, 7 insertions(+)
Quoted 11 lines

arch/arm/include/asm/arch-mx6/imx-regs.h struct pwm_regs { · line 987

Quoted 8 lines
arch/arm/include/asm/arch-mx6/imx-regs.h +0 -0
index 86e267087a..895ef4de83 100644
@@ -985,5 +985,12 @@ struct pwm_regs {
  	u32	pr;
  	u32	cnr;
  };

It seems as if you've already named a constant, so you might as well #define and use it (USBPH0_PWD or USB0_PWD).

Agreed.

Quoted 1 line
Quoted 8 lines
Quoted 1 line

The reference manual seems to call it RXPWDRX though.

I guess taking the latest naming from the manual make sense. Will update in v2.

Before I send out v2, I'd like to know from Stefano whether he agrees with the general direction of the patch.

Green light from my side :-)

Quoted 16 lines
Quoted 16 lines

arch/arm/include/asm/arch-mx6/imx-regs.h struct pwm_regs { · line 996

Quoted 13 lines
arch/arm/include/asm/arch-mx6/imx-regs.h +7 -0
+
+/*
+ * If ROM fell back to USB recover mode, USBPH0_PWD will be clear to use USB
+ * If boot from the other mode, USB0_PWD will keep reset value
+ */
+#define	is_boot_from_usb(void) (!(readl(USB_PHY0_BASE_ADDR) & (1<<20)))
+
  #endif /* __ASSEMBLER__*/
  #endif /* __ASM_ARCH_MX6_IMX_REGS_H__ */

If I'm reading your comment correctly, the RXPWDRX bit will be set (the PHY will be powered down) unless it was enabled by the Boot ROM.

Quoted 5 lines
Quoted 1 line

Won't this also be clear if you've run 'usb start' under U-Boot?

Yes, this only works before a USB initialization...

This should be fine for the use case I have in mind (see patch 2).

Agree. We want to detect just in SPL which was the (last) bootdevice and rather we cannot detect them from SCR/GPR that just reflect the configured booting device and not a fallback.

Quoted 4 lines

Note this idea is borrowed from NXP downstream and seems to work here:
http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/tree/arch/arm/include/asm/arch-mx7/imx-regs.h?h=imx_v2016.03_4.1.15_2.0.0_ga#n1204

Regards,
Stefano

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#6 lore raw

PATCH 1/2 imx: add macro to detect whether USB has been initialized

In reply to Stefan Agner

Hi Stefan,

Quoted 2 lines · Stefan Agner
Quoted 1 line · Eric Nelson

On 09/04/2017 06:21 PM, Stefan Agner wrote:

<snip>

Quoted 13 lines
Quoted 13 lines

arch/arm/include/asm/arch-mx6/imx-regs.h struct pwm_regs { · line 996

Quoted 10 lines
arch/arm/include/asm/arch-mx6/imx-regs.h +7 -0
+
+/*
+ * If ROM fell back to USB recover mode, USBPH0_PWD will be clear to use USB
+ * If boot from the other mode, USB0_PWD will keep reset value
+ */
+#define	is_boot_from_usb(void) (!(readl(USB_PHY0_BASE_ADDR) & (1<<20)))
+
   #endif /* __ASSEMBLER__*/
   #endif /* __ASM_ARCH_MX6_IMX_REGS_H__ */

If I'm reading your comment correctly, the RXPWDRX bit will be set (the PHY will be powered down) unless it was enabled by the Boot ROM.

Quoted 4 lines
Quoted 1 line

Won't this also be clear if you've run 'usb start' under U-Boot?

Yes, this only works before a USB initialization...

Based on this, I'd recommend changing the macro name to something like "is_udc_active" to reflect it's true meaning.

Quoted 5 lines

This should be fine for the use case I have in mind (see patch 2).

Note this idea is borrowed from NXP downstream and seems to work here:
http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/tree/arch/arm/include/asm/arch-mx7/imx-regs.h?h=imx_v2016.03_4.1.15_2.0.0_ga#n1204

Understood.

Using this detection mechanism in SPL (where there isn't another path for initializing the UDC) makes sense.

Regards,

Eric

reviewer
#7 lore raw

PATCH 1/2 imx: add macro to detect whether USB has been initialized

In reply to Stefan Agner

Hi Stefan,

Quoted 2 lines · Stefan Agner

Note this idea is borrowed from NXP downstream and seems to work here:
http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/tree/arch/arm/include/asm/arch-mx7/imx-regs.h?h=imx_v2016.03_4.1.15_2.0.0_ga#n1204

Please mention the NXP patch in the commit log, so that it is clear where this idea is coming from.

Thanks

reviewer
#8 lore raw

PATCH 1/2 imx: add macro to detect whether USB has been initialized

In reply to Stefan Agner

Hi Stefan,

Quoted 8 lines · Stefan Agner

From: Stefan Agner <[email protected]>

This macro allows to detect whether the boot ROM initialized USB already (serial downloader). This is helpful to reliably detect if the system has been recovered via USB serial downloader.

This allows Serial Download Protocol to work on imx6q sabresd:

Quoted 26 lines

---
Hi Stefano,

I noted already in my initial post that detection of serial downloader mode is somewhat brittle:
https://lists.denx.de/pipermail/u-boot/2017-August/301952.html

This came up quite fast now also for other boards:
https://www.mail-archive.com/u-boot at lists.denx.de/msg262234.html

We use this patches since quite some time. Also NXP uses this detection method to start their mfgr tools... Altough a hack, maybe we should still add it upstream?

--
Stefan

 arch/arm/include/asm/arch-mx6/imx-regs.h | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/include/asm/arch-mx6/imx-regs.h +0 -0
index 86e267087a..895ef4de83 100644

arch/arm/include/asm/arch-mx6/imx-regs.h struct pwm_regs { · line 993

Quoted 9 lines
arch/arm/include/asm/arch-mx6/imx-regs.h +6 -0
@@ -985,5 +985,12 @@ struct pwm_regs {
        u32     pr;
        u32     cnr;
 };
+
+/*
+ * If ROM fell back to USB recover mode, USBPH0_PWD will be clear to use USB
+ * If boot from the other mode, USB0_PWD will keep reset value
+ */
+#define        is_boot_from_usb(void) (!(readl(USB_PHY0_BASE_ADDR) & (1<<20)))

Minor nit: imx-regs.h is better suited for storing register layout definitions.

I think that arch/arm/include/asm/mach-imx/sys_proto.h would be a more appropriate location for this macro.

Also you could remove that tab between 'define' and the macro name.

#9 lore raw

PATCH 1/2 imx: add macro to detect whether USB has been initialized

Quoted 54 lines · Fabio Estevam

Hi Stefan,

Quoted 8 lines · Stefan Agner

From: Stefan Agner <[email protected]>

This macro allows to detect whether the boot ROM initialized USB already (serial downloader). This is helpful to reliably detect if the system has been recovered via USB serial downloader.

This allows Serial Download Protocol to work on imx6q sabresd:

Quoted 26 lines

---
Hi Stefano,

I noted already in my initial post that detection of serial downloader mode is somewhat brittle:
https://lists.denx.de/pipermail/u-boot/2017-August/301952.html

This came up quite fast now also for other boards:
https://www.mail-archive.com/u-boot at lists.denx.de/msg262234.html

We use this patches since quite some time. Also NXP uses this detection method to start their mfgr tools... Altough a hack, maybe we should still add it upstream?

--
Stefan

 arch/arm/include/asm/arch-mx6/imx-regs.h | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/include/asm/arch-mx6/imx-regs.h +0 -0
index 86e267087a..895ef4de83 100644

arch/arm/include/asm/arch-mx6/imx-regs.h struct pwm_regs { · line 993

Quoted 9 lines
arch/arm/include/asm/arch-mx6/imx-regs.h +6 -0
@@ -985,5 +985,12 @@ struct pwm_regs {
        u32     pr;
        u32     cnr;
 };
+
+/*
+ * If ROM fell back to USB recover mode, USBPH0_PWD will be clear to use USB
+ * If boot from the other mode, USB0_PWD will keep reset value
+ */
+#define        is_boot_from_usb(void) (!(readl(USB_PHY0_BASE_ADDR) & (1<<20)))

Minor nit: imx-regs.h is better suited for storing register layout definitions.

Quoted 2 lines

I think that arch/arm/include/asm/mach-imx/sys_proto.h would be a more appropriate location for this macro.

Makes sense, will move it.

Quoted 2 lines

Also you could remove that tab between 'define' and the macro name.

Agreed.

--
Stefan

#10 lore raw

PATCH 1/2 imx: add macro to detect whether USB has been initialized

In reply to Stefan Agner

Hi Stefan,

Quoted 15 lines · Stefan Agner

From: Stefan Agner <[email protected]>

This macro allows to detect whether the boot ROM initialized USB already (serial downloader). This is helpful to reliably detect if the system has been recovered via USB serial downloader.

---
Hi Stefano,

I noted already in my initial post that detection of serial downloader mode is somewhat brittle:
https://lists.denx.de/pipermail/u-boot/2017-August/301952.html

Quoted 5 lines

This came up quite fast now also for other boards:
https://www.mail-archive.com/u-boot at lists.denx.de/msg262234.html

We use this patches since quite some time. Also NXP uses this detection method to start their mfgr tools...

Then it seems to be an "undocumented feature" rather a hack.

Quoted 2 lines

Altough a hack,
maybe we should still add it upstream?

If we can detect at runtime as this patch is thought to do, it is really an improvement and I will glad to merge it.

Maybe we get some further info from our "insider" (Fabio, Peng). It will be very interesting to know if we can apply this to all spectrum from i.MX6, or if there is some MX6 variant where the Bootrom is doing something different.

Regards,
Stefano

Quoted 26 lines

--
Stefan

 arch/arm/include/asm/arch-mx6/imx-regs.h | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/include/asm/arch-mx6/imx-regs.h +7 -0
index 86e267087a..895ef4de83 100644
@@ -985,5 +985,12 @@ struct pwm_regs {
 	u32	pr;
 	u32	cnr;
 };
+
+/*
+ * If ROM fell back to USB recover mode, USBPH0_PWD will be clear to use USB
+ * If boot from the other mode, USB0_PWD will keep reset value
+ */
+#define	is_boot_from_usb(void) (!(readl(USB_PHY0_BASE_ADDR) & (1<<20)))
+
 #endif /* __ASSEMBLER__*/
 #endif /* __ASM_ARCH_MX6_IMX_REGS_H__ */
Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
reviewer
#11 lore raw

PATCH 1/2 imx: add macro to detect whether USB has been initialized

Hi Stefano,

Quoted 4 lines · Stefano Babic

Maybe we get some further info from our "insider" (Fabio, Peng). It will be very interesting to know if we can apply this to all spectrum from i.MX6, or if there is some MX6 variant where the Bootrom is doing something different.

Looking at NXP U-Boot code I see that this same mechanism applies not only to mx6, but it extends to mx7 and mx7ulp, so it seems like a good approach.

Thanks

#12 lore raw

PATCH 1/2 imx: add macro to detect whether USB has been initialized

Quoted 4 lines · Fabio Estevam

Hi Stefano,

On Tue, Sep 5, 2017 at 8:16 AM, Stefano Babic <[email protected]> wrote:

Quoted 8 lines
Quoted 4 lines

Maybe we get some further info from our "insider" (Fabio, Peng). It will be very interesting to know if we can apply this to all spectrum from i.MX6, or if there is some MX6 variant where the Bootrom is doing something different.

Looking at NXP U-Boot code I see that this same mechanism applies not only to mx6, but it extends to mx7 and mx7ulp, so it seems like a good approach.

i.MX 7 has a Boot Information structure which is passed from the Boot ROM, so we have a much cleaner method there.
http://git.denx.de/?p=u-boot/u-boot-imx.git;a=blob;f=arch/arm/mach-imx/mx7/soc.c;h=87bf105f385d4c12bee6d038c0ba50e2e588124c;hb=HEAD#l392

As far as I can tell this boot information structure is also accurate when the Boot ROM entered serial downloader as a fallback.

Do we have boards using SPL on i.MX 7?

--
Stefan

reviewer
#13 lore raw

PATCH 1/2 imx: add macro to detect whether USB has been initialized

Quoted 6 lines · Stefan Agner

i.MX 7 has a Boot Information structure which is passed from the Boot ROM, so we have a much cleaner method there.
http://git.denx.de/?p=u-boot/u-boot-imx.git;a=blob;f=arch/arm/mach-imx/mx7/soc.c;h=87bf105f385d4c12bee6d038c0ba50e2e588124c;hb=HEAD#l392

As far as I can tell this boot information structure is also accurate when the Boot ROM entered serial downloader as a fallback.

What I meant is that the is_boot_from_usb() macro is also defined for MX7 and MX7ULP:

http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/tree/arch/arm/include/asm/arch-mx7/imx-regs.h?h=imx_v2016.03_4.1.33_7ulp_beta#n1209

http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/tree/arch/arm/include/asm/arch-mx7ulp/imx-regs.h?h=imx_v2016.03_4.1.33_7ulp_beta#n1207

Quoted 1 line

Do we have boards using SPL on i.MX 7?

No, we don't have it currently.

#14 lore raw

PATCH 1/2 imx: add macro to detect whether USB has been initialized

Quoted 9 lines · Fabio Estevam
Quoted 6 lines · Stefan Agner

i.MX 7 has a Boot Information structure which is passed from the Boot ROM, so we have a much cleaner method there.
http://git.denx.de/?p=u-boot/u-boot-imx.git;a=blob;f=arch/arm/mach-imx/mx7/soc.c;h=87bf105f385d4c12bee6d038c0ba50e2e588124c;hb=HEAD#l392

As far as I can tell this boot information structure is also accurate when the Boot ROM entered serial downloader as a fallback.

Quoted 7 lines

What I meant is that the is_boot_from_usb() macro is also defined for MX7 and MX7ULP:

http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/tree/arch/arm/include/asm/arch-mx7/imx-regs.h?h=imx_v2016.03_4.1.33_7ulp_beta#n1209

http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/tree/arch/arm/include/asm/arch-mx7ulp/imx-regs.h?h=imx_v2016.03_4.1.33_7ulp_beta#n1207

Yes, I understand.

I am just saying, I don't see a point to use that macro over i.MX 7's Boot Information structure...

Quoted 4 lines
Quoted 2 lines

Do we have boards using SPL on i.MX 7?

No, we don't have it currently.

Ok.

--
Stefan

reviewer
#15 lore raw

PATCH 1/2 imx: add macro to detect whether USB has been initialized

Quoted 4 lines · Stefan Agner

Yes, I understand.

I am just saying, I don't see a point to use that macro over i.MX 7's Boot Information structure...

Correct, and I did not suggest this either :-)

#16 lore raw

PATCH 1/2 imx: add macro to detect whether USB has been initialized

In reply to Stefano Babic

Hi Stefano,

Quoted 17 lines · Stefano Babic

Hi Stefan,

Quoted 15 lines · Stefan Agner

From: Stefan Agner <[email protected]>

This macro allows to detect whether the boot ROM initialized USB already (serial downloader). This is helpful to reliably detect if the system has been recovered via USB serial downloader.

---
Hi Stefano,

I noted already in my initial post that detection of serial downloader mode is somewhat brittle:
https://lists.denx.de/pipermail/u-boot/2017-August/301952.html

Quoted 8 lines
Quoted 5 lines

This came up quite fast now also for other boards:
https://www.mail-archive.com/u-boot at lists.denx.de/msg262234.html

We use this patches since quite some time. Also NXP uses this detection method to start their mfgr tools...

Then it seems to be an "undocumented feature" rather a hack.

This patch only detects that the OTG PHY is active, so it's not really a hack.

The next patch uses this to infer how it happened (booted using SDP), and since I don't think there's another way for that to happen, it also seems to be reasonable.

Can you think of another way that the OTG PHY could be alive when the code is hit in SPL?

... A comment to that effect is probably in order though.

Please advise,

Eric

#17 lore raw

PATCH 1/2 imx: add macro to detect whether USB has been initialized

Hi Eric,

Quoted 23 lines · Eric Nelson

Hi Stefano,

Quoted 20 lines · Stefano Babic

Hi Stefan,

Quoted 18 lines · Stefan Agner

From: Stefan Agner <[email protected]>

This macro allows to detect whether the boot ROM initialized USB already (serial downloader). This is helpful to reliably detect if the system has been recovered via USB serial downloader.

---
Hi Stefano,

I noted already in my initial post that detection of serial downloader mode is somewhat brittle:
https://lists.denx.de/pipermail/u-boot/2017-August/301952.html

This came up quite fast now also for other boards:
https://www.mail-archive.com/u-boot at lists.denx.de/msg262234.html

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

We use this patches since quite some time. Also NXP uses this detection method to start their mfgr tools...

Then it seems to be an "undocumented feature" rather a hack.

This patch only detects that the OTG PHY is active, so it's not really a hack.

Agree.

Quoted 3 lines

The next patch uses this to infer how it happened (booted using SDP), and since I don't think there's another way for that to happen, it also seems to be reasonable.

Right. It is absolutely reasonable.

Quoted 3 lines

Can you think of another way that the OTG PHY could be alive when the code is hit in SPL?

No, I can't - nothing that makes sense ;-)

Quoted 4 lines

... A comment to that effect is probably in order though.

Please advise,

Regards,
Stefano

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================