All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/3] board/freescale/imx: Add helper to generate fw binary
@ 2020-04-27 21:34 Xavier Roumegue
  2020-04-27 21:34 ` [Buildroot] [PATCH 2/3] configs/imx8mmevk: new defconfig Xavier Roumegue
                   ` (2 more replies)
  0 siblings, 3 replies; 58+ messages in thread
From: Xavier Roumegue @ 2020-04-27 21:34 UTC (permalink / raw)
  To: buildroot

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

Signed-off-by: Xavier Roumegue <xroumegue@gmail.com>
---
 .../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

diff --git a/board/freescale/common/imx/imx8-generate-fw-image.sh b/board/freescale/common/imx/imx8-generate-fw-image.sh
new file mode 100755
index 0000000000..eb9e96265b
--- /dev/null
+++ b/board/freescale/common/imx/imx8-generate-fw-image.sh
@@ -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

^ permalink raw reply related	[flat|nested] 58+ messages in thread

end of thread, other threads:[~2021-01-23 22:42 UTC | newest]

Thread overview: 58+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-27 21:34 [Buildroot] [PATCH 1/3] board/freescale/imx: Add helper to generate fw binary Xavier Roumegue
2020-04-27 21:34 ` [Buildroot] [PATCH 2/3] configs/imx8mmevk: new defconfig Xavier Roumegue
2020-04-27 21:34 ` [Buildroot] [PATCH 3/3] configs/imx8mqevk: " Xavier Roumegue
2020-04-27 21:57 ` [Buildroot] [PATCH 1/3] board/freescale/imx: Add helper to generate fw binary Thomas Petazzoni
2020-04-28  8:53   ` Gary Bisson
2020-04-28 20:05     ` Fabio Estevam
2020-04-28 21:50   ` Xavier Roumegue
2020-11-03 22:39     ` Thomas Petazzoni
2020-11-07 13:59       ` [Buildroot] [PATCH v2 0/8] Add imx8mm platform using only upstream components Xavier Roumegue
2020-11-09 14:23         ` [Buildroot] [PATCH v3 " Xavier Roumegue
2020-11-09 14:23         ` [Buildroot] [PATCH v3 1/8] package/freescale-imx/firmware-imx: Add option to install all ddr fw files Xavier Roumegue
2020-11-25  9:15           ` Stephane Viau
2020-11-25 18:30           ` [Buildroot] [PATCH v4 0/8] Add imx8mm platform using only upstream components Xavier Roumegue
2020-12-14 22:24             ` Heiko Thiery
2021-01-23 22:23             ` Thomas Petazzoni
2020-11-25 18:30           ` [Buildroot] [PATCH v4 1/8] package/freescale-imx/firmware-imx: Add option to install all ddr fw files Xavier Roumegue
2020-12-14 22:25             ` Heiko Thiery
2020-12-23 14:32             ` Gary Bisson
2021-01-23 22:29             ` Thomas Petazzoni
2020-11-25 18:30           ` [Buildroot] [PATCH v4 2/8] boot/uboot: Add option to install fw files list to uboot build directory Xavier Roumegue
2020-12-14 22:26             ` Heiko Thiery
2021-01-23 22:32             ` Thomas Petazzoni
2020-11-25 18:30           ` [Buildroot] [PATCH v4 3/8] package/freescale-imx/firmware-imx: Copy of all DDR files if uboot needs fw Xavier Roumegue
2020-12-14 22:27             ` Heiko Thiery
2021-01-23 22:33             ` Thomas Petazzoni
2020-11-25 18:30           ` [Buildroot] [PATCH v4 4/8] boot/uboot/imx8: Add new target needed for mainline u-boot Xavier Roumegue
2020-12-14 22:27             ` Heiko Thiery
2020-12-23 14:42             ` Gary Bisson
2021-01-23 22:34             ` Thomas Petazzoni
2020-11-25 18:30           ` [Buildroot] [PATCH v4 5/8] board/freescale/common/imx: Add Support for uboot 'flash.bin' image Xavier Roumegue
2020-12-14 22:28             ` Heiko Thiery
2020-11-25 18:30           ` [Buildroot] [PATCH v4 6/8] board/freescale/common/imx8: Use post build generated uboot image if present Xavier Roumegue
2020-12-14 22:28             ` Heiko Thiery
2021-01-23 22:36             ` Thomas Petazzoni
2021-01-23 22:42               ` Thomas Petazzoni
2020-11-25 18:30           ` [Buildroot] [PATCH v4 7/8] board/freescale/common/imx8: Templatize uboot image name Xavier Roumegue
2020-11-25 18:30           ` [Buildroot] [PATCH v4 8/8] configs/imx8mmevk: new defconfig Xavier Roumegue
2020-12-06 11:03             ` Gilles Talis
2020-11-09 14:23         ` [Buildroot] [PATCH v3 2/8] boot/uboot: Add option to install fw files list to uboot build directory Xavier Roumegue
2020-11-09 14:23         ` [Buildroot] [PATCH v3 3/8] freescale-imx/firmware-imx: Copy of all DDR files if uboot needs fw Xavier Roumegue
2020-11-09 14:23         ` [Buildroot] [PATCH v3 4/8] boot/uboot/imx8: Add new target needed for mainline u-boot Xavier Roumegue
2020-11-09 14:23         ` [Buildroot] [PATCH v3 5/8] board/freescale/common/imx: Add Support for uboot 'flash.bin' image Xavier Roumegue
2020-11-09 14:23         ` [Buildroot] [PATCH v3 6/8] board/freescale/common/imx8: Use post build generated uboot image if present Xavier Roumegue
2020-11-09 14:23         ` [Buildroot] [PATCH v3 7/8] board/freescale/common/imx8: Templatize uboot image name Xavier Roumegue
2020-11-09 14:23         ` [Buildroot] [PATCH v3 8/8] configs/imx8mmevk: new defconfig Xavier Roumegue
2020-11-09 20:27           ` Julien Olivain
2020-11-11 20:31           ` Fabio Estevam
2020-11-07 13:59       ` [Buildroot] [PATCH v2 1/8] package/freescale-imx/firmware-imx: Add option to install all ddr fw files Xavier Roumegue
2020-11-07 13:59       ` [Buildroot] [PATCH v2 2/8] boot/uboot: Add option to install fw files list to uboot build directory Xavier Roumegue
2020-11-07 13:59       ` [Buildroot] [PATCH v2 3/8] freescale-imx/firmware-imx: Copy of all DDR files if uboot needs fw Xavier Roumegue
2020-11-07 13:59       ` [Buildroot] [PATCH v2 4/8] boot/uboot/imx8: Add new target needed for mainline u-boot Xavier Roumegue
2020-11-07 13:59       ` [Buildroot] [PATCH v2 5/8] board/freescale/common/imx: Add Support for uboot 'flash.bin' image Xavier Roumegue
2020-11-07 13:59       ` [Buildroot] [PATCH v2 6/8] board/freescale/common/imx8: Use post build generated uboot image if present Xavier Roumegue
2020-11-07 13:59       ` [Buildroot] [PATCH v2 7/8] board/freescale/common/imx8: Templatize uboot image name Xavier Roumegue
2020-11-07 13:59       ` [Buildroot] [PATCH v2 8/8] configs/imx8mmevk: new defconfig Xavier Roumegue
2020-11-08  0:05         ` Fabio Estevam
2020-11-10 20:23           ` Xavier Roumegue
2020-11-10 20:44       ` [Buildroot] [PATCH 1/3] board/freescale/imx: Add helper to generate fw binary Xavier Roumegue

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.