### start_file_server() Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Starts an HTTP server to manage files on SPIFFS and trigger AVR flashing. ```APIDOC ## `start_file_server()` — HTTP File Server with OTA Flash Trigger Starts an ESP-IDF HTTP server on port 80 mounted at `/spiffs`. Registers four URI handlers: `GET /*` (browse/download files), `POST /upload/*` (upload a `.hex` file, max 200 KB), `POST /flash/*` (trigger AVR flashing as a FreeRTOS task), `POST /delete/*` (remove a file). The flash handler spawns a 32 KB stack FreeRTOS task to avoid blocking the HTTP server. ```c #include "esp_http_server.h" // In app_main (file_serving_avr/main/main.c): ESP_ERROR_CHECK(nvs_flash_init()); esp_netif_init(); ESP_ERROR_CHECK(esp_event_loop_create_default()); ESP_ERROR_CHECK(example_connect()); // Connect to WiFi (configured via menuconfig) initSPIFFS(); ESP_ERROR_CHECK(start_file_server("/spiffs")); // Only "/spiffs" is supported as base path initUART(); initGPIO(); // The server now handles: // GET http:/// → HTML page listing all files in SPIFFS // GET http:/// → Download the file // POST http:///upload/ → Upload a .hex file (multipart form) // POST http:///flash/ → Flash the .hex file to AVR // POST http:///delete/ → Delete the file from SPIFFS ``` ``` -------------------------------- ### setupDevice() Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Orchestrates the complete setup process for programming the AVR MCU using the STK500 protocol. This includes resetting the device and configuring it for programming mode. ```APIDOC ## setupDevice() ### Description Orchestrates the complete AVR programming preparation: reset, sync, set STK500 device parameters, set extended parameters, and enter programming mode. Call this once before any write or read tasks. ### Method `void setupDevice()` ### Parameters None ### Request Example ```c #include "avr_pro_mode.h" void flashTask(void) { // Prepares AVR for flashing via STK500 protocol setupDevice(); // Internally calls in order: // resetMCU() → hardware reset // getSync() → STK_GET_SYNC (0x30) // setProgParams() → STK_SET_DEVICE (0x42) with 20-byte params // setExtProgParams() → STK_SET_DEVICE_EXT (0x45) with 5-byte params // enterProgMode() → STK_ENTER_PROGMODE (0x50) // ... proceed with writeTask / readTask } ``` ``` -------------------------------- ### Start HTTP File Server with OTA Flash Trigger (`start_file_server`) Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Initializes an ESP-IDF HTTP server on port 80, mounted at /spiffs. It handles file browsing, uploads, AVR flashing triggers, and file deletion. The flash task uses a 32 KB stack to prevent blocking. ```c #include "esp_http_server.h" // In app_main (file_serving_avr/main/main.c): ESP_ERROR_CHECK(nvs_flash_init()); esp_netif_init(); ESP_ERROR_CHECK(esp_event_loop_create_default()); ESP_ERROR_CHECK(example_connect()); // Connect to WiFi (configured via menuconfig) initSPIFFS(); ESP_ERROR_CHECK(start_file_server("/spiffs")); // Only "/spiffs" is supported as base path initUART(); initGPIO(); // The server now handles: // GET http:/// → HTML page listing all files in SPIFFS // GET http:/// → Download the file // POST http:///upload/ → Upload a .hex file (multipart form) // POST http:///flash/ → Flash the .hex file to AVR // POST http:///delete/ → Delete the file from SPIFFS ``` -------------------------------- ### Setup STK500 Programming Mode Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Orchestrates the full AVR programming preparation, including hardware reset, synchronization, setting STK500 device and extended parameters, and entering programming mode. This should be called before any write or read operations. ```c #include "avr_pro_mode.h" void flashTask(void) { // Prepares AVR for flashing via STK500 protocol setupDevice(); // Internally calls in order: // resetMCU() → hardware reset // getSync() → STK_GET_SYNC (0x30) // setProgParams() → STK_SET_DEVICE (0x42) with 20-byte params // setExtProgParams() → STK_SET_DEVICE_EXT (0x45) with 5-byte params // enterProgMode() → STK_ENTER_PROGMODE (0x50) // ... proceed with writeTask / readTask } ``` -------------------------------- ### OTA Flash HTTP Endpoints Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Examples using curl to interact with the OTA flashing HTTP endpoints. ```APIDOC ## OTA Flash HTTP Endpoints (curl examples) ```bash # Upload a .hex file to the ESP32's SPIFFS curl -X POST http://192.168.43.82/upload/blink.hex \ -F "data=@/path/to/blink.hex" # Response: 303 redirect to / (or 400 if file already exists / too large) # Trigger OTA flash of the uploaded .hex file to the connected AVR curl -X POST http://192.168.43.82/flash/blink.hex # Response: 303 redirect to / ``` ``` -------------------------------- ### initSPIFFS() Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Initializes and mounts the SPIFFS filesystem on the ESP32. This is necessary for accessing firmware files and is typically mounted at `/spiffs`. ```APIDOC ## initSPIFFS() ### Description Registers and mounts the SPIFFS partition at `/spiffs` (max 5 open files, auto-format on mount failure). Required before reading `.hex` files or starting the HTTP file server. ### Method `void initSPIFFS()` ### Parameters None ### Request Example ```c #include "avr_pro_mode.h" void app_main(void) { initSPIFFS(); // Expected logs: // I avr_pro_mode (initSPIFFS:38) Initializing SPIFFS // D avr_pro_mode (initSPIFFS:72) Partition size: total: 917504, used: 0 // Now /spiffs is accessible via standard POSIX file I/O FILE *f = fopen("/spiffs/blink.hex", "r"); } ``` ``` -------------------------------- ### Basic AVR Flash Utility (Non-OTA) Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Standalone ESP-IDF application to flash a hard-coded .hex file from SPIFFS to an AVR microcontroller on startup. Requires UART, GPIO, and SPIFFS initialization. ```c // esp_avr_flash/main/esp_avr_flash.c void app_main(void) { // Step 1: Initialize all peripherals initUART(); // UART1, 115200 baud initGPIO(); // GPIO19 as RESET output initSPIFFS(); // Mount /spiffs setupDevice(); // Reset AVR → Sync → SetParams → EnterProgMode // Step 2: Parse the pre-uploaded .hex file char *filepath = "/spiffs/blink.hex"; ESP_ERROR_CHECK(hexFileParser(filepath, page, &block_count)); // Step 3: Write firmware to AVR flash ESP_ERROR_CHECK(writeTask(page, block_count)); // Step 4: Verify flash contents match the .hex data ESP_ERROR_CHECK(readTask(page, block_count)); // Step 5: Exit programming mode; AVR runs new firmware endConn(); } // Build and flash to ESP32: // idf.py -p /dev/ttyUSB0 -b 921600 flash monitor ``` -------------------------------- ### writeTask() Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Writes firmware data from a binary page buffer to the AVR's flash memory in 128-byte blocks. ```APIDOC ## `writeTask()` — Write Firmware to AVR Flash Memory Iterates over all 128-byte blocks in the parsed `page` buffer, sets the flash address for each block (`STK_LOAD_ADDRESS`, 0x55), then sends the page write command (`STK_PROG_PAGE`, 0x64) with the block data over UART. Verifies SYNC+OK after each block. ```c #include "avr_flash.h" uint8_t page[PAGE_SIZE_MAX]; int block_count = 0; // Parse the hex file first ESP_ERROR_CHECK(hexFileParser("/spiffs/blink.hex", page, &block_count)); // Write all blocks to AVR flash // Each block: loadAddress() + STK_PROG_PAGE header + 128 bytes + 0x20 esp_err_t result = writeTask(page, block_count); if (result == ESP_OK) { ESP_LOGI("APP", "Firmware written successfully"); } else { ESP_LOGE("APP", "Flash write failed - check UART wiring or AVR sync"); } // Expected per-block log: I avr_flash (flashPage:69) Sync Success // On failure: E avr_flash (flashPage:73) Sync Failure // E avr_flash (flashPage:82) Serial Timeout ``` ``` -------------------------------- ### initGPIO() Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Initializes the GPIO pin designated for controlling the AVR MCU's hardware reset. This pin is configured as an output and held in an idle HIGH state. ```APIDOC ## initGPIO() ### Description Sets GPIO19 as a digital output and drives it HIGH (idle state). Controls AVR hardware reset during the programming handshake. ### Method `void initGPIO()` ### Parameters None ### Request Example ```c #include "avr_pro_mode.h" void app_main(void) { initUART(); initGPIO(); // GPIO19 is now configured as output, held HIGH // Expected log: I avr_pro_mode (initGPIO:33) GPIO initialized } ``` ``` -------------------------------- ### endConn() Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Exits STK500 programming mode and resets the AVR to begin normal execution of the newly flashed firmware. ```APIDOC ## `endConn()` — Exit Programming Mode and Reset Exits STK500 programming mode (`STK_LEAVE_PROGMODE`, 0x51) and resets the AVR to begin normal execution of the newly flashed firmware. ```c #include "avr_pro_mode.h" void flashTask(void) { setupDevice(); // ... write and verify flash ... endConn(); // Calls: extProgMode() → STK_LEAVE_PROGMODE (0x51) // resetMCU() → resets AVR to run new firmware // Expected log: I avr_pro_mode (extProgMode:136) Exiting Pro Mode } ``` ``` -------------------------------- ### Parse Intel HEX File to Binary Page (`hexFileParser`) Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Reads a .hex file from SPIFFS, converts hex-encoded data to binary, and pads it to a 128-byte boundary. Outputs a binary page buffer and the total block count. Ensure the file exists in SPIFFS. ```c #include "hex_parser.h" // Intel HEX record format: // :LLAAAATT[DD...]CC // LL = byte count // AAAA = address // TT = record type (00=data, 01=EOF) // DD = data bytes // CC = checksum // Example: :100000000C9434000C9446000C9446000C9446006A uint8_t page[PAGE_SIZE_MAX]; // PAGE_SIZE_MAX = 24 * 1024 bytes int block_count = 0; esp_err_t err = hexFileParser("/spiffs/blink.hex", page, &block_count); if (err != ESP_OK) { // File not found or read error ESP_LOGE("APP", "Failed to parse hex file"); return; } // page[] now contains raw binary firmware data // block_count = total 128-byte blocks (e.g., 16 for a 2048-byte sketch) // Expected log: D hex_parser (hexFileParser:85) Block count: 16 ``` -------------------------------- ### ESP-IDF Project Boilerplate in CMakeLists.txt Source: https://github.com/esp32-musings/ota_update_avr_using_esp32/blob/master/file_serving_avr/CMakeLists.txt These lines must be included in your project's CMakeLists.txt in the exact order shown for the cmake build system to work correctly. They set up the minimum required CMake version, specify additional component directories, and include the main ESP-IDF project script. ```cmake cmake_minimum_required(VERSION 3.5) # (Not part of the boilerplate) set(EXTRA_COMPONENT_DIRS $ENV{HOME}/OTA_update_AVR_using_ESP32/components) include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(file_server_avr) ``` -------------------------------- ### initUART() Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Initializes the UART peripheral on the ESP32 for communication with the AVR MCU. This function must be called before any serial communication attempts. ```APIDOC ## initUART() ### Description Configures UART1 at 115200 baud, 8N1, no hardware flow control, and installs the UART driver. Must be called before any serial communication with the AVR. ### Method `void initUART()` ### Parameters None ### Request Example ```c #include "avr_pro_mode.h" void app_main(void) { // Initialize UART1 at 115200 baud on GPIO4 (TX) / GPIO5 (RX) initUART(); // Expected log: I (tag) avr_pro_mode (initUART:26) UART initialized initGPIO(); // Set GPIO19 as OUTPUT for AVR RESET initSPIFFS(); // Mount SPIFFS at /spiffs } ``` ``` -------------------------------- ### List Files on SPIFFS using cURL Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Use cURL to retrieve an HTML listing of files stored on the ESP32's SPIFFS. ```bash # List files (HTML response) curl http://192.168.43.82/ ``` -------------------------------- ### hexFileParser() Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Parses an Intel HEX file from SPIFFS, converting it into a binary page buffer suitable for flashing. ```APIDOC ## `hexFileParser()` — Parse Intel HEX File to Binary Page Reads a `.hex` file from SPIFFS, strips record headers/checksums, converts hex-encoded data bytes to binary, pads the result to a 128-byte boundary, and outputs a flat binary `page` buffer along with the total block count. ```c #include "hex_parser.h" // Intel HEX record format: // :LLAAAATT[DD...]CC // LL = byte count // AAAA = address // TT = record type (00=data, 01=EOF) // DD = data bytes // CC = checksum // Example: :100000000C9434000C9446000C9446000C9446006A uint8_t page[PAGE_SIZE_MAX]; // PAGE_SIZE_MAX = 24 * 1024 bytes int block_count = 0; esp_err_t err = hexFileParser("/spiffs/blink.hex", page, &block_count); if (err != ESP_OK) { // File not found or read error ESP_LOGE("APP", "Failed to parse hex file"); return; } // page[] now contains raw binary firmware data // block_count = total 128-byte blocks (e.g., 16 for a 2048-byte sketch) // Expected log: D hex_parser (hexFileParser:85) Block count: 16 ``` ``` -------------------------------- ### Mount SPIFFS Filesystem Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Registers and mounts the SPIFFS partition at `/spiffs`. This is necessary for reading `.hex` files or running the HTTP file server. It supports up to 5 open files and auto-formats on mount failure. ```c #include "avr_pro_mode.h" void app_main(void) { initSPIFFS(); // Expected logs: // I avr_pro_mode (initSPIFFS:38) Initializing SPIFFS // D avr_pro_mode (initSPIFFS:72) Partition size: total: 917504, used: 0 // Now /spiffs is accessible via standard POSIX file I/O FILE *f = fopen("/spiffs/blink.hex", "r"); } ``` -------------------------------- ### Write Firmware to AVR Flash Memory (`writeTask`) Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Writes firmware block by block to the AVR's flash memory. Requires the parsed binary data and block count. Ensure UART wiring and AVR sync are correct. ```c #include "avr_flash.h" uint8_t page[PAGE_SIZE_MAX]; int block_count = 0; // Parse the hex file first ESP_ERROR_CHECK(hexFileParser("/spiffs/blink.hex", page, &block_count)); // Write all blocks to AVR flash // Each block: loadAddress() + STK_PROG_PAGE header + 128 bytes + 0x20 esp_err_t result = writeTask(page, block_count); if (result == ESP_OK) { ESP_LOGI("APP", "Firmware written successfully"); } else { ESP_LOGE("APP", "Flash write failed - check UART wiring or AVR sync"); } // Expected per-block log: I avr_flash (flashPage:69) Sync Success // On failure: E avr_flash (flashPage:73) Sync Failure // E avr_flash (flashPage:82) Serial Timeout ``` -------------------------------- ### Structured Component Logging with logger() Macros Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Utilize logger macros to automatically include component name and line number in ESP-IDF log messages. Ensure logger.h is included. ```c #include "logger.h" // Macro signatures: // logV(TAG, fmt, ...) → ESP_LOG_VERBOSE // logD(TAG, fmt, ...) → ESP_LOG_DEBUG // logI(TAG, fmt, ...) → ESP_LOG_INFO // logW(TAG, fmt, ...) → ESP_LOG_WARN // logE(TAG, fmt, ...) → ESP_LOG_ERROR static const char *TAG = "my_component"; logI(TAG, "%s", "Device initialized"); // Output: I (tag) my_component (app_main:12) Device initialized logD(TAG, "Block count: %d", block_count); // Output: D (tag) my_component (flashTask:18) Block count: 16 logE(TAG, "Failed to open: %s", filepath); // Output: E (tag) my_component (hexFileParser:30) Failed to open: /spiffs/missing.hex ``` -------------------------------- ### Verify AVR Flash Memory After Write (`readTask`) Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Reads back firmware from AVR flash and compares it with the original data. Returns ESP_FAIL on mismatch or communication errors. Call `endConn()` after successful verification. ```c #include "avr_flash.h" // After writeTask() completes successfully, verify the flash contents esp_err_t verify = readTask(page, block_count); if (verify == ESP_OK) { ESP_LOGI("APP", "Verification passed - AVR flash matches .hex file"); endConn(); // Exit programming mode; AVR starts executing new firmware } else { ESP_LOGE("APP", "Verification failed - flashing may need to be retried"); } // Expected per-block log: I avr_flash (compare:38) Verification Success // On mismatch: I avr_flash (compare:42) Verification Failure ``` -------------------------------- ### Upload File to ESP32 Server Source: https://github.com/esp32-musings/ota_update_avr_using_esp32/blob/master/file_serving_avr/main/upload_script.html Handles the file upload process, including validation of file selection, path, and size. It uses XMLHttpRequest to send the file to the server. Ensure the MAX_FILE_SIZE constant matches the server-side configuration. ```javascript function upload() { var filePath = document.getElementById("filepath").value; var upload_path = "/upload/" + filePath; var fileInput = document.getElementById("newfile").files; /* Max size of an individual file. Make sure this * value is same as that set in file_server.c */ var MAX_FILE_SIZE = 200 * 1024; var MAX_FILE_SIZE_STR = "200KB"; if (fileInput.length == 0) { alert("No file selected!"); } else if (filePath.length == 0) { alert("File path on server is not set!"); } else if (filePath.indexOf(' ') >= 0) { alert("File path on server cannot have spaces!"); } else if (filePath[filePath.length - 1] == '/') { alert("File name not specified after path!"); } else if (fileInput[0].size > 200 * 1024) { alert("File size must be less than 200KB!"); } else { document.getElementById("newfile").disabled = true; document.getElementById("filepath").disabled = true; document.getElementById("upload").disabled = true; var file = fileInput[0]; var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function () { if (xhttp.readyState == 4) { if (xhttp.status == 200) { document.open(); document.write(xhttp.responseText); document.close(); } else if (xhttp.status == 0) { alert("Server closed the connection abruptly!"); location.reload() } else { alert(xhttp.status + " Error!\n" + xhttp.responseText); location.reload() } } }; xhttp.open("POST", upload_path, true); xhttp.send(file); } } ``` -------------------------------- ### Project Boilerplate Configuration Source: https://github.com/esp32-musings/ota_update_avr_using_esp32/blob/master/esp_avr_flash/CMakeLists.txt These lines are required boilerplate for the project's CMakeLists.txt to function correctly. They set the minimum CMake version, define extra component directories, and include the project's main CMake script. ```cmake cmake_minimum_required(VERSION 3.5) set(EXTRA_COMPONENT_DIRS $ENV{HOME}/OTA_update_AVR_using_ESP32/components) include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(esp_avr_flash) ``` -------------------------------- ### Initialize UART for AVR Communication Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Configures UART1 for communication with the AVR MCU at 115200 baud, 8N1, with no hardware flow control. This must be called before any serial communication. ```c #include "avr_pro_mode.h" void app_main(void) { // Initialize UART1 at 115200 baud on GPIO4 (TX) / GPIO5 (RX) initUART(); // Expected log: I (tag) avr_pro_mode (initUART:26) UART initialized initGPIO(); // Set GPIO19 as OUTPUT for AVR RESET initSPIFFS(); // Mount SPIFFS at /spiffs } ``` -------------------------------- ### Upload .hex file via HTTP POST Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Uploads a .hex file to the ESP32's SPIFFS using a cURL POST request. The file is sent as form data. Expects a 303 redirect on success or a 400 error if the file is too large or already exists. ```bash # Upload a .hex file to the ESP32's SPIFFS curl -X POST http://192.168.43.82/upload/blink.hex \ -F "data=@/path/to/blink.hex" # Response: 303 redirect to / (or 400 if file already exists / too large) ``` -------------------------------- ### Register Logger Component in CMakeLists.txt Source: https://github.com/esp32-musings/ota_update_avr_using_esp32/blob/master/components/logger/CMakeLists.txt Use this snippet to register the logger component in your CMakeLists.txt file. It specifies the source files, include directories, and required components. ```cmake idf_component_register(SRCS "logger.c" INCLUDE_DIRS "include" REQUIRES log) ``` -------------------------------- ### Trigger AVR OTA Flash via HTTP POST Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Triggers the OTA flashing process for an uploaded .hex file on the connected AVR microcontroller using a cURL POST request. Expects a 303 redirect on success. ```bash # Trigger OTA flash of the uploaded .hex file to the connected AVR curl -X POST http://192.168.43.82/flash/blink.hex # Response: 303 redirect to / ``` -------------------------------- ### readTask() Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Verifies the integrity of the AVR's flash memory after a write operation by reading back and comparing blocks. ```APIDOC ## `readTask()` — Verify AVR Flash Memory After Write Reads back all 128-byte blocks from the AVR flash using `STK_READ_PAGE` (0x74) and compares each against the original `page` data. Returns `ESP_FAIL` immediately on any mismatch or communication error. ```c #include "avr_flash.h" // After writeTask() completes successfully, verify the flash contents esp_err_t verify = readTask(page, block_count); if (verify == ESP_OK) { ESP_LOGI("APP", "Verification passed - AVR flash matches .hex file"); endConn(); // Exit programming mode; AVR starts executing new firmware } else { ESP_LOGE("APP", "Verification failed - flashing may need to be retried"); } // Expected per-block log: I avr_flash (compare:38) Verification Success // On mismatch: I avr_flash (compare:42) Verification Failure ``` ``` -------------------------------- ### Register AVR Pro Mode Component Source: https://github.com/esp32-musings/ota_update_avr_using_esp32/blob/master/components/avr_pro_mode/CMakeLists.txt Registers the AVR Pro Mode component with the ESP-IDF build system. Specifies source files, include directories, and dependencies. ```cmake idf_component_register(SRCS "avr_pro_mode.c" INCLUDE_DIRS "include" REQUIRES esp_event freertos logger esp_http_server esp_wifi nvs_flash spiffs) ``` -------------------------------- ### Set File Path on Server Source: https://github.com/esp32-musings/ota_update_avr_using_esp32/blob/master/file_serving_avr/main/upload_script.html Sets the server path for the file to be uploaded based on the selected file's name. This function is typically called when a file is selected. ```javascript function setpath() { var default_path = document.getElementById("newfile").files[0].name; document.getElementById("filepath").value = default_path; } ``` -------------------------------- ### Initialize RESET Pin for AVR MCU Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Configures GPIO19 as a digital output and sets it to a HIGH state, which is the idle state for controlling the AVR's hardware reset during the programming handshake. ```c #include "avr_pro_mode.h" void app_main(void) { initUART(); initGPIO(); // GPIO19 is now configured as output, held HIGH // Expected log: I avr_pro_mode (initGPIO:33) GPIO initialized } ``` -------------------------------- ### resetMCU() Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Performs a hardware reset on the AVR MCU by manipulating the RESET pin. This action is crucial for entering the STK500 programming mode. ```APIDOC ## resetMCU() ### Description Performs a double-pulse LOW on the RESET pin (GPIO19) to put the AVR bootloader into a known ready state before beginning the STK500 handshake. The timing follows AVR bootloader entry requirements. ### Method `void resetMCU()` ### Parameters None ### Request Example ```c #include "avr_pro_mode.h" // Manually reset the AVR before a programming session resetMCU(); // Sequence: HIGH → LOW(1ms) → HIGH(100ms) → LOW(1ms) → HIGH(100ms) // Expected logs: // I avr_pro_mode (resetMCU:79) Starting Reset Procedure // I avr_pro_mode (resetMCU:89) Reset Procedure finished ``` ``` -------------------------------- ### Exit Programming Mode and Reset AVR (`endConn`) Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Exits STK500 programming mode and resets the AVR to execute the newly flashed firmware. This function is called after a successful flash and verification. ```c #include "avr_pro_mode.h" void flashTask(void) { setupDevice(); // ... write and verify flash ... endConn(); // Calls: extProgMode() → STK_LEAVE_PROGMODE (0x51) // resetMCU() → resets AVR to run new firmware // Expected log: I avr_pro_mode (extProgMode:136) Exiting Pro Mode } ``` -------------------------------- ### Hardware Reset AVR MCU Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Performs a double-pulse LOW on the RESET pin (GPIO19) to ensure the AVR bootloader is in a ready state for the STK500 handshake. The timing adheres to AVR bootloader entry requirements. ```c #include "avr_pro_mode.h" // Manually reset the AVR before a programming session resetMCU(); // Sequence: HIGH → LOW(1ms) → HIGH(100ms) → LOW(1ms) → HIGH(100ms) // Expected logs: // I avr_pro_mode (resetMCU:79) Starting Reset Procedure // I avr_pro_mode (resetMCU:89) Reset Procedure finished ``` -------------------------------- ### Delete File from SPIFFS using cURL Source: https://context7.com/esp32-musings/ota_update_avr_using_esp32/llms.txt Use cURL to send a POST request to the ESP32's file server to delete a file from SPIFFS. ```bash # Delete a file from SPIFFS curl -X POST http://192.168.43.82/delete/blink.hex ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.