From 0bf71121cdcdaeb20ecde8aab0833c25952ac115 Mon Sep 17 00:00:00 2001 From: Tomasz Kłoczko Date: Nov 04 2017 09:48:29 +0000 Subject: [PATCH 1/9] - output of the list-targets.py to update list of supported boards. --- diff --git a/SUPPORTED-BOARDS b/SUPPORTED-BOARDS index 09f5a6b..3983ae0 100644 --- a/SUPPORTED-BOARDS +++ b/SUPPORTED-BOARDS @@ -1,24 +1,32 @@ AllWinner Devices: -A10-OLinuXino-Lime A10s-OLinuXino-M A13-OLinuXino A13-OLinuXinoM - A20-OLinuXino-Lime A20-OLinuXino-Lime2 A20-OLinuXino_MICRO - A20-Olimex-SOM-EVB Ampe_A76 Auxtek-T003 Auxtek-T004 Bananapi Bananapro CHIP - CSQ_CS908 Chuwi_V7_CW0825 Colombus Cubieboard Cubieboard2 Cubietruck - Cubietruck_plus Hummingbird_A31 Hyundai_A7HD Itead_Ibox_A20 Lamobo_R1 - Linksprite_pcDuino Linksprite_pcDuino3 Linksprite_pcDuino3_Nano MK808C - MSI_Primo73 MSI_Primo81 Marsboard_A10 Mele_A1000 Mele_A1000G_quad Mele_I7 - Mele_M3 Mele_M5 Mele_M9 Mini-X Orangepi Orangepi_mini Sinlinx_SinA31s - UTOO_P66 Wexler_TAB7200 Wits_Pro_A20_DKT Yones_Toptech_BS1078_V2 ba10_tv_box - colorfly_e708_q1 difrnce_dit4350 dserve_dsrv9703c i12-tvbox iNet_86VS - icnova-a20-swac inet86dz jesurun_q5 mk802 mk802_a10s mk802ii orangepi_2 - orangepi_lite orangepi_pc orangepi_plus polaroid_mid2809pxe04 - pov_protab2_ips9 q8_a13_tablet q8_a23_tablet_800x480 q8_a33_tablet_1024x600 - q8_a33_tablet_800x480 r7-tv-dongle sunxi_Gemei_G9 + +A10-OLinuXino-Lime A10s-OLinuXino-M A13-OLinuXino A13-OLinuXinoM + A20-Olimex-SOM-EVB A20-OLinuXino-Lime A20-OLinuXino-Lime2 + A20-OLinuXino-Lime2-eMMC A20-OLinuXino_MICRO a64-olinuxino Ampe_A76 + Auxtek-T003 Auxtek-T004 ba10_tv_box Bananapi Bananapi_M2_Ultra bananapi_m64 + Bananapro CHIP Chuwi_V7_CW0825 Colombus colorfly_e708_q1 CSQ_CS908 + Cubieboard Cubieboard2 Cubieboard4 Cubietruck Cubietruck_plus + difrnce_dit4350 dserve_dsrv9703c Hummingbird_A31 Hyundai_A7HD i12-tvbox + icnova-a20-swac inet86dz iNet_86VS Itead_Ibox_A20 jesurun_q5 Lamobo_R1 + Linksprite_pcDuino Linksprite_pcDuino3 Linksprite_pcDuino3_Nano + Marsboard_A10 Mele_A1000 Mele_A1000G_quad Mele_I7 Mele_M3 Mele_M5 Mele_M9 + Mini-X mk802 mk802_a10s mk802ii MK808C MSI_Primo73 MSI_Primo81 nanopi_a64 + nanopi_m1 nanopi_m1_plus nanopi_neo nanopi_neo2 nanopi_neo_air Orangepi + orangepi_2 orangepi_lite Orangepi_mini orangepi_one orangepi_pc orangepi_pc2 + orangepi_pc_plus orangepi_plus orangepi_plus2e orangepi_prime orangepi_win + orangepi_zero orangepi_zero_plus2 pine64_plus polaroid_mid2809pxe04 + pov_protab2_ips9 q8_a13_tablet q8_a23_tablet_800x480 q8_a33_tablet_1024x600 + q8_a33_tablet_800x480 r7-tv-dongle Sinlinx_SinA31s Sinovoip_BPI_M2_Plus + sopine_baseboard sunxi_Gemei_G9 UTOO_P66 Wexler_TAB7200 Wits_Pro_A20_DKT + Yones_Toptech_BS1078_V2 MX6 Devices: -cm_fx6 mx6cuboxi novena riotboard wandboard +cm_fx6 liteboard marsboard mx6cuboxi novena riotboard udoo udoo_neo + usbarmory wandboard warp warp7 OMAP Devices: -am335x_boneblack am57xx_evm kc1 omap3_beagle omap4_panda omap5_uevm +am335x_boneblack am335x_evm am57xx_evm chiliboard cl-som-am57x kc1 + omap3_beagle omap4_panda omap5_uevm MVEBU Devices: clearfog From 4eb7367c8789a9ca210f7049f2f809a92c9939b2 Mon Sep 17 00:00:00 2001 From: Tomasz Kłoczko Date: Nov 04 2017 09:52:00 +0000 Subject: [PATCH 2/9] - change spaces to tabs. --- diff --git a/arm-image-installer b/arm-image-installer old mode 100755 new mode 100644 index ee7a9b2..0aa5d5d --- a/arm-image-installer +++ b/arm-image-installer @@ -33,94 +33,94 @@ Example: $(basename ${0}) --image=Fedora-Rawhide.xz --target=Bananapi --media=/d # and valid targets. DIR=$(dirname $0) if [ -d "/usr/share/arm-image-installer/boards.d" ]; then - BOARDDIR="/usr/share/arm-image-installer/boards.d" + BOARDDIR="/usr/share/arm-image-installer/boards.d" DOC_DIR="/usr/share/doc/fedora-arm-installer/" else - DIR=$(dirname $0) - BOARDDIR="${DIR}/boards.d" + DIR=$(dirname $0) + BOARDDIR="${DIR}/boards.d" DOC_DIR="${DIR}/" fi # check the args while [ $# -gt 0 ]; do - case $1 in - --debug) - set -x - ;; - -h|--help) - usage - exit 0 - ;; - --target*) - if echo $1 | grep '=' >/dev/null ; then - TARGET=$(echo $1 | sed 's/^--target=//') - else - TARGET=$2 - shift - fi - ;; - --image*) - if echo $1 | grep '=' >/dev/null ; then - IMAGE=$(echo $1 | sed 's/^--image=//') - else - IMAGE=$2 - shift - fi - ;; - --media*) - if echo $1 | grep '=' >/dev/null ; then - MEDIA=$(echo $1 | sed 's/^--media=//') - else - MEDIA=$2 - shift - fi - ;; - --addkey*) - if echo $1 | grep '=' >/dev/null ; then - SSH_KEY=$(echo $1 | sed 's/^--addkey=//') - else - SSH_KEY=$2 - shift - fi - ;; - --selinux*) - if echo $1 | grep '=' >/dev/null ; then - SELINUX=$(echo $1 | sed 's/^--selinux=//') - else - SELINUX=$2 - shift - fi - ;; - --norootpass) - NOROOTPASS=1 - ;; - --resizefs) - RESIZEFS=1 - ;; - --addconsole) - CONSOLE=1 + case $1 in + --debug) + set -x + ;; + -h|--help) + usage + exit 0 + ;; + --target*) + if echo $1 | grep '=' >/dev/null ; then + TARGET=$(echo $1 | sed 's/^--target=//') + else + TARGET=$2 + shift + fi + ;; + --image*) + if echo $1 | grep '=' >/dev/null ; then + IMAGE=$(echo $1 | sed 's/^--image=//') + else + IMAGE=$2 + shift + fi + ;; + --media*) + if echo $1 | grep '=' >/dev/null ; then + MEDIA=$(echo $1 | sed 's/^--media=//') + else + MEDIA=$2 + shift + fi + ;; + --addkey*) + if echo $1 | grep '=' >/dev/null ; then + SSH_KEY=$(echo $1 | sed 's/^--addkey=//') + else + SSH_KEY=$2 + shift + fi + ;; + --selinux*) + if echo $1 | grep '=' >/dev/null ; then + SELINUX=$(echo $1 | sed 's/^--selinux=//') + else + SELINUX=$2 + shift + fi + ;; + --norootpass) + NOROOTPASS=1 + ;; + --resizefs) + RESIZEFS=1 + ;; + --addconsole) + CONSOLE=1 ;; --blacklistvc4) FIX_RPI=1 - ;; + ;; --supported) - cat $DOC_DIR/SUPPORTED-BOARDS - exit 0 - ;; - --version) - echo "$(basename ${0})-"$VERSION"" - exit 0 - ;; - -y) - NOASK=1 - ;; - *) - echo "$(basename ${0}): Error - ${1}" - usage - exit 1 - ;; - esac - shift + cat $DOC_DIR/SUPPORTED-BOARDS + exit 0 + ;; + --version) + echo "$(basename ${0})-"$VERSION"" + exit 0 + ;; + -y) + NOASK=1 + ;; + *) + echo "$(basename ${0}): Error - ${1}" + usage + exit 1 + ;; + esac + shift done contains() { @@ -128,46 +128,46 @@ contains() { substring="$2" if test "${string#*$substring}" != "$string" then - return 0 # $substring is in $string + return 0 # $substring is in $string else - return 1 # $substring is not in $string + return 1 # $substring is not in $string fi } # ensure sudo user if [ "$(whoami)" != "root" ] ; then - echo "Error: This script requires 'sudo' privileges in order to write to disk & mount media." - exit 1 + echo "Error: This script requires 'sudo' privileges in order to write to disk & mount media." + exit 1 fi # check to make sure populated if [ "$MEDIA" = "" ] ; then - usage - exit 1 + usage + exit 1 fi # change cubietruck target to uppercase if [ "$TARGET" = "cubietruck" ]; then - TARGET="Cubietruck" + TARGET="Cubietruck" fi # check for boards if [ "$TARGET" != "" -a ! -e "${BOARDDIR}/${TARGET}" ] ; then - echo "Error: You must choose a supported board or none at all." - usage - exit 1 + echo "Error: You must choose a supported board or none at all." + usage + exit 1 fi # image exists if [ ! -f "$IMAGE" ] && [ "$IMAGE" != "" ] ; then - echo "Error: $IMAGE not found! Please choose an existing image." - exit 1 + echo "Error: $IMAGE not found! Please choose an existing image." + exit 1 fi # device exists if [ ! -e "$MEDIA" ] ; then - echo "Error: $MEDIA not found! Please choose an existing device." - exit 1 + echo "Error: $MEDIA not found! Please choose an existing device." + exit 1 fi clear @@ -176,33 +176,33 @@ echo " " echo "=====================================================" # Image if included if [ "$IMAGE" != "" ] ; then - echo "= Selected Image: " - echo "= $IMAGE" + echo "= Selected Image: " + echo "= $IMAGE" fi echo "= Selected Media : $MEDIA" # target hardware platform if [ "$TARGET" != "" ] ; then - echo "= U-Boot Target : $TARGET" + echo "= U-Boot Target : $TARGET" fi # SE Linux On/Off if [ "$SELINUX" != "" ] ; then - echo "= SELINUX = $SELINUX" + echo "= SELINUX = $SELINUX" fi # Remove root password if [ "$NOROOTPASS" != "" ] ; then - echo "= Root Password will be removed." + echo "= Root Password will be removed." fi # Resize root filesystem to fill media device if [ "$RESIZEFS" != "" ] ; then - echo "= Root partition will be resized" + echo "= Root partition will be resized" fi # Console to be added if [ "$CONSOLE" != "" ] ; then - echo "= Console for $TARGET will be added." + echo "= Console for $TARGET will be added." fi # User ssh key if [ "$SSH_KEY" != "" ] ; then - echo "= SSH Public Key $SSH_KEY will be added." + echo "= SSH Public Key $SSH_KEY will be added." fi echo "=====================================================" echo " " @@ -212,78 +212,78 @@ echo "******** WARNING! ALL DATA WILL BE DESTROYED ********" echo "*****************************************************" echo "*****************************************************" if [ "$NOASK" != 1 ] ; then - echo " " - echo " Type 'YES' to proceed, anything else to exit now " - echo " " - # wait for agreement - read -p "= Proceed? " PROCEED - if [ "$(echo ${PROCEED} | tr [:lower:] [:upper:])" != "YES" ] ; then - echo "User exit, no image written." - exit 0 - fi + echo " " + echo " Type 'YES' to proceed, anything else to exit now " + echo " " + # wait for agreement + read -p "= Proceed? " PROCEED + if [ "$(echo ${PROCEED} | tr [:lower:] [:upper:])" != "YES" ] ; then + echo "User exit, no image written." + exit 0 + fi fi # umount before starting umount $MEDIA* &> /dev/null # Write the disk image to media if [ "$IMAGE" != "" ] ; then - echo "= Writing: " - echo "= $IMAGE " - echo "= To: $MEDIA ...." - xzcat $IMAGE | dd of=$MEDIA bs=4M; sync; sleep 3 - echo "= Writing image complete!" - # read the new partition table - partprobe "$MEDIA" + echo "= Writing: " + echo "= $IMAGE " + echo "= To: $MEDIA ...." + xzcat $IMAGE | dd of=$MEDIA bs=4M; sync; sleep 3 + echo "= Writing image complete!" + # read the new partition table + partprobe "$MEDIA" fi # check to see how many partitions on the image partprobe "$MEDIA" sleep 1 case $MEDIA in - "/dev/mmcblk"*) - if [ -e "$MEDIA"p4 ]; then - export FIRMPART="${MEDIA}p1" - BOOTPART="${MEDIA}p2" - ROOTPART="${MEDIA}p4" - PARTNUM=4 - else - BOOTPART="${MEDIA}p1" - ROOTPART="${MEDIA}p3" - PARTNUM=3 - fi - ;; - *) - if [ -e "$MEDIA"4 ]; then - export FIRMPART="${MEDIA}1" - BOOTPART="${MEDIA}2" - ROOTPART="${MEDIA}4" - PARTNUM=4 - else - BOOTPART="${MEDIA}1" - ROOTPART="${MEDIA}3" - PARTNUM=3 - fi - ;; + "/dev/mmcblk"*) + if [ -e "$MEDIA"p4 ]; then + export FIRMPART="${MEDIA}p1" + BOOTPART="${MEDIA}p2" + ROOTPART="${MEDIA}p4" + PARTNUM=4 + else + BOOTPART="${MEDIA}p1" + ROOTPART="${MEDIA}p3" + PARTNUM=3 + fi + ;; + *) + if [ -e "$MEDIA"4 ]; then + export FIRMPART="${MEDIA}1" + BOOTPART="${MEDIA}2" + ROOTPART="${MEDIA}4" + PARTNUM=4 + else + BOOTPART="${MEDIA}1" + ROOTPART="${MEDIA}3" + PARTNUM=3 + fi + ;; esac # resize root filesystem before mounting if [ "$RESIZEFS" != "" ] ; then - echo "= Resizing $MEDIA ...." - sync + echo "= Resizing $MEDIA ...." + sync count=0 - echo ", +" | sfdisk -N "$PARTNUM" "$MEDIA" - while [ $? != '0' ]; do - sleep 5 - echo ", +" | sfdisk -N "$PARTNUM" "$MEDIA" + echo ", +" | sfdisk -N "$PARTNUM" "$MEDIA" + while [ $? != '0' ]; do + sleep 5 + echo ", +" | sfdisk -N "$PARTNUM" "$MEDIA" count=$((count+1)) if [ $count -gt 5 ] then echo "= Partition Resize Failed." - continue + continue fi - done - - partprobe "$MEDIA" + done + + partprobe "$MEDIA" FS_TYPE=$(file -s "$ROOTPART" | awk '{print $3}') if [ "$FS_TYPE" = "XFS" ]; then @@ -294,7 +294,7 @@ if [ "$RESIZEFS" != "" ] ; then umount "$ROOTPART" else fsck.ext4 -fy "$ROOTPART" - resize2fs "$ROOTPART" + resize2fs "$ROOTPART" fi fi @@ -302,62 +302,62 @@ fi mkdir /tmp/{boot,root} &> /dev/null mount "$BOOTPART" /tmp/boot &> /dev/null if [ $? -ne 0 ]; then - echo "Error: mount $BOOTPART /tmp/boot failed" - exit 1 + echo "Error: mount $BOOTPART /tmp/boot failed" + exit 1 fi mount "$ROOTPART" /tmp/root &> /dev/null if [ $? -ne 0 ]; then - echo "Error: mount $ROOTPART /tmp/root failed" - exit 1 + echo "Error: mount $ROOTPART /tmp/root failed" + exit 1 fi # turn off selinux if [ "$SELINUX" != "" ] ; then - if [ "$(echo ${SELINUX} | tr [:lower:] [:upper:])" = "OFF" ] ; then - echo "= Turning SELinux off ..." - sed -i 's/append/& enforcing=0/' /tmp/boot/extlinux/extlinux.conf - # turn on selinux - elif [ "$(echo ${SELINUX} | tr [:lower:] [:upper:])" = "ON" ] ; then - echo "= Turning SELinux on ..." - sed -i 's/ enforcing=0//' /tmp/boot/extlinux/extlinux.conf - fi + if [ "$(echo ${SELINUX} | tr [:lower:] [:upper:])" = "OFF" ] ; then + echo "= Turning SELinux off ..." + sed -i 's/append/& enforcing=0/' /tmp/boot/extlinux/extlinux.conf + # turn on selinux + elif [ "$(echo ${SELINUX} | tr [:lower:] [:upper:])" = "ON" ] ; then + echo "= Turning SELinux on ..." + sed -i 's/ enforcing=0//' /tmp/boot/extlinux/extlinux.conf + fi fi # Remove root password if [ "$NOROOTPASS" = "1" ] ; then - echo "= Removing the root password." - sed -i 's/root:x:/root::/' /tmp/root/etc/passwd + echo "= Removing the root password." + sed -i 's/root:x:/root::/' /tmp/root/etc/passwd fi # Add ssh key to the image if [ "$SSH_KEY" != "" ] ; then - if [ -f $SSH_KEY ]; then - echo "= Adding SSH key to authorized keys." - mkdir /tmp/root/root/.ssh/ &> /dev/null - cat $SSH_KEY >> /tmp/root/root/.ssh/authorized_keys - chmod -R u=rwX,o=,g= /tmp/root/root/.ssh/ - else - echo "= SSH key $SSH_KEY : Not Found!" - echo "= WARNING: No SSH Key Added." - fi - + if [ -f $SSH_KEY ]; then + echo "= Adding SSH key to authorized keys." + mkdir /tmp/root/root/.ssh/ &> /dev/null + cat $SSH_KEY >> /tmp/root/root/.ssh/authorized_keys + chmod -R u=rwX,o=,g= /tmp/root/root/.ssh/ + else + echo "= SSH key $SSH_KEY : Not Found!" + echo "= WARNING: No SSH Key Added." + fi + fi # determine uboot and write to disk if [ "$TARGET" = "" ]; then - echo "= No U-boot will be written." - TARGET="Mystery Board" + echo "= No U-boot will be written." + TARGET="Mystery Board" else - PREFIX=/tmp/root - . "${BOARDDIR}/${TARGET}" - # Add console - if [ "$CONSOLE" = "1" ] && [ "$SYSCON" != "" ] ; then - echo "= Adding console $SYSCON to extlinux.conf ..." - sed -i "s|append|& console=$SYSCON|" /tmp/boot/extlinux/extlinux.conf + PREFIX=/tmp/root + . "${BOARDDIR}/${TARGET}" + # Add console + if [ "$CONSOLE" = "1" ] && [ "$SYSCON" != "" ] ; then + echo "= Adding console $SYSCON to extlinux.conf ..." + sed -i "s|append|& console=$SYSCON|" /tmp/boot/extlinux/extlinux.conf if [ "$TARGET" = "rpi2" ] || [ "$TARGET" = "rpi3" ]; then - mkdir /tmp/fw &> /dev/null - mount "$FIRMPART" /tmp/fw &> /dev/null - sed -i "s|# enable_uart=1|enable_uart=1|" /tmp/fw/config.txt - fi - fi + mkdir /tmp/fw &> /dev/null + mount "$FIRMPART" /tmp/fw &> /dev/null + sed -i "s|# enable_uart=1|enable_uart=1|" /tmp/fw/config.txt + fi + fi fi # fix up rpi2/3 diff --git a/rpi-firmware-update b/rpi-firmware-update old mode 100755 new mode 100644 index 6b9ebd4..ca2f396 --- a/rpi-firmware-update +++ b/rpi-firmware-update @@ -2,8 +2,8 @@ # ensure sudo user if [ "$(whoami)" != "root" ] ; then - echo "Error: This script requires 'sudo' privileges in order to write to disk & mount media." - exit 1 + echo "Error: This script requires 'sudo' privileges in order to write to disk & mount media." + exit 1 fi echo @@ -11,55 +11,55 @@ echo "= This will update U-Boot and the " echo "= Raspberry Pi Firmware to the latest." UBOOT=$(rpm -q uboot-images-armv7) if [ "$UBOOT" = "package uboot-images-armv7 is not installed" ]; then - echo - echo "$UBOOT" - read -p "Would you like to install uboot-images-armv7 (yes or no)? " INSTALL_UBOOT - if [ "$(echo ${INSTALL_UBOOT} | tr [:lower:] [:upper:])" = "YES" ] ; thee + echo + echo "$UBOOT" + read -p "Would you like to install uboot-images-armv7 (yes or no)? " INSTALL_UBOOT + if [ "$(echo ${INSTALL_UBOOT} | tr [:lower:] [:upper:])" = "YES" ] ; thee n - dnf install -y uboot-images-armv7 - UBOOT=$(rpm -q uboot-images-armv7) - fi + dnf install -y uboot-images-armv7 + UBOOT=$(rpm -q uboot-images-armv7) + fi fi FW=$(rpm -q bcm283x-firmware) if [ "$FW" = "package bcm283x-firmware is not installed" ]; then - echo - echo "$FW" - read -p "Would you like to install bcm283x-firmware (yes or no)? " INSTALL_FW - if [ "$(echo ${INSTALL_FW} | tr [:lower:] [:upper:])" = "YES" ] ; then - dnf install -y bcm283x-firmware - FW=$(rpm -q bcm283x-firmware) - fi + echo + echo "$FW" + read -p "Would you like to install bcm283x-firmware (yes or no)? " INSTALL_FW + if [ "$(echo ${INSTALL_FW} | tr [:lower:] [:upper:])" = "YES" ] ; then + dnf install -y bcm283x-firmware + FW=$(rpm -q bcm283x-firmware) + fi fi if [ "$FW" = "package bcm283x-firmware is not installed" ] && [ "$UBOOT" = "package uboot-images-armv7 is not installed" ]; then - echo - echo "Nothing to update, exiting." - exit 0 + echo + echo "Nothing to update, exiting." + exit 0 fi echo echo "= Uboot: $UBOOT" echo "= Firmware: $FW" if [ -d /boot/fw ]; then - mount /dev/mmcblk0p1 /boot/fw - else - mkdir /boot/fw - mount /dev/mmcblk0p1 /boot/fw + mount /dev/mmcblk0p1 /boot/fw + else + mkdir /boot/fw + mount /dev/mmcblk0p1 /boot/fw fi # copy uboot if [ -f /usr/share/uboot/rpi_2/u-boot.bin ]; then - cp -rp /usr/share/uboot/rpi_2/u-boot.bin /boot/fw/rpi2-u-boot.bin - else - echo "Missing U-Boot for Raspberry Pi 2, no file copied." + cp -rp /usr/share/uboot/rpi_2/u-boot.bin /boot/fw/rpi2-u-boot.bin + else + echo "Missing U-Boot for Raspberry Pi 2, no file copied." fi if [ -f /usr/share/uboot/rpi_3_32b/u-boot.bin ]; then - cp -rp /usr/share/uboot/rpi_3_32b/u-boot.bin /boot/fw/rpi3-u-boot.bin - else - echo "Missing U-Boot for Raspberry Pi 3, no file copied." + cp -rp /usr/share/uboot/rpi_3_32b/u-boot.bin /boot/fw/rpi3-u-boot.bin + else + echo "Missing U-Boot for Raspberry Pi 3, no file copied." fi # copy fw if [ -d /usr/share/bcm283x-firmware ]; then - cp -rfp /usr/share/bcm283x-firmware/*.{bin,dat,elf} /boot/fw/ + cp -rfp /usr/share/bcm283x-firmware/*.{bin,dat,elf} /boot/fw/ else - echo "Missing bcm283x-firmware, no files copied." + echo "Missing bcm283x-firmware, no files copied." fi umount /boot/fw echo diff --git a/update-uboot b/update-uboot old mode 100755 new mode 100644 index 1320a7c..4514b5b --- a/update-uboot +++ b/update-uboot @@ -22,100 +22,100 @@ For list of supported boards please check SUPPORTED-BOARDS file. # check the args while [ $# -gt 0 ]; do - case $1 in - --debug) - set -x - ;; - -h|--help) - usage - ;; - --target*) - if echo $1 | grep '=' >/dev/null ; then - TARGET=$(echo $1 | sed 's/^--target=//') - else - TARGET=$2 - shift - fi - ;; - --media*) - if echo $1 | grep '=' >/dev/null ; then - MEDIA=$(echo $1 | sed 's/^--media=//') - else - MEDIA=$2 - shift - fi - ;; - --tag*) - if echo $1 | grep '=' >/dev/null ; then - KOJI_TAG=$(echo $1 | sed 's/^--tag=//') - else - KOJI_TAG=$2 - shift - fi - ;; - *) - echo "$(basename ${0}): Error - ${1}" - usage - exit 1 - ;; - esac - shift + case $1 in + --debug) + set -x + ;; + -h|--help) + usage + ;; + --target*) + if echo $1 | grep '=' >/dev/null ; then + TARGET=$(echo $1 | sed 's/^--target=//') + else + TARGET=$2 + shift + fi + ;; + --media*) + if echo $1 | grep '=' >/dev/null ; then + MEDIA=$(echo $1 | sed 's/^--media=//') + else + MEDIA=$2 + shift + fi + ;; + --tag*) + if echo $1 | grep '=' >/dev/null ; then + KOJI_TAG=$(echo $1 | sed 's/^--tag=//') + else + KOJI_TAG=$2 + shift + fi + ;; + *) + echo "$(basename ${0}): Error - ${1}" + usage + exit 1 + ;; + esac + shift done if [ -d "/usr/share/arm-image-installer/boards.d" ]; then - BOARDDIR="/usr/share/arm-image-installer/boards.d" + BOARDDIR="/usr/share/arm-image-installer/boards.d" else - DIR=$(dirname $0) - BOARDDIR="${DIR}/boards.d" + DIR=$(dirname $0) + BOARDDIR="${DIR}/boards.d" fi # ensure sudo user if [ "$(whoami)" != "root" ] ; then - echo "Error: This script requires 'sudo' privileges in order to write to disk & mount media." - exit 1 + echo "Error: This script requires 'sudo' privileges in order to write to disk & mount media." + exit 1 fi # check if media exists if [[ ! -e $MEDIA ]] ; then - echo "Missing media" - usage - exit 1 + echo "Missing media" + usage + exit 1 fi if [[ $TARGET = '' ]] ; then - echo "Missing target" - usage - exit 1 + echo "Missing target" + usage + exit 1 fi if [[ $KOJI_TAG != '' ]] ; then - if [[ ! -f /usr/bin/koji ]]; then - echo "Please install koji-utils for this option." - exit 1 - else - PREFIX='/tmp/root/' - rm -rf /tmp/root &> /dev/null - mkdir $PREFIX + if [[ ! -f /usr/bin/koji ]]; then + echo "Please install koji-utils for this option." + exit 1 + else + PREFIX='/tmp/root/' + rm -rf /tmp/root &> /dev/null + mkdir $PREFIX - #get the latest uboot - pushd $PREFIX &> /dev/null - if [ $KOJI_TAG = f22 ]; then - koji download-build --arch=armv7hl --latestfrom=$KOJI_TAG uboot-tools - else - koji download-build --arch=noarch --latestfrom=$KOJI_TAG uboot-tools - fi - # unpack uboot - for rpm in uboot-images*.rpm - do - rpm2cpio "${rpm}" | cpio -idv &> /dev/null - done - popd &> /dev/null - fi + #get the latest uboot + pushd $PREFIX &> /dev/null + if [ $KOJI_TAG = f22 ]; then + koji download-build --arch=armv7hl --latestfrom=$KOJI_TAG uboot-tools + else + koji download-build --arch=noarch --latestfrom=$KOJI_TAG uboot-tools + fi + # unpack uboot + for rpm in uboot-images*.rpm + do + rpm2cpio "${rpm}" | cpio -idv &> /dev/null + done + popd &> /dev/null + fi fi # determine uboot and write to disk if [ "$TARGET" = "" ]; then - echo "= No U-boot will be written." - TARGET="Mystery Board" + echo "= No U-boot will be written." + TARGET="Mystery Board" else - . "${DIR}/${BOARDDIR}/${TARGET}" + . "${DIR}/${BOARDDIR}/${TARGET}" fi echo "= Complete!" From 80dca82e02665e56913588317c11201486fa8099 Mon Sep 17 00:00:00 2001 From: Tomasz Kłoczko Date: Nov 04 2017 09:58:25 +0000 Subject: [PATCH 3/9] - fixed if []; then syntax and few other cleanups. --- diff --git a/rpi-firmware-update b/rpi-firmware-update index ca2f396..8961698 100644 --- a/rpi-firmware-update +++ b/rpi-firmware-update @@ -14,10 +14,9 @@ if [ "$UBOOT" = "package uboot-images-armv7 is not installed" ]; then echo echo "$UBOOT" read -p "Would you like to install uboot-images-armv7 (yes or no)? " INSTALL_UBOOT - if [ "$(echo ${INSTALL_UBOOT} | tr [:lower:] [:upper:])" = "YES" ] ; thee -n - dnf install -y uboot-images-armv7 - UBOOT=$(rpm -q uboot-images-armv7) + if [ "$(echo ${INSTALL_UBOOT} | tr [:lower:] [:upper:])" = "YES" ] ; then + dnf install -y uboot-images-armv7 + UBOOT=$(rpm -q uboot-images-armv7) fi fi FW=$(rpm -q bcm283x-firmware) @@ -39,10 +38,10 @@ echo echo "= Uboot: $UBOOT" echo "= Firmware: $FW" if [ -d /boot/fw ]; then - mount /dev/mmcblk0p1 /boot/fw - else - mkdir /boot/fw - mount /dev/mmcblk0p1 /boot/fw + mount /dev/mmcblk0p1 /boot/fw +else + mkdir /boot/fw + mount /dev/mmcblk0p1 /boot/fw fi # copy uboot if [ -f /usr/share/uboot/rpi_2/u-boot.bin ]; then @@ -65,4 +64,3 @@ umount /boot/fw echo echo "== Complete!" echo - From 6b6425a28372c0e8cc5a922ea5ef9332f61d204f Mon Sep 17 00:00:00 2001 From: Tomasz Kłoczko Date: Nov 04 2017 09:59:10 +0000 Subject: [PATCH 4/9] - cleanups. --- diff --git a/arm-image-installer b/arm-image-installer index 0aa5d5d..381db54 100644 --- a/arm-image-installer +++ b/arm-image-installer @@ -124,14 +124,13 @@ while [ $# -gt 0 ]; do done contains() { - string="$1" - substring="$2" - if test "${string#*$substring}" != "$string" - then - return 0 # $substring is in $string - else - return 1 # $substring is not in $string - fi + string="$1" + substring="$2" + if test "${string#*$substring}" != "$string"; then + return 0 # $substring is in $string + else + return 1 # $substring is not in $string + fi } # ensure sudo user @@ -172,7 +171,7 @@ fi clear # Last chance to back out -echo " " +echo "" echo "=====================================================" # Image if included if [ "$IMAGE" != "" ] ; then @@ -275,14 +274,12 @@ if [ "$RESIZEFS" != "" ] ; then sleep 5 echo ", +" | sfdisk -N "$PARTNUM" "$MEDIA" count=$((count+1)) - if [ $count -gt 5 ] - then - echo "= Partition Resize Failed." - continue + if [ $count -gt 5 ]; then + echo "= Partition Resize Failed." + continue fi - done - + partprobe "$MEDIA" FS_TYPE=$(file -s "$ROOTPART" | awk '{print $3}') From 897cc8008ab5011aa029241fbec6083b64c48232 Mon Sep 17 00:00:00 2001 From: Tomasz Kłoczko Date: Nov 04 2017 10:01:57 +0000 Subject: [PATCH 5/9] - use everywhere the same if []; then syntax ('s/] ; then/]; then/) --- diff --git a/arm-image-installer b/arm-image-installer index 381db54..9399e35 100644 --- a/arm-image-installer +++ b/arm-image-installer @@ -134,13 +134,13 @@ contains() { } # ensure sudo user -if [ "$(whoami)" != "root" ] ; then +if [ "$(whoami)" != "root" ]; then echo "Error: This script requires 'sudo' privileges in order to write to disk & mount media." exit 1 fi # check to make sure populated -if [ "$MEDIA" = "" ] ; then +if [ "$MEDIA" = "" ]; then usage exit 1 fi @@ -151,20 +151,20 @@ if [ "$TARGET" = "cubietruck" ]; then fi # check for boards -if [ "$TARGET" != "" -a ! -e "${BOARDDIR}/${TARGET}" ] ; then +if [ "$TARGET" != "" -a ! -e "${BOARDDIR}/${TARGET}" ]; then echo "Error: You must choose a supported board or none at all." usage exit 1 fi # image exists -if [ ! -f "$IMAGE" ] && [ "$IMAGE" != "" ] ; then +if [ ! -f "$IMAGE" ] && [ "$IMAGE" != "" ]; then echo "Error: $IMAGE not found! Please choose an existing image." exit 1 fi # device exists -if [ ! -e "$MEDIA" ] ; then +if [ ! -e "$MEDIA" ]; then echo "Error: $MEDIA not found! Please choose an existing device." exit 1 fi @@ -174,33 +174,33 @@ clear echo "" echo "=====================================================" # Image if included -if [ "$IMAGE" != "" ] ; then +if [ "$IMAGE" != "" ]; then echo "= Selected Image: " echo "= $IMAGE" fi echo "= Selected Media : $MEDIA" # target hardware platform -if [ "$TARGET" != "" ] ; then +if [ "$TARGET" != "" ]; then echo "= U-Boot Target : $TARGET" fi # SE Linux On/Off -if [ "$SELINUX" != "" ] ; then +if [ "$SELINUX" != "" ]; then echo "= SELINUX = $SELINUX" fi # Remove root password -if [ "$NOROOTPASS" != "" ] ; then +if [ "$NOROOTPASS" != "" ]; then echo "= Root Password will be removed." fi # Resize root filesystem to fill media device -if [ "$RESIZEFS" != "" ] ; then +if [ "$RESIZEFS" != "" ]; then echo "= Root partition will be resized" fi # Console to be added -if [ "$CONSOLE" != "" ] ; then +if [ "$CONSOLE" != "" ]; then echo "= Console for $TARGET will be added." fi # User ssh key -if [ "$SSH_KEY" != "" ] ; then +if [ "$SSH_KEY" != "" ]; then echo "= SSH Public Key $SSH_KEY will be added." fi echo "=====================================================" @@ -210,13 +210,13 @@ echo "*****************************************************" echo "******** WARNING! ALL DATA WILL BE DESTROYED ********" echo "*****************************************************" echo "*****************************************************" -if [ "$NOASK" != 1 ] ; then +if [ "$NOASK" != 1 ]; then echo " " echo " Type 'YES' to proceed, anything else to exit now " echo " " # wait for agreement read -p "= Proceed? " PROCEED - if [ "$(echo ${PROCEED} | tr [:lower:] [:upper:])" != "YES" ] ; then + if [ "$(echo ${PROCEED} | tr [:lower:] [:upper:])" != "YES" ]; then echo "User exit, no image written." exit 0 fi @@ -225,7 +225,7 @@ fi umount $MEDIA* &> /dev/null # Write the disk image to media -if [ "$IMAGE" != "" ] ; then +if [ "$IMAGE" != "" ]; then echo "= Writing: " echo "= $IMAGE " echo "= To: $MEDIA ...." @@ -265,7 +265,7 @@ case $MEDIA in esac # resize root filesystem before mounting -if [ "$RESIZEFS" != "" ] ; then +if [ "$RESIZEFS" != "" ]; then echo "= Resizing $MEDIA ...." sync count=0 @@ -310,23 +310,23 @@ if [ $? -ne 0 ]; then fi # turn off selinux -if [ "$SELINUX" != "" ] ; then - if [ "$(echo ${SELINUX} | tr [:lower:] [:upper:])" = "OFF" ] ; then +if [ "$SELINUX" != "" ]; then + if [ "$(echo ${SELINUX} | tr [:lower:] [:upper:])" = "OFF" ]; then echo "= Turning SELinux off ..." sed -i 's/append/& enforcing=0/' /tmp/boot/extlinux/extlinux.conf # turn on selinux - elif [ "$(echo ${SELINUX} | tr [:lower:] [:upper:])" = "ON" ] ; then + elif [ "$(echo ${SELINUX} | tr [:lower:] [:upper:])" = "ON" ]; then echo "= Turning SELinux on ..." sed -i 's/ enforcing=0//' /tmp/boot/extlinux/extlinux.conf fi fi # Remove root password -if [ "$NOROOTPASS" = "1" ] ; then +if [ "$NOROOTPASS" = "1" ]; then echo "= Removing the root password." sed -i 's/root:x:/root::/' /tmp/root/etc/passwd fi # Add ssh key to the image -if [ "$SSH_KEY" != "" ] ; then +if [ "$SSH_KEY" != "" ]; then if [ -f $SSH_KEY ]; then echo "= Adding SSH key to authorized keys." mkdir /tmp/root/root/.ssh/ &> /dev/null @@ -346,7 +346,7 @@ else PREFIX=/tmp/root . "${BOARDDIR}/${TARGET}" # Add console - if [ "$CONSOLE" = "1" ] && [ "$SYSCON" != "" ] ; then + if [ "$CONSOLE" = "1" ] && [ "$SYSCON" != "" ]; then echo "= Adding console $SYSCON to extlinux.conf ..." sed -i "s|append|& console=$SYSCON|" /tmp/boot/extlinux/extlinux.conf if [ "$TARGET" = "rpi2" ] || [ "$TARGET" = "rpi3" ]; then @@ -358,7 +358,7 @@ else fi # fix up rpi2/3 -if [ "$FIX_RPI" != "" ] ; then +if [ "$FIX_RPI" != "" ]; then echo "= Blacklisting the VC4 Driver for the Raspberry Pi 2/3" echo blacklist vc4 > /tmp/root/etc/modprobe.d/blacklist-vc4.conf sed -i 's/append/& rd.driver.blacklist=vc4/' /tmp/boot/extlinux/extlinux.conf diff --git a/rpi-firmware-update b/rpi-firmware-update index 8961698..c2679cf 100644 --- a/rpi-firmware-update +++ b/rpi-firmware-update @@ -1,7 +1,7 @@ #!/bin/bash # ensure sudo user -if [ "$(whoami)" != "root" ] ; then +if [ "$(whoami)" != "root" ]; then echo "Error: This script requires 'sudo' privileges in order to write to disk & mount media." exit 1 fi @@ -14,7 +14,7 @@ if [ "$UBOOT" = "package uboot-images-armv7 is not installed" ]; then echo echo "$UBOOT" read -p "Would you like to install uboot-images-armv7 (yes or no)? " INSTALL_UBOOT - if [ "$(echo ${INSTALL_UBOOT} | tr [:lower:] [:upper:])" = "YES" ] ; then + if [ "$(echo ${INSTALL_UBOOT} | tr [:lower:] [:upper:])" = "YES" ]; then dnf install -y uboot-images-armv7 UBOOT=$(rpm -q uboot-images-armv7) fi @@ -24,7 +24,7 @@ if [ "$FW" = "package bcm283x-firmware is not installed" ]; then echo echo "$FW" read -p "Would you like to install bcm283x-firmware (yes or no)? " INSTALL_FW - if [ "$(echo ${INSTALL_FW} | tr [:lower:] [:upper:])" = "YES" ] ; then + if [ "$(echo ${INSTALL_FW} | tr [:lower:] [:upper:])" = "YES" ]; then dnf install -y bcm283x-firmware FW=$(rpm -q bcm283x-firmware) fi diff --git a/update-uboot b/update-uboot index 4514b5b..14c8696 100644 --- a/update-uboot +++ b/update-uboot @@ -69,24 +69,24 @@ else BOARDDIR="${DIR}/boards.d" fi # ensure sudo user -if [ "$(whoami)" != "root" ] ; then +if [ "$(whoami)" != "root" ]; then echo "Error: This script requires 'sudo' privileges in order to write to disk & mount media." exit 1 fi # check if media exists -if [[ ! -e $MEDIA ]] ; then +if [[ ! -e $MEDIA ]]; then echo "Missing media" usage exit 1 fi -if [[ $TARGET = '' ]] ; then +if [[ $TARGET = '' ]]; then echo "Missing target" usage exit 1 fi -if [[ $KOJI_TAG != '' ]] ; then +if [[ $KOJI_TAG != '' ]]; then if [[ ! -f /usr/bin/koji ]]; then echo "Please install koji-utils for this option." exit 1 From ac90743fe0ecb9cd5fea394c75cf2d51f84136ce Mon Sep 17 00:00:00 2001 From: Tomasz Kłoczko Date: Nov 04 2017 10:06:20 +0000 Subject: [PATCH 6/9] - add use more tabs in usage() and sort alphabetically options. --- diff --git a/arm-image-installer b/arm-image-installer index 9399e35..cc735c3 100644 --- a/arm-image-installer +++ b/arm-image-installer @@ -12,20 +12,19 @@ usage() { echo " Usage: $(basename ${0}) - --image=IMAGE - xz compressed image file name - --target=TARGET - target board - --media=DEVICE - media device file (/dev/[sdX|mmcblkX]) - --norootpass - Remove the root password - -y - Assumes yes, will not wait for confirmation - --version - Display version and exit - --resizefs - Resize root filesystem to fill media device - --addconsole - Add system console to extlinux.conf - --addkey= - /path/to/ssh-public-key - --supported - List of supported hardware + --addconsole - Add system console to extlinux.conf + --addkey= - /path/to/ssh-public-key + --image=IMAGE - xz compressed image file name + --media=DEVICE - media device file (/dev/[sdX|mmcblkX]) + --norootpass - Remove the root password + --resizefs - Resize root filesystem to fill media device + --supported - List of supported hardware + --target=TARGET - target board + --version - Display version and exit + -y - Assumes yes, will not wait for confirmation Example: $(basename ${0}) --image=Fedora-Rawhide.xz --target=Bananapi --media=/dev/mmcblk0 - " } diff --git a/update-uboot b/update-uboot index 14c8696..0104fdb 100644 --- a/update-uboot +++ b/update-uboot @@ -10,9 +10,9 @@ usage() { echo " Usage: $(basename ${0}) - --target=TARGET - target board - --media=DEVICE - media device file (/dev/[sdX|mmcblkX]) - --tag=KOJI TAG - koji tag to download build + --media=DEVICE - media device file (/dev/[sdX|mmcblkX]) + --tag=KOJI TAG - koji tag to download build + --target=TARGET - target board Example: $(basename ${0}) --target=panda --media=/dev/mmcblk0 From 122638dc49001575b6838e41f216830ef3ce2611 Mon Sep 17 00:00:00 2001 From: Tomasz Kłoczko Date: Nov 04 2017 10:07:52 +0000 Subject: [PATCH 7/9] - looks like aarch64 support is now done. --- diff --git a/TODO b/TODO index c5a4937..c969759 100644 --- a/TODO +++ b/TODO @@ -10,5 +10,4 @@ just ideas that might, or might not work. - Duplicating a currently running system from a SD card to an onboard eMMC - Dynamic list of devices supported based on available u-boot firmwares and/or known means of writing out SoC options - Support writing images with hosts that support uEFI -- Support for aarch64 devices - Support writing u-boot to NAND devices like C.H.I.P. From 42d7e7c476f5d1bc80731c6558a3a13f60bf70b7 Mon Sep 17 00:00:00 2001 From: Tomasz Kłoczko Date: Nov 04 2017 10:30:42 +0000 Subject: [PATCH 8/9] - update usage output of the scripts. --- diff --git a/README b/README index f9b8661..7f52e65 100644 --- a/README +++ b/README @@ -19,14 +19,16 @@ needed to write U-Boot for the target board. Usage: arm-image-installer - --image=IMAGE - xz compressed image file name - --target=TARGET - target board - [Bananapi|beaglebone|Cubieboard|Cubieboard2|Cubietruck|Mele_A1000|Mele_A1000G|panda|trimslice|wandboard_dual|wandboard_quad|wandboard_solo] - --media=DEVICE - media device file (/dev/[sdX|mmcblkX]) - --selinux=ON/OFF - Turn SELinux off/on as needed - --norootpass - Remove the root password - -y - Assumes yes, will not wait for confirmation - --version - Display version and exit + --addconsole - Add system console to extlinux.conf + --addkey= - /path/to/ssh-public-key + --image=IMAGE - xz compressed image file name + --media=DEVICE - media device file (/dev/[sdX|mmcblkX]) + --norootpass - Remove the root password + --resizefs - Resize root filesystem to fill media device + --supported - List of supported hardware + --target=TARGET - target board + --version - Display version and exit + -y - Assumes yes, will not wait for confirmation Example: arm-image-installer --image=Fedora-Rawhide.xz --target=panda --media=/dev/mmcblk0 --selinux=OFF @@ -38,10 +40,8 @@ newer u-boot from koji by specifying a koji tag. Usage: update-uboot - --target=TARGET - target board - [Bananapi|beaglebone|Cubieboard|Cubieboard2|Cubietruck|Mele_A1000|Mele_A1000G|panda|trimslice|wandboard_dual|wandboard_quad|wandboard_solo] - --media=DEVICE - media device file (/dev/[sdX|mmcblkX]) - --tag=KOJI TAG - koji tag (Default is f22. f21, f21-updates etc..) + --media=DEVICE - media device file (/dev/[sdX|mmcblkX]) + --tag=KOJI TAG - koji tag to download build + --target=TARGET - target board Example: update-uboot --target=panda --media=/dev/mmcblk0 - From 9eca0baab84f22652b352ac47a610bc5c1c994f8 Mon Sep 17 00:00:00 2001 From: Tomasz Kłoczko Date: Nov 05 2017 06:08:00 +0000 Subject: [PATCH 9/9] - changed from /bin/bash to /bin/sh as long as nothing in scripts uses bash specyfic syntax. --- diff --git a/arm-image-installer b/arm-image-installer old mode 100644 new mode 100755 index cc735c3..ee3ab1c --- a/arm-image-installer +++ b/arm-image-installer @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Copyright (C) 2014-2015 Red Hat Inc. # SPDX-License-Identifier: GPL-2.0+ diff --git a/rpi-firmware-update b/rpi-firmware-update old mode 100644 new mode 100755 index c2679cf..e1f43f2 --- a/rpi-firmware-update +++ b/rpi-firmware-update @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # ensure sudo user if [ "$(whoami)" != "root" ]; then diff --git a/update-uboot b/update-uboot old mode 100644 new mode 100755 index 0104fdb..7cd396c --- a/update-uboot +++ b/update-uboot @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Copyright (C) 2013 Red Hat Inc. # SPDX-License-Identifier: GPL-2.0+