# CTR2-MIDI Programmer for Linux and Mac.  Should also work on MSWindows
# MUST have python3 and pip installed
# Lou Scalpati KI5FTY
# >>>> REMEMBER TO MAKE THIS FILE EXECUTABLE <<<<
# 
# Edited 11/1/25 to flash just CTR2-MIDI.BIN to address 0x0

PYTHON=python3
CHIP=esp32s3

#-----------------------------------------------
# Replace the PORT and DIR variables below to fit your system
#-----------------------------------------------
# Begin Edit

PORT=/dev/<YOUR-USB-DEVICE>
DIR=<DIRECTORY-CONTAINING-THE-CTR2-MIDI.BIN-FILE>


# End Edit
#------------------------------------------------

pip -q install esptool

read -rsn1 -p "Hold down ENCODER and press any key to continue" 

$PYTHON -m esptool --chip $CHIP --port $PORT  write_flash -z 0x0 $DIR/CTR2-MIDI.bin
