Date:2010-10-30 16:25:11 (9 years 8 months ago)
Author:Xiangfu Liu
Commit:cae16156304573584813d7b1c464001152f8726d
Message:move NanoNote special files(build, reflash_ben.sh) to data/ folder

Signed-off-by: Xiangfu Liu <xiangfu@sharism.cc>
Files: data/qi_lb60/scripts/build (1 diff)
data/qi_lb60/scripts/reflash_ben.sh (1 diff)
scripts/build (1 diff)
scripts/reflash_ben.sh (1 diff)

Change Details

data/qi_lb60/scripts/build
1#!/bin/bash
2
3BASE_DIR="xburst"
4
5LOG="${BASE_DIR}/LOG"
6
7BUILD_LOG="${BASE_DIR}/BUILD_LOG"
8
9DATE=$(date "+%Y-%m-%d")
10TIME=$(date "+%H-%M-%S")
11DATE_TIME="${DATE}_${TIME}"
12
13FEEDS_CONF="feeds.conf.default"
14test -f "feeds.conf" && FEEDS_CONF="feeds.conf"
15
16if [ "${0}" != "./scripts/build" ]; then
17    echo "Please call me that way: ./scripts/build"
18    echo " - out of the main directory"
19    exit 1
20fi
21
22if [ ! -f ".config" ]; then
23    echo "OpenWrt didn't get configured yet."
24    exit 1
25fi
26
27if [ -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
32fi
33
34echo "This script will move previous builds to bak/!"
35echo "This script will compile base on last commit"
36echo " your modifications will backup by git stash"
37echo " those modifications will apply again after compile"
38echo "This script comes without any kind of warranty!"
39echo " "
40echo "Are you brave, dude? [NO/yes]"
41
42read brave
43
44echo " "
45
46if [ "${brave}" != "yes" ]; then
47    exit 1
48fi
49
50echo "cleaning up toolchain..."
51mkdir bak 2>/dev/null
52BAK="build_dir staging_dir tmp bin .config.old feeds xburst config"
53for bak in $BAK; do
54    mv "${bak}" "bak/${bak}_${DATE_TIME}" 2> /dev/null && echo "backed up <${bak}>"
55done
56rm -rf package/feeds/*
57
58mv .config config
59mkdir xburst
60
61echo "updating git repo..."
62git stash
63git checkout tracking_backfire
64git pull > /dev/null
65if [ "$?" != "0" ]; then
66    echo "ERROR: updating openwrt-xburst failed"
67    exit 1
68fi
69
70echo "updating feeds..."
71scripts/feeds update -a > /dev/null 2>&1
72if [ "$?" != "0" ]; then
73    echo "ERROR: updating feeds failed"
74    exit 1
75fi
76echo "installing feeds..."
77scripts/feeds install -a > /dev/null 2>&1
78if [ "$?" != "0" ]; then
79    echo "ERROR: installing feeds failed"
80    exit 1
81fi
82
83echo "getting version numbers of used repositories..."
84feeds="$(cat "${FEEDS_CONF}" | grep -v -E "^#")"
85VERSIONS_FILE="xburst/VERSIONS"
86echo "# base :: 'openwrt' [scm-protocol] [revision] [source] [branch]" > ${VERSIONS_FILE}
87tmp=($(git show-ref | head -n 1))
88rev=${tmp[0]}
89echo "openwrt git ${rev} git://projects.qi-hardware.com/openwrt-xburst.git tracking_backfire" >> ${VERSIONS_FILE}
90echo "# feeds :: [feedname] [scm-protocol] [revision]" >> ${VERSIONS_FILE}
91IFS=$'\n'
92for 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}
106done
107
108mkdir -p files/etc
109echo ${DATE} > files/etc/VERSION
110
111mv config .config
112
113yes "" | make oldconfig
114
115echo "starting compiling - this may take several hours..."
116
117time make V=99 > xburst/BUILD_LOG 2>&1
118
119if [ "$?" != "0" ]; then
120    echo "ERROR: Build failed!"
121    echo "Please refer to the log file"
122    exit 1
123fi
124
125git stash pop
126
127cp .config xburst/config
128cp bin/xburst/* xburst/ 2>/dev/null
129mkdir xburst/files
130cp -a files/* xburst/files/
131
132echo "DONE :)"
data/qi_lb60/scripts/reflash_ben.sh
1#!/bin/bash
2VERSION="latest"
3
4# use 'http' to download and flash images, use 'file' to flash images present in the <WORKING_DIR>
5PROTOCOL="http"
6
7# working directory
8#WORKING_DIR="/tmp/NanoNote/${VERSION}"
9WORKING_DIR="${HOME}/.qi/nanonote/ben/${VERSION}"
10
11# where the verbose output goes to
12LOG_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"
16BASE_URL_HTTP="http://downloads.qi-hardware.com/software/images/NanoNote/Ben"
17
18# names of images
19LOADER="openwrt-xburst-qi_lb60-u-boot.bin"
20#KERNEL="openwrt-xburst-uImage.bin"
21KERNEL="openwrt-xburst-qi_lb60-uImage.bin"
22#ROOTFS="openwrt-xburst-rootfs.ubi"
23ROOTFS="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
32B="TRUE"
33K="TRUE"
34R="TRUE"
35
36while getopts d:l:bkr OPTIONS
37do
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 "\
55Usage: $0 [-d <version>] [-l <path to local images>] [-b] [-k] [-r] [-h] [-v]
56
57without 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
70reflash script for qi-hardware Ben NanoNote
71
72written by: Mirko Vogt (mirko.vogt@sharism.cc)
73            Xiangfu Liu (xiangfu@sharism.cc)
74
75version: ${__VERSION__}
76
77Please report bugs to developer@lists.qi-hardware.com"
78        exit 1
79        ;;
80    esac
81done
82
83# if no arguments were given
84if [ "$#" == "0" ]; then
85    B="TRUE"
86    K="TRUE"
87    R="TRUE"
88fi
89
90# create working directory
91mkdir -p ${WORKING_DIR}
92date > "${LOG_FILE}" # purge logfile if exists
93
94function log() {
95    echo -e "$1"
96    echo -e "$1" >> "${LOG_FILE}"
97}
98
99function 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
114log "working dir: ${WORKING_DIR}"
115log "chosen method: ${PROTOCOL}"
116test ${VERSION} && log "chosen version: ${VERSION}"
117log "==="
118
119if [ "$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
152fi
153
154log "booting device..."
155usbboot -c "boot" >> "${LOG_FILE}" || abort "can't boot device - xburst-tools setup correctly? device in boot-mode? device connected?"
156
157if [ "$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}"
161fi
162if [ "$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}"
166fi
167if [ "$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}"
173fi
174log "done"
scripts/build
1#!/bin/bash
2
3BASE_DIR="xburst"
4
5LOG="${BASE_DIR}/LOG"
6
7BUILD_LOG="${BASE_DIR}/BUILD_LOG"
8
9DATE=$(date "+%Y-%m-%d")
10TIME=$(date "+%H-%M-%S")
11DATE_TIME="${DATE}_${TIME}"
12
13FEEDS_CONF="feeds.conf.default"
14test -f "feeds.conf" && FEEDS_CONF="feeds.conf"
15
16if [ "${0}" != "./scripts/build" ]; then
17    echo "Please call me that way: ./scripts/build"
18    echo " - out of the main directory"
19    exit 1
20fi
21
22if [ ! -f ".config" ]; then
23    echo "OpenWrt didn't get configured yet."
24    exit 1
25fi
26
27if [ -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
32fi
33
34echo "This script will move previous builds to bak/!"
35echo "This script will compile base on last commit"
36echo " your modifications will backup by git stash"
37echo " those modifications will apply again after compile"
38echo "This script comes without any kind of warranty!"
39echo " "
40echo "Are you brave, dude? [NO/yes]"
41
42read brave
43
44echo " "
45
46if [ "${brave}" != "yes" ]; then
47    exit 1
48fi
49
50echo "cleaning up toolchain..."
51mkdir bak 2>/dev/null
52BAK="build_dir staging_dir tmp bin .config.old feeds xburst config"
53for bak in $BAK; do
54    mv "${bak}" "bak/${bak}_${DATE_TIME}" 2> /dev/null && echo "backed up <${bak}>"
55done
56rm -rf package/feeds/*
57
58mv .config config
59mkdir xburst
60
61echo "updating git repo..."
62git stash
63git checkout tracking_backfire
64git pull > /dev/null
65if [ "$?" != "0" ]; then
66    echo "ERROR: updating openwrt-xburst failed"
67    exit 1
68fi
69
70echo "updating feeds..."
71scripts/feeds update -a > /dev/null 2>&1
72if [ "$?" != "0" ]; then
73    echo "ERROR: updating feeds failed"
74    exit 1
75fi
76echo "installing feeds..."
77scripts/feeds install -a > /dev/null 2>&1
78if [ "$?" != "0" ]; then
79    echo "ERROR: installing feeds failed"
80    exit 1
81fi
82
83echo "getting version numbers of used repositories..."
84feeds="$(cat "${FEEDS_CONF}" | grep -v -E "^#")"
85VERSIONS_FILE="xburst/VERSIONS"
86echo "# base :: 'openwrt' [scm-protocol] [revision] [source] [branch]" > ${VERSIONS_FILE}
87tmp=($(git show-ref | head -n 1))
88rev=${tmp[0]}
89echo "openwrt git ${rev} git://projects.qi-hardware.com/openwrt-xburst.git tracking_backfire" >> ${VERSIONS_FILE}
90echo "# feeds :: [feedname] [scm-protocol] [revision]" >> ${VERSIONS_FILE}
91IFS=$'\n'
92for 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}
106done
107
108mkdir -p files/etc
109echo ${DATE} > files/etc/VERSION
110
111mv config .config
112
113yes "" | make oldconfig
114
115echo "starting compiling - this may take several hours..."
116
117time make V=99 > xburst/BUILD_LOG 2>&1
118
119if [ "$?" != "0" ]; then
120    echo "ERROR: Build failed!"
121    echo "Please refer to the log file"
122    exit 1
123fi
124
125git stash pop
126
127cp .config xburst/config
128cp bin/xburst/* xburst/ 2>/dev/null
129mkdir xburst/files
130cp -a files/* xburst/files/
131
132echo "DONE :)"
scripts/reflash_ben.sh
1#!/bin/bash
2VERSION="latest"
3
4# use 'http' to download and flash images, use 'file' to flash images present in the <WORKING_DIR>
5PROTOCOL="http"
6
7# working directory
8#WORKING_DIR="/tmp/NanoNote/${VERSION}"
9WORKING_DIR="${HOME}/.qi/nanonote/ben/${VERSION}"
10
11# where the verbose output goes to
12LOG_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"
16BASE_URL_HTTP="http://downloads.qi-hardware.com/software/images/NanoNote/Ben"
17
18# names of images
19LOADER="openwrt-xburst-qi_lb60-u-boot.bin"
20#KERNEL="openwrt-xburst-uImage.bin"
21KERNEL="openwrt-xburst-qi_lb60-uImage.bin"
22#ROOTFS="openwrt-xburst-rootfs.ubi"
23ROOTFS="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
32B="TRUE"
33K="TRUE"
34R="TRUE"
35
36while getopts d:l:bkr OPTIONS
37do
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 "\
55Usage: $0 [-d <version>] [-l <path to local images>] [-b] [-k] [-r] [-h] [-v]
56
57without 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
70reflash script for qi-hardware Ben NanoNote
71
72written by: Mirko Vogt (mirko.vogt@sharism.cc)
73            Xiangfu Liu (xiangfu@sharism.cc)
74
75version: ${__VERSION__}
76
77Please report bugs to developer@lists.qi-hardware.com"
78        exit 1
79        ;;
80    esac
81done
82
83# if no arguments were given
84if [ "$#" == "0" ]; then
85    B="TRUE"
86    K="TRUE"
87    R="TRUE"
88fi
89
90# create working directory
91mkdir -p ${WORKING_DIR}
92date > "${LOG_FILE}" # purge logfile if exists
93
94function log() {
95    echo -e "$1"
96    echo -e "$1" >> "${LOG_FILE}"
97}
98
99function 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
114log "working dir: ${WORKING_DIR}"
115log "chosen method: ${PROTOCOL}"
116test ${VERSION} && log "chosen version: ${VERSION}"
117log "==="
118
119if [ "$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
152fi
153
154log "booting device..."
155usbboot -c "boot" >> "${LOG_FILE}" || abort "can't boot device - xburst-tools setup correctly? device in boot-mode? device connected?"
156
157if [ "$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}"
161fi
162if [ "$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}"
166fi
167if [ "$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}"
173fi
174log "done"

Archive Download the corresponding diff file



interactive