#!/bin/bash
source ../lib.sh
BUILD_TOOL=$(lib_get_esptool_command)
allports=$(lib_detect_allports)
if [ -z "$allports" ]; then
lib_no_esp_device_message_and_exit
fi
echo "Detected ports:"
echo "$allports"
# allports に対して、1つずつ書き込んでいく
# Define the paths to the firmware files
BUILD_PATH="../FactoryTest/build/esp32.esp32.m5stack_stickc_plus2"
BOOTLOADER_PATH="$BUILD_PATH/FactoryTest.ino.bootloader.bin"
PARTITIONS_PATH="$BUILD_PATH/FactoryTest.ino.partitions.bin"
FIRMWARE_PATH="$BUILD_PATH/FactoryTest.ino.bin"
for port in ${allports} ; do
echo "Flashing port: $port"
$BUILD_TOOL --chip esp32 --port "$port" --baud 460800 write-flash -z \
0x1000 "$BOOTLOADER_PATH" \
0x8000 "$PARTITIONS_PATH" \
0x10000 "$FIRMWARE_PATH" && echo "Flashing completed."
done