Advertisement
Guest User

Untitled

a guest
Sep 5th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. msg "Finishing image for $DEVICE $EDITION edition..."
  2. info "Copying files to image..."
  3.  
  4. ARCH='aarch64'
  5.  
  6. SIZE=$(du -s --block-size=MB $ROOTFS_IMG/rootfs_$ARCH | awk '{print $1}' | sed -e 's/MB//g')
  7. EXTRA_SIZE=300
  8. REAL_SIZE=`echo "$(($SIZE+$EXTRA_SIZE))"`
  9.  
  10. #making blank .img to be used
  11. dd if=/dev/zero of=$IMGDIR/$IMGNAME.img bs=1M count=$REAL_SIZE 1> /dev/null 2>&1
  12.  
  13. #probing loop into the kernel
  14. modprobe loop 1> /dev/null 2>&1
  15.  
  16. #set up loop device
  17. LDEV=`losetup -f`
  18. DEV=`echo $LDEV | cut -d "/" -f 3`
  19.  
  20. #mount image to loop device
  21. losetup $LDEV $IMGDIR/$IMGNAME.img 1> /dev/null 2>&1
  22.  
  23. #For BPI-R2 rootfs
  24. if [[ "$DEVICE" = "bpi-r2" ]]; then
  25. #partition with boot and root
  26. parted -s $LDEV mklabel msdos 1> /dev/null 2>&1
  27. parted -s $LDEV mkpart primary fat32 -- 100MiB 356MiB 1> /dev/null 2>&1
  28. START=`cat /sys/block/$DEV/${DEV}p1/start`
  29. SIZE=`cat /sys/block/$DEV/${DEV}p1/size`
  30. END_SECTOR=$(expr $START + $SIZE)
  31. parted -s $LDEV mkpart primary ext4 "${END_SECTOR}s" 100% 1> /dev/null 2>&1
  32. partprobe $LDEV 1> /dev/null 2>&1
  33. mkfs.vfat "${LDEV}p1" -n BPI-BOOT 1> /dev/null 2>&1
  34. mkfs.ext4 -O ^metadata_csum,^64bit ${LDEV}p2 -L BPI-ROOT 1> /dev/null 2>&1
  35.  
  36. #copy rootfs contents over to the FS
  37. mkdir -p $TMPDIR/root
  38. mkdir -p $TMPDIR/boot
  39. mount ${LDEV}p1 $TMPDIR/boot
  40. mount ${LDEV}p2 $TMPDIR/root
  41. cp -ra $ROOTFS_IMG/rootfs_$ARCH/* $TMPDIR/root/
  42. mv $TMPDIR/root/boot/* $TMPDIR/boot
  43.  
  44.  
  45.  
  46. #flash bootloader
  47. if [[ "$DEVICE" = "bpi-r2" ]]; then
  48. #dd if=$TMPDIR/boot/BPI-R2-HEAD440-0k.img of=${LDEV} bs=1024 seek=0
  49. #dd if=$TMPDIR/boot/BPI-R2-HEAD1-512b.img of=${LDEV} bs=512 seek=1
  50. #dd if=$TMPDIR/boot/BPI-R2-preloader-DDR1600-20190722-2k.img of=${LDEV} bs=1k seek=2
  51. #dd if=$TMPDIR/boot/u-boot.bin of=${LDEV} bs=1k seek=320
  52. #Using frank's 1M ready Img with all partition table, Preloader and uboot
  53. dd if=/boot/bpi-r2-sd-boot1m.img bs=1M count=1 of=${LDEV}
  54.  
  55. fi
  56.  
  57. #clean up
  58. umount $TMPDIR/root
  59. umount $TMPDIR/boot
  60. losetup -d $LDEV 1> /dev/null 2>&1
  61. rm -r $TMPDIR/root $TMPDIR/boot
  62. partprobe $LDEV 1> /dev/null 2>&1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement