This tutorial is for advanced users. Following along may result in soft-bricking your board.
The Arduino UNO R4 WiFi has two different microcontrollers onboard, the Renesas RA4M1 and the ESP32-S3.
By default, the ESP32-S3 module acts as a serial bridge, handling the connection to your computer. It also handles the rebooting of the main MCU, the Renesas RA4M1 when it is needed, for example when receiving a new sketch and resetting.
On the UNO R3, the ATMEGA16U2 serves the same purpose, but the onboard ESP32 module is a more advanced SoC, adding Wi-Fi® & Bluetooth® connectivity to the board.
The UNO R4 WiFi also exposes the ESP32's data lines, so that you can program the ESP32 directly. These data lines are exposed by a 3x2 header at the top of the board, or through pads on the bottom side.
Please note that the ESP32 has a default firmware installed, which is set to communicate with the RA4M1 chip. Any direct programming of the ESP32 will override that firmware and the communication between the chips may be disrupted until the default firmware is restored.
We don't provide any custom firmware in this tutorial. If you flash a firmware that doesn't enable a serial-usb-bridge between two microcontrollers you will lose most of the board's functionality!
In order to flash custom firmware to the ESP32-S3 we need to put the chip in download mode by shorting the download pin and GND. The download pin can be found on the 3x2 header at the top of the board or on the downside using the exposed pads.
The easiest way is to use a female-to-female cable and short the pins at the top of the board. At this point, the board has to be powered off. Once the pins are shorted you can connect the board to your PC and remove the jumper wire. If you check the device name it should have changed to: USB JTAG/serial debug unit.
Windows
MacOS
Linux
lsusb
.Once the chip is set to the right mode we use esptool to flash custom firmware to the board. For this to work you will need to download and install Python, which you can then use to install esptool using a simple command. Verify that python is installed by opening your terminal and write
pip3
. You should see a list of commands shown in the terminal. Once you have confirmed that it's installed properly install esptool by typing:1pip3 install esptool
Next,
esptool.py
should be added to your PATH so you can run it from anywhere, instead of navigating to the installation folder each time. The PATH variable allows you to run commands and programs from any location on your computer without having to specify the full path to the executable file. This is done differently depending on your operating system, you can read more about it here. Flashing a new firmware is done in two steps, first erasing the firmware currently on the module and then flashing the new one. Once everything is set up it's just a matter of running the following two commands:
To erase the flash memory run:
1esptool.py --chip esp32s3 --port <yourPort> erase_flash
To upload firmware run:
1esptool.py --chip esp32s3 --port <your port> write_flash -z 0 <yourCustomFirmware.bin>
Please note that we don't provide any custom firmware in this tutorial. If you flash a firmware that doesn't enable a serial-usb-bridge between two microcontrollers you will lose most of the board's functionality!
Restoring the default firmware varies slightly depending on which operating system you are using.
Windows
Download the latest firmware and unzip it.
Unplug all the USB devices except for your UNO R4 WiFi.
Open the update.bat file - if a warning dialog appears, click on "More info" and then "Run anyway".
Follow the steps inside the terminal and select your board from the device list (if you still see more than one device after unplugging everything apart from the board, check under Windows' Device Manager)
Once done, unplug the board, connect it again and you should have the default firmware installed again.
MacOS
Download the latest firmware and unzip it.
Unplug all the USB devices except for your UNO R4 WiFi.
Right-click on the folder, select "New terminal at folder" (you might find it under "Services"), and launch the following commands:
1chmod a+x update.command
1sudo xattr -d com.apple.quarantine bin/espflash
1sudo xattr -d com.apple.quarantine bin/unor4wifi-reboot-macos
1./update.command
Follow the steps inside the terminal and select your board from the device list, it is listed as /dev/tty.usbmodem141301 - USB JTAG_serial debug unit.
Once done, unplug the board, connect it again and you should have the default firmware installed again.
Linux
Download the latest firmware and unzip it.
Unplug all the USB devices except for your UNO R4 WiFi.
Right-click on the folder, select "Open in Terminal" and launch the following command:
1sudo ./update.sh
Follow the steps inside the terminal and answer yes to the first question, no to the second.
Once done, unplug the board, connect it again and you should have the default firmware installed again.
Alternatively you can also repeat Step 1 and Step 2 using the
.bin
file found inside the .zip
file using the esptool.These are the steps for uploading firmware to your ESP32-S3. This process is not suitable for beginners as it easily breaks your board. Unless the new firmware does not implement a new serial bridge, a lot of functionality is lost. But for those who know what they are doing, it opens up many new possibilities as you can rewrite the firmware on the ESP32 to fit your custom needs.