board/freescale: factorize genimage logic
authorGeorges Savoundararadj <savoundg@gmail.com>
Wed, 7 Sep 2016 22:29:08 +0000 (15:29 -0700)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Sun, 11 Sep 2016 21:24:04 +0000 (23:24 +0200)
For the boards imx6ulevk, imx6sabresd, mx25pdk, mx51evk, mx53loco,
warpboard:
* Replace genimage.cfg with a common Freescale genimage template named
  genimage.cfg.template because they all use the same layout.  The only
  difference comes from the device tree blobs.
* Replace each post-image.sh script with a generic post-image.sh script
  which is able to generate the right genimage.cfg depending on:
** the image type (zImage or uImage) from BR2_LINUX_KERNEL_UIMAGE
** the device tree blobs from BR2_LINUX_KERNEL_INTREE_DTS_NAME
** the rootfs type (ext2, ext3 or ext4) from BR2_TARGET_ROOTFS_EXT2
* Fix the readme.txt files accordingly

Signed-off-by: Georges Savoundararadj <savoundg@gmail.com>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Peter Korsgaard <peter@korsgaard.com>
Cc: Yann E. MORIN <yann.morin.1998@free.fr>
[Thomas: remove handling of rootfs type, using rootfs.ext2 in all cases
is fine, rootfs.ext3 and rootfs.ext4 are just symbolic links to it.]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
24 files changed:
board/freescale/common/genimage.cfg.template [new file with mode: 0644]
board/freescale/common/post-image.sh [new file with mode: 0755]
board/freescale/imx25pdk/genimage.cfg [deleted file]
board/freescale/imx25pdk/post-image.sh [deleted file]
board/freescale/imx25pdk/readme.txt
board/freescale/imx51evk/genimage.cfg [deleted file]
board/freescale/imx51evk/post-image.sh [deleted file]
board/freescale/imx51evk/readme.txt
board/freescale/imx53loco/genimage.cfg [deleted file]
board/freescale/imx53loco/post-image.sh [deleted file]
board/freescale/imx6ulevk/genimage.cfg [deleted file]
board/freescale/imx6ulevk/post-image.sh [deleted file]
board/freescale/imx6ulevk/readme.txt
board/freescale/imx7dsdb/genimage.cfg [deleted file]
board/freescale/imx7dsdb/post-image.sh [deleted file]
board/freescale/imx7dsdb/readme.txt
board/freescale/warpboard/genimage.cfg [deleted file]
board/freescale/warpboard/post-image.sh [deleted file]
configs/freescale_imx6ulevk_defconfig
configs/freescale_imx7dsabresd_defconfig
configs/mx25pdk_defconfig
configs/mx51evk_defconfig
configs/mx53loco_defconfig
configs/warpboard_defconfig

diff --git a/board/freescale/common/genimage.cfg.template b/board/freescale/common/genimage.cfg.template
new file mode 100644 (file)
index 0000000..acce058
--- /dev/null
@@ -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.imx"
+    offset = 1024
+  }
+
+  partition boot {
+    partition-type = 0xC
+    bootable = "true"
+    image = "boot.vfat"
+    offset = 8M
+  }
+
+  partition rootfs {
+    partition-type = 0x83
+    image = "rootfs.ext2"
+  }
+}
diff --git a/board/freescale/common/post-image.sh b/board/freescale/common/post-image.sh
new file mode 100755 (executable)
index 0000000..7d48550
--- /dev/null
@@ -0,0 +1,54 @@
+#!/usr/bin/env bash
+
+#
+# dtb_list extracts the list of DTB files from BR2_LINUX_KERNEL_INTREE_DTS_NAME
+# in ${BR_CONFIG}, then prints the corresponding list of file names for the
+# genimage configuration file
+#
+dtb_list()
+{
+       local DTB_LIST="$(sed -n 's/^BR2_LINUX_KERNEL_INTREE_DTS_NAME="\([a-z0-9 \-]*\)"$/\1/p' ${BR2_CONFIG})"
+
+       for dt in $DTB_LIST; do
+               echo -n "\"$dt.dtb\", "
+       done
+}
+
+#
+# linux_image extracts the Linux image format from BR2_LINUX_KERNEL_UIMAGE in
+# ${BR_CONFIG}, then prints the corresponding file name for the genimage
+# configuration file
+#
+linux_image()
+{
+       if grep -Eq "^BR2_LINUX_KERNEL_UIMAGE=y$" ${BR2_CONFIG}; then
+               echo "\"uImage\""
+       else
+               echo "\"zImage\""
+       fi
+}
+
+main()
+{
+       local FILES="$(dtb_list) $(linux_image)"
+       local GENIMAGE_CFG="$(mktemp --suffix genimage.cfg)"
+       local GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
+
+       sed -e "s/%FILES%/${FILES}/" \
+               board/freescale/common/genimage.cfg.template > ${GENIMAGE_CFG}
+
+       rm -rf "${GENIMAGE_TMP}"
+
+       genimage \
+               --rootpath "${TARGET_DIR}" \
+               --tmppath "${GENIMAGE_TMP}" \
+               --inputpath "${BINARIES_DIR}" \
+               --outputpath "${BINARIES_DIR}" \
+               --config "${GENIMAGE_CFG}"
+
+       rm -f ${GENIMAGE_CFG}
+
+       exit $?
+}
+
+main $@
diff --git a/board/freescale/imx25pdk/genimage.cfg b/board/freescale/imx25pdk/genimage.cfg
deleted file mode 100644 (file)
index 9386e32..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-# Minimal SD card image for the Freescale's i.MX25 PDK board
-#
-# We mimic the .sdcard Freescale's image format for i.MX25:
-# * 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 and dtbs,
-# * a single root filesystem partition is required (Ext4 in this case).
-#
-
-image boot.vfat {
-  vfat {
-    files = {
-      "imx25-pdk.dtb",
-      "zImage"
-    }
-  }
-  size = 16M
-}
-
-image sdcard.img {
-  hdimage {
-  }
-
-  partition u-boot {
-    in-partition-table = "no"
-    image = "u-boot.imx"
-    offset = 1024
-  }
-
-  partition boot {
-    partition-type = 0xC
-    bootable = "true"
-    image = "boot.vfat"
-    offset = 8M
-  }
-
-  partition rootfs {
-    partition-type = 0x83
-    image = "rootfs.ext4"
-  }
-}
diff --git a/board/freescale/imx25pdk/post-image.sh b/board/freescale/imx25pdk/post-image.sh
deleted file mode 100755 (executable)
index b4ac460..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env bash
-
-BOARD_DIR="$(dirname $0)"
-GENIMAGE_CFG="${BOARD_DIR}/genimage.cfg"
-GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
-
-rm -rf "${GENIMAGE_TMP}"
-
-genimage \
-  --rootpath "${TARGET_DIR}" \
-  --tmppath "${GENIMAGE_TMP}" \
-  --inputpath "${BINARIES_DIR}" \
-  --outputpath "${BINARIES_DIR}" \
-  --config "${GENIMAGE_CFG}"
index a154b995f6d4910322b85097a3434e9773994e9f..df7c617264b60e79f50d3c196d9447b9989df673 100644 (file)
@@ -40,7 +40,7 @@ command as root:
 *** WARNING! This will destroy all the card content. Use with care! ***
 
 For details about the medium image layout, see the definition in
-board/freescale/imx25pdk/genimage.cfg.
+board/freescale/common/genimage.cfg.template.
 
 Boot the i.MX25 PDK board
 =========================
diff --git a/board/freescale/imx51evk/genimage.cfg b/board/freescale/imx51evk/genimage.cfg
deleted file mode 100644 (file)
index a44ed30..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-# Minimal SD card image for the Freescale's i.MX51 EVK board
-#
-# We mimic the .sdcard Freescale's image format for i.MX51:
-# * the microSD 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 and dtbs,
-# * a single root filesystem partition is required (Ext4 in this case).
-#
-
-image boot.vfat {
-  vfat {
-    files = {
-      "imx51-babbage.dtb",
-      "zImage"
-    }
-  }
-  size = 16M
-}
-
-image sdcard.img {
-  hdimage {
-  }
-
-  partition u-boot {
-    in-partition-table = "no"
-    image = "u-boot.imx"
-    offset = 1024
-  }
-
-  partition boot {
-    partition-type = 0xC
-    bootable = "true"
-    image = "boot.vfat"
-    offset = 8M
-  }
-
-  partition rootfs {
-    partition-type = 0x83
-    image = "rootfs.ext4"
-  }
-}
diff --git a/board/freescale/imx51evk/post-image.sh b/board/freescale/imx51evk/post-image.sh
deleted file mode 100755 (executable)
index b4ac460..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env bash
-
-BOARD_DIR="$(dirname $0)"
-GENIMAGE_CFG="${BOARD_DIR}/genimage.cfg"
-GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
-
-rm -rf "${GENIMAGE_TMP}"
-
-genimage \
-  --rootpath "${TARGET_DIR}" \
-  --tmppath "${GENIMAGE_TMP}" \
-  --inputpath "${BINARIES_DIR}" \
-  --outputpath "${BINARIES_DIR}" \
-  --config "${GENIMAGE_CFG}"
index 6639a9208553e30e1fd1b2b8b6594fac54d681a0..bf739fd6596cf377a34d9860a36273545d9f4bbd 100644 (file)
@@ -40,7 +40,7 @@ command as root:
 *** WARNING! This will destroy all the card content. Use with care! ***
 
 For details about the medium image layout, see the definition in
-board/freescale/imx51evk/genimage.cfg.
+board/freescale/common/genimage.cfg.template.
 
 Boot the i.MX51 EVK board
 =========================
diff --git a/board/freescale/imx53loco/genimage.cfg b/board/freescale/imx53loco/genimage.cfg
deleted file mode 100644 (file)
index b56c168..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-# Minimal microSD card image for the Freescale's i.MX53 QSB board
-#
-# We mimic the .sdcard Freescale's image format for i.MX53:
-# * the microSD 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 and dtbs,
-# * a single root filesystem partition is required (Ext4 in this case).
-#
-
-image boot.vfat {
-  vfat {
-    files = {
-      "imx53-qsb.dtb",
-      "imx53-qsrb.dtb",
-      "zImage"
-    }
-  }
-  size = 16M
-}
-
-image sdcard.img {
-  hdimage {
-  }
-
-  partition u-boot {
-    in-partition-table = "no"
-    image = "u-boot.imx"
-    offset = 1024
-  }
-
-  partition boot {
-    partition-type = 0xC
-    bootable = "true"
-    image = "boot.vfat"
-    offset = 8M
-  }
-
-  partition rootfs {
-    partition-type = 0x83
-    image = "rootfs.ext4"
-  }
-}
diff --git a/board/freescale/imx53loco/post-image.sh b/board/freescale/imx53loco/post-image.sh
deleted file mode 100755 (executable)
index b4ac460..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env bash
-
-BOARD_DIR="$(dirname $0)"
-GENIMAGE_CFG="${BOARD_DIR}/genimage.cfg"
-GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
-
-rm -rf "${GENIMAGE_TMP}"
-
-genimage \
-  --rootpath "${TARGET_DIR}" \
-  --tmppath "${GENIMAGE_TMP}" \
-  --inputpath "${BINARIES_DIR}" \
-  --outputpath "${BINARIES_DIR}" \
-  --config "${GENIMAGE_CFG}"
diff --git a/board/freescale/imx6ulevk/genimage.cfg b/board/freescale/imx6ulevk/genimage.cfg
deleted file mode 100644 (file)
index b58193a..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-# Minimal microSD card image for the Freescale's i.MX6UL EVK board
-#
-# We mimic the .sdcard Freescale's image format for i.MX6UL:
-# * the microSD 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 and dtbs,
-# * a single root filesystem partition is required (Ext4 in this case).
-#
-
-image boot.vfat {
-  vfat {
-    files = {
-      "imx6ul-14x14-evk.dtb",
-      "zImage"
-    }
-  }
-  size = 16M
-}
-
-image sdcard.img {
-  hdimage {
-  }
-
-  partition u-boot {
-    in-partition-table = "no"
-    image = "u-boot.imx"
-    offset = 1024
-  }
-
-  partition boot {
-    partition-type = 0xC
-    bootable = "true"
-    image = "boot.vfat"
-    offset = 8M
-  }
-
-  partition rootfs {
-    partition-type = 0x83
-    image = "rootfs.ext4"
-  }
-}
diff --git a/board/freescale/imx6ulevk/post-image.sh b/board/freescale/imx6ulevk/post-image.sh
deleted file mode 100755 (executable)
index b4ac460..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env bash
-
-BOARD_DIR="$(dirname $0)"
-GENIMAGE_CFG="${BOARD_DIR}/genimage.cfg"
-GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
-
-rm -rf "${GENIMAGE_TMP}"
-
-genimage \
-  --rootpath "${TARGET_DIR}" \
-  --tmppath "${GENIMAGE_TMP}" \
-  --inputpath "${BINARIES_DIR}" \
-  --outputpath "${BINARIES_DIR}" \
-  --config "${GENIMAGE_CFG}"
index 462715c18d7e6b99f79511d81b76fd6cd40e2afc..98de2775dbe2120986d31f78136ad215d2785383 100644 (file)
@@ -43,7 +43,7 @@ command as root:
 *** WARNING! This will destroy all the card content. Use with care! ***
 
 For details about the medium image layout, see the definition in
-board/freescale/imx6ulevk/genimage.cfg.
+board/freescale/common/genimage.cfg.template.
 
 Boot the i.MX6UL EVK board
 =========================
diff --git a/board/freescale/imx7dsdb/genimage.cfg b/board/freescale/imx7dsdb/genimage.cfg
deleted file mode 100644 (file)
index aa6ae9e..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-# Minimal microSD card image for the Freescale's i.MX7D SDB board
-#
-# We mimic the .sdcard Freescale's image format for i.MX7D:
-# * the microSD 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 and dtbs,
-# * a single root filesystem partition is required (Ext4 in this case).
-#
-
-image boot.vfat {
-  vfat {
-    files = {
-      "imx7d-sdb.dtb",
-      "zImage"
-    }
-  }
-  size = 16M
-}
-
-image sdcard.img {
-  hdimage {
-  }
-
-  partition u-boot {
-    in-partition-table = "no"
-    image = "u-boot.imx"
-    offset = 1024
-  }
-
-  partition boot {
-    partition-type = 0xC
-    bootable = "true"
-    image = "boot.vfat"
-    offset = 8M
-  }
-
-  partition rootfs {
-    partition-type = 0x83
-    image = "rootfs.ext4"
-  }
-}
diff --git a/board/freescale/imx7dsdb/post-image.sh b/board/freescale/imx7dsdb/post-image.sh
deleted file mode 100755 (executable)
index b4ac460..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env bash
-
-BOARD_DIR="$(dirname $0)"
-GENIMAGE_CFG="${BOARD_DIR}/genimage.cfg"
-GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
-
-rm -rf "${GENIMAGE_TMP}"
-
-genimage \
-  --rootpath "${TARGET_DIR}" \
-  --tmppath "${GENIMAGE_TMP}" \
-  --inputpath "${BINARIES_DIR}" \
-  --outputpath "${BINARIES_DIR}" \
-  --config "${GENIMAGE_CFG}"
index c72e9a979d65f7e4e126e8844d0fc1fc2a38683a..9aeeb166d828208296116e42f7daa3955095b503 100644 (file)
@@ -40,7 +40,7 @@ command as root:
 *** WARNING! This will destroy all the card content. Use with care! ***
 
 For details about the medium image layout, see the definition in
-board/freescale/imx7dsdb/genimage.cfg.
+board/freescale/common/genimage.cfg.template.
 
 Boot the i.MX7D SDB board
 =========================
diff --git a/board/freescale/warpboard/genimage.cfg b/board/freescale/warpboard/genimage.cfg
deleted file mode 100644 (file)
index a22aa2a..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-# Minimal SD card image for the Warp board
-#
-# We mimic the .sdcard Freescale's image format for i.MX6SL:
-# * the microSD 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 and dtbs,
-# * a single root filesystem partition is required (Ext4 in this case).
-#
-
-image boot.vfat {
-  vfat {
-    files = {
-      "imx6sl-warp.dtb",
-      "zImage"
-    }
-  }
-  size = 16M
-}
-
-image sdcard.img {
-  hdimage {
-  }
-
-  partition u-boot {
-    in-partition-table = "no"
-    image = "u-boot.imx"
-    offset = 1024
-  }
-
-  partition boot {
-    partition-type = 0xC
-    bootable = "true"
-    image = "boot.vfat"
-    offset = 8M
-  }
-
-  partition rootfs {
-    partition-type = 0x83
-    image = "rootfs.ext4"
-  }
-}
diff --git a/board/freescale/warpboard/post-image.sh b/board/freescale/warpboard/post-image.sh
deleted file mode 100755 (executable)
index b4ac460..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env bash
-
-BOARD_DIR="$(dirname $0)"
-GENIMAGE_CFG="${BOARD_DIR}/genimage.cfg"
-GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
-
-rm -rf "${GENIMAGE_TMP}"
-
-genimage \
-  --rootpath "${TARGET_DIR}" \
-  --tmppath "${GENIMAGE_TMP}" \
-  --inputpath "${BINARIES_DIR}" \
-  --outputpath "${BINARIES_DIR}" \
-  --config "${GENIMAGE_CFG}"
index 5a18c1d4e86bea1a462ec7b07e95b7c5974bf6c0..fb860b5607b4331e5e9a029e6ad432f4b3089394 100644 (file)
@@ -31,6 +31,6 @@ BR2_PACKAGE_HOST_GENIMAGE=y
 BR2_PACKAGE_HOST_MTOOLS=y
 
 # filesystem / image
-BR2_ROOTFS_POST_IMAGE_SCRIPT="board/freescale/imx6ulevk/post-image.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/freescale/common/post-image.sh"
 BR2_TARGET_ROOTFS_EXT2=y
 BR2_TARGET_ROOTFS_EXT2_4=y
index 676804118f2428dcd72a0f5dc34c498c58e0a5b9..311f8acaae3d3f796b64447da657d848b777366d 100644 (file)
@@ -33,4 +33,4 @@ BR2_TARGET_UBOOT_FORMAT_IMX=y
 BR2_PACKAGE_HOST_DOSFSTOOLS=y
 BR2_PACKAGE_HOST_GENIMAGE=y
 BR2_PACKAGE_HOST_MTOOLS=y
-BR2_ROOTFS_POST_IMAGE_SCRIPT="board/freescale/imx7dsdb/post-image.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/freescale/common/post-image.sh"
index d682f0fa638323c8f9bfb567d755b215946c4335..645fe8a13ad9e46d8faec4484e747afdf8aa9286 100644 (file)
@@ -14,7 +14,7 @@ BR2_PACKAGE_HOST_GENIMAGE=y
 BR2_PACKAGE_HOST_MTOOLS=y
 
 # Filesystem
-BR2_ROOTFS_POST_IMAGE_SCRIPT="board/freescale/imx25pdk/post-image.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/freescale/common/post-image.sh"
 BR2_TARGET_ROOTFS_EXT2=y
 BR2_TARGET_ROOTFS_EXT2_4=y
 
index bc72e06cbadcb91c62fd6a7cd687f2349539c9ac..1fca282536f745109d8f1502de990b010eb7c925 100644 (file)
@@ -14,7 +14,7 @@ BR2_PACKAGE_HOST_GENIMAGE=y
 BR2_PACKAGE_HOST_MTOOLS=y
 
 # Filesystem
-BR2_ROOTFS_POST_IMAGE_SCRIPT="board/freescale/imx51evk/post-image.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/freescale/common/post-image.sh"
 BR2_TARGET_ROOTFS_EXT2=y
 BR2_TARGET_ROOTFS_EXT2_4=y
 
index 286b719e2fe98a5edf920e7940fd5d0c526112e0..94ac818d1b20b83fa7458c0f5c5bf793f33cc01d 100644 (file)
@@ -14,7 +14,7 @@ BR2_PACKAGE_HOST_GENIMAGE=y
 BR2_PACKAGE_HOST_MTOOLS=y
 
 # Filesystem
-BR2_ROOTFS_POST_IMAGE_SCRIPT="board/freescale/imx53loco/post-image.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/freescale/common/post-image.sh"
 BR2_TARGET_ROOTFS_EXT2=y
 BR2_TARGET_ROOTFS_EXT2_4=y
 
index 19425b3645b57d3345f4fff134bbbda4436b17f7..5e9c0514b7dd90e857bb18002fdb07b1248e2ea3 100644 (file)
@@ -42,7 +42,7 @@ BR2_PACKAGE_HOST_DFU_UTIL=y
 BR2_PACKAGE_HOST_IMX_USB_LOADER=y
 
 # Filesystem
-BR2_ROOTFS_POST_IMAGE_SCRIPT="board/freescale/warpboard/post-image.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/freescale/common/post-image.sh"
 BR2_TARGET_ROOTFS_EXT2=y
 BR2_TARGET_ROOTFS_EXT2_4=y