ESP32-C3 Program Prevents Flashing.

jjd5th
Posts: 3
Joined: Tue Feb 22, 2022 2:49 am

ESP32-C3 Program Prevents Flashing.

Postby jjd5th » Tue Feb 22, 2022 3:08 am

Hello,

I am fairly new to using the ESP-32 C3 and have run into an issue while taking the Esspressif course for the ESP32. Specifically, I have uploaded my copy of the iBeacon program through VSCode, which was successfully uploaded, but now prevents me from flashing to the board in any way.

Some background:

- I am using a custom board I created that integrates the ESP32-C3-WROOM-02-N4 and uses the onboard USB Serial/JTAG Controller for programming. I know this board was designed right to at least some extent as I was able to upload a variety of programs to it and control a lot of the onboard peripherals.

- I have tried flashing to the chip in both standard operation (after pressing reset or unplugging the board) and serial bootloader mode through VSCode. Device Manager in Windows identifies the board in both instances but as different COM ports.

- The board is still functional. I still get 3.3V onto the Vin pin of the ESP-32. I also get a readout on Tera Term when I use the reset button on the device. The Tera Term readout is as follows:

Image

The main file, which is all I have edited beyond creating a template project, reads as follows:

Code: Select all

#include <stdio.h>
#include <String.h>

#include "driver/gpio.h"
#include "esp_log.h"
#include "nvs_flash.h"
#include "esp_nimble_hci.h"
#include "nimble/nimble_port.h"
#include "nimble/nimble_port_freertos.h"
#include "host/ble_hs.h"
#include "services/gap/ble_svc_gap.h"

void ble_app_on_sync(void)
{
    ble_addr_t addr;
    ble_hs_id_gen_rnd(1, &addr);
    ble_hs_id_set_rnd(addr.val);

    uint8_t uuid128[16];
    memset(uuid128, 0x11, sizeof(uuid128));
    ble_ibeacon_set_adv_data(uuid128, 2, 10, -10);

    struct ble_gap_adv_params adv_params = (struct ble_gap_adv_params) {0};
    ble_gap_adv_start(BLE_OWN_ADDR_RANDOM, NULL, BLE_HS_FOREVER, &adv_params, NULL, NULL);
}

void host_Task(void *param)
{
    nimble_port_run();
}

void app_main(void)
{
    nvs_flash_init();

    esp_nimble_hci_and_controller_init();
    nimble_port_init();

    ble_hs_cfg.sync_cb = ble_app_on_sync;

    nimble_port_freertos_init(host_Task);
}
The error I get when attempting to flash to the board is as follows:

"
Executing action: flash
Serial port COM5
COM5 failed to connect: Cannot configure port, something went wrong. Original message: PermissionError(13, 'A device attached to the system is not functioning.', None, 31)
No serial ports found. Connect a device, or use '-p PORT' option to set a specific port.
"

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

Re: ESP32-C3 Program Prevents Flashing.

Postby ESP_Sprite » Tue Feb 22, 2022 8:20 am

Which ESP-IDF version is this? If 4.4, there's a known issue that WiFi/BT erroneously kills the USB clock if you haven't have USB-serial-JTAG set as the primary console; we have a fix for that in the pipeline. You should be able to reflash the ESP32C3 by tying GPIO9 low and resetting (or powering off and on) the chip.

jjd5th
Posts: 3
Joined: Tue Feb 22, 2022 2:49 am

Re: ESP32-C3 Program Prevents Flashing.

Postby jjd5th » Wed Feb 23, 2022 2:01 am

Thank you for the reply! I am using 4.4., which may explain it. Unfortunately, holding GPIO9 low and resetting does not allow me to flash to the chip. I have tried setting this up in various ways but definitely have held GPIO9 low and pressed reset. When I do this, my PC recognizes the board as a different COM device, but I still get the same error message when I try to flash to the new COM port.

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

Re: ESP32-C3 Program Prevents Flashing.

Postby ESP_Sprite » Wed Feb 23, 2022 10:00 am

That I cannot explain. Perhaps something's up with the USB side of things? Perhaps adding or removing a hub may work?

jjd5th
Posts: 3
Joined: Tue Feb 22, 2022 2:49 am

Re: ESP32-C3 Program Prevents Flashing.

Postby jjd5th » Thu Feb 24, 2022 1:44 am

I have set up the board so I can set the EN pin low while VCC still is routed to the 3V3 pin. However, I am still unable to flash to the chip. I have tried multiple ports (USB 2.0, 3.0 and 3.1), as well as a different computer, all nothing. My only guess is that somewhere in the program I am accidentally reconfiguring the USB pins, but I don't know how that would happen. I have pasted my USB circuit below:

Image

I have also attempted this with ESP-IDF 4.3.2 and with the iBeacon example from espressif and the same thing happened.

Here is the flashing and monitoring portion of the output that I get when uploading this program to the board:
Serial port COM12
Connecting...
Chip is ESP32-C3 (revision 3)
Features: Wi-Fi
Crystal is 40MHz
MAC: 7c:df:a1:d1:96:88
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00004fff...
Flash will be erased from 0x00020000 to 0x0008afff...
Flash will be erased from 0x00010000 to 0x00010fff...
Flash will be erased from 0x00015000 to 0x00016fff...
Compressed 19840 bytes to 12000...
Writing at 0x00000000... (100 %)
Wrote 19840 bytes (12000 compressed) at 0x00000000 in 0.4 seconds (effective 396.6 kbit/s)...
Hash of data verified.
Compressed 437808 bytes to 243982...
Writing at 0x00020000... (6 %)
Writing at 0x0002aa03... (13 %)
Writing at 0x0003296a... (20 %)
Writing at 0x00039d7c... (26 %)
Writing at 0x00040b33... (33 %)
Writing at 0x00047b19... (40 %)
Writing at 0x0004e702... (46 %)
Writing at 0x00055590... (53 %)
Writing at 0x0005c468... (60 %)
Writing at 0x00062e91... (66 %)
Writing at 0x000699dd... (73 %)
Writing at 0x0006f7e5... (80 %)
Writing at 0x000774bb... (86 %)
Writing at 0x0007e88f... (93 %)
Writing at 0x00084756... (100 %)
Wrote 437808 bytes (243982 compressed) at 0x00020000 in 6.0 seconds (effective 580.7 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 139...
Writing at 0x00010000... (100 %)
Wrote 3072 bytes (139 compressed) at 0x00010000 in 0.1 seconds (effective 435.9 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 31...
Writing at 0x00015000... (100 %)
Wrote 8192 bytes (31 compressed) at 0x00015000 in 0.1 seconds (effective 595.8 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
Executing action: monitor
Serial port COM12
Connecting...
Detecting chip type... ESP32-C3
Running idf_monitor in directory c:\users\jjd5t\documents\glucolight\programming\learning\bluetoothtest
Executing "C:\Users\jjd5t\.espressif\python_env\idf4.4_py3.8_env\Scripts\python.exe C:/Espressif/frameworks/esp-idf-v4.4/tools/idf_monitor.py -p COM12 -b 115200 --toolchain-prefix riscv32-esp-elf- --target esp32c3 --decode-panic backtrace c:\users\jjd5t\documents\glucolight\programming\learning\bluetoothtest\build\intro_project.elf -m 'C:\Users\jjd5t\.espressif\python_env\idf4.4_py3.8_env\Scripts\python.exe' 'C:/Espressif/frameworks/esp-idf-v4.4/\tools\idf.py'"...
--- WARNING: GDB cannot open serial ports accessed as COMx
--- Using \\.\COM12 instead...
--- idf_monitor on \\.\COM12 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x15 (USB_UART_CHIP_RESET),boot:0xb (SPI_FAST_FLASH_BOOT)
Saved PC:0x4004c626
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0x16b4
load:0x403ce000,len:0x930
load:0x403d0000,len:0x2d40
entry 0x403ce000
**edit, ignore the original text below:

I have found a mistake in my hardware that may be the reason I cannot flash on reset. My reset button pulls the EN and 3V3 pin down, not just the EN pin. Therefore I am never truly putting it into bootloader mode. This may mean the board is fine and it is the BLE on 4.4 problem that you mentioned that is causing the issue.

bmkuter
Posts: 2
Joined: Fri Feb 25, 2022 8:00 pm

Re: ESP32-C3 Program Prevents Flashing.

Postby bmkuter » Thu Aug 18, 2022 5:55 pm

ESP_Sprite wrote:
Tue Feb 22, 2022 8:20 am
Which ESP-IDF version is this? If 4.4, there's a known issue that WiFi/BT erroneously kills the USB clock if you haven't have USB-serial-JTAG set as the primary console; we have a fix for that in the pipeline. You should be able to reflash the ESP32C3 by tying GPIO9 low and resetting (or powering off and on) the chip.
Hi! Do you know if there is a resolution to this issue in ESP-IDF v4.4.2? I'm having similar issues, despite "Channel for console output" being set to "USB Serial/JTAG Controller" in menuconfig.

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

Re: ESP32-C3 Program Prevents Flashing.

Postby ESP_Sprite » Fri Aug 19, 2022 12:59 pm

Just to check: are you sure nothing is re-initializing the USB pins as e.g. normal GPIOs?

Who is online

Users browsing this forum: No registered users and 110 guests