ESP32-C3 i2c not work

salviador
Posts: 3
Joined: Sun Jan 27, 2019 12:07 pm

ESP32-C3 i2c not work

Postby salviador » Tue Dec 07, 2021 5:56 pm

I use ESP-IDF 4.3, with "esp32-c3 devkit-02"
I am trying example "i2c_simple" but I have a continuous reset of the ESP32
SCL GPIO Num 6 (default)
SDA GPIO Num 5 (default)

Code: Select all

[code]
Failed to run gdb_panic_server.py script: Command '['riscv32-esp-elf-gdb', '--batch', '-n', '/home/michele/myesp/i2c_simple/build/i2c-simple.elf', '-ex', 'target remote | "/home/michele/.espressif/python_env/idf4.4_py3.9_env/bin/python" "/home/michele/esp/esp-idf/tools/idf_monitor_base/../gdb_panic_server.py" --target esp32c3 "/tmp/tmph24wwd2t"', '-ex', 'bt']' returned non-zero exit status 127.
b'riscv32-esp-elf-gdb: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory\n'


Core  0 register dump:
MEPC    : 0x40380668  RA      : 0x40384c20  SP      : 0x3fc90850  GP      : 0x3fc8c000  
TP      : 0x3fc88d60  T0      : 0x37363534  T1      : 0x7271706f  T2      : 0x33323130  
S0/FP   : 0x00000004  S1      : 0x3fc908b4  A0      : 0x3fc9087c  A1      : 0x3fc908b2  
A2      : 0x00000000  A3      : 0x3fc908a9  A4      : 0x00000001  A5      : 0x3fc8e000  
A6      : 0x7a797877  A7      : 0x76757473  S2      : 0x00000000  S3      : 0x00000000  
S4      : 0x00000000  S5      : 0x00000000  S6      : 0x00000000  S7      : 0x00000000  
S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
T3      : 0x6e6d6c6b  T4      : 0x6a696867  T5      : 0x66656463  T6      : 0x62613938  
MSTATUS : 0x00001881  MTVEC   : 0x40380001  MCAUSE  : 0x00000007  MTVAL   : 0x00000000  
MHARTID : 0x00000000  

Stack memory:
3fc90850: 0x3c022d60 0x40384c14 0x3fc908b0 0x4038a230 0x00000001 0x3fc90868 0x00001000 0x3fc8c618
3fc90870: 0x3fc908b4 0x3fc8c634 0x3fc908b0 0x726f6261 0x20292874 0x20736177 0x6c6c6163 0x61206465
3fc90890: 0x43502074 0x34783020 0x34383330 0x20353163 0x63206e6f 0x2065726f 0x00000030 0x00000000
3fc908b0: 0x00000030 0x38333034 0x35316334 0x00000000 0x00000000 0x00000000 0x00000000 0x40384c18
3fc908d0: 0x3c022d7c 0x00000000 0x3fc912bc 0x42005cd6 0x00000000 0x00000000 0x00000005 0x0100a66c
3fc908f0: 0x00000000 0x00000000 0x00000000 0x42014c4e 0x00000000 0x00000000 0x00000000 0x40387452
3fc90910: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
3fc90930: 0x27146414 0x01010107 0x00000001 0x00000000 0xffffffff 0x7fefffff 0x00000000 0x3fc00000
3fc90950: 0x00000000 0x40300000 0x00000000 0x3fe00000 0x00000000 0x3ff80000 0x636f4361 0x3fd287a7
3fc90970: 0x8b60c8b3 0x3fc68a28 0x509f79fb 0x3fd34413 0x00000000 0x3ff00000 0x00000000 0x40240000
3fc90990: 0x00000000 0x401c0000 0x00000000 0x40140000 0x00000000 0x43500000 0x3fc8b800 0x00001410
3fc909b0: 0xa5a5a5a5 0xa5a5a5a5 0x00000154 0x3fc90760 0x00000064 0x3fc8d45c 0x3fc8d45c 0x3fc909bc
3fc909d0: 0x3fc8d454 0x00000018 0x3fc913a8 0x3fc913a8 0x3fc909bc 0x00000000 0x00000001 0x3fc8f9b8
3fc909f0: 0x6e69616d 0x10f19c00 0x73e3f701 0x009c12fb 0x00000000 0x3fc909b0 0x00000001 0x00000000
3fc90a10: 0x00000000 0x00000000 0x00000000 0x3fc8e42c 0x3fc8e494 0x3fc8e4fc 0x00000000 0x00000000
3fc90a30: 0x00000001 0x00000000 0x00000000 0x00000000 0x4200b322 0x00000000 0x00000000 0x00000000
3fc90a50: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc90a70: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc90a90: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc90ab0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc90ad0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc90af0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x3fc90000
3fc90b10: 0x00000154 0x3fc91120 0x3fc8da94 0x3fc8d448 0x3fc8d448 0x3fc90b14 0x3fc8d440 0x00000019
SP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0x1730
load:0x403ce000,len:0x930
load:0x403d0000,len:0x2d68
SHA-256 comparison failed:
Calculated: e538c2188e435db2dba3c0af6305c35e2ef51581311b9b03cd9b0bdbc03f16c2
Expected: 434de0aedc5516081d89f3ce584b98c43a8556dc06ad780caed0c70fe3190f23
Attempting to boot anyway...
entry 0x403ce000
I (48) boot: ESP-IDF v4.4-dev-3703-gddc44956bf-dirty 2nd stage bootloader
I (49) boot: compile time 18:43:50
I (49) boot: chip revision: 3
I (52) boot.esp32c3: SPI Speed      : 80MHz
I (57) boot.esp32c3: SPI Mode       : DIO
I (62) boot.esp32c3: SPI Flash Size : 4MB
I (67) boot: Enabling RNG early entropy source...
I (72) boot: Partition Table:
I (76) boot: ## Label            Usage          Type ST Offset   Length
I (83) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (90) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (98) boot:  2 factory          factory app      00 00 00010000 00100000
I (105) boot: End of partition table
I (110) esp_image: segment 0: paddr=00010020 vaddr=3c020020 size=07d48h ( 32072) map
I (123) esp_image: segment 1: paddr=00017d70 vaddr=3fc8b800 size=01410h (  5136) load
I (127) esp_image: segment 2: paddr=00019188 vaddr=40380000 size=06e90h ( 28304) load
I (140) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=14ecch ( 85708) map
I (157) esp_image: segment 4: paddr=00034ef4 vaddr=40386e90 size=047f8h ( 18424) load
I (160) esp_image: segment 5: paddr=000396f4 vaddr=50000000 size=00010h (    16) load
I (166) boot: Loaded app from partition at offset 0x10000
I (169) boot: Disabling RNG early entropy source...
I (185) cpu_start: Pro cpu up.
I (194) cpu_start: Pro cpu start user code
I (194) cpu_start: cpu freq: 160000000
I (194) cpu_start: Application information:
I (197) cpu_start: Project name:     i2c-simple
I (202) cpu_start: App version:      1
I (207) cpu_start: Compile time:     Dec  7 2021 18:43:46
I (213) cpu_start: ELF file SHA256:  372ddd53fdd0c101...
I (213) cpu_start: ELF file SHA256:  372ddd53fdd0c101...
I (219) cpu_start: ESP-IDF:          v4.4-dev-3703-gddc44956bf-dirty
I (226) heap_init: Initializing. RAM available for dynamic allocation:
I (233) heap_init: At 3FC8DA80 len 00032580 (201 KiB): DRAM
I (239) heap_init: At 3FCC0000 len 0001F060 (124 KiB): STACK/DRAM
I (246) heap_init: At 50000010 len 00001FF0 (7 KiB): RTCRAM
I (253) spi_flash: detected chip: generic
I (257) spi_flash: flash io: dio
I (261) sleep: Configure to isolate all GPIO pins in sleep state
I (268) sleep: Enable automatic switching of GPIO sleep configuration
I (275) cpu_start: Starting scheduler.
I (280) i2c-simple-example: I2C initialized successfully
ESP_ERROR_CHECK failed: esp_err_t 0xffffffff (ESP_FAIL) at 0x40384c11
0x40384c11: _esp_error_check_failed at /home/michele/esp/esp-idf/components/esp_system/esp_err.c:42

file: "../main/i2c_simple_main.c" line 89
func: app_main
expression: mpu9250_register_read(MPU9250_WHO_AM_I_REG_ADDR, data, 1)

abort() was called at PC 0x40384c15 on core 0
0x40384c15: _esp_error_check_failed at /home/michele/esp/esp-idf/components/esp_system/esp_err.c:43

Stack dump detected
Core  0 register dump:
MEPC    : 0x40380668  RA      : 0x40384c20  SP      : 0x3fc90850  GP      : 0x3fc8c000  
0x40380668: panic_abort at /home/michele/esp/esp-idf/components/esp_system/panic.c:402

0x40384c20: __ubsan_include at /home/michele/esp/esp-idf/components/esp_system/ubsan.c:294

TP      : 0x3fc88d60  T0      : 0x37363534  T1      : 0x7271706f  T2      : 0x33323130  
S0/FP   : 0x00000004  S1      : 0x3fc908b4  A0      : 0x3fc9087c  A1      : 0x3fc908b2  
A2      : 0x00000000  A3      : 0x3fc908a9  A4      : 0x00000001  A5      : 0x3fc8e000  
A6      : 0x7a797877  A7      : 0x76757473  S2      : 0x00000000  S3      : 0x00000000  
S4      : 0x00000000  S5      : 0x00000000  S6      : 0x00000000  S7      : 0x00000000  
S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
T3      : 0x6e6d6c6b  T4      : 0x6a696867  T5      : 0x66656463  T6      : 0x62613938  
MSTATUS : 0x00001881  MTVEC   : 0x40380001  MCAUSE  : 0x00000007  MTVAL   : 0x00000000  
0x40380001: _vector_table at ??:?

MHARTID : 0x00000000  

Failed to run gdb_panic_server.py script: Command '['riscv32-esp-elf-gdb', '--batch', '-n', '/home/michele/myesp/i2c_simple/build/i2c-simple.elf', '-ex', 'target remote | "/home/michele/.espressif/python_env/idf4.4_py3.9_env/bin/python" "/home/michele/esp/esp-idf/tools/idf_monitor_base/../gdb_panic_server.py" --target esp32c3 "/tmp/tmp_ry4zmi8"', '-ex', 'bt']' returned non-zero exit status 127.
b'riscv32-esp-elf-gdb: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory\n'


Core  0 register dump:
MEPC    : 0x40380668  RA      : 0x40384c20  SP      : 0x3fc90850  GP      : 0x3fc8c000  
TP      : 0x3fc88d60  T0      : 0x37363534  T1      : 0x7271706f  T2      : 0x33323130  
S0/FP   : 0x00000004  S1      : 0x3fc908b4  A0      : 0x3fc9087c  A1      : 0x3fc908b2  
A2      : 0x00000000  A3      : 0x3fc908a9  A4      : 0x00000001  A5      : 0x3fc8e000  
A6      : 0x7a797877  A7      : 0x76757473  S2      : 0x00000000  S3      : 0x00000000  
S4      : 0x00000000  S5      : 0x00000000  S6      : 0x00000000  S7      : 0x00000000  
S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
T3      : 0x6e6d6c6b  T4      : 0x6a696867  T5      : 0x66656463  T6      : 0x62613938  
MSTATUS : 0x00001881  MTVEC   : 0x40380001  MCAUSE  : 0x00000007  MTVAL   : 0x00000000  
MHARTID : 0x00000000  

Stack memory:
3fc90850: 0x3c022d60 0x40384c14 0x3fc908b0 0x4038a230 0x00000001 0x3fc90868 0x00001000 0x3fc8c618
3fc90870: 0x3fc908b4 0x3fc8c634 0x3fc908b0 0x726f6261 0x20292874 0x20736177 0x6c6c6163 0x61206465
3fc90890: 0x43502074 0x34783020 0x34383330 0x20353163 0x63206e6f 0x2065726f 0x00000030 0x00000000
3fc908b0: 0x00000030 0x38333034 0x35316334 0x00000000 0x00000000 0x00000000 0x00000000 0x40384c18
3fc908d0: 0x3c022d7c 0x00000000 0x3fc912bc 0x42005cd6 0x00000000 0x00000000 0x00000005 0x0100a66c
3fc908f0: 0x00000000 0x00000000 0x00000000 0x42014c4e 0x00000000 0x00000000 0x00000000 0x40387452
3fc90910: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
3fc90930: 0x27146414 0x01010107 0x00000001 0x00000000 0xffffffff 0x7fefffff 0x00000000 0x3fc00000
3fc90950: 0x00000000 0x40300000 0x00000000 0x3fe00000 0x00000000 0x3ff80000 0x636f4361 0x3fd287a7
3fc90970: 0x8b60c8b3 0x3fc68a28 0x509f79fb 0x3fd34413 0x00000000 0x3ff00000 0x00000000 0x40240000
3fc90990: 0x00000000 0x401c0000 0x00000000 0x40140000 0x00000000 0x43500000 0x3fc8b800 0x00001410
3fc909b0: 0xa5a5a5a5 0xa5a5a5a5 0x00000154 0x3fc90760 0x00000064 0x3fc8d45c 0x3fc8d45c 0x3fc909bc
3fc909d0: 0x3fc8d454 0x00000018 0x3fc913a8 0x3fc913a8 0x3fc909bc 0x00000000 0x00000001 0x3fc8f9b8
3fc909f0: 0x6e69616d 0x00f19a00 0x73e3f709 0x00bc12fb 0x00000000 0x3fc909b0 0x00000001 0x00000000
3fc90a10: 0x00000000 0x00000000 0x00000000 0x3fc8e42c 0x3fc8e494 0x3fc8e4fc 0x00000000 0x00000000
3fc90a30: 0x00000001 0x00000000 0x00000000 0x00000000 0x4200b322 0x00000000 0x00000000 0x00000000
3fc90a50: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc90a70: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc90a90: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc90ab0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc90ad0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc90af0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x3fc90000
3fc90b10: 0x00000154 0x3fc91120 0x3fc8da94 0x3fc8d448 0x3fc8d448 0x3fc90b14 0x3fc8d440 0x00000019
3fc90b30: 0x0184df50 0xf79124b9 0x3fc90b14 0x00000000 0x00000000 0x3fc90c6c 0x454c4449 0x9f992800
3fc90b50: 0xd3dd5f90 0x00f91111 0x00000000 0x3fc91260 0x00000000 0x00000000 0x00000000 0x00000000
3fc90b70: 0x00000000 0x3fc8e42c 0x3fc8e494 0x3fc8e4fc 0x00000000 0x00000000 0x00000001 0x00000000
3fc90b90: 0x00000000 0x00000000 0x4200b322 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc90bb0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc90bd0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc90bf0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc90c10: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc90c30: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000



ELF file SHA256: 372ddd53fdd0c101
ELF file SHA256: 372ddd53fdd0c101

Rebooting...
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x403804ca
0x403804ca: esp_restart_noos_dig at /home/michele/esp/esp-idf/components/esp_system/esp_system.c:46 (discriminator 1)

SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0x1730
load:0x403ce000,len:0x930
load:0x403d0000,len:0x2d68
SHA-256 comparison failed:
Calculated: e538c2188e435db2dba3c0af6305c35e2ef51581311b9b03cd9b0bdbc03f16c2
Expected: 434de0aedc5516081d89f3ce584b98c43a8556dc06ad780caed0c70fe3190f23
Attempting to boot anyway...
entry 0x403ce000
I (53) boot: ESP-IDF v4.4-dev-3703-gddc44956bf-dirty 2nd stage bootloader
I (53) boot: compile time 18:43:50
I (54) boot: chip revision: 3
I (57) boot.esp32c3: SPI Speed      : 80MHz
I (62) boot.esp32c3: SPI Mode       : DIO
I (67) boot.esp32c3: SPI Flash Size : 4MB
I (72) boot: Enabling RNG early entropy source...
I (77) boot: Partition Table:
I (81) boot: ## Label            Usage          Type ST Offset   Length
I (88) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (95) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (103) boot:  2 factory          factory app      00 00 00010000 00100000
I (110) boot: End of partition table
I (115) esp_image: segment 0: paddr=00010020 vaddr=3c020020 size=07d48h ( 32072) map
I (128) esp_image: segment 1: paddr=00017d70 vaddr=3fc8b800 size=01410h (  5136) load
I (132) esp_image: segment 2: paddr=00019188 vaddr=40380000 size=06e90h ( 28304) load
I (145) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=14ecch ( 85708) map
I (162) esp_image: segment 4: paddr=00034ef4 vaddr=40386e90 size=047f8h ( 18424) load
I (165) esp_image: segment 5: paddr=000396f4 vaddr=50000000 size=00010h (    16) load
I (171) boot: Loaded app from partition at offset 0x10000
I (174) boot: Disabling RNG early entropy source...
I (190) cpu_start: Pro cpu up.

[/code]

salviador
Posts: 3
Joined: Sun Jan 27, 2019 12:07 pm

Re: ESP32-C3 i2c not work

Postby salviador » Wed Dec 08, 2021 11:09 am

Send My code

Code: Select all

#include <stdio.h>
#include "esp_log.h"
#include "driver/i2c.h"

#include "driver/periph_ctrl.h"
#include <esp_types.h>
#include "esp_intr.h"

static const char *TAG = "WII I2C Test";

void app_main(void)
{

    i2c_config_t conf = {
        .mode = I2C_MODE_MASTER,
        .sda_io_num = 5,
        .scl_io_num = 6,
        .sda_pullup_en = GPIO_PULLUP_ENABLE,
        .scl_pullup_en = GPIO_PULLUP_ENABLE,
        .master.clk_speed = 100000,
    };

    ESP_ERROR_CHECK(i2c_param_config(0, &conf));

    ESP_ERROR_CHECK(i2c_driver_install(0, conf.mode, 0, 0, 0));

    ESP_LOGI(TAG, "I2C unitialized successfully");
 
    
    while(1){
        i2c_cmd_handle_t i2chandle = i2c_cmd_link_create();

        ESP_ERROR_CHECK(i2c_master_start(i2chandle));
        ESP_ERROR_CHECK(i2c_master_write_byte(i2chandle, 0x52 | I2C_MASTER_WRITE, 0x00));

        ESP_ERROR_CHECK(i2c_master_write_byte(i2chandle, 0xF0, 0x00));
        ESP_ERROR_CHECK(i2c_master_write_byte(i2chandle, 0x55, 0x00));

        ESP_ERROR_CHECK(i2c_master_stop(i2chandle));


        vTaskDelay(1000 / portTICK_PERIOD_MS);
        ESP_LOGI(TAG, "I2C Send byte");
    }
}


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

Re: ESP32-C3 i2c not work

Postby ESP_Sprite » Thu Dec 09, 2021 2:13 am

Are you sure the device is connected and addressed correctly? Those ESP_ERROR_CHECK checks can also trigger if a device doesn't properly ACKs packets, I think. Possibly using a logic analyzer to see what's going on on the line may help.

User avatar
jgustavoam
Posts: 117
Joined: Thu Feb 01, 2018 2:43 pm
Location: Belo Horizonte , Brazil
Contact:

Re: ESP32-C3 i2c not work

Postby jgustavoam » Sat Jan 22, 2022 1:30 am

Which device is connected to the I2C bus? Does this device already have pullup resistors?
I suggest testing I2C addressing with this scanner

https://www.esp32.com/viewtopic.php?f=18&t=4742
Retired IBM Brasil
Electronic hobbyist since 1976.

Who is online

Users browsing this forum: No registered users and 114 guests