Tuesday 4 June 2024

Arduino Uno R4 Wifi Flash Reprogramming

Introduction 
This short post covers the reprogramming process on the Arduino Uno R4 WiFi (Arduino R4) firmware. The information in this post supplements the content available from the Arduino website with a few additional images. This post is targeted at installations using Windows machines.

The discussions in the Arduino forums for the detection and programming issues on the Arduino R4 can be viewed here.

Reason for Reprogramming the Arduino R4
During software development, a debug message in the Arduino IDE stated that a firmware update was available for the Arduino R4 WiFi. Using the steps below, the module type detected by the Arduino IDE was changed from an Arduino R4 to a WiFiduinoV2 following a firmware update. Reprogramming the
Arduino R4 resulted in incorrect operation.

Steps Resulting in Incorrect Firmware Programming
To begin, the computer running the Arduino IDE was connected to the Arduino R4. The Firmware Updater was selected from the Tools menu in the IDE.

Arduino IDE Displaying Correct Board Type
Arduino IDE Displaying Correct Board Type

The Arduino R4 was recognised in the IDE as the correct board.

Arduino IDE Firmware Updater
Arduino IDE Firmware Updater

The firmware update process was initiated in the IDE by clicking the Install button.

Arduino IDE Firmware Selection
Arduino IDE Firmware Selection

Firmware version 0.4.1 update on the Arduino R4.

Arduino IDE Firmware Update of Arduino R4
Arduino IDE Firmware Update of Arduino R4

After updating the Arduino R4 firmware, the IDE recognised the R4 as a WiFiduinoV2. This behaviour has been noted in Arduino forums.

Arduino IDE Detecting Different Board
Arduino IDE Detecting Different Board

When attempting to build using the WiFiduino2 this results in various compiler issues. The firmware needed reversion.

Arduino IDE Error with Incorrect Board Type
Arduino IDE Error with Incorrect Board Type

Attempting to repeat the flash process for the Arduino R4 firmware not possible as the board was not recognised as the correct type.

Arduino R4 not Recognised After Flash Update
Arduino R4 not Recognised After Flash Update

Using the ESP32 Flash Tool to Restore the Firmware
Fortunately, the Arduino website provides the firmware and tools to reprogram the ESP32 on the Arduino R4 board to restore the type. Some details are contained on the ESP32 Upload page and the main details are available on an associated page here.

Capture from Arduino Website
Capture from Arduino Website

The Arduino website describes the steps required to reprogram the Arduino R4 flash which, begins with removing the USB (power).
A jumper was fitted to the 3x2 header on the Arduino R4 board.

Arduino R4 WiFi Header with Jumper Fitted
Arduino R4 WiFi Header with Jumper Fitted

With the Arduino R4 board reconnected to the computer, the batch file for reprogramming was downloaded from the Arduino website here. When executing the batch file, there was an issue detecting the Arduino R4 board and the batch file operation was terminated.

The ESPflash tool was initiated from the command line following the settings shown on the Arduino website. The results of executing the ESPflash tool are listed below.

C:\********\unor4wifi-update-windows\unor4wifi-update-windows\bin>espflashwrite-bin -b 115200 0x0 
C:\********\unor4wifi-update-windows\unor4wifi-update-windows\firmware\UNOR4-WIFI-S3-0.4.1.bin
[2024-06-01T07:32:00Z INFO ] 🚀 A new version of espflash is available: v3.1.0
[2024-06-01T07:32:00Z INFO ] Serial port: 'COM8'
[2024-06-01T07:32:00Z INFO ] Connecting...
[2024-06-01T07:32:00Z INFO ] Using flash stub
Chip type:         esp32s3 (revision v0.2)
Crystal frequency: 40MHz
Flash size:        8MB
Features:         WiFi, BLE
MAC address:   <hidden>
[00:00:17] [========================================]    877/877     0x0 
C:\********\unor4wifi-update-windows\unor4wifi-update-windows\bin>

Closing the command line and opening the Arduino IDE, confirmed that the Arduino R4 board type was restored correctly. This process mentioned in this post was repeated numerous times during testing without any issues.

If the jumper was left in the Arduino R4 and restarted, the board type is detected as a Deneyap Kart G in the IDE.

Arduino IDE Detecting Deneyap Kart G Board
Arduino IDE Detecting Deneyap Kart G Board