Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- msg "Finishing image for $DEVICE $EDITION edition..."
- info "Copying files to image..."
- ARCH='aarch64'
- SIZE=$(du -s --block-size=MB $ROOTFS_IMG/rootfs_$ARCH | awk '{print $1}' | sed -e 's/MB//g')
- EXTRA_SIZE=300
- REAL_SIZE=`echo "$(($SIZE+$EXTRA_SIZE))"`
- #making blank .img to be used
- dd if=/dev/zero of=$IMGDIR/$IMGNAME.img bs=1M count=$REAL_SIZE 1> /dev/null 2>&1
- #probing loop into the kernel
- modprobe loop 1> /dev/null 2>&1
- #set up loop device
- LDEV=`losetup -f`
- DEV=`echo $LDEV | cut -d "/" -f 3`
- #mount image to loop device
- losetup $LDEV $IMGDIR/$IMGNAME.img 1> /dev/null 2>&1
- #For BPI-R2 rootfs
- if [[ "$DEVICE" = "bpi-r2" ]]; then
- #partition with boot and root
- parted -s $LDEV mklabel msdos 1> /dev/null 2>&1
- parted -s $LDEV mkpart primary fat32 -- 100MiB 356MiB 1> /dev/null 2>&1
- START=`cat /sys/block/$DEV/${DEV}p1/start`
- SIZE=`cat /sys/block/$DEV/${DEV}p1/size`
- END_SECTOR=$(expr $START + $SIZE)
- parted -s $LDEV mkpart primary ext4 "${END_SECTOR}s" 100% 1> /dev/null 2>&1
- partprobe $LDEV 1> /dev/null 2>&1
- mkfs.vfat "${LDEV}p1" -n BPI-BOOT 1> /dev/null 2>&1
- mkfs.ext4 -O ^metadata_csum,^64bit ${LDEV}p2 -L BPI-ROOT 1> /dev/null 2>&1
- #copy rootfs contents over to the FS
- mkdir -p $TMPDIR/root
- mkdir -p $TMPDIR/boot
- mount ${LDEV}p1 $TMPDIR/boot
- mount ${LDEV}p2 $TMPDIR/root
- cp -ra $ROOTFS_IMG/rootfs_$ARCH/* $TMPDIR/root/
- mv $TMPDIR/root/boot/* $TMPDIR/boot
- #flash bootloader
- if [[ "$DEVICE" = "bpi-r2" ]]; then
- #dd if=$TMPDIR/boot/BPI-R2-HEAD440-0k.img of=${LDEV} bs=1024 seek=0
- #dd if=$TMPDIR/boot/BPI-R2-HEAD1-512b.img of=${LDEV} bs=512 seek=1
- #dd if=$TMPDIR/boot/BPI-R2-preloader-DDR1600-20190722-2k.img of=${LDEV} bs=1k seek=2
- #dd if=$TMPDIR/boot/u-boot.bin of=${LDEV} bs=1k seek=320
- #Using frank's 1M ready Img with all partition table, Preloader and uboot
- dd if=/boot/bpi-r2-sd-boot1m.img bs=1M count=1 of=${LDEV}
- fi
- #clean up
- umount $TMPDIR/root
- umount $TMPDIR/boot
- losetup -d $LDEV 1> /dev/null 2>&1
- rm -r $TMPDIR/root $TMPDIR/boot
- partprobe $LDEV 1> /dev/null 2>&1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement