summaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
authorDenys Dmytriyenko <denys@ti.com>2014-01-28 17:19:35 -0500
committerDenys Dmytriyenko <denys@ti.com>2014-01-29 16:06:58 -0500
commit2b524321a25c35c5f987b8331e41b49d3b2e2d2b (patch)
tree2c4bbd9a4792d48edc4862fd0c9699a42a562ccc /classes
parentbb88de3462480930c3b27138fd670a57beb9156e (diff)
downloadmeta-ti-2b524321a25c35c5f987b8331e41b49d3b2e2d2b.tar.gz
sdcard_image: remove deprecated class
This class has been deprecated for a while. The recommended replacement is to use Yocto Project's new "wic" tool. Signed-off-by: Denys Dmytriyenko <denys@ti.com>
Diffstat (limited to 'classes')
-rw-r--r--classes/sdcard_image.bbclass156
1 files changed, 0 insertions, 156 deletions
diff --git a/classes/sdcard_image.bbclass b/classes/sdcard_image.bbclass
deleted file mode 100644
index f9b8d467..00000000
--- a/classes/sdcard_image.bbclass
+++ /dev/null
@@ -1,156 +0,0 @@
1inherit image
2
3# Add the fstypes we need
4IMAGE_FSTYPES_append = " tar.bz2 sdimg"
5
6# Ensure required utilities are present
7IMAGE_DEPENDS_sdimg = "genext2fs-native e2fsprogs-native"
8
9# Change this to match your host distro
10LOSETUP ?= "/sbin/losetup"
11
12# Since these need to go in /etc/fstab we can hardcode them
13# Since the vars are weakly assigned, you can override them from your local.conf
14LOOPDEV ?= "/dev/loop1"
15LOOPDEV_BOOT ?= "/dev/loop2"
16LOOPDEV_FS ?= "/dev/loop3"
17
18# Default to 4GiB images
19SDIMG_SIZE ?= "444"
20
21# FS type for rootfs
22ROOTFSTYPE ?= "ext4"
23
24BOOTPARTNAME_beaglebone = "BEAGLE_BONE"
25BOOTPARTNAME ?= "${MACHINE}"
26
27IMAGEDATESTAMP = "${@time.strftime('%Y.%m.%d',time.gmtime())}"
28
29# Files and/or directories to be copied into the vfat partition
30FATPAYLOAD ?= ""
31
32IMAGE_CMD_sdimg () {
33 SDIMG=${WORKDIR}/sd.img
34
35 # sanity check fstab entry for boot partition mounting
36 if [ "x$(cat /etc/fstab | grep ${LOOPDEV_BOOT} | grep ${WORKDIR}/tmp-mnt-boot | grep user || true)" = "x" ]; then
37 echo "/etc/fstab entries need to be created with the user flag for the loop devices like:"
38 echo "${LOOPDEV_BOOT} ${WORKDIR}/tmp-mnt-boot vfat user 0 0"
39 false
40 fi
41
42 # cleanup loops
43 for loop in ${LOOPDEV} ${LOOPDEV_BOOT} ${LOOPDEV_FS} ; do
44 ${LOSETUP} -d $loop || true
45 done
46
47 # If an SD image is already present, reuse and reformat it
48 if [ ! -e ${SDIMG} ] ; then
49 dd if=/dev/zero of=${SDIMG} bs=$(echo '255 * 63 * 512' | bc) count=${SDIMG_SIZE}
50 fi
51
52 ${LOSETUP} ${LOOPDEV} ${SDIMG}
53
54 # Create partition table
55 dd if=/dev/zero of=${LOOPDEV} bs=1024 count=1024
56 SIZE=$(/sbin/fdisk -l ${LOOPDEV} | grep Disk | grep bytes | awk '{print $5}')
57 CYLINDERS=$(echo $SIZE/255/63/512 | bc)
58 {
59 echo ,9,0x0C,*
60 echo ,,,-
61 } | /sbin/sfdisk -D -H 255 -S 63 -C ${CYLINDERS} ${LOOPDEV}
62
63 # Prepare loop devices for boot and filesystem partitions
64 BOOT_OFFSET=32256
65 FS_OFFSET_SECT=$(/sbin/fdisk -l -u ${LOOPDEV} 2>&1 | grep Linux | perl -p -i -e "s/\s+/ /"|cut -d " " -f 2)
66 FS_OFFSET=$(echo "$FS_OFFSET_SECT * 512" | bc)
67 FS_SIZE_BLOCKS=$(/sbin/fdisk -l -u ${LOOPDEV} 2>&1 | grep Linux | perl -p -i -e "s/\s+/ /g" \
68 |cut -d " " -f 4 | cut -d "+" -f 1)
69
70 LOOPDEV_BLOCKS=$(/sbin/fdisk -l -u ${LOOPDEV} 2>&1 | grep FAT | perl -p -i -e "s/\s+/ /g"|cut -d " " -f 5)
71 LOOPDEV_BYTES=$(echo "$LOOPDEV_BLOCKS * 1024" | bc)
72
73 ${LOSETUP} -d ${LOOPDEV}
74
75 ${LOSETUP} ${LOOPDEV_BOOT} ${SDIMG} -o ${BOOT_OFFSET}
76
77 /sbin/mkfs.vfat ${LOOPDEV_BOOT} -n ${BOOTPARTNAME} $LOOPDEV_BLOCKS
78
79 # Prepare filesystem partition
80 # Copy ubi used by flashing scripts
81 if [ -e ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ubi ] ; then
82 echo "Copying UBIFS image to file system"
83 cp ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ubi ${IMAGE_ROOTFS}/boot/fs.ubi
84 fi
85
86 # Prepare boot partion. First mount the boot partition, and copy the boot loader and supporting files
87 # from the root filesystem
88
89 mkdir -p ${WORKDIR}/tmp-mnt-boot
90 mount $LOOPDEV_BOOT ${WORKDIR}/tmp-mnt-boot
91
92 echo "Copying bootloaders into the boot partition"
93 if [ -e ${IMAGE_ROOTFS}/boot/MLO ] ; then
94 cp -v ${IMAGE_ROOTFS}/boot/MLO ${WORKDIR}/tmp-mnt-boot
95 else
96 cp -v ${DEPLOY_DIR_IMAGE}/MLO ${WORKDIR}/tmp-mnt-boot
97 fi
98
99 # Check for u-boot SPL
100 if [ -e ${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.img ] ; then
101 suffix=img
102 else
103 suffix=bin
104 fi
105
106 cp -v ${IMAGE_ROOTFS}/boot/uEnv.txt ${WORKDIR}/tmp-mnt-boot || true
107 cp -v ${IMAGE_ROOTFS}/boot/user.txt ${WORKDIR}/tmp-mnt-boot || true
108 cp -v ${IMAGE_ROOTFS}/boot/uImage ${WORKDIR}/tmp-mnt-boot || true
109
110 if [ -e ${IMAGE_ROOTFS}/boot/u-boot.$suffix ] ; then
111 cp -v ${IMAGE_ROOTFS}/boot/{u-boot.$suffix} ${WORKDIR}/tmp-mnt-boot || true
112 else
113 cp -v ${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.$suffix ${WORKDIR}/tmp-mnt-boot/u-boot.$suffix
114 fi
115
116 if [ -n ${FATPAYLOAD} ] ; then
117 echo "Copying payload into VFAT"
118 for entry in ${FATPAYLOAD} ; do
119 # add the || true to stop aborting on vfat issues like not supporting .~lock files
120 cp -av ${IMAGE_ROOTFS}$entry ${WORKDIR}/tmp-mnt-boot || true
121 done
122 fi
123
124 echo "${IMAGE_NAME}-${IMAGEDATESTAMP}" > ${IMAGE_ROOTFS}/etc/image-version-info
125
126 # Cleanup VFAT mount
127 echo "Cleaning up VFAT mount"
128 umount ${WORKDIR}/tmp-mnt-boot
129 ${LOSETUP} -d ${LOOPDEV_BOOT} || true
130
131 # Prepare rootfs parition
132 echo "Creating rootfs loopback"
133 ${LOSETUP} ${LOOPDEV_FS} ${SDIMG} -o ${FS_OFFSET}
134
135 FS_NUM_INODES=$(echo $FS_SIZE_BLOCKS / 4 | bc)
136
137 case "${ROOTFSTYPE}" in
138 ext3)
139 genext2fs -z -N $FS_NUM_INODES -b $FS_SIZE_BLOCKS -d ${IMAGE_ROOTFS} ${LOOPDEV_FS}
140 tune2fs -L ${IMAGE_NAME} -j ${LOOPDEV_FS}
141 ;;
142 ext4)
143 genext2fs -z -N $FS_NUM_INODES -b $FS_SIZE_BLOCKS -d ${IMAGE_ROOTFS} ${LOOPDEV_FS}
144 tune2fs -L ${IMAGE_NAME} -j -O extents,uninit_bg,dir_index ${LOOPDEV_FS}
145 ;;
146 *)
147 echo "Please set ROOTFSTYPE to something supported"
148 exit 1
149 ;;
150 esac
151
152 ${LOSETUP} -d ${LOOPDEV_FS} || true
153
154 gzip -c ${WORKDIR}/sd.img > ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}-${IMAGEDATESTAMP}.img.gz
155 rm -f ${WORKDIR}/sd.img
156}