ESP32-S3 rebooting to DFU

rtborg
Posts: 67
Joined: Wed Oct 23, 2019 6:15 am

ESP32-S3 rebooting to DFU

Postby rtborg » Mon Nov 28, 2022 9:52 am

Using the default bootloader, is it possible to reboot to DFU?

The case is that I need to have the option of invoking the DFU mode without having to press any buttons.

chegewara
Posts: 2207
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP32-S3 rebooting to DFU

Postby chegewara » Mon Nov 28, 2022 2:38 pm


rtborg
Posts: 67
Joined: Wed Oct 23, 2019 6:15 am

Re: ESP32-S3 rebooting to DFU

Postby rtborg » Mon Nov 28, 2022 4:00 pm

From what I can understand, the docs say that bootloader mode can only be entered via the button press combination. So I can either use TinyUF2, which supports that mode, or use external circuit to force the boot pin low - is that correct?

chegewara
Posts: 2207
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP32-S3 rebooting to DFU

Postby chegewara » Mon Nov 28, 2022 5:15 pm

In theory you should be able to install tinyusb with DFU interface to do it without buttons, but i didnt test it with S3 yet (on S2 it worked).

In addition to the docs from my previous post, you have to burn efuse USB_PHY_SEL to make it works with buttons.

On S3 DFU is not that user friendly as on S2, but we have JTAG over USB enabled by default.

rtborg
Posts: 67
Joined: Wed Oct 23, 2019 6:15 am

Re: ESP32-S3 rebooting to DFU

Postby rtborg » Mon Dec 05, 2022 3:16 pm

I've compiled tinyuf2 for my board, flashed it and the board appears as a storage drive.

Now I'm trying to build and flash a simple blinky app, using the partition table provided by tinyuf2, `and idf.py app-flash`. There are some things which are not clear to me:
- tinyuf2 exposes the board as a storage device, hence idf.py can't find it (it's not a serial port)
- I can force the board in bootloader mode using reset and GPIO0 combination, and then flash a Blinky app using `idf.py app-flash`, however that seems to erase tinyuf2

I need to be able to use idf.py for uploading code - is that possible? Also, the storage functionality is not needed - can it be removed?

chegewara
Posts: 2207
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP32-S3 rebooting to DFU

Postby chegewara » Mon Dec 05, 2022 10:59 pm

As you already know tinyuf2 is not what you want.
Read more about adafruit implementation :
https://github.com/adafruit/tinyuf2#features
You can use it, but you have to embed it in every firmware you want to flash that way.

My suggestion was to use DFU, which is not the same as tinyuf2 (its not easy, since espressif does not provide implementation for it in tinyusb component). Same situation, it has to be embed in every firmware.

Probably it will be easier to just use idf.py. On board with CP210x it does not require to use buttons and when you want to use native USB pins, well, you will need reset and boot buttons.

rtborg
Posts: 67
Joined: Wed Oct 23, 2019 6:15 am

Re: ESP32-S3 rebooting to DFU

Postby rtborg » Tue Dec 06, 2022 8:17 am

You're right, I am back into looking for a way to reboot to bootloader from application, as I don't have any buttons exposed. Probably an one-shot timer could do the job - it would keep GPIO0 low for a period of time, starting from before issuing `esp_restart()` from the application.
The period can be made long enough to ensure the chip has started.
The above will not work if `esp-restart()` is not equivalent to pressing the reset button.

chegewara
Posts: 2207
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP32-S3 rebooting to DFU

Postby chegewara » Tue Dec 06, 2022 5:05 pm

Its not going to work, because level of GPIO0 wont survive the reset. Another thing is that timer state is reset on reboot.
As far as i remember adafruit is using external RC elements to make it works with tinyuf2, but i cant help much in this matter.

rtborg
Posts: 67
Joined: Wed Oct 23, 2019 6:15 am

Re: ESP32-S3 rebooting to DFU

Postby rtborg » Thu Dec 08, 2022 1:50 pm

Sorry, I didn't explain clear what I was thinking of doing.

When I need to reboot to DFU, I will use a GPIO (not GPIO0) to trigger an external circuit, which will then pull GPIO0 down for a period of time (not sure how long yet). After triggering, I'll issue an `esp_restart()`, and the chip wil reset, then come out of reset with GPIO0 still being pulled low. The circuit can be as simple as a diode, capacitor and N-channel MOSFET.

I'll give it a try and post the results.

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-S3 rebooting to DFU

Postby ESP_Sprite » Fri Dec 09, 2022 12:46 am

Note that the S2 and S3 actually have a bit to specifically reset into download mode - it's used for the ROM CDC driver in ESP-IDF. If you select 'cdc-acm' as a console, I think it does this by default. If you need to do this yourself, look here. Note that you do need to burn a fuse on the S3 to use the USB-OTG peripheral (and not USB-serial-JTAG) when in download mode to support DFU.

Who is online

Users browsing this forum: No registered users and 112 guests