Skip to content

Instantly share code, notes, and snippets.

@hyphop
Last active April 29, 2021 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyphop/e0f61b9368b22c9dc806171af3346e2b to your computer and use it in GitHub Desktop.
Save hyphop/e0f61b9368b22c9dc806171af3346e2b to your computer and use it in GitHub Desktop.
upgrade_mcu.sh
#!/bin/bash
# one-line usage
# /bin/bash -c "$(curl -jkL https://gist.githubusercontent.com/hyphop/e0f61b9368b22c9dc806171af3346e2b/raw/777fce5586d8921e719f382f8ac3b1da55cb2204/upgrade_mcu.sh)"
echo "[i] Tone Board MCU upgrade (online script) - PRESS ANY KEY or Escape by Ctrl+C"
read l
cd ~
mkdir tone_upgrade
cd tone_upgrade
case $(uname) in
Darwin) # MacOS
#install homebrew for mac os
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install git libusb make automake mk-configure install-sh libtool pkg-config wget
echo 'export PATH="/usr/local/opt/m4/bin:$PATH"' >> ~/.zshrc
git clone https://github.com/libusb/libusb.git
cd libusb
./autogen.sh
./configure
make
make install
cd ..
;;
pkg-config --libs libusb-1.0
*) # Linux
sudo apt-get update
sudo apt-get install build-essential libusb-1.0-0-dev git
;;
esac
git clone https://github.com/vdudouyt/stm8flash.git
make -C stm8flash
wget https://dl.khadas.com/Hardware/Tone2/MCU/Tone2_Pro_MCU_Firmware_210417.zip
unzip *.zip
echo "[i] please connect your ST-Link(programmator) paired with Tone Board and PRESS ANY KEY"
read l
./stm8flash/stm8flash -cstlinkv2 "-pstm8s003?3" -s flash \
-w Tone2_Pro_MCU_Firmware_210417/Tone2_Pro_MCU_BOOT_APP_210417.hex && echo "[i] OK"
echo "[i] DONE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment