Fixing Bricked Boards

In some instances, the board may no longer function as original. For example, malfunctions could be due to numerous issues. In some cases, the board can be reset to factory image, or a newly updated firmware can be applied. The steps to recover or load a new firmware will be outlined in this post. Additionally, we will go over some quick tests you can use to verify the board’s functionality.

Acquiring the firmware

The first step is to head over to the repository and download the latest version. If possible, try to use a full release as the pre-releases may still be undergoing tests.

In the example above, we will install the Release v0.2 firmware on the board. Then, download the bin file to the computer. Once the file has been downloaded, it is highly recommended to run a SHA256sum on the bin file to verify it has been downloaded correctly.

On Windows, run the following command:

C:> certutil -hashfile <firmware.bin> SHA256

On Mac, run the following command:

% shasum -a 256 <firmware.bin>

On Linux, run the following command:

$ sha256sum <firmware.bin>

Ensure the output of the sha256 matches what is displayed on the repo website.

Uploading the firmware

Head over to Adafruit’s ESPTool website (https://adafruit.github.io/Adafruit_WebSerial_ESPTool/). The board needs to be placed into the native boot state to upload the new firmware. While holding down the ‘BOOT’ button, press the ‘RESET’ button for 5 seconds and release. Finally, release the ‘BOOT’ button.

Click on ‘Connect’ in the top right corner. A window will now popup with a list of serial devices; select ‘ESP32-S2 (COM5)’. The COM port number might be different on your computer. Once the device has been connected to the website, click on ‘Erase’ and confirm.

When the erasing process is complete, click on ‘Choose a file…’ on the topmost button selection. Locate the download firm and click on open. The button will now change to the file name. Click on ‘Program’ to start the programming process.

The process will be complete when you get a notification to reset your device.

Toggling between USB and UART

For boards equipped with a toggle switch for USB and UART mode, make sure to unplug the USB cable from the USB port, move the selector to the intended mode, and then plug the USB cable back into the USB port.

If the board is in USB mode, make sure to unmount or eject the CIRCUITPY drive before unplugging the USB cable.

CircuitPython Test

Before going to the Web IDE page, ensure that the board has been toggled into USB mode from the switch. For Windows users, check the ‘Device Manager’ and see if a ‘USB Serial Device (COM4)’ appears as you plug in the board to the USB port.

Verify that the ‘CIRCUITPY’ drive is available in the ‘File Explorer’.

The first test that should be done is using CircuitPython. First, proceed to the Web IDE and click on ‘Connect’ on the top menu bar. Next, select ‘CircuitPython CDC control (COM4)’ and click on ‘Connect’.

Once the board has been connected, the serial display on the bottom of the IDE will be populated from the board’s output. Press the ‘Run’ button to enter the REPL mode. The serial console should indicate the version of CircuitPython and the name of the board.

You can use the web IDE to load the initial code for testing. The sample code below can be cut and pasted from the Git repo (https://raw.githubusercontent.com/BrainBoardzProject/CodeShare/main/QA/test1.py) into the Web IDE.

“””
Author: Salim Haniff
Email: salimwp@gmail.com
Description: Basic QA test 1
“””
import time
import board
import busio
import array
import audiobusio
import audiocore
import digitalio

uart = busio.UART(board.IO43, board.IO44, baudrate=9600)
led = digitalio.DigitalInOut(board.IO42)
led.direction = digitalio.Direction.OUTPUT
a = audiobusio.I2SOut(board.IO45, board.IO35, board.IO41)

while True:
uart.write(bytearray(b’Hello from UART’))
print(“Hello from USB”)
led.value = True
time.sleep(2)
led.value = False
time.sleep(2)

Press ‘Upload’ and locate the code.py file on D:\CIRCUITPY\code.py. Then, press’ Upload’ again to commit the upload to the board. Finally, press the ‘REPL’ button to exit REPL.

After some time, the board should be printing serial statements to the IDE serial output.

Check to see if the LED is blinking. If there are no errors on the serial console, then the first test works.

Close the Web browser to ensure that no conflicts occur with further tests.

MU Editor

The test system is currently using Mu-Editor-Win64-1.1.0b6.

Startup MU Editor and verify that the MU Editor displays CircuitPython board has been detected. Click on ‘OK’.

Click on ‘Serial’ on the top menu bar. Observe for the presence of a serial output like the one observed on the Web IDE.

Press the left mouse button on the CircuitPython REPL pane and press the keyboard combination CTRL+C followed by ENTER. The IDE should be in REPL mode. Enter a basic Python command like: print(‘Hello World’)

If the console outputs the above, then the first part of the MU test is complete.

Eject the CIRCUITPY drive and unplug the USB cable. Switch the board to UART mode and plug the cable back into the USB Port. Open Device Driver and verify that ‘USB-SERIAL CH340 (COM3)’ appears in the list.

If there is no device listed, verify that CH341SER.exe has been installed. Then, reinstall the driver, unplug and plug the USB cable again.

If there is an error message on MU, ignore it by clicking ‘OK. There will be another popup appearing indicating a new HL-340 device has been detected. Click on ‘OK’

Exit out of MU.

Arduino IDE

Startup the Arduino IDE. If this is the first time starting the Arduino IDE, the ESP32 packages need to be installed. Consult the following like for instructions https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html .

Once the installation of the boards is complete. Make sure to select the ESP32S2 Dev Module located under Tools -> Board -> (Under Board Manager…) ESP32 Arduino -> ESP32S2 Dev Module. The defaults are sufficient for the test.

Click on the Serial Plotter icon on the top right. Ensure that the baud rate is set to 9600 baud. The message ‘Hello from UART’ should appear.

Load the “WiFiScan” example located under File -> Examples -> WiFi -> WiDiScan .

Once loaded, click on the ‘Upload’ button. The Arduino status window will display the progress of the upload. The screenshot below shows a successful build.

Open the Serial Plotter again and change the speed on the bottom to 115200. In a few seconds, the following output should appear of the AP points located nearby.

If the screen above is shown, the UART test is complete, and you are ready to use the board.

Leave a Reply