Skip to content

Commit

Permalink
- Use $IMAGE_FILE instead of NookManager.img, makes ad hoc testing ea…
Browse files Browse the repository at this point in the history
…sier

- Use `losetup -f` to get a usable loop device: some may be in use
- Use `parted --align=minimal` to allow tighter control over partition shape
- Explicitly start partition at 16KiB rather than relying on "cyl" alignment
- "An" SD card :)
  • Loading branch information
filbo committed Mar 18, 2014
1 parent afee964 commit c841db5
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -181,25 +181,28 @@ cp "$BDIR/patched-jars/android.policy.jar" "$OUTDIR/files/system/framework/"
cp "$BDIR/patched-jars/services.jar" "$OUTDIR/files/system/framework/"

# Create image
dd if=/dev/zero of=NookManager.img bs=1MiB count=64
sudo losetup /dev/loop0 NookManager.img
sudo parted /dev/loop0 mklabel msdos
sudo parted /dev/loop0 --align=cyl mkpart primary fat32 0 100%
sudo parted /dev/loop0 set 1 boot on
sudo losetup -o 16384 /dev/loop1 /dev/loop0
sudo mkdosfs -F 32 -n "NookManager" /dev/loop1
IMAGE_FILE=NookManager.img
dd if=/dev/zero of=$IMAGE_FILE bs=1MiB count=64
WHOLE_CARD=$(sudo losetup -f)
sudo losetup $WHOLE_CARD $IMAGE_FILE
BOOTFS_DEV=$(sudo losetup -f)
sudo parted $WHOLE_CARD mklabel msdos
sudo parted $WHOLE_CARD --align=minimal mkpart primary fat32 16384B 100%
sudo parted $WHOLE_CARD set 1 boot on
sudo losetup -o 16384 $BOOTFS_DEV $WHOLE_CARD
sudo mkdosfs -F 32 -n "NookManager" $BOOTFS_DEV

if [ ! -d "$BDIR/tmpmount" ]; then
mkdir "$BDIR/tmpmount"
fi
sudo mount -t vfat -o uid=$(id -ur) -o gid=$(id -gr) /dev/loop1 "$BDIR/tmpmount"
sudo mount -t vfat -o uid=$(id -ur) -o gid=$(id -gr) $BOOTFS_DEV "$BDIR/tmpmount"

rsync -a "$OUTDIR/" "$BDIR/tmpmount/"
sync
sudo umount "$BDIR/tmpmount"

sudo losetup -d /dev/loop1
sudo losetup -d $BOOTFS_DEV
sync
sudo losetup -d /dev/loop0
sudo losetup -d $WHOLE_CARD

echo "Build Complete. You can now flash NookManager.img to a SD card."
echo "Build Complete. You can now flash $IMAGE_FILE to an SD card."

0 comments on commit c841db5

Please sign in to comment.