imx: Introduce CONFIG_SPL_FORCE_MMC_BOOT to force MMC boot on falcon mode
Subsystems (3)
PATCH 1/1 imx: Introduce CONFIG_SPL_FORCE_MMC_BOOT to force MMC boot on falcon mode
This change tries to fix the following problem:
- The board boots (to be more precise - ROM loads SPL) from a slow SPI-NOR memory.
As a result the spl_boot_device() will return SPI-NOR as a boot device (which is correct).
- The problem is that in 'falcon boot' the eMMC is used as a boot medium to load kernel from its partition.
Calling spl_boot_device() will break things as it returns SPI-NOR device.
To fix this issue the new CONFIG_SPL_FORCE_MMC_BOOT Kconfig flag is introduced to handle this special use case. By default it is not defined, so there is no change in the legacy code flow.
---
This patch is a follow up of previous discussion/fix:
https://patchwork.ozlabs.org/patch/796237/
Travis-CI:
https://travis-ci.org/lmajewski/u-boot-dfu/builds/580272414
--- arch/arm/mach-imx/spl.c | 11 +++++++++++ common/spl/Kconfig | 7 +++++++ 2 files changed, 18 insertions(+)
arch/arm/mach-imx/spl.c +11 -0
@@ -178,7 +178,18 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)/* called from spl_mmc to see type of boot mode for storage (RAW or FAT) */ u32 spl_boot_mode (const u32 boot_device) { +/* +* When CONFIG_SPL_FORCE_MMC_BOOT is defined the 'boot_device' is used +* unconditionally to decide about device to use for booting. +* This is crucial for falcon boot mode, when board boots up (i.e. ROM +* loads SPL) from slow SPI-NOR memory and afterwards the SPL's 'falcon' boot +* mode is used to load Linux OS from eMMC partition. +*/ +#ifdef CONFIG_SPL_FORCE_MMC_BOOT +switch (boot_device) { +#else switch (spl_boot_device ()) { +#endif /* for MMC return either RAW or FAT mode */ case BOOT_DEVICE_MMC1 :case BOOT_DEVICE_MMC2 :
common/spl/Kconfig +7 -0
@@ -607,6 +607,13 @@ config SPL_MMC_SUPPORT this option to build the drivers in drivers/mmc as part of an SPL build. +config SPL_FORCE_MMC_BOOT + bool "Force SPL's falcon boot from MMC" + depends on SPL_MMC_SUPPORT + default n + help + Force SPL's falcon boot to use MMC device for Linux kernel booting. + config SPL_MMC_TINY bool "Tiny MMC framework in SPL" depends on SPL_MMC_SUPPORT
Signature · 1 line
2.11.0
PATCH 1/1 imx: Introduce CONFIG_SPL_FORCE_MMC_BOOT to force MMC boot on falcon mode
Hello Lukasz,
added Stefano to cc as he is the imx custodian.
Am 03.09.2019 um 23:43 schrieb Lukasz Majewski:
Quoted 23 lines
This change tries to fix the following problem:
- The board boots (to be more precise - ROM loads SPL) from a slow SPI-NOR memory.
As a result thespl_boot_device()will return SPI-NOR as a boot device (which is correct).- The problem is that in 'falcon boot' the eMMC is used as a boot medium to load kernel from its partition.
Callingspl_boot_device()will break things as it returns SPI-NOR device.To fix this issue the new
CONFIG_SPL_FORCE_MMC_BOOTKconfigflag is introduced to handle this special use case. By default it is not defined, so there is no change in the legacy code flow.Signed-off-by Lukasz Majewski <[email protected]>---
This patch is a follow up of previous discussion/fix:
https://patchwork.ozlabs.org/patch/796237/
Quoted 6 lines
Travis-CI:
https://travis-ci.org/lmajewski/u-boot-dfu/builds/580272414--- arch/arm/mach-imx/spl.c | 11 +++++++++++ common/spl/Kconfig | 7 +++++++ 2 files changed, 18 insertions(+)
I have just similiar change for an imx6ull based board ... just antoher usecase: In factory empty board boots into USB SDP mode, and SPL gets loaded with usb_loader ... SPL detects a sd card (there is no sd card slot mounted, mmc boot is disabled! They attach only one for installing software) and boots U-Boot and system from sd card. Than all software gets installed fully automated with the help of swupdate ...
Quoted 10 lines
arch/arm/mach-imx/spl.c +2
-0@@ -178,7 +178,18 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)/* called from spl_mmc to see type of boot mode for storage (RAW or FAT) */ u32 spl_boot_mode (const u32 boot_device) { +/* +* When CONFIG_SPL_FORCE_MMC_BOOT is defined the 'boot_device' is used
arch/arm/mach-imx/spl.c int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) · line 192
Quoted 10 lines
arch/arm/mach-imx/spl.c +9
-0+* unconditionally to decide about device to use for booting. +* This is crucial for falcon boot mode, when board boots up (i.e. ROM +* loads SPL) from slow SPI-NOR memory and afterwards the SPL's 'falcon' boot +* mode is used to load Linux OS from eMMC partition. +*/ +#ifdef CONFIG_SPL_FORCE_MMC_BOOT +switch (boot_device) { +#else switch (spl_boot_device ()) { +#endif
Just dummy question .. couldn;t we switch to use always boot_device?
In my case I had a board specific:
void board_boot_order(u32 *spl_boot_list)
{
spl_boot_list[0] = BOOT_DEVICE_MMC1;
spl_boot_list[1] = BOOT_DEVICE_SPI;
spl_boot_list[2] = BOOT_DEVICE_BOARD;
spl_boot_list[3] = BOOT_DEVICE_NONE;
}which leads that BOOT_DEVICE_MMC1 is passed to spl_boot_mode()
If MMC1 is not found, it tries to boot U-Boot from SPI, and if this is empty, as fallback board go into USB SDP mode.
The weak function of board_boot_order is:
__weak void board_boot_order(u32 *spl_boot_list)
{
spl_boot_list[0] = spl_boot_device();
}which is exactly what we pass to spl_boot_mode() ... so instead calling spl_boot_device() twice we can use the passed boot_device ... and save the ifdef and new Kconfig option.
But may I oversee something ?
Quoted 8 lines
arch/arm/mach-imx/spl.c +0
-0/* for MMC return either RAW or FAT mode */ case BOOT_DEVICE_MMC1 :case BOOT_DEVICE_MMC2 :common/spl/Kconfig +0
-0
common/spl/Kconfig config SPL_MMC_SUPPORT · line 615
Quoted 9 lines
common/spl/Kconfig +6
-0@@ -607,6 +607,13 @@ config SPL_MMC_SUPPORT this option to build the drivers in drivers/mmc as part of an SPL build. +config SPL_FORCE_MMC_BOOT + bool "Force SPL's falcon boot from MMC" + depends on SPL_MMC_SUPPORT + default n + help + Force SPL's falcon boot to use MMC device for Linux kernel booting.
Hmm... falcon boot is just one use case. I would drop "falcon boot" It just to force boot from MMC.
common/spl/Kconfig config SPL_MMC_SUPPORT · line 619
Quoted 5 lines
common/spl/Kconfig +1
-0+ config SPL_MMC_TINY bool "Tiny MMC framework in SPL" depends on SPL_MMC_SUPPORT
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH 1/1 imx: Introduce CONFIG_SPL_FORCE_MMC_BOOT to force MMC boot on falcon mode
Hi Heiko,
Quoted 3 lines
Hello Lukasz,
added Stefano to cc as he is the imx custodian.
I've relied on patman ... Thanks for adding Stefano to CC.
Quoted 26 lines
Am 03.09.2019 um 23:43 schrieb Lukasz Majewski:
Quoted 24 lines
This change tries to fix the following problem:
- The board boots (to be more precise - ROM loads SPL) from a slow SPI-NOR memory.
As a result thespl_boot_device()will return SPI-NOR as a boot
device (which is correct).- The problem is that in 'falcon boot' the eMMC is used as a boot medium to load kernel from its partition.
Callingspl_boot_device()will break things as it returns
SPI-NOR device.To fix this issue the new
CONFIG_SPL_FORCE_MMC_BOOTKconfigflag is introduced to handle this special use case. By default it is not defined, so there is no change in the legacy code flow.Signed-off-by Lukasz Majewski <[email protected]>---
This patch is a follow up of previous discussion/fix:
https://patchwork.ozlabs.org/patch/796237/
Quoted 8 lines
Quoted 6 lines
Travis-CI:
https://travis-ci.org/lmajewski/u-boot-dfu/builds/580272414--- arch/arm/mach-imx/spl.c | 11 +++++++++++ common/spl/Kconfig | 7 +++++++ 2 files changed, 18 insertions(+)I have just similiar change for an imx6ull based board ...
Also one more of my boards uses this trick (i.MX28 based one).
Quoted 4 lines
just antoher usecase: In factory empty board boots into USB SDP mode, and SPL gets loaded with
usb_loader... SPL detects a sd card (there is no sd card slot mounted, mmc boot is disabled! They attach only one for installing software)
So there is no dedicated SD card slot (also the mmc is disabled on that point).
Instead, in the factory the sd card is attached to pads - just for this time.
Quoted 3 lines
and boots U-Boot and system from sd card.
Than all software gets installed fully automated with the help of swupdate ...
Ok.
Quoted 18 lines
Quoted 18 lines
arch/arm/mach-imx/spl.c +0
-0@@ -178,7 +178,18 @@ int g_dnl_bind_fixup(struct
usb_device_descriptor*dev, const char *name) /* called fromspl_mmcto see type of boot mode for storage (RAW or FAT) */ u32spl_boot_mode(const u32 boot_device){
+/*
+ * WhenCONFIG_SPL_FORCE_MMC_BOOTis defined the 'boot_device' is used
+ * unconditionally to decide about device to use for booting.
+ * This is crucial for falcon boot mode, when board boots up (i.e. ROM
+ * loads SPL) from slow SPI-NOR memory and afterwards the SPL's 'falcon' boot
+ * mode is used to load Linux OS from eMMC partition.
Quoted 8 lines
arch/arm/mach-imx/spl.c int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) · line 192
Quoted 6 lines
+ */
arch/arm/mach-imx/spl.c +4
-0+#ifdef CONFIG_SPL_FORCE_MMC_BOOT +switch (boot_device) { +#else switch (spl_boot_device ()) { +#endif Just dummy question .. couldn;t we switch to use always
boot_device?
Stefano has provided some rationale for the need of spl_boot_device() in the previous version of this fix [1]:
https://patchwork.ozlabs.org/patch/796237/
Quoted 4 lines
In my case I had a board specific:
void
board_boot_order(u32 *spl_boot_list)
Quoted 8 lines
{ spl_boot_list[0] = BOOT_DEVICE_MMC1; spl_boot_list[1] = BOOT_DEVICE_SPI; spl_boot_list[2] = BOOT_DEVICE_BOARD; spl_boot_list[3] = BOOT_DEVICE_NONE; }which leads that
BOOT_DEVICE_MMC1is passed tospl_boot_mode()
Is your board normally booting from MMC or SPI-NOR (from where SoC ROM loads SPL) ?
Quoted 11 lines
If MMC1 is not found, it tries to boot U-Boot from SPI, and if this is empty, as fallback board go into USB SDP mode.
The weak function of
board_boot_orderis:
__weakvoidboard_boot_order(u32 *spl_boot_list){ spl_boot_list[0] = spl_boot_device(); }
Quoted 5 lines
which is exactly what we pass to
spl_boot_mode()... so instead callingspl_boot_device()twice we can use the passedboot_device... and save the ifdef and newKconfigoption.But may I oversee something ?
Please read the Stefano's reply from [1] - the spl_boot_device() has a valid use cases as well.
Quoted 12 lines
Quoted 12 lines
/* for MMC return either RAW or FAT mode */ case
BOOT_DEVICE_MMC1:
caseBOOT_DEVICE_MMC2:common/spl/Kconfig +0
-0@@ -607,6 +607,13 @@ config SPL_MMC_SUPPORT this option to build the drivers in drivers/mmc as partof an SPL build.
Quoted 10 lines
Quoted 7 lines
common/spl/Kconfig +6
-0+config SPL_FORCE_MMC_BOOT + bool "Force SPL's falcon boot from MMC" + depends on SPL_MMC_SUPPORT + default n + help + Force SPL's falcon boot to use MMC device for Linuxkernel booting.
Hmm... falcon boot is just one use case. I would drop "falcon boot" It just to force boot from MMC.
Ok. I will rewrite the help message.
Quoted 9 lines
Quoted 6 lines
+
configSPL_MMC_TINY
bool "Tiny MMC framework in SPL"
depends onSPL_MMC_SUPPORTbye,
Heiko
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190904/51782664/attachment.sig>
PATCH 1/1 imx: Introduce CONFIG_SPL_FORCE_MMC_BOOT to force MMC boot on falcon mode
Quoted 121 lines · Lukasz Majewski
Hi Heiko,
Quoted 3 lines
Hello Lukasz,
added Stefano to cc as he is the imx custodian.
I've relied on patman ... Thanks for adding Stefano to CC.
Quoted 26 lines
Am 03.09.2019 um 23:43 schrieb Lukasz Majewski:
Quoted 24 lines
This change tries to fix the following problem:
- The board boots (to be more precise - ROM loads SPL) from a slow SPI-NOR memory.
As a result thespl_boot_device()will return SPI-NOR as a boot
device (which is correct).- The problem is that in 'falcon boot' the eMMC is used as a boot medium to load kernel from its partition.
Callingspl_boot_device()will break things as it returns
SPI-NOR device.To fix this issue the new
CONFIG_SPL_FORCE_MMC_BOOTKconfigflag is introduced to handle this special use case. By default it is not defined, so there is no change in the legacy code flow.Signed-off-by Lukasz Majewski <[email protected]>---
This patch is a follow up of previous discussion/fix:
https://patchwork.ozlabs.org/patch/796237/Quoted 8 lines
Quoted 6 lines
Travis-CI:
https://travis-ci.org/lmajewski/u-boot-dfu/builds/580272414--- arch/arm/mach-imx/spl.c | 11 +++++++++++ common/spl/Kconfig | 7 +++++++ 2 files changed, 18 insertions(+)I have just similiar change for an imx6ull based board ...
Also one more of my boards uses this trick (i.MX28 based one).
Quoted 4 lines
just antoher usecase: In factory empty board boots into USB SDP mode, and SPL gets loaded with
usb_loader... SPL detects a sd card (there is no sd card slot mounted, mmc boot is disabled! They attach only one for installing software)So there is no dedicated SD card slot (also the mmc is disabled on that point).
Instead, in the factory the sd card is attached to pads - just for this time.Quoted 3 lines
and boots U-Boot and system from sd card.
Than all software gets installed fully automated with the help of swupdate ...Ok.
Quoted 18 lines
Quoted 18 lines
arch/arm/mach-imx/spl.c +0
-0@@ -178,7 +178,18 @@ int g_dnl_bind_fixup(struct
usb_device_descriptor*dev, const char *name) /* called fromspl_mmcto see type of boot mode for storage (RAW or FAT) */ u32spl_boot_mode(const u32 boot_device){
+/*
+ * WhenCONFIG_SPL_FORCE_MMC_BOOTis defined the 'boot_device' is used
+ * unconditionally to decide about device to use for booting.
+ * This is crucial for falcon boot mode, when board boots up (i.e. ROM
+ * loads SPL) from slow SPI-NOR memory and afterwards the SPL's 'falcon' boot
+ * mode is used to load Linux OS from eMMC partition.Quoted 8 lines
arch/arm/mach-imx/spl.c int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) · line 192
Quoted 6 lines
+ */
arch/arm/mach-imx/spl.c +4
-0+#ifdef CONFIG_SPL_FORCE_MMC_BOOT +switch (boot_device) { +#else switch (spl_boot_device ()) { +#endif Just dummy question .. couldn;t we switch to use always
boot_device?Stefano has provided some rationale for the need of
spl_boot_device()in the previous version of this fix [1]:https://patchwork.ozlabs.org/patch/796237/
Quoted 4 lines
In my case I had a board specific:
void
board_boot_order(u32 *spl_boot_list)Quoted 8 lines
{ spl_boot_list[0] = BOOT_DEVICE_MMC1; spl_boot_list[1] = BOOT_DEVICE_SPI; spl_boot_list[2] = BOOT_DEVICE_BOARD; spl_boot_list[3] = BOOT_DEVICE_NONE; }which leads that
BOOT_DEVICE_MMC1is passed tospl_boot_mode()Is your board normally booting from MMC or SPI-NOR (from where SoC ROM loads SPL) ?
Quoted 11 lines
If MMC1 is not found, it tries to boot U-Boot from SPI, and if this is empty, as fallback board go into USB SDP mode.
The weak function of
board_boot_orderis:
__weakvoidboard_boot_order(u32 *spl_boot_list){ spl_boot_list[0] = spl_boot_device(); }
Quoted 8 lines
Quoted 5 lines
which is exactly what we pass to
spl_boot_mode()... so instead callingspl_boot_device()twice we can use the passedboot_device... and save the ifdef and newKconfigoption.But may I oversee something ?
Please read the Stefano's reply from [1] - the
spl_boot_device()has a valid use cases as well.
Nevertheless, why do we need to add a new compiler switch if this can be check into board code ? You just need that spl_boot_device() returns the device you want (MMC for falcon boot). Why do you need to force it in this way ?
Regards,
Stefano
Quoted 48 lines
Quoted 13 lines
Quoted 13 lines
/* for MMC return either RAW or FAT mode */ case
BOOT_DEVICE_MMC1:
caseBOOT_DEVICE_MMC2:common/spl/Kconfig +0
-0@@ -607,6 +607,13 @@ config SPL_MMC_SUPPORT this option to build the drivers in drivers/mmc as partof an SPL build.
Quoted 10 lines
Quoted 7 lines
common/spl/Kconfig +6
-0+config SPL_FORCE_MMC_BOOT + bool "Force SPL's falcon boot from MMC" + depends on SPL_MMC_SUPPORT + default n + help + Force SPL's falcon boot to use MMC device for Linuxkernel booting.
Hmm... falcon boot is just one use case. I would drop "falcon boot" It just to force boot from MMC.
Ok. I will rewrite the help message.
Quoted 9 lines
Quoted 6 lines
+
configSPL_MMC_TINY
bool "Tiny MMC framework in SPL"
depends onSPL_MMC_SUPPORTbye,
HeikoBest regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
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 =====================================================================
PATCH 1/1 imx: Introduce CONFIG_SPL_FORCE_MMC_BOOT to force MMC boot on falcon mode
Hi Stefano, Heiko,
Quoted 127 lines · Lukasz Majewski
Quoted 126 lines
Hi Heiko,
Quoted 3 lines
Hello Lukasz,
added Stefano to cc as he is the imx custodian.
I've relied on patman ... Thanks for adding Stefano to CC.
Quoted 26 lines
Am 03.09.2019 um 23:43 schrieb Lukasz Majewski:
Quoted 24 lines
This change tries to fix the following problem:
- The board boots (to be more precise - ROM loads SPL) from a slow SPI-NOR memory.
As a result thespl_boot_device()will return SPI-NOR as a boot
device (which is correct).- The problem is that in 'falcon boot' the eMMC is used as a boot medium to load kernel from its partition.
Callingspl_boot_device()will break things as it returns
SPI-NOR device.To fix this issue the new
CONFIG_SPL_FORCE_MMC_BOOTKconfigflag is introduced to handle this special use case. By default it is not defined, so there is no change in the legacy code flow.Signed-off-by Lukasz Majewski <[email protected]>---
This patch is a follow up of previous discussion/fix:
https://patchwork.ozlabs.org/patch/796237/Quoted 8 lines
Quoted 6 lines
Travis-CI:
https://travis-ci.org/lmajewski/u-boot-dfu/builds/580272414--- arch/arm/mach-imx/spl.c | 11 +++++++++++ common/spl/Kconfig | 7 +++++++ 2 files changed, 18 insertions(+)I have just similiar change for an imx6ull based board ...
Also one more of my boards uses this trick (i.MX28 based one).
Quoted 4 lines
just antoher usecase: In factory empty board boots into USB SDP mode, and SPL gets loaded with
usb_loader... SPL detects a sd card (there is no sd card slot mounted, mmc boot is disabled! They attach only one for installing software)So there is no dedicated SD card slot (also the mmc is disabled on that point).
Instead, in the factory the sd card is attached to pads - just for this time.Quoted 3 lines
and boots U-Boot and system from sd card.
Than all software gets installed fully automated with the help of swupdate ...Ok.
Quoted 19 lines
Quoted 19 lines
arch/arm/mach-imx/spl.c +0
-0@@ -178,7 +178,18 @@ int g_dnl_bind_fixup(struct
usb_device_descriptor*dev, const char *name) /* called fromspl_mmcto see type of boot mode for storage (RAW or FAT) */ u32spl_boot_mode(const u32 boot_device){
+/*
+ * WhenCONFIG_SPL_FORCE_MMC_BOOTis defined the 'boot_device' is used
+ * unconditionally to decide about device to use for booting.
+ * This is crucial for falcon boot mode, when board boots up (i.e. ROM
+ * loads SPL) from slow SPI-NOR memory and afterwards the SPL's 'falcon' boot
+ * mode is used to load Linux OS from eMMC partition.
+ */Quoted 8 lines
arch/arm/mach-imx/spl.c int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) · line 192
Quoted 5 lines
arch/arm/mach-imx/spl.c +4
-0+#ifdef CONFIG_SPL_FORCE_MMC_BOOT +switch (boot_device) { +#else switch (spl_boot_device ()) { +#endif Just dummy question .. couldn;t we switch to use always
boot_device?Stefano has provided some rationale for the need of
spl_boot_device()in the previous version of this fix [1]:https://patchwork.ozlabs.org/patch/796237/
Quoted 4 lines
In my case I had a board specific:
void
board_boot_order(u32 *spl_boot_list)Quoted 8 lines
{ spl_boot_list[0] = BOOT_DEVICE_MMC1; spl_boot_list[1] = BOOT_DEVICE_SPI; spl_boot_list[2] = BOOT_DEVICE_BOARD; spl_boot_list[3] = BOOT_DEVICE_NONE; }which leads that
BOOT_DEVICE_MMC1is passed tospl_boot_mode()Is your board normally booting from MMC or SPI-NOR (from where SoC ROM loads SPL) ?
Quoted 15 lines
If MMC1 is not found, it tries to boot U-Boot from SPI, and if this is empty, as fallback board go into USB SDP mode.
The weak function of
board_boot_orderis:
__weakvoidboard_boot_order(u32 *spl_boot_list){ spl_boot_list[0] = spl_boot_device(); }which is exactly what we pass to
spl_boot_mode()... so instead callingspl_boot_device()twice we can use the passedboot_device... and save the ifdef and newKconfigoption.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
But may I oversee something ?
Please read the Stefano's reply from [1] - the
spl_boot_device()has a valid use cases as well.Nevertheless, why do we need to add a new compiler switch if this can be check into board code ? You just need that
spl_boot_device()returns the device you want (MMC for falcon boot).
Current status:
git grep -n "spl_boot_mode" | grep weak common/spl/spl_mmc.c:287:u32 __weak spl_boot_mode(const u32 boot_device)
git grep -n "board_boot_order" | grep weak common/spl/spl.c:491:__weak void board_boot_order(u32 *spl_boot_list)
The spl_boot_device() is defined in arch/arm/mach-imx/spl.c [*] as a NON __weak function:
git grep -n "spl_boot_device" | grep weak
Shall I make this function [*] as __weak and provide override for it in the board file?
The problem is in the call of spl_boot_mode() (which is overridden already in arch/arm/mach-imx/spl.c) at common/spl/spl_mmc.c
Which then calls spl_boot_device() [**], which may return (correctly) SPI-NOR for eMMC.
As is now spl_boot_device() is not a __weak function.
Quoted 2 lines
Why do you need to
force it in this way ?
The option is to use the proposed patch to make spl_boot_device as a weak function.
Quoted 54 lines
Regards,
StefanoQuoted 48 lines
Quoted 13 lines
Quoted 13 lines
/* for MMC return either RAW or FAT mode */ case
BOOT_DEVICE_MMC1:
caseBOOT_DEVICE_MMC2:common/spl/Kconfig +0
-0@@ -607,6 +607,13 @@ config SPL_MMC_SUPPORT this option to build the drivers in drivers/mmc aspart of an SPL build.
Quoted 10 lines
Quoted 7 lines
common/spl/Kconfig +6
-0+config SPL_FORCE_MMC_BOOT + bool "Force SPL's falcon boot from MMC" + depends on SPL_MMC_SUPPORT + default n + help + Force SPL's falcon boot to use MMC device for Linuxkernel booting.
Hmm... falcon boot is just one use case. I would drop "falcon boot" It just to force boot from MMC.
Ok. I will rewrite the help message.
Quoted 9 lines
Quoted 6 lines
+
configSPL_MMC_TINY
bool "Tiny MMC framework in SPL"
depends onSPL_MMC_SUPPORTbye,
HeikoBest regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang
Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
lukma at denx.de
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190904/02d5ca2b/attachment.sig>
PATCH 1/1 imx: Introduce CONFIG_SPL_FORCE_MMC_BOOT to force MMC boot on falcon mode
Quoted 167 lines · On Wed, 4 Sep 2019 11:54:40 +0200 Lukasz Majewski <[email protected]> wrote:
Hi Stefano, Heiko,
Quoted 128 lines · Lukasz Majewski
Quoted 127 lines
Hi Heiko,
Quoted 3 lines
Hello Lukasz,
added Stefano to cc as he is the imx custodian.
I've relied on patman ... Thanks for adding Stefano to CC.
Quoted 26 lines
Am 03.09.2019 um 23:43 schrieb Lukasz Majewski:
Quoted 24 lines
This change tries to fix the following problem:
- The board boots (to be more precise - ROM loads SPL) from a slow SPI-NOR memory.
As a result thespl_boot_device()will return SPI-NOR as a
boot device (which is correct).- The problem is that in 'falcon boot' the eMMC is used as a boot medium to load kernel from its partition. Calling
spl_boot_device()will break things as it returns
SPI-NOR device.To fix this issue the new
CONFIG_SPL_FORCE_MMC_BOOTKconfigflag is introduced to handle this special use case. By default it is not defined, so there is no change in the legacy code flow.Signed-off-by Lukasz Majewski <[email protected]>---
This patch is a follow up of previous discussion/fix:
https://patchwork.ozlabs.org/patch/796237/Quoted 8 lines
Quoted 6 lines
Travis-CI:
https://travis-ci.org/lmajewski/u-boot-dfu/builds/580272414--- arch/arm/mach-imx/spl.c | 11 +++++++++++ common/spl/Kconfig | 7 +++++++ 2 files changed, 18 insertions(+)I have just similiar change for an imx6ull based board ...
Also one more of my boards uses this trick (i.MX28 based one).
Quoted 4 lines
just antoher usecase: In factory empty board boots into USB SDP mode, and SPL gets loaded with
usb_loader... SPL detects a sd card (there is no sd card slot mounted, mmc boot is disabled! They attach only one for installing software)So there is no dedicated SD card slot (also the mmc is disabled on that point).
Instead, in the factory the sd card is attached to pads - just for this time.Quoted 3 lines
and boots U-Boot and system from sd card.
Than all software gets installed fully automated with the help of swupdate ...Ok.
Quoted 19 lines
Quoted 19 lines
arch/arm/mach-imx/spl.c +0
-0@@ -178,7 +178,18 @@ int g_dnl_bind_fixup(struct
usb_device_descriptor*dev, const char *name) /* called fromspl_mmcto see type of boot mode for storage (RAW or FAT) */ u32spl_boot_mode(const u32 boot_device){
+/*
+ * WhenCONFIG_SPL_FORCE_MMC_BOOTis defined the 'boot_device' is used
+ * unconditionally to decide about device to use for booting.
+ * This is crucial for falcon boot mode, when board boots up (i.e. ROM
+ * loads SPL) from slow SPI-NOR memory and afterwards the SPL's 'falcon' boot
+ * mode is used to load Linux OS from eMMC partition.
+ */Quoted 8 lines
arch/arm/mach-imx/spl.c int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) · line 192
Quoted 5 lines
arch/arm/mach-imx/spl.c +4
-0+#ifdef CONFIG_SPL_FORCE_MMC_BOOT +switch (boot_device) { +#else switch (spl_boot_device ()) { +#endif Just dummy question .. couldn;t we switch to use always
boot_device?Stefano has provided some rationale for the need of
spl_boot_device()in the previous version of this fix [1]:https://patchwork.ozlabs.org/patch/796237/
Quoted 4 lines
In my case I had a board specific:
void
board_boot_order(u32 *spl_boot_list)Quoted 9 lines
{ spl_boot_list[0] = BOOT_DEVICE_MMC1; spl_boot_list[1] = BOOT_DEVICE_SPI; spl_boot_list[2] = BOOT_DEVICE_BOARD; spl_boot_list[3] = BOOT_DEVICE_NONE; }which leads that
BOOT_DEVICE_MMC1is passed tospl_boot_mode()Is your board normally booting from MMC or SPI-NOR (from where SoC ROM loads SPL) ?
Quoted 15 lines
If MMC1 is not found, it tries to boot U-Boot from SPI, and if this is empty, as fallback board go into USB SDP mode.
The weak function of
board_boot_orderis:
__weakvoidboard_boot_order(u32 *spl_boot_list){ spl_boot_list[0] = spl_boot_device(); }which is exactly what we pass to
spl_boot_mode()... so instead callingspl_boot_device()twice we can use the passedboot_device... and save the ifdef and newKconfigoption.Quoted 8 lines
Quoted 4 lines
Quoted 1 line
But may I oversee something ?
Please read the Stefano's reply from [1] - the
spl_boot_device()has a valid use cases as well.Nevertheless, why do we need to add a new compiler switch if this can be check into board code ? You just need that
spl_boot_device()returns the device you want (MMC for falcon boot).Current status:
git grep -n "
spl_boot_mode" | grep weak common/spl/spl_mmc.c:287:u32__weakspl_boot_mode(const u32 boot_device)git grep -n "
board_boot_order" | grep weak common/spl/spl.c:491:__weak voidboard_boot_order(u32 *spl_boot_list)The
spl_boot_device()is defined inarch/arm/mach-imx/spl.c[*] as a NON__weakfunction:
git grep -n "spl_boot_device" | grep weakShall I make this function [*] as
__weakand provide override for it in the board file?The problem is in the call of
spl_boot_mode()(which is overridden already inarch/arm/mach-imx/spl.c) atcommon/spl/spl_mmc.cWhich then calls
spl_boot_device()[**], which may return (correctly) SPI-NOR for eMMC.
Quoted 7 lines
As is now
spl_boot_device()is not a__weakfunction.Quoted 2 lines
Why do you need to
force it in this way ?The option is to use the proposed patch to make
spl_boot_deviceas a weak function.
The above text is a bit misleading - better version below.
The solution would be:
1. Use the proposed patch (with Kconfig option)
2. Define spl_boot_device as weak and override it in board file. However, it is not the preferred solution as spl_boot_device() on my setup correctly returns SPI-NOR (as SOC ROM loads SPL from SPI-NOR, not eMMC).
Quoted 60 lines
Quoted 55 lines
Regards,
StefanoQuoted 48 lines
Quoted 13 lines
Quoted 13 lines
/* for MMC return either RAW or FAT mode */ case
BOOT_DEVICE_MMC1:
caseBOOT_DEVICE_MMC2:common/spl/Kconfig +0
-0@@ -607,6 +607,13 @@ config SPL_MMC_SUPPORT this option to build the drivers in drivers/mmc aspart of an SPL build.
Quoted 10 lines
Quoted 7 lines
common/spl/Kconfig +6
-0+config SPL_FORCE_MMC_BOOT + bool "Force SPL's falcon boot from MMC" + depends on SPL_MMC_SUPPORT + default n + help + Force SPL's falcon boot to use MMC device for Linuxkernel booting.
Hmm... falcon boot is just one use case. I would drop "falcon boot" It just to force boot from MMC.
Ok. I will rewrite the help message.
Quoted 9 lines
Quoted 6 lines
+
configSPL_MMC_TINY
bool "Tiny MMC framework in SPL"
depends onSPL_MMC_SUPPORTbye,
HeikoBest regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang
Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
lukma at denx.deBest regards,
Quoted 8 lines
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
lukma at denx.de
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190904/70f120a5/attachment.sig>
PATCH 1/1 imx: Introduce CONFIG_SPL_FORCE_MMC_BOOT to force MMC boot on falcon mode
Quoted 180 lines · Lukasz Majewski
Quoted 167 lines · On Wed, 4 Sep 2019 11:54:40 +0200 Lukasz Majewski <[email protected]> wrote:
Hi Stefano, Heiko,
Quoted 128 lines · Lukasz Majewski
Quoted 127 lines
Hi Heiko,
Quoted 3 lines
Hello Lukasz,
added Stefano to cc as he is the imx custodian.
I've relied on patman ... Thanks for adding Stefano to CC.
Quoted 26 lines
Am 03.09.2019 um 23:43 schrieb Lukasz Majewski:
Quoted 24 lines
This change tries to fix the following problem:
- The board boots (to be more precise - ROM loads SPL) from a slow SPI-NOR memory.
As a result thespl_boot_device()will return SPI-NOR as a
boot device (which is correct).- The problem is that in 'falcon boot' the eMMC is used as a boot medium to load kernel from its partition. Calling
spl_boot_device()will break things as it returns
SPI-NOR device.To fix this issue the new
CONFIG_SPL_FORCE_MMC_BOOTKconfigflag is introduced to handle this special use case. By default it is not defined, so there is no change in the legacy code flow.Signed-off-by Lukasz Majewski <[email protected]>---
This patch is a follow up of previous discussion/fix:
https://patchwork.ozlabs.org/patch/796237/Quoted 8 lines
Quoted 6 lines
Travis-CI:
https://travis-ci.org/lmajewski/u-boot-dfu/builds/580272414--- arch/arm/mach-imx/spl.c | 11 +++++++++++ common/spl/Kconfig | 7 +++++++ 2 files changed, 18 insertions(+)I have just similiar change for an imx6ull based board ...
Also one more of my boards uses this trick (i.MX28 based one).
Quoted 4 lines
just antoher usecase: In factory empty board boots into USB SDP mode, and SPL gets loaded with
usb_loader... SPL detects a sd card (there is no sd card slot mounted, mmc boot is disabled! They attach only one for installing software)So there is no dedicated SD card slot (also the mmc is disabled on that point).
Instead, in the factory the sd card is attached to pads - just for this time.Quoted 3 lines
and boots U-Boot and system from sd card.
Than all software gets installed fully automated with the help of swupdate ...Ok.
Quoted 19 lines
Quoted 19 lines
arch/arm/mach-imx/spl.c +0
-0@@ -178,7 +178,18 @@ int g_dnl_bind_fixup(struct
usb_device_descriptor*dev, const char *name) /* called fromspl_mmcto see type of boot mode for storage (RAW or FAT) */ u32spl_boot_mode(const u32 boot_device){
+/*
+ * WhenCONFIG_SPL_FORCE_MMC_BOOTis defined the 'boot_device' is used
+ * unconditionally to decide about device to use for booting.
+ * This is crucial for falcon boot mode, when board boots up (i.e. ROM
+ * loads SPL) from slow SPI-NOR memory and afterwards the SPL's 'falcon' boot
+ * mode is used to load Linux OS from eMMC partition.
+ */Quoted 8 lines
arch/arm/mach-imx/spl.c int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) · line 192
Quoted 5 lines
arch/arm/mach-imx/spl.c +4
-0+#ifdef CONFIG_SPL_FORCE_MMC_BOOT +switch (boot_device) { +#else switch (spl_boot_device ()) { +#endif Just dummy question .. couldn;t we switch to use always
boot_device?Stefano has provided some rationale for the need of
spl_boot_device()in the previous version of this fix [1]:https://patchwork.ozlabs.org/patch/796237/
Quoted 4 lines
In my case I had a board specific:
void
board_boot_order(u32 *spl_boot_list)Quoted 9 lines
{ spl_boot_list[0] = BOOT_DEVICE_MMC1; spl_boot_list[1] = BOOT_DEVICE_SPI; spl_boot_list[2] = BOOT_DEVICE_BOARD; spl_boot_list[3] = BOOT_DEVICE_NONE; }which leads that
BOOT_DEVICE_MMC1is passed tospl_boot_mode()Is your board normally booting from MMC or SPI-NOR (from where SoC ROM loads SPL) ?
Quoted 15 lines
If MMC1 is not found, it tries to boot U-Boot from SPI, and if this is empty, as fallback board go into USB SDP mode.
The weak function of
board_boot_orderis:
__weakvoidboard_boot_order(u32 *spl_boot_list){ spl_boot_list[0] = spl_boot_device(); }which is exactly what we pass to
spl_boot_mode()... so instead callingspl_boot_device()twice we can use the passedboot_device... and save the ifdef and newKconfigoption.Quoted 8 lines
Quoted 4 lines
Quoted 1 line
But may I oversee something ?
Please read the Stefano's reply from [1] - the
spl_boot_device()has a valid use cases as well.Nevertheless, why do we need to add a new compiler switch if this can be check into board code ? You just need that
spl_boot_device()returns the device you want (MMC for falcon boot).Current status:
git grep -n "
spl_boot_mode" | grep weak common/spl/spl_mmc.c:287:u32__weakspl_boot_mode(const u32 boot_device)git grep -n "
board_boot_order" | grep weak common/spl/spl.c:491:__weak voidboard_boot_order(u32 *spl_boot_list)The
spl_boot_device()is defined inarch/arm/mach-imx/spl.c[*] as a NON__weakfunction:
git grep -n "spl_boot_device" | grep weakShall I make this function [*] as
__weakand provide override for it in the board file?The problem is in the call of
spl_boot_mode()(which is overridden already inarch/arm/mach-imx/spl.c) atcommon/spl/spl_mmc.cWhich then calls
spl_boot_device()[**], which may return (correctly) SPI-NOR for eMMC.Quoted 7 lines
As is now
spl_boot_device()is not a__weakfunction.Quoted 2 lines
Why do you need to
force it in this way ?The option is to use the proposed patch to make
spl_boot_deviceas a weak function.The above text is a bit misleading - better version below.
Quoted 8 lines
The solution would be:
1. Use the proposed patch (with
Kconfigoption)2. Define
spl_boot_deviceas weak and override it in board file. However, it is not the preferred solution asspl_boot_device()on my setup correctly returns SPI-NOR (as SOC ROM loads SPL from SPI-NOR, not eMMC).
Ok, but is a wek not thought for this purpose ? If it is weak, you can change it and decide to return the device you want. You could also check if Falco boot is enabled, at compile time with CONFIG_SPL_OS_BOOT or at runtime with spl_start_uboot(). Should it not be enough ?
Regards,
Stefano
Quoted 82 lines
Quoted 61 lines
Quoted 56 lines
Regards,
StefanoQuoted 48 lines
Quoted 13 lines
Quoted 13 lines
/* for MMC return either RAW or FAT mode */ case
BOOT_DEVICE_MMC1:
caseBOOT_DEVICE_MMC2:common/spl/Kconfig +0
-0@@ -607,6 +607,13 @@ config SPL_MMC_SUPPORT this option to build the drivers in drivers/mmc aspart of an SPL build.
Quoted 10 lines
Quoted 7 lines
common/spl/Kconfig +6
-0+config SPL_FORCE_MMC_BOOT + bool "Force SPL's falcon boot from MMC" + depends on SPL_MMC_SUPPORT + default n + help + Force SPL's falcon boot to use MMC device for Linuxkernel booting.
Hmm... falcon boot is just one use case. I would drop "falcon boot" It just to force boot from MMC.
Ok. I will rewrite the help message.
Quoted 9 lines
Quoted 6 lines
+
configSPL_MMC_TINY
bool "Tiny MMC framework in SPL"
depends onSPL_MMC_SUPPORTbye,
HeikoBest regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang
Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
lukma at denx.deBest regards,
Quoted 8 lines
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
lukma at denx.deBest regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
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 =====================================================================
PATCH 1/1 imx: Introduce CONFIG_SPL_FORCE_MMC_BOOT to force MMC boot on falcon mode
Hi Stefano,
Quoted 186 lines · Lukasz Majewski
Quoted 185 lines
Quoted 170 lines · On Wed, 4 Sep 2019 11:54:40 +0200 Lukasz Majewski <[email protected]> wrote:
Hi Stefano, Heiko,
Quoted 131 lines · Lukasz Majewski
Quoted 130 lines
Hi Heiko,
Quoted 3 lines
Hello Lukasz,
added Stefano to cc as he is the imx custodian.
I've relied on patman ... Thanks for adding Stefano to CC.
Quoted 27 lines
Am 03.09.2019 um 23:43 schrieb Lukasz Majewski:
Quoted 25 lines
This change tries to fix the following problem:
- The board boots (to be more precise - ROM loads SPL) from a slow SPI-NOR memory.
As a result thespl_boot_device()will return SPI-NOR as a
boot device (which is correct).- The problem is that in 'falcon boot' the eMMC is used as a boot medium to load kernel from its partition. Calling
spl_boot_device()will break things as it returns
SPI-NOR device.To fix this issue the new
CONFIG_SPL_FORCE_MMC_BOOTKconfigflag is introduced to handle this special use case. By default it is not defined, so there is no change in the legacy code flow.Signed-off-by Lukasz Majewski <[email protected]>---
This patch is a follow up of previous discussion/fix:
https://patchwork.ozlabs.org/patch/796237/Quoted 8 lines
Quoted 6 lines
Travis-CI:
https://travis-ci.org/lmajewski/u-boot-dfu/builds/580272414--- arch/arm/mach-imx/spl.c | 11 +++++++++++ common/spl/Kconfig | 7 +++++++ 2 files changed, 18 insertions(+)I have just similiar change for an imx6ull based board ...
Also one more of my boards uses this trick (i.MX28 based one).
Quoted 4 lines
just antoher usecase: In factory empty board boots into USB SDP mode, and SPL gets loaded with
usb_loader... SPL detects a sd card (there is no sd card slot mounted, mmc boot is disabled! They attach only one for installing software)So there is no dedicated SD card slot (also the mmc is disabled on that point).
Instead, in the factory the sd card is attached to pads - just for this time.Quoted 3 lines
and boots U-Boot and system from sd card.
Than all software gets installed fully automated with the help of swupdate ...Ok.
Quoted 19 lines
Quoted 19 lines
arch/arm/mach-imx/spl.c +0
-0@@ -178,7 +178,18 @@ int g_dnl_bind_fixup(struct
usb_device_descriptor*dev, const char *name) /* called fromspl_mmcto see type of boot mode for storage (RAW or FAT) */ u32spl_boot_mode(const u32 boot_device){
+/*
+ * WhenCONFIG_SPL_FORCE_MMC_BOOTis defined the 'boot_device' is used
+ * unconditionally to decide about device to use for booting.
+ * This is crucial for falcon boot mode, when board boots up (i.e. ROM
+ * loads SPL) from slow SPI-NOR memory and afterwards the SPL's 'falcon' boot
+ * mode is used to load Linux OS from eMMC partition.
+ */Quoted 8 lines
arch/arm/mach-imx/spl.c
Quoted 5 lines
arch/arm/mach-imx/spl.c +4
-0+#ifdef CONFIG_SPL_FORCE_MMC_BOOT +switch (boot_device) { +#else switch (spl_boot_device ()) { +#endif Just dummy question .. couldn;t we switch to use always
boot_device?Stefano has provided some rationale for the need of
spl_boot_device()in the previous version of this fix [1]:https://patchwork.ozlabs.org/patch/796237/
Quoted 4 lines
In my case I had a board specific:
void
board_boot_order(u32 *spl_boot_list)Quoted 9 lines
{ spl_boot_list[0] = BOOT_DEVICE_MMC1; spl_boot_list[1] = BOOT_DEVICE_SPI; spl_boot_list[2] = BOOT_DEVICE_BOARD; spl_boot_list[3] = BOOT_DEVICE_NONE; }which leads that
BOOT_DEVICE_MMC1is passed tospl_boot_mode()Is your board normally booting from MMC or SPI-NOR (from where SoC ROM loads SPL) ?
Quoted 16 lines
If MMC1 is not found, it tries to boot U-Boot from SPI, and if this is empty, as fallback board go into USB SDP mode.
The weak function of
board_boot_orderis:
__weakvoidboard_boot_order(u32 *spl_boot_list){ spl_boot_list[0] = spl_boot_device(); }which is exactly what we pass to
spl_boot_mode()... so instead callingspl_boot_device()twice we can use the passedboot_device... and save the ifdef and newKconfigoption.But may I oversee something ?
Quoted 7 lines
Quoted 2 lines
Please read the Stefano's reply from [1] - the
spl_boot_device()has a valid use cases as well.Nevertheless, why do we need to add a new compiler switch if this can be check into board code ? You just need that
spl_boot_device()returns the device you want (MMC for falcon boot).Current status:
git grep -n "
spl_boot_mode" | grep weak common/spl/spl_mmc.c:287:u32__weakspl_boot_mode(const u32 boot_device)git grep -n "
board_boot_order" | grep weak common/spl/spl.c:491:__weak voidboard_boot_order(u32 *spl_boot_list)The
spl_boot_device()is defined inarch/arm/mach-imx/spl.c[*] as a NON__weakfunction:
git grep -n "spl_boot_device" | grep weakShall I make this function [*] as
__weakand provide override for it in the board file?The problem is in the call of
spl_boot_mode()(which is overridden already inarch/arm/mach-imx/spl.c) atcommon/spl/spl_mmc.cWhich then calls
spl_boot_device()[**], which may return (correctly) SPI-NOR for eMMC.Quoted 7 lines
As is now
spl_boot_device()is not a__weakfunction.Quoted 2 lines
Why do you need to
force it in this way ?The option is to use the proposed patch to make
spl_boot_deviceas a weak function.The above text is a bit misleading - better version below.
The solution would be:
Quoted 8 lines
Quoted 6 lines
1. Use the proposed patch (with
Kconfigoption)2. Define
spl_boot_deviceas weak and override it in board file. However, it is not the preferred solution asspl_boot_device()
on my setup correctly returns SPI-NOR (as SOC ROM loads SPL from SPI-NOR, not eMMC).Ok, but is a wek not thought for this purpose ?
Making the spl_boot_device() __weak would be a fix only for a specific appearance of spl_boot_device() in arch/arm/mach-imx/spl.c (L178):
------------------>8--------------------------
#if defined(CONFIG_SPL_MMC_SUPPORT)
/* called from spl_mmc to see type of boot mode for storage (RAW or FAT) */ u32 spl_boot_mode(const u32 boot_device)
{
switch (spl_boot_device()) {
/* for MMC return either RAW or FAT mode */------------------8<--------------------------
The above code is only executed when SPL_MMC_SUPPORT is enabled and IMHO the spl_boot_device() call assumes that one boots up from eMMC (but not from SPI-NOR).
I'm (in a first place) curious if this code is correct - the boot_device is passed as a parameter to this function, but then it is ignored.
Quoted 6 lines
If it is weak, you can
change it and decide to return the device you want. You could also check if Falco boot is enabled, at compile time withCONFIG_SPL_OS_BOOTor at runtime withspl_start_uboot(). Should it not be enough ?
Quoted 87 lines
Regards,
StefanoQuoted 82 lines
Quoted 61 lines
Quoted 56 lines
Regards,
StefanoQuoted 48 lines
Quoted 13 lines
Quoted 13 lines
/* for MMC return either RAW or FAT mode */ case
BOOT_DEVICE_MMC1:
caseBOOT_DEVICE_MMC2:common/spl/Kconfig +0
-0@@ -607,6 +607,13 @@ config SPL_MMC_SUPPORT this option to build the drivers in drivers/mmc aspart of an SPL build.
Quoted 10 lines
Quoted 7 lines
common/spl/Kconfig +6
-0+config SPL_FORCE_MMC_BOOT + bool "Force SPL's falcon boot from MMC" + depends on SPL_MMC_SUPPORT + default n + help + Force SPL's falcon boot to use MMC device for Linuxkernel booting.
Hmm... falcon boot is just one use case. I would drop "falcon boot" It just to force boot from MMC.
Ok. I will rewrite the help message.
Quoted 9 lines
Quoted 6 lines
+
configSPL_MMC_TINY
bool "Tiny MMC framework in SPL"
depends onSPL_MMC_SUPPORTbye,
HeikoBest regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang
Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax:
(+49)-8142-66989-80 Email: lukma at denx.deBest regards,
Quoted 8 lines
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang
Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
lukma at denx.deBest regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang
Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
lukma at denx.de
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190905/c8916b4d/attachment.sig>
PATCH 1/1 imx: Introduce CONFIG_SPL_FORCE_MMC_BOOT to force MMC boot on falcon mode
Hello Lukasz,
Am 05.09.2019 um 11:42 schrieb Lukasz Majewski:
Quoted 205 lines
Hi Stefano,
Quoted 186 lines · Lukasz Majewski
Quoted 185 lines
Quoted 170 lines · On Wed, 4 Sep 2019 11:54:40 +0200 Lukasz Majewski <[email protected]> wrote:
Hi Stefano, Heiko,
Quoted 131 lines · Lukasz Majewski
Quoted 130 lines
Hi Heiko,
Quoted 3 lines
Hello Lukasz,
added Stefano to cc as he is the imx custodian.
I've relied on patman ... Thanks for adding Stefano to CC.
Quoted 27 lines
Am 03.09.2019 um 23:43 schrieb Lukasz Majewski:
Quoted 25 lines
This change tries to fix the following problem:
- The board boots (to be more precise - ROM loads SPL) from a slow SPI-NOR memory.
As a result thespl_boot_device()will return SPI-NOR as a
boot device (which is correct).- The problem is that in 'falcon boot' the eMMC is used as a boot medium to load kernel from its partition. Calling
spl_boot_device()will break things as it returns
SPI-NOR device.To fix this issue the new
CONFIG_SPL_FORCE_MMC_BOOTKconfigflag is introduced to handle this special use case. By default it is not defined, so there is no change in the legacy code flow.Signed-off-by Lukasz Majewski <[email protected]>---
This patch is a follow up of previous discussion/fix:
https://patchwork.ozlabs.org/patch/796237/Quoted 8 lines
Quoted 6 lines
Travis-CI:
https://travis-ci.org/lmajewski/u-boot-dfu/builds/580272414--- arch/arm/mach-imx/spl.c | 11 +++++++++++ common/spl/Kconfig | 7 +++++++ 2 files changed, 18 insertions(+)I have just similiar change for an imx6ull based board ...
Also one more of my boards uses this trick (i.MX28 based one).
Quoted 4 lines
just antoher usecase: In factory empty board boots into USB SDP mode, and SPL gets loaded with
usb_loader... SPL detects a sd card (there is no sd card slot mounted, mmc boot is disabled! They attach only one for installing software)So there is no dedicated SD card slot (also the mmc is disabled on that point).
Instead, in the factory the sd card is attached to pads - just for this time.Quoted 3 lines
and boots U-Boot and system from sd card.
Than all software gets installed fully automated with the help of swupdate ...Ok.
Quoted 19 lines
Quoted 19 lines
arch/arm/mach-imx/spl.c +0
-0@@ -178,7 +178,18 @@ int g_dnl_bind_fixup(struct
usb_device_descriptor*dev, const char *name) /* called fromspl_mmcto see type of boot mode for storage (RAW or FAT) */ u32spl_boot_mode(const u32 boot_device){
+/*
+ * WhenCONFIG_SPL_FORCE_MMC_BOOTis defined the 'boot_device' is used
+ * unconditionally to decide about device to use for booting.
+ * This is crucial for falcon boot mode, when board boots up (i.e. ROM
+ * loads SPL) from slow SPI-NOR memory and afterwards the SPL's 'falcon' boot
+ * mode is used to load Linux OS from eMMC partition.
+ */Quoted 8 lines
arch/arm/mach-imx/spl.c
Quoted 5 lines
arch/arm/mach-imx/spl.c +4
-0+#ifdef CONFIG_SPL_FORCE_MMC_BOOT +switch (boot_device) { +#else switch (spl_boot_device ()) { +#endif Just dummy question .. couldn;t we switch to use always
boot_device?Stefano has provided some rationale for the need of
spl_boot_device()in the previous version of this fix [1]:https://patchwork.ozlabs.org/patch/796237/
Quoted 4 lines
In my case I had a board specific:
void
board_boot_order(u32 *spl_boot_list)Quoted 9 lines
{ spl_boot_list[0] = BOOT_DEVICE_MMC1; spl_boot_list[1] = BOOT_DEVICE_SPI; spl_boot_list[2] = BOOT_DEVICE_BOARD; spl_boot_list[3] = BOOT_DEVICE_NONE; }which leads that
BOOT_DEVICE_MMC1is passed tospl_boot_mode()Is your board normally booting from MMC or SPI-NOR (from where SoC ROM loads SPL) ?
Quoted 16 lines
If MMC1 is not found, it tries to boot U-Boot from SPI, and if this is empty, as fallback board go into USB SDP mode.
The weak function of
board_boot_orderis:
__weakvoidboard_boot_order(u32 *spl_boot_list){ spl_boot_list[0] = spl_boot_device(); }which is exactly what we pass to
spl_boot_mode()... so instead callingspl_boot_device()twice we can use the passedboot_device... and save the ifdef and newKconfigoption.But may I oversee something ?
Quoted 7 lines
Quoted 2 lines
Please read the Stefano's reply from [1] - the
spl_boot_device()has a valid use cases as well.Nevertheless, why do we need to add a new compiler switch if this can be check into board code ? You just need that
spl_boot_device()returns the device you want (MMC for falcon boot).Current status:
git grep -n "
spl_boot_mode" | grep weak common/spl/spl_mmc.c:287:u32__weakspl_boot_mode(const u32 boot_device)git grep -n "
board_boot_order" | grep weak common/spl/spl.c:491:__weak voidboard_boot_order(u32 *spl_boot_list)The
spl_boot_device()is defined inarch/arm/mach-imx/spl.c[*] as a NON__weakfunction:
git grep -n "spl_boot_device" | grep weakShall I make this function [*] as
__weakand provide override for it in the board file?The problem is in the call of
spl_boot_mode()(which is overridden already inarch/arm/mach-imx/spl.c) atcommon/spl/spl_mmc.cWhich then calls
spl_boot_device()[**], which may return (correctly) SPI-NOR for eMMC.Quoted 7 lines
As is now
spl_boot_device()is not a__weakfunction.Quoted 2 lines
Why do you need to
force it in this way ?The option is to use the proposed patch to make
spl_boot_deviceas a weak function.The above text is a bit misleading - better version below.
The solution would be:
Quoted 8 lines
Quoted 6 lines
1. Use the proposed patch (with
Kconfigoption)2. Define
spl_boot_deviceas weak and override it in board file. However, it is not the preferred solution asspl_boot_device()
on my setup correctly returns SPI-NOR (as SOC ROM loads SPL from SPI-NOR, not eMMC).Ok, but is a wek not thought for this purpose ?
Making the
spl_boot_device()__weakwould be a fix only for a specific appearance ofspl_boot_device()inarch/arm/mach-imx/spl.c(L178):------------------>8--------------------------
#ifdefined(CONFIG_SPL_MMC_SUPPORT)/* called from
spl_mmcto see type of boot mode for storage (RAW or FAT) */ u32spl_boot_mode(const u32 boot_device)
Quoted 8 lines
{ switch (spl_boot_device()) { /* for MMC return either RAW or FAT mode */------------------8<--------------------------
The above code is only executed when
SPL_MMC_SUPPORTis enabled and IMHO thespl_boot_device()call assumes that one boots up from eMMC (but not from SPI-NOR).
Indeed, it is not that easy ... so forget my previous commment.
Quoted 2 lines
I'm (in a first place) curious if this code is correct - the
boot_deviceis passed as a parameter to this function, but then it is ignored.
Yes, that was also my first thought, so I simply replaced
arch/arm/mach-imx/spl.c +1 -1
@@ -178,7 +178,7 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)/* called from spl_mmc to see type of boot mode for storage (RAW or FAT) */ u32 spl_boot_mode (const u32 boot_device) { -switch (spl_boot_device ()) { +switch (boot_device) {/* for MMC return either RAW or FAT mode */ case BOOT_DEVICE_MMC1 :case BOOT_DEVICE_MMC2 :
but I see Stefanos arguments:
https://patchwork.ozlabs.org/patch/796237/#1735852
So your current patch seems the best solution for me ...
bye,
Heiko
Quoted 108 lines
Quoted 95 lines
If it is weak, you can
change it and decide to return the device you want. You could also check if Falco boot is enabled, at compile time withCONFIG_SPL_OS_BOOTor at runtime withspl_start_uboot(). Should it not be enough ?Regards,
StefanoQuoted 82 lines
Quoted 61 lines
Quoted 56 lines
Regards,
StefanoQuoted 48 lines
Quoted 13 lines
Quoted 13 lines
/* for MMC return either RAW or FAT mode */ case BOOT_DEVICE_MMC1: case BOOT_DEVICE_MMC2:common/spl/Kconfig +0
-0@@ -607,6 +607,13 @@ config SPL_MMC_SUPPORT this option to build the drivers in drivers/mmc aspart of an SPL build.
Quoted 10 lines
Quoted 7 lines
common/spl/Kconfig +6
-0+config SPL_FORCE_MMC_BOOT + bool "Force SPL's falcon boot from MMC" + depends on SPL_MMC_SUPPORT + default n + help + Force SPL's falcon boot to use MMC device for Linuxkernel booting.
Hmm... falcon boot is just one use case. I would drop "falcon boot" It just to force boot from MMC.
Ok. I will rewrite the help message.
Quoted 9 lines
Quoted 6 lines
+
configSPL_MMC_TINY
bool "Tiny MMC framework in SPL"
depends onSPL_MMC_SUPPORTbye,
HeikoBest regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang
Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax:
(+49)-8142-66989-80 Email: lukma at denx.deBest regards,
Quoted 8 lines
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang
Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
lukma at denx.deBest regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang
Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
lukma at denx.deBest regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH 1/1 imx: Introduce CONFIG_SPL_FORCE_MMC_BOOT to force MMC boot on falcon mode
Hi Heiko, Stefano
Quoted 241 lines
Hello Lukasz,
Am 05.09.2019 um 11:42 schrieb Lukasz Majewski:
Quoted 207 lines
Hi Stefano,
Quoted 188 lines · Lukasz Majewski
Quoted 187 lines
Quoted 172 lines · On Wed, 4 Sep 2019 11:54:40 +0200 Lukasz Majewski <[email protected]> wrote:
Hi Stefano, Heiko,
Quoted 132 lines · Lukasz Majewski
Quoted 131 lines
Hi Heiko,
Quoted 3 lines
Hello Lukasz,
added Stefano to cc as he is the imx custodian.
I've relied on patman ... Thanks for adding Stefano to CC.
Quoted 27 lines
Am 03.09.2019 um 23:43 schrieb Lukasz Majewski:
Quoted 25 lines
This change tries to fix the following problem:
- The board boots (to be more precise - ROM loads SPL) from a slow SPI-NOR memory.
As a result thespl_boot_device()will return SPI-NOR as
a boot device (which is correct).- The problem is that in 'falcon boot' the eMMC is used as a boot medium to load kernel from its partition. Calling
spl_boot_device()will break things as it returns
SPI-NOR device.To fix this issue the new
CONFIG_SPL_FORCE_MMC_BOOTKconfigflag is introduced to handle this special use case. By default it is not defined, so there is no change in the legacy code flow.Signed-off-by Lukasz Majewski <[email protected]>---
This patch is a follow up of previous discussion/fix:
https://patchwork.ozlabs.org/patch/796237/Quoted 8 lines
Quoted 6 lines
Travis-CI:
https://travis-ci.org/lmajewski/u-boot-dfu/builds/580272414--- arch/arm/mach-imx/spl.c | 11 +++++++++++ common/spl/Kconfig | 7 +++++++ 2 files changed, 18 insertions(+)I have just similiar change for an imx6ull based board ...
Also one more of my boards uses this trick (i.MX28 based one).
Quoted 4 lines
just antoher usecase: In factory empty board boots into USB SDP mode, and SPL gets loaded with
usb_loader... SPL detects a sd card (there is no sd card slot mounted, mmc boot is disabled! They attach only one for installing software)So there is no dedicated SD card slot (also the mmc is disabled on that point).
Instead, in the factory the sd card is attached to pads - just for this time.Quoted 3 lines
and boots U-Boot and system from sd card.
Than all software gets installed fully automated with the help of swupdate ...Ok.
Quoted 20 lines
Quoted 20 lines
(quoted diff) +0
-0
b/arch/arm/mach-imx/spl.cindex1f230aca3397..daa3d8f7ed94100644 ---a/arch/arm/mach-imx/spl.c
+++b/arch/arm/mach-imx/spl.c(quoted diff) +0
-0@@ -178,7 +178,18 @@ int g_dnl_bind_fixup(struct
usb_device_descriptor*dev, const char *name) /* called fromspl_mmcto see type of boot mode for storage (RAW or FAT) */ u32spl_boot_mode(const u32 boot_device){
+/*
+ * WhenCONFIG_SPL_FORCE_MMC_BOOTis defined the 'boot_device' is used
+ * unconditionally to decide about device to use for booting.
+ * This is crucial for falcon boot mode, when board boots up (i.e. ROM
+ * loads SPL) from slow SPI-NOR memory and afterwards the SPL's 'falcon' boot
+ * mode is used to load Linux OS from eMMC partition.
+ */Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +4
-0+#ifdef CONFIG_SPL_FORCE_MMC_BOOT + switch (boot_device) { +#else switch (spl_boot_device()) { +#endifJust dummy question .. couldn;t we switch to use always
boot_device?Stefano has provided some rationale for the need of
spl_boot_device()in the previous version of this fix [1]:https://patchwork.ozlabs.org/patch/796237/
Quoted 4 lines
In my case I had a board specific:
void
board_boot_order(u32 *spl_boot_list)Quoted 9 lines
{ spl_boot_list[0] = BOOT_DEVICE_MMC1; spl_boot_list[1] = BOOT_DEVICE_SPI; spl_boot_list[2] = BOOT_DEVICE_BOARD; spl_boot_list[3] = BOOT_DEVICE_NONE; }which leads that
BOOT_DEVICE_MMC1is passed tospl_boot_mode()Is your board normally booting from MMC or SPI-NOR (from where SoC ROM loads SPL) ?
Quoted 16 lines
If MMC1 is not found, it tries to boot U-Boot from SPI, and if this is empty, as fallback board go into USB SDP mode.
The weak function of
board_boot_orderis:
__weakvoidboard_boot_order(u32 *spl_boot_list){ spl_boot_list[0] = spl_boot_device(); }which is exactly what we pass to
spl_boot_mode()... so instead callingspl_boot_device()twice we can use the passedboot_device... and save the ifdef and newKconfigoption.But may I oversee something ?
Quoted 7 lines
Quoted 2 lines
Please read the Stefano's reply from [1] - the
spl_boot_device()has a valid use cases as well.Nevertheless, why do we need to add a new compiler switch if this can be check into board code ? You just need that
spl_boot_device()returns the device you want (MMC for falcon boot).Current status:
git grep -n "
spl_boot_mode" | grep weak common/spl/spl_mmc.c:287:u32__weakspl_boot_mode(const u32 boot_device)git grep -n "
board_boot_order" | grep weak common/spl/spl.c:491:__weak voidboard_boot_order(u32 *spl_boot_list)The
spl_boot_device()is defined inarch/arm/mach-imx/spl.c[*] as a NON__weakfunction:
git grep -n "spl_boot_device" | grep weakShall I make this function [*] as
__weakand provide override for it in the board file?The problem is in the call of
spl_boot_mode()(which is overridden already inarch/arm/mach-imx/spl.c) atcommon/spl/spl_mmc.cWhich then calls
spl_boot_device()[**], which may return (correctly) SPI-NOR for eMMC.Quoted 7 lines
As is now
spl_boot_device()is not a__weakfunction.Quoted 2 lines
Why do you need to
force it in this way ?The option is to use the proposed patch to make
spl_boot_deviceas a weak function.The above text is a bit misleading - better version below.
The solution would be:
Quoted 8 lines
Quoted 6 lines
1. Use the proposed patch (with
Kconfigoption)2. Define
spl_boot_deviceas weak and override it in board file. However, it is not the preferred solution asspl_boot_device()
on my setup correctly returns SPI-NOR (as SOC ROM loads SPL from SPI-NOR, not eMMC).Ok, but is a wek not thought for this purpose ?
Making the
spl_boot_device()__weakwould be a fix only for a specific appearance ofspl_boot_device()inarch/arm/mach-imx/spl.c(L178):
------------------>8--------------------------
#ifdefined(CONFIG_SPL_MMC_SUPPORT)/* called from
spl_mmcto see type of boot mode for storage (RAW or FAT) */ u32spl_boot_mode(const u32 boot_device)Quoted 8 lines
{ switch (spl_boot_device()) { /* for MMC return either RAW or FAT mode */------------------8<--------------------------
The above code is only executed when
SPL_MMC_SUPPORTis enabled and IMHO thespl_boot_device()call assumes that one boots up from eMMC (but not from SPI-NOR).Indeed, it is not that easy ... so forget my previous commment.
Quoted 3 lines
I'm (in a first place) curious if this code is correct - the
boot_deviceis passed as a parameter to this function, but then it is ignored.Yes, that was also my first thought, so I simply replaced
arch/arm/mach-imx/spl.c +0
-0@@ -178,7 +178,7 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) /* called from spl_mmc to see type of bootmode for storage (RAW or FAT) */ u32
spl_boot_mode(const u32 boot_device){arch/arm/mach-imx/spl.c +1
-1-switch (spl_boot_device ()) { +switch (boot_device) {/* for MMC return either RAW or FAT mode */ case BOOT_DEVICE_MMC1 :case BOOT_DEVICE_MMC2 :
Quoted 5 lines
but I see Stefanos arguments:
https://patchwork.ozlabs.org/patch/796237/#1735852So your current patch seems the best solution for me ...
Can I assume that we do have a consensus here?
If yes - I will prepare v2 of this patch taking in the comments regarding Heiko's production flashing comments.
Quoted 113 lines
bye,
HeikoQuoted 108 lines
Quoted 95 lines
If it is weak, you can
change it and decide to return the device you want. You could also check if Falco boot is enabled, at compile time withCONFIG_SPL_OS_BOOTor at runtime withspl_start_uboot(). Should it not be enough ?Regards,
StefanoQuoted 82 lines
Quoted 61 lines
Quoted 56 lines
Regards,
StefanoQuoted 48 lines
Quoted 13 lines
Quoted 13 lines
/* for MMC return either RAW or FAT mode */ case BOOT_DEVICE_MMC1: case BOOT_DEVICE_MMC2:common/spl/Kconfig +0
-0@@ -607,6 +607,13 @@ config SPL_MMC_SUPPORT this option to build the drivers in drivers/mmcas part of an SPL build.
Quoted 10 lines
Quoted 7 lines
common/spl/Kconfig +6
-0+config SPL_FORCE_MMC_BOOT + bool "Force SPL's falcon boot from MMC" + depends on SPL_MMC_SUPPORT + default n + help + Force SPL's falcon boot to use MMC device forLinux kernel booting.
Hmm... falcon boot is just one use case. I would drop "falcon boot" It just to force boot from MMC.
Ok. I will rewrite the help message.
Quoted 9 lines
Quoted 6 lines
+
configSPL_MMC_TINY
bool "Tiny MMC framework in SPL"
depends onSPL_MMC_SUPPORTbye,
HeikoBest regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director:
Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax:
(+49)-8142-66989-80 Email: lukma at denx.deBest regards,
Quoted 8 lines
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang
Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax:
(+49)-8142-66989-80 Email: lukma at denx.deBest regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang
Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
lukma at denx.deBest regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang
Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
lukma at denx.de
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190909/b6a952d9/attachment.sig>
PATCH 1/1 imx: Introduce CONFIG_SPL_FORCE_MMC_BOOT to force MMC boot on falcon mode
Quoted 246 lines · Lukasz Majewski
Hi Heiko, Stefano
Quoted 244 lines
Hello Lukasz,
Am 05.09.2019 um 11:42 schrieb Lukasz Majewski:
Quoted 207 lines
Hi Stefano,
Quoted 188 lines · Lukasz Majewski
Quoted 187 lines
Quoted 172 lines · On Wed, 4 Sep 2019 11:54:40 +0200 Lukasz Majewski <[email protected]> wrote:
Hi Stefano, Heiko,
Quoted 132 lines · Lukasz Majewski
Quoted 131 lines
Hi Heiko,
Quoted 3 lines
Hello Lukasz,
added Stefano to cc as he is the imx custodian.
I've relied on patman ... Thanks for adding Stefano to CC.
Quoted 27 lines
Am 03.09.2019 um 23:43 schrieb Lukasz Majewski:
Quoted 25 lines
This change tries to fix the following problem:
- The board boots (to be more precise - ROM loads SPL) from a slow SPI-NOR memory.
As a result thespl_boot_device()will return SPI-NOR as
a boot device (which is correct).- The problem is that in 'falcon boot' the eMMC is used as a boot medium to load kernel from its partition. Calling
spl_boot_device()will break things as it returns
SPI-NOR device.To fix this issue the new
CONFIG_SPL_FORCE_MMC_BOOTKconfigflag is introduced to handle this special use case. By default it is not defined, so there is no change in the legacy code flow.Signed-off-by Lukasz Majewski <[email protected]>---
This patch is a follow up of previous discussion/fix:
https://patchwork.ozlabs.org/patch/796237/Quoted 8 lines
Quoted 6 lines
Travis-CI:
https://travis-ci.org/lmajewski/u-boot-dfu/builds/580272414--- arch/arm/mach-imx/spl.c | 11 +++++++++++ common/spl/Kconfig | 7 +++++++ 2 files changed, 18 insertions(+)I have just similiar change for an imx6ull based board ...
Also one more of my boards uses this trick (i.MX28 based one).
Quoted 4 lines
just antoher usecase: In factory empty board boots into USB SDP mode, and SPL gets loaded with
usb_loader... SPL detects a sd card (there is no sd card slot mounted, mmc boot is disabled! They attach only one for installing software)So there is no dedicated SD card slot (also the mmc is disabled on that point).
Instead, in the factory the sd card is attached to pads - just for this time.Quoted 3 lines
and boots U-Boot and system from sd card.
Than all software gets installed fully automated with the help of swupdate ...Ok.
Quoted 20 lines
Quoted 20 lines
(quoted diff) +0
-0
b/arch/arm/mach-imx/spl.cindex1f230aca3397..daa3d8f7ed94100644 ---a/arch/arm/mach-imx/spl.c
+++b/arch/arm/mach-imx/spl.c(quoted diff) +0
-0@@ -178,7 +178,18 @@ int g_dnl_bind_fixup(struct
usb_device_descriptor*dev, const char *name) /* called fromspl_mmcto see type of boot mode for storage (RAW or FAT) */ u32spl_boot_mode(const u32 boot_device){
+/*
+ * WhenCONFIG_SPL_FORCE_MMC_BOOTis defined the 'boot_device' is used
+ * unconditionally to decide about device to use for booting.
+ * This is crucial for falcon boot mode, when board boots up (i.e. ROM
+ * loads SPL) from slow SPI-NOR memory and afterwards the SPL's 'falcon' boot
+ * mode is used to load Linux OS from eMMC partition.
+ */Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +4
-0+#ifdef CONFIG_SPL_FORCE_MMC_BOOT + switch (boot_device) { +#else switch (spl_boot_device()) { +#endifJust dummy question .. couldn;t we switch to use always
boot_device?Stefano has provided some rationale for the need of
spl_boot_device()in the previous version of this fix [1]:https://patchwork.ozlabs.org/patch/796237/
Quoted 4 lines
In my case I had a board specific:
void
board_boot_order(u32 *spl_boot_list)Quoted 9 lines
{ spl_boot_list[0] = BOOT_DEVICE_MMC1; spl_boot_list[1] = BOOT_DEVICE_SPI; spl_boot_list[2] = BOOT_DEVICE_BOARD; spl_boot_list[3] = BOOT_DEVICE_NONE; }which leads that
BOOT_DEVICE_MMC1is passed tospl_boot_mode()Is your board normally booting from MMC or SPI-NOR (from where SoC ROM loads SPL) ?
Quoted 16 lines
If MMC1 is not found, it tries to boot U-Boot from SPI, and if this is empty, as fallback board go into USB SDP mode.
The weak function of
board_boot_orderis:
__weakvoidboard_boot_order(u32 *spl_boot_list){ spl_boot_list[0] = spl_boot_device(); }which is exactly what we pass to
spl_boot_mode()... so instead callingspl_boot_device()twice we can use the passedboot_device... and save the ifdef and newKconfigoption.But may I oversee something ?
Quoted 7 lines
Quoted 2 lines
Please read the Stefano's reply from [1] - the
spl_boot_device()has a valid use cases as well.Nevertheless, why do we need to add a new compiler switch if this can be check into board code ? You just need that
spl_boot_device()returns the device you want (MMC for falcon boot).Current status:
git grep -n "
spl_boot_mode" | grep weak common/spl/spl_mmc.c:287:u32__weakspl_boot_mode(const u32 boot_device)git grep -n "
board_boot_order" | grep weak common/spl/spl.c:491:__weak voidboard_boot_order(u32 *spl_boot_list)The
spl_boot_device()is defined inarch/arm/mach-imx/spl.c[*] as a NON__weakfunction:
git grep -n "spl_boot_device" | grep weakShall I make this function [*] as
__weakand provide override for it in the board file?The problem is in the call of
spl_boot_mode()(which is overridden already inarch/arm/mach-imx/spl.c) atcommon/spl/spl_mmc.cWhich then calls
spl_boot_device()[**], which may return (correctly) SPI-NOR for eMMC.Quoted 7 lines
As is now
spl_boot_device()is not a__weakfunction.Quoted 2 lines
Why do you need to
force it in this way ?The option is to use the proposed patch to make
spl_boot_deviceas a weak function.The above text is a bit misleading - better version below.
The solution would be:
Quoted 8 lines
Quoted 6 lines
1. Use the proposed patch (with
Kconfigoption)2. Define
spl_boot_deviceas weak and override it in board file. However, it is not the preferred solution asspl_boot_device()
on my setup correctly returns SPI-NOR (as SOC ROM loads SPL from SPI-NOR, not eMMC).Ok, but is a wek not thought for this purpose ?
Making the
spl_boot_device()__weakwould be a fix only for a specific appearance ofspl_boot_device()inarch/arm/mach-imx/spl.c(L178):
------------------>8--------------------------
#ifdefined(CONFIG_SPL_MMC_SUPPORT)/* called from
spl_mmcto see type of boot mode for storage (RAW or FAT) */ u32spl_boot_mode(const u32 boot_device)Quoted 8 lines
{ switch (spl_boot_device()) { /* for MMC return either RAW or FAT mode */------------------8<--------------------------
The above code is only executed when
SPL_MMC_SUPPORTis enabled and IMHO thespl_boot_device()call assumes that one boots up from eMMC (but not from SPI-NOR).Indeed, it is not that easy ... so forget my previous commment.
Quoted 3 lines
I'm (in a first place) curious if this code is correct - the
boot_deviceis passed as a parameter to this function, but then it is ignored.Yes, that was also my first thought, so I simply replaced
arch/arm/mach-imx/spl.c +0
-0@@ -178,7 +178,7 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) /* called from spl_mmc to see type of bootmode for storage (RAW or FAT) */ u32
spl_boot_mode(const u32 boot_device){arch/arm/mach-imx/spl.c +1
-1-switch (spl_boot_device ()) { +switch (boot_device) {/* for MMC return either RAW or FAT mode */ case BOOT_DEVICE_MMC1 :case BOOT_DEVICE_MMC2 :but I see Stefanos arguments:
https://patchwork.ozlabs.org/patch/796237/#1735852
Quoted 7 lines
Quoted 2 lines
So your current patch seems the best solution for me ...
Can I assume that we do have a consensus here?
If yes - I will prepare v2 of this patch taking in the comments regarding Heiko's production flashing comments.
ok, fine.
Regards,
Stefano
Quoted 127 lines
Quoted 114 lines
bye,
HeikoQuoted 108 lines
Quoted 95 lines
If it is weak, you can
change it and decide to return the device you want. You could also check if Falco boot is enabled, at compile time withCONFIG_SPL_OS_BOOTor at runtime withspl_start_uboot(). Should it not be enough ?Regards,
StefanoQuoted 82 lines
Quoted 61 lines
Quoted 56 lines
Regards,
StefanoQuoted 48 lines
Quoted 13 lines
Quoted 13 lines
/* for MMC return either RAW or FAT mode */ case BOOT_DEVICE_MMC1: case BOOT_DEVICE_MMC2:common/spl/Kconfig +0
-0@@ -607,6 +607,13 @@ config SPL_MMC_SUPPORT this option to build the drivers in drivers/mmcas part of an SPL build.
Quoted 10 lines
Quoted 7 lines
common/spl/Kconfig +6
-0+config SPL_FORCE_MMC_BOOT + bool "Force SPL's falcon boot from MMC" + depends on SPL_MMC_SUPPORT + default n + help + Force SPL's falcon boot to use MMC device forLinux kernel booting.
Hmm... falcon boot is just one use case. I would drop "falcon boot" It just to force boot from MMC.
Ok. I will rewrite the help message.
Quoted 9 lines
Quoted 6 lines
+
configSPL_MMC_TINY
bool "Tiny MMC framework in SPL"
depends onSPL_MMC_SUPPORTbye,
HeikoBest regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director:
Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax:
(+49)-8142-66989-80 Email: lukma at denx.deBest regards,
Quoted 8 lines
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang
Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax:
(+49)-8142-66989-80 Email: lukma at denx.deBest regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang
Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
lukma at denx.deBest regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang
Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
lukma at denx.deBest regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
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 =====================================================================
PATCH 1/1 imx: Introduce CONFIG_SPL_FORCE_MMC_BOOT to force MMC boot on falcon mode
In reply to Stefano BabicHello Stefano, Lukasz,
Am 05.09.2019 um 10:08 schrieb Stefano Babic:
Quoted 190 lines · Lukasz Majewski
Quoted 180 lines
Quoted 167 lines · On Wed, 4 Sep 2019 11:54:40 +0200 Lukasz Majewski <[email protected]> wrote:
Hi Stefano, Heiko,
Quoted 128 lines · Lukasz Majewski
Quoted 127 lines
Hi Heiko,
Quoted 3 lines
Hello Lukasz,
added Stefano to cc as he is the imx custodian.
I've relied on patman ... Thanks for adding Stefano to CC.
Quoted 26 lines
Am 03.09.2019 um 23:43 schrieb Lukasz Majewski:
Quoted 24 lines
This change tries to fix the following problem:
- The board boots (to be more precise - ROM loads SPL) from a slow SPI-NOR memory.
As a result thespl_boot_device()will return SPI-NOR as a
boot device (which is correct).- The problem is that in 'falcon boot' the eMMC is used as a boot medium to load kernel from its partition. Calling
spl_boot_device()will break things as it returns
SPI-NOR device.To fix this issue the new
CONFIG_SPL_FORCE_MMC_BOOTKconfigflag is introduced to handle this special use case. By default it is not defined, so there is no change in the legacy code flow.Signed-off-by Lukasz Majewski <[email protected]>---
This patch is a follow up of previous discussion/fix:
https://patchwork.ozlabs.org/patch/796237/Quoted 8 lines
Quoted 6 lines
Travis-CI:
https://travis-ci.org/lmajewski/u-boot-dfu/builds/580272414--- arch/arm/mach-imx/spl.c | 11 +++++++++++ common/spl/Kconfig | 7 +++++++ 2 files changed, 18 insertions(+)I have just similiar change for an imx6ull based board ...
Also one more of my boards uses this trick (i.MX28 based one).
Quoted 4 lines
just antoher usecase: In factory empty board boots into USB SDP mode, and SPL gets loaded with
usb_loader... SPL detects a sd card (there is no sd card slot mounted, mmc boot is disabled! They attach only one for installing software)So there is no dedicated SD card slot (also the mmc is disabled on that point).
Instead, in the factory the sd card is attached to pads - just for this time.Quoted 3 lines
and boots U-Boot and system from sd card.
Than all software gets installed fully automated with the help of swupdate ...Ok.
Quoted 19 lines
Quoted 19 lines
arch/arm/mach-imx/spl.c +0
-0@@ -178,7 +178,18 @@ int g_dnl_bind_fixup(struct
usb_device_descriptor*dev, const char *name) /* called fromspl_mmcto see type of boot mode for storage (RAW or FAT) */ u32spl_boot_mode(const u32 boot_device){
+/*
+ * WhenCONFIG_SPL_FORCE_MMC_BOOTis defined the 'boot_device' is used
+ * unconditionally to decide about device to use for booting.
+ * This is crucial for falcon boot mode, when board boots up (i.e. ROM
+ * loads SPL) from slow SPI-NOR memory and afterwards the SPL's 'falcon' boot
+ * mode is used to load Linux OS from eMMC partition.
+ */Quoted 8 lines
arch/arm/mach-imx/spl.c
Quoted 5 lines
arch/arm/mach-imx/spl.c +4
-0+#ifdef CONFIG_SPL_FORCE_MMC_BOOT +switch (boot_device) { +#else switch (spl_boot_device ()) { +#endif Just dummy question .. couldn;t we switch to use always
boot_device?Stefano has provided some rationale for the need of
spl_boot_device()in the previous version of this fix [1]:https://patchwork.ozlabs.org/patch/796237/
Quoted 4 lines
In my case I had a board specific:
void
board_boot_order(u32 *spl_boot_list)Quoted 9 lines
{ spl_boot_list[0] = BOOT_DEVICE_MMC1; spl_boot_list[1] = BOOT_DEVICE_SPI; spl_boot_list[2] = BOOT_DEVICE_BOARD; spl_boot_list[3] = BOOT_DEVICE_NONE; }which leads that
BOOT_DEVICE_MMC1is passed tospl_boot_mode()Is your board normally booting from MMC or SPI-NOR (from where SoC ROM loads SPL) ?
Quoted 15 lines
If MMC1 is not found, it tries to boot U-Boot from SPI, and if this is empty, as fallback board go into USB SDP mode.
The weak function of
board_boot_orderis:
__weakvoidboard_boot_order(u32 *spl_boot_list){ spl_boot_list[0] = spl_boot_device(); }which is exactly what we pass to
spl_boot_mode()... so instead callingspl_boot_device()twice we can use the passedboot_device... and save the ifdef and newKconfigoption.Quoted 8 lines
Quoted 4 lines
Quoted 1 line
But may I oversee something ?
Please read the Stefano's reply from [1] - the
spl_boot_device()has a valid use cases as well.Nevertheless, why do we need to add a new compiler switch if this can be check into board code ? You just need that
spl_boot_device()returns the device you want (MMC for falcon boot).Current status:
git grep -n "
spl_boot_mode" | grep weak common/spl/spl_mmc.c:287:u32__weakspl_boot_mode(const u32 boot_device)git grep -n "
board_boot_order" | grep weak common/spl/spl.c:491:__weak voidboard_boot_order(u32 *spl_boot_list)The
spl_boot_device()is defined inarch/arm/mach-imx/spl.c[*] as a NON__weakfunction:
git grep -n "spl_boot_device" | grep weakShall I make this function [*] as
__weakand provide override for it in the board file?The problem is in the call of
spl_boot_mode()(which is overridden already inarch/arm/mach-imx/spl.c) atcommon/spl/spl_mmc.cWhich then calls
spl_boot_device()[**], which may return (correctly) SPI-NOR for eMMC.Quoted 7 lines
As is now
spl_boot_device()is not a__weakfunction.Quoted 2 lines
Why do you need to
force it in this way ?The option is to use the proposed patch to make
spl_boot_deviceas a weak function.The above text is a bit misleading - better version below.
Quoted 8 lines
The solution would be:
1. Use the proposed patch (with
Kconfigoption)2. Define
spl_boot_deviceas weak and override it in board file. However, it is not the preferred solution asspl_boot_device()on my setup correctly returns SPI-NOR (as SOC ROM loads SPL from SPI-NOR, not eMMC).
Quoted 4 lines
Ok, but is a wek not thought for this purpose ? If it is weak, you can change it and decide to return the device you want. You could also check if Falco boot is enabled, at compile time with
CONFIG_SPL_OS_BOOTor at runtime withspl_start_uboot(). Should it not be enough ?
I am fine with a weak function only.
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de