Using SAMD21 to flash ESP32

marchingband
Posts: 46
Joined: Wed Mar 13, 2019 9:20 pm

Using SAMD21 to flash ESP32

Postby marchingband » Fri Apr 22, 2022 3:47 am

I have a SAMD21 devboard which I would like to use to flash my ESP32 WROVER module.
My computer connects to the SAMD21 via usb, and I can use it to receive logs from my ESP32 over a UART connection.
Unfortunately when I run esptool.py, the connection fails, I get a timeout waiting for packet header.

I am using 115200 8N1, and the ESP32 is in bootloader mode, I receive rst:0x1 (POWERON_RESET),boot:0x27 (DOWNLOAD_BOOT(UART0/UART1/SDIO_REI_REO_V2))

My code on the SAMD21 is very simple

Code: Select all

#include <Arduino.h>

void setup()
{
    Serial.begin(115200);
    Serial1.begin(115200);
}

void loop()
{
    while(Serial.available())
    {
        Serial1.write(Serial.read());
    }
    while(Serial1.available())
    {
        Serial.write(Serial1.read());
    }
}
In this framework Serial1 is the UART, and Serial is the USB serial.

Is there something I am not understanding in the protocol between esptool and the FTDI-USB chip on a typical ESP32 dev board? I assumed it was a simple serial connection. I have read all the relevant docs, and am not sure how to proceed.

(The reason I want to achieve this is, I produce a dev board that already has an ESP32 WROVER, and a SAMD21, but no FTDI chip, and I would like to make it easier for my users to flash and debug custom code, although there is no room for an FTDI chip on the board, there is already the SAMD21, and I hope I can put it to use in this way)

marchingband
Posts: 46
Joined: Wed Mar 13, 2019 9:20 pm

Re: Using SAMD21 to flash ESP32

Postby marchingband » Fri Apr 22, 2022 4:15 am

It's also strange that, although my terminal emulator (Cool Term) establishes communication with the SAMD21, the esp-idf monitor does not.

My command is idf.py -p /dev/cu.usbmodemFA131 -b 115200 monitor

The monitor runs, but does not get any logs back from the ESP32, via the SAMD21.

marchingband
Posts: 46
Joined: Wed Mar 13, 2019 9:20 pm

Re: Using SAMD21 to flash ESP32

Postby marchingband » Sun Apr 24, 2022 5:31 pm

Is it possible to pass flags to esptool.py to fix the baud rate throughout the transaction, and/or limit the way it passes data, perhaps to slow it down, so the Arduino libraries can handle the transfer more easily?

marchingband
Posts: 46
Joined: Wed Mar 13, 2019 9:20 pm

Re: Using SAMD21 to flash ESP32

Postby marchingband » Sun Apr 24, 2022 5:32 pm

Also if I should delete this and repost in a different section of the forum let me know :)

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

Re: Using SAMD21 to flash ESP32

Postby chegewara » Mon Apr 25, 2022 10:31 am

1. your device is not and probably never was in download mode:
rst:0x1 (POWERON_RESET),boot:0x27 (DOWNLOAD_BOOT(UART0/UART1/SDIO_REI_REO_V2))
this means it just got reset
2. read this closely and you will find solution for few problems you have, including missing logs after reset:
https://docs.espressif.com/projects/esp ... ction.html


A tip: GPIO12 and GPIO15, and no GPIO0 in "boot: 0x27"

marchingband
Posts: 46
Joined: Wed Mar 13, 2019 9:20 pm

Re: Using SAMD21 to flash ESP32

Postby marchingband » Tue Apr 26, 2022 4:50 pm

@chewarga I am sure the chip is in bootloader mode. I very often use a usb-ftdi module to flash my bare ESP32s, and this is the same log I always receive
`rst:0x1 (POWERON_RESET),boot:0x27 (DOWNLOAD_BOOT(UART0/UART1/SDIO_REI_REO_V2))`
the next line of the log explicitly says
`waiting for download`

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

Re: Using SAMD21 to flash ESP32

Postby chegewara » Tue Apr 26, 2022 4:54 pm

Sorry, my mistake (i was sick and my brain stuck). GPIO0 == 0x10, and is set to low, so my bad.

The other part may be correct, because GPIO12 is flash voltage. and it wont get flashed with wrong voltage. I said it may be, and not it is, because you may have burned efuse or require to have GPIO12 high.
VDDSDIO has been enabled at 1.8V (due to MTDI/GPIO12, see above), but this flash chip requires 3.3V so it’s browning out.

marchingband
Posts: 46
Joined: Wed Mar 13, 2019 9:20 pm

Re: Using SAMD21 to flash ESP32

Postby marchingband » Tue Apr 26, 2022 4:57 pm

Oh that makes sense :) . Yes I always burn the fuse for flash voltage because my chip uses eMMC driver.

I posted the same question on Stack Overflow here https://stackoverflow.com/questions/719 ... ing-samd21
Another user had success using the same steps I used. I think either one of my chips is damaged, or there is a difference in the USB driver being used on the SAMD21. This user used PlatformIO, with no additional libs, to compile the SAMD21 code. I don't know platformIO at all, so I was unable to determine if it uses TINYUSB like the SEEED XIAO dev board that I have uses, or a different lib.

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

Re: Using SAMD21 to flash ESP32

Postby chegewara » Tue Apr 26, 2022 5:31 pm

To confirm if it is problem with GPIO12 just dont enter download mode and see what logs show.
You should see different logs for empty flash and flash with wrong voltage because of GPIO12.

marchingband
Posts: 46
Joined: Wed Mar 13, 2019 9:20 pm

Re: Using SAMD21 to flash ESP32

Postby marchingband » Tue Apr 26, 2022 6:45 pm

Yes I've done that and I get normal logs. The same ESP32 chip flashes normally with a usb-ftdi module, so the issue is either the XIAO board, or the USB drivers which their BSP provides

Who is online

Users browsing this forum: Basalt and 345 guests