esp32 s2 DFU update
esp32 s2 DFU update
Recently i am playing a lot with native USB on S2 and i have had some success with running MSC, CDC, DFU and webUSB.
Making more researches i found this website:
https://devanlai.github.io/webdfu/dfu-util/
and i discovered it it is possible to DFU update esp32S2 without any extra preparations. All we have to do is to connect it with native USB to PC, enter bootload mode with buttons, input espressif vendor ID (0x303a) and connect. Then just download new firmware.
There is one extra step required on linux, its udev rules, which is described here:
https://docs.espressif.com/projects/esp ... s/dfu.html
It is not big deal because we still need 2 buttons on board to enter bootload mode, but with tinyusb component and implemented USB DFU it is no longer required to have boot and RST buttons. That also means it is possible to OTA update without need to have extra partitions, just one, factory partition is enough.
What do you think, is it useful? Is it a reason to have S2?
Making more researches i found this website:
https://devanlai.github.io/webdfu/dfu-util/
and i discovered it it is possible to DFU update esp32S2 without any extra preparations. All we have to do is to connect it with native USB to PC, enter bootload mode with buttons, input espressif vendor ID (0x303a) and connect. Then just download new firmware.
There is one extra step required on linux, its udev rules, which is described here:
https://docs.espressif.com/projects/esp ... s/dfu.html
It is not big deal because we still need 2 buttons on board to enter bootload mode, but with tinyusb component and implemented USB DFU it is no longer required to have boot and RST buttons. That also means it is possible to OTA update without need to have extra partitions, just one, factory partition is enough.
What do you think, is it useful? Is it a reason to have S2?
-
- Posts: 9764
- Joined: Thu Nov 26, 2015 4:08 am
Re: esp32 s2 DFU update
Cute, but note it's limited to Chrome... other webbrowsers do not support WebUSB afaik. (Also, do note you still need the buttons in case the firmware crashes before it is able to enable DFU.)
Re: esp32 s2 DFU update
Are you sure espressif want to sell this product?
Thats true mozilla is not supporting webusb, thats true you have to add udev on linux, and in addition on windows you have to install driver for device with VID and PID, but all of this is not esp32 dependent. Thats is also not a reason to not show it as option.
As a bonus, for those who would like to try few USB devices at the same time on esp32s2, not espressif because they seems not to be interested, here is dfu prepared bin, ready to install from mentioned website. In that bin is enabled webUSB echo terminal, CDC which can be tested with putty or other serial terminal, MSC 1.5MB ram disk.
Because of ram disk which is using PSRAM only wrover modules are supported. If someone with S2 wroom module would like to test it too i can build another demo.
Thats true mozilla is not supporting webusb, thats true you have to add udev on linux, and in addition on windows you have to install driver for device with VID and PID, but all of this is not esp32 dependent. Thats is also not a reason to not show it as option.
Are you sure? You can always unplug device and plug it in one more time.ESP_Sprite wrote: Also, do note you still need the buttons in case the firmware crashes before it is able to enable DFU.)
As a bonus, for those who would like to try few USB devices at the same time on esp32s2, not espressif because they seems not to be interested, here is dfu prepared bin, ready to install from mentioned website. In that bin is enabled webUSB echo terminal, CDC which can be tested with putty or other serial terminal, MSC 1.5MB ram disk.
Because of ram disk which is using PSRAM only wrover modules are supported. If someone with S2 wroom module would like to test it too i can build another demo.
- Attachments
-
- dfu.zip
- (122.05 KiB) Downloaded 718 times
Re: esp32 s2 DFU update
This is some cool project, built with ATTiny85 which is using webUSB protocol:
https://github.com/sowbug/weblight
https://github.com/WICG/webusb
https://github.com/sowbug/weblight
https://github.com/WICG/webusb
Re: esp32 s2 DFU update
Could you have a dfu second stage bootloader which tries to enumerate then if it fails goes to normal boot?
Re: esp32 s2 DFU update
I cant fully answer that question yet, but this question made me thinking. How dfu really works, because for example nordic is not using partitions. I did some test and looks like dfu is writing 1 merged file, bootloader + app, from address 0x0. That allows to update bootloader and partitions table fairly easy (tested with hello world example). That also leads to conclusion that device will be bricked if you dont have option to enter bootloader mode with buttons and something will disturb dfu update.
There is option to use software dfu. It will basically register device with USB dfu descriptor, but you have control over data and you can perform just regular OTA update. It is just theory, because i didnt test it yet.
There is option to use software dfu. It will basically register device with USB dfu descriptor, but you have control over data and you can perform just regular OTA update. It is just theory, because i didnt test it yet.
-
- Posts: 9764
- Joined: Thu Nov 26, 2015 4:08 am
Re: esp32 s2 DFU update
Wrt how dfu supports partitions: note we don't upload a raw binary over DFU, it's a bit more complicated and the ROM does a bunch of on-the-fly interpreting of what's uploaded before it does any writing. Documentation should be coming at some point, but here's a hint:
Also, sorry, my 'cute' may have been misunderstood, it was not sarcastic and I do think it's an interesting use of the WebUSB technology for sure. I just think that the inherent limitations of WebUSB in various OSses/browsers hinder general adoptation a bit.
Code: Select all
jeroen@laptop:idfproject/build$ file blink.dfu
blink.dfu: ASCII cpio archive (SVR4 with no CRC)
Re: esp32 s2 DFU update
Like they say, where one doors get closer other doors get opened.ESP_Sprite wrote: Also, sorry, my 'cute' may have been misunderstood, it was not sarcastic and I do think it's an interesting use of the WebUSB technology for sure. I just think that the inherent limitations of WebUSB in various OSses/browsers hinder general adoptation a bit.
I agree there is a lot limitations on personal computers, like support on chromium family browsers, requirements to install drivers with VID and PID to support webUSB or DFU on windows (here espressif could help to make drivers), reuirements to add udev rules in linux, but there is a lot use cases where this can be used. Lets think about device that does not have built in wifi. It will be possible to update it, not only firmware, but also to change set of instructions by not qualified person, with android tablet or smartphone. No need to install drivers, all android devices are preinstalled with chrome browser. Just plug n play.
Sure, it was possible before with old esp32 but requires cp210x or similar usb to uart IC, now it is part of esp32 and much much cheaper and easier to use. I tested only serial example, but you can easy implement full AT set, upload spiffs or ffat partition and many more. I can find teens examples how to use it and still i feel like my mind is not open wide enough to make full usage of it.
Re: esp32 s2 DFU update
A contribution to this nice community: a way to flash the ESP32-S2 directly from a browser exploiting WebUSB. Built specifically for the ESP32-S2. It automatically switches the dfu mode without the need to connect twice.
dfu.stetelthings.com
You have to place the ESP32-S2 in boot mode (GPIO0 when connecting or reseting) connect it to the computer and you're good to go.
I must admit, as sprite_tm pointed out, support is basically limited to Chromium based browsers (Chrome, Chromiums, Opera and the new Edge) and also that only on the OS X it is plug'nplay. On windows you have to install an .inf file that makes the usb device available to WebUSB (available on the flashing site) while on Linux you have to grant access.
Please try it out and let me know what you like, what must be better or problems you faced. Any feedback is welcome.
(There is an example dfu bin file with a Rainmaker demo you could use).
dfu.stetelthings.com
You have to place the ESP32-S2 in boot mode (GPIO0 when connecting or reseting) connect it to the computer and you're good to go.
I must admit, as sprite_tm pointed out, support is basically limited to Chromium based browsers (Chrome, Chromiums, Opera and the new Edge) and also that only on the OS X it is plug'nplay. On windows you have to install an .inf file that makes the usb device available to WebUSB (available on the flashing site) while on Linux you have to grant access.
Please try it out and let me know what you like, what must be better or problems you faced. Any feedback is welcome.
(There is an example dfu bin file with a Rainmaker demo you could use).
Re: esp32 s2 DFU update
Hi, author of the webdfu proof-of-concept code here.
I just want to second rainman's suggestion to add a WCID descriptor to the ROM DFU bootloader so that Windows will automatically install a generic WinUSB driver. This would be a huge step forward in usability for browser based IDEs and demos that would otherwise require the user to install a driver manually. (Yes, there's a far bit of trust involved with flashing firmware from the web, but at least that's restricted to doing terrible things on your $10 devkit and whatever it can access, as opposed to doing terrible things on your workstation directly).
I just want to second rainman's suggestion to add a WCID descriptor to the ROM DFU bootloader so that Windows will automatically install a generic WinUSB driver. This would be a huge step forward in usability for browser based IDEs and demos that would otherwise require the user to install a driver manually. (Yes, there's a far bit of trust involved with flashing firmware from the web, but at least that's restricted to doing terrible things on your $10 devkit and whatever it can access, as opposed to doing terrible things on your workstation directly).
Who is online
Users browsing this forum: Bing [Bot] and 66 guests