Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions scripts/flash_ec_buspirate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

DEVICE=${DEVICE:-"/dev/serial/by-id/usb-Bus_Pirate_Bus_Pirate_5"}
CTRLUART=(${DEVICE}*-if00)
FLASHUART=$(basename $(readlink ${DEVICE}*-if00))

if [ $# -eq 0 ]; then
#no argument, try default locations
search_paths=("${HOME}/software/ec-lotus/src/platform/ec/build/zephyr/azalea/output"\
"${HOME}/chromiumos/src/platform/ec/build/zephyr/azalea/output")

for search in ${search_paths[@]}
do
if [ -d $search ]
then
echo "${search} exists"
FLASH_SRC="${search}/ec.bin"
MONITOR="${search}/npcx_monitor.bin"
fi
done
else
#allow specifying a file as argument
FLASH_SRC="$1/ec.bin"
MONITOR="$1/npcx_monitor.bin"
fi
echo "USING ${FLASH_SRC} to flash EC"

#clear any invalid commands from uart buffer
echo -e "n\r\n" > ${CTRLUART}
#put ec into reset
echo -e "\r\na 2\r\n" > ${CTRLUART}
#read INPUT < ${CTRLUART}
sleep 1

#enable 10k external pulldown on UART RX wired to pin 20
echo -e "\r\na 6\r\n" > ${CTRLUART}
sleep 1

# take out of reset
echo -e "\r\n@ 2\r\n" > ${CTRLUART}
sleep 1

echo -e "\r\nbridge\r\n" > ${CTRLUART}

sleep 1

#### DO FLASH
echo "Using NUVOTON Tool ./uartupdatetool"
./uartupdatetool --port ${FLASHUART} --opr wr --addr 0x200c3020 --file ${MONITOR}
./uartupdatetool --port ${FLASHUART} --opr wr --auto --addr 0x0000 --file ${FLASH_SRC}

read -p "Press button on buspirate" userinput

#### TAKE OUT OF RESET

#put ec into reset
echo -e "\r\na 2\r\n" > ${CTRLUART}
#read INPUT < ${CTRLUART}
sleep 1

#disable 10k external pulldown on UART RX wired to pin 20
echo -e "\r\n@ 6\r\n" > ${CTRLUART}
sleep 1


# take out of reset
echo -e "\r\n@ 2\r\n" > ${CTRLUART}