ย้อนกลับการอัปเดตที่มีปัญหา
กู้คืนอย่างปลอดภัยเมื่อการอัปโหลดผิดพลาด
ย้อนกลับการอัปเดตที่มีปัญหา เป็นบทเรียน Arduino & IoT Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน 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. 🛡️
คำถามที่พบบ่อย
บทเรียน “ย้อนกลับการอัปเดตที่มีปัญหา” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ย้อนกลับการอัปเดตที่มีปัญหา” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Arduino & IoT Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Arduino & IoT Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “ย้อนกลับการอัปเดตที่มีปัญหา”
กู้คืนอย่างปลอดภัยเมื่อการอัปโหลดผิดพลาด คุณปฏิบัติ Arduino & IoT Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Arduino & IoT Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Arduino & IoT Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน
บทเรียน “ย้อนกลับการอัปเดตที่มีปัญหา” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Arduino & IoT Academy นี้ได้ไหม
ได้ บทเรียน Arduino & IoT Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- ทำไม OTA จึงสำคัญเมื่อใช้งานจริง
- เปิดใช้ ArduinoOTA
- โฮสต์หน้าเว็บอัปเดต
- ย้อนกลับการอัปเดตที่มีปัญหา