From 417c2a114832be80ea122de8a2cc6c8c606ff74f Mon Sep 17 00:00:00 2001 From: Samuli Piippo Date: Sun, 28 Apr 2013 19:23:50 +0300 Subject: mkcard: script to initialize memory card The mkcard.sh script can be used to initialize memory card, so that rootfs and boot files can be copied to it. Creates two partitions, fat and ext3, named boot and rootfs respectively. Change-Id: I62846802845f1715cde2c2fbb98e57f604b96878 Reviewed-by: Kalle Viironen --- recipes/mkcard/files/mkcard.sh | 78 ++++++++++++++++++++++++++++++++++++++++++ recipes/mkcard/mkcard_0.5.bb | 14 ++++++++ 2 files changed, 92 insertions(+) create mode 100755 recipes/mkcard/files/mkcard.sh create mode 100644 recipes/mkcard/mkcard_0.5.bb diff --git a/recipes/mkcard/files/mkcard.sh b/recipes/mkcard/files/mkcard.sh new file mode 100755 index 0000000..3e70dbc --- /dev/null +++ b/recipes/mkcard/files/mkcard.sh @@ -0,0 +1,78 @@ +#! /bin/sh +# mkcard.sh v0.5 +# (c) Copyright 2009 Graeme Gregory +# Licensed under terms of GPLv2 +# +# Parts of the procudure base on the work of Denys Dmytriyenko +# http://wiki.omap.com/index.php/MMC_Boot_Format + +export LC_ALL=C + +if [ $# -ne 1 ]; then + echo "Usage: $0 " + exit 1; +fi + +DRIVE=$1 + +dd if=/dev/zero of=$DRIVE bs=1024 count=1024 + +SIZE=`fdisk -l $DRIVE | grep Disk | grep bytes | awk '{print $5}'` + +echo DISK SIZE - $SIZE bytes + +CYLINDERS=`echo $SIZE/255/63/512 | bc` + +echo CYLINDERS - $CYLINDERS + +{ +echo ,9,0x0C,* +echo ,,,- +} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE + +sleep 1 + + +if [ -x `which kpartx` ]; then + kpartx -a ${DRIVE} +fi + +# handle various device names. +# note something like fdisk -l /dev/loop0 | egrep -E '^/dev' | cut -d' ' -f1 +# won't work due to https://bugzilla.redhat.com/show_bug.cgi?id=649572 + +PARTITION1=${DRIVE}1 +if [ ! -b ${PARTITION1} ]; then + PARTITION1=${DRIVE}p1 +fi + +DRIVE_NAME=`basename $DRIVE` +DEV_DIR=`dirname $DRIVE` + +if [ ! -b ${PARTITION1} ]; then + PARTITION1=$DEV_DIR/mapper/${DRIVE_NAME}p1 +fi + +PARTITION2=${DRIVE}2 +if [ ! -b ${PARTITION2} ]; then + PARTITION2=${DRIVE}p2 +fi +if [ ! -b ${PARTITION2} ]; then + PARTITION2=$DEV_DIR/mapper/${DRIVE_NAME}p2 +fi + + +# now make partitions. +if [ -b ${PARTITION1} ]; then + umount ${PARTITION1} + mkfs.vfat -F 32 -n "boot" ${PARTITION1} +else + echo "Cant find boot partition in /dev" +fi + +if [ -b ${PARITION2} ]; then + umount ${PARTITION2} + mke2fs -t ext3 -j -L "rootfs" ${PARTITION2} +else + echo "Cant find rootfs partition in /dev" +fi diff --git a/recipes/mkcard/mkcard_0.5.bb b/recipes/mkcard/mkcard_0.5.bb new file mode 100644 index 0000000..3671f7a --- /dev/null +++ b/recipes/mkcard/mkcard_0.5.bb @@ -0,0 +1,14 @@ +DESCRIPTION = "mkcard.sh v0.5" +LICENSE = "GPLv2+" +LIC_FILES_CHKSUM = "file://${COREBASE}/bitbake/COPYING;md5=751419260aa954499f7abaabaa882bbe" +SECTION = "devel" +PR = "0" + +SRC_URI = "file://mkcard.sh" + +do_install () { + install -d ${D}${bindir}/ + install -m 0755 ${WORKDIR}/mkcard.sh ${D}${bindir}/ +} + +BBCLASSEXTEND = "nativesdk" -- cgit v1.2.3-54-g00ecf