From: Andres Salomon Date: Fri, 17 Oct 2008 22:12:09 +0000 (-0400) Subject: mkjffs2: add (redboot) partition support X-Git-Tag: v0.2~14 X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0e1fb495b585c112496322a488dfa9cfb5f6ba9;p=xodist mkjffs2: add (redboot) partition support We now create a 50MB boot partition, and the rest goes to a root partition. This shaves 7s off of bootup, as OFW only has to mount /boot. It also provides us the opportunity to use other filesystems in /, as long as we keep /boot using jffs2. Signed-off-by: Andres Salomon --- diff --git a/functions.sh b/functions.sh index 29d4ae9..5829dd0 100644 --- a/functions.sh +++ b/functions.sh @@ -36,7 +36,7 @@ create_fstab() fstype="$2" if [ "${fstype}" = "jffs2" ]; then - r=mtd0 + r=mtd:root else r="LABEL=${IMG_LABEL}" fi @@ -60,7 +60,7 @@ create_ofwboot() fstype="$2" if [ "${fstype}" = "jffs2" ]; then - r=mtd0 + r="mtd:root" rfs="rootfstype=jffs2" else r="LABEL=${IMG_LABEL}" diff --git a/mkjffs2.sh b/mkjffs2.sh index f3c521d..da53633 100755 --- a/mkjffs2.sh +++ b/mkjffs2.sh @@ -33,10 +33,10 @@ fi ROOT_DIR=$1 IMG_NAME=$2 -if [ "${IMG_NAME}" == "${IMG_NAME/.img/.crc}" ]; then - CRC_NAME=${IMG_NAME}.crc +if [ "${IMG_NAME}" == "${IMG_NAME/.img/.dat}" ]; then + DAT_NAME=${IMG_NAME}.dat else - CRC_NAME=${IMG_NAME/.img/.crc} + DAT_NAME=${IMG_NAME/.img/.dat} fi if [ ! -d "${ROOT_DIR}" ]; then @@ -49,7 +49,64 @@ check_for_cmds mkfs.jffs2 sumtool || exit 1 create_fstab ${ROOT_DIR} jffs2 create_ofwboot ${ROOT_DIR} jffs2 -mkfs.jffs2 -n -e128KiB -r ${ROOT_DIR} -o ${IMG_NAME}.pre -sumtool -n -p -e 128KiB -i ${IMG_NAME}.pre -o ${IMG_NAME} -rm -f ${IMG_NAME}.pre -./crcimg.pl < ${IMG_NAME} > ${CRC_NAME} +create_jffs2() +{ + root_dir="$1" + out="$2" + + # XXX: do we want to switch to lzo? (mkfs.jffs2 -X lzo) + mkfs.jffs2 -n -e128KiB -r ${root_dir} -o ${out}.pre + sumtool -n -p -e 128KiB -i ${out}.pre -o ${out} + rm -f ${out}.pre +} + +do_sha256() +{ + f=$1 + eblocks=$((`stat --printf "%s\n" $f` / (128*1024))) + for b in $(seq 0 $(($eblocks - 1))); do + sha=$(dd status=noxfer bs=128KiB skip=$b count=1 if=$f | sha256sum | cut -d- -f1) + echo "eblock: `printf '%x' $b` sha256 $sha" >> ${IMG_NAME} + done +} + +partition_map() +{ + # 0x190 * 128KiB = 50MiB boot, and the rest for root + cat >${IMG_NAME}<>${IMG_NAME}<>${IMG_NAME}< ${DAT_NAME} +rm -f _boot.img _root.img