I am having problems uploading sketches and need help.
I can upload sketches to two XIAOs without any problem, but I can’t upload to one of them. So I am trying to write the bootloader according to “Q3: I want to reflash the bootloader with factory firmware” on the Wiki, but it looks like the screenshot below and I can’t write it. It seems that the connection is made but the write timeout has occurred.
PJ, thanks for the reply.
ArduinoIDE is closed. No other devices are using this port. The connection to the port seems to succeed, but the write times out.
I have over 20 XIAOs and have unbricked many times, but this is a tough problem.
Hi there,
I agree, the connection looks ok, What about speed, Try lower baud rate
or flash with esptool.py ```
I was able to read a ESP32C6 with this command line below, you can flash that way also, I had to drop the speed to get a successful read to 230400
“esptool.py -p com4 -b 921600 read_flash 0 0x400000 flash_dump.bin”
so try esptool.py
HTH
GL PJ
I tried using esptool.py, but it still doesn’t work. I am going in circles.
PS C:\ESP_TOOLS\EspRFTestTool_v3.6_Manual\tool\esptool> python esptool.py -p com5 -b 9600 flash_id
esptool.py v4.5-dev
Serial port com5
Connecting...
Failed to get PID of a device on com5, using standard reset sequence.
.
A serial exception error occurred: Write timeout
Note: This error originates from pySerial. It is likely not a problem with esptool, but with the hardware connection or drivers.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
PS C:\ESP_TOOLS\EspRFTestTool_v3.6_Manual\tool\esptool>
I also tried ESP-IDF, but the result is the same. It does not seem to be able to access Flash. The Blink sketch I uploaded just before the problem occurred is working, so it appears the device is not dead.
It doesn’t look like an easy solution.
Hi Seeed_Seraphine,
The screenshot in post 1/12 is the result of trying to write using EspRSTestTool.
I changed BSP to 3.0.0-rc1 and checked with a simple sketch with just blink and Serial.print(). However, there is a problem that the sketch does not work on battery power. I changed the sketch several times and uploaded it, but when I noticed it was bricked.
I changed BSP back to 2.1.1 and the problem persisted. I did the same with two other XIAOs as well, and these two uploaded without any problems.
Could this be caused by the code containing while(!serial) not being removed?
Do you remember roughly how many times you uploaded the code before it bricked? I’d like to see if I can reproduce this situation
There is no While(!Serial) in the sketch.
(I found that using printf() instead of Serial.print() works on battery power.)
Just before bricking, the following sketch was written. It was written at most a few times.
#define LED D10
void setup() {
Serial.begin(115200);
pinMode(LED, OUTPUT); // LED
// Serial.println("END of SETUP");
printf("END of SETUP\n");
}
void loop() {
digitalWrite(LED, LOW);
// Serial.println("serial print");
printf("serial print\n");
delay(100);
digitalWrite(LED, HIGH);
delay(500);
}
The battery or the charging circuit will give a voltage of about 2V on A0/D0(GPIO2).
It seems that the level of A0/D0(GPIO2), which is Strapping Pin, was determined to be HIGH and did not enter boot mode. When the resistors for voltage divider was removed, writing to Flash became possible.
Since the threshold voltage that is judged as HIGH is subtle, it seems to have been just barely working so far; A0/D0(GPIO2) is not suitable as a battery voltage measurement port. This method is also described in the ESP32C3 Wiki, and should be noted when using Strapping Pins (A0/D0,A1/D1,D8,D9).
On the other hand, the following documents states that GPIO2 must be set to 1 when writing code to Flash.
1.“ESP32-C3 Series Datasheet Version, 2.4 Strapping Pins, able 4: Strapping Pins” 2.“Technical Reference Manual 7.2, Boot Mode Control, Table 7-2. Boot Mode Control”
However, as a result of experiments, it is possible to write to Flash when GPIO2 is LOW, but not when GPIO2 is HIGH.
Note that the document description and the experimental results do not match.