Skip to contentSkip to conversation

Add support to build imx8 images using mainline uboot

PATCH Applied Heiko Thiery 3 participants 13 messages Sep 10, 2021 – Sep 11, 2021 Arm i.MX and Layerscape

lore
Share & tools
lore
#0 lore raw

v2 cover Add support to build imx8 images using mainline uboot

New U-Boot version support building the flash.bin bootimage using binman. For that the imx specific firmware files like (LP)DDR and HDMI firmware has to be located in the u-boot builddirectory.

Xavier Roumegue already posted a patchset [1] to add this support but did no follow up version after getting review comments.

I have taken up these comments and prepared the patchset.

[1] https://lists.buildroot.org/pipermail/buildroot/2020-November/599906.html

Heiko Thiery (3):
package/freescale-imx/firmware-imx: copy all (lp)ddr files
unconditionaly
boot/uboot: copy ATF bl31 binary to uboot package dir boot/uboot: copy IMX firmware files to uboot package dir

 boot/uboot/Config.in                          | 12 +++++++
 boot/uboot/uboot.mk                           | 35 +++++++++++++++++++
 .../firmware-imx/firmware-imx.mk              | 10 ++++++
 3 files changed, 57 insertions(+)
Signature · 6 lines
2.30.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH v2 1/3 package/freescale-imx/firmware-imx: copy all (lp)ddr files unconditionaly

In mainline u-boot more and more imx8 boards are switched to binman to create the imx specific image (flash.bin). To support this the (lp)ddr firmware training files are needed. For this to work all files should be made available to the U-Boot build.

---

v2:
- add reviewed-by (thanks Gary)

 package/freescale-imx/firmware-imx/firmware-imx.mk | 10 ++++++++++
 1 file changed, 10 insertions(+)
package/freescale-imx/firmware-imx/firmware-imx.mk +10 -0
index 1076cf85f1..29241342be 100644
@@ -51,6 +51,11 @@ define FIRMWARE_IMX_INSTALL_IMAGE_DDR_FW
 		$(FIRMWARE_IMX_DDRFW_DIR)/lpddr4_pmu_train_2d_fw.bin > \
 		$(BINARIES_DIR)/lpddr4_pmu_train_fw.bin
 	ln -sf $(BINARIES_DIR)/lpddr4_pmu_train_fw.bin $(BINARIES_DIR)/ddr_fw.bin
+
+	# U-Boot supports creation of the combined flash.bin image. To make
+	# sure that U-Boot can access all available files copy them to
+	# the binary dir.
+	cp $(FIRMWARE_IMX_DDRFW_DIR)/lpddr4*.bin $(BINARIES_DIR)/
 endef
 endif
 
@@ -69,6 +74,11 @@ define FIRMWARE_IMX_INSTALL_IMAGE_DDR_FW
 		$(FIRMWARE_IMX_DDRFW_DIR)/ddr4_2d_201810_fw.bin > \
 		$(BINARIES_DIR)/ddr4_201810_fw.bin
 	ln -sf $(BINARIES_DIR)/ddr4_201810_fw.bin $(BINARIES_DIR)/ddr_fw.bin
+
+	# U-Boot supports creation of the combined flash.bin image. To make
+	# sure that U-Boot can access all available files copy them to
+	# the binary dir.
+	cp $(FIRMWARE_IMX_DDRFW_DIR)/ddr4*.bin $(BINARIES_DIR)/
 endef
 endif
 
Signature · 6 lines
2.30.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
reviewer Reviewed-by on v2 1/3
#2 lore raw

Re: [Buildroot] [PATCH v2 1/3] package/freescale-imx/firmware-imx: copy all (lp)ddr files unconditionaly

Hi Heiko,

Quoted 8 lines · Heiko Thiery

In mainline u-boot more and more imx8 boards are switched to binman to create the imx specific image (flash.bin). To support this the (lp)ddr firmware training files are needed. For this to work all files should be made available to the U-Boot build.

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw

Re: [Buildroot] [PATCH v2 1/3] package/freescale-imx/firmware-imx: copy all (lp)ddr files unconditionaly

In reply to Heiko Thiery
Quoted 7 lines · Heiko Thiery

In mainline u-boot more and more imx8 boards are switched to binman to create the imx specific image (flash.bin). To support this the (lp)ddr firmware training files are needed. For this to work all files should be made available to the U-Boot build.

Applied to master, thanks.

Regards,
Arnout

Quoted 27 lines

---

v2:
- add reviewed-by (thanks Gary)

 package/freescale-imx/firmware-imx/firmware-imx.mk | 10 ++++++++++
 1 file changed, 10 insertions(+)
package/freescale-imx/firmware-imx/firmware-imx.mk +5 -0
index 1076cf85f1..29241342be 100644
@@ -51,6 +51,11 @@ define FIRMWARE_IMX_INSTALL_IMAGE_DDR_FW
 		$(FIRMWARE_IMX_DDRFW_DIR)/lpddr4_pmu_train_2d_fw.bin > \
 		$(BINARIES_DIR)/lpddr4_pmu_train_fw.bin
 	ln -sf $(BINARIES_DIR)/lpddr4_pmu_train_fw.bin $(BINARIES_DIR)/ddr_fw.bin
+
+	# U-Boot supports creation of the combined flash.bin image. To make
+	# sure that U-Boot can access all available files copy them to
+	# the binary dir.
+	cp $(FIRMWARE_IMX_DDRFW_DIR)/lpddr4*.bin $(BINARIES_DIR)/
 endef
 endif
 
@@ -69,6 +74,11 @@ define FIRMWARE_IMX_INSTALL_IMAGE_DDR_FW
 		$(FIRMWARE_IMX_DDRFW_DIR)/ddr4_2d_201810_fw.bin > \

package/freescale-imx/firmware-imx/firmware-imx.mk define FIRMWARE_IMX_INSTALL_IMAGE_DDR_FW · line 84

Quoted 10 lines
package/freescale-imx/firmware-imx/firmware-imx.mk +5 -0
 		$(BINARIES_DIR)/ddr4_201810_fw.bin
 	ln -sf $(BINARIES_DIR)/ddr4_201810_fw.bin $(BINARIES_DIR)/ddr_fw.bin
+
+	# U-Boot supports creation of the combined flash.bin image. To make
+	# sure that U-Boot can access all available files copy them to
+	# the binary dir.
+	cp $(FIRMWARE_IMX_DDRFW_DIR)/ddr4*.bin $(BINARIES_DIR)/
 endef
 endif
 

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#4 lore raw

PATCH v2 2/3 boot/uboot: copy ATF bl31 binary to uboot package dir

In reply to Heiko Thiery

If the U-Boot image is to be built with binman and the ATF binary is used, the file is expected in the toplevel directory.

---
 boot/uboot/uboot.mk | 8 ++++++++
 1 file changed, 8 insertions(+)
boot/uboot/uboot.mk +8 -0
index 4f3c9b7c3a..1a840d9cc1 100644
@@ -162,8 +162,16 @@ ifeq ($(BR2_TARGET_UBOOT_NEEDS_ATF_BL31),y)
 UBOOT_DEPENDENCIES += arm-trusted-firmware
 ifeq ($(BR2_TARGET_UBOOT_NEEDS_ATF_BL31_ELF),y)
 UBOOT_MAKE_OPTS += BL31=$(BINARIES_DIR)/bl31.elf
+define UBOOT_COPY_ATF_FIRMWARE
+	cp $(BINARIES_DIR)/bl31.elf $(@D)/
+endef
+UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_ATF_FIRMWARE
 else
 UBOOT_MAKE_OPTS += BL31=$(BINARIES_DIR)/bl31.bin
+define UBOOT_COPY_ATF_FIRMWARE
+	cp $(BINARIES_DIR)/bl31.bin $(@D)/
+endef
+UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_ATF_FIRMWARE
 endif
 endif
 
Signature · 6 lines
2.30.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
reviewer Reviewed-by on v2 2/3
#5 lore raw

Re: [Buildroot] [PATCH v2 2/3] boot/uboot: copy ATF bl31 binary to uboot package dir

Quoted 5 lines · Heiko Thiery

If the U-Boot image is to be built with binman and the ATF binary is used, the file is expected in the toplevel directory.

This applies even if the image is built without binman:

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#6 lore raw

Re: [Buildroot] [PATCH v2 2/3] boot/uboot: copy ATF bl31 binary to uboot package dir

Hi Fabio,

Am Fr., 10. Sept. 2021 um 16:27 Uhr schrieb Fabio Estevam <[email protected]>:

Quoted 9 lines · Heiko Thiery
Quoted 5 lines

If the U-Boot image is to be built with binman and the ATF binary is used, the file is expected in the toplevel directory.

This applies even if the image is built without binman:

I don't think that's quite right. With the old mainline uboot you could also build the flash.bin, but that was optional. The make rule 'flash.bin' was not part of 'make all'. But with the change to binman the files are now necessary, because 'make all' now also builds the flash.bin.

Quoted 1 line
Signature · 5 lines
Heiko
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
reviewer
#7 lore raw

Re: [Buildroot] [PATCH v2 2/3] boot/uboot: copy ATF bl31 binary to uboot package dir

Hi Heiko,

Quoted 5 lines · Heiko Thiery

I don't think that's quite right. With the old mainline uboot you could also build the flash.bin, but that was optional. The make rule 'flash.bin' was not part of 'make all'. But with the change to binman the files are now necessary, because 'make all' now also builds the flash.bin.

The need for bl31.bin present in the build directory was required even prior to the binman conversion.

For example, let's take the U-Boot 2021.01 readme for imx8mm evk:
https://source.denx.de/u-boot/u-boot/-/blob/v2021.01/doc/board/freescale/imx8mm_evk.rst
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#8 lore raw

Re: [Buildroot] [PATCH v2 2/3] boot/uboot: copy ATF bl31 binary to uboot package dir

Hi Fabio,

Am Fr., 10. Sept. 2021 um 18:08 Uhr schrieb Fabio Estevam <[email protected]>:

Quoted 11 lines

Hi Heiko,

Quoted 5 lines · Heiko Thiery

I don't think that's quite right. With the old mainline uboot you could also build the flash.bin, but that was optional. The make rule 'flash.bin' was not part of 'make all'. But with the change to binman the files are now necessary, because 'make all' now also builds the flash.bin.

Quoted 5 lines

The need for bl31.bin present in the build directory was required even prior to the binman conversion.

For example, let's take the U-Boot 2021.01 readme for imx8mm evk:
https://source.denx.de/u-boot/u-boot/-/blob/v2021.01/doc/board/freescale/imx8mm_evk.rst

ah ok .. I was not aware of that. I just thought this requirement comes from building via binman.

Thank you

Signature · 5 lines
Heiko
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#9 lore raw

Re: [Buildroot] [PATCH v2 2/3] boot/uboot: copy ATF bl31 binary to uboot package dir

In reply to Heiko Thiery
Quoted 4 lines · Heiko Thiery

If the U-Boot image is to be built with binman and the ATF binary is used, the file is expected in the toplevel directory.

Applied to master, thanks. I've updated the commit message to reflect that it's
not related to binman.

Regards,
Arnout

Quoted 16 lines
---
 boot/uboot/uboot.mk | 8 ++++++++
 1 file changed, 8 insertions(+)
boot/uboot/uboot.mk +3 -0
index 4f3c9b7c3a..1a840d9cc1 100644
@@ -162,8 +162,16 @@ ifeq ($(BR2_TARGET_UBOOT_NEEDS_ATF_BL31),y)
 UBOOT_DEPENDENCIES += arm-trusted-firmware
 ifeq ($(BR2_TARGET_UBOOT_NEEDS_ATF_BL31_ELF),y)
 UBOOT_MAKE_OPTS += BL31=$(BINARIES_DIR)/bl31.elf
+define UBOOT_COPY_ATF_FIRMWARE
+	cp $(BINARIES_DIR)/bl31.elf $(@D)/
+endef

boot/uboot/uboot.mk ifeq ($(BR2_TARGET_UBOOT_NEEDS_ATF_BL31),y) · line 177

Quoted 10 lines
boot/uboot/uboot.mk +5 -0
+UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_ATF_FIRMWARE
 else
 UBOOT_MAKE_OPTS += BL31=$(BINARIES_DIR)/bl31.bin
+define UBOOT_COPY_ATF_FIRMWARE
+	cp $(BINARIES_DIR)/bl31.bin $(@D)/
+endef
+UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_ATF_FIRMWARE
 endif
 endif
 

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#10 lore raw

PATCH v2 3/3 boot/uboot: copy IMX firmware files to uboot package dir

In reply to Heiko Thiery

If the U-Boot image is to be built with binman and one of the i.MX firmware files (ddr, hdmi) is used, the files are expected in the toplevel directory.

---

v2:
- small changes in commit messages (thanks Stephane)
- use "i.MX 8M" for consistency (thanks Stephane)

 boot/uboot/Config.in | 12 ++++++++++++
 boot/uboot/uboot.mk  | 27 +++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)
boot/uboot/Config.in +12 -0
index 0854fb13cc..da518db118 100644
@@ -239,6 +239,18 @@ config BR2_TARGET_UBOOT_NEEDS_OPENSBI
 	  and that the OpenSBI variable pointing to OpenSBI binary,
 	  is passed during the Buildroot build.
 
+config BR2_TARGET_UBOOT_NEEDS_IMX_FIRMWARE
+	bool "U-Boot needs firmware-imx"
+	depends on BR2_PACKAGE_FIRMWARE_IMX
+	depends on BR2_PACKAGE_FIRMWARE_IMX_NEEDS_DDR_FW || \
+		BR2_PACKAGE_FIRMWARE_IMX_NEEDS_HDMI_FW
+	help
+	  Some IMX platforms (such as iMX8m, iMX8mq, iIMX8mm, iIMX8mn)
+	  encapsulate NXP specific firmware (DDR, HDMI) inside U-Boot.
+	  This option makes sure the imx firmware gets built prior to
+	  U-Boot and copies the files from the buildroot binary dir
+	  into the U-Boot source dir.
+
 menu "U-Boot binary format"
 
 config BR2_TARGET_UBOOT_FORMAT_AIS
boot/uboot/uboot.mk +27 -0
index 1a840d9cc1..cf8d6b1f39 100644
@@ -180,6 +180,33 @@ UBOOT_DEPENDENCIES += opensbi
 UBOOT_MAKE_OPTS += OPENSBI=$(BINARIES_DIR)/fw_dynamic.bin
 endif
 
+# New U-Boot versions can create the IMX specific boot images
+# and needs the some NXP firmware blobs.
+ifeq ($(BR2_TARGET_UBOOT_NEEDS_IMX_FIRMWARE),y)
+UBOOT_DEPENDENCIES += firmware-imx
+
+ifeq ($(BR2_PACKAGE_FIRMWARE_IMX_NEEDS_HDMI_FW),y)
+define UBOOT_COPY_IMX_DDR_FIRMWARE
+	cp $(BINARIES_DIR)/signed_hdmi_imx8m.bin $(@D)/
+endef
+UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_IMX_DDR_FIRMWARE
+endif
+
+ifeq ($(BR2_PACKAGE_FIRMWARE_IMX_LPDDR4),y)
+define UBOOT_COPY_IMX_LPDDR4_FIRMWARE
+	cp $(BINARIES_DIR)/lpddr4*.bin $(@D)/
+endef
+UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_IMX_LPDDR4_FIRMWARE
+endif
+
+ifeq ($(BR2_PACKAGE_FIRMWARE_IMX_DDR4),y)
+define UBOOT_COPY_IMX_DDR4_FIRMWARE
+	cp $(BINARIES_DIR)/ddr4*.bin $(@D)/
+endef
+UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_IMX_DDR4_FIRMWARE
+endif
+endif
+
 ifeq ($(BR2_TARGET_UBOOT_NEEDS_DTC),y)
 UBOOT_DEPENDENCIES += host-dtc
 endif
Signature · 6 lines
2.30.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
reviewer Reviewed-by on v2 3/3
#11 lore raw

Re: [Buildroot] [PATCH v2 3/3] boot/uboot: copy IMX firmware files to uboot package dir

Quoted 4 lines · Heiko Thiery

If the U-Boot image is to be built with binman and one of the i.MX firmware files (ddr, hdmi) is used, the files are expected in the toplevel directory.

I would remove binman from the description as this is not binman related.

boot/uboot/Config.in config BR2_TARGET_UBOOT_NEEDS_OPENSBI · line 250

Quoted 12 lines
boot/uboot/Config.in +9 -0
+config BR2_TARGET_UBOOT_NEEDS_IMX_FIRMWARE
+       bool "U-Boot needs firmware-imx"
+       depends on BR2_PACKAGE_FIRMWARE_IMX
+       depends on BR2_PACKAGE_FIRMWARE_IMX_NEEDS_DDR_FW || \
+               BR2_PACKAGE_FIRMWARE_IMX_NEEDS_HDMI_FW
+       help
+         Some IMX platforms (such as iMX8m, iMX8mq, iIMX8mm, iIMX8mn)
+         encapsulate NXP specific firmware (DDR, HDMI) inside U-Boot.
+         This option makes sure the imx firmware gets built prior to

The imx firmwares are binaries, so they are not built. Please adjust it to:

"This option makes sure that the imx firmwares are copied into the U-Boot source directory".

Quoted 11 lines
boot/uboot/Config.in +3 -0
+         U-Boot and copies the files from the buildroot binary dir
+         into the U-Boot source dir.
+
 menu "U-Boot binary format"
 
 config BR2_TARGET_UBOOT_FORMAT_AIS
boot/uboot/uboot.mk +0 -0
index 1a840d9cc1..cf8d6b1f39 100644

boot/uboot/uboot.mk UBOOT_DEPENDENCIES += opensbi · line 183

Quoted 4 lines
boot/uboot/uboot.mk +1 -0
@@ -180,6 +180,33 @@ UBOOT_DEPENDENCIES += opensbi
 UBOOT_MAKE_OPTS += OPENSBI=$(BINARIES_DIR)/fw_dynamic.bin
 endif
 
+# New U-Boot versions can create the IMX specific boot images

s/New/Mainline

boot/uboot/uboot.mk UBOOT_DEPENDENCIES += opensbi · line 184

Quoted 1 line
boot/uboot/uboot.mk +1 -0
+# and needs the some NXP firmware blobs.

s/needs the some/need some

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#12 lore raw

Re: [Buildroot] [PATCH v2 3/3] boot/uboot: copy IMX firmware files to uboot package dir

In reply to Heiko Thiery
Quoted 5 lines · Heiko Thiery

If the U-Boot image is to be built with binman and one of the i.MX firmware files (ddr, hdmi) is used, the files are expected in the toplevel directory.

I was too lazy to update with all of Fabio's comments :-) so I marked as
Changes Requested.

Regards,
Arnout

Quoted 62 lines

---

v2:
- small changes in commit messages (thanks Stephane)
- use "i.MX 8M" for consistency (thanks Stephane)

 boot/uboot/Config.in | 12 ++++++++++++
 boot/uboot/uboot.mk  | 27 +++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)
boot/uboot/Config.in +12 -0
index 0854fb13cc..da518db118 100644
@@ -239,6 +239,18 @@ config BR2_TARGET_UBOOT_NEEDS_OPENSBI
 	  and that the OpenSBI variable pointing to OpenSBI binary,
 	  is passed during the Buildroot build.
 
+config BR2_TARGET_UBOOT_NEEDS_IMX_FIRMWARE
+	bool "U-Boot needs firmware-imx"
+	depends on BR2_PACKAGE_FIRMWARE_IMX
+	depends on BR2_PACKAGE_FIRMWARE_IMX_NEEDS_DDR_FW || \
+		BR2_PACKAGE_FIRMWARE_IMX_NEEDS_HDMI_FW
+	help
+	  Some IMX platforms (such as iMX8m, iMX8mq, iIMX8mm, iIMX8mn)
+	  encapsulate NXP specific firmware (DDR, HDMI) inside U-Boot.
+	  This option makes sure the imx firmware gets built prior to
+	  U-Boot and copies the files from the buildroot binary dir
+	  into the U-Boot source dir.
+
 menu "U-Boot binary format"
 
 config BR2_TARGET_UBOOT_FORMAT_AIS
boot/uboot/uboot.mk +20 -0
index 1a840d9cc1..cf8d6b1f39 100644
@@ -180,6 +180,33 @@ UBOOT_DEPENDENCIES += opensbi
 UBOOT_MAKE_OPTS += OPENSBI=$(BINARIES_DIR)/fw_dynamic.bin
 endif
 
+# New U-Boot versions can create the IMX specific boot images
+# and needs the some NXP firmware blobs.
+ifeq ($(BR2_TARGET_UBOOT_NEEDS_IMX_FIRMWARE),y)
+UBOOT_DEPENDENCIES += firmware-imx
+
+ifeq ($(BR2_PACKAGE_FIRMWARE_IMX_NEEDS_HDMI_FW),y)
+define UBOOT_COPY_IMX_DDR_FIRMWARE
+	cp $(BINARIES_DIR)/signed_hdmi_imx8m.bin $(@D)/
+endef
+UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_IMX_DDR_FIRMWARE
+endif
+
+ifeq ($(BR2_PACKAGE_FIRMWARE_IMX_LPDDR4),y)
+define UBOOT_COPY_IMX_LPDDR4_FIRMWARE
+	cp $(BINARIES_DIR)/lpddr4*.bin $(@D)/
+endef
+UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_IMX_LPDDR4_FIRMWARE
+endif
+
+ifeq ($(BR2_PACKAGE_FIRMWARE_IMX_DDR4),y)

boot/uboot/uboot.mk UBOOT_DEPENDENCIES += opensbi · line 212

Quoted 10 lines
boot/uboot/uboot.mk +7 -0
+define UBOOT_COPY_IMX_DDR4_FIRMWARE
+	cp $(BINARIES_DIR)/ddr4*.bin $(@D)/
+endef
+UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_IMX_DDR4_FIRMWARE
+endif
+endif
+
 ifeq ($(BR2_TARGET_UBOOT_NEEDS_DTC),y)
 UBOOT_DEPENDENCIES += host-dtc
 endif

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot