Skip to contentSkip to conversation

board/freescale/imx: Add helper to generate fw binary

PATCH New Fabio Estevam 2 participants 3 messages Apr 27, 2020 – Jul 16, 2020 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/3 board/freescale/imx: Add helper to generate fw binary

Hi Xavier,

Quoted 11 lines · Xavier Roumegue

This script aims to create an imx compatible boot image embedding mainline components, using only upstream uboot mkimage tool, avoiding dependencies on proprietary imx mkimage.

Mainline u-boot can generate a bootable image, but SPL soc proprietary firmware dependencies have to be copied on uboot root dir.

This script prevents additional buildroot uboot recipe hacking to handle custom SoC uboot build process.

Quoted 7 lines

The script actions summary is:
- Append DDR4 firmware to uboot spl binary
- Generate imx mkimage configuration file, extracting entry points from relevant elf files on the fly.
- Generate imx boot image using uboot upstream mkimage tool

This is cool :-) I like it!

Do you think we can also expand this later to support booting i.MX8QXP and i.MX8QM too?

Thanks

Quoted 66 lines
---
 .../common/imx/imx8-generate-fw-image.sh      | 52 +++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100755 board/freescale/common/imx/imx8-generate-fw-image.sh
board/freescale/common/imx/imx8-generate-fw-image.sh new file +52 -1
new file mode 100755
index 0000000000..eb9e96265b
@@ -0,0 +1,52 @@
+#!/usr/bin/env bash
+
+get_entry()
+{
+    local elf_file=$1
+    readelf -h "$elf_file" | sed -e '/Entry/!d;s/.*:.*\(0x[0-9a-fA-F]\)/\1/g'
+}
+
+gen_cfg_file()
+{
+cat <<EOF > "$CFG_OUTFILE"
+#define __ASSEMBLY__
+
+FIT
+BOOT_FROM      sd
+LOADER         ${SPL_DDR_BIN}  ${SPL_ENTRY}
+SECOND_LOADER  ${UBOOT_BIN}            ${UBOOT_ENTRY} 0x60000
+
+EOF
+}
+
+gen_1stloader_bin()
+{
+    SPL_BIN_PAD="$(mktemp --suffix spl_pad.bin)"
+    dd if="${SPL_BIN}" of="${SPL_BIN_PAD}"  bs=4 conv=sync
+    cat "${SPL_BIN_PAD}" "${DDR_FW_BIN}" > "${SPL_DDR_BIN}"
+}
+
+gen_fw_image()
+{
+    "${HOST_DIR}"/bin/mkimage -n "${CFG_OUTFILE}" -T imx8mimage -e "${SPL_ENTRY}" -d "${UBOOT_BIN}" "${FLASH_BIN}"
+
+}
+main()
+{
+    UBOOT_BIN="${BINARIES_DIR}/u-boot.itb"
+    UBOOT_ELF="${BINARIES_DIR}/u-boot"
+    SPL_DDR_BIN="${BINARIES_DIR}/u-boot-spl-ddr.bin"
+    SPL_BIN="${BINARIES_DIR}/u-boot-spl.bin"
+    SPL_ELF="${BINARIES_DIR}/u-boot-spl"
+    CFG_OUTFILE="${BINARIES_DIR}/bootimage.cfg"
+    FLASH_BIN="${BINARIES_DIR}/imx8-boot-sd.bin"
+    UBOOT_ENTRY="$(get_entry "${UBOOT_ELF}")"
+    SPL_ENTRY="$(get_entry "${SPL_ELF}")"
+    DDR_FW_BIN="${BINARIES_DIR}/lpddr4_pmu_train_fw.bin"
+
+    gen_1stloader_bin
+    gen_cfg_file
+    gen_fw_image
+}
+
+main "$@"
--

2.25.1

#2 lore raw

PATCH 1/3 board/freescale/imx: Add helper to generate fw binary

Quoted 20 lines · Fabio Estevam

Hi Xavier,

Quoted 17 lines · Xavier Roumegue

This script aims to create an imx compatible boot image embedding mainline components, using only upstream uboot mkimage tool, avoiding dependencies on proprietary imx mkimage.

Mainline u-boot can generate a bootable image, but SPL soc proprietary firmware dependencies have to be copied on uboot root dir.

This script prevents additional buildroot uboot recipe hacking to handle custom SoC uboot build process.

The script actions summary is:
- Append DDR4 firmware to uboot spl binary
- Generate imx mkimage configuration file, extracting entry points from relevant elf files on the fly.
- Generate imx boot image using uboot upstream mkimage tool

Quoted 3 lines
Quoted 1 line

This is cool :-) I like it!

Hi Fabio
Glad to read you like the idea !

Quoted 3 lines

Do you think we can also expand this later to support booting i.MX8QXP and i.MX8QM too?

Yes, that's exactly the intention here, supporting all imx8 platforms, relying on uboot mkimage only.

Xavier

#3 lore raw

PATCH 1/3 board/freescale/imx: Add helper to generate fw binary

In reply to a message not in the archive

Hi Xavier,

Quoted 11 lines · Xavier Roumegue

This script aims to create an imx compatible boot image embedding mainline components, using only upstream uboot mkimage tool, avoiding dependencies on proprietary imx mkimage.

Mainline u-boot can generate a bootable image, but SPL soc proprietary firmware dependencies have to be copied on uboot root dir.

This script prevents additional buildroot uboot recipe hacking to handle custom SoC uboot build process.

Quoted 7 lines

The script actions summary is:
- Append DDR4 firmware to uboot spl binary
- Generate imx mkimage configuration file, extracting entry points from relevant elf files on the fly.
- Generate imx boot image using uboot upstream mkimage tool

Do you plan to resubmit this patch?

I am looking forward to being able to use a Buildroot generated image with U-Boot and kernel mainline on i.MX8 boards :-)