Ken Van Hoeylandt 431fa84ffb
Merge develop into main (#161)
- Fix CoreS3 boot failure (I2C now returns bool instead of err_result_t)
- Flashing scripts now erase before flashing (to ensure it's a clean install)
- M5Stack Core2 and CoreS3: Experimental SPI speed increase
2025-01-12 00:38:19 +01:00

43 lines
1.2 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Usage:
# flash.sh [port]
#
# Arguments:
# port - the port of the device (e.g. /dev/ttyUSB0, ...)
#
# Requirements:
# jq - run 'pip install jq'
# esptool.py - run 'pip install esptool'
#
# Documentation:
# https://docs.espressif.com/projects/esptool/en/latest/esp32/
#
# Source: https://stackoverflow.com/a/53798785
function is_bin_in_path {
builtin type -P "$1" &> /dev/null
}
function require_bin {
program=$1
tip=$2
if ! is_bin_in_path $program; then
echo -e "\e[31m⚠ $program not found!\n\t$tip\e[0m"
fi
}
require_bin esptool.py "install esptool from your package manager or install python and run 'pip install esptool'"
require_bin jq "install jq from your package manager or install python and run 'pip install jq'"
if [[ $1 -eq 0 ]]; then
echo -e "\e[31m⚠ Must Specify port as argument. For example:\n\tflash.sh /dev/ttyACM0\n\tflash.sh /dev/ttyUSB0\e[0m"
exit -1
fi
cd Binaries
# Create flash command based on partitions
KEY_VALUES=`jq -r '.flash_files | keys[] as $k | "\($k) \(.[$k])"' flasher_args.json | tr "\n" " "`
esptool.py --port $1 erase_flash
esptool.py --port $1 --connect-attempts 10 -b 460800 write_flash $KEY_VALUES