ESP32C3 upload OK, won't run, IDE 2.2.1

Hi
It's first time I try out ESP32, and IDE 2.2.1 and a lot of other things, so hopefully this is in the appropriate category.

I just got a few this ESP32C3 Dev 0.42 inch display. Pre-loaded demo works fine so no HW problems.

Using Arduino IDE 2.2.1 with the board set to "ESP32C3 Dev Module" it compiles Examples/Wifi/WifiScan just fine. Upload says all OK and last message is "Hard resetting via RTS pin..." which should mean all OK or could there be anything else wrong?

I have tried with two boards and uploads goes fine but no running code.

A strange thing is that when going "Tools/Get Board Info" it says "BN: ESP32-S3-Box" which I guess is just an un-updated entry. The "SN:" matches what I see with dmesg. I did however tried to change the board to "ESP32 S3" but would not upload at all.

I tried to hold down "boot" button while connecting USB-C and upload, and then release the boot button with the same result. No output in the Serial Monitor connected. Changing baud to 9600 didn't help either.

I tried other small demos without luck.

Any idea to where to look next?

best regards
./hans

Sketch uses 682726 bytes (52%) of program storage space. Maximum is 1310720 bytes.
Global variables use 36860 bytes (11%) of dynamic memory, leaving 290820 bytes for local variables. Maximum is 327680 bytes.
esptool.py v4.5.1
Serial port /dev/ttyACM0
Connecting...
Chip is ESP32-C3 (revision v0.3)
Features: WiFi, BLE
Crystal is 40MHz
MAC: a0:76:4e:18:f7:c8
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00003fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x000bafff...
Compressed 13216 bytes to 9528...
Writing at 0x00000000... (100 %)
Wrote 13216 bytes (9528 compressed) at 0x00000000 in 0.2 seconds (effective 495.7 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 146...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (146 compressed) at 0x00008000 in 0.0 seconds (effective 583.9 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 767.6 kbit/s)...
Hash of data verified.
Compressed 698560 bytes to 424809...
Writing at 0x00010000... (3 %)
...
Writing at 0x000aed01... (96 %)
Writing at 0x000b4838... (100 %)
Wrote 698560 bytes (424809 compressed) at 0x00010000 in 5.8 seconds (effective 963.7 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

Edit: When trying WifiScan.ino just to some serial communication it looks alright to me:
image

The tools menu

Welcome back

So you basically don't have a problem with the IDE :wink: And you also don't seem to have a problem with your board.

That information should be pulled from the board as far as I know.

That indicates that you did select the wrong board.

Question is why you think that there is a problem. What are the symptoms? If it's only about the upload, I would keep the board at "ESP32C3 Dev Module".

The platform author can associate a board definition with identifying information from the port. If there is a board definition associated with the port, the board name is shown in this "Board Info" dialog.

Although any arbitrary identification properties are supported by the Arduino platform framework, most platforms use the USB VID/PID identifier pair. The USB interface of the ESP32-C3 and ESP32-S3 microcontrollers have a default VID/PID of 303a:1001, which is provided by the manufacturer Espressif.

Typically in this case where a property is not uniquely identifying, the platform would not associate it with the board. For example, Arduino does not associate the 0403:6001 VID/PID pair supplied by FTDI for the FT232R chip with definition of the classic Nano board because this would cause the ports of other boards using the FT232R to be incorrectly associated with the Nano board definition in Arduino IDE.

But there is nothing in the Arduino boards platform framework to prevent each platform author from associating non-unique properties with their board definitions. That is what the ESP32 boards platform developers did. They associated many different board definitions with the VID/PID pair 303a:1001. For example:

... and so on.

So it is not clear what Arduino IDE should do in this case. It just picks the name of one of the multiple associated boards to show in the dialog and other parts of the Arduino IDE UI. Apparently there is some non-deterministic behavior in terms of which board Arduino IDE 2.x selects, so you might see the name change.

Here is the link for the library to use to control the screen on that board.

What ESP32 URL in "Additional Boards Manager" do you have in the preferences?

The problem is that I get no serial output from the esp32.
When trying to use WifiScan.ino it should at least write "Setup done" and "Scan start" in the serial monitor but I get no messages.

It also seems like the upload work just fine without pressing the boot button.

I also tried the simple ws2812 LED demo without luck. Well, it is more complicated than just turning on a LED.

Current conclusion:

  1. Device is attached
  2. Upload working
  3. Ampere supplied is adequate
  4. The right board/compiler is selected

I'm not really sure what to try next...

You've got the library in post #4?

Are you using the link below for ESP32 in preferences?

https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json


```cpp
// Attempt for calibration of KY039
// Sensor pin S connect to Arduino pin Analoog 1 / A1
// Sensor pin + (middle pin) connect to Arduino pin 5+
// Sensor pin - connect to Arduino pin GND
#include <math.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>



int sensorPin = 1; // Analog Pin where the S is connected to
int period = 20; // delay 20 ms
long count = 0; // count for number of picks
long HrtRate =0; // Heart rate (determined)
long Cal_hrt_rate = 0; // calibrated heart rate

// For calculation of the difference of time
long time1 = 0; 
long time2 = 0;

LiquidCrystal_I2C  lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POE);SITIV // 0x3F is the I2C bus address for an unmodified backpack

#define CONTRAST_PIN  9
#define BacklightPin 7

void setup() {
  Serial.begin(9600);
  // activate LCD module
  lcd.begin (16,2); 
  lcd.setBacklightPin  ;
  lcd.setBacklight ( HIGH );
}

void loop() {
  int data1 = analogRead(sensorPin);
  delay (period);
  int data2 = analogRead(sensorPin);
  int diff = data2 - data1; // difference of two simultanious values

  if (diff>0) // graph is moving upwards 
  {
    while (diff>0)
    {
    data1 = analogRead(sensorPin);
    delay (period);
    data2 = analogRead(sensorPin);
    diff = data2 - data1;
    } // coming out of the while loop means the graph has started moving downward
    count++; 
    if (count == 1) 
    {
    time1 = millis(); // time at the time of first pick
    }
  }
  else // graph is moving upwards 
  {
    while (diff<=0)
    {
    data1 = analogRead(sensorPin);
    delay (period);
    data2 = analogRead(sensorPin);
    diff = data2 - data1;
    } // coming out of the while loop means the graph has started moving downwardward
    
    count++; // pick counted
    if (count == 1)
    {
    time1 = millis(); // time at the time of first pick
    }
  }
  if (count>49) // when 50 picks arrived
  {
    time2 = millis(); // time after the specific number of picks
    HrtRate = 30000*count/(time2 - time1); // Heart rate at 1 min =  (count/2)*60000 ms,1 pick = count/2
    Cal_hrt_rate = 0.206*HrtRate-16.09; // CALIBRATED EQUATION obtained from the experiment on different volunteers.
    if ((Cal_hrt_rate>59) && (Cal_hrt_rate<91)) // considered the max and min heart rate could be 90 and 60
    {
    Serial.print("Heart Rate= ");
    Serial.println(HrtRate);
    count  = 0; // For new loop and subsiquent calculations
    lcd.home (); // set cursor to 0,0
    lcd.print ("HEART RATE=");
    lcd.setCursor (0,1);        // go to start of 2nd line
    lcd.print(Cal_hrt_rate);
    lcd.setCursor (3,1);
    lcd.print ("Pulse/min");
    delay (5000); // after 5 sec
    }      
    
  }
  }
  
  

Sorry to say....But this won't work, the display is OLED to start with. :upside_down_face:

Yes, from File -> Preferences:

Yes, display is this one 0.42 inch OLED Bare Display (72x40, SSD1306).
Not LCD.

Have you tried swapping the I2C pins around?

I2C pins are 5(SCL) & 6(SDA) by default.

When first powered on the device was actually working.
It was showing the demo which can be seen here.

So the hardware is correct.

So when it's not working, I guess it must be:

  1. Compiled to wrong machine code (but it seems right in the log)
  2. The code is written to a wrong memory address in the chip (could that happen?)

I have tried to setup Espressif-IDE instead but it's not working yet. I guess that it wouldn't help anyway if the problem is compiling for the wrong machine architecture.

I guess you are still getting confused by the board's port being identified as "ESP32-S3-Box". If you are interested in the boring details of why that happens, I explained it already in my previous reply (post #3), but all you really need to know is that it doesn't indicate any problem and won't cause any problem so you should simply ignore the incorrect board name shown in that "Board Info dialog and the Tools > Port menu.

As long as you have the correct board selected from the Tools > Board menu in Arduino IDE, everything is fine. As you already discovered, the tool that uploads the sketch is even smart enough to check whether the board has a different microcontroller than the one you have selected in the IDE and fails the upload.

Solved 1!

Problem: A lot of demos didn't work.

Solution: Start with a simple example like ASCIITable.

I thought WifiScan was a simple example which could just run anyway but it got stuck at WiFi.mode(WIFI_STA); so no message was printed out. Maybe I should report this as a bug?

Solved 2!

Problem: Within "Arduino IDE 2.2.1" I was using the board "esp32 by Espressif Systems 3.0.0-alpha2" which was the default.

Solution: Downgrade board to "esp32 by Espressif Systems 2.0.14"

The board used: ESP32C2 Dev Module

Sorry for the inconvenience.

2 Likes

No problem.... :slightly_smiling_face:

I have the same setup, and want to add that the ESP32-C3 goes into a boot loop with this message on serial output, at least with the 3.0.0-rc1 and 3.0.0-rc2 releases specified by the product's github examples. This message below may be useful to those searching for this condition.

-> assert failed: i2c_ll_cal_bus_clk /IDF/components/hal/esp32c3/include/hal/i2c_ll.h:105 (clk_cal->scl_wait_high < clk_cal->sda_sample && clk_cal->sda_sample < clk_cal->scl_high)

The Espressif 2.0 board version boots fine, and enabling "USB CDC on Boot: Enable" in IDE Tools menu fixed the printing.

Have same problem with board ESP32-C3-0.42 OLED
it detects as:

BN: ESP32S3 CAM LCD
VID: 0x303a
PID: 0x1001
SN: A0:76:4E:18:FA:34

When i choise in Arduino IDE board: "ESP32S3 CAM LCD" after compiling I got message:

esptool.py v4.6
Serial port /dev/ttyACM0
Connecting...

A fatal error occurred: This chip is ESP32-C3 not ESP32-S3. Wrong --chip argument?
Failed uploading: uploading error: exit status 2

After choising in Arduino IDE board: "ESP32C3 Dev Module", it compiling without errors and uploads without errors.
But when I reset board, it repeatly rebooting... in Serial console it prints next debug:

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0xf (SPI_FAST_FLASH_BOOT)
Saved PC:0x40048b82
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5820,len:0x3ac
load:0x403cc710,len:0x6c4
load:0x403ce710,len:0x2784
entry 0x403cc710
=========== Before Setup Start ===========
Chip Info:
------------------------------------------
  Model             : ESP32-C3
  Package           : 0
  Revision          : 3
  Cores             : 1
  Frequency         : 160 MHz
  Embedded Flash    : No
  Embedded PSRAM    : No
  2.4GHz WiFi       : Yes
  Classic BT        : No
  BT Low Energy     : Yes
  IEEE 802.15.4     : No
------------------------------------------
INTERNAL Memory Info:
------------------------------------------
  Total Size        :   334824 B ( 327.0 KB)
  Free Bytes        :   303056 B ( 296.0 KB)
  Allocated Bytes   :    28076 B (  27.4 KB)
  Minimum Free Bytes:   303056 B ( 296.0 KB)
  Largest Free Block:   278516 B ( 272.0 KB)
------------------------------------------
Flash Info:
------------------------------------------
  Chip Size         :  4194304 B (4 MB)
  Block Size        :    65536 B (  64.0 KB)
  Sector Size       :     4096 B (   4.0 KB)
  Page Size         :      256 B (   0.2 KB)
  Bus Speed         : 80 MHz
  Bus Mode          : DIO
------------------------------------------
Partitions Info:
------------------------------------------
                nvs : addr: 0x00009000, size:    20.0 KB, type: DATA, subtype: NVS
            otadata : addr: 0x0000E000, size:     8.0 KB, type: DATA, subtype: OTA
               app0 : addr: 0x00010000, size:  1280.0 KB, type:  APP, subtype: OTA_0
               app1 : addr: 0x00150000, size:  1280.0 KB, type:  APP, subtype: OTA_1
             spiffs : addr: 0x00290000, size:  1408.0 KB, type: DATA, subtype: SPIFFS
           coredump : addr: 0x003F0000, size:    64.0 KB, type: DATA, subtype: COREDUMP
------------------------------------------
Software Info:
------------------------------------------
  Compile Date/Time : Dec  3 2023 01:00:38
  Compile Host OS   : linux
  ESP-IDF Version   : v5.1.1-577-g6b1f40b9bf-dirty
  Arduino Version   : 3.0.0
------------------------------------------
Board Info:
------------------------------------------
  Arduino Board     : ESP32C3_DEV
  Arduino Variant   : esp32c3
  Arduino FQBN      : esp32:esp32:esp32c3:UploadSpeed=921600,CDCOnBoot=cdc,CPUFreq=160,FlashFreq=80,FlashMode=dio,FlashSize=4M,PartitionScheme=default,DebugLevel=verbose,EraseFlash=none,JTAGAdapter=default
============ Before Setup End ============
[   201][I][esp32-hal-i2c.c:99] i2cInit(): Initialising I2C Master: sda=5 scl=6 freq=100000
[   202][W][Wire.cpp:305] begin(): Bus already started in Master Mode.

assert failed: i2c_ll_cal_bus_clk /IDF/components/hal/esp32c3/include/hal/i2c_ll.h:105 (clk_cal->scl_wait_high < clk_cal->sda_sample && clk_cal->sda_sample < clk_cal->scl_high)
Core  0 register dump:
MEPC    : 0x40381ef2  RA      : 0x40385ac4  SP      : 0x3fc96580  GP      : 0x3fc8d400  
TP      : 0x3fc88dac  T0      : 0x656c706d  T1      : 0x6d61735f  T2      : 0x61735f61  
S0/FP   : 0x00000001  S1      : 0x3fc96760  A0      : 0x3fc965e4  A1      : 0x3fc8d4fd  
A2      : 0x00000001  A3      : 0x00000029  A4      : 0x00000001  A5      : 0x3fc8f000  
A6      : 0x6c63203c  A7      : 0x20656c70  S2      : 0x00000017  S3      : 0x3fc965d8  
S4      : 0x3fc965d8  S5      : 0x4200db34  S6      : 0x00000002  S7      : 0x3c036334  
S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
T3      : 0x6164733e  T4      : 0x2d6c6163  T5      : 0x5f6b6c63  T6      : 0x20262620  
MSTATUS : 0x00001801  MTVEC   : 0x40380001  MCAUSE  : 0x00000007  MTVAL   : 0x00000000  
MHARTID : 0x00000000  

3fc96740: 0xa0000000 0x0000000a 0x00000000 0x00000000 0x3fc8f000 0x3fc8e000 0x3fc8de98 0x420003b4
3fc96760: 0x00000000 0x000000ae 0x3fc8de98 0x420010cc 0x00000000 0x00000000 0x000000fe 0x00000019
3fc96780: 0x00000017 0x3fc8de98 0x3c030645 0x4200100e 0x00000000 0x3fc8f000 0x00000000 0xae000000
3fc967a0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x3fc8f000 0x3fc8de98 0x42001192
3fc967c0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x3fc8f000 0x3fc8e000 0x4200011a
3fc967e0: 0x00000000 0x00000000 0x00000000 0x42004434 0x00000000 0x00000000 0x00000000 0x00000000
3fc96800: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
3fc96820: 0xa5a5a5a5 0xbaad5678 0x00000160 0xabba1234 0x00000154 0x3fc96700 0x000001a1 0x3fc8e544
3fc96840: 0x3fc8e544 0x3fc96834 0x3fc8e53c 0x00000018 0x3fc96ba4 0x3fc96ba4 0x3fc96834 0x00000000
3fc96860: 0x00000001 0x3fc94824 0x706f6f6c 0x6b736154 0x0dfee400 0x00fb349f 0x00000000 0x3fc96820
3fc96880: 0x00000001 0x00000002 0x00000000 0x00000000 0x00000000 0x3fc8fe9c 0x3fc8ff04 0x3fc8ff6c
3fc968a0: 0x00000000 0x00000000 0x00000001 0x00000000 0x00000000 0x3fc96d24 0x4201c570 0x00000000
3fc968c0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc968e0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc96900: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc96920: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc96940: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc96960: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000



ELF file SHA256: 8399380bf2a6fecf

Rebooting...

Always Error:
assert failed: i2c_ll_cal_bus_clk /IDF/components/hal/esp32c3/include/hal/i2c_ll.h:105 (clk_cal->scl_wait_high < clk_cal->sda_sample && clk_cal->sda_sample < clk_cal->scl_high)

I can restore my module using

esptool.py --port /dev/ttyACM0 --chip esp32c3 --baud 115200 write_flash 0x0 firmware_main.bin

firmware_main.bin - that flash which I saved from new device, and it back as new, and loads without errors.

But I can not to write my own programs.
What is wrong? How to fix it? Can someone help?

  • I tried to Upload test program Hello world, and always got same error at boot :frowning:
    assert failed: i2c_ll_cal_bus_clk /IDF/components/hal/esp32c3/include/hal/i2c_ll.h:105
1 Like

Looks like I didn't read carefully this topic. Sorry...
After removing esp32 by Espressif Systems v3.0.0, and install v2.0.14, problems is gone.
My programs (and Hello world) uploads correctly.
Thank you! :heart_eyes:

1 Like

@wa5znu , @cement143

Hi, could you please explain to me how to do this? what is espress if 2.0 and how can I install it? (I have the same error: assert failed: i2c_ll_cal_bus_clk /IDF/components/hal/esp32c3/include/hal/i2c_ll.h:105 (clk_cal->scl_wait_high < clk_cal->sda_sample && clk_cal->sda_sample < clk_cal->scl_high).
Thank you in advance for the help. Best regards.