diff options
author | Bruce Beare <bruce.j.beare@intel.com> | 2015-10-23 21:14:10 -0700 |
---|---|---|
committer | Bruce Beare <bruce.j.beare@intel.com> | 2015-11-03 23:10:31 -0800 |
commit | a7e9352d2976e87e72cb83b50d28186b5f42122b (patch) | |
tree | c188fc8e7d90886bb02cc1317b4387fc1a8dd2a7 | |
parent | c5f3ec985ca4ddf661c73844f94d6109dd0ec95f (diff) | |
download | edison-a7e9352d2976e87e72cb83b50d28186b5f42122b.tar.gz |
Flashing scripts for Edison
Change-Id: I3d857691af3de31b2aa91c456f3e28b466681652
Author: Bruce Beare <bruce.j.beare@intel.com>
Author: Pierre Tardy <pierre.tardy@intel.com>
Author: Scott D Phillips <scott.d.phillips@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
Signed-off-by: Pierre Tardy <pierre.tardy@intel.com>
Signed-off-by: Scott D Phillips <scott.d.phillips@intel.com>
-rw-r--r-- | flash_tools/FlashEdison.json | 197 | ||||
-rw-r--r-- | flash_tools/LICENSE.txt | 13 | ||||
-rw-r--r-- | flash_tools/README | 1 | ||||
-rwxr-xr-x | flash_tools/brillo-flashall-edison.bat | 26 | ||||
-rwxr-xr-x | flash_tools/brillo-flashall-edison.sh | 40 | ||||
-rwxr-xr-x | flash_tools/brillo-provision-edison.sh | 116 |
6 files changed, 393 insertions, 0 deletions
diff --git a/flash_tools/FlashEdison.json b/flash_tools/FlashEdison.json new file mode 100644 index 0000000..c58c517 --- /dev/null +++ b/flash_tools/FlashEdison.json @@ -0,0 +1,197 @@ +{ + "flash": { + "version": "2.2", + "osplatform": "android", + "commands": [ + { + "duration": 42000, + "restrict": null, + "tool": "notifier", + "source": "Please reset the edison (with reset button)", + "description": "notify" + }, + { + "restrict": ["full"], + "ifwi_dnx": "${fw_dnx_file}", + "os_dnx": "${os_dnx_file}", + "tool": "xfstkDownloader", + "os": "${os_file}", + "gpflag": "${gpflag}", + "ifwi": "${ifwi_file}", + "description": "flashing ifwi via xfstk" + }, + { + "restrict": null, + "state": "pos", + "tool": "waitForDevice", + "timeout": 120000, + "description": "Waiting for device" + }, + { + "restrict": ["full", "os"], + "retry": 2, + "mandatory": true, + "description": "Flashing gpt", + "timeout": 60000, + "tool": "fastboot", + "args": "flash gpt ${gpt_file}" + }, + { + "restrict": ["full", "os"], + "retry": 2, + "mandatory": true, + "description": "Flashing u-boot", + "timeout": 60000, + "tool": "fastboot", + "args": "flash u-boot ${u-boot_file}" + }, + { + "restrict": ["full", "os"], + "retry": 2, + "mandatory": true, + "description": "Flashing boot", + "timeout": 60000, + "tool": "fastboot", + "args": "flash boot_a ${boot_file}" + }, + { + "restrict": ["full", "os"], + "retry": 2, + "mandatory": true, + "description": "Flashing data", + "timeout": 60000, + "tool": "fastboot", + "args": "flash data ${userdata_file}" + }, + { + "restrict": ["full", "os", "system"], + "retry": 2, + "mandatory": true, + "description": "Flashing system", + "timeout": 1200000, + "tool": "fastboot", + "args": "flash system_a ${system_file}" + }, + { + "restrict": ["full", "os", "system"], + "retry": 2, + "mandatory": true, + "description": "Setting slot 0 active", + "timeout": 1200000, + "tool": "fastboot", + "args": "oem set_active 0" + }, + { + "restrict": ["full", "os", "system"], + "retry": 2, + "mandatory": true, + "description": "Rebooting", + "timeout": 1200000, + "tool": "fastboot", + "args": "reboot" + }, + { + "duration": 60000, + "restrict": null, + "tool": "notifier", + "source": "Edison board needs to reboot<br />\nPlease do not unplug it for 2 minutes<br /><br /><br />\n\n", + "description": "flashing ifwi via xfstk" + } + ], + "groups": {}, + "parameters": { + "system_file": { + "type": "file", + "description": "System", + "value": "system.img", + "name": "System" + }, + "userdata_file": { + "type": "file", + "description": "data partition", + "value": "userdata.img", + "name": "Userdata" + }, + "u-boot_file": { + "type": "file", + "description": "U-Boot", + "value": "u-boot-edison.bin", + "name": "U-Boot primary" + }, + "os_file": { + "type": "file", + "description": "OS", + "value": "u-boot-edison.img", + "name": "OS" + }, + "gpflag": { + "type": "string", + "description": "GP flag", + "value": "0x80000007", + "name": "GP flag" + }, + "fw_dnx_file": { + "type": "file", + "description": "Firmware DnX", + "value": "edison_dnx_fwr.bin", + "name": "Firmware DnX" + }, + "ifwi_file": { + "type": "file", + "description": "Firmware", + "value": "edison_ifwi-dbg-00.bin", + "name": "Firmware" + }, + "os_dnx_file": { + "type": "file", + "description": "OS DnX", + "value": "edison_dnx_osr.bin", + "name": "OS DnX" + }, + "boot_file": { + "type": "file", + "description": "Boot partition", + "value": "boot.img", + "name": "Boot partition" + }, + "gpt_file": { + "type": "file", + "description": "Partition Table", + "value": "gpt.bin", + "name": "Partition Table" + } + }, + "configurations": { + "full": { + "name": "Full", + "parameters": {}, + "default": false, + "documentation": "", + "groupsState": {}, + "brief": "full recovery flashing", + "startState": "dnx_fw", + "description": "full reflash" + }, + "os": { + "name": "OS", + "parameters": {}, + "default": false, + "documentation": "", + "groupsState": {}, + "brief": "Flash boot image and system image", + "startState": "dnx_fw", + "description": "os reflash" + }, + "system": { + "name": "System", + "parameters": {}, + "default": false, + "documentation": "", + "groupsState": {}, + "brief": "Flash system image", + "startState": "dnx_fw", + "description": "system reflash" + } + } + } +} diff --git a/flash_tools/LICENSE.txt b/flash_tools/LICENSE.txt new file mode 100644 index 0000000..f22324c --- /dev/null +++ b/flash_tools/LICENSE.txt @@ -0,0 +1,13 @@ +Copyright 2015 Intel Corporation + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/flash_tools/README b/flash_tools/README new file mode 100644 index 0000000..df8acf9 --- /dev/null +++ b/flash_tools/README @@ -0,0 +1 @@ +## Including Flashing instructions here. diff --git a/flash_tools/brillo-flashall-edison.bat b/flash_tools/brillo-flashall-edison.bat new file mode 100755 index 0000000..74f9d0e --- /dev/null +++ b/flash_tools/brillo-flashall-edison.bat @@ -0,0 +1,26 @@ +@ECHO OFF +:: Copyright 2012 The Android Open Source Project +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. + +PATH=%PATH%;"%SYSTEMROOT%\System32" + +:: Only execute this script on a Brillo provisioned Edison. +:: See your Brillo-Edison online information for initial provisioning and recovery. + +fastboot flash gpt gpt.bin +fastboot flash u-boot u-boot-edison.bin +fastboot flash boot_a boot.img +fastboot flash system_a system.img +fastboot flash data userdata.img +fastboot oem set_active 0 diff --git a/flash_tools/brillo-flashall-edison.sh b/flash_tools/brillo-flashall-edison.sh new file mode 100755 index 0000000..dafbcfa --- /dev/null +++ b/flash_tools/brillo-flashall-edison.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Only execute this script on a Brillo provisioned Edison. +# See your Brillo-Edison online information for initial provisioning and recovery. + +set -e + +function dir_with_file() { + local file=${1}; shift + local dir; + for dir; do + if [ -z "${dir}" ]; then continue; fi + if [ -r "${dir}/${file}" ]; then + echo ${dir} + return + fi + done + echo "Could not find ${file}, looked in $@" >&2 + return 1 +} + +LOCAL_DIR=$(dirname "${0}") + +# Location of where the Brillo OS image is built. +_EDISON_IMG_DIR=$(dir_with_file boot.img \ + "${LOCAL_DIR}" \ + "${BRILLO_OUT_DIR}" \ + "${ANDROID_PRODUCT_OUT}") + +# Location of binary blobs supplied by the vendor. +_EDISON_UBOOT_DIR=$(dir_with_file u-boot-edison.bin \ + "${LOCAL_DIR}" \ + "${ANDROID_BUILD_TOP}/device/intel/edison/uboot_firmware") + +fastboot flash gpt "${_EDISON_IMG_DIR}"/gpt.bin \ + flash u-boot "${_EDISON_UBOOT_DIR}"/u-boot-edison.bin \ + flash boot_a "${_EDISON_IMG_DIR}"/boot.img \ + flash system_a "${_EDISON_IMG_DIR}"/system.img \ + flash data "${_EDISON_IMG_DIR}"/userdata.img +fastboot oem set_active 0 diff --git a/flash_tools/brillo-provision-edison.sh b/flash_tools/brillo-provision-edison.sh new file mode 100755 index 0000000..2fb97ce --- /dev/null +++ b/flash_tools/brillo-provision-edison.sh @@ -0,0 +1,116 @@ +#!/bin/bash + +BACKUP_IFS=$IFS +IFS=$(echo -en "\n\b") + +function dir_with_file() { + local file=${1}; shift + local dir; + for dir; do + if [ -z "${dir}" ]; then continue; fi + if [ -r "${dir}/${file}" ]; then + echo ${dir} + return + fi + done + echo "Could not find ${file}, looked in $@" >&2 + return 1 +} + +LOCAL_DIR=$(dirname "${0}") + +# Location of where the Brillo OS image is built. +UBOOT_DIR=$(dir_with_file u-boot-edison.img \ + "${LOCAL_DIR}"/uboot_firmware \ + "${LOCAL_DIR}") +IFWI_DIR=$(dir_with_file edison_dnx_fwr.bin \ + "${LOCAL_DIR}"/ifwi_firmware \ + "${LOCAL_DIR}") + +if [ $? -ne 0 ]; then + exit 1 +fi + +GETOPTS="$(which getopt)" +if [[ "$OSTYPE" == "darwin"* ]] ; then READLINK=greadlink; GETOPTS="$(brew list gnu-getopt | grep bin/getopt)"; else READLINK=readlink;fi; + +if [[ "$OSTYPE" == "cygwin" ]] ; +then + TEMP_DIR="$(dirname $($READLINK -f "$0"))" + UBOOT_DIR="$(cygpath -m ${UBOOT_DIR})" + IFWI_DIR="$(cygpath -m ${IFWI_DIR})" +else + UBOOT_DIR=${UBOOT_DIR//' '/'\ '} + IFWI_DIR=${IFWI_DIR//' '/'\ '} +fi; + +LOG_FILENAME="flash.log" + +function print-usage { + cat << EOF +Usage: ${0##*/} [-h][--help] +Update all software and restore board to its initial state. + -h,--help display this help and exit. +EOF + exit -5 +} + +function flash-debug { + echo "DEBUG: lsusb" + lsusb +} + +function flash-ifwi { + if [ -x "$(which xfstk-dldr-solo)" ]; then + flash-ifwi-xfstk + else + echo "!!! You should install xfstk tools, please visit http://xfstk.sourceforge.net/" + echo "!!! Alternatively, see the Edison-Brillo web for information on using Phone Flash Tool Lite" + exit -1 + fi +} + +function flash-ifwi-xfstk { + XFSTK_PARAMS=" --gpflags 0x80000007 --osimage ${UBOOT_DIR}/u-boot-edison.img" + XFSTK_PARAMS="${XFSTK_PARAMS} --fwdnx ${IFWI_DIR}/edison_dnx_fwr.bin" + XFSTK_PARAMS="${XFSTK_PARAMS} --fwimage ${IFWI_DIR}/edison_ifwi-dbg-00.bin" + XFSTK_PARAMS="${XFSTK_PARAMS} --osdnx ${IFWI_DIR}/edison_dnx_osr.bin" + + eval xfstk-dldr-solo ${XFSTK_PARAMS} + if [ $? -ne 0 ]; + then + echo "Xfstk tool error" + flash-debug + exit -1 + fi +} + +# Execute old getopt to have long options support +ARGS=$($GETOPTS -o hv -l "recovery,help" -n "${0##*/}" -- "$@"); +#Bad arguments +if [ $? -ne 0 ]; then print-usage ; fi; +eval set -- "$ARGS"; + +while true; do + case "$1" in + -h|--help) shift; print-usage;; + --) shift; break;; + esac +done + +echo "** Flashing Edison Board $(date) **" >> ${LOG_FILENAME} + + +if [[ "$OSTYPE" == "darwin"* ]] ; then + echo "Recovery mode is only available on windows and linux"; + exit -3 +fi + +echo "Starting Recovery mode" +echo "Please plug and reboot the board" +echo "Flashing IFWI" +flash-ifwi +echo "Recovery Success..." +echo "You can now try a regular flash" + +IFS=${BACKUP_IFS} |