[U-Boot] [PATCH] Makefile: Create single image for imx6 socs based boards

IMX6 platform has two stage boot loaders like SPL and U-Boot proper. For each stage we need to burn the image on to flash with respective offsets.
This patch create a single image using binman, so that user can get rid of burning different stage boot images.
without this patch: ------------------ $ sudo dd if=SPL of=/dev/mmcblk0 bs=1k seek=1 $ sudo dd if=u-boot-dtb.img of=/dev/mmcblk0 bs=1k seek=69
with this patch: --------------- $ sudo dd if=u-boot-imx6-with-spl.bin of=/dev/mmcblk0 bs=1k seek=1
This would be easily extended to single image creation for other imx6 soc boards.
This was tested on engicam imx6qdl and imx6ul boards
Reviewed-by: Jagan Teki jagan@amarulasolutions.com Signed-off-by: Shyam Saini shyam.saini@amarulasolutions.com --- Makefile | 10 ++++++++++ arch/arm/dts/imx6-u-boot-binman.dtsi | 16 ++++++++++++++++ arch/arm/dts/imx6qdl-u-boot.dtsi | 1 + arch/arm/dts/imx6ul-u-boot.dtsi | 1 + arch/arm/mach-imx/mx6/Kconfig | 2 ++ doc/imx/common/imx6.txt | 5 +++++ 6 files changed, 35 insertions(+) create mode 100644 arch/arm/dts/imx6-u-boot-binman.dtsi
diff --git a/Makefile b/Makefile index f2c7bb6041..474271a1d0 100644 --- a/Makefile +++ b/Makefile @@ -851,6 +851,11 @@ ifeq ($(CONFIG_ARCH_SUNXI)$(CONFIG_SPL),yy) ALL-y += u-boot-sunxi-with-spl.bin endif
+# Build a combined spl + u-boot image for imx6 +ifeq ($(filter y, $(CONFIG_MX6QDL) $(CONFIG_MX6UL))$(CONFIG_SPL)$(CONFIG_OF_CONTROL),yyy) +ALL-$(CONFIG_ARCH_MX6) += u-boot-imx6-with-spl.bin +endif + # enable combined SPL/u-boot/dtb rules for tegra ifeq ($(CONFIG_TEGRA)$(CONFIG_SPL),yy) ALL-y += u-boot-tegra.bin u-boot-nodtb-tegra.bin @@ -1364,6 +1369,11 @@ u-boot-br.bin: u-boot FORCE endif endif
+ifeq ($(filter y, $(CONFIG_MX6QDL) $(CONFIG_MX6UL))$(CONFIG_SPL)$(CONFIG_OF_CONTROL),yyy) +u-boot-imx6-with-spl.bin: SPL u-boot-dtb.img FORCE + @$(call if_changed,binman) +endif + # x86 uses a large ROM. We fill it with 0xff, put the 16-bit stuff (including # reset vector) at the top, Intel ME descriptor at the bottom, and U-Boot in # the middle. This is handled by binman based on an image description in the diff --git a/arch/arm/dts/imx6-u-boot-binman.dtsi b/arch/arm/dts/imx6-u-boot-binman.dtsi new file mode 100644 index 0000000000..fa02d5f61f --- /dev/null +++ b/arch/arm/dts/imx6-u-boot-binman.dtsi @@ -0,0 +1,16 @@ +#include <config.h> + +/ { + binman { + filename = "u-boot-imx6-with-spl.bin"; + pad-byte = <0xff>; + + blob { + filename = "SPL"; + }; + + u-boot-img { + offset = <CONFIG_SPL_PAD_TO>; + }; + }; +}; diff --git a/arch/arm/dts/imx6qdl-u-boot.dtsi b/arch/arm/dts/imx6qdl-u-boot.dtsi index 0aa29e38b8..3dfa84dcac 100644 --- a/arch/arm/dts/imx6qdl-u-boot.dtsi +++ b/arch/arm/dts/imx6qdl-u-boot.dtsi @@ -2,6 +2,7 @@ /* * Copyright (C) 2018 Jagan Teki jagan@amarulasolutions.com */ +#include "imx6-u-boot-binman.dtsi"
/ { soc { diff --git a/arch/arm/dts/imx6ul-u-boot.dtsi b/arch/arm/dts/imx6ul-u-boot.dtsi index eb190cf8c8..4e769da0d5 100644 --- a/arch/arm/dts/imx6ul-u-boot.dtsi +++ b/arch/arm/dts/imx6ul-u-boot.dtsi @@ -2,6 +2,7 @@ /* * Copyright (C) 2018 Jagan Teki jagan@amarulasolutions.com */ +#include "imx6-u-boot-binman.dtsi"
/ { soc { diff --git a/arch/arm/mach-imx/mx6/Kconfig b/arch/arm/mach-imx/mx6/Kconfig index e782859b1e..7de1a00935 100644 --- a/arch/arm/mach-imx/mx6/Kconfig +++ b/arch/arm/mach-imx/mx6/Kconfig @@ -34,6 +34,7 @@ config MX6QDL bool select HAS_CAAM select MX6_SMP + select BINMAN if SPL && OF_CONTROL
config MX6S bool @@ -57,6 +58,7 @@ config MX6UL select ROM_UNIFIED_SECTIONS select SYSCOUNTER_TIMER select SYS_L2CACHE_OFF + select BINMAN if SPL && OF_CONTROL
config MX6UL_LITESOM bool diff --git a/doc/imx/common/imx6.txt b/doc/imx/common/imx6.txt index eab88353f6..5a10f94957 100644 --- a/doc/imx/common/imx6.txt +++ b/doc/imx/common/imx6.txt @@ -88,3 +88,8 @@ Reading bank 4:
Word 0x00000002: 9f027772 00000004
+2. Single Boot Image +--------------------- +Write your single imx6 uboot image as: + +$ sudo dd if=u-boot-imx6-with-spl.bin of=/dev/mmcblk0 bs=1k seek=1

Hi Shyam,
On Tue, Apr 30, 2019 at 7:34 AM Shyam Saini shyam.saini@amarulasolutions.com wrote:
IMX6 platform has two stage boot loaders like SPL and U-Boot proper. For each stage we need to burn the image on to flash with respective offsets.
This patch create a single image using binman, so that user can get rid of burning different stage boot images.
without this patch:
$ sudo dd if=SPL of=/dev/mmcblk0 bs=1k seek=1 $ sudo dd if=u-boot-dtb.img of=/dev/mmcblk0 bs=1k seek=69
with this patch:
$ sudo dd if=u-boot-imx6-with-spl.bin of=/dev/mmcblk0 bs=1k seek=1
This would be easily extended to single image creation for other imx6 soc boards.
This was tested on engicam imx6qdl and imx6ul boards
Reviewed-by: Jagan Teki jagan@amarulasolutions.com Signed-off-by: Shyam Saini shyam.saini@amarulasolutions.com
I like the idea, but this breaks the build for mx6sabresd_defconfig:
COPY spl/u-boot-spl.bin CFGS spl/u-boot-spl.cfgout MKIMAGE SPL BINMAN u-boot-imx6-with-spl.bin Wrote map file './image.map' to show errors binman: Node '/binman/u-boot-img': Offset 0x11000 (69632) overlaps with previous entry '/binman/blob' ending at 0x11c00 (72704) Makefile:1374: recipe for target 'u-boot-imx6-with-spl.bin' failed make: *** [u-boot-imx6-with-spl.bin] Error 1
I am interested to see if this solution could load u-boot-imx6-with-spl.bin via imx_usb_loader in Serial Download Mode.
Currently it is not possible to load SPL + u-boot-dtb.img + FIT via imx_usb_loader. Does it work with your proposal?
Thanks

Hi Fabio,
On Tue, Apr 30, 2019 at 6:17 PM Fabio Estevam festevam@gmail.com wrote:
Hi Shyam,
On Tue, Apr 30, 2019 at 7:34 AM Shyam Saini shyam.saini@amarulasolutions.com wrote:
IMX6 platform has two stage boot loaders like SPL and U-Boot proper. For each stage we need to burn the image on to flash with respective offsets.
This patch create a single image using binman, so that user can get rid of burning different stage boot images.
without this patch:
$ sudo dd if=SPL of=/dev/mmcblk0 bs=1k seek=1 $ sudo dd if=u-boot-dtb.img of=/dev/mmcblk0 bs=1k seek=69
with this patch:
$ sudo dd if=u-boot-imx6-with-spl.bin of=/dev/mmcblk0 bs=1k seek=1
This would be easily extended to single image creation for other imx6 soc boards.
This was tested on engicam imx6qdl and imx6ul boards
Reviewed-by: Jagan Teki jagan@amarulasolutions.com Signed-off-by: Shyam Saini shyam.saini@amarulasolutions.com
I like the idea, but this breaks the build for mx6sabresd_defconfig:
COPY spl/u-boot-spl.bin CFGS spl/u-boot-spl.cfgout MKIMAGE SPL BINMAN u-boot-imx6-with-spl.bin Wrote map file './image.map' to show errors binman: Node '/binman/u-boot-img': Offset 0x11000 (69632) overlaps with previous entry '/binman/blob' ending at 0x11c00 (72704) Makefile:1374: recipe for target 'u-boot-imx6-with-spl.bin' failed make: *** [u-boot-imx6-with-spl.bin] Error 1
Look like few of boards are crossing size > 68K which is the default CONFIG_SPL_PAD_TO value.
This is the value in sabresd case, ₹ cat image.map ImagePos Offset Size Name <none> 00000000 0009c8b8 main-section <none> 00000000 00011c00 blob <none> 00011000 0008b8b8 u-boot-img
But if this the case the existing u-boot right from board/freescale/mx6sabresd/README $ sudo dd if=u-boot-dtb.img of=/dev/sdX bs=1K seek=69
will override the SPL, isn't it?
I am interested to see if this solution could load u-boot-imx6-with-spl.bin via imx_usb_loader in Serial Download Mode.
Currently it is not possible to load SPL + u-boot-dtb.img + FIT via imx_usb_loader. Does it work with your proposal?
Sure, will try.

Hi Shyam,
On 30/04/19 12:33, Shyam Saini wrote:
IMX6 platform has two stage boot loaders like SPL and U-Boot proper. For each stage we need to burn the image on to flash with respective offsets.
This patch create a single image using binman, so that user can get rid of burning different stage boot images.
without this patch:
$ sudo dd if=SPL of=/dev/mmcblk0 bs=1k seek=1 $ sudo dd if=u-boot-dtb.img of=/dev/mmcblk0 bs=1k seek=69
with this patch:
$ sudo dd if=u-boot-imx6-with-spl.bin of=/dev/mmcblk0 bs=1k seek=1
I am quite confused. There is already a "u-boot-with-spl.imx" target, this works since a lot of time. Which is the reason to duplicate this feature or where is the difference ?
Best regards, Stefano Babic
This would be easily extended to single image creation for other imx6 soc boards.
This was tested on engicam imx6qdl and imx6ul boards
Reviewed-by: Jagan Teki jagan@amarulasolutions.com Signed-off-by: Shyam Saini shyam.saini@amarulasolutions.com
Makefile | 10 ++++++++++ arch/arm/dts/imx6-u-boot-binman.dtsi | 16 ++++++++++++++++ arch/arm/dts/imx6qdl-u-boot.dtsi | 1 + arch/arm/dts/imx6ul-u-boot.dtsi | 1 + arch/arm/mach-imx/mx6/Kconfig | 2 ++ doc/imx/common/imx6.txt | 5 +++++ 6 files changed, 35 insertions(+) create mode 100644 arch/arm/dts/imx6-u-boot-binman.dtsi
diff --git a/Makefile b/Makefile index f2c7bb6041..474271a1d0 100644 --- a/Makefile +++ b/Makefile @@ -851,6 +851,11 @@ ifeq ($(CONFIG_ARCH_SUNXI)$(CONFIG_SPL),yy) ALL-y += u-boot-sunxi-with-spl.bin endif
+# Build a combined spl + u-boot image for imx6 +ifeq ($(filter y, $(CONFIG_MX6QDL) $(CONFIG_MX6UL))$(CONFIG_SPL)$(CONFIG_OF_CONTROL),yyy) +ALL-$(CONFIG_ARCH_MX6) += u-boot-imx6-with-spl.bin +endif
# enable combined SPL/u-boot/dtb rules for tegra ifeq ($(CONFIG_TEGRA)$(CONFIG_SPL),yy) ALL-y += u-boot-tegra.bin u-boot-nodtb-tegra.bin @@ -1364,6 +1369,11 @@ u-boot-br.bin: u-boot FORCE endif endif
+ifeq ($(filter y, $(CONFIG_MX6QDL) $(CONFIG_MX6UL))$(CONFIG_SPL)$(CONFIG_OF_CONTROL),yyy) +u-boot-imx6-with-spl.bin: SPL u-boot-dtb.img FORCE
- @$(call if_changed,binman)
+endif
# x86 uses a large ROM. We fill it with 0xff, put the 16-bit stuff (including # reset vector) at the top, Intel ME descriptor at the bottom, and U-Boot in # the middle. This is handled by binman based on an image description in the diff --git a/arch/arm/dts/imx6-u-boot-binman.dtsi b/arch/arm/dts/imx6-u-boot-binman.dtsi new file mode 100644 index 0000000000..fa02d5f61f --- /dev/null +++ b/arch/arm/dts/imx6-u-boot-binman.dtsi @@ -0,0 +1,16 @@ +#include <config.h>
+/ {
- binman {
filename = "u-boot-imx6-with-spl.bin";
pad-byte = <0xff>;
blob {
filename = "SPL";
};
u-boot-img {
offset = <CONFIG_SPL_PAD_TO>;
};
- };
+}; diff --git a/arch/arm/dts/imx6qdl-u-boot.dtsi b/arch/arm/dts/imx6qdl-u-boot.dtsi index 0aa29e38b8..3dfa84dcac 100644 --- a/arch/arm/dts/imx6qdl-u-boot.dtsi +++ b/arch/arm/dts/imx6qdl-u-boot.dtsi @@ -2,6 +2,7 @@ /*
- Copyright (C) 2018 Jagan Teki jagan@amarulasolutions.com
*/ +#include "imx6-u-boot-binman.dtsi"
/ { soc { diff --git a/arch/arm/dts/imx6ul-u-boot.dtsi b/arch/arm/dts/imx6ul-u-boot.dtsi index eb190cf8c8..4e769da0d5 100644 --- a/arch/arm/dts/imx6ul-u-boot.dtsi +++ b/arch/arm/dts/imx6ul-u-boot.dtsi @@ -2,6 +2,7 @@ /*
- Copyright (C) 2018 Jagan Teki jagan@amarulasolutions.com
*/ +#include "imx6-u-boot-binman.dtsi"
/ { soc { diff --git a/arch/arm/mach-imx/mx6/Kconfig b/arch/arm/mach-imx/mx6/Kconfig index e782859b1e..7de1a00935 100644 --- a/arch/arm/mach-imx/mx6/Kconfig +++ b/arch/arm/mach-imx/mx6/Kconfig @@ -34,6 +34,7 @@ config MX6QDL bool select HAS_CAAM select MX6_SMP
- select BINMAN if SPL && OF_CONTROL
config MX6S bool @@ -57,6 +58,7 @@ config MX6UL select ROM_UNIFIED_SECTIONS select SYSCOUNTER_TIMER select SYS_L2CACHE_OFF
- select BINMAN if SPL && OF_CONTROL
config MX6UL_LITESOM bool diff --git a/doc/imx/common/imx6.txt b/doc/imx/common/imx6.txt index eab88353f6..5a10f94957 100644 --- a/doc/imx/common/imx6.txt +++ b/doc/imx/common/imx6.txt @@ -88,3 +88,8 @@ Reading bank 4:
Word 0x00000002: 9f027772 00000004
+2. Single Boot Image +--------------------- +Write your single imx6 uboot image as:
+$ sudo dd if=u-boot-imx6-with-spl.bin of=/dev/mmcblk0 bs=1k seek=1

Hi Stefano,
On Tue, Apr 30, 2019 at 9:36 PM Stefano Babic sbabic@denx.de wrote:
Hi Shyam,
On 30/04/19 12:33, Shyam Saini wrote:
IMX6 platform has two stage boot loaders like SPL and U-Boot proper. For each stage we need to burn the image on to flash with respective offsets.
This patch create a single image using binman, so that user can get rid of burning different stage boot images.
without this patch:
$ sudo dd if=SPL of=/dev/mmcblk0 bs=1k seek=1 $ sudo dd if=u-boot-dtb.img of=/dev/mmcblk0 bs=1k seek=69
with this patch:
$ sudo dd if=u-boot-imx6-with-spl.bin of=/dev/mmcblk0 bs=1k seek=1
I am quite confused. There is already a "u-boot-with-spl.imx" target, this works since a lot of time. Which is the reason to duplicate this feature or where is the difference ?
At-least I did noticed this now, since it require explicit 'make u-boot-with-spl.bin' I hardly unaware before this been available for i.mx6.
But, this binman feature more extensible than the Makefile oriented and the same been adopting by many platforms. May be we can come-up with common solution with binman, what do you think?
Jagan.

On 30/04/19 18:56, Jagan Teki wrote:
Hi Stefano,
On Tue, Apr 30, 2019 at 9:36 PM Stefano Babic sbabic@denx.de wrote:
Hi Shyam,
On 30/04/19 12:33, Shyam Saini wrote:
IMX6 platform has two stage boot loaders like SPL and U-Boot proper. For each stage we need to burn the image on to flash with respective offsets.
This patch create a single image using binman, so that user can get rid of burning different stage boot images.
without this patch:
$ sudo dd if=SPL of=/dev/mmcblk0 bs=1k seek=1 $ sudo dd if=u-boot-dtb.img of=/dev/mmcblk0 bs=1k seek=69
with this patch:
$ sudo dd if=u-boot-imx6-with-spl.bin of=/dev/mmcblk0 bs=1k seek=1
I am quite confused. There is already a "u-boot-with-spl.imx" target, this works since a lot of time. Which is the reason to duplicate this feature or where is the difference ?
At-least I did noticed this now, since it require explicit 'make u-boot-with-spl.bin' I hardly unaware before this been available for i.mx6.
But, this binman feature more extensible than the Makefile oriented and the same been adopting by many platforms. May be we can come-up with common solution with binman, what do you think?
First, I would like to avoid to have the same feature implemented multiple times in different ways.
If we can get the same solution for all platform, fine. But I guess i.MX is not the only one having such as target, socFPGA has the same solution.
Regards, Stefano

On Tue, Apr 30, 2019 at 10:30 PM Stefano Babic sbabic@denx.de wrote:
On 30/04/19 18:56, Jagan Teki wrote:
Hi Stefano,
On Tue, Apr 30, 2019 at 9:36 PM Stefano Babic sbabic@denx.de wrote:
Hi Shyam,
On 30/04/19 12:33, Shyam Saini wrote:
IMX6 platform has two stage boot loaders like SPL and U-Boot proper. For each stage we need to burn the image on to flash with respective offsets.
This patch create a single image using binman, so that user can get rid of burning different stage boot images.
without this patch:
$ sudo dd if=SPL of=/dev/mmcblk0 bs=1k seek=1 $ sudo dd if=u-boot-dtb.img of=/dev/mmcblk0 bs=1k seek=69
with this patch:
$ sudo dd if=u-boot-imx6-with-spl.bin of=/dev/mmcblk0 bs=1k seek=1
I am quite confused. There is already a "u-boot-with-spl.imx" target, this works since a lot of time. Which is the reason to duplicate this feature or where is the difference ?
At-least I did noticed this now, since it require explicit 'make u-boot-with-spl.bin' I hardly unaware before this been available for i.mx6.
But, this binman feature more extensible than the Makefile oriented and the same been adopting by many platforms. May be we can come-up with common solution with binman, what do you think?
First, I would like to avoid to have the same feature implemented multiple times in different ways.
As I said, we didn't know this was supported before since it require an explicit argument to build..it's our bad.
If we can get the same solution for all platform, fine. But I guess i.MX is not the only one having such as target, socFPGA has the same solution.
Okay.

On 30/04/19 19:08, Jagan Teki wrote:
On Tue, Apr 30, 2019 at 10:30 PM Stefano Babic sbabic@denx.de wrote:
On 30/04/19 18:56, Jagan Teki wrote:
Hi Stefano,
On Tue, Apr 30, 2019 at 9:36 PM Stefano Babic sbabic@denx.de wrote:
Hi Shyam,
On 30/04/19 12:33, Shyam Saini wrote:
IMX6 platform has two stage boot loaders like SPL and U-Boot proper. For each stage we need to burn the image on to flash with respective offsets.
This patch create a single image using binman, so that user can get rid of burning different stage boot images.
without this patch:
$ sudo dd if=SPL of=/dev/mmcblk0 bs=1k seek=1 $ sudo dd if=u-boot-dtb.img of=/dev/mmcblk0 bs=1k seek=69
with this patch:
$ sudo dd if=u-boot-imx6-with-spl.bin of=/dev/mmcblk0 bs=1k seek=1
I am quite confused. There is already a "u-boot-with-spl.imx" target, this works since a lot of time. Which is the reason to duplicate this feature or where is the difference ?
At-least I did noticed this now, since it require explicit 'make u-boot-with-spl.bin' I hardly unaware before this been available for i.mx6.
But, this binman feature more extensible than the Makefile oriented and the same been adopting by many platforms. May be we can come-up with common solution with binman, what do you think?
First, I would like to avoid to have the same feature implemented multiple times in different ways.
As I said, we didn't know this was supported before since it require an explicit argument to build..it's our bad.
No problem ;-) - there are so many new features / targets in U-Boot, I think I know just a small percentage of them.. ;-)
If we can get the same solution for all platform, fine. But I guess i.MX is not the only one having such as target, socFPGA has the same solution.
Okay.
Best regards, Stefano
participants (4)
-
Fabio Estevam
-
Jagan Teki
-
Shyam Saini
-
Stefano Babic