Update esp32s2 via USB drive

_Rens_
Posts: 25
Joined: Fri Mar 25, 2022 10:04 am

Update esp32s2 via USB drive

Postby _Rens_ » Wed Jun 29, 2022 12:26 pm

Hi all,

For a project i need to update the esp32s2 via a usb drive, (data pins connected to pin 19 and 20). For this i need to read a file from the usb drive and use this to update the code of the esp32s2.

I have tried the usb host examples from the esptinyusb library, but all fail to compile. Also the examples look like they have been writing for the espressif ide.

Does anybody have an example for the arduino ide that i can test and modify for the usb (drive) update?

zyghom
Posts: 6
Joined: Tue Oct 19, 2021 11:13 pm

Re: Update esp32s2 via USB drive

Postby zyghom » Sun Jul 03, 2022 7:04 am

all USB examples on my Arduino compile ok - check the settings again of your Arduino

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

Re: Update esp32s2 via USB drive

Postby chegewara » Tue Jul 05, 2022 9:52 am

I can confirm. With arduino-esp32 v2.0.3 host msc example can buid for both, S2 and S3.

_Rens_
Posts: 25
Joined: Fri Mar 25, 2022 10:04 am

Re: Update esp32s2 via USB drive

Postby _Rens_ » Wed Jul 06, 2022 3:12 pm

chegewara wrote:
Tue Jul 05, 2022 9:52 am
I can confirm. With arduino-esp32 v2.0.3 host msc example can buid for both, S2 and S3.
The msc example works for me to on the arduino-esp32 v2.0.3 after changing all LOGI to printf.

Which variant of the ota did you use for the updating?
I am currently testing with a mixture of the msc and sd_update example from arduino, but the update.h library can't use the fopen. I'll be looking into that later today.

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

Re: Update esp32s2 via USB drive

Postby chegewara » Thu Jul 07, 2022 1:41 am

Since i dont know ArduinoOTA library and even with arduino i prefer to use esp-idf API whenever i can, i made PoC app with esp-idf ota API.
It is simple code, with no error handling etc, but works good.

_Rens_
Posts: 25
Joined: Fri Mar 25, 2022 10:04 am

Re: Update esp32s2 via USB drive

Postby _Rens_ » Wed Jul 13, 2022 2:43 pm

I managed to get the code to begin and write the update to the partition, but no matter how i write it or what i do it keeps failing with the validation when calling esp_ota_end();

Anybody who knows what could be wrong? The update.bin file is created in the arduino ide by exporting it as a bin file. Reading the file works without any issue, but updating turned out to be more difficult.

The code i got until now: https://pastebin.com/q7yyES0v
Arduino esp32 v2.0.4
tinyusb v2.0.1

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

Re: Update esp32s2 via USB drive

Postby ESP_Sprite » Thu Jul 14, 2022 12:46 am

fgets() is used for strings and handles null bytes as the end of those. OTA files are binary; use fread() instead.

_Rens_
Posts: 25
Joined: Fri Mar 25, 2022 10:04 am

Re: Update esp32s2 via USB drive

Postby _Rens_ » Thu Jul 14, 2022 12:18 pm

Yes the code works now, i can update the esp32s2 now. The problem was indeed with fgets().

doctorsnap
Posts: 1
Joined: Wed Jan 11, 2023 3:23 pm

Re: Update esp32s2 via USB drive

Postby doctorsnap » Thu Jan 12, 2023 6:56 pm

The link seems to be out of date. Any chance for an update?
On the same problem now and getting all kinds of strange errors.

ESP32-S3-DevKitC-1 v1.1
Arduino esp32 v2.0.4
Tinyusb v2.0.1


_Rens_ wrote:
Wed Jul 13, 2022 2:43 pm
I managed to get the code to begin and write the update to the partition, but no matter how i write it or what i do it keeps failing with the validation when calling esp_ota_end();

Anybody who knows what could be wrong? The update.bin file is created in the arduino ide by exporting it as a bin file. Reading the file works without any issue, but updating turned out to be more difficult.

The code i got until now: https://pastebin.com/q7yyES0v
Arduino esp32 v2.0.4
tinyusb v2.0.1

Who is online

Users browsing this forum: No registered users and 27 guests