diff options
-rw-r--r-- | classes/sdcard_image.bbclass | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/classes/sdcard_image.bbclass b/classes/sdcard_image.bbclass new file mode 100644 index 0000000..5887240 --- /dev/null +++ b/classes/sdcard_image.bbclass | |||
@@ -0,0 +1,38 @@ | |||
1 | # | ||
2 | # Create an image that can by written onto a SD card using dd. | ||
3 | # | ||
4 | # External variables needed: | ||
5 | # ${ROOTFS} - the rootfs image to incorporate | ||
6 | |||
7 | inherit image | ||
8 | |||
9 | # Add the fstypes we need | ||
10 | IMAGE_FSTYPES += "sdimg" | ||
11 | |||
12 | # Ensure required utilities are present | ||
13 | IMAGE_DEPENDS_sdimg = "parted-native" | ||
14 | |||
15 | # Default to 3.4GiB images | ||
16 | SDIMG_SIZE ?= "3400" | ||
17 | |||
18 | # Addional space for boot partition | ||
19 | BOOT_SPACE ?= "10M" | ||
20 | |||
21 | IMAGE_CMD_sdimg () { | ||
22 | TMP=${WORKDIR}/tmp | ||
23 | SDIMG=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.sdimg | ||
24 | |||
25 | dd if=/dev/zero of=${SDIMG} bs=$(expr 1000 \* 1000) count=${SDIMG_SIZE} | ||
26 | |||
27 | # Create partition table | ||
28 | parted -s ${SDIMG} mklabel msdos | ||
29 | parted -s ${SDIMG} mkpart primary ${BOOT_SPACE} 100% | ||
30 | parted ${SDIMG} print | ||
31 | |||
32 | dd if=${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.bin of=${SDIMG} conv=notrunc seek=1 skip=1 bs=512 | ||
33 | dd if=${DEPLOY_DIR_IMAGE}/uImage-${MACHINE}.bin of=${SDIMG} conv=notrunc seek=1 bs=1M | ||
34 | dd if=${ROOTFS} of=${SDIMG} conv=notrunc seek=1 bs=${BOOT_SPACE} | ||
35 | |||
36 | cd ${DEPLOY_DIR_IMAGE} | ||
37 | ln -sf ${IMAGE_NAME}.sdimg ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.sdimg | ||
38 | } | ||