All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] imx_common: check for Serial Downloader in spl_boot_device
@ 2015-12-04  9:02 Stefano Babic
  2015-12-04 10:51 ` Fabio Estevam
  2015-12-05 20:13 ` Eric Nelson
  0 siblings, 2 replies; 11+ messages in thread
From: Stefano Babic @ 2015-12-04  9:02 UTC (permalink / raw)
  To: u-boot

Check for bmode before reading the boot device
to check if a serial downloader is started,
and returns UART if the serial downloader is set,
letting SPL to wait for an image if
CONFIG_SPL_YMODEM_SUPPORT is set.

This allows to load again a SPL based board
with imx_usb_loader together with a tool
such as kermit.

Signed-off-by: Stefano Babic <sbabic@denx.de>
CC: Tim Harvey <tharvey@gateworks.com>
CC: Fabio Estevam <Fabio.Estevam@freescale.com>
CC: Eric Nelson <eric.nelson@boundarydevices.com>
---

Note: I know we have already discussed more complicated solution
	for adding multilple files to imx_usb_loader.
	However, fixing ymodem support for i.MX6
	was trivial and imx_usb_loader is working
	again.

 arch/arm/imx-common/spl.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/imx-common/spl.c b/arch/arm/imx-common/spl.c
index ac6e40e..28217d2 100644
--- a/arch/arm/imx-common/spl.c
+++ b/arch/arm/imx-common/spl.c
@@ -20,7 +20,14 @@ u32 spl_boot_device(void)
 	struct src *psrc = (struct src *)SRC_BASE_ADDR;
 	unsigned int gpr10_boot = readl(&psrc->gpr10) & (1 << 28);
 	unsigned reg = gpr10_boot ? readl(&psrc->gpr9) : readl(&psrc->sbmr1);
+	unsigned int bmode = readl(&psrc->sbmr2);
 
+	/*
+	 * Check for BMODE if serial downloader is enabled
+	 * BOOT_MODE - see IMX6DQRM Table 8-1
+	 */
+	if ((bmode >> 24) == 0x01) /* Serial Downloader */
+		return BOOT_DEVICE_UART;
 	/* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */
 	switch ((reg & 0x000000FF) >> 4) {
 	 /* EIM: See 8.5.1, Table 8-9 */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH] imx_common: check for Serial Downloader in spl_boot_device
  2015-12-04  9:02 [U-Boot] [PATCH] imx_common: check for Serial Downloader in spl_boot_device Stefano Babic
@ 2015-12-04 10:51 ` Fabio Estevam
  2015-12-04 11:49   ` Stefano Babic
  2015-12-05 20:13 ` Eric Nelson
  1 sibling, 1 reply; 11+ messages in thread
From: Fabio Estevam @ 2015-12-04 10:51 UTC (permalink / raw)
  To: u-boot

Hi Stefano,

On Fri, Dec 4, 2015 at 7:02 AM, Stefano Babic <sbabic@denx.de> wrote:
> Check for bmode before reading the boot device
> to check if a serial downloader is started,
> and returns UART if the serial downloader is set,
> letting SPL to wait for an image if
> CONFIG_SPL_YMODEM_SUPPORT is set.
>
> This allows to load again a SPL based board
> with imx_usb_loader together with a tool
> such as kermit.

Just curious: what were the commands you usned with imx_usb_loader to
load SPL + u-boot.img?

Thanks,

Fabio Estevam

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH] imx_common: check for Serial Downloader in spl_boot_device
  2015-12-04 10:51 ` Fabio Estevam
@ 2015-12-04 11:49   ` Stefano Babic
  2015-12-04 13:09     ` Stefan Roese
  0 siblings, 1 reply; 11+ messages in thread
From: Stefano Babic @ 2015-12-04 11:49 UTC (permalink / raw)
  To: u-boot

Hi Fabio,

On 04/12/2015 11:51, Fabio Estevam wrote:
> Hi Stefano,
> 
> On Fri, Dec 4, 2015 at 7:02 AM, Stefano Babic <sbabic@denx.de> wrote:
>> Check for bmode before reading the boot device
>> to check if a serial downloader is started,
>> and returns UART if the serial downloader is set,
>> letting SPL to wait for an image if
>> CONFIG_SPL_YMODEM_SUPPORT is set.
>>
>> This allows to load again a SPL based board
>> with imx_usb_loader together with a tool
>> such as kermit.
> 
> Just curious: what were the commands you usned with imx_usb_loader to
> load SPL + u-boot.img?
> 

I did in this way:

sudo ../imx_usb_loader/imx_usb -v SPL
kermit kermit_uboot

And kermit_uboot (a kermit script) contains the lines:

set line /dev/ttyUSB1
set speed 115200
SET CARRIER-WATCH OFF
set flow-control none
set handshake none
set prefixing all
set file type bin
set protocol ymodem
send u-boot.img
c

The last "c" command tells kermit (from ckermit package in most distro)
to switch from command line mode to communication mode, and when the
script is finished, I get U-Boot prompt in the same shell. I tested on a
custom board booting from SPI (when internal mode is used), and changing
BOOT_MODE to serial, SPL starts automatically a download with y-modem.

Best regards,
Stefano

-- 
=====================================================================
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
=====================================================================

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH] imx_common: check for Serial Downloader in spl_boot_device
  2015-12-04 11:49   ` Stefano Babic
@ 2015-12-04 13:09     ` Stefan Roese
  2015-12-04 14:30       ` Tim Harvey
  2015-12-05  7:10       ` Stefano Babic
  0 siblings, 2 replies; 11+ messages in thread
From: Stefan Roese @ 2015-12-04 13:09 UTC (permalink / raw)
  To: u-boot

Hi Stefano,

On 04.12.2015 12:49, Stefano Babic wrote:
> On 04/12/2015 11:51, Fabio Estevam wrote:
>> Hi Stefano,
>>
>> On Fri, Dec 4, 2015 at 7:02 AM, Stefano Babic <sbabic@denx.de> wrote:
>>> Check for bmode before reading the boot device
>>> to check if a serial downloader is started,
>>> and returns UART if the serial downloader is set,
>>> letting SPL to wait for an image if
>>> CONFIG_SPL_YMODEM_SUPPORT is set.
>>>
>>> This allows to load again a SPL based board
>>> with imx_usb_loader together with a tool
>>> such as kermit.
>>
>> Just curious: what were the commands you usned with imx_usb_loader to
>> load SPL + u-boot.img?
>>
>
> I did in this way:
>
> sudo ../imx_usb_loader/imx_usb -v SPL
> kermit kermit_uboot
>
> And kermit_uboot (a kermit script) contains the lines:
>
> set line /dev/ttyUSB1
> set speed 115200
> SET CARRIER-WATCH OFF
> set flow-control none
> set handshake none
> set prefixing all
> set file type bin
> set protocol ymodem
> send u-boot.img
> c
>
> The last "c" command tells kermit (from ckermit package in most distro)
> to switch from command line mode to communication mode, and when the
> script is finished, I get U-Boot prompt in the same shell. I tested on a
> custom board booting from SPI (when internal mode is used), and changing
> BOOT_MODE to serial, SPL starts automatically a download with y-modem.

Could you please add this description to some imx README in the
U-Boot source tree? I'm pretty sure this could be helpful to others
as well.

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH] imx_common: check for Serial Downloader in spl_boot_device
  2015-12-04 13:09     ` Stefan Roese
@ 2015-12-04 14:30       ` Tim Harvey
  2015-12-05  7:10       ` Stefano Babic
  1 sibling, 0 replies; 11+ messages in thread
From: Tim Harvey @ 2015-12-04 14:30 UTC (permalink / raw)
  To: u-boot

On Fri, Dec 4, 2015 at 5:09 AM, Stefan Roese <sr@denx.de> wrote:
> Hi Stefano,
>
>
> On 04.12.2015 12:49, Stefano Babic wrote:
>>
>> On 04/12/2015 11:51, Fabio Estevam wrote:
>>>
>>> Hi Stefano,
>>>
>>> On Fri, Dec 4, 2015 at 7:02 AM, Stefano Babic <sbabic@denx.de> wrote:
>>>>
>>>> Check for bmode before reading the boot device
>>>> to check if a serial downloader is started,
>>>> and returns UART if the serial downloader is set,
>>>> letting SPL to wait for an image if
>>>> CONFIG_SPL_YMODEM_SUPPORT is set.
>>>>
>>>> This allows to load again a SPL based board
>>>> with imx_usb_loader together with a tool
>>>> such as kermit.
>>>
>>>
>>> Just curious: what were the commands you usned with imx_usb_loader to
>>> load SPL + u-boot.img?
>>>
>>
>> I did in this way:
>>
>> sudo ../imx_usb_loader/imx_usb -v SPL
>> kermit kermit_uboot
>>
>> And kermit_uboot (a kermit script) contains the lines:
>>
>> set line /dev/ttyUSB1
>> set speed 115200
>> SET CARRIER-WATCH OFF
>> set flow-control none
>> set handshake none
>> set prefixing all
>> set file type bin
>> set protocol ymodem
>> send u-boot.img
>> c
>>
>> The last "c" command tells kermit (from ckermit package in most distro)
>> to switch from command line mode to communication mode, and when the
>> script is finished, I get U-Boot prompt in the same shell. I tested on a
>> custom board booting from SPI (when internal mode is used), and changing
>> BOOT_MODE to serial, SPL starts automatically a download with y-modem.
>
>
> Could you please add this description to some imx README in the
> U-Boot source tree? I'm pretty sure this could be helpful to others
> as well.
>

Stefano,

Agreed - this sounds like an excellent thing to document for IMX6 SPL!

Nice work!

Tim

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH] imx_common: check for Serial Downloader in spl_boot_device
  2015-12-04 13:09     ` Stefan Roese
  2015-12-04 14:30       ` Tim Harvey
@ 2015-12-05  7:10       ` Stefano Babic
  1 sibling, 0 replies; 11+ messages in thread
From: Stefano Babic @ 2015-12-05  7:10 UTC (permalink / raw)
  To: u-boot



On 04/12/2015 14:09, Stefan Roese wrote:
> Hi Stefano,
> 
> On 04.12.2015 12:49, Stefano Babic wrote:
>> On 04/12/2015 11:51, Fabio Estevam wrote:
>>> Hi Stefano,
>>>
>>> On Fri, Dec 4, 2015 at 7:02 AM, Stefano Babic <sbabic@denx.de> wrote:
>>>> Check for bmode before reading the boot device
>>>> to check if a serial downloader is started,
>>>> and returns UART if the serial downloader is set,
>>>> letting SPL to wait for an image if
>>>> CONFIG_SPL_YMODEM_SUPPORT is set.
>>>>
>>>> This allows to load again a SPL based board
>>>> with imx_usb_loader together with a tool
>>>> such as kermit.
>>>
>>> Just curious: what were the commands you usned with imx_usb_loader to
>>> load SPL + u-boot.img?
>>>
>>
>> I did in this way:
>>
>> sudo ../imx_usb_loader/imx_usb -v SPL
>> kermit kermit_uboot
>>
>> And kermit_uboot (a kermit script) contains the lines:
>>
>> set line /dev/ttyUSB1
>> set speed 115200
>> SET CARRIER-WATCH OFF
>> set flow-control none
>> set handshake none
>> set prefixing all
>> set file type bin
>> set protocol ymodem
>> send u-boot.img
>> c
>>
>> The last "c" command tells kermit (from ckermit package in most distro)
>> to switch from command line mode to communication mode, and when the
>> script is finished, I get U-Boot prompt in the same shell. I tested on a
>> custom board booting from SPI (when internal mode is used), and changing
>> BOOT_MODE to serial, SPL starts automatically a download with y-modem.
> 
> Could you please add this description to some imx README in the
> U-Boot source tree? I'm pretty sure this could be helpful to others
> as well.
> 


Sure, it will be done in V2.

Stefano

-- 
=====================================================================
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
=====================================================================

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH] imx_common: check for Serial Downloader in spl_boot_device
  2015-12-04  9:02 [U-Boot] [PATCH] imx_common: check for Serial Downloader in spl_boot_device Stefano Babic
  2015-12-04 10:51 ` Fabio Estevam
@ 2015-12-05 20:13 ` Eric Nelson
  2015-12-07  9:55   ` Stefano Babic
  1 sibling, 1 reply; 11+ messages in thread
From: Eric Nelson @ 2015-12-05 20:13 UTC (permalink / raw)
  To: u-boot

Hi Stefano,

On 12/04/2015 02:02 AM, Stefano Babic wrote:
> Check for bmode before reading the boot device
> to check if a serial downloader is started,
> and returns UART if the serial downloader is set,
> letting SPL to wait for an image if
> CONFIG_SPL_YMODEM_SUPPORT is set.
> 
> This allows to load again a SPL based board
> with imx_usb_loader together with a tool
> such as kermit.
> 
> Signed-off-by: Stefano Babic <sbabic@denx.de>
> CC: Tim Harvey <tharvey@gateworks.com>
> CC: Fabio Estevam <Fabio.Estevam@freescale.com>
> CC: Eric Nelson <eric.nelson@boundarydevices.com>
> ---
> 
> Note: I know we have already discussed more complicated solution
> 	for adding multilple files to imx_usb_loader.
> 	However, fixing ymodem support for i.MX6
> 	was trivial and imx_usb_loader is working
> 	again.
> 
>  arch/arm/imx-common/spl.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/arch/arm/imx-common/spl.c b/arch/arm/imx-common/spl.c
> index ac6e40e..28217d2 100644
> --- a/arch/arm/imx-common/spl.c
> +++ b/arch/arm/imx-common/spl.c
> @@ -20,7 +20,14 @@ u32 spl_boot_device(void)
>  	struct src *psrc = (struct src *)SRC_BASE_ADDR;
>  	unsigned int gpr10_boot = readl(&psrc->gpr10) & (1 << 28);
>  	unsigned reg = gpr10_boot ? readl(&psrc->gpr9) : readl(&psrc->sbmr1);
> +	unsigned int bmode = readl(&psrc->sbmr2);
>  
> +	/*
> +	 * Check for BMODE if serial downloader is enabled
> +	 * BOOT_MODE - see IMX6DQRM Table 8-1
> +	 */

I think you may need to check only bits 24 and 25 here.

> +	if ((bmode >> 24) == 0x01) /* Serial Downloader */
> +		return BOOT_DEVICE_UART;

Even though the data sheet says the high bits should be zero,
I'm seeing some other bits set on an i.MX6SL:

	=> mm 0x020d801c
	020d801c: 22000001 ? x

Separately, what's your thought about enabling this when the
system is reset through "bmode usb"?

http://git.denx.de/?p=u-boot.git;a=blob;f=arch/arm/cpu/armv7/mx6/soc.c;h=bf5ae8cdffd8b0887291249332b06f66dc644832;hb=HEAD#l389

Since the gpr9 value in this mode is 0x00000001, the switch
statement currently falls into the NOR/OneNAND block, which
is pretty useless.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH] imx_common: check for Serial Downloader in spl_boot_device
  2015-12-05 20:13 ` Eric Nelson
@ 2015-12-07  9:55   ` Stefano Babic
  2015-12-07 11:59     ` Stefano Babic
  2015-12-07 14:08     ` Eric Nelson
  0 siblings, 2 replies; 11+ messages in thread
From: Stefano Babic @ 2015-12-07  9:55 UTC (permalink / raw)
  To: u-boot

Hi Eric,

On 05/12/2015 21:13, Eric Nelson wrote:
> Hi Stefano,
> 
> On 12/04/2015 02:02 AM, Stefano Babic wrote:
>> Check for bmode before reading the boot device
>> to check if a serial downloader is started,
>> and returns UART if the serial downloader is set,
>> letting SPL to wait for an image if
>> CONFIG_SPL_YMODEM_SUPPORT is set.
>>
>> This allows to load again a SPL based board
>> with imx_usb_loader together with a tool
>> such as kermit.
>>
>> Signed-off-by: Stefano Babic <sbabic@denx.de>
>> CC: Tim Harvey <tharvey@gateworks.com>
>> CC: Fabio Estevam <Fabio.Estevam@freescale.com>
>> CC: Eric Nelson <eric.nelson@boundarydevices.com>
>> ---
>>
>> Note: I know we have already discussed more complicated solution
>> 	for adding multilple files to imx_usb_loader.
>> 	However, fixing ymodem support for i.MX6
>> 	was trivial and imx_usb_loader is working
>> 	again.
>>
>>  arch/arm/imx-common/spl.c | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/arch/arm/imx-common/spl.c b/arch/arm/imx-common/spl.c
>> index ac6e40e..28217d2 100644
>> --- a/arch/arm/imx-common/spl.c
>> +++ b/arch/arm/imx-common/spl.c
>> @@ -20,7 +20,14 @@ u32 spl_boot_device(void)
>>  	struct src *psrc = (struct src *)SRC_BASE_ADDR;
>>  	unsigned int gpr10_boot = readl(&psrc->gpr10) & (1 << 28);
>>  	unsigned reg = gpr10_boot ? readl(&psrc->gpr9) : readl(&psrc->sbmr1);
>> +	unsigned int bmode = readl(&psrc->sbmr2);
>>  
>> +	/*
>> +	 * Check for BMODE if serial downloader is enabled
>> +	 * BOOT_MODE - see IMX6DQRM Table 8-1
>> +	 */
> 
> I think you may need to check only bits 24 and 25 here.
> 
>> +	if ((bmode >> 24) == 0x01) /* Serial Downloader */
>> +		return BOOT_DEVICE_UART;
> 
> Even though the data sheet says the high bits should be zero,
> I'm seeing some other bits set on an i.MX6SL:
> 
> 	=> mm 0x020d801c
> 	020d801c: 22000001 ? x
> 

Agree - I checked on Solo / DL, and bits were zero. I fix it in V2.

> Separately, what's your thought about enabling this when the
> system is reset through "bmode usb"?
> 
> http://git.denx.de/?p=u-boot.git;a=blob;f=arch/arm/cpu/armv7/mx6/soc.c;h=bf5ae8cdffd8b0887291249332b06f66dc644832;hb=HEAD#l389
> 
> Since the gpr9 value in this mode is 0x00000001, the switch
> statement currently falls into the NOR/OneNAND block, which
> is pretty useless.

I agree with you, in fact it does not work  - but I do not see a way to
inform the ROM that next time it should run with USB as boot device.
From the fusemap, I tried to set BOOT_CFG4 as 0x40 ("Reserved for serial
ROM"), and fixing BOOT_CFG1 to 0x30, but it was only a try. In fact, we
need to change BMODE from internal to serial, and I do not see a way in
the "official" documentation.

Regards,
Stefano


-- 
=====================================================================
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
=====================================================================

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH] imx_common: check for Serial Downloader in spl_boot_device
  2015-12-07  9:55   ` Stefano Babic
@ 2015-12-07 11:59     ` Stefano Babic
  2015-12-07 14:08     ` Eric Nelson
  1 sibling, 0 replies; 11+ messages in thread
From: Stefano Babic @ 2015-12-07 11:59 UTC (permalink / raw)
  To: u-boot

Hi Eric,

On 07/12/2015 10:55, Stefano Babic wrote:

> 
> I agree with you, in fact it does not work  - but I do not see a way to
> inform the ROM that next time it should run with USB as boot device.
> From the fusemap, I tried to set BOOT_CFG4 as 0x40 ("Reserved for serial
> ROM"), and fixing BOOT_CFG1 to 0x30, but it was only a try. In fact, we
> need to change BMODE from internal to serial, and I do not see a way in
> the "official" documentation.

Ok, it was quite confused - forget it ;-).

Anyway, the fact is that when "bmode usb" is issued, the board announces
itself correctly to the USB bus, but reading SBMR2 we get again internal
mode. It is like another information to be stored, we should require a
bit in some of the GPR registers to store it.

Regards,
Stefano


-- 
=====================================================================
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
=====================================================================

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH] imx_common: check for Serial Downloader in spl_boot_device
  2015-12-07  9:55   ` Stefano Babic
  2015-12-07 11:59     ` Stefano Babic
@ 2015-12-07 14:08     ` Eric Nelson
  2015-12-07 14:24       ` Stefano Babic
  1 sibling, 1 reply; 11+ messages in thread
From: Eric Nelson @ 2015-12-07 14:08 UTC (permalink / raw)
  To: u-boot

Hi Stefano,

On 12/07/2015 02:55 AM, Stefano Babic wrote:
> Hi Eric,
> 
> On 05/12/2015 21:13, Eric Nelson wrote:
>> Hi Stefano,
>>
>> On 12/04/2015 02:02 AM, Stefano Babic wrote:
>>> Check for bmode before reading the boot device
>>> to check if a serial downloader is started,
>>> and returns UART if the serial downloader is set,
>>> letting SPL to wait for an image if
>>> CONFIG_SPL_YMODEM_SUPPORT is set.
>>>
...

>> Separately, what's your thought about enabling this when the
>> system is reset through "bmode usb"?
>>
>> http://git.denx.de/?p=u-boot.git;a=blob;f=arch/arm/cpu/armv7/mx6/soc.c;h=bf5ae8cdffd8b0887291249332b06f66dc644832;hb=HEAD#l389
>>
>> Since the gpr9 value in this mode is 0x00000001, the switch
>> statement currently falls into the NOR/OneNAND block, which
>> is pretty useless.
> 
> I agree with you, in fact it does not work  - but I do not see a way to
> inform the ROM that next time it should run with USB as boot device.
> From the fusemap, I tried to set BOOT_CFG4 as 0x40 ("Reserved for serial
> ROM"), and fixing BOOT_CFG1 to 0x30, but it was only a try. In fact, we
> need to change BMODE from internal to serial, and I do not see a way in
> the "official" documentation.
> 

It doesn't help that all of this is undocumented :), but reverse-
engineering the bmode command

The "bmode usb" command sets gpr9 to 1, which isn't used for anything
else, so something like this will work:

diff --git a/arch/arm/imx-common/spl.c b/arch/arm/imx-common/spl.c
index 28217d2..54f22e6 100644
--- a/arch/arm/imx-common/spl.c
+++ b/arch/arm/imx-common/spl.c
@@ -26,8 +26,10 @@ u32 spl_boot_device(void)
         * Check for BMODE if serial downloader is enabled
         * BOOT_MODE - see IMX6DQRM Table 8-1
         */
-       if ((bmode >> 24) == 0x01) /* Serial Downloader */
+       if (((bmode >> 24) == 0x01) /* Serial Downloader */
+           || (gpr10_boot && (1 == reg)))
                return BOOT_DEVICE_UART;

AFAIK, there isn't any other way to get a value of 1 into GPR9,
so the test is safe.

Secondarily, since the low four bits are discarded in the switch(),
this prevents an almost-always-wrong interpretation of 1 as
OneNAND/NOR (I think there are very few if any i.MX6 boards using
OneNAND or NOR for boot).

Regards,


Eric

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH] imx_common: check for Serial Downloader in spl_boot_device
  2015-12-07 14:08     ` Eric Nelson
@ 2015-12-07 14:24       ` Stefano Babic
  0 siblings, 0 replies; 11+ messages in thread
From: Stefano Babic @ 2015-12-07 14:24 UTC (permalink / raw)
  To: u-boot

Hi Eric,

On 07/12/2015 15:08, Eric Nelson wrote:

>> I agree with you, in fact it does not work  - but I do not see a way to
>> inform the ROM that next time it should run with USB as boot device.
>> From the fusemap, I tried to set BOOT_CFG4 as 0x40 ("Reserved for serial
>> ROM"), and fixing BOOT_CFG1 to 0x30, but it was only a try. In fact, we
>> need to change BMODE from internal to serial, and I do not see a way in
>> the "official" documentation.
>>
> 
> It doesn't help that all of this is undocumented :), but reverse-
> engineering the bmode command

:-)

> 
> The "bmode usb" command sets gpr9 to 1, which isn't used for anything
> else, so something like this will work:
> 
> diff --git a/arch/arm/imx-common/spl.c b/arch/arm/imx-common/spl.c
> index 28217d2..54f22e6 100644
> --- a/arch/arm/imx-common/spl.c
> +++ b/arch/arm/imx-common/spl.c
> @@ -26,8 +26,10 @@ u32 spl_boot_device(void)
>          * Check for BMODE if serial downloader is enabled
>          * BOOT_MODE - see IMX6DQRM Table 8-1
>          */
> -       if ((bmode >> 24) == 0x01) /* Serial Downloader */
> +       if (((bmode >> 24) == 0x01) /* Serial Downloader */
> +           || (gpr10_boot && (1 == reg)))
>                 return BOOT_DEVICE_UART;
> 
> AFAIK, there isn't any other way to get a value of 1 into GPR9,
> so the test is safe.
> 

This is a nice trick - I cannot see as well any combination for
obtaining a 0x01 in GPR9.

> Secondarily, since the low four bits are discarded in the switch(),
> this prevents an almost-always-wrong interpretation of 1 as
> OneNAND/NOR (I think there are very few if any i.MX6 boards using
> OneNAND or NOR for boot).

Agree.

I add your proposal in V2, thanks !

Best regards,
Stefano



-- 
=====================================================================
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
=====================================================================

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-12-07 14:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-04  9:02 [U-Boot] [PATCH] imx_common: check for Serial Downloader in spl_boot_device Stefano Babic
2015-12-04 10:51 ` Fabio Estevam
2015-12-04 11:49   ` Stefano Babic
2015-12-04 13:09     ` Stefan Roese
2015-12-04 14:30       ` Tim Harvey
2015-12-05  7:10       ` Stefano Babic
2015-12-05 20:13 ` Eric Nelson
2015-12-07  9:55   ` Stefano Babic
2015-12-07 11:59     ` Stefano Babic
2015-12-07 14:08     ` Eric Nelson
2015-12-07 14:24       ` Stefano Babic

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.