|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +DEVICE=${DEVICE:-"/dev/serial/by-id/usb-Bus_Pirate_Bus_Pirate_5"} |
| 4 | +CTRLUART=(${DEVICE}*-if00) |
| 5 | +FLASHUART=$(basename $(readlink ${DEVICE}*-if00)) |
| 6 | + |
| 7 | +if [ $# -eq 0 ]; then |
| 8 | + #no argument, try default locations |
| 9 | + search_paths=("${HOME}/software/ec-lotus/src/platform/ec/build/zephyr/azalea/output"\ |
| 10 | + "${HOME}/chromiumos/src/platform/ec/build/zephyr/azalea/output") |
| 11 | + |
| 12 | + for search in ${search_paths[@]} |
| 13 | + do |
| 14 | + if [ -d $search ] |
| 15 | + then |
| 16 | + echo "${search} exists" |
| 17 | + FLASH_SRC="${search}/ec.bin" |
| 18 | + MONITOR="${search}/npcx_monitor.bin" |
| 19 | + fi |
| 20 | + done |
| 21 | +else |
| 22 | + #allow specifying a file as argument |
| 23 | + FLASH_SRC="$1/ec.bin" |
| 24 | + MONITOR="$1/npcx_monitor.bin" |
| 25 | +fi |
| 26 | +echo "USING ${FLASH_SRC} to flash EC" |
| 27 | + |
| 28 | +#clear any invalid commands from uart buffer |
| 29 | +echo -e "n\r\n" > ${CTRLUART} |
| 30 | +#put ec into reset |
| 31 | +echo -e "\r\na 2\r\n" > ${CTRLUART} |
| 32 | +#read INPUT < ${CTRLUART} |
| 33 | +sleep 1 |
| 34 | + |
| 35 | +#enable 10k external pulldown on UART RX wired to pin 20 |
| 36 | +echo -e "\r\na 6\r\n" > ${CTRLUART} |
| 37 | +sleep 1 |
| 38 | + |
| 39 | +# take out of reset |
| 40 | + echo -e "\r\n@ 2\r\n" > ${CTRLUART} |
| 41 | +sleep 1 |
| 42 | + |
| 43 | +echo -e "\r\nbridge\r\n" > ${CTRLUART} |
| 44 | + |
| 45 | +sleep 1 |
| 46 | + |
| 47 | +#### DO FLASH |
| 48 | +echo "Using NUVOTON Tool ./uartupdatetool" |
| 49 | +./uartupdatetool --port ${FLASHUART} --opr wr --addr 0x200c3020 --file ${MONITOR} |
| 50 | +./uartupdatetool --port ${FLASHUART} --opr wr --auto --addr 0x0000 --file ${FLASH_SRC} |
| 51 | + |
| 52 | +read -p "Press button on buspirate" userinput |
| 53 | + |
| 54 | +#### TAKE OUT OF RESET |
| 55 | + |
| 56 | +#put ec into reset |
| 57 | +echo -e "\r\na 2\r\n" > ${CTRLUART} |
| 58 | +#read INPUT < ${CTRLUART} |
| 59 | +sleep 1 |
| 60 | + |
| 61 | +#disable 10k external pulldown on UART RX wired to pin 20 |
| 62 | +echo -e "\r\n@ 6\r\n" > ${CTRLUART} |
| 63 | +sleep 1 |
| 64 | + |
| 65 | + |
| 66 | +# take out of reset |
| 67 | +echo -e "\r\n@ 2\r\n" > ${CTRLUART} |
0 commit comments