diff options
Diffstat (limited to 'classes')
-rw-r--r-- | classes/image_types_fsl.bbclass | 232 |
1 files changed, 2 insertions, 230 deletions
diff --git a/classes/image_types_fsl.bbclass b/classes/image_types_fsl.bbclass index e49bb1af..5e50f476 100644 --- a/classes/image_types_fsl.bbclass +++ b/classes/image_types_fsl.bbclass | |||
@@ -1,254 +1,26 @@ | |||
1 | inherit image_types | 1 | inherit image_types |
2 | 2 | ||
3 | IMAGE_BOOTLOADER ?= "u-boot" | ||
4 | |||
5 | # Handle u-boot suffixes | 3 | # Handle u-boot suffixes |
6 | UBOOT_SUFFIX ?= "bin" | 4 | UBOOT_SUFFIX ?= "bin" |
7 | UBOOT_SUFFIX_SDCARD ?= "${UBOOT_SUFFIX}" | ||
8 | 5 | ||
9 | # | 6 | # |
10 | # Handles i.MX mxs bootstream generation | 7 | # Handles i.MX mxs bootstream generation |
11 | # | 8 | # |
12 | MXSBOOT_NAND_ARGS ?= "" | 9 | MXSBOOT_NAND_ARGS ?= "" |
13 | 10 | ||
14 | # U-Boot mxsboot generation to SD-Card | 11 | # U-Boot mxsboot generation for uSD |
15 | UBOOT_SUFFIX_SDCARD_mxs ?= "mxsboot-sdcard" | ||
16 | do_image_uboot_mxsboot_sdcard[depends] += "u-boot-mxsboot-native:do_populate_sysroot \ | 12 | do_image_uboot_mxsboot_sdcard[depends] += "u-boot-mxsboot-native:do_populate_sysroot \ |
17 | u-boot:do_deploy" | 13 | u-boot:do_deploy" |
18 | IMAGE_CMD_uboot-mxsboot-sdcard = "mxsboot sd ${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX} \ | 14 | IMAGE_CMD_uboot-mxsboot-sdcard = "mxsboot sd ${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX} \ |
19 | ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.uboot-mxsboot-sdcard" | 15 | ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.uboot-mxsboot-sdcard" |
20 | 16 | ||
17 | # U-Boot mxsboot generation for NAND | ||
21 | do_image_uboot_mxsboot_nand[depends] += "u-boot-mxsboot-native:do_populate_sysroot \ | 18 | do_image_uboot_mxsboot_nand[depends] += "u-boot-mxsboot-native:do_populate_sysroot \ |
22 | u-boot:do_deploy" | 19 | u-boot:do_deploy" |
23 | IMAGE_CMD_uboot-mxsboot-nand = "mxsboot ${MXSBOOT_NAND_ARGS} nand \ | 20 | IMAGE_CMD_uboot-mxsboot-nand = "mxsboot ${MXSBOOT_NAND_ARGS} nand \ |
24 | ${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX} \ | 21 | ${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX} \ |
25 | ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.uboot-mxsboot-nand" | 22 | ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.uboot-mxsboot-nand" |
26 | 23 | ||
27 | # Boot partition volume id | ||
28 | BOOTDD_VOLUME_ID ?= "Boot ${MACHINE}" | ||
29 | |||
30 | # Boot partition size [in KiB] | ||
31 | BOOT_SPACE ?= "8192" | ||
32 | |||
33 | # Set alignment to 4MB [in KiB] | ||
34 | IMAGE_ROOTFS_ALIGNMENT = "4096" | ||
35 | |||
36 | do_image_sdcard[depends] = "parted-native:do_populate_sysroot \ | ||
37 | dosfstools-native:do_populate_sysroot \ | ||
38 | mtools-native:do_populate_sysroot \ | ||
39 | virtual/kernel:do_deploy \ | ||
40 | ${@d.getVar('IMAGE_BOOTLOADER', True) and d.getVar('IMAGE_BOOTLOADER', True) + ':do_deploy' or ''}" | ||
41 | |||
42 | SDCARD = "${IMGDEPLOYDIR}/${IMAGE_NAME}.rootfs.sdcard" | ||
43 | |||
44 | SDCARD_GENERATION_COMMAND_mxs = "generate_mxs_sdcard" | ||
45 | SDCARD_GENERATION_COMMAND_mx25 = "generate_imx_sdcard" | ||
46 | SDCARD_GENERATION_COMMAND_mx5 = "generate_imx_sdcard" | ||
47 | SDCARD_GENERATION_COMMAND_mx6 = "generate_imx_sdcard" | ||
48 | SDCARD_GENERATION_COMMAND_mx7 = "generate_imx_sdcard" | ||
49 | SDCARD_GENERATION_COMMAND_vf = "generate_imx_sdcard" | ||
50 | |||
51 | |||
52 | # | ||
53 | # Generate the boot image with the boot scripts and required Device Tree | ||
54 | # files | ||
55 | _generate_boot_image() { | ||
56 | local boot_part=$1 | ||
57 | |||
58 | # Create boot partition image | ||
59 | BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDCARD} unit b print \ | ||
60 | | awk "/ $boot_part / { print substr(\$4, 1, length(\$4 -1)) / 1024 }") | ||
61 | |||
62 | # mkdosfs will sometimes use FAT16 when it is not appropriate, | ||
63 | # resulting in a boot failure from SYSLINUX. Use FAT32 for | ||
64 | # images larger than 512MB, otherwise let mkdosfs decide. | ||
65 | if [ $(expr $BOOT_BLOCKS / 1024) -gt 512 ]; then | ||
66 | FATSIZE="-F 32" | ||
67 | fi | ||
68 | |||
69 | rm -f ${WORKDIR}/boot.img | ||
70 | mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 ${FATSIZE} -C ${WORKDIR}/boot.img $BOOT_BLOCKS | ||
71 | |||
72 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin ::/${KERNEL_IMAGETYPE} | ||
73 | |||
74 | # Copy boot scripts | ||
75 | for item in ${BOOT_SCRIPTS}; do | ||
76 | src=`echo $item | awk -F':' '{ print $1 }'` | ||
77 | dst=`echo $item | awk -F':' '{ print $2 }'` | ||
78 | |||
79 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/$src ::/$dst | ||
80 | done | ||
81 | |||
82 | # Copy device tree file | ||
83 | if test -n "${KERNEL_DEVICETREE}"; then | ||
84 | for DTS_FILE in ${KERNEL_DEVICETREE}; do | ||
85 | DTS_BASE_NAME=`basename ${DTS_FILE} .dtb` | ||
86 | if [ -e "${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb" ]; then | ||
87 | kernel_bin="`readlink ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin`" | ||
88 | 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"`" | ||
89 | if [ $kernel_bin = $kernel_bin_for_dtb ]; then | ||
90 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb ::/${DTS_BASE_NAME}.dtb | ||
91 | fi | ||
92 | else | ||
93 | bbfatal "${DTS_FILE} does not exist." | ||
94 | fi | ||
95 | done | ||
96 | fi | ||
97 | |||
98 | # Copy extlinux.conf to images that have U-Boot Extlinux support. | ||
99 | if [ "${UBOOT_EXTLINUX}" = "1" ]; then | ||
100 | mmd -i ${WORKDIR}/boot.img ::/extlinux | ||
101 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/extlinux.conf ::/extlinux/extlinux.conf | ||
102 | fi | ||
103 | } | ||
104 | |||
105 | # | ||
106 | # Create an image that can by written onto a SD card using dd for use | ||
107 | # with i.MX SoC family | ||
108 | # | ||
109 | # External variables needed: | ||
110 | # ${SDCARD_ROOTFS} - the rootfs image to incorporate | ||
111 | # ${IMAGE_BOOTLOADER} - bootloader to use | ||
112 | # | ||
113 | # The disk layout used is: | ||
114 | # | ||
115 | # 0 -> IMAGE_ROOTFS_ALIGNMENT - reserved to bootloader (not partitioned) | ||
116 | # IMAGE_ROOTFS_ALIGNMENT -> BOOT_SPACE - kernel and other data | ||
117 | # BOOT_SPACE -> SDIMG_SIZE - rootfs | ||
118 | # | ||
119 | # Default Free space = 1.3x | ||
120 | # Use IMAGE_OVERHEAD_FACTOR to add more space | ||
121 | # <---------> | ||
122 | # 4MiB 8MiB SDIMG_ROOTFS 4MiB | ||
123 | # <-----------------------> <----------> <----------------------> <------------------------------> | ||
124 | # ------------------------ ------------ ------------------------ ------------------------------- | ||
125 | # | IMAGE_ROOTFS_ALIGNMENT | BOOT_SPACE | ROOTFS_SIZE | IMAGE_ROOTFS_ALIGNMENT | | ||
126 | # ------------------------ ------------ ------------------------ ------------------------------- | ||
127 | # ^ ^ ^ ^ ^ | ||
128 | # | | | | | | ||
129 | # 0 4096 4MiB + 8MiB 4MiB + 8Mib + SDIMG_ROOTFS 4MiB + 8MiB + SDIMG_ROOTFS + 4MiB | ||
130 | generate_imx_sdcard () { | ||
131 | # Create partition table | ||
132 | parted -s ${SDCARD} mklabel msdos | ||
133 | parted -s ${SDCARD} unit KiB mkpart primary fat32 ${IMAGE_ROOTFS_ALIGNMENT} $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED}) | ||
134 | parted -s ${SDCARD} unit KiB mkpart primary $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED}) $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED} \+ $ROOTFS_SIZE) | ||
135 | parted ${SDCARD} print | ||
136 | |||
137 | # Burn bootloader | ||
138 | case "${IMAGE_BOOTLOADER}" in | ||
139 | u-boot) | ||
140 | if [ -n "${SPL_BINARY}" ]; then | ||
141 | dd if=${DEPLOY_DIR_IMAGE}/${SPL_BINARY} of=${SDCARD} conv=notrunc seek=2 bs=512 | ||
142 | dd if=${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX_SDCARD} of=${SDCARD} conv=notrunc seek=69 bs=1K | ||
143 | else | ||
144 | dd if=${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX_SDCARD} of=${SDCARD} conv=notrunc seek=2 bs=512 | ||
145 | fi | ||
146 | ;; | ||
147 | *) | ||
148 | bberror "Unknown IMAGE_BOOTLOADER value" | ||
149 | exit 1 | ||
150 | ;; | ||
151 | esac | ||
152 | |||
153 | _generate_boot_image 1 | ||
154 | |||
155 | # Burn Partition | ||
156 | dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc,fsync seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) | ||
157 | dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc,fsync seek=1 bs=$(expr ${BOOT_SPACE_ALIGNED} \* 1024 + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) | ||
158 | } | ||
159 | |||
160 | # | ||
161 | # Create an image that can by written onto a SD card using dd for use | ||
162 | # with i.MXS SoC family | ||
163 | # | ||
164 | # External variables needed: | ||
165 | # ${SDCARD_ROOTFS} - the rootfs image to incorporate | ||
166 | # ${IMAGE_BOOTLOADER} - bootloader to use | ||
167 | # | ||
168 | generate_mxs_sdcard () { | ||
169 | # Create partition table | ||
170 | parted -s ${SDCARD} mklabel msdos | ||
171 | |||
172 | case "${IMAGE_BOOTLOADER}" in | ||
173 | u-boot) | ||
174 | # The disk layout used is: | ||
175 | # | ||
176 | # 1M - 2M - reserved to bootloader and other data | ||
177 | # 2M - BOOT_SPACE - kernel | ||
178 | # BOOT_SPACE - SDCARD_SIZE - rootfs | ||
179 | # | ||
180 | # The disk layout used is: | ||
181 | # | ||
182 | # 1M -> 2M - reserved to bootloader and other data | ||
183 | # 2M -> BOOT_SPACE - kernel and other data | ||
184 | # BOOT_SPACE -> SDIMG_SIZE - rootfs | ||
185 | # | ||
186 | # Default Free space = 1.3x | ||
187 | # Use IMAGE_OVERHEAD_FACTOR to add more space | ||
188 | # <---------> | ||
189 | # 4MiB 8MiB SDIMG_ROOTFS 4MiB | ||
190 | # <-----------------------> <-------------> <----------------------> <------------------------------> | ||
191 | # ---------------------------------------- ------------------------ ------------------------------- | ||
192 | # | | | |ROOTFS_SIZE | IMAGE_ROOTFS_ALIGNMENT | | ||
193 | # ---------------------------------------- ------------------------ ------------------------------- | ||
194 | # ^ ^ ^ ^ ^ ^ ^ | ||
195 | # | | | | | | | | ||
196 | # 0 1M 2M 4M 4MiB + BOOTSPACE 4MiB + BOOTSPACE + SDIMG_ROOTFS 4MiB + BOOTSPACE + SDIMG_ROOTFS + 4MiB | ||
197 | # | ||
198 | parted -s ${SDCARD} unit KiB mkpart primary 1024 2048 | ||
199 | parted -s ${SDCARD} unit KiB mkpart primary 2048 $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED}) | ||
200 | parted -s ${SDCARD} unit KiB mkpart primary $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED}) $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED} \+ $ROOTFS_SIZE) | ||
201 | |||
202 | dd if=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.uboot-mxsboot-sdcard of=${SDCARD} conv=notrunc seek=1 bs=$(expr 1024 \* 1024) | ||
203 | |||
204 | _generate_boot_image 2 | ||
205 | |||
206 | dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc seek=2 bs=$(expr 1024 \* 1024) | ||
207 | ;; | ||
208 | *) | ||
209 | bberror "Unknown IMAGE_BOOTLOADER value" | ||
210 | exit 1 | ||
211 | ;; | ||
212 | esac | ||
213 | |||
214 | # Change partition type for mxs processor family | ||
215 | bbnote "Setting partition type to 0x53 as required for mxs' SoC family." | ||
216 | echo -n S | dd of=${SDCARD} bs=1 count=1 seek=450 conv=notrunc | ||
217 | |||
218 | parted ${SDCARD} print | ||
219 | |||
220 | dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc,fsync seek=1 bs=$(expr ${BOOT_SPACE_ALIGNED} \* 1024 + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) | ||
221 | } | ||
222 | |||
223 | IMAGE_CMD_sdcard () { | ||
224 | bbwarn "The '${MACHINE}' is using the i.MX 'sdcard' image format which is deprecated. This image type is going to be removed in next release so please convert this machine to use the wic tool" | ||
225 | |||
226 | if [ -z "${SDCARD_ROOTFS}" ]; then | ||
227 | bberror "SDCARD_ROOTFS is undefined. To use sdcard image from Freescale's BSP it needs to be defined." | ||
228 | exit 1 | ||
229 | fi | ||
230 | |||
231 | # Align boot partition and calculate total SD card image size | ||
232 | BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1) | ||
233 | BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT}) | ||
234 | SDCARD_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + ${BOOT_SPACE_ALIGNED} + $ROOTFS_SIZE + ${IMAGE_ROOTFS_ALIGNMENT}) | ||
235 | |||
236 | # Initialize a sparse file | ||
237 | dd if=/dev/zero of=${SDCARD} bs=1 count=0 seek=$(expr 1024 \* ${SDCARD_SIZE}) | ||
238 | |||
239 | ${SDCARD_GENERATION_COMMAND} | ||
240 | } | ||
241 | |||
242 | # The sdcard requires the rootfs filesystem to be built before using | ||
243 | # it so we must make this dependency explicit. | ||
244 | IMAGE_TYPEDEP_sdcard_append = " ${@d.getVar('SDCARD_ROOTFS', 1).split('.')[-1]}" | ||
245 | |||
246 | # In case we are building for i.MX23 or i.MX28 we need to have the | ||
247 | # image stream built before the sdcard generation | ||
248 | IMAGE_TYPEDEP_sdcard_append = " \ | ||
249 | ${@bb.utils.contains('IMAGE_FSTYPES', 'uboot-mxsboot-sdcard', 'uboot-mxsboot-sdcard', '', d)} \ | ||
250 | " | ||
251 | |||
252 | # In case we are building for i.MX23 or i.MX28 we need to have the | 24 | # In case we are building for i.MX23 or i.MX28 we need to have the |
253 | # image stream built before the wic generation | 25 | # image stream built before the wic generation |
254 | do_image_wic[depends] += " \ | 26 | do_image_wic[depends] += " \ |