Skip to contentSkip to conversation

SAMA5D2 xplained SD/eMMC boot

U-Boot Marek Vasut 5 participants 17 messages Apr 18, 2016 – Apr 26, 2016

lore
Share & tools
lore
#0 lore raw

Hi!

I've been playing around with latest mainline u-boot on sama5d2 xplained ultra. I noticed that if I want to boot the board from
SD card (SDHCI1), the board will indeed load the SPL from it, but SPL will try to load u-boot.img from eMMC (SDHCI0) and fail, as my eMMC is blank. This is a result of hard-coding boot device to BOOT_DEVICE_MMC1 in arch/arm/mach-at91/spl.c spl_boot_device() I think.

Is there any way to discern from which SDHCI the board booted to continue loading u-boot.img from the correct one ? This would let us implement board_boot_order() and boot from correct SDHCI.

Signature · 2 lines
Best regards,
Marek Vasut
#1 lore raw

Hi Marek,

Quoted 11 lines · Marek Vasut

Hi!

I've been playing around with latest mainline u-boot on sama5d2 xplained
ultra. I noticed that if I want to boot the board from SD card (SDHCI1), the board will indeed load the SPL from it, but SPL will try to load u-boot.img from eMMC (SDHCI0) and fail, as my eMMC is blank. This is a result of hard-coding boot device to BOOT_DEVICE_MMC1 in arch/arm/mach-at91/spl.c spl_boot_device() I think.

Quoted 3 lines

Is there any way to discern from which SDHCI the board booted to continue loading u-boot.img from the correct one ? This would let us implement board_boot_order() and boot from correct SDHCI.

AFIAK it is not possible to detect the boot medium in a running device. At least was this the case when I checked it the last time (for sama5d3).

Andreas

#2 lore raw
Quoted 13 lines · Andreas Bie?mann

Hi Marek,

Quoted 10 lines · Marek Vasut

Hi!

I've been playing around with latest mainline u-boot on sama5d2 xplained ultra. I noticed that if I want to boot the board from
SD card (SDHCI1), the board will indeed load the SPL from it, but SPL will try to load u-boot.img from eMMC (SDHCI0) and fail, as my eMMC is blank. This is a result of hard-coding boot device to BOOT_DEVICE_MMC1 in arch/arm/mach-at91/spl.c spl_boot_device() I think.

Quoted 6 lines
Quoted 3 lines

Is there any way to discern from which SDHCI the board booted to continue loading u-boot.img from the correct one ? This would let us implement board_boot_order() and boot from correct SDHCI.

AFIAK it is not possible to detect the boot medium in a running device. At least was this the case when I checked it the last time (for sama5d3).

For the TI am5728 (ARM V7), there is a register, CTRL_CORE_BOOTSTRAP (0x4A0026C4) which contains the boot device selection at last power cycle. I'm new to ARM so I don't know how likely it is that the Atmel part has a similar register. Good luck.

Signature · 3 lines
Jim Chargin
AJA Video Systems                       jimc at aja.com
(530) 271-3334                          http://www.aja.com
#3 lore raw
In reply to Marek Vasut

Hi Marek,

Quoted 7 lines

-----Original Message-----
From: Marek Vasut [mailto:marek.vasut at gmail.com]
Sent: 2016?4?18? 23:30
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: SAMA5D2 xplained SD/eMMC boot

Quoted 6 lines

Hi!

I've been playing around with latest mainline u-boot on sama5d2 xplained ultra. I noticed that if I want to boot the board from SD card (SDHCI1), the board will indeed load the SPL from it, but SPL will try to load u-boot.img from eMMC (SDHCI0) and fail, as my eMMC is blank.

Yes, there is some issue to load u-boot.img. I found there is something to do on sdhci.c.

You can try this branch, it should works.

https://github.com/linux4sam/u-boot-at91/commits/u-boot-2016.03-at91

Quoted 11 lines

This is a result of hard-coding boot
device to
BOOT_DEVICE_MMC1 in arch/arm/mach-at91/spl.c spl_boot_device() I think.

Is there any way to discern from which SDHCI the board booted to continue loading u-boot.img from the correct one ? This would let us implement board_boot_order() and boot from correct SDHCI.

--
Best regards,
Marek Vasut

Best Regards,
Wenyou Yang

#4 lore raw
Quoted 16 lines · Wenyou

Hi Marek,

Quoted 7 lines

-----Original Message-----
From: Marek Vasut [mailto:marek.vasut at gmail.com]
Sent: 2016?4?18? 23:30
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: SAMA5D2 xplained SD/eMMC boot

Quoted 6 lines

Hi!

I've been playing around with latest mainline u-boot on sama5d2 xplained ultra. I noticed that if I want to boot the board from SD card (SDHCI1), the board will indeed load the SPL from it, but SPL will try to load u-boot.img from eMMC (SDHCI0) and fail, as my eMMC is blank.

Quoted 5 lines

Yes, there is some issue to load u-boot.img. I found there is something to do on sdhci.c.

You can try this branch, it should works.

https://github.com/linux4sam/u-boot-at91/commits/u-boot-2016.03-at91

I am not interested in using non-mainline stuff. Do you have any particular patch/commit which I can refer to ? I do not think this has anything to do with sdhci.c driver at all, it has to do with detecting the boot device from which SPL was started and loading u-boot.img from the same boot device instead of always using SDHCI0.

Quoted 16 lines
Quoted 11 lines

This is a result of hard-coding boot
device to
BOOT_DEVICE_MMC1 in arch/arm/mach-at91/spl.c spl_boot_device() I think.

Is there any way to discern from which SDHCI the board booted to continue loading u-boot.img from the correct one ? This would let us implement board_boot_order() and boot from correct SDHCI.

--
Best regards,
Marek Vasut

Best Regards,
Wenyou Yang

Signature · 2 lines
Best regards,
Marek Vasut
#5 lore raw

Hi Marek,

Quoted 30 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2016?4?20? 0:34
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: SAMA5D2 xplained SD/eMMC boot

Quoted 11 lines · Wenyou

Hi Marek,

Quoted 9 lines

-----Original Message-----
From: Marek Vasut [mailto:marek.vasut at gmail.com]
Sent: 2016?4?18? 23:30
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: SAMA5D2 xplained SD/eMMC boot

Hi!

Quoted 7 lines
Quoted 5 lines

I've been playing around with latest mainline u-boot on sama5d2 xplained ultra. I noticed that if I want to boot the board from SD card (SDHCI1), the board will indeed load the SPL from it, but SPL will try to load u-boot.img from eMMC
(SDHCI0) and fail, as my eMMC is blank.

Yes, there is some issue to load u-boot.img. I found there is something to do on

sdhci.c.

Quoted 3 lines

You can try this branch, it should works.

Quoted 7 lines
Quoted 1 line

https://github.com/linux4sam/u-boot-at91/commits/u-boot-2016.03-at91

I am not interested in using non-mainline stuff. Do you have any particular patch/commit which I can refer to ? I do not think this has anything to do with sdhci.c driver at all, it has to do with detecting the boot device from which SPL was started and loading u-boot.img from the same boot device instead of always using SDHCI0.

I will test the mainline code. I will let you know when I get something.

Thank you.

Quoted 15 lines
Quoted 15 lines
Quoted 13 lines

This is a result of hard-coding boot
device to
BOOT_DEVICE_MMC1 in arch/arm/mach-at91/spl.c spl_boot_device() I think.

Is there any way to discern from which SDHCI the board booted to continue loading u-boot.img from the correct one ? This would let us implement
board_boot_order() and boot from correct SDHCI.

--
Best regards,
Marek Vasut

Quoted 8 lines
Quoted 3 lines

Best Regards,
Wenyou Yang

--
Best regards,
Marek Vasut

Best Regards,
Wenyou Yang

#6 lore raw
Quoted 34 lines · Wenyou

Hi Marek,

Quoted 32 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2016?4?20? 0:34
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: SAMA5D2 xplained SD/eMMC boot

Quoted 11 lines · Wenyou

Hi Marek,

Quoted 9 lines

-----Original Message-----
From: Marek Vasut [mailto:marek.vasut at gmail.com]
Sent: 2016?4?18? 23:30
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: SAMA5D2 xplained SD/eMMC boot

Hi!

Quoted 7 lines
Quoted 5 lines

I've been playing around with latest mainline u-boot on sama5d2 xplained ultra. I noticed that if I want to boot the board from SD card (SDHCI1), the board will indeed load the SPL from it, but SPL will try to load u-boot.img from eMMC
(SDHCI0) and fail, as my eMMC is blank.

Yes, there is some issue to load u-boot.img. I found there is something to do on

sdhci.c.

Quoted 4 lines

You can try this branch, it should works.

https://github.com/linux4sam/u-boot-at91/commits/u-boot-2016.03-at91

Quoted 7 lines
Quoted 5 lines

I am not interested in using non-mainline stuff. Do you have any particular patch/commit which I can refer to ? I do not think this has anything to do with sdhci.c driver at all, it has to do with detecting the boot device from which SPL was started and loading u-boot.img from the same boot device instead of always using SDHCI0.

I will test the mainline code. I will let you know when I get something.

OK.

Does the SoC have any sort of register which lists the current boot device ?

Quoted 30 lines

Thank you.

Quoted 15 lines
Quoted 15 lines
Quoted 13 lines

This is a result of hard-coding boot
device to
BOOT_DEVICE_MMC1 in arch/arm/mach-at91/spl.c spl_boot_device() I think.

Is there any way to discern from which SDHCI the board booted to continue loading u-boot.img from the correct one ? This would let us implement
board_boot_order() and boot from correct SDHCI.

--
Best regards,
Marek Vasut

Quoted 8 lines
Quoted 3 lines

Best Regards,
Wenyou Yang

--
Best regards,
Marek Vasut

Best Regards,
Wenyou Yang

Signature · 2 lines
Best regards,
Marek Vasut
#7 lore raw

Hi Marek,

Quoted 49 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2016?4?20? 17:37
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: SAMA5D2 xplained SD/eMMC boot

Quoted 41 lines · Wenyou

Hi Marek,

Quoted 38 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2016?4?20? 0:34
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: SAMA5D2 xplained SD/eMMC boot

Quoted 11 lines · Wenyou

Hi Marek,

Quoted 9 lines

-----Original Message-----
From: Marek Vasut [mailto:marek.vasut at gmail.com]
Sent: 2016?4?18? 23:30
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: SAMA5D2 xplained SD/eMMC boot

Hi!

Quoted 8 lines
Quoted 5 lines

I've been playing around with latest mainline u-boot on sama5d2 xplained ultra. I noticed that if I want to boot the board from SD card (SDHCI1), the board will indeed load the SPL from it, but SPL will try to load u-boot.img from eMMC
(SDHCI0) and fail, as my eMMC is blank.

Yes, there is some issue to load u-boot.img. I found there is something to do on

sdhci.c.

Quoted 4 lines

You can try this branch, it should works.

https://github.com/linux4sam/u-boot-at91/commits/u-boot-2016.03-at91

I am not interested in using non-mainline stuff. Do you have any particular patch/commit which I can refer to ? I do not think this has anything to do with sdhci.c driver at all, it has to do with detecting the boot device from which SPL was started and loading u-boot.img from the same boot device instead of always using SDHCI0.

Quoted 5 lines
Quoted 1 line

I will test the mainline code. I will let you know when I get something.

OK.

Does the SoC have any sort of register which lists the current boot device ?

In this SoC, there is not register to list the current boot device.

Quoted 28 lines
Quoted 6 lines

Thank you.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

This is a result of hard-coding boot device to BOOT_DEVICE_MMC1 in arch/arm/mach-at91/spl.c spl_boot_device() I

think.

Quoted 21 lines
Quoted 19 lines
Quoted 6 lines
Quoted 6 lines

Is there any way to discern from which SDHCI the board booted to continue loading u-boot.img from the correct one ? This would let us implement
board_boot_order() and boot from correct SDHCI.

Quoted 8 lines
Quoted 3 lines

--
Best regards,
Marek Vasut

Best Regards,
Wenyou Yang

--
Best regards,
Marek Vasut

Quoted 8 lines
Quoted 3 lines

Best Regards,
Wenyou Yang

--
Best regards,
Marek Vasut

Best Regards,
Wenyou Yang

#8 lore raw
Quoted 1 line · Wenyou

Hi Marek,

Hi!

Quoted 6 lines
Quoted 6 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2016?4?20? 17:37
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: SAMA5D2 xplained SD/eMMC boot

Can you fix your mailer so it doesn't insert this crap into each and every message ? Pretty please ?

Quoted 42 lines
Quoted 42 lines · Wenyou
Quoted 41 lines

Hi Marek,

Quoted 38 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2016?4?20? 0:34
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: SAMA5D2 xplained SD/eMMC boot

Quoted 11 lines · Wenyou

Hi Marek,

Quoted 9 lines

-----Original Message-----
From: Marek Vasut [mailto:marek.vasut at gmail.com]
Sent: 2016?4?18? 23:30
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: SAMA5D2 xplained SD/eMMC boot

Hi!

Quoted 8 lines
Quoted 5 lines

I've been playing around with latest mainline u-boot on sama5d2 xplained ultra. I noticed that if I want to boot the board from SD card (SDHCI1), the board will indeed load the SPL from it, but SPL will try to load u-boot.img from eMMC
(SDHCI0) and fail, as my eMMC is blank.

Yes, there is some issue to load u-boot.img. I found there is something to do on

sdhci.c.

Quoted 4 lines

You can try this branch, it should works.

https://github.com/linux4sam/u-boot-at91/commits/u-boot-2016.03-at91

I am not interested in using non-mainline stuff. Do you have any particular patch/commit which I can refer to ? I do not think this has anything to do with sdhci.c driver at all, it has to do with detecting the boot device from which SPL was started and loading u-boot.img from the same boot device instead of always using SDHCI0.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

I will test the mainline code. I will let you know when I get something.

OK.

Does the SoC have any sort of register which lists the current boot device ?

In this SoC, there is not register to list the current boot device.

And thus, it is not possible to detect at runtime from which device the SoC booted and thus load u-boot.img from the same device. Correct ?

You should add such register, it's a few lines of HDL ...

[...]
Best regards,
Marek Vasut

#9 lore raw

Hi,

Quoted 67 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2016?4?21? 10:41
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: SAMA5D2 xplained SD/eMMC boot

Quoted 1 line · Wenyou

Hi Marek,

Hi!

Quoted 6 lines
Quoted 6 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2016?4?20? 17:37
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: SAMA5D2 xplained SD/eMMC boot

Can you fix your mailer so it doesn't insert this crap into each and every message ? Pretty please ?

Quoted 45 lines
Quoted 45 lines · Wenyou
Quoted 43 lines

Hi Marek,

Quoted 31 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2016?4?20? 0:34
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: SAMA5D2 xplained SD/eMMC boot

Quoted 11 lines · Wenyou

Hi Marek,

Quoted 9 lines

-----Original Message-----
From: Marek Vasut [mailto:marek.vasut at gmail.com]
Sent: 2016?4?18? 23:30
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: SAMA5D2 xplained SD/eMMC boot

Hi!

Quoted 8 lines
Quoted 5 lines

I've been playing around with latest mainline u-boot on sama5d2 xplained ultra. I noticed that if I want to boot the board from SD card (SDHCI1), the board will indeed load the SPL from it, but SPL will try to load u-boot.img from eMMC
(SDHCI0) and fail, as my eMMC is blank.

Yes, there is some issue to load u-boot.img. I found there is something to do on

sdhci.c.

Quoted 3 lines

You can try this branch, it should works.

Quoted 8 lines
Quoted 2 lines

https://github.com/linux4sam/u-boot-at91/commits/u-boot-2016.03-at
91

I am not interested in using non-mainline stuff. Do you have any particular patch/commit which I can refer to ? I do not think this has anything to do with sdhci.c driver at all, it has to do with detecting the boot device from which SPL was started and loading u-boot.img from the same boot device instead of always using SDHCI0.

I will test the mainline code. I will let you know when I get something.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

OK.

Does the SoC have any sort of register which lists the current boot device ?

In this SoC, there is not register to list the current boot device.

And thus, it is not possible to detect at runtime from which device the SoC booted and thus load u-boot.img from the same device. Correct ?

Yes,

Quoted 2 lines

You should add such register, it's a few lines of HDL ...

Good suggestion.

Recorded.

Thank you.

Quoted 4 lines

[...]
Best regards,
Marek Vasut

Best Regards
Wenyou Yang

#10 lore raw
Quoted 1 line · Wenyou

Hi,

Hi!

[...]
pile of unnecessary email headers redacted.
[...]

Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 17 lines
Quoted 17 lines
Quoted 10 lines
Quoted 7 lines

Hi!

I've been playing around with latest mainline u-boot on sama5d2 xplained ultra. I noticed that if I want to boot the board from SD card (SDHCI1), the board will indeed load the SPL from it, but SPL will try to load u-boot.img from eMMC
(SDHCI0) and fail, as my eMMC is blank.

Yes, there is some issue to load u-boot.img. I found there is something to do on

sdhci.c.

Quoted 5 lines

You can try this branch, it should works.

https://github.com/linux4sam/u-boot-at91/commits/u-boot-2016.03-at
91

Quoted 7 lines
Quoted 5 lines

I am not interested in using non-mainline stuff. Do you have any particular patch/commit which I can refer to ? I do not think this has anything to do with sdhci.c driver at all, it has to do with detecting the boot device from which SPL was started and loading u-boot.img from the same boot device instead of always using SDHCI0.

I will test the mainline code. I will let you know when I get something.

OK.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Does the SoC have any sort of register which lists the current boot device ?

In this SoC, there is not register to list the current boot device.

And thus, it is not possible to detect at runtime from which device the SoC booted and thus load u-boot.img from the same device. Correct ?

Yes,

Ha, thanks for confirming.

[...]

Signature · 2 lines
Best regards,
Marek Vasut
#11 lore raw

Hi Marek,

Quoted 47 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2016?4?21? 10:59
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: SAMA5D2 xplained SD/eMMC boot

Quoted 1 line · Wenyou

Hi,

Hi!

[...]
pile of unnecessary email headers redacted.
[...]

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 10 lines
Quoted 7 lines

Hi!

I've been playing around with latest mainline u-boot on sama5d2 xplained ultra. I noticed that if I want to boot the board from SD card (SDHCI1), the board will indeed load the SPL from it, but SPL will try to load u-boot.img from eMMC (SDHCI0) and fail, as my eMMC is blank.

Yes, there is some issue to load u-boot.img. I found there is something to do on

sdhci.c.

Quoted 6 lines

You can try this branch, it should works.

https://github.com/linux4sam/u-boot-at91/commits/u-boot-2016.03-
at
91

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

I am not interested in using non-mainline stuff. Do you have any particular patch/commit which I can refer to ? I do not think this has anything to do with sdhci.c driver at all, it has to do with detecting the boot device from which SPL was started and loading u-boot.img from the same boot device instead of always using

SDHCI0.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

I will test the mainline code. I will let you know when I get something.

OK.

Does the SoC have any sort of register which lists the current boot device ?

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

In this SoC, there is not register to list the current boot device.

And thus, it is not possible to detect at runtime from which device the SoC booted and thus load u-boot.img from the same device. Correct ?

Yes,

Ha, thanks for confirming.

Sorry, can I correct what I said yesterday? There is a register to list the boot information exported by ROMCode.

The boot information is stored in R4 register when the ROMCode jumps to the bootstrap.

Here is the contents definitions R4 on the SAMA5D2 (improved compared to old MPUs to take care of IOSet features).

/* bootFrom ID Definitions */
#define BOOT_FROM_KEY (0xBAu << 24)

#define BOOT_FROM_SPI               	(0x0u << 0)
#define BOOT_FROM_MCI               	(0x1u << 0)
#define BOOT_FROM_SMC               	(0x2u << 0)
#define BOOT_FROM_TWI               	(0x3u << 0)

#define BOOT_FROM_QSPI (0x4u << 0)

/* ID number of the IP from the data sheet */

#define BOOT_FROM_ID0               (0x0u << 4)
#define BOOT_FROM_ID1               (0x1u << 4)
#define BOOT_FROM_ID2               (0x2u << 4)
#define BOOT_FROM_ID3               (0x3u << 4)
#define BOOT_FROM_ID4               (0x4u << 4)
#define BOOT_FROM_ID_Pos            	4
#define BOOT_FROM_ID_Msk            	(0xfu << BOOT_FROM_ID_Pos)
#define BOOT_FROM_ID(value)         	((BOOT_FROM_ID_Msk & ((value) << BOOT_FROM_ID_Pos)))
#define BOOT_FROM_TYPE_SD_OR_AT25   	(0x0u << 8)
#define BOOT_FROM_TYPE_MMC_OR_AT45  (0x1u << 8)
#define BOOT_FROM_TYPE_EMMC         	(0x2u << 8)

/* QSPI serial flashes */

#define BOOT_FROM_TYPE_SPANSION     	(0x0u << 8)
#define BOOT_FROM_TYPE_MICRON       	(0x1u << 8)
#define BOOT_FROM_TYPE_MACRONIX     	(0x2u << 8)

/* Chip Select or (MCI) Slot identifier used in code by the IP. */

#define BOOT_FROM_CS0               (0x0u << 12) // Slot A
#define BOOT_FROM_CS1               (0x1u << 12) // Slot B
#define BOOT_FROM_CS2               (0x2u << 12) // Slot C
#define BOOT_FROM_CS3               (0x3u << 12) // Slot D
#define BOOT_FROM_CS4               (0x4u << 12)
#define BOOT_FROM_CS_Pos            12
#define BOOT_FROM_CS_Msk            (0xfu << BOOT_FROM_CS_Pos)
#define BOOT_FROM_CS(value)         ((BOOT_FROM_CS_Msk & ((value) << BOOT_FROM_CS_Pos)))

#define BOOT_FROM_IOSET_Pos 16
#define BOOT_FROM_IOSET_Msk (0x3u << BOOT_FROM_IOSET_Pos)
#define BOOT_FROM_IOSET(value) ((BOOT_FROM_IOSET_Msk & ((value) << BOOT_FROM_IOSET_Pos)))>>

Quoted 5 lines

[...]

--
Best regards,
Marek Vasut

Sorry for incorrect information before.

Best Regards,
Wenyou Yang

#12 lore raw
Quoted 1 line · Wenyou

Hi Marek,

Hi!

Quoted 49 lines
Quoted 49 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2016?4?21? 10:59
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: SAMA5D2 xplained SD/eMMC boot

Quoted 1 line · Wenyou

Hi,

Hi!

[...]
pile of unnecessary email headers redacted.
[...]

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 10 lines
Quoted 7 lines

Hi!

I've been playing around with latest mainline u-boot on sama5d2 xplained ultra. I noticed that if I want to boot the board from SD card (SDHCI1), the board will indeed load the SPL from it, but SPL will try to load u-boot.img from eMMC (SDHCI0) and fail, as my eMMC is blank.

Yes, there is some issue to load u-boot.img. I found there is something to do on

sdhci.c.

Quoted 6 lines

You can try this branch, it should works.

https://github.com/linux4sam/u-boot-at91/commits/u-boot-2016.03-
at
91

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

I am not interested in using non-mainline stuff. Do you have any particular patch/commit which I can refer to ? I do not think this has anything to do with sdhci.c driver at all, it has to do with detecting the boot device from which SPL was started and loading u-boot.img from the same boot device instead of always using

SDHCI0.

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

I will test the mainline code. I will let you know when I get something.

OK.

Does the SoC have any sort of register which lists the current boot device ?

In this SoC, there is not register to list the current boot device.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

And thus, it is not possible to detect at runtime from which device the SoC booted and thus load u-boot.img from the same device. Correct ?

Yes,

Ha, thanks for confirming.

Sorry, can I correct what I said yesterday?

What if I said "no" ? :-)

Quoted 3 lines

There is a register to list the boot information exported by ROMCode.

The boot information is stored in R4 register when the ROMCode jumps to the bootstrap.

Ha, so the U-Boot SPL can save the r4 register early in the boot and extract the boot device from it. That's neat. Thanks!

Quoted 1 line

Here is the contents definitions R4 on the SAMA5D2 (improved compared to old MPUs to take care of IOSet features).

Is this stuff somewhere in the SAMA5Dx datasheet ? It'd be nice to know/have this information for other SAMA5Dx too (d3 and d4).

Quoted 45 lines

/* bootFrom ID Definitions */
#define BOOT_FROM_KEY (0xBAu << 24)

#define BOOT_FROM_SPI               	(0x0u << 0)
#define BOOT_FROM_MCI               	(0x1u << 0)
#define BOOT_FROM_SMC               	(0x2u << 0)
#define BOOT_FROM_TWI               	(0x3u << 0)

#define BOOT_FROM_QSPI (0x4u << 0)

/* ID number of the IP from the data sheet */

#define BOOT_FROM_ID0               (0x0u << 4)
#define BOOT_FROM_ID1               (0x1u << 4)
#define BOOT_FROM_ID2               (0x2u << 4)
#define BOOT_FROM_ID3               (0x3u << 4)
#define BOOT_FROM_ID4               (0x4u << 4)
#define BOOT_FROM_ID_Pos            	4
#define BOOT_FROM_ID_Msk            	(0xfu << BOOT_FROM_ID_Pos)
#define BOOT_FROM_ID(value)         	((BOOT_FROM_ID_Msk & ((value) << BOOT_FROM_ID_Pos)))
#define BOOT_FROM_TYPE_SD_OR_AT25   	(0x0u << 8)
#define BOOT_FROM_TYPE_MMC_OR_AT45  (0x1u << 8)
#define BOOT_FROM_TYPE_EMMC         	(0x2u << 8)

/* QSPI serial flashes */

#define BOOT_FROM_TYPE_SPANSION     	(0x0u << 8)
#define BOOT_FROM_TYPE_MICRON       	(0x1u << 8)
#define BOOT_FROM_TYPE_MACRONIX     	(0x2u << 8)

/* Chip Select or (MCI) Slot identifier used in code by the IP. */

#define BOOT_FROM_CS0               (0x0u << 12) // Slot A
#define BOOT_FROM_CS1               (0x1u << 12) // Slot B
#define BOOT_FROM_CS2               (0x2u << 12) // Slot C
#define BOOT_FROM_CS3               (0x3u << 12) // Slot D
#define BOOT_FROM_CS4               (0x4u << 12)
#define BOOT_FROM_CS_Pos            12
#define BOOT_FROM_CS_Msk            (0xfu << BOOT_FROM_CS_Pos)
#define BOOT_FROM_CS(value)         ((BOOT_FROM_CS_Msk & ((value) << BOOT_FROM_CS_Pos)))

#define BOOT_FROM_IOSET_Pos 16
#define BOOT_FROM_IOSET_Msk (0x3u << BOOT_FROM_IOSET_Pos)
#define BOOT_FROM_IOSET(value) ((BOOT_FROM_IOSET_Msk & ((value) << BOOT_FROM_IOSET_Pos)))>>

Quoted 7 lines
Quoted 5 lines

[...]

--
Best regards,
Marek Vasut

Sorry for incorrect information before.

No problem, thanks for the update!

Quoted 3 lines

Best Regards,
Wenyou Yang

Signature · 2 lines
Best regards,
Marek Vasut
#13 lore raw

Hi Marek,

Quoted 80 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2016?4?22? 20:18
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: SAMA5D2 xplained SD/eMMC boot

Quoted 1 line · Wenyou

Hi Marek,

Hi!

Quoted 41 lines
Quoted 41 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2016?4?21? 10:59
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: SAMA5D2 xplained SD/eMMC boot

Quoted 1 line · Wenyou

Hi,

Hi!

[...]
pile of unnecessary email headers redacted.
[...]

Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 10 lines
Quoted 7 lines

Hi!

I've been playing around with latest mainline u-boot on sama5d2 xplained ultra. I noticed that if I want to boot the board from SD card (SDHCI1), the board will indeed load the SPL from it, but SPL will try to load u-boot.img from eMMC (SDHCI0) and fail, as my eMMC is blank.

Yes, there is some issue to load u-boot.img. I found there is something to do on

sdhci.c.

Quoted 7 lines

You can try this branch, it should works.

https://github.com/linux4sam/u-boot-at91/commits/u-boot-2016.0
3-
at
91

I am not interested in using non-mainline stuff. Do you have any particular patch/commit which I can refer to ? I do not think this has anything to do with sdhci.c driver at all, it has to do with detecting the boot device from which SPL was started and loading u-boot.img from the same boot device instead of always using

Quoted 7 lines
Quoted 7 lines

SDHCI0.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

I will test the mainline code. I will let you know when I get something.

OK.

Does the SoC have any sort of register which lists the current boot

device ?

Quoted 11 lines
Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

In this SoC, there is not register to list the current boot device.

And thus, it is not possible to detect at runtime from which device the SoC booted and thus load u-boot.img from the same device. Correct ?

Yes,

Ha, thanks for confirming.

Sorry, can I correct what I said yesterday?

What if I said "no" ? :-)

Quoted 3 lines

There is a register to list the boot information exported by ROMCode.

The boot information is stored in R4 register when the ROMCode jumps to the

bootstrap.

Quoted 8 lines

Ha, so the U-Boot SPL can save the r4 register early in the boot and extract the boot device from it. That's neat. Thanks!

Quoted 1 line

Here is the contents definitions R4 on the SAMA5D2 (improved compared to old

MPUs to take care of IOSet features).

Is this stuff somewhere in the SAMA5Dx datasheet ? It'd be nice to know/have this information for other SAMA5Dx too (d3 and d4).

It seems it is not included in the in the SAMA5Dx datasheet.

This feature is available since AT91SAM9G45, inclusive d3 and d4.

Quoted 59 lines
Quoted 17 lines

/* bootFrom ID Definitions */
#define BOOT_FROM_KEY (0xBAu << 24)

#define BOOT_FROM_SPI               	(0x0u << 0)
#define BOOT_FROM_MCI               	(0x1u << 0)
#define BOOT_FROM_SMC               	(0x2u << 0)
#define BOOT_FROM_TWI               	(0x3u << 0)

#define BOOT_FROM_QSPI (0x4u << 0)

/* ID number of the IP from the data sheet */

#define BOOT_FROM_ID0               (0x0u << 4)
#define BOOT_FROM_ID1               (0x1u << 4)
#define BOOT_FROM_ID2               (0x2u << 4)
#define BOOT_FROM_ID3               (0x3u << 4)
#define BOOT_FROM_ID4               (0x4u << 4)
Quoted 3 lines
#define BOOT_FROM_ID_Pos            	4
#define BOOT_FROM_ID_Msk            	(0xfu << BOOT_FROM_ID_Pos)
#define BOOT_FROM_ID(value)         	((BOOT_FROM_ID_Msk &

((value) << BOOT_FROM_ID_Pos)))

Quoted 17 lines
#define BOOT_FROM_TYPE_SD_OR_AT25   	(0x0u << 8)
#define BOOT_FROM_TYPE_MMC_OR_AT45  (0x1u << 8)
#define BOOT_FROM_TYPE_EMMC         	(0x2u << 8)

/* QSPI serial flashes */

#define BOOT_FROM_TYPE_SPANSION     	(0x0u << 8)
#define BOOT_FROM_TYPE_MICRON       	(0x1u << 8)
#define BOOT_FROM_TYPE_MACRONIX     	(0x2u << 8)

/* Chip Select or (MCI) Slot identifier used in code by the IP. */

#define BOOT_FROM_CS0               (0x0u << 12) // Slot A
#define BOOT_FROM_CS1               (0x1u << 12) // Slot B
#define BOOT_FROM_CS2               (0x2u << 12) // Slot C
#define BOOT_FROM_CS3               (0x3u << 12) // Slot D
#define BOOT_FROM_CS4               (0x4u << 12)
Quoted 3 lines
#define BOOT_FROM_CS_Pos            12
#define BOOT_FROM_CS_Msk            (0xfu << BOOT_FROM_CS_Pos)
#define BOOT_FROM_CS(value)         ((BOOT_FROM_CS_Msk & ((value) <<

BOOT_FROM_CS_Pos)))

Quoted 4 lines

#define BOOT_FROM_IOSET_Pos 16
#define BOOT_FROM_IOSET_Msk (0x3u << BOOT_FROM_IOSET_Pos)
#define BOOT_FROM_IOSET(value) ((BOOT_FROM_IOSET_Msk &

((value) << BOOT_FROM_IOSET_Pos)))>>

Quoted 9 lines
Quoted 7 lines

[...]

--
Best regards,
Marek Vasut

Sorry for incorrect information before.

No problem, thanks for the update!

Quoted 8 lines
Quoted 3 lines

Best Regards,
Wenyou Yang

--
Best regards,
Marek Vasut

Best Regards,
Wenyou Yang

#14 lore raw
Quoted 85 lines · Wenyou

Hi Marek,

Quoted 83 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2016?4?22? 20:18
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: SAMA5D2 xplained SD/eMMC boot

Quoted 1 line · Wenyou

Hi Marek,

Hi!

Quoted 41 lines
Quoted 41 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2016?4?21? 10:59
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: SAMA5D2 xplained SD/eMMC boot

Quoted 1 line · Wenyou

Hi,

Hi!

[...]
pile of unnecessary email headers redacted.
[...]

Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 10 lines
Quoted 7 lines

Hi!

I've been playing around with latest mainline u-boot on sama5d2 xplained ultra. I noticed that if I want to boot the board from SD card (SDHCI1), the board will indeed load the SPL from it, but SPL will try to load u-boot.img from eMMC (SDHCI0) and fail, as my eMMC is blank.

Yes, there is some issue to load u-boot.img. I found there is something to do on

sdhci.c.

Quoted 7 lines

You can try this branch, it should works.

https://github.com/linux4sam/u-boot-at91/commits/u-boot-2016.0
3-
at
91

I am not interested in using non-mainline stuff. Do you have any particular patch/commit which I can refer to ? I do not think this has anything to do with sdhci.c driver at all, it has to do with detecting the boot device from which SPL was started and loading u-boot.img from the same boot device instead of always using

Quoted 7 lines
Quoted 7 lines

SDHCI0.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

I will test the mainline code. I will let you know when I get something.

OK.

Does the SoC have any sort of register which lists the current boot

device ?

Quoted 11 lines
Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

In this SoC, there is not register to list the current boot device.

And thus, it is not possible to detect at runtime from which device the SoC booted and thus load u-boot.img from the same device. Correct ?

Yes,

Ha, thanks for confirming.

Sorry, can I correct what I said yesterday?

What if I said "no" ? :-)

Quoted 3 lines

There is a register to list the boot information exported by ROMCode.

The boot information is stored in R4 register when the ROMCode jumps to the

bootstrap.

Ha, so the U-Boot SPL can save the r4 register early in the boot and extract the boot device from it. That's neat. Thanks!

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Here is the contents definitions R4 on the SAMA5D2 (improved compared to old

MPUs to take care of IOSet features).

Is this stuff somewhere in the SAMA5Dx datasheet ? It'd be nice to know/have this information for other SAMA5Dx too (d3 and d4).

It seems it is not included in the in the SAMA5Dx datasheet.

So where did you get these numbers from ?

Quoted 1 line

This feature is available since AT91SAM9G45, inclusive d3 and d4.

Oh cool, so the numbers are the same for all these chips ?

Thanks!
Best regards,
Marek Vasut

#15 lore raw
Quoted 102 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2016?4?25? 18:30
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: SAMA5D2 xplained SD/eMMC boot

Quoted 71 lines · Wenyou

Hi Marek,

Quoted 69 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2016?4?22? 20:18
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: SAMA5D2 xplained SD/eMMC boot

Quoted 1 line · Wenyou

Hi Marek,

Hi!

Quoted 43 lines
Quoted 43 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2016?4?21? 10:59
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: SAMA5D2 xplained SD/eMMC boot

Quoted 1 line · Wenyou

Hi,

Hi!

[...]
pile of unnecessary email headers redacted.
[...]

Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 11 lines
Quoted 8 lines

Hi!

I've been playing around with latest mainline u-boot on
sama5d2 xplained ultra. I noticed that if I want to boot
the board from SD card (SDHCI1), the board will indeed load
the SPL from it, but SPL will try to load u-boot.img from
eMMC
(SDHCI0) and fail, as my eMMC is blank.

Yes, there is some issue to load u-boot.img. I found there is something to do on

sdhci.c.

Quoted 8 lines

You can try this branch, it should works.

https://github.com/linux4sam/u-boot-at91/commits/u-boot-2016
.0
3-
at
91

I am not interested in using non-mainline stuff. Do you have any particular patch/commit which I can refer to ? I do not think this has anything to do with sdhci.c driver at all, it has to do with detecting the boot device from which SPL was started and loading u-boot.img from the same boot device instead of always using

Quoted 8 lines
Quoted 8 lines

SDHCI0.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

I will test the mainline code. I will let you know when I get something.

OK.

Does the SoC have any sort of register which lists the current boot

device ?

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

In this SoC, there is not register to list the current boot device.

And thus, it is not possible to detect at runtime from which device the SoC booted and thus load u-boot.img from the same device.

Correct ?

Quoted 20 lines
Quoted 20 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Yes,

Ha, thanks for confirming.

Sorry, can I correct what I said yesterday?

What if I said "no" ? :-)

Quoted 4 lines

There is a register to list the boot information exported by ROMCode.

The boot information is stored in R4 register when the ROMCode jumps to the

bootstrap.

Ha, so the U-Boot SPL can save the r4 register early in the boot and extract the boot device from it. That's neat. Thanks!

Quoted 2 lines

Here is the contents definitions R4 on the SAMA5D2 (improved compared to old

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

MPUs to take care of IOSet features).

Is this stuff somewhere in the SAMA5Dx datasheet ? It'd be nice to know/have this information for other SAMA5Dx too (d3 and d4).

It seems it is not included in the in the SAMA5Dx datasheet.

So where did you get these numbers from ?

Yes, it is not included in the datasheet now. We are not recommend to use them.

If it is helpful for you, please reference the previous mail.

Quoted 4 lines
Quoted 2 lines

This feature is available since AT91SAM9G45, inclusive d3 and d4.

Oh cool, so the numbers are the same for all these chips ?

Yes, basically same, only d2 includes additional ioset information.

Best Regards,
Wenyou Yang

#16 lore raw
Quoted 107 lines · Wenyou
Quoted 107 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2016?4?25? 18:30
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: SAMA5D2 xplained SD/eMMC boot

Quoted 71 lines · Wenyou

Hi Marek,

Quoted 69 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2016?4?22? 20:18
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: SAMA5D2 xplained SD/eMMC boot

Quoted 1 line · Wenyou

Hi Marek,

Hi!

Quoted 43 lines
Quoted 43 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2016?4?21? 10:59
To: Yang, Wenyou <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: SAMA5D2 xplained SD/eMMC boot

Quoted 1 line · Wenyou

Hi,

Hi!

[...]
pile of unnecessary email headers redacted.
[...]

Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 11 lines

Hi!

I've been playing around with latest mainline u-boot on
sama5d2 xplained ultra. I noticed that if I want to boot
the board from SD card (SDHCI1), the board will indeed load
the SPL from it, but SPL will try to load u-boot.img from
eMMC
(SDHCI0) and fail, as my eMMC is blank.

Yes, there is some issue to load u-boot.img. I found there
is something to do on

sdhci.c.

Quoted 8 lines

You can try this branch, it should works.

https://github.com/linux4sam/u-boot-at91/commits/u-boot-2016
.0
3-
at
91

I am not interested in using non-mainline stuff. Do you have any particular patch/commit which I can refer to ? I do not think this has anything to do with sdhci.c driver at all, it has to do with detecting the boot device from which SPL was started and loading u-boot.img from the same boot device instead of always using

Quoted 8 lines
Quoted 8 lines

SDHCI0.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

I will test the mainline code. I will let you know when I get something.

OK.

Does the SoC have any sort of register which lists the current boot

device ?

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

In this SoC, there is not register to list the current boot device.

And thus, it is not possible to detect at runtime from which device the SoC booted and thus load u-boot.img from the same device.

Correct ?

Quoted 25 lines
Quoted 24 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Yes,

Ha, thanks for confirming.

Sorry, can I correct what I said yesterday?

What if I said "no" ? :-)

Quoted 4 lines

There is a register to list the boot information exported by ROMCode.

The boot information is stored in R4 register when the ROMCode jumps to the

bootstrap.

Ha, so the U-Boot SPL can save the r4 register early in the boot and extract the boot device from it. That's neat. Thanks!

Quoted 2 lines

Here is the contents definitions R4 on the SAMA5D2 (improved compared to old

MPUs to take care of IOSet features).

Is this stuff somewhere in the SAMA5Dx datasheet ? It'd be nice to know/have this information for other SAMA5Dx too (d3 and d4).

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

It seems it is not included in the in the SAMA5Dx datasheet.

So where did you get these numbers from ?

Yes, it is not included in the datasheet now. We are not recommend to use them.

If it is helpful for you, please reference the previous mail.

It is helpful, I sent a patch for SAMA5D2 which makes it behave sane. I will have to battle SAMA5D4 board soon, so I will most likely extend that patch for SAMA5D4.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

This feature is available since AT91SAM9G45, inclusive d3 and d4.

Oh cool, so the numbers are the same for all these chips ?

Yes, basically same, only d2 includes additional ioset information.

OK, the IOSET is not interesting for now.

It'd be cool to have this documented somewhere :)

Best regards,
Marek Vasut