[U-Boot] Building u-boot.imx and SPL simultaneously

Hi,
I'm facing a problem that the iMX Makefile does not allow to build u-boot.imx and the SPL binary simultaneously. This would be useful for generating images for flash and for a serial loading. The reason is that each target needs a different config file, but there is only one IMX_CONFIG variable.
I have tried to create a dedicated IMX_CONFIG_SPL for the SPL, which seems to work and I almost prepared a patch for submit. Unfortunatelly there is some problem with the dependencies if both u-boot.imx and SPL are put in ALL-y. The make with single job runs but it fails in multi-job execution.
Could you please help me and throw some light into the dependencies. I think this patch could be useful also for others, see below.
Thanks Petr
---------------------------------------------
diff --git a/arch/arm/config.mk b/arch/arm/config.mk index 8f85862..57ea5d3 100644 --- a/arch/arm/config.mk +++ b/arch/arm/config.mk @@ -132,16 +132,18 @@ ifdef CONFIG_EFI_LOADER OBJCOPYFLAGS += -j .efi_runtime -j .efi_runtime_rel endif
-ifneq ($(CONFIG_IMX_CONFIG),) +ifneq ($(CONFIG_IMX_CONFIG_SPL),) ifdef CONFIG_SPL ifndef CONFIG_SPL_BUILD ALL-y += SPL endif -else +endif +endif + +ifneq ($(CONFIG_IMX_CONFIG),) ifeq ($(CONFIG_OF_SEPARATE),y) ALL-y += u-boot-dtb.imx else ALL-y += u-boot.imx endif endif -endif diff --git a/arch/arm/imx-common/Makefile b/arch/arm/imx-common/Makefile index d34a784..b2e3490 100644 --- a/arch/arm/imx-common/Makefile +++ b/arch/arm/imx-common/Makefile @@ -42,8 +42,9 @@ quiet_cmd_cpp_cfg = CFGS $@ cmd_cpp_cfg = $(CPP) $(cpp_flags) -x c -o $@ $<
IMX_CONFIG = $(CONFIG_IMX_CONFIG:"%"=%).cfgtmp +IMX_CONFIG_SPL = $(CONFIG_IMX_CONFIG_SPL:"%"=%).cfgtmp
-$(IMX_CONFIG): %.cfgtmp: % FORCE +$(IMX_CONFIG) $(IMX_CONFIG_SPL): %.cfgtmp: % FORCE $(Q)mkdir -p $(dir $@) $(call if_changed_dep,cpp_cfg)
@@ -64,7 +65,7 @@ endif MKIMAGEFLAGS_SPL = -n $(filter-out $< $(PHONY),$^) -T imximage \ -e $(CONFIG_SPL_TEXT_BASE)
-SPL: spl/u-boot-spl.bin $(IMX_CONFIG) FORCE +SPL: spl/u-boot-spl.bin $(IMX_CONFIG_SPL) FORCE $(call if_changed,mkimage)
MKIMAGEFLAGS_u-boot.uim = -A arm -O U-Boot -a $(CONFIG_SYS_TEXT_BASE) \ @@ -92,4 +93,4 @@ cmd_u-boot-nand-spl_imx = (printf '\000\000\000\000\106\103\102\040\001' && \ spl/u-boot-nand-spl.imx: SPL FORCE $(call if_changed,u-boot-nand-spl_imx)
-targets += $(addprefix ../../../,$(IMX_CONFIG) SPL u-boot.uim spl/u-boot-nand-spl.imx) +targets += $(addprefix ../../../,$(IMX_CONFIG) $(IMX_CONFIG_SPL) SPL u-boot.uim spl/u-boot-nand-spl.imx)
----------------------------------------

Hi,
On 02/09/2016 18:46, Petr Kulhavy wrote:
Hi,
I'm facing a problem that the iMX Makefile does not allow to build u-boot.imx and the SPL binary simultaneously.
...I am missing why you need to build them at the same time. Can you start with a detailed description of the problem ? Why is it not enough to build them in sequence ?
This would be useful for generating images for flash and for a serial loading. The reason is that each target needs a different config file, but there is only one IMX_CONFIG variable.
I do not get the point. Yes, you have two defconfig. And yes, you cannot built it at the same time. But you define the IMX_CONFIG in each of the two defconfig, making use of two different IMX_CONFIG, if this is what you want.
I have tried to create a dedicated IMX_CONFIG_SPL for the SPL, which seems to work and I almost prepared a patch for submit. Unfortunatelly there is some problem with the dependencies if both u-boot.imx and SPL are put in ALL-y. The make with single job runs but it fails in multi-job execution.
Could you please help me and throw some light into the dependencies. I think this patch could be useful also for others, see below.
Best regards, Stefano Babic
Thanks Petr
diff --git a/arch/arm/config.mk b/arch/arm/config.mk index 8f85862..57ea5d3 100644 --- a/arch/arm/config.mk +++ b/arch/arm/config.mk @@ -132,16 +132,18 @@ ifdef CONFIG_EFI_LOADER OBJCOPYFLAGS += -j .efi_runtime -j .efi_runtime_rel endif
-ifneq ($(CONFIG_IMX_CONFIG),) +ifneq ($(CONFIG_IMX_CONFIG_SPL),) ifdef CONFIG_SPL ifndef CONFIG_SPL_BUILD ALL-y += SPL endif -else +endif +endif
+ifneq ($(CONFIG_IMX_CONFIG),) ifeq ($(CONFIG_OF_SEPARATE),y) ALL-y += u-boot-dtb.imx else ALL-y += u-boot.imx endif endif -endif diff --git a/arch/arm/imx-common/Makefile b/arch/arm/imx-common/Makefile index d34a784..b2e3490 100644 --- a/arch/arm/imx-common/Makefile +++ b/arch/arm/imx-common/Makefile @@ -42,8 +42,9 @@ quiet_cmd_cpp_cfg = CFGS $@ cmd_cpp_cfg = $(CPP) $(cpp_flags) -x c -o $@ $<
IMX_CONFIG = $(CONFIG_IMX_CONFIG:"%"=%).cfgtmp +IMX_CONFIG_SPL = $(CONFIG_IMX_CONFIG_SPL:"%"=%).cfgtmp
-$(IMX_CONFIG): %.cfgtmp: % FORCE +$(IMX_CONFIG) $(IMX_CONFIG_SPL): %.cfgtmp: % FORCE $(Q)mkdir -p $(dir $@) $(call if_changed_dep,cpp_cfg)
@@ -64,7 +65,7 @@ endif MKIMAGEFLAGS_SPL = -n $(filter-out $< $(PHONY),$^) -T imximage \ -e $(CONFIG_SPL_TEXT_BASE)
-SPL: spl/u-boot-spl.bin $(IMX_CONFIG) FORCE +SPL: spl/u-boot-spl.bin $(IMX_CONFIG_SPL) FORCE $(call if_changed,mkimage)
MKIMAGEFLAGS_u-boot.uim = -A arm -O U-Boot -a $(CONFIG_SYS_TEXT_BASE) \ @@ -92,4 +93,4 @@ cmd_u-boot-nand-spl_imx = (printf '\000\000\000\000\106\103\102\040\001' && \ spl/u-boot-nand-spl.imx: SPL FORCE $(call if_changed,u-boot-nand-spl_imx)
-targets += $(addprefix ../../../,$(IMX_CONFIG) SPL u-boot.uim spl/u-boot-nand-spl.imx) +targets += $(addprefix ../../../,$(IMX_CONFIG) $(IMX_CONFIG_SPL) SPL u-boot.uim spl/u-boot-nand-spl.imx)

Hi,
you have already brought it to the point - it needs two defconfigs. This means double the files in U-boot and second and more important, how does it integrate into a tool like Buildroot? In other words I'm trying to do it with just one defconfig.
Alltogether I want to build 3 files: * SPL which is started by the RBL * u-boot.img which is loaded by the SPL from the flash after typing 'c' or similar on the terminal * u-boot.imx for an initial load of the board via USB if there is no BL at all All these images plus rootfs and kernel should be an outcome of one build in Buildroot.
Since the u-boot.imx is in fact u-boot.img with an extra header I don't see a reason why it shouldn't be possible to compile with the same make command. And the interdependency of SPL and u-boot.imx, that only one can be built at a time, isn't obvious to me either. After all SPL is a completely different binary.
...or am I touching some skeleton in a cupboard?
Thanks Petr
On 02/09/16 20:18, Stefano Babic wrote:
Hi,
On 02/09/2016 18:46, Petr Kulhavy wrote:
Hi,
I'm facing a problem that the iMX Makefile does not allow to build u-boot.imx and the SPL binary simultaneously.
...I am missing why you need to build them at the same time. Can you start with a detailed description of the problem ? Why is it not enough to build them in sequence ?
This would be useful for generating images for flash and for a serial loading. The reason is that each target needs a different config file, but there is only one IMX_CONFIG variable.
I do not get the point. Yes, you have two defconfig. And yes, you cannot built it at the same time. But you define the IMX_CONFIG in each of the two defconfig, making use of two different IMX_CONFIG, if this is what you want.
I have tried to create a dedicated IMX_CONFIG_SPL for the SPL, which seems to work and I almost prepared a patch for submit. Unfortunatelly there is some problem with the dependencies if both u-boot.imx and SPL are put in ALL-y. The make with single job runs but it fails in multi-job execution.
Could you please help me and throw some light into the dependencies. I think this patch could be useful also for others, see below.
Best regards, Stefano Babic

Hi Petr,
On Fri, Sep 2, 2016 at 3:57 PM, Petr Kulhavy brain@jikos.cz wrote:
Hi,
you have already brought it to the point - it needs two defconfigs. This means double the files in U-boot and second and more important, how does it integrate into a tool like Buildroot?
Buildroot is capable of booting SPL + u-boot.img just fine. Check wandboard support a reference.
In other words I'm trying to do it with just one defconfig.
Alltogether I want to build 3 files:
- SPL which is started by the RBL
- u-boot.img which is loaded by the SPL from the flash after typing 'c' or
similar on the terminal
- u-boot.imx for an initial load of the board via USB if there is no BL at
all
You don't need u-boot.imx to boot the board with imx_usb_loader.
Check the README update that Stefano did with this commit:
commit 40f4839ce12adfc0223d6e3035cf9c3a4754a0ec Author: Stefano Babic sbabic@denx.de Date: Fri Dec 11 17:30:42 2015 +0100
imx_common: check for Serial Downloader in spl_boot_device
Check for bmode before reading the boot device to check if a serial downloader is started, and returns UART if the serial downloader is set, letting SPL to wait for an image if CONFIG_SPL_YMODEM_SUPPORT is set.
This allows to load again a SPL based board with imx_usb_loader together with a tool such as kermit.
Signed-off-by: Stefano Babic sbabic@denx.de CC: Tim Harvey tharvey@gateworks.com CC: Fabio Estevam Fabio.Estevam@freescale.com CC: Eric Nelson eric.nelson@boundarydevices.com Reviewed-by: Eric Nelson eric@nelint.com Tested-by: Eric Nelson eric@nelint.com

Hi Fabio,
On 02/09/16 22:03, Fabio Estevam wrote:
You don't need u-boot.imx to boot the board with imx_usb_loader. Check the README update that Stefano did with this commit:
commit 40f4839ce12adfc0223d6e3035cf9c3a4754a0ec Author: Stefano Babic sbabic@denx.de Date: Fri Dec 11 17:30:42 2015 +0100
imx_common: check for Serial Downloader in spl_boot_device Check for bmode before reading the boot device to check if a serial downloader is started, and returns UART if the serial downloader is set, letting SPL to wait for an image if CONFIG_SPL_YMODEM_SUPPORT is set. This allows to load again a SPL based board with imx_usb_loader together with a tool such as kermit. Signed-off-by: Stefano Babic <sbabic@denx.de> CC: Tim Harvey <tharvey@gateworks.com> CC: Fabio Estevam <Fabio.Estevam@freescale.com> CC: Eric Nelson <eric.nelson@boundarydevices.com> Reviewed-by: Eric Nelson <eric@nelint.com> Tested-by: Eric Nelson <eric@nelint.com>
This is not particularly what I want to do. I want to load the u-boot.img directly via the imx_usb_loader. The kermit method is unacceptably slow for a production environment.
Regards Petr

On Fri, Sep 02, 2016 at 10:53:58PM +0200, Petr Kulhavy wrote:
Hi Fabio,
On 02/09/16 22:03, Fabio Estevam wrote:
You don't need u-boot.imx to boot the board with imx_usb_loader. Check the README update that Stefano did with this commit:
commit 40f4839ce12adfc0223d6e3035cf9c3a4754a0ec Author: Stefano Babic sbabic@denx.de Date: Fri Dec 11 17:30:42 2015 +0100
imx_common: check for Serial Downloader in spl_boot_device Check for bmode before reading the boot device to check if a serial downloader is started, and returns UART if the serial downloader is set, letting SPL to wait for an image if CONFIG_SPL_YMODEM_SUPPORT is set. This allows to load again a SPL based board with imx_usb_loader together with a tool such as kermit. Signed-off-by: Stefano Babic <sbabic@denx.de> CC: Tim Harvey <tharvey@gateworks.com> CC: Fabio Estevam <Fabio.Estevam@freescale.com> CC: Eric Nelson <eric.nelson@boundarydevices.com> Reviewed-by: Eric Nelson <eric@nelint.com> Tested-by: Eric Nelson <eric@nelint.com>
This is not particularly what I want to do. I want to load the u-boot.img directly via the imx_usb_loader. The kermit method is unacceptably slow for a production environment.
Another place this doesn't work (which is where it doesn't work for me) is when the console is already open and I can't easily take it away to shoot over the next stage via Y-MODEM.
Would it be possible to implement having the next stage also be sent via imx_usb_loader? ie there's examples today of doing u-boot.imx + kernel + initrd via imx_usb_loader, so what would be needed for SPL + u-boot.img (+ kenrel + initrd) via imx_usb_loader? Thanks!

On Tue, Sep 6, 2016 at 10:40 AM, Tom Rini trini@konsulko.com wrote:
On Fri, Sep 02, 2016 at 10:53:58PM +0200, Petr Kulhavy wrote:
Hi Fabio,
On 02/09/16 22:03, Fabio Estevam wrote:
You don't need u-boot.imx to boot the board with imx_usb_loader. Check the README update that Stefano did with this commit:
commit 40f4839ce12adfc0223d6e3035cf9c3a4754a0ec Author: Stefano Babic sbabic@denx.de Date: Fri Dec 11 17:30:42 2015 +0100
imx_common: check for Serial Downloader in spl_boot_device Check for bmode before reading the boot device to check if a serial downloader is started, and returns UART if the serial downloader is set, letting SPL to wait for an image if CONFIG_SPL_YMODEM_SUPPORT is set. This allows to load again a SPL based board with imx_usb_loader together with a tool such as kermit. Signed-off-by: Stefano Babic <sbabic@denx.de> CC: Tim Harvey <tharvey@gateworks.com> CC: Fabio Estevam <Fabio.Estevam@freescale.com> CC: Eric Nelson <eric.nelson@boundarydevices.com> Reviewed-by: Eric Nelson <eric@nelint.com> Tested-by: Eric Nelson <eric@nelint.com>
This is not particularly what I want to do. I want to load the u-boot.img directly via the imx_usb_loader. The kermit method is unacceptably slow for a production environment.
Another place this doesn't work (which is where it doesn't work for me) is when the console is already open and I can't easily take it away to shoot over the next stage via Y-MODEM.
Would it be possible to implement having the next stage also be sent via imx_usb_loader? ie there's examples today of doing u-boot.imx + kernel
- initrd via imx_usb_loader, so what would be needed for SPL +
u-boot.img (+ kenrel + initrd) via imx_usb_loader? Thanks!
It should be the same except that the image will be already loaded and we need to instruct the SPL to jump to it. Am I missing something?
... zImage-foo:load 0x82000000 core-image-minimal-foo.cpio.gz:load 0x83800000 u-boot.imx:clear_dcd,jump header

On Tue, Sep 06, 2016 at 10:53:30AM -0300, Otavio Salvador wrote:
On Tue, Sep 6, 2016 at 10:40 AM, Tom Rini trini@konsulko.com wrote:
On Fri, Sep 02, 2016 at 10:53:58PM +0200, Petr Kulhavy wrote:
Hi Fabio,
On 02/09/16 22:03, Fabio Estevam wrote:
You don't need u-boot.imx to boot the board with imx_usb_loader. Check the README update that Stefano did with this commit:
commit 40f4839ce12adfc0223d6e3035cf9c3a4754a0ec Author: Stefano Babic sbabic@denx.de Date: Fri Dec 11 17:30:42 2015 +0100
imx_common: check for Serial Downloader in spl_boot_device Check for bmode before reading the boot device to check if a serial downloader is started, and returns UART if the serial downloader is set, letting SPL to wait for an image if CONFIG_SPL_YMODEM_SUPPORT is set. This allows to load again a SPL based board with imx_usb_loader together with a tool such as kermit. Signed-off-by: Stefano Babic <sbabic@denx.de> CC: Tim Harvey <tharvey@gateworks.com> CC: Fabio Estevam <Fabio.Estevam@freescale.com> CC: Eric Nelson <eric.nelson@boundarydevices.com> Reviewed-by: Eric Nelson <eric@nelint.com> Tested-by: Eric Nelson <eric@nelint.com>
This is not particularly what I want to do. I want to load the u-boot.img directly via the imx_usb_loader. The kermit method is unacceptably slow for a production environment.
Another place this doesn't work (which is where it doesn't work for me) is when the console is already open and I can't easily take it away to shoot over the next stage via Y-MODEM.
Would it be possible to implement having the next stage also be sent via imx_usb_loader? ie there's examples today of doing u-boot.imx + kernel
- initrd via imx_usb_loader, so what would be needed for SPL +
u-boot.img (+ kenrel + initrd) via imx_usb_loader? Thanks!
It should be the same except that the image will be already loaded and we need to instruct the SPL to jump to it. Am I missing something?
... zImage-foo:load 0x82000000 core-image-minimal-foo.cpio.gz:load 0x83800000 u-boot.imx:clear_dcd,jump header
Yes, I want to load SPL + u-boot.img so SPL will need to know that it's going to fall back to ROM and allow it to be given u-boot.img to load into DRAM :)

Hi Tom,
On 09/06/2016 06:40 AM, Tom Rini wrote:
On Fri, Sep 02, 2016 at 10:53:58PM +0200, Petr Kulhavy wrote:
Hi Fabio,
On 02/09/16 22:03, Fabio Estevam wrote:
You don't need u-boot.imx to boot the board with imx_usb_loader. Check the README update that Stefano did with this commit:
commit 40f4839ce12adfc0223d6e3035cf9c3a4754a0ec Author: Stefano Babic sbabic@denx.de Date: Fri Dec 11 17:30:42 2015 +0100
imx_common: check for Serial Downloader in spl_boot_device Check for bmode before reading the boot device to check if a serial downloader is started, and returns UART if the serial downloader is set, letting SPL to wait for an image if CONFIG_SPL_YMODEM_SUPPORT is set. This allows to load again a SPL based board with imx_usb_loader together with a tool such as kermit. Signed-off-by: Stefano Babic <sbabic@denx.de> CC: Tim Harvey <tharvey@gateworks.com> CC: Fabio Estevam <Fabio.Estevam@freescale.com> CC: Eric Nelson <eric.nelson@boundarydevices.com> Reviewed-by: Eric Nelson <eric@nelint.com> Tested-by: Eric Nelson <eric@nelint.com>
This is not particularly what I want to do. I want to load the u-boot.img directly via the imx_usb_loader. The kermit method is unacceptably slow for a production environment.
Another place this doesn't work (which is where it doesn't work for me) is when the console is already open and I can't easily take it away to shoot over the next stage via Y-MODEM.
Would it be possible to implement having the next stage also be sent via imx_usb_loader? ie there's examples today of doing u-boot.imx + kernel
- initrd via imx_usb_loader, so what would be needed for SPL +
u-boot.img (+ kenrel + initrd) via imx_usb_loader? Thanks!
SPL+u-boot.img could be bundled into a single image through the use of plugins which would require:
- updates to mkimage to support plugins, and - Makefile updates to produce a third output (u-boot.imx?), and - an update to SPL startup on i.MX to check for the plugin flag and return to the boot ROM after startup (instead of loading U-Boot) if set.
Troy implemented the key bits back in 2012, and I provided some links here:
http://lists.denx.de/pipermail/u-boot/2016-June/258784.html
Regards,
Eric

On 06/09/16 16:00, Eric Nelson wrote:
Hi Tom,
On 09/06/2016 06:40 AM, Tom Rini wrote:
On Fri, Sep 02, 2016 at 10:53:58PM +0200, Petr Kulhavy wrote:
Another place this doesn't work (which is where it doesn't work for me) is when the console is already open and I can't easily take it away to shoot over the next stage via Y-MODEM.
Would it be possible to implement having the next stage also be sent via imx_usb_loader? ie there's examples today of doing u-boot.imx + kernel
- initrd via imx_usb_loader, so what would be needed for SPL +
u-boot.img (+ kenrel + initrd) via imx_usb_loader? Thanks!
SPL+u-boot.img could be bundled into a single image through the use of plugins which would require:
- updates to mkimage to support plugins, and
- Makefile updates to produce a third output (u-boot.imx?), and
- an update to SPL startup on i.MX to check for the plugin flag
and return to the boot ROM after startup (instead of loading U-Boot) if set.
Maybe this jumping to RBL forth and back is not needed at all. If the SPL+img was loaded as one chunk into DRAM instead of the on-chip RAM (would require DDR initialization via DCD as it happens for the IMX image) then the SPL could jump directly into the uboot image, couldn't it?
Cheers Petr

On Tue, Sep 06, 2016 at 04:12:55PM +0200, Petr Kulhavy wrote:
On 06/09/16 16:00, Eric Nelson wrote:
Hi Tom,
On 09/06/2016 06:40 AM, Tom Rini wrote:
On Fri, Sep 02, 2016 at 10:53:58PM +0200, Petr Kulhavy wrote:
Another place this doesn't work (which is where it doesn't work for me) is when the console is already open and I can't easily take it away to shoot over the next stage via Y-MODEM.
Would it be possible to implement having the next stage also be sent via imx_usb_loader? ie there's examples today of doing u-boot.imx + kernel
- initrd via imx_usb_loader, so what would be needed for SPL +
u-boot.img (+ kenrel + initrd) via imx_usb_loader? Thanks!
SPL+u-boot.img could be bundled into a single image through the use of plugins which would require:
- updates to mkimage to support plugins, and
- Makefile updates to produce a third output (u-boot.imx?), and
- an update to SPL startup on i.MX to check for the plugin flag
and return to the boot ROM after startup (instead of loading U-Boot) if set.
Maybe this jumping to RBL forth and back is not needed at all. If the SPL+img was loaded as one chunk into DRAM instead of the on-chip RAM (would require DDR initialization via DCD as it happens for the IMX image) then the SPL could jump directly into the uboot image, couldn't it?
Yes but many of the use cases involve "get away from doing DCD script DDR init". That's basically what the u-boot.imx version does, there's the header up front that does DDR init and then u-boot is loaded into DRAM.

On Tue, Sep 06, 2016 at 07:00:56AM -0700, Eric Nelson wrote:
Hi Tom,
On 09/06/2016 06:40 AM, Tom Rini wrote:
On Fri, Sep 02, 2016 at 10:53:58PM +0200, Petr Kulhavy wrote:
Hi Fabio,
On 02/09/16 22:03, Fabio Estevam wrote:
You don't need u-boot.imx to boot the board with imx_usb_loader. Check the README update that Stefano did with this commit:
commit 40f4839ce12adfc0223d6e3035cf9c3a4754a0ec Author: Stefano Babic sbabic@denx.de Date: Fri Dec 11 17:30:42 2015 +0100
imx_common: check for Serial Downloader in spl_boot_device Check for bmode before reading the boot device to check if a serial downloader is started, and returns UART if the serial downloader is set, letting SPL to wait for an image if CONFIG_SPL_YMODEM_SUPPORT is set. This allows to load again a SPL based board with imx_usb_loader together with a tool such as kermit. Signed-off-by: Stefano Babic <sbabic@denx.de> CC: Tim Harvey <tharvey@gateworks.com> CC: Fabio Estevam <Fabio.Estevam@freescale.com> CC: Eric Nelson <eric.nelson@boundarydevices.com> Reviewed-by: Eric Nelson <eric@nelint.com> Tested-by: Eric Nelson <eric@nelint.com>
This is not particularly what I want to do. I want to load the u-boot.img directly via the imx_usb_loader. The kermit method is unacceptably slow for a production environment.
Another place this doesn't work (which is where it doesn't work for me) is when the console is already open and I can't easily take it away to shoot over the next stage via Y-MODEM.
Would it be possible to implement having the next stage also be sent via imx_usb_loader? ie there's examples today of doing u-boot.imx + kernel
- initrd via imx_usb_loader, so what would be needed for SPL +
u-boot.img (+ kenrel + initrd) via imx_usb_loader? Thanks!
SPL+u-boot.img could be bundled into a single image through the use of plugins which would require:
- updates to mkimage to support plugins, and
- Makefile updates to produce a third output (u-boot.imx?), and
- an update to SPL startup on i.MX to check for the plugin flag
and return to the boot ROM after startup (instead of loading U-Boot) if set.
Troy implemented the key bits back in 2012, and I provided some links here:
Ah yes, this. I really would like to see this come in as I think it'll be required to really drop the old style u-boot.imx binaries for cases like factory programming. As well as the use cases outlined before too about supporting multiple boards more easily.

Hi Tom,
On 09/06/2016 07:15 AM, Tom Rini wrote:
On Tue, Sep 06, 2016 at 07:00:56AM -0700, Eric Nelson wrote:
On 09/06/2016 06:40 AM, Tom Rini wrote:
On Fri, Sep 02, 2016 at 10:53:58PM +0200, Petr Kulhavy wrote:
<snip>
Would it be possible to implement having the next stage also be sent via imx_usb_loader? ie there's examples today of doing u-boot.imx + kernel
- initrd via imx_usb_loader, so what would be needed for SPL +
u-boot.img (+ kenrel + initrd) via imx_usb_loader? Thanks!
SPL+u-boot.img could be bundled into a single image through the use of plugins which would require:
- updates to mkimage to support plugins, and
- Makefile updates to produce a third output (u-boot.imx?), and
- an update to SPL startup on i.MX to check for the plugin flag
and return to the boot ROM after startup (instead of loading U-Boot) if set.
It appears that the mkimage support is present in a patch against v2015.04:
http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/commit/tools/mkimage...
Peng, can you up-stream this?
Troy implemented the key bits back in 2012, and I provided some links here:
Ah yes, this. I really would like to see this come in as I think it'll be required to really drop the old style u-boot.imx binaries for cases like factory programming. As well as the use cases outlined before too about supporting multiple boards more easily.
I'd also like to see this get pulled into main-line, and I just ran across another reason for supporting plugins.
The i.MX7 LPSR mode resumes from a "power-off" state by going through the boot ROM, and it's up to the code loaded by the boot ROM to recognize the condition, take DRAM out of self-refresh and jump back into IRAM:
http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/commit/board/freesca...
Some additional commentary is in this post on NXP community:
https://community.nxp.com/thread/434057#comment-830672
For this use case, SPL will be too heavyweight and plugin support is needed.
Regards,
Eric

Hi,
On Sat, Sep 10, 2016 at 04:40:47PM -0700, Eric Nelson wrote:
Hi Tom,
On 09/06/2016 07:15 AM, Tom Rini wrote:
On Tue, Sep 06, 2016 at 07:00:56AM -0700, Eric Nelson wrote:
On 09/06/2016 06:40 AM, Tom Rini wrote:
On Fri, Sep 02, 2016 at 10:53:58PM +0200, Petr Kulhavy wrote:
<snip>
Would it be possible to implement having the next stage also be sent via imx_usb_loader? ie there's examples today of doing u-boot.imx + kernel
- initrd via imx_usb_loader, so what would be needed for SPL +
u-boot.img (+ kenrel + initrd) via imx_usb_loader? Thanks!
SPL+u-boot.img could be bundled into a single image through the use of plugins which would require:
- updates to mkimage to support plugins, and
- Makefile updates to produce a third output (u-boot.imx?), and
- an update to SPL startup on i.MX to check for the plugin flag
and return to the boot ROM after startup (instead of loading U-Boot) if set.
It appears that the mkimage support is present in a patch against v2015.04:
http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/commit/tools/mkimage...
Peng, can you up-stream this?
Hi Stefano,
I would like see your points on this. I tried to uptream plugin before, but rejected, Since more people would like to see this in, do you agree to let plugin supported in mainline?
Thanks, Peng.
Troy implemented the key bits back in 2012, and I provided some links here:
Ah yes, this. I really would like to see this come in as I think it'll be required to really drop the old style u-boot.imx binaries for cases like factory programming. As well as the use cases outlined before too about supporting multiple boards more easily.
I'd also like to see this get pulled into main-line, and I just ran across another reason for supporting plugins.
The i.MX7 LPSR mode resumes from a "power-off" state by going through the boot ROM, and it's up to the code loaded by the boot ROM to recognize the condition, take DRAM out of self-refresh and jump back into IRAM:
http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/commit/board/freesca...
Some additional commentary is in this post on NXP community:
https://community.nxp.com/thread/434057#comment-830672
For this use case, SPL will be too heavyweight and plugin support is needed.
Regards,
Eric

Hi Peng,
On 18/09/2016 08:50, Peng Fan wrote:
Hi,
On Sat, Sep 10, 2016 at 04:40:47PM -0700, Eric Nelson wrote:
Hi Tom,
On 09/06/2016 07:15 AM, Tom Rini wrote:
On Tue, Sep 06, 2016 at 07:00:56AM -0700, Eric Nelson wrote:
On 09/06/2016 06:40 AM, Tom Rini wrote:
On Fri, Sep 02, 2016 at 10:53:58PM +0200, Petr Kulhavy wrote:
<snip>
Would it be possible to implement having the next stage also be sent via imx_usb_loader? ie there's examples today of doing u-boot.imx + kernel
- initrd via imx_usb_loader, so what would be needed for SPL +
u-boot.img (+ kenrel + initrd) via imx_usb_loader? Thanks!
SPL+u-boot.img could be bundled into a single image through the use of plugins which would require:
- updates to mkimage to support plugins, and
- Makefile updates to produce a third output (u-boot.imx?), and
- an update to SPL startup on i.MX to check for the plugin flag
and return to the boot ROM after startup (instead of loading U-Boot) if set.
It appears that the mkimage support is present in a patch against v2015.04:
http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/commit/tools/mkimage...
Peng, can you up-stream this?
Hi Stefano,
I would like see your points on this. I tried to uptream plugin before, but rejected, Since more people would like to see this in, do you agree to let plugin supported in mainline?
Yes - I see a general agreement to get in mainline, and thanks for the effort to push it.
Best regards, Stefano

Hi Petr,
On 02/09/2016 20:57, Petr Kulhavy wrote:
Hi,
you have already brought it to the point - it needs two defconfigs. This means double the files in U-boot and second and more important, how does it integrate into a tool like Buildroot? In other words I'm trying to do it with just one defconfig.
Alltogether I want to build 3 files:
- SPL which is started by the RBL
- u-boot.img which is loaded by the SPL from the flash after typing 'c'
or similar on the terminal
- u-boot.imx for an initial load of the board via USB if there is no BL
at all
You are assuming that the two different setups are equivalent: u-boot.ix against SPL + u-boot.img. It is not, and they have very different concepts on the basis of two.
And with imx_usb_loader it is still possible to load the SPL via USB, and via UART, SPL loads u-boot.img - see README.imx6.
All these images plus rootfs and kernel should be an outcome of one build in Buildroot.
Since the u-boot.imx is in fact u-boot.img with an extra header
It is not: it is different. If it was just an header, I agree that it is like building the bootloader in several formats. That happens for u-boot.bin and u-boot.img, or u-boot.bin and u-boot.imx.
u-boot.imx has much more as a header: it is contain the DCD tables according to the FSL documentation that it is interpreted by the RBL. This is a static setup, because the DCD table is fixed. The RBL sets the SOC according to the values in the DCD table and has (or it can have) nothing to do with the SPL+u-boot.img built for the same board.
On the other side, SPL does not use DCD at all (it could be, but it is empty), and the setup is done with runtime detection by SPL code. The u-boot.img built together with SPL depends on it, that means it does not set again some parts already set by the SPL. That means you cannot simply exchange u-boot.img or u-boot.imx.
Generally, we cannot assume that a u-boot.img, behaves as u-boot.imx: it could be, but it is only luck. At the end, they are two different systems - two targets, that means two defconfig.
I don't see a reason why it shouldn't be possible to compile with the same make command.
See above - we should have the same result, just with two formats. It is not.
And the interdependency of SPL and u-boot.imx, that only one can be built at a time, isn't obvious to me either. After all SPL is a completely different binary.
...and result and behavior are completely different. That means having two targets, or two defconfig.
...or am I touching some skeleton in a cupboard?
Best regards, Stefano Babic
Thanks Petr
On 02/09/16 20:18, Stefano Babic wrote:
Hi,
On 02/09/2016 18:46, Petr Kulhavy wrote:
Hi,
I'm facing a problem that the iMX Makefile does not allow to build u-boot.imx and the SPL binary simultaneously.
...I am missing why you need to build them at the same time. Can you start with a detailed description of the problem ? Why is it not enough to build them in sequence ?
This would be useful for generating images for flash and for a serial loading. The reason is that each target needs a different config file, but there is only one IMX_CONFIG variable.
I do not get the point. Yes, you have two defconfig. And yes, you cannot built it at the same time. But you define the IMX_CONFIG in each of the two defconfig, making use of two different IMX_CONFIG, if this is what you want.
I have tried to create a dedicated IMX_CONFIG_SPL for the SPL, which seems to work and I almost prepared a patch for submit. Unfortunatelly there is some problem with the dependencies if both u-boot.imx and SPL are put in ALL-y. The make with single job runs but it fails in multi-job execution.
Could you please help me and throw some light into the dependencies. I think this patch could be useful also for others, see below.
Best regards, Stefano Babic

Hi Stefano,
I need to build two set-ups: 1) SPL + u-boot.img for normal device run out of flash 2) u-boot.imx for initial device load together with fastboot
For (2) SPL + kermit + u-boot.img is not an option for me, simply because it is too slow.
I agree that the u-boot images in case (1) and (2) do not generally have to be identical. However in my case I don't need them to be different.
You are saying that in order to cover my use case(s) I need two defconfigs. Well, ok... But how do I integrate this into Buildroot? For the sake of maintainability, simplification, reducing chance for an error during build I want to have one Buildroot defconfig, run one build command and get all the necessary images. How do I do that with two U-boot defconfigs?
On 02/09/16 23:45, Stefano Babic wrote:
Hi Petr,
On 02/09/2016 20:57, Petr Kulhavy wrote:
Hi,
you have already brought it to the point - it needs two defconfigs. This means double the files in U-boot and second and more important, how does it integrate into a tool like Buildroot? In other words I'm trying to do it with just one defconfig.
Alltogether I want to build 3 files:
- SPL which is started by the RBL
- u-boot.img which is loaded by the SPL from the flash after typing 'c'
or similar on the terminal
- u-boot.imx for an initial load of the board via USB if there is no BL
at all
You are assuming that the two different setups are equivalent: u-boot.ix against SPL + u-boot.img. It is not, and they have very different concepts on the basis of two.
Well, I see it slightly different. There is some core functionality of u-boot, which is the command interpreter, scripting, drivers, etc. And then there is some one-time HW initialization that needs to be done. There are two different ways of doing the HW initialization: either via RBL and DCD, or via SPL. But after the HW is initialized it comes in both cases to the same functionality. Once the u-boot is started it does not see the SPL and it probably doesn't even know how it was loaded. It just assumes that certain HW is initialized in a certain way.
In the end both u-boot.imx and u-boot.img are generated out of the same u-boot.bin, just with different mkimage parameters.
And with imx_usb_loader it is still possible to load the SPL via USB, and via UART, SPL loads u-boot.img - see README.imx6.
That is too slow for my needs.
All these images plus rootfs and kernel should be an outcome of one build in Buildroot.
Since the u-boot.imx is in fact u-boot.img with an extra header
It is not: it is different. If it was just an header, I agree that it is like building the bootloader in several formats. That happens for u-boot.bin and u-boot.img, or u-boot.bin and u-boot.imx.
u-boot.imx has much more as a header: it is contain the DCD tables according to the FSL documentation that it is interpreted by the RBL. This is a static setup, because the DCD table is fixed. The RBL sets the SOC according to the values in the DCD table and has (or it can have) nothing to do with the SPL+u-boot.img built for the same board.
On the other side, SPL does not use DCD at all (it could be, but it is empty), and the setup is done with runtime detection by SPL code. The u-boot.img built together with SPL depends on it, that means it does not set again some parts already set by the SPL. That means you cannot simply exchange u-boot.img or u-boot.imx.
I don't want to exchange them. I want to do the same HW initialization which u-boot expects from SPL in the DCD and out of that create the u-boot.imx, which is then directly loaded without SPL. But currently it is not possible.
Generally, we cannot assume that a u-boot.img, behaves as u-boot.imx: it could be, but it is only luck.
Of course, if I want to use two different vesions of u-boot with different sets of commands and features it makes sense to have two defconfigs. But if I want to use the same functionality why should the make process hinder generating the .img and .imx in the same build process?
Regards Petr

Hi Petr,
On 03/09/2016 01:15, Petr Kulhavy wrote:
Hi Stefano,
I need to build two set-ups:
- SPL + u-boot.img for normal device run out of flash
- u-boot.imx for initial device load together with fastboot
For (2) SPL + kermit + u-boot.img is not an option for me, simply because it is too slow.
I agree that the u-boot images in case (1) and (2) do not generally have to be identical.
This is why they have two different defconfigs.
However in my case I don't need them to be different.
You are saying that in order to cover my use case(s) I need two defconfigs. Well, ok... But how do I integrate this into Buildroot? For the sake of maintainability, simplification, reducing chance for an error during build I want to have one Buildroot defconfig, run one build command and get all the necessary images. How do I do that with two U-boot defconfigs?
I am noit a Buildroot expert, someone else can better point you in the right direction. I will expect that you need a second target. If I had to do thuis in Yoct, I will tend to add a new recipe to build .imx variant.
Best regards, Stefano Babic
On 02/09/16 23:45, Stefano Babic wrote:
Hi Petr,
On 02/09/2016 20:57, Petr Kulhavy wrote:
Hi,
you have already brought it to the point - it needs two defconfigs. This means double the files in U-boot and second and more important, how does it integrate into a tool like Buildroot? In other words I'm trying to do it with just one defconfig.
Alltogether I want to build 3 files:
- SPL which is started by the RBL
- u-boot.img which is loaded by the SPL from the flash after typing 'c'
or similar on the terminal
- u-boot.imx for an initial load of the board via USB if there is no BL
at all
You are assuming that the two different setups are equivalent: u-boot.ix against SPL + u-boot.img. It is not, and they have very different concepts on the basis of two.
Well, I see it slightly different. There is some core functionality of u-boot, which is the command interpreter, scripting, drivers, etc. And then there is some one-time HW initialization that needs to be done. There are two different ways of doing the HW initialization: either via RBL and DCD, or via SPL. But after the HW is initialized it comes in both cases to the same functionality. Once the u-boot is started it does not see the SPL and it probably doesn't even know how it was loaded. It just assumes that certain HW is initialized in a certain way.
In the end both u-boot.imx and u-boot.img are generated out of the same u-boot.bin, just with different mkimage parameters.
And with imx_usb_loader it is still possible to load the SPL via USB, and via UART, SPL loads u-boot.img - see README.imx6.
That is too slow for my needs.
All these images plus rootfs and kernel should be an outcome of one build in Buildroot.
Since the u-boot.imx is in fact u-boot.img with an extra header
It is not: it is different. If it was just an header, I agree that it is like building the bootloader in several formats. That happens for u-boot.bin and u-boot.img, or u-boot.bin and u-boot.imx.
u-boot.imx has much more as a header: it is contain the DCD tables according to the FSL documentation that it is interpreted by the RBL. This is a static setup, because the DCD table is fixed. The RBL sets the SOC according to the values in the DCD table and has (or it can have) nothing to do with the SPL+u-boot.img built for the same board.
On the other side, SPL does not use DCD at all (it could be, but it is empty), and the setup is done with runtime detection by SPL code. The u-boot.img built together with SPL depends on it, that means it does not set again some parts already set by the SPL. That means you cannot simply exchange u-boot.img or u-boot.imx.
I don't want to exchange them. I want to do the same HW initialization which u-boot expects from SPL in the DCD and out of that create the u-boot.imx, which is then directly loaded without SPL. But currently it is not possible.
Generally, we cannot assume that a u-boot.img, behaves as u-boot.imx: it could be, but it is only luck.
Of course, if I want to use two different vesions of u-boot with different sets of commands and features it makes sense to have two defconfigs. But if I want to use the same functionality why should the make process hinder generating the .img and .imx in the same build process?
Regards Petr

On Sat, Sep 3, 2016 at 6:40 AM, Stefano Babic sbabic@denx.de wrote:
On 03/09/2016 01:15, Petr Kulhavy wrote:
You are saying that in order to cover my use case(s) I need two defconfigs. Well, ok... But how do I integrate this into Buildroot? For the sake of maintainability, simplification, reducing chance for an error during build I want to have one Buildroot defconfig, run one build command and get all the necessary images. How do I do that with two U-boot defconfigs?
I am noit a Buildroot expert, someone else can better point you in the right direction. I will expect that you need a second target. If I had to do thuis in Yoct, I will tend to add a new recipe to build .imx variant.
On OpenEmbedded-based systems, as is the case of Yocto Project, we introduced the UBOOT_CONFIG mechanism for this. So for example in:
https://github.com/Freescale/meta-fsl-arm/blob/master/conf/machine/imx6slevk...
The UBOOT_CONFIG is changed, in local.conf for a machine, to:
UBOOT_CONFIG = "spinor sd"
Both as build.

Hi Otavio,
On 03/09/2016 22:27, Otavio Salvador wrote:
On Sat, Sep 3, 2016 at 6:40 AM, Stefano Babic sbabic@denx.de wrote:
On 03/09/2016 01:15, Petr Kulhavy wrote:
You are saying that in order to cover my use case(s) I need two defconfigs. Well, ok... But how do I integrate this into Buildroot? For the sake of maintainability, simplification, reducing chance for an error during build I want to have one Buildroot defconfig, run one build command and get all the necessary images. How do I do that with two U-boot defconfigs?
I am noit a Buildroot expert, someone else can better point you in the right direction. I will expect that you need a second target. If I had to do thuis in Yoct, I will tend to add a new recipe to build .imx variant.
On OpenEmbedded-based systems, as is the case of Yocto Project, we introduced the UBOOT_CONFIG mechanism for this. So for example in:
https://github.com/Freescale/meta-fsl-arm/blob/master/conf/machine/imx6slevk...
The UBOOT_CONFIG is changed, in local.conf for a machine, to:
UBOOT_CONFIG = "spinor sd"
Both as build.
Thanks for the hint - this is an elegant solution for Yocto.
Best regards, Stefano
participants (7)
-
Eric Nelson
-
Fabio Estevam
-
Otavio Salvador
-
Peng Fan
-
Petr Kulhavy
-
Stefano Babic
-
Tom Rini