Skip to content

Commit

Permalink
Improve esp32 flash.sh tool
Browse files Browse the repository at this point in the history
Enhances the `flash.sh` tool to accept `-o` option to set the flash offset from option arguments,
overriding any environment variable. Also adds the `-l` option to allow flashing `atomvmlib.avm` to
the default `lib.avm` partiton offset of `0x1D0000`. Allows for the use of independently installed
`esptool.py`, either from OS packages, with `pip install esptool`, or from Espressif's
[esptool github repo](https://github.com/espressif/esptool). Note: by default, if the ESP-IDF has
been activated in the users environment, the esp-idf included version of the tool will appear first
in the users environment PATH.

Signed-off-by: Winford <winford@object.stream>
  • Loading branch information
UncleGrumpy committed Jul 14, 2023
1 parent 474dea9 commit ed7c549
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tools/dev/flash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,35 @@ set -e
: "${FLASH_SERIAL_PORT:=/dev/ttyUSB0}"
: "${FLASH_OFFSET:=0x210000}"

if [ -z "${IDF_PATH}" ]; then
echo "ERROR! IDF_PATH must be set to root of IDF-SDK to pick up esptool."
ESP_TOOL=`which esptool.py`
if [ -z ${ESP_TOOL} ]; then
echo "ERROR! esptool.py not found! IDF_PATH must be set to root of IDF-SDK to pick up esptool. Or install the standalone tool."
exit -1
fi

usage() {
echo "Usage: $0 [-p <port>] [-b <baud>] <avm_file>"
echo "Usage: $ ${0} [-p <port>] [-b <baud>] [-o <offset>] [-l :: flash given .avm file to lib.avm partition] <avm_file>"
}

if [[ $# -lt 1 ]]; then
usage
exit -1
fi

while getopts 'p:b:h' arg; do
while getopts 'p:b:o:lh' arg; do
case ${arg} in
p)
FLASH_SERIAL_PORT=${OPTARG}
;;
b)
FLASH_BAUD_RATE=${OPTARG}
;;
o)
FLASH_OFFSET=${OPTARG}
;;
l)
FLASH_OFFSET="0x1D0000"
;;
h)
usage
exit 0
Expand Down

0 comments on commit ed7c549

Please sign in to comment.