| data/qi_lb60/scripts/build |
| 1 | #!/bin/bash |
| 2 | |
| 3 | BASE_DIR="xburst" |
| 4 | |
| 5 | LOG="${BASE_DIR}/LOG" |
| 6 | |
| 7 | BUILD_LOG="${BASE_DIR}/BUILD_LOG" |
| 8 | |
| 9 | DATE=$(date "+%Y-%m-%d") |
| 10 | TIME=$(date "+%H-%M-%S") |
| 11 | DATE_TIME="${DATE}_${TIME}" |
| 12 | |
| 13 | FEEDS_CONF="feeds.conf.default" |
| 14 | test -f "feeds.conf" && FEEDS_CONF="feeds.conf" |
| 15 | |
| 16 | if [ "${0}" != "./scripts/build" ]; then |
| 17 | echo "Please call me that way: ./scripts/build" |
| 18 | echo " - out of the main directory" |
| 19 | exit 1 |
| 20 | fi |
| 21 | |
| 22 | if [ ! -f ".config" ]; then |
| 23 | echo "OpenWrt didn't get configured yet." |
| 24 | exit 1 |
| 25 | fi |
| 26 | |
| 27 | if [ -f "config" ]; then |
| 28 | echo "file <config> exists." |
| 29 | echo "That means normally, a previous build failed" |
| 30 | echo "Please examine the situation" |
| 31 | exit 1 |
| 32 | fi |
| 33 | |
| 34 | echo "This script will move previous builds to bak/!" |
| 35 | echo "This script will compile base on last commit" |
| 36 | echo " your modifications will backup by git stash" |
| 37 | echo " those modifications will apply again after compile" |
| 38 | echo "This script comes without any kind of warranty!" |
| 39 | echo " " |
| 40 | echo "Are you brave, dude? [NO/yes]" |
| 41 | |
| 42 | read brave |
| 43 | |
| 44 | echo " " |
| 45 | |
| 46 | if [ "${brave}" != "yes" ]; then |
| 47 | exit 1 |
| 48 | fi |
| 49 | |
| 50 | echo "cleaning up toolchain..." |
| 51 | mkdir bak 2>/dev/null |
| 52 | BAK="build_dir staging_dir tmp bin .config.old feeds xburst config" |
| 53 | for bak in $BAK; do |
| 54 | mv "${bak}" "bak/${bak}_${DATE_TIME}" 2> /dev/null && echo "backed up <${bak}>" |
| 55 | done |
| 56 | rm -rf package/feeds/* |
| 57 | |
| 58 | mv .config config |
| 59 | mkdir xburst |
| 60 | |
| 61 | echo "updating git repo..." |
| 62 | git stash |
| 63 | git checkout tracking_backfire |
| 64 | git pull > /dev/null |
| 65 | if [ "$?" != "0" ]; then |
| 66 | echo "ERROR: updating openwrt-xburst failed" |
| 67 | exit 1 |
| 68 | fi |
| 69 | |
| 70 | echo "updating feeds..." |
| 71 | scripts/feeds update -a > /dev/null 2>&1 |
| 72 | if [ "$?" != "0" ]; then |
| 73 | echo "ERROR: updating feeds failed" |
| 74 | exit 1 |
| 75 | fi |
| 76 | echo "installing feeds..." |
| 77 | scripts/feeds install -a > /dev/null 2>&1 |
| 78 | if [ "$?" != "0" ]; then |
| 79 | echo "ERROR: installing feeds failed" |
| 80 | exit 1 |
| 81 | fi |
| 82 | |
| 83 | echo "getting version numbers of used repositories..." |
| 84 | feeds="$(cat "${FEEDS_CONF}" | grep -v -E "^#")" |
| 85 | VERSIONS_FILE="xburst/VERSIONS" |
| 86 | echo "# base :: 'openwrt' [scm-protocol] [revision] [source] [branch]" > ${VERSIONS_FILE} |
| 87 | tmp=($(git show-ref | head -n 1)) |
| 88 | rev=${tmp[0]} |
| 89 | echo "openwrt git ${rev} git://projects.qi-hardware.com/openwrt-xburst.git tracking_backfire" >> ${VERSIONS_FILE} |
| 90 | echo "# feeds :: [feedname] [scm-protocol] [revision]" >> ${VERSIONS_FILE} |
| 91 | IFS=$'\n' |
| 92 | for feed in $feeds; do |
| 93 | IFS=' ' arr=(${feed:4}) |
| 94 | proto=${arr[0]} |
| 95 | dir=${arr[1]} |
| 96 | url=${arr[2]} |
| 97 | if [ "$proto" = "svn" ]; then |
| 98 | cd feeds/${arr[1]} && tmp=($(svn info | grep -E "^Revision")) && cd ../../ |
| 99 | rev=${tmp[1]} |
| 100 | fi |
| 101 | if [ "$proto" = "git" ]; then |
| 102 | cd feeds/${arr[1]} && tmp=($(git show-ref | head -n 1)) && cd ../../ |
| 103 | rev=${tmp[0]} |
| 104 | fi |
| 105 | echo "${dir} ${proto} ${rev}" >> ${VERSIONS_FILE} |
| 106 | done |
| 107 | |
| 108 | mkdir -p files/etc |
| 109 | echo ${DATE} > files/etc/VERSION |
| 110 | |
| 111 | mv config .config |
| 112 | |
| 113 | yes "" | make oldconfig |
| 114 | |
| 115 | echo "starting compiling - this may take several hours..." |
| 116 | |
| 117 | time make V=99 > xburst/BUILD_LOG 2>&1 |
| 118 | |
| 119 | if [ "$?" != "0" ]; then |
| 120 | echo "ERROR: Build failed!" |
| 121 | echo "Please refer to the log file" |
| 122 | exit 1 |
| 123 | fi |
| 124 | |
| 125 | git stash pop |
| 126 | |
| 127 | cp .config xburst/config |
| 128 | cp bin/xburst/* xburst/ 2>/dev/null |
| 129 | mkdir xburst/files |
| 130 | cp -a files/* xburst/files/ |
| 131 | |
| 132 | echo "DONE :)" |
| data/qi_lb60/scripts/reflash_ben.sh |
| 1 | #!/bin/bash |
| 2 | VERSION="latest" |
| 3 | |
| 4 | # use 'http' to download and flash images, use 'file' to flash images present in the <WORKING_DIR> |
| 5 | PROTOCOL="http" |
| 6 | |
| 7 | # working directory |
| 8 | #WORKING_DIR="/tmp/NanoNote/${VERSION}" |
| 9 | WORKING_DIR="${HOME}/.qi/nanonote/ben/${VERSION}" |
| 10 | |
| 11 | # where the verbose output goes to |
| 12 | LOG_FILE="${WORKING_DIR}/log.txt" |
| 13 | |
| 14 | # URL to images ($URL/$VERSION/$[images]) |
| 15 | #BASE_URL_HTTP="http://downloads.qi-hardware.com/software/images/Ben_NanoNote_2GB_NAND" |
| 16 | BASE_URL_HTTP="http://downloads.qi-hardware.com/software/images/NanoNote/Ben" |
| 17 | |
| 18 | # names of images |
| 19 | LOADER="openwrt-xburst-qi_lb60-u-boot.bin" |
| 20 | #KERNEL="openwrt-xburst-uImage.bin" |
| 21 | KERNEL="openwrt-xburst-qi_lb60-uImage.bin" |
| 22 | #ROOTFS="openwrt-xburst-rootfs.ubi" |
| 23 | ROOTFS="openwrt-xburst-qi_lb60-root.ubi" |
| 24 | |
| 25 | ############### |
| 26 | |
| 27 | # version of script |
| 28 | __VERSION__="2.1.1" |
| 29 | |
| 30 | |
| 31 | # options for reflash bootloader, kernel or rootfs |
| 32 | B="TRUE" |
| 33 | K="TRUE" |
| 34 | R="TRUE" |
| 35 | |
| 36 | while getopts d:l:bkr OPTIONS |
| 37 | do |
| 38 | case $OPTIONS in |
| 39 | d) |
| 40 | VERSION=$OPTARG # override version by first argument if passed |
| 41 | B="TRUE" |
| 42 | K="TRUE" |
| 43 | R="TRUE" |
| 44 | ;; |
| 45 | l) |
| 46 | WORKING_DIR=$OPTARG |
| 47 | VERSION= |
| 48 | PROTOCOL="file" |
| 49 | B="TRUE" |
| 50 | K="TRUE" |
| 51 | R="TRUE" |
| 52 | ;; |
| 53 | *) |
| 54 | echo "\ |
| 55 | Usage: $0 [-d <version>] [-l <path to local images>] [-b] [-k] [-r] [-h] [-v] |
| 56 | |
| 57 | without any arguments, I will download and flash the latest official images |
| 58 | (includes bootloader, kernel and rootfs) |
| 59 | |
| 60 | -d <> I will download and flash a specific version of official images |
| 61 | (includes bootloader, kernel and rootfs) |
| 62 | |
| 63 | -l <> I will flash images present in <arg> |
| 64 | (includes bootloader, kernel and rootfs - |
| 65 | missing files will be skipped) |
| 66 | |
| 67 | -h you already found out |
| 68 | |
| 69 | |
| 70 | reflash script for qi-hardware Ben NanoNote |
| 71 | |
| 72 | written by: Mirko Vogt (mirko.vogt@sharism.cc) |
| 73 | Xiangfu Liu (xiangfu@sharism.cc) |
| 74 | |
| 75 | version: ${__VERSION__} |
| 76 | |
| 77 | Please report bugs to developer@lists.qi-hardware.com" |
| 78 | exit 1 |
| 79 | ;; |
| 80 | esac |
| 81 | done |
| 82 | |
| 83 | # if no arguments were given |
| 84 | if [ "$#" == "0" ]; then |
| 85 | B="TRUE" |
| 86 | K="TRUE" |
| 87 | R="TRUE" |
| 88 | fi |
| 89 | |
| 90 | # create working directory |
| 91 | mkdir -p ${WORKING_DIR} |
| 92 | date > "${LOG_FILE}" # purge logfile if exists |
| 93 | |
| 94 | function log() { |
| 95 | echo -e "$1" |
| 96 | echo -e "$1" >> "${LOG_FILE}" |
| 97 | } |
| 98 | |
| 99 | function abort() { |
| 100 | log "===" |
| 101 | log "fatal error occured - ABORTED" |
| 102 | log "===" |
| 103 | log "$1" |
| 104 | log "===" |
| 105 | log "Before reporting this as a bug" |
| 106 | log "please ensure you're using the latest available version of" |
| 107 | log " this reflash script" |
| 108 | log " the xburst-tools" |
| 109 | exit 1 |
| 110 | } |
| 111 | |
| 112 | [ "$(whoami)" == "root" ] || abort "this script must be run as root" |
| 113 | |
| 114 | log "working dir: ${WORKING_DIR}" |
| 115 | log "chosen method: ${PROTOCOL}" |
| 116 | test ${VERSION} && log "chosen version: ${VERSION}" |
| 117 | log "===" |
| 118 | |
| 119 | if [ "$PROTOCOL" == "http" ]; then |
| 120 | |
| 121 | MD5SUMS_SERVER=$(wget -O - ${BASE_URL_HTTP}/${VERSION}/md5sums 2> /dev/null | grep -E "(${LOADER}|${KERNEL}|${ROOTFS})" | sort) |
| 122 | [ "${MD5SUMS_SERVER}" ] || abort "can't fetch files from server" |
| 123 | |
| 124 | MD5SUMS_LOCAL=$( (cd "${WORKING_DIR}" ; md5sum --binary "${LOADER}" "${KERNEL}" "${ROOTFS}" 2> /dev/null) | sort ) |
| 125 | |
| 126 | if [ "${MD5SUMS_SERVER}" == "${MD5SUMS_LOCAL}" ]; then |
| 127 | log "present files are identical to the ones on the server - do not download them again" |
| 128 | else |
| 129 | rm -f "${WORKING_DIR}/${LOADER}" "${WORKING_DIR}/${KERNEL}" "${WORKING_DIR}/${ROOTFS}" |
| 130 | if [ "$B" == "TRUE" ]; then |
| 131 | log "fetching bootloader..." |
| 132 | wget \ |
| 133 | -a "${LOG_FILE}" \ |
| 134 | -P "${WORKING_DIR}" \ |
| 135 | "${BASE_URL_HTTP}/${VERSION}/${LOADER}" |
| 136 | fi |
| 137 | if [ "$K" == "TRUE" ]; then |
| 138 | log "fetching kernel..." |
| 139 | wget \ |
| 140 | -a "${LOG_FILE}" \ |
| 141 | -P "${WORKING_DIR}" \ |
| 142 | "${BASE_URL_HTTP}/${VERSION}/${KERNEL}" |
| 143 | fi |
| 144 | if [ "$R" == "TRUE" ]; then |
| 145 | log "fetching rootfs..." |
| 146 | wget \ |
| 147 | -a "${LOG_FILE}" \ |
| 148 | -P "${WORKING_DIR}" \ |
| 149 | "${BASE_URL_HTTP}/${VERSION}/${ROOTFS}" |
| 150 | fi |
| 151 | fi |
| 152 | fi |
| 153 | |
| 154 | log "booting device..." |
| 155 | usbboot -c "boot" >> "${LOG_FILE}" || abort "can't boot device - xburst-tools setup correctly? device in boot-mode? device connected?" |
| 156 | |
| 157 | if [ "$B" == "TRUE" ]; then |
| 158 | log "flashing bootloader..." |
| 159 | tmp=$(usbboot -c "nprog 0 ${WORKING_DIR}/${LOADER} 0 0 -n" 3>> "${LOG_FILE}" 2>&1 >&3) |
| 160 | test "${tmp}" && abort "error while flashing bootloader:\n${tmp}" |
| 161 | fi |
| 162 | if [ "$K" == "TRUE" ]; then |
| 163 | log "flashing kernel..." |
| 164 | tmp=$(usbboot -c "nprog 1024 ${WORKING_DIR}/${KERNEL} 0 0 -n" 3>> "${LOG_FILE}" 2>&1 >&3) |
| 165 | test "${tmp}" && abort "error while flashing kernel:\n${tmp}" |
| 166 | fi |
| 167 | if [ "$R" == "TRUE" ]; then |
| 168 | log "erase nand rootfs partition..." |
| 169 | usbboot -c "boot;nerase 16 512 0 0" >> "${LOG_FILE}" 2>&1 |
| 170 | log "flashing rootfs..." |
| 171 | tmp=$(usbboot -c "nprog 2048 ${WORKING_DIR}/${ROOTFS} 0 0 -n" 3>> "${LOG_FILE}" 2>&1 >&3) |
| 172 | test "${tmp}" && abort "error while flashing rootfs:\n${tmp}" |
| 173 | fi |
| 174 | log "done" |
| scripts/build |
| 1 | | #!/bin/bash |
| 2 | | |
| 3 | | BASE_DIR="xburst" |
| 4 | | |
| 5 | | LOG="${BASE_DIR}/LOG" |
| 6 | | |
| 7 | | BUILD_LOG="${BASE_DIR}/BUILD_LOG" |
| 8 | | |
| 9 | | DATE=$(date "+%Y-%m-%d") |
| 10 | | TIME=$(date "+%H-%M-%S") |
| 11 | | DATE_TIME="${DATE}_${TIME}" |
| 12 | | |
| 13 | | FEEDS_CONF="feeds.conf.default" |
| 14 | | test -f "feeds.conf" && FEEDS_CONF="feeds.conf" |
| 15 | | |
| 16 | | if [ "${0}" != "./scripts/build" ]; then |
| 17 | | echo "Please call me that way: ./scripts/build" |
| 18 | | echo " - out of the main directory" |
| 19 | | exit 1 |
| 20 | | fi |
| 21 | | |
| 22 | | if [ ! -f ".config" ]; then |
| 23 | | echo "OpenWrt didn't get configured yet." |
| 24 | | exit 1 |
| 25 | | fi |
| 26 | | |
| 27 | | if [ -f "config" ]; then |
| 28 | | echo "file <config> exists." |
| 29 | | echo "That means normally, a previous build failed" |
| 30 | | echo "Please examine the situation" |
| 31 | | exit 1 |
| 32 | | fi |
| 33 | | |
| 34 | | echo "This script will move previous builds to bak/!" |
| 35 | | echo "This script will compile base on last commit" |
| 36 | | echo " your modifications will backup by git stash" |
| 37 | | echo " those modifications will apply again after compile" |
| 38 | | echo "This script comes without any kind of warranty!" |
| 39 | | echo " " |
| 40 | | echo "Are you brave, dude? [NO/yes]" |
| 41 | | |
| 42 | | read brave |
| 43 | | |
| 44 | | echo " " |
| 45 | | |
| 46 | | if [ "${brave}" != "yes" ]; then |
| 47 | | exit 1 |
| 48 | | fi |
| 49 | | |
| 50 | | echo "cleaning up toolchain..." |
| 51 | | mkdir bak 2>/dev/null |
| 52 | | BAK="build_dir staging_dir tmp bin .config.old feeds xburst config" |
| 53 | | for bak in $BAK; do |
| 54 | | mv "${bak}" "bak/${bak}_${DATE_TIME}" 2> /dev/null && echo "backed up <${bak}>" |
| 55 | | done |
| 56 | | rm -rf package/feeds/* |
| 57 | | |
| 58 | | mv .config config |
| 59 | | mkdir xburst |
| 60 | | |
| 61 | | echo "updating git repo..." |
| 62 | | git stash |
| 63 | | git checkout tracking_backfire |
| 64 | | git pull > /dev/null |
| 65 | | if [ "$?" != "0" ]; then |
| 66 | | echo "ERROR: updating openwrt-xburst failed" |
| 67 | | exit 1 |
| 68 | | fi |
| 69 | | |
| 70 | | echo "updating feeds..." |
| 71 | | scripts/feeds update -a > /dev/null 2>&1 |
| 72 | | if [ "$?" != "0" ]; then |
| 73 | | echo "ERROR: updating feeds failed" |
| 74 | | exit 1 |
| 75 | | fi |
| 76 | | echo "installing feeds..." |
| 77 | | scripts/feeds install -a > /dev/null 2>&1 |
| 78 | | if [ "$?" != "0" ]; then |
| 79 | | echo "ERROR: installing feeds failed" |
| 80 | | exit 1 |
| 81 | | fi |
| 82 | | |
| 83 | | echo "getting version numbers of used repositories..." |
| 84 | | feeds="$(cat "${FEEDS_CONF}" | grep -v -E "^#")" |
| 85 | | VERSIONS_FILE="xburst/VERSIONS" |
| 86 | | echo "# base :: 'openwrt' [scm-protocol] [revision] [source] [branch]" > ${VERSIONS_FILE} |
| 87 | | tmp=($(git show-ref | head -n 1)) |
| 88 | | rev=${tmp[0]} |
| 89 | | echo "openwrt git ${rev} git://projects.qi-hardware.com/openwrt-xburst.git tracking_backfire" >> ${VERSIONS_FILE} |
| 90 | | echo "# feeds :: [feedname] [scm-protocol] [revision]" >> ${VERSIONS_FILE} |
| 91 | | IFS=$'\n' |
| 92 | | for feed in $feeds; do |
| 93 | | IFS=' ' arr=(${feed:4}) |
| 94 | | proto=${arr[0]} |
| 95 | | dir=${arr[1]} |
| 96 | | url=${arr[2]} |
| 97 | | if [ "$proto" = "svn" ]; then |
| 98 | | cd feeds/${arr[1]} && tmp=($(svn info | grep -E "^Revision")) && cd ../../ |
| 99 | | rev=${tmp[1]} |
| 100 | | fi |
| 101 | | if [ "$proto" = "git" ]; then |
| 102 | | cd feeds/${arr[1]} && tmp=($(git show-ref | head -n 1)) && cd ../../ |
| 103 | | rev=${tmp[0]} |
| 104 | | fi |
| 105 | | echo "${dir} ${proto} ${rev}" >> ${VERSIONS_FILE} |
| 106 | | done |
| 107 | | |
| 108 | | mkdir -p files/etc |
| 109 | | echo ${DATE} > files/etc/VERSION |
| 110 | | |
| 111 | | mv config .config |
| 112 | | |
| 113 | | yes "" | make oldconfig |
| 114 | | |
| 115 | | echo "starting compiling - this may take several hours..." |
| 116 | | |
| 117 | | time make V=99 > xburst/BUILD_LOG 2>&1 |
| 118 | | |
| 119 | | if [ "$?" != "0" ]; then |
| 120 | | echo "ERROR: Build failed!" |
| 121 | | echo "Please refer to the log file" |
| 122 | | exit 1 |
| 123 | | fi |
| 124 | | |
| 125 | | git stash pop |
| 126 | | |
| 127 | | cp .config xburst/config |
| 128 | | cp bin/xburst/* xburst/ 2>/dev/null |
| 129 | | mkdir xburst/files |
| 130 | | cp -a files/* xburst/files/ |
| 131 | | |
| 132 | | echo "DONE :)" |
| scripts/reflash_ben.sh |
| 1 | | #!/bin/bash |
| 2 | | VERSION="latest" |
| 3 | | |
| 4 | | # use 'http' to download and flash images, use 'file' to flash images present in the <WORKING_DIR> |
| 5 | | PROTOCOL="http" |
| 6 | | |
| 7 | | # working directory |
| 8 | | #WORKING_DIR="/tmp/NanoNote/${VERSION}" |
| 9 | | WORKING_DIR="${HOME}/.qi/nanonote/ben/${VERSION}" |
| 10 | | |
| 11 | | # where the verbose output goes to |
| 12 | | LOG_FILE="${WORKING_DIR}/log.txt" |
| 13 | | |
| 14 | | # URL to images ($URL/$VERSION/$[images]) |
| 15 | | #BASE_URL_HTTP="http://downloads.qi-hardware.com/software/images/Ben_NanoNote_2GB_NAND" |
| 16 | | BASE_URL_HTTP="http://downloads.qi-hardware.com/software/images/NanoNote/Ben" |
| 17 | | |
| 18 | | # names of images |
| 19 | | LOADER="openwrt-xburst-qi_lb60-u-boot.bin" |
| 20 | | #KERNEL="openwrt-xburst-uImage.bin" |
| 21 | | KERNEL="openwrt-xburst-qi_lb60-uImage.bin" |
| 22 | | #ROOTFS="openwrt-xburst-rootfs.ubi" |
| 23 | | ROOTFS="openwrt-xburst-qi_lb60-root.ubi" |
| 24 | | |
| 25 | | ############### |
| 26 | | |
| 27 | | # version of script |
| 28 | | __VERSION__="2.1.1" |
| 29 | | |
| 30 | | |
| 31 | | # options for reflash bootloader, kernel or rootfs |
| 32 | | B="TRUE" |
| 33 | | K="TRUE" |
| 34 | | R="TRUE" |
| 35 | | |
| 36 | | while getopts d:l:bkr OPTIONS |
| 37 | | do |
| 38 | | case $OPTIONS in |
| 39 | | d) |
| 40 | | VERSION=$OPTARG # override version by first argument if passed |
| 41 | | B="TRUE" |
| 42 | | K="TRUE" |
| 43 | | R="TRUE" |
| 44 | | ;; |
| 45 | | l) |
| 46 | | WORKING_DIR=$OPTARG |
| 47 | | VERSION= |
| 48 | | PROTOCOL="file" |
| 49 | | B="TRUE" |
| 50 | | K="TRUE" |
| 51 | | R="TRUE" |
| 52 | | ;; |
| 53 | | *) |
| 54 | | echo "\ |
| 55 | | Usage: $0 [-d <version>] [-l <path to local images>] [-b] [-k] [-r] [-h] [-v] |
| 56 | | |
| 57 | | without any arguments, I will download and flash the latest official images |
| 58 | | (includes bootloader, kernel and rootfs) |
| 59 | | |
| 60 | | -d <> I will download and flash a specific version of official images |
| 61 | | (includes bootloader, kernel and rootfs) |
| 62 | | |
| 63 | | -l <> I will flash images present in <arg> |
| 64 | | (includes bootloader, kernel and rootfs - |
| 65 | | missing files will be skipped) |
| 66 | | |
| 67 | | -h you already found out |
| 68 | | |
| 69 | | |
| 70 | | reflash script for qi-hardware Ben NanoNote |
| 71 | | |
| 72 | | written by: Mirko Vogt (mirko.vogt@sharism.cc) |
| 73 | | Xiangfu Liu (xiangfu@sharism.cc) |
| 74 | | |
| 75 | | version: ${__VERSION__} |
| 76 | | |
| 77 | | Please report bugs to developer@lists.qi-hardware.com" |
| 78 | | exit 1 |
| 79 | | ;; |
| 80 | | esac |
| 81 | | done |
| 82 | | |
| 83 | | # if no arguments were given |
| 84 | | if [ "$#" == "0" ]; then |
| 85 | | B="TRUE" |
| 86 | | K="TRUE" |
| 87 | | R="TRUE" |
| 88 | | fi |
| 89 | | |
| 90 | | # create working directory |
| 91 | | mkdir -p ${WORKING_DIR} |
| 92 | | date > "${LOG_FILE}" # purge logfile if exists |
| 93 | | |
| 94 | | function log() { |
| 95 | | echo -e "$1" |
| 96 | | echo -e "$1" >> "${LOG_FILE}" |
| 97 | | } |
| 98 | | |
| 99 | | function abort() { |
| 100 | | log "===" |
| 101 | | log "fatal error occured - ABORTED" |
| 102 | | log "===" |
| 103 | | log "$1" |
| 104 | | log "===" |
| 105 | | log "Before reporting this as a bug" |
| 106 | | log "please ensure you're using the latest available version of" |
| 107 | | log " this reflash script" |
| 108 | | log " the xburst-tools" |
| 109 | | exit 1 |
| 110 | | } |
| 111 | | |
| 112 | | [ "$(whoami)" == "root" ] || abort "this script must be run as root" |
| 113 | | |
| 114 | | log "working dir: ${WORKING_DIR}" |
| 115 | | log "chosen method: ${PROTOCOL}" |
| 116 | | test ${VERSION} && log "chosen version: ${VERSION}" |
| 117 | | log "===" |
| 118 | | |
| 119 | | if [ "$PROTOCOL" == "http" ]; then |
| 120 | | |
| 121 | | MD5SUMS_SERVER=$(wget -O - ${BASE_URL_HTTP}/${VERSION}/md5sums 2> /dev/null | grep -E "(${LOADER}|${KERNEL}|${ROOTFS})" | sort) |
| 122 | | [ "${MD5SUMS_SERVER}" ] || abort "can't fetch files from server" |
| 123 | | |
| 124 | | MD5SUMS_LOCAL=$( (cd "${WORKING_DIR}" ; md5sum --binary "${LOADER}" "${KERNEL}" "${ROOTFS}" 2> /dev/null) | sort ) |
| 125 | | |
| 126 | | if [ "${MD5SUMS_SERVER}" == "${MD5SUMS_LOCAL}" ]; then |
| 127 | | log "present files are identical to the ones on the server - do not download them again" |
| 128 | | else |
| 129 | | rm -f "${WORKING_DIR}/${LOADER}" "${WORKING_DIR}/${KERNEL}" "${WORKING_DIR}/${ROOTFS}" |
| 130 | | if [ "$B" == "TRUE" ]; then |
| 131 | | log "fetching bootloader..." |
| 132 | | wget \ |
| 133 | | -a "${LOG_FILE}" \ |
| 134 | | -P "${WORKING_DIR}" \ |
| 135 | | "${BASE_URL_HTTP}/${VERSION}/${LOADER}" |
| 136 | | fi |
| 137 | | if [ "$K" == "TRUE" ]; then |
| 138 | | log "fetching kernel..." |
| 139 | | wget \ |
| 140 | | -a "${LOG_FILE}" \ |
| 141 | | -P "${WORKING_DIR}" \ |
| 142 | | "${BASE_URL_HTTP}/${VERSION}/${KERNEL}" |
| 143 | | fi |
| 144 | | if [ "$R" == "TRUE" ]; then |
| 145 | | log "fetching rootfs..." |
| 146 | | wget \ |
| 147 | | -a "${LOG_FILE}" \ |
| 148 | | -P "${WORKING_DIR}" \ |
| 149 | | "${BASE_URL_HTTP}/${VERSION}/${ROOTFS}" |
| 150 | | fi |
| 151 | | fi |
| 152 | | fi |
| 153 | | |
| 154 | | log "booting device..." |
| 155 | | usbboot -c "boot" >> "${LOG_FILE}" || abort "can't boot device - xburst-tools setup correctly? device in boot-mode? device connected?" |
| 156 | | |
| 157 | | if [ "$B" == "TRUE" ]; then |
| 158 | | log "flashing bootloader..." |
| 159 | | tmp=$(usbboot -c "nprog 0 ${WORKING_DIR}/${LOADER} 0 0 -n" 3>> "${LOG_FILE}" 2>&1 >&3) |
| 160 | | test "${tmp}" && abort "error while flashing bootloader:\n${tmp}" |
| 161 | | fi |
| 162 | | if [ "$K" == "TRUE" ]; then |
| 163 | | log "flashing kernel..." |
| 164 | | tmp=$(usbboot -c "nprog 1024 ${WORKING_DIR}/${KERNEL} 0 0 -n" 3>> "${LOG_FILE}" 2>&1 >&3) |
| 165 | | test "${tmp}" && abort "error while flashing kernel:\n${tmp}" |
| 166 | | fi |
| 167 | | if [ "$R" == "TRUE" ]; then |
| 168 | | log "erase nand rootfs partition..." |
| 169 | | usbboot -c "boot;nerase 16 512 0 0" >> "${LOG_FILE}" 2>&1 |
| 170 | | log "flashing rootfs..." |
| 171 | | tmp=$(usbboot -c "nprog 2048 ${WORKING_DIR}/${ROOTFS} 0 0 -n" 3>> "${LOG_FILE}" 2>&1 >&3) |
| 172 | | test "${tmp}" && abort "error while flashing rootfs:\n${tmp}" |
| 173 | | fi |
| 174 | | log "done" |