Esp32-s2 native USB burning tinyuf2 bootloader plus circuitpython

Time:2021-10-1

summary

The most desirable improvement of esp32-s2 is that it supports USB natively, that is, it has a full speed USB OTG peripheral with integrated transceiver, which conforms to USB 1.1 specification and has a theoretical speed of 1.5m/s. If it is properly used, it will be a great progress.

At present, esp32-s2 has been supported by circuitpython. The content of this article is about what I made after some data query and sortingUse native USB interface onlyTo burnTinyUF2 bootloaderplusCircuitPythonMethod summary.

The operations listed in this paper are on a small development board equipped with esp32-s2-wrover moduleESP32-S2-Saola-1The operating system is windows10, and other modules and development boards of different models need to be adapted accordingly, which will not be described separately below.

Connect a USB female port directly connected to the chip on the development board

  1. There is no USB interface directly connected to esp32-s2 on the esp32-s2-saola-1 development board, which needs referenceTechnical specification for esp32-s2-wrover module (PDF)MediumPin definitionTo determine which pins the USB OTG is led out from, you can also have a direct lookSchematic diagram of peripheral design

image

image

  1. The whole four wire USB type-C female port is welded to the corresponding interface. Of course, other USB interface models are similar.

image

Set esp32-s2 to bootloader boot mode

Refer to the in the esp32-s2 official API guideUpgrading device firmware via USBChapter, after connecting to the PC through the native USB interface, press and hold the boot key while pressing the reset key, and then release the boot key to make the esp32-s2 chip in the bootloader boot mode. At this time, you can view the new USB serial device in the windows device manager.

image

Burn tinyuf2 into the flash of esp32-s2 through esptool

  1. Ensure that Python 3.4 or later is installed, enter the CMD command prompt window, and enter:
pip install esptool
  1. After installing esptool, enter the following command to erase flash:
esptool -p com9 --after no_reset erase_flash

--after no_resetThe key here is to specify that after the operation of esptool.py is completed, the chip will not be reset, but will be left in the bootloader boot mode. The execution results are as follows:

>esptool -p com9 --after no_reset erase_flash
esptool.py v3.1-dev
Serial port com9
Connecting...
Detecting chip type... ESP32-S2
Chip is ESP32-S2
Features: WiFi, ADC and temperature sensor calibration in BLK2 of efuse
Crystal is 40MHz
MAC: xx:xx:xx:xx:xx:xx
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 16.3s
Staying in bootloader.
>
  1. Connect here:github TinyUF2Download the corresponding development board modeltinyuf2-espressif_saola_1_wrover-0.5.1.zipThe file to local and then unzip.


    image

  2. Enter the command in CMD to enter this file path, for example:

Please incd /dEnter the path of the folder you extracted correctly

cd /d D:\Users\Wind\esp\tinyuf2-espressif_saola_1_wrover-0.5.1
  1. reference resourcesEsp32s2 description document of tinyuf2Enter the following command in CMD to burn it into flash:
esptool --chip esp32s2 -p com9  -b 460800 --before=default_reset --after=no_reset write_flash --flash_mode dio --flash_freq 80m --flash_size 4MB 0x8000 partition-table.bin 0xe000 ota_data_initial.bin 0x1000 bootloader.bin 0x2d0000 tinyuf2.bin

If the burning is completed correctly, the execution results are as follows:

D:\Users\Wind\esp\tinyuf2-espressif_saola_1_wrover-0.5.1>esptool --chip esp32s2 -p com9  -b 460800 --before=default_reset --after=no_reset write_flash --flash_mode dio --flash_freq 80m --flash_size 4MB 0x8000 partition-table.bin 0xe000 ota_data_initial.bin 0x1000 bootloader.bin 0x2d0000 tinyuf2.bin
esptool.py v3.1
Serial port com9
Connecting...
Device PID identification is only supported on COM and /dev/ serial ports.

Chip is ESP32-S2
Features: WiFi, ADC and temperature sensor calibration in BLK2 of efuse
Crystal is 40MHz
MAC: xx:xx:xx:xx:xx:xx
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00001000 to 0x00006fff...
Flash will be erased from 0x002d0000 to 0x002effff...
Compressed 3072 bytes to 136...
Wrote 3072 bytes (136 compressed) at 0x00008000 in 0.1 seconds (effective 446.1 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 31...
Wrote 8192 bytes (31 compressed) at 0x0000e000 in 0.1 seconds (effective 645.0 kbit/s)...
Hash of data verified.
Compressed 20832 bytes to 13005...
Wrote 20832 bytes (13005 compressed) at 0x00001000 in 0.4 seconds (effective 464.5 kbit/s)...
Hash of data verified.
Compressed 130736 bytes to 82339...
Wrote 130736 bytes (82339 compressed) at 0x002d0000 in 1.5 seconds (effective 677.7 kbit/s)...
Hash of data verified.

Leaving...
Staying in bootloader.

D:\Users\Wind\esp\tinyuf2-espressif_saola_1_wrover-0.5.1>
  1. Click the reset key on the development board to view a portable memory named saola1rboot and a disk drive named adafruit uF2 bootloader USB device in the local device manager list


    image


    image

Burn circuitpython firmware

1. Go toDownload page of esp32 on the official website of circuitpython, all esp32 development boards supported by circuit Python are here. There is no esp32-s2-saola-1 I use here, but a very similar one using the same esp32-s2-wrap module is found, i.eNanoESP32 S2 w/WROVER

2. Click in circuitpython 7.0.0-alpha. 6DOWNLOAD .UF2 NOWDownload to local

image

3. The last step is very simple. Copy it to saola1rboot mobile memory.

image

4. After the development board is automatically reset, you can view different portable memory and disk drive in the local device manager list, and add a USB serial device COM port.

image


image

5. Through the IDE supporting circuitpython, for exampleThonnyYou can program on this development board.

image

Switching method between modes

  1. After burning the circuitpython firmware, power on the development board again or press the reset key to enter the circuitpython mode.

  2. Press the reset key while holding down the boot key, and then release the boot key to enter the esp32-s2 bootloader mode, in which esptool can operate flash.

  3. Quickly press the reset key and then the boot key within 0.5 seconds to enter the tinyuf2 bootloader mode, from which the firmware supporting uF2 can be burned into flash.

Recommended Today

SQL exercise 20 – Modeling & Reporting

This blog is used to review and sort out the common topic modeling architecture, analysis oriented architecture and integration topic reports in data warehouse. I have uploaded these reports to GitHub. If you are interested, you can have a lookAddress:https://github.com/nino-laiqiu/TiTanI recorded a relatively complete development process in my hexo blog deployed on GitHub. You can […]