2016-09-08 00:29:08 +02:00
|
|
|
#!/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()
|
|
|
|
{
|
2018-04-12 14:35:23 +02:00
|
|
|
local DTB_LIST="$(sed -n 's/^BR2_LINUX_KERNEL_INTREE_DTS_NAME="\([\/a-z0-9 \-]*\)"$/\1/p' ${BR2_CONFIG})"
|
2016-09-08 00:29:08 +02:00
|
|
|
|
|
|
|
for dt in $DTB_LIST; do
|
2018-04-12 14:35:23 +02:00
|
|
|
echo -n "\"`basename $dt`.dtb\", "
|
2016-09-08 00:29:08 +02:00
|
|
|
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\""
|
2018-04-12 14:35:23 +02:00
|
|
|
elif grep -Eq "^BR2_LINUX_KERNEL_IMAGE=y$" ${BR2_CONFIG}; then
|
|
|
|
echo "\"Image\""
|
2016-09-08 00:29:08 +02:00
|
|
|
else
|
|
|
|
echo "\"zImage\""
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-09-16 15:12:11 +02:00
|
|
|
genimage_type()
|
|
|
|
{
|
2019-09-09 14:14:55 +02:00
|
|
|
if grep -Eq "^BR2_PACKAGE_FREESCALE_IMX_PLATFORM_IMX8=y$" ${BR2_CONFIG}; then
|
|
|
|
echo "genimage.cfg.template_imx8"
|
|
|
|
elif grep -Eq "^BR2_PACKAGE_FREESCALE_IMX_PLATFORM_IMX8M=y$" ${BR2_CONFIG}; then
|
2018-04-12 22:39:07 +02:00
|
|
|
echo "genimage.cfg.template_imx8"
|
2019-06-10 12:19:23 +02:00
|
|
|
elif grep -Eq "^BR2_PACKAGE_FREESCALE_IMX_PLATFORM_IMX8MM=y$" ${BR2_CONFIG}; then
|
|
|
|
echo "genimage.cfg.template_imx8"
|
2020-05-27 07:07:47 +02:00
|
|
|
elif grep -Eq "^BR2_PACKAGE_FREESCALE_IMX_PLATFORM_IMX8MN=y$" ${BR2_CONFIG}; then
|
|
|
|
echo "genimage.cfg.template_imx8"
|
2021-03-25 07:21:40 +01:00
|
|
|
elif grep -Eq "^BR2_PACKAGE_FREESCALE_IMX_PLATFORM_IMX8MP=y$" ${BR2_CONFIG}; then
|
|
|
|
echo "genimage.cfg.template_imx8"
|
2019-02-18 21:48:06 +01:00
|
|
|
elif grep -Eq "^BR2_PACKAGE_FREESCALE_IMX_PLATFORM_IMX8X=y$" ${BR2_CONFIG}; then
|
|
|
|
echo "genimage.cfg.template_imx8"
|
2019-06-10 21:41:42 +02:00
|
|
|
elif grep -Eq "^BR2_LINUX_KERNEL_INSTALL_TARGET=y$" ${BR2_CONFIG}; then
|
|
|
|
if grep -Eq "^BR2_TARGET_UBOOT_SPL=y$" ${BR2_CONFIG}; then
|
|
|
|
echo "genimage.cfg.template_no_boot_part_spl"
|
|
|
|
fi
|
2018-04-12 22:39:07 +02:00
|
|
|
elif grep -Eq "^BR2_TARGET_UBOOT_SPL=y$" ${BR2_CONFIG}; then
|
2017-09-16 15:12:11 +02:00
|
|
|
echo "genimage.cfg.template_spl"
|
|
|
|
else
|
|
|
|
echo "genimage.cfg.template"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-02-18 21:48:06 +01:00
|
|
|
imx_offset()
|
|
|
|
{
|
|
|
|
if grep -Eq "^BR2_PACKAGE_FREESCALE_IMX_PLATFORM_IMX8M=y$" ${BR2_CONFIG}; then
|
|
|
|
echo "33K"
|
2019-06-10 12:19:23 +02:00
|
|
|
elif grep -Eq "^BR2_PACKAGE_FREESCALE_IMX_PLATFORM_IMX8MM=y$" ${BR2_CONFIG}; then
|
|
|
|
echo "33K"
|
2019-02-18 21:48:06 +01:00
|
|
|
else
|
|
|
|
echo "32K"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-07-08 23:16:18 +02:00
|
|
|
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"
|
2019-07-09 11:57:02 +02:00
|
|
|
elif grep -Eq "^BR2_TARGET_UBOOT_FORMAT_DTB_IMG=y$" ${BR2_CONFIG}; then
|
|
|
|
echo "u-boot-dtb.img"
|
2019-07-10 07:17:02 +02:00
|
|
|
elif grep -Eq "^BR2_TARGET_UBOOT_FORMAT_IMG=y$" ${BR2_CONFIG}; then
|
2019-07-09 11:57:02 +02:00
|
|
|
echo "u-boot.img"
|
2018-07-08 23:16:18 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-09-08 00:29:08 +02:00
|
|
|
main()
|
|
|
|
{
|
|
|
|
local FILES="$(dtb_list) $(linux_image)"
|
2019-02-18 21:48:06 +01:00
|
|
|
local IMXOFFSET="$(imx_offset)"
|
2018-07-08 23:16:18 +02:00
|
|
|
local UBOOTBIN="$(uboot_image)"
|
2016-09-08 00:29:08 +02:00
|
|
|
local GENIMAGE_CFG="$(mktemp --suffix genimage.cfg)"
|
|
|
|
local GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
|
|
|
|
|
|
|
|
sed -e "s/%FILES%/${FILES}/" \
|
2019-02-18 21:48:06 +01:00
|
|
|
-e "s/%IMXOFFSET%/${IMXOFFSET}/" \
|
2018-07-08 23:16:18 +02:00
|
|
|
-e "s/%UBOOTBIN%/${UBOOTBIN}/" \
|
2017-09-16 15:12:11 +02:00
|
|
|
board/freescale/common/imx/$(genimage_type) > ${GENIMAGE_CFG}
|
2016-09-08 00:29:08 +02:00
|
|
|
|
|
|
|
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 $@
|