uboot: Introduce BR2_TARGET_UBOOT_FORMAT_DTB_IMX
Fabio Estevam
reviewerPATCH 1/3 uboot: Introduce BR2_TARGET_UBOOT_FORMAT_DTB_IMX
Some i.MX boards which use device tree to describe the hardware for U-Boot generate a u-boot-dtb.imx binary.
Introduce the BR2_TARGET_UBOOT_FORMAT_DTB_IMX option to handle such case.
--- boot/uboot/Config.in | 3 +++ boot/uboot/uboot.mk | 5 +++++ 2 files changed, 8 insertions(+)
boot/uboot/Config.in +3 -0
@@ -190,6 +190,9 @@ config BR2_TARGET_UBOOT_FORMAT_DTB_BIN config BR2_TARGET_UBOOT_FORMAT_DTB_IMG bool "u-boot-dtb.img" +config BR2_TARGET_UBOOT_FORMAT_DTB_IMX + bool "u-boot-dtb.imx" + config BR2_TARGET_UBOOT_FORMAT_IMG bool "u-boot.img"
boot/uboot/uboot.mk +5 -0
@@ -70,6 +70,11 @@ UBOOT_BINS += u-boot-dtb.img UBOOT_MAKE_TARGET += u-boot-dtb.img endif +ifeq ($(BR2_TARGET_UBOOT_FORMAT_DTB_IMX),y) +UBOOT_BINS += u-boot-dtb.imx +UBOOT_MAKE_TARGET += u-boot-dtb.imx +endif + ifeq ($(BR2_TARGET_UBOOT_FORMAT_DTB_BIN),y) UBOOT_BINS += u-boot-dtb.bin UBOOT_MAKE_TARGET += u-boot-dtb.bin
Signature · 1 line
2.7.4
Fabio Estevam
reviewerPATCH 2/3 imx/post-image: Allow flashing u-boot-dtb.imx in the SD card
Add support for flashing the u-boot-dtb.imx binary in the SD card when a target selects BR2_TARGET_UBOOT_FORMAT_DTB_IMX.
--- .../common/imx/genimage.cfg.template_dtb_imx | 40 ++++++++++++++++++++++ board/freescale/common/imx/post-image.sh | 2 ++ 2 files changed, 42 insertions(+) create mode 100644 board/freescale/common/imx/genimage.cfg.template_dtb_imx
board/freescale/common/imx/genimage.cfg.template_dtb_imx new file +40 -0
@@ -0,0 +1,40 @@ +# Minimal SD card image for the Freescale boards Template +# +# We mimic the .sdcard Freescale's image format: +# * the SD card must have 1 kB free space at the beginning, +# * U-Boot is dumped as is, +# * a FAT partition at offset 8 MB is containing zImage/uImage and DTB files +# * a single root filesystem partition is required (ext2, ext3 or ext4) +# + +image boot.vfat { + vfat { + files = { + %FILES% + } + } + size = 16M +} + +image sdcard.img { + hdimage { + } + + partition u-boot { + in-partition-table = "no" + image = "u-boot-dtb.imx" + offset = 1024 + } + + partition boot { + partition-type = 0xC + bootable = "true" + image = "boot.vfat" + offset = 8M + } + + partition rootfs { + partition-type = 0x83 + image = "rootfs.ext2" + } +}
board/freescale/common/imx/post-image.sh +2 -0
@@ -36,6 +36,8 @@ genimage_type() echo "genimage.cfg.template_imx8" elif grep -Eq "^BR2_TARGET_UBOOT_SPL=y$" ${BR2_CONFIG}; then echo "genimage.cfg.template_spl" + elif grep -Eq "^BR2_TARGET_UBOOT_FORMAT_DTB_IMX=y$" ${BR2_CONFIG}; then + echo "genimage.cfg.template_dtb_imx" else echo "genimage.cfg.template" fi
Signature · 1 line
2.7.4
PATCH 2/3 imx/post-image: Allow flashing u-boot-dtb.imx in the SD card
board/freescale/common/imx/genimage.cfg.template_dtb_imx
Quoted 11 lines · Fabio Estevam
Add support for flashing the u-boot-dtb.imx binary in the SD card when a target selects
BR2_TARGET_UBOOT_FORMAT_DTB_IMX.Signed-off-by Fabio Estevam <[email protected]>--- .../common/imx/genimage.cfg.template_dtb_imx | 40 ++++++++++++++++++++++ board/freescale/common/imx/post-image.sh | 2 ++ 2 files changed, 42 insertions(+) create mode 100644 board/freescale/common/imx/genimage.cfg.template_dtb_imxboard/freescale/common/imx/genimage.cfg.template_dtb_imx +0
-0
This file only differs from the normal template in the name of the u-boot
binary, right? So wouldn't it make more sense to make that configurable, just like the %FILES%, and handle it in an extra sed line?
Regards,
Arnout
Quoted 59 lines
new file mode 100644
index 0000000..b38dfa4board/freescale/common/imx/genimage.cfg.template_dtb_imx new file +40
-0@@ -0,0 +1,40 @@ +# Minimal SD card image for the Freescale boards Template +# +# We mimic the .sdcard Freescale's image format: +# * the SD card must have 1 kB free space at the beginning, +# * U-Boot is dumped as is, +# * a FAT partition at offset 8 MB is containing zImage/uImage and DTB files +# * a single root filesystem partition is required (ext2, ext3 or ext4) +# + +image boot.vfat { + vfat { + files = { + %FILES% + } + } + size = 16M +} + +image sdcard.img { + hdimage { + } + + partition u-boot { + in-partition-table = "no" + image = "u-boot-dtb.imx" + offset = 1024 + } + + partition boot { + partition-type = 0xC + bootable = "true" + image = "boot.vfat" + offset = 8M + } + + partition rootfs { + partition-type = 0x83 + image = "rootfs.ext2" + } +}board/freescale/common/imx/post-image.sh +2
-0@@ -36,6 +36,8 @@ genimage_type() echo "genimage.cfg.template_imx8" elif grep -Eq "^BR2_TARGET_UBOOT_SPL=y$" ${BR2_CONFIG}; then echo "genimage.cfg.template_spl" + elif grep -Eq "^BR2_TARGET_UBOOT_FORMAT_DTB_IMX=y$" ${BR2_CONFIG}; then + echo "genimage.cfg.template_dtb_imx" else echo "genimage.cfg.template" fi
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
Fabio Estevam
reviewerPATCH 2/3 imx/post-image: Allow flashing u-boot-dtb.imx in the SD card
Hi Arnout.
Quoted 3 lines · Arnout Vandecappelle
This file only differs from the normal template in the name of the u-boot
binary, right? So wouldn't it make more sense to make that configurable, just like the %FILES%, and handle it in an extra sed line?
That's correct: only the U-Boot binary name differs.
I need to learn how to make this generic as you suggested. I will give it a try.
Thanks
Fabio Estevam
reviewerPATCH 2/3 imx/post-image: Allow flashing u-boot-dtb.imx in the SD card
In reply to Arnout VandecappelleHi Arnout,
Quoted 3 lines · Arnout Vandecappelle
This file only differs from the normal template in the name of the u-boot
binary, right? So wouldn't it make more sense to make that configurable, just like the %FILES%, and handle it in an extra sed line?
I am trying to implement your suggestion, but I think I need some help.
Here is what I have done so far:
(quoted diff) +0 -0
b/board/freescale/common/imx/genimage.cfg.template index acce058..41584d9 100644
board/freescale/common/imx/genimage.cfg.template +1 -1
@@ -22,7 +22,7 @@ image sdcard.img { partition u-boot { in-partition-table = "no" - image = "u-boot.imx" + image = %UBOOTBIN% offset = 1024 }
(quoted diff) +0 -0
b/board/freescale/common/imx/post-image.sh
index 264c8a4..2e57cef 100755
board/freescale/common/imx/post-image.sh +13 -0
@@ -41,8 +41,18 @@ genimage_type() fi } +uboot_image() +{ + if grep -Eq "^BR2_TARGET_UBOOT_FORMAT_DTB_IMX=y$" ${BR2_CONFIG}; then + echo "u-boot-dtb.imx" + elif grep -Eq "^BR2_TARGET_UBOOT_FORMAT_IMX=y$" ${BR2_CONFIG}; then + echo "u-boot.imx" + fi +} + main() { + local UBOOTBIN="$(uboot_image)" local FILES="$(dtb_list) $(linux_image)" local GENIMAGE_CFG="$(mktemp --suffix genimage.cfg)" local GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
@@ -50,6 +60,9 @@ main() sed -e "s/%FILES%/${FILES}/" \ board/freescale/common/imx/$(genimage_type) > ${GENIMAGE_CFG} + sed -e "s/%UBOOTBIN%/${UBOOTBIN}/" \ + board/freescale/common/imx/$(genimage_type) > ${GENIMAGE_CFG} + rm -rf "${GENIMAGE_TMP}" genimage \
but it does not work:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Executing post-image script
board/freescale/common/imx/post-image.sh
file(%FILES%): stat(/home/fabio/buildroot/output/images/%FILES%)
failed: No such file or directory
vfat(boot.vfat): could not setup %FILES%
Could you please provide some suggestion?
Thanks
PATCH 2/3 imx/post-image: Allow flashing u-boot-dtb.imx in the SD card
Quoted 18 lines · Fabio Estevam
Hi Arnout,
Quoted 3 lines · Arnout Vandecappelle
This file only differs from the normal template in the name of the u-boot
binary, right? So wouldn't it make more sense to make that configurable, just like the %FILES%, and handle it in an extra sed line?I am trying to implement your suggestion, but I think I need some help.
Here is what I have done so far:
board/freescale/common/imx/genimage.cfg.template +0
-0
board/freescale/common/imx/genimage.cfg.template image sdcard.img { · line 25
Quoted 5 lines
board/freescale/common/imx/genimage.cfg.template +1
-1@@ -22,7 +22,7 @@ image sdcard.img { partition u-boot { in-partition-table = "no" - image = "u-boot.imx" + image = %UBOOTBIN%
You want to keep the quotation marks, so
image = "%UBOOBTIN%"
Quoted 28 lines
board/freescale/common/imx/genimage.cfg.template +0
-0offset = 1024 }board/freescale/common/imx/post-image.sh +10
-0@@ -41,8 +41,18 @@ genimage_type() fi } +uboot_image() +{ + if grep -Eq "^BR2_TARGET_UBOOT_FORMAT_DTB_IMX=y$" ${BR2_CONFIG}; then + echo "u-boot-dtb.imx" + elif grep -Eq "^BR2_TARGET_UBOOT_FORMAT_IMX=y$" ${BR2_CONFIG}; then + echo "u-boot.imx" + fi +} + main() { + local UBOOTBIN="$(uboot_image)" local FILES="$(dtb_list) $(linux_image)" local GENIMAGE_CFG="$(mktemp --suffix genimage.cfg)" local GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
board/freescale/common/imx/post-image.sh main() · line 65
Quoted 6 lines
board/freescale/common/imx/post-image.sh +3
-0@@ -50,6 +60,9 @@ main() sed -e "s/%FILES%/${FILES}/" \ board/freescale/common/imx/$(genimage_type) > ${GENIMAGE_CFG} + sed -e "s/%UBOOTBIN%/${UBOOTBIN}/" \ + board/freescale/common/imx/$(genimage_type) > ${GENIMAGE_CFG} +
This way, you're overwriting the file that was created just above. You need to
do both in a single command:
sed -e "s/%FILES%/${FILES}/" \
-e "s/%UBOOTBIN%/${UBOOTBIN}/" \
board/freescale/common/imx/$(genimage_type) > ${GENIMAGE_CFG} Regards,
Arnout
Quoted 15 lines
board/freescale/common/imx/post-image.sh +0
-0rm -rf "${GENIMAGE_TMP}" genimage \but it does not work:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Executing post-image script
board/freescale/common/imx/post-image.shfile(%FILES%): stat(/home/fabio/buildroot/output/images/%FILES%)
failed: No such file or directory
vfat(boot.vfat): could not setup %FILES%Could you please provide some suggestion?
Thanks
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
Fabio Estevam
reviewerPATCH 2/3 imx/post-image: Allow flashing u-boot-dtb.imx in the SD card
Hi Arnout,
Quoted 6 lines · Arnout Vandecappelle
This way, you're overwriting the file that was created just above. You need to
do both in a single command:sed -e "s/%FILES%/${FILES}/" \ -e "s/%UBOOTBIN%/${UBOOTBIN}/" \ board/freescale/common/imx/$(genimage_type) > ${GENIMAGE_CFG}
Thanks a lot for your suggestions! It is working fine now.
Really appreciated!
Will submit a v2.
Fabio Estevam
reviewerPATCH 3/3 configs/imx7d-sdb: Add new defconfig
In reply to Fabio EstevamIntroduce imx7d-sdb_defconfig that allows booting imx7d-sdb board using U-Boot and kernel mainline instead of the vendor provided versions.
--- configs/imx7d-sdb_defconfig | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 configs/imx7d-sdb_defconfig
configs/imx7d-sdb_defconfig new file +36 -0
@@ -0,0 +1,36 @@ +# architecture +BR2_arm=y +BR2_cortex_a7=y +BR2_ARM_FPU_NEON_VFPV4=y + +# Linux headers same as kernel, a 4.17 series +BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_17=y + +# system +BR2_TARGET_GENERIC_GETTY_PORT="ttymxc0" + +# Kernel +BR2_LINUX_KERNEL=y +BR2_LINUX_KERNEL_CUSTOM_VERSION=y +BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.17.4" +BR2_LINUX_KERNEL_DEFCONFIG="imx_v6_v7" +BR2_LINUX_KERNEL_DTS_SUPPORT=y +BR2_LINUX_KERNEL_INTREE_DTS_NAME="imx7d-sdb" +BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y + +# U-Boot +BR2_TARGET_UBOOT=y +BR2_TARGET_UBOOT_BOARDNAME="mx7dsabresd" +BR2_TARGET_UBOOT_CUSTOM_VERSION=y +BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2018.01" +BR2_TARGET_UBOOT_FORMAT_DTB_IMX=y + +# Filesystem +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/freescale/common/imx/post-image.sh" +BR2_TARGET_ROOTFS_EXT2=y +BR2_TARGET_ROOTFS_EXT2_4=y + +# required tools to create the eMMC image +BR2_PACKAGE_HOST_DOSFSTOOLS=y +BR2_PACKAGE_HOST_GENIMAGE=y +BR2_PACKAGE_HOST_MTOOLS=y
Signature · 1 line
2.7.4
Arnout Vandecappelle
AppliedPATCH 1/3 uboot: Introduce BR2_TARGET_UBOOT_FORMAT_DTB_IMX
In reply to Fabio EstevamQuoted 7 lines · Fabio Estevam
Some i.MX boards which use device tree to describe the hardware for U-Boot generate a u-boot-dtb.imx binary.
Introduce the
BR2_TARGET_UBOOT_FORMAT_DTB_IMXoption to handle such case.Signed-off-by Fabio Estevam <[email protected]>
Applied to master, thanks.
I didn't apply the rest of the series since I had some feedback on patch 2. So
the others are marked as Changes Requested.
Regards,
Arnout
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF