失敗した更新をロールバックする
アップロードに失敗したとき安全に復旧します。
「失敗した更新をロールバックする」はCoddyKit上の無料Arduino & IoT Academyレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはArduino & IoT Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Arduino & IoT Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
Updates Can Go Wrong
Even careful OTA pushes sometimes ship broken code. A solid plan needs a way to roll back to firmware that actually worked.
The Brick Risk
If new firmware can't connect to WiFi, you lose OTA itself. Without a safety net the device becomes a useless brick.
Two Partitions Save You
The ESP32 keeps the old app in one slot while flashing the new one into another. The previous build is still intact if needed.
Mark a Build as Trusted
A fresh update boots in a pending state. Your code must prove it works and then confirm the image so it becomes permanent.
esp_ota_mark_app_valid_cancel_rollback();Self-Test on Boot
Before confirming, run a quick health check: did WiFi connect, did key sensors respond? Only then mark the build valid.
Auto Rollback on Failure
If a pending build crashes or reboots before confirming, the bootloader quietly returns to the last good firmware on its own.
Trigger It Yourself
You can also force a return to the previous image in code with esp_ota_mark_app_invalid_rollback_and_reboot() when a check fails.
esp_ota_mark_app_invalid_rollback_and_reboot();Use a Watchdog
A watchdog timer resets a frozen board. Paired with rollback, a hung update reboots straight back into working code.
Version Your Firmware
Stamp each build with a version number you can print over Serial, so you instantly know which image is actually running.
#define FW_VERSION "1.4.2"
Serial.println(FW_VERSION);Test on One Device First
Never push to your whole fleet at once. Update a single canary device, watch it, then roll out widely. 🐤
Always Keep a Recovery Path
Worst case, a USB cable still reflashes any board. Design so a bad OTA is an inconvenience, never a permanent loss.
Quick Check
Consider what happens if new firmware crashes before it confirms itself.
Recap
Keep two partitions, self-test then confirm each build, lean on auto rollback and a watchdog, and always leave a USB recovery path. 🛡️
よくある質問
「失敗した更新をロールバックする」レッスンは無料ですか?
はい。「失敗した更新をロールバックする」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Arduino & IoT Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Arduino & IoT Academyコースには全4レッスンが含まれています。
「失敗した更新をロールバックする」で何を学びますか?
アップロードに失敗したとき安全に復旧します。 ブラウザで直接実行するハンズオンコードでArduino & IoT Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Arduino & IoT Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのArduino & IoT Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。
「失敗した更新をロールバックする」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このArduino & IoT Academyレッスンでコードを書いて実行できますか?
はい。すべてのArduino & IoT Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- 現場でOTAが重要な理由
- ArduinoOTAを有効にする
- Web更新ページをホストする
- 失敗した更新をロールバックする