summaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
authorOtavio Salvador <otavio@ossystems.com.br>2015-10-15 15:03:31 -0300
committerOtavio Salvador <otavio@ossystems.com.br>2016-04-19 15:03:21 -0300
commitff25379b23b75a9204e6e1126543c70f10d2b910 (patch)
tree7565c9ffc3f85700ceda1fd9c3eae466f71accf2 /classes
parentf3390f41dbc5e7bf0b5ee1ddcf110a77cdad2884 (diff)
downloadmeta-freescale-ff25379b23b75a9204e6e1126543c70f10d2b910.tar.gz
image_types_fsl.bbclass: Refactor boot image duplicated code
The code which copies the boot scripts and Device Tree files is duplicated across the different image types. This patch reworks this code to avoid this duplication. Change-Id: Ib9405067a5419e1b295dfac9e3d3bd9b896d424e Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Diffstat (limited to 'classes')
-rw-r--r--classes/image_types_fsl.bbclass89
1 files changed, 42 insertions, 47 deletions
diff --git a/classes/image_types_fsl.bbclass b/classes/image_types_fsl.bbclass
index 80722d68..fc7d438c 100644
--- a/classes/image_types_fsl.bbclass
+++ b/classes/image_types_fsl.bbclass
@@ -92,6 +92,45 @@ SDCARD_GENERATION_COMMAND_mx6 = "generate_imx_sdcard"
92SDCARD_GENERATION_COMMAND_mx7 = "generate_imx_sdcard" 92SDCARD_GENERATION_COMMAND_mx7 = "generate_imx_sdcard"
93SDCARD_GENERATION_COMMAND_vf = "generate_imx_sdcard" 93SDCARD_GENERATION_COMMAND_vf = "generate_imx_sdcard"
94 94
95
96#
97# Generate the boot image with the boot scripts and required Device Tree
98# files
99_generate_boot_image() {
100 local boot_part=$1
101
102 # Create boot partition image
103 BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDCARD} unit b print \
104 | awk "/ $boot_part / { print substr(\$4, 1, length(\$4 -1)) / 1024 }")
105
106 rm -f ${WORKDIR}/boot.img
107 mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -F 32 -C ${WORKDIR}/boot.img $BOOT_BLOCKS
108
109 mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin ::/${KERNEL_IMAGETYPE}
110
111 # Copy boot scripts
112 for item in ${BOOT_SCRIPTS}; do
113 src=`echo $item | awk -F':' '{ print $1 }'`
114 dst=`echo $item | awk -F':' '{ print $2 }'`
115
116 mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/$src ::/$dst
117 done
118
119 # Copy device tree file
120 if test -n "${KERNEL_DEVICETREE}"; then
121 for DTS_FILE in ${KERNEL_DEVICETREE}; do
122 DTS_BASE_NAME=`basename ${DTS_FILE} | awk -F "." '{print $1}'`
123 if [ -e "${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb" ]; then
124 kernel_bin="`readlink ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin`"
125 kernel_bin_for_dtb="`readlink ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb | sed "s,$DTS_BASE_NAME,${MACHINE},g;s,\.dtb$,.bin,g"`"
126 if [ $kernel_bin = $kernel_bin_for_dtb ]; then
127 mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb ::/${DTS_BASE_NAME}.dtb
128 fi
129 fi
130 done
131 fi
132}
133
95# 134#
96# Create an image that can by written onto a SD card using dd for use 135# Create an image that can by written onto a SD card using dd for use
97# with i.MX SoC family 136# with i.MX SoC family
@@ -150,35 +189,7 @@ generate_imx_sdcard () {
150 ;; 189 ;;
151 esac 190 esac
152 191
153 # Create boot partition image 192 _generate_boot_image 1
154 BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDCARD} unit b print \
155 | awk '/ 1 / { print substr($4, 1, length($4 -1)) / 1024 }')
156 rm -f ${WORKDIR}/boot.img
157 mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -F 32 -C ${WORKDIR}/boot.img $BOOT_BLOCKS
158
159 mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin ::/${KERNEL_IMAGETYPE}
160
161 # Copy boot scripts
162 for item in ${BOOT_SCRIPTS}; do
163 src=`echo $item | awk -F':' '{ print $1 }'`
164 dst=`echo $item | awk -F':' '{ print $2 }'`
165
166 mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/$src ::/$dst
167 done
168
169 # Copy device tree file
170 if test -n "${KERNEL_DEVICETREE}"; then
171 for DTS_FILE in ${KERNEL_DEVICETREE}; do
172 DTS_BASE_NAME=`basename ${DTS_FILE} | awk -F "." '{print $1}'`
173 if [ -e "${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb" ]; then
174 kernel_bin="`readlink ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin`"
175 kernel_bin_for_dtb="`readlink ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb | sed "s,$DTS_BASE_NAME,${MACHINE},g;s,\.dtb$,.bin,g"`"
176 if [ $kernel_bin = $kernel_bin_for_dtb ]; then
177 mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb ::/${DTS_BASE_NAME}.dtb
178 fi
179 fi
180 done
181 fi
182 193
183 # Burn Partition 194 # Burn Partition
184 dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc,fsync seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) 195 dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc,fsync seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024)
@@ -255,24 +266,8 @@ generate_mxs_sdcard () {
255 parted -s ${SDCARD} unit KiB mkpart primary $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED}) $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED} \+ $ROOTFS_SIZE) 266 parted -s ${SDCARD} unit KiB mkpart primary $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED}) $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED} \+ $ROOTFS_SIZE)
256 267
257 dd if=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.uboot.mxsboot-sdcard of=${SDCARD} conv=notrunc seek=1 bs=$(expr 1024 \* 1024) 268 dd if=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.uboot.mxsboot-sdcard of=${SDCARD} conv=notrunc seek=1 bs=$(expr 1024 \* 1024)
258 BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDCARD} unit b print \ 269
259 | awk '/ 2 / { print substr($4, 1, length($4 -1)) / 1024 }') 270 _generate_boot_image 2
260
261 rm -f ${WORKDIR}/boot.img
262 mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -F 32 -C ${WORKDIR}/boot.img $BOOT_BLOCKS
263 mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin ::/${KERNEL_IMAGETYPE}
264 if test -n "${KERNEL_DEVICETREE}"; then
265 for DTS_FILE in ${KERNEL_DEVICETREE}; do
266 DTS_BASE_NAME=`basename ${DTS_FILE} | awk -F "." '{print $1}'`
267 if [ -e "${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb" ]; then
268 kernel_bin="`readlink ${KERNEL_IMAGETYPE}-${MACHINE}.bin`"
269 kernel_bin_for_dtb="`readlink ${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb | sed "s,$DTS_BASE_NAME,${MACHINE},g;s,\.dtb$,.bin,g"`"
270 if [ $kernel_bin = $kernel_bin_for_dtb ]; then
271 mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb ::/${DTS_BASE_NAME}.dtb
272 fi
273 fi
274 done
275 fi
276 271
277 dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc seek=2 bs=$(expr 1024 \* 1024) 272 dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc seek=2 bs=$(expr 1024 \* 1024)
278 ;; 273 ;;