summaryrefslogtreecommitdiff
path: root/board/freescale/common/mxs/post-image.sh
diff options
context:
space:
mode:
Diffstat (limited to 'board/freescale/common/mxs/post-image.sh')
-rwxr-xr-xboard/freescale/common/mxs/post-image.sh54
1 files changed, 54 insertions, 0 deletions
diff --git a/board/freescale/common/mxs/post-image.sh b/board/freescale/common/mxs/post-image.sh
new file mode 100755
index 000000000..0bfb835c6
--- /dev/null
+++ b/board/freescale/common/mxs/post-image.sh
@@ -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/mxs/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 $@