Last active
September 6, 2017 10:43
-
-
Save MitchRatquest/c09fdcb7c0b854677ee7e4022da13605 to your computer and use it in GitHub Desktop.
Alpine Linux Install Script for Allwinner H3 single board computers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#this script grabs dependencies for the armhf alpine image for H3 allwinner chips | |
#you will need to modify your script.bin with the fex files and sunxi-tools | |
#use fex2bin to modify and create and place it in the H3-Distro directory | |
#TODO: check dependencies for dosfstools sunxi-tools | |
echo "run this script with your sd card as the argument" | |
echo "if unsure, check with: ls /dev/sd*" | |
echo "use only the last part, like: ./burnimg.sh sdh" | |
#look here to make it less painful: http://askubuntu.com/questions/446156/pause-execution-and-wait-for-user-input | |
if [ ! -d "Alpine-Linux-Allwinner-H3-Distro" ] #if you don't have the repo | |
then | |
git clone https://github.com/atlury/Alpine-Linux-Allwinner-H3-Distro.git | |
fi | |
if [ ! -d "apks" ] #gotta get them apks | |
then | |
wget https://nl.alpinelinux.org/alpine/v3.5/releases/armhf/alpine-uboot-3.5.2-armhf.tar.gz | |
tar -xvzf alpine-uboot-3.5.2-armhf.tar.gz ./apks/ #only the apks folder | |
fi | |
alpdir=Alpine-Linux-Allwinner-H3-Distro | |
disk="$1" | |
dd if=/dev/zero of=/dev/$disk bs=1M count=1 #leading space for partition tables | |
dd if=$alpdir/u-boot-sunxi-with-spl.bin of=/dev/$disk bs=1024 seek=8 #uboot file at right place | |
# from https://superuser.com/questions/332252/creating-and-formating-a-partition-using-a-bash-script | |
# to create the partitions programatically (rather than manually) | |
# we're going to simulate the manual input to fdisk | |
# The sed script strips off all the comments so that we can | |
# document what we're doing in-line with the actual commands | |
# Note that a blank line (commented as "default" will send a empty | |
# line terminated with a newline to take the fdisk default. | |
sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk /dev/$disk | |
n # create new partition | |
p # primary partition | |
1 # partition number 1 | |
2048 #offset | |
# default, partition to end of disk | |
w # write changes to disk | |
EOF | |
mkfs.fat /dev/"$disk"1 | |
sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk /dev/$disk | |
a # set bootable flag on partition 1 to enabled | |
w # write changes | |
EOF | |
rootfs=/tmp/alpinetmp #put it somewhere | |
if [ ! -d "/tmp/alpinetmp" ] | |
then | |
mkdir "$rootfs" | |
fi | |
mount /dev/"$disk"1 "$rootfs" #there it goes | |
cp -r apks/ /tmp/alpinetmp/ | |
cp "$alpdir"/boot.cmd "$rootfs" | |
cp "$alpdir"/boot.scr "$rootfs" | |
cp "$alpdir"/initramfs-sunxi-new "$rootfs" | |
cp "$alpdir"/modloop-sunxi "$rootfs" | |
cp "$alpdir"/script.bin "$rootfs" | |
cp "$alpdir"/vmlinuz "$rootfs" | |
#drivers may not be necessary | |
cp "$alpdir"/mt7601Uap.ko "$rootfs" | |
cp "$alpdir"/RT2870AP.dat "$rootfs" | |
cp "$alpdir"/rtnet7601Uap.ko "$rootfs" | |
cp "$alpdir"/rtutil7601Uap.ko "$rootfs" | |
umount /dev/"$disk"1 | |
#you should be good to go now | |
echo "pull out your sdcard and give it a go" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Excellent....keep it going!!!