diff --git a/44_write_latest.sh b/44_write_latest.sh index 0364e1a..daf42c8 100755 --- a/44_write_latest.sh +++ b/44_write_latest.sh @@ -134,6 +134,16 @@ exit 1 fi + echo "Erasing flash memory completely..." + $BUILD_TOOL --chip esp32 --port "$PORT" --baud 460800 erase_flash + + if [ $? -ne 0 ]; then + echo "Flash erase failed." + exit 1 + fi + + echo "Flash erase completed successfully." + echo "Flashing ESP32 firmware using esptool..." echo "Bootloader: latest.bootloader.bin" echo "Partitions: latest.partitions.bin" @@ -145,7 +155,15 @@ 0x8000 "latest.partitions.bin" \ 0x10000 "latest.bin" - echo "Flashing completed." + if [ $? -eq 0 ]; then + echo "Flashing completed successfully." + echo "Resetting ESP32..." + $BUILD_TOOL --chip esp32 --port "$PORT" --baud 460800 run + echo "ESP32 reset completed. The new program should now be running." + else + echo "Flashing failed." + exit 1 + fi fi # シリアルモニタを開くか確認 if [ -z "$2" ]; then diff --git a/m5latest.sh b/m5latest.sh index 0364e1a..daf42c8 100755 --- a/m5latest.sh +++ b/m5latest.sh @@ -134,6 +134,16 @@ exit 1 fi + echo "Erasing flash memory completely..." + $BUILD_TOOL --chip esp32 --port "$PORT" --baud 460800 erase_flash + + if [ $? -ne 0 ]; then + echo "Flash erase failed." + exit 1 + fi + + echo "Flash erase completed successfully." + echo "Flashing ESP32 firmware using esptool..." echo "Bootloader: latest.bootloader.bin" echo "Partitions: latest.partitions.bin" @@ -145,7 +155,15 @@ 0x8000 "latest.partitions.bin" \ 0x10000 "latest.bin" - echo "Flashing completed." + if [ $? -eq 0 ]; then + echo "Flashing completed successfully." + echo "Resetting ESP32..." + $BUILD_TOOL --chip esp32 --port "$PORT" --baud 460800 run + echo "ESP32 reset completed. The new program should now be running." + else + echo "Flashing failed." + exit 1 + fi fi # シリアルモニタを開くか確認 if [ -z "$2" ]; then diff --git a/upload_by_hash.sh b/upload_by_hash.sh index 3e4c25f..99d1a78 100755 --- a/upload_by_hash.sh +++ b/upload_by_hash.sh @@ -72,6 +72,16 @@ exit 1 fi +echo "Erasing flash memory completely..." +$BUILD_TOOL --chip esp32 --port "$PORT" --baud 460800 erase_flash + +if [ $? -ne 0 ]; then + echo "Flash erase failed." + exit 1 +fi + +echo "Flash erase completed successfully." + echo "Flashing ESP32 firmware using esptool..." echo "Bootloader: byhash.bootloader.bin" echo "Partitions: byhash.partitions.bin" @@ -83,7 +93,15 @@ 0x8000 "byhash.partitions.bin" \ 0x10000 "byhash.bin" -echo "Flashing completed." +if [ $? -eq 0 ]; then + echo "Flashing completed successfully." + echo "Resetting ESP32..." + $BUILD_TOOL --chip esp32 --port "$PORT" --baud 460800 run + echo "ESP32 reset completed. The new program should now be running." +else + echo "Flashing failed." + exit 1 +fi # シリアルモニタを開くか確認 read -p "シリアルモニタを開きますか?(y/n): " yn