Script for installing Armbian (3.14 kernel) to Phicomm N1Update: I suggest to use this script instead if you care about (a bit) more free disk space and/or want to change the box’s boot splash image.
From GitHub, slightly modified.
The original source seems to be a post at right.com.cn but I was not able to download that as the forum’s registration requires an invitation.
The use of environment variable mac
is removed, it does not seem to hurt.
DTB is also not used.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 #!/bin/sh echo "Start copy system for DATA partition." mkdir -p /ddbrchmod 777 /ddbr VER=`uname -r` IMAGE_KERNEL="/boot/zImage"IMAGE_INITRD="/boot/initrd.img-$VER"PART_ROOT="/dev/data"DIR_INSTALL="/ddbr/install"#IMAGE_DTB="/boot/dtb/gxl_p230_2g.dtb" if [ ! -f $IMAGE_KERNEL ] ; then echo "Not KERNEL. STOP install !!!" returnfi if [ ! -f $IMAGE_INITRD ] ; then echo "Not INITRD. STOP install !!!" returnfi echo "Formatting DATA partition..."umount -f $PART_ROOTmke2fs -F -q -t ext4 -m 0 $PART_ROOT/sbin/resize2fs -s $PART_ROOT/sbin/tune2fs -O ^metadata_csum $PART_ROOTe2fsck -n $PART_ROOTecho "done." echo "Copying ROOTFS." if [ -d $DIR_INSTALL ] ; then rm -rf $DIR_INSTALLfi mkdir -p $DIR_INSTALLmount -o rw $PART_ROOT $DIR_INSTALL cd /echo "Copy BIN"tar -cf - bin | (cd $DIR_INSTALL; tar -xpf -)echo "Copy BOOT"#mkdir -p $DIR_INSTALL/boottar -cf - boot | (cd $DIR_INSTALL; tar -xpf -)echo "Create DEV"mkdir -p $DIR_INSTALL/dev#tar -cf - dev | (cd $DIR_INSTALL; tar -xpf -)echo "Copy ETC"tar -cf - etc | (cd $DIR_INSTALL; tar -xpf -)echo "Copy HOME"tar -cf - home | (cd $DIR_INSTALL; tar -xpf -)echo "Copy LIB"tar -cf - lib | (cd $DIR_INSTALL; tar -xpf -)echo "Create MEDIA"mkdir -p $DIR_INSTALL/media#tar -cf - media | (cd $DIR_INSTALL; tar -xpf -)echo "Create MNT"mkdir -p $DIR_INSTALL/mnt#tar -cf - mnt | (cd $DIR_INSTALL; tar -xpf -)echo "Copy OPT"tar -cf - opt | (cd $DIR_INSTALL; tar -xpf -)echo "Create PROC"mkdir -p $DIR_INSTALL/procecho "Copy ROOT"tar -cf - root | (cd $DIR_INSTALL; tar -xpf -)echo "Create RUN"mkdir -p $DIR_INSTALL/runecho "Copy SBIN"tar -cf - sbin | (cd $DIR_INSTALL; tar -xpf -)echo "Copy SELINUX"tar -cf - selinux | (cd $DIR_INSTALL; tar -xpf -)echo "Copy SRV"tar -cf - srv | (cd $DIR_INSTALL; tar -xpf -)echo "Create SYS"mkdir -p $DIR_INSTALL/sysecho "Create TMP"mkdir -p $DIR_INSTALL/tmpecho "Copy USR"tar -cf - usr | (cd $DIR_INSTALL; tar -xpf -)echo "Copy VAR"tar -cf - var | (cd $DIR_INSTALL; tar -xpf -) echo "Copy fstab" rm $DIR_INSTALL/etc/fstabcp -a /root/fstab $DIR_INSTALL/etc#cp -a /boot/hdmi.sh $DIR_INSTALL/boot #add by achaoge 2018-06-22#export $(/usr/sbin/fw_printenv mac)echo "Modify files for N1 emmc boot"/bin/sed -e "/usb [23]/d" -e 's/fatload mmc 0 \([^ ]*\) \([^;]*\)/ext4load mmc 1:c \1 \/boot\/\2/g' -i $DIR_INSTALL/boot/s905_autoscript.cmd/bin/sed -e 's/LABEL=ROOTFS/\/dev\/data/' -i $DIR_INSTALL/boot/uEnv.ini/usr/bin/mkimage -C none -A arm -T script -d $DIR_INSTALL/boot/s905_autoscript.cmd $DIR_INSTALL/boot/s905_autoscriptecho "Emmc boot fixed end" rm $DIR_INSTALL/root/install.shrm $DIR_INSTALL/root/fstabrm $DIR_INSTALL/usr/bin/ddbrrm $DIR_INSTALL/usr/bin/ddbr_backup_nandrm $DIR_INSTALL/usr/bin/ddbr_restore_nand cd /sync umount $DIR_INSTALL echo "*******************************************"echo "Done copy ROOTFS"echo "*******************************************" # echo "Writing new kernel image..."## mkdir -p $DIR_INSTALL/aboot# cd $DIR_INSTALL/aboot# dd if=/dev/boot of=boot.backup.img# abootimg -i /dev/boot > aboot.txt# abootimg -x /dev/boot# abootimg -u /dev/boot -k $IMAGE_KERNEL# abootimg -u /dev/boot -r $IMAGE_INITRD## echo "done."## if [ -f $IMAGE_DTB ] ; then# # abootimg -u /dev/boot -s $IMAGE_DTB# echo "Writing new dtb ..."# dd if="$IMAGE_DTB" of="/dev/dtb" bs=262144 status=none && sync# echo "done."# fi echo "Write env bootargs"#/usr/sbin/fw_setenv initargs "root=/dev/data rootflags=data=writeback rw console=ttyS0,115200n8 console=tty0 no_console_suspend consoleblank=0 fsck.repair=yes net.ifnames=0 mac=\${mac}" #Edit by achaoge 2018-06-22, for Phicomm N1 boot from emmc/usr/sbin/fw_setenv start_autoscript "if usb start ; then run start_usb_autoscript; fi; if ext4load mmc 1:c 1020000 /boot/s905_autoscript; then autoscr 1020000; fi;" echo "*******************************************"echo "Complete copy OS to eMMC parted DATA"echo "*******************************************"
Update: I suggest to use this script instead if you care about (a bit) more free disk space and/or want to change the box’s boot splash image.
From GitHub, slightly modified.
The original source seems to be a post at right.com.cn but I was not able to download that as the forum’s registration requires an invitation.
The use of environment variable mac
is removed, it does not seem to hurt.
DTB is also not used.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | #!/bin/sh echo "Start copy system for DATA partition." mkdir -p /ddbr chmod 777 /ddbr VER=`uname -r` IMAGE_KERNEL="/boot/zImage" IMAGE_INITRD="/boot/initrd.img-$VER" PART_ROOT="/dev/data" DIR_INSTALL="/ddbr/install" #IMAGE_DTB="/boot/dtb/gxl_p230_2g.dtb" if [ ! -f $IMAGE_KERNEL ] ; then echo "Not KERNEL. STOP install !!!" return fi if [ ! -f $IMAGE_INITRD ] ; then echo "Not INITRD. STOP install !!!" return fi echo "Formatting DATA partition..." umount -f $PART_ROOT mke2fs -F -q -t ext4 -m 0 $PART_ROOT /sbin/resize2fs -s $PART_ROOT /sbin/tune2fs -O ^metadata_csum $PART_ROOT e2fsck -n $PART_ROOT echo "done." echo "Copying ROOTFS." if [ -d $DIR_INSTALL ] ; then rm -rf $DIR_INSTALL fi mkdir -p $DIR_INSTALL mount -o rw $PART_ROOT $DIR_INSTALL cd / echo "Copy BIN" tar -cf - bin | (cd $DIR_INSTALL; tar -xpf -) echo "Copy BOOT" #mkdir -p $DIR_INSTALL/boot tar -cf - boot | (cd $DIR_INSTALL; tar -xpf -) echo "Create DEV" mkdir -p $DIR_INSTALL/dev #tar -cf - dev | (cd $DIR_INSTALL; tar -xpf -) echo "Copy ETC" tar -cf - etc | (cd $DIR_INSTALL; tar -xpf -) echo "Copy HOME" tar -cf - home | (cd $DIR_INSTALL; tar -xpf -) echo "Copy LIB" tar -cf - lib | (cd $DIR_INSTALL; tar -xpf -) echo "Create MEDIA" mkdir -p $DIR_INSTALL/media #tar -cf - media | (cd $DIR_INSTALL; tar -xpf -) echo "Create MNT" mkdir -p $DIR_INSTALL/mnt #tar -cf - mnt | (cd $DIR_INSTALL; tar -xpf -) echo "Copy OPT" tar -cf - opt | (cd $DIR_INSTALL; tar -xpf -) echo "Create PROC" mkdir -p $DIR_INSTALL/proc echo "Copy ROOT" tar -cf - root | (cd $DIR_INSTALL; tar -xpf -) echo "Create RUN" mkdir -p $DIR_INSTALL/run echo "Copy SBIN" tar -cf - sbin | (cd $DIR_INSTALL; tar -xpf -) echo "Copy SELINUX" tar -cf - selinux | (cd $DIR_INSTALL; tar -xpf -) echo "Copy SRV" tar -cf - srv | (cd $DIR_INSTALL; tar -xpf -) echo "Create SYS" mkdir -p $DIR_INSTALL/sys echo "Create TMP" mkdir -p $DIR_INSTALL/tmp echo "Copy USR" tar -cf - usr | (cd $DIR_INSTALL; tar -xpf -) echo "Copy VAR" tar -cf - var | (cd $DIR_INSTALL; tar -xpf -) echo "Copy fstab" rm $DIR_INSTALL/etc/fstab cp -a /root/fstab $DIR_INSTALL/etc #cp -a /boot/hdmi.sh $DIR_INSTALL/boot #add by achaoge 2018-06-22 #export $(/usr/sbin/fw_printenv mac) echo "Modify files for N1 emmc boot" /bin/sed -e "/usb [23]/d" -e 's/fatload mmc 0 \([^ ]*\) \([^;]*\)/ext4load mmc 1:c \1 \/boot\/\2/g' -i $DIR_INSTALL/boot/s905_autoscript.cmd /bin/sed -e 's/LABEL=ROOTFS/\/dev\/data/' -i $DIR_INSTALL/boot/uEnv.ini /usr/bin/mkimage -C none -A arm -T script -d $DIR_INSTALL/boot/s905_autoscript.cmd $DIR_INSTALL/boot/s905_autoscript echo "Emmc boot fixed end" rm $DIR_INSTALL/root/install.sh rm $DIR_INSTALL/root/fstab rm $DIR_INSTALL/usr/bin/ddbr rm $DIR_INSTALL/usr/bin/ddbr_backup_nand rm $DIR_INSTALL/usr/bin/ddbr_restore_nand cd / sync umount $DIR_INSTALL echo "*******************************************" echo "Done copy ROOTFS" echo "*******************************************" # echo "Writing new kernel image..." # # mkdir -p $DIR_INSTALL/aboot # cd $DIR_INSTALL/aboot # dd if=/dev/boot of=boot.backup.img # abootimg -i /dev/boot > aboot.txt # abootimg -x /dev/boot # abootimg -u /dev/boot -k $IMAGE_KERNEL # abootimg -u /dev/boot -r $IMAGE_INITRD # # echo "done." # # if [ -f $IMAGE_DTB ] ; then # # abootimg -u /dev/boot -s $IMAGE_DTB # echo "Writing new dtb ..." # dd if="$IMAGE_DTB" of="/dev/dtb" bs=262144 status=none && sync # echo "done." # fi echo "Write env bootargs" #/usr/sbin/fw_setenv initargs "root=/dev/data rootflags=data=writeback rw console=ttyS0,115200n8 console=tty0 no_console_suspend consoleblank=0 fsck.repair=yes net.ifnames=0 mac=\${mac}" #Edit by achaoge 2018-06-22, for Phicomm N1 boot from emmc /usr/sbin/fw_setenv start_autoscript "if usb start ; then run start_usb_autoscript; fi; if ext4load mmc 1:c 1020000 /boot/s905_autoscript; then autoscr 1020000; fi;" echo "*******************************************" echo "Complete copy OS to eMMC parted DATA" echo "*******************************************" |