08-15-2017, 07:34 PM
(This post was last modified: 08-15-2017, 07:47 PM by MarkHaysHarris777.)
Greetings,
The purpose of this post is to make available as quickly as possible the Rock64 Linux Image Writing Scripts ( codes and tutorials ) as well giving theory and instructions for their use.
Both of the scripts presented her derive directly, and were ported from, ayufan's "Pinebook to eMMC" script and perform the same function, yet over the Rock64 repos ( the arm64 primary images ).
Theory
Place these scripts ( as well the "curl" and "jq" packages ) on your gnu+linux system and use them to download and write the desired image from the network repos directly to the SD card ; or even to the eMMC module using an adapter ! In addition the scripts may be placed on your bootable SD card in preparation for using the jumper setting technique for writing a network repo image directly to the eMMC memory module. The flexibility is your own choice. I have pushed the script(s) as a github PR, and eventually they will be included in the images automatically.
The Scripts
rock64_install_to_emmc.sh
rock64_install_to_SD.sh
Instructions for Use:
Be sure to make both scripts executable as always with :
chmod 0754 rock64_install_to_SD.sh
Both of the above scripts function the same way and have some very subtle differences, but generally have the same theory of operation; the user selects a system image and version -- the script then finds the latest ( not pre release ) build, verifies it, and then downloads it from the network repos directly to the SD card, or even to the eMMC module via an adapter.
Sample syntax of the command is :
sudo ./rock64_install_to_SD.sh xenial-mate 0.4.16
sudo ./rock64_install_to_SD.sh xenial-minimal
If the version number is omitted then the script will find the latest ( not pre release ) build release! The three primary arm64 versions are supported with this script: xenial-mate | xenial-i3 | xenial-minimal
The scripts differ mostly in their error checking, and where they write; the SD.sh script writes to /dev/mmcblk0 while the emmc.sh script writes to mmcblk1. The emmc.sh script makes sure that you're booted on the SD card first ! (very important for writing to the eMMC on the same system). Otherwise, the two scripts are mostly identical and perform the same function.
The SD.sh script may be also used to write to the eMMC module if the module is placed into an adapter for use with the PC gnu+linux system. The benefits of these scripts is two fold: 1) they are very fast with no intermediary step, and 2) the SD or eMMC is written to without having to play around with dd or Etcher ( or some other ) as well the syntax checking and command parsing is completely automatic ; all the user has to know is the system and the version.
I have tested both of these scripts within reason and have found that they are functional and useful; if the scripts are placed on your bootable SD card ( for writing to the eMMC module on-board with the jumper technique ) then they become very powerful for downloading and installing the desired image directly to the eMMC module from the network repos. This is the very same technique that is used on the Pinebook to write images to its on-board eMMC module.
The Rock64 eMMC tutorial will be updated with this information.
As with any derived work, I have left ayufan's name attached due to respect, as well copyright and dignity of propriety; however, any errors are mine alone and I am responsible to correct any errors that might be found, quickly.
The purpose of this post is to make available as quickly as possible the Rock64 Linux Image Writing Scripts ( codes and tutorials ) as well giving theory and instructions for their use.
Both of the scripts presented her derive directly, and were ported from, ayufan's "Pinebook to eMMC" script and perform the same function, yet over the Rock64 repos ( the arm64 primary images ).
Theory
Place these scripts ( as well the "curl" and "jq" packages ) on your gnu+linux system and use them to download and write the desired image from the network repos directly to the SD card ; or even to the eMMC module using an adapter ! In addition the scripts may be placed on your bootable SD card in preparation for using the jumper setting technique for writing a network repo image directly to the eMMC memory module. The flexibility is your own choice. I have pushed the script(s) as a github PR, and eventually they will be included in the images automatically.
The Scripts
rock64_install_to_emmc.sh
Code:
#!/bin/bash
set -eo pipefail
if [[ "$(id -u)" -ne "0" ]]; then
echo "This script requires root."
exit 1
fi
echo "Rock64 Release Installer!"
echo "(C) 2017. Kamil Trzciński (https://ayufan.eu)."
echo ""
usage() {
echo "Usage:"
echo "$ $0 <system> [version]"
echo ""
echo "Systems:"
echo " - xenial-minimal (https://github.com/ayufan-rock64/linux-build/releases)"
echo " - xenial-mate (https://github.com/ayufan-rock64/linux-build/releases)"
echo " - xenial-i3 (https://github.com/ayufan-rock64/linux-build/releases)"
echo ""
echo "Version:"
echo " - latest will be used if version is not defined"
exit 1
}
if [[ $# -ne 1 ]] && [[ $# -ne 2 ]]; then
usage
fi
if [[ ! -d /sys/devices/soc.0/1c10000.sdmmc/mmc_host/mmc1 ]]; then
echo "You should boot from SD card"
exit 1
fi
if [[ ! -e /dev/mmcblk1 ]]; then
echo "You should boot from SD card"
exit 1
fi
case "$1" in
xenial-minimal|xenial-mate|xenial-i3)
REPO="ayufan-rock64/linux-build"
PREFIX="$1-rock64-"
SUFFIX="-[0-9]*-arm64.img.xz"
ARCHIVER="xz -d"
;;
*)
echo "Unknown system: $1"
echo ""
usage
;;
esac
VERSION="$2"
if [[ -z "$VERSION" ]]; then
VERSION=$(curl -f -sS https://api.github.com/repos/$REPO/releases/latest | jq -r ".tag_name")
if [ -z "$VERSION" ]; then
echo "Latest release was not for $1."
echo "Please go to: https://github.com/$REPO/releases/latest"
exit 1
fi
echo "Using latest release: $VERSION from https://github.com/$REPO/releases."
fi
NAME="$PREFIX$VERSION$SUFFIX"
NAME_SAFE="${NAME//./\\.}"
VERSION_SAFE="${VERSION//./\\.}"
echo "Looking for download URL..."
DOWNLOAD_URL=$(curl -f -sS https://api.github.com/repos/$REPO/releases | \
jq -r ".[].assets | .[].browser_download_url" | \
( grep -o "https://github\.com/$REPO/releases/download/$VERSION_SAFE/$NAME_SAFE" || true))
if [[ -z "$DOWNLOAD_URL" ]]; then
echo "The download URL for $NAME not found".
echo "Look at https://github.com/$REPO/releases for correct versions."
exit 1
fi
echo "Doing this will overwrite all data stored on eMMC."
while true; do
echo "Type YES to continue or Ctrl-C to abort."
read CONFIRM
if [[ "$CONFIRM" == "YES" ]]; then
break
fi
done
echo ""
echo "Using $DOWNLOAD_URL..."
echo "Umounting..."
umount -f /dev/mmcblk1* || true
echo ""
echo "Downloading and writing to /dev/mmcblk1..."
curl -L -f "$DOWNLOAD_URL" | $ARCHIVER | dd bs=30M of=/dev/mmcblk1
sync
echo ""
echo "Done."
rock64_install_to_SD.sh
Code:
#!/bin/bash
set -eo pipefail
if [[ "$(id -u)" -ne "0" ]]; then
echo "This script requires root."
exit 1
fi
echo "Rock64 Release Installer!"
echo "(C) 2017. Kamil Trzciński (https://ayufan.eu)."
echo ""
usage() {
echo "Usage:"
echo "$ $0 <system> [version]"
echo ""
echo "Systems:"
echo " - xenial-minimal (https://github.com/ayufan-rock64/linux-build/releases)"
echo " - xenial-mate (https://github.com/ayufan-rock64/linux-build/releases)"
echo " - xenial-i3 (https://github.com/ayufan-rock64/linux-build/releases)"
echo ""
echo "Version:"
echo " - latest will be used if version is not defined"
exit 1
}
if [[ $# -ne 1 ]] && [[ $# -ne 2 ]]; then
usage
fi
#if [[ ! -d /sys/devices/soc.0/1c10000.sdmmc/mmc_host/mmc1 ]]; then
# echo "You should boot from SD card"
# exit 1
#fi
#if [[ ! -e /dev/mmcblk0 ]]; then
# echo "You should boot from SD card"
# exit 1
#fi
case "$1" in
xenial-minimal|xenial-mate|xenial-i3)
REPO="ayufan-rock64/linux-build"
PREFIX="$1-rock64-"
SUFFIX="-[0-9]*-arm64.img.xz"
ARCHIVER="xz -d"
;;
*)
echo "Unknown system: $1"
echo ""
usage
;;
esac
VERSION="$2"
if [[ -z "$VERSION" ]]; then
VERSION=$(curl -f -sS https://api.github.com/repos/$REPO/releases/latest | jq -r ".tag_name")
if [ -z "$VERSION" ]; then
echo "Latest release was not for $1."
echo "Please go to: https://github.com/$REPO/releases/latest"
exit 1
fi
echo "Using latest release: $VERSION from https://github.com/$REPO/releases."
fi
NAME="$PREFIX$VERSION$SUFFIX"
NAME_SAFE="${NAME//./\\.}"
VERSION_SAFE="${VERSION//./\\.}"
echo "Looking for download URL..."
DOWNLOAD_URL=$(curl -f -sS https://api.github.com/repos/$REPO/releases | \
jq -r ".[].assets | .[].browser_download_url" | \
( grep -o "https://github\.com/$REPO/releases/download/$VERSION_SAFE/$NAME_SAFE" || true))
if [[ -z "$DOWNLOAD_URL" ]]; then
echo "The download URL for $NAME not found".
echo "Look at https://github.com/$REPO/releases for correct versions."
exit 1
fi
echo "Doing this will overwrite all data stored on eMMC."
while true; do
echo "Type YES to continue or Ctrl-C to abort."
read CONFIRM
if [[ "$CONFIRM" == "YES" ]]; then
break
fi
done
echo ""
echo "Using $DOWNLOAD_URL..."
echo "Umounting..."
umount -f /dev/mmcblk0* || true
echo ""
echo "Downloading and writing to /dev/mmcblk0..."
curl -L -f "$DOWNLOAD_URL" | $ARCHIVER | dd bs=30M of=/dev/mmcblk0
sync
echo ""
echo "Done."
Instructions for Use:
Be sure to make both scripts executable as always with :
chmod 0754 rock64_install_to_SD.sh
Both of the above scripts function the same way and have some very subtle differences, but generally have the same theory of operation; the user selects a system image and version -- the script then finds the latest ( not pre release ) build, verifies it, and then downloads it from the network repos directly to the SD card, or even to the eMMC module via an adapter.
Sample syntax of the command is :
sudo ./rock64_install_to_SD.sh xenial-mate 0.4.16
sudo ./rock64_install_to_SD.sh xenial-minimal
If the version number is omitted then the script will find the latest ( not pre release ) build release! The three primary arm64 versions are supported with this script: xenial-mate | xenial-i3 | xenial-minimal
The scripts differ mostly in their error checking, and where they write; the SD.sh script writes to /dev/mmcblk0 while the emmc.sh script writes to mmcblk1. The emmc.sh script makes sure that you're booted on the SD card first ! (very important for writing to the eMMC on the same system). Otherwise, the two scripts are mostly identical and perform the same function.
The SD.sh script may be also used to write to the eMMC module if the module is placed into an adapter for use with the PC gnu+linux system. The benefits of these scripts is two fold: 1) they are very fast with no intermediary step, and 2) the SD or eMMC is written to without having to play around with dd or Etcher ( or some other ) as well the syntax checking and command parsing is completely automatic ; all the user has to know is the system and the version.
I have tested both of these scripts within reason and have found that they are functional and useful; if the scripts are placed on your bootable SD card ( for writing to the eMMC module on-board with the jumper technique ) then they become very powerful for downloading and installing the desired image directly to the eMMC module from the network repos. This is the very same technique that is used on the Pinebook to write images to its on-board eMMC module.
The Rock64 eMMC tutorial will be updated with this information.
As with any derived work, I have left ayufan's name attached due to respect, as well copyright and dignity of propriety; however, any errors are mine alone and I am responsible to correct any errors that might be found, quickly.
marcushh777
please join us for a chat @ irc.pine64.xyz:6667 or ssl irc.pine64.xyz:6697
( I regret that I am not able to respond to personal messages; let's meet on irc! )
please join us for a chat @ irc.pine64.xyz:6667 or ssl irc.pine64.xyz:6697
( I regret that I am not able to respond to personal messages; let's meet on irc! )