mkfrey / u8g2-hal-esp-idf

U8g2 compatibility component for esp-idf on ESP32
Apache License 2.0
51 stars 27 forks source link

u8g2_esp32_i2c_byte_cb u8g2_esp32_hal.c:179 (0 && "i2c_master_cmd_begin(I2C_MASTER_NUM, handle_i2c, I2C_TIMEOUT_MS / portTICK_RATE_MS)") #3

Open ghost opened 2 years ago

ghost commented 2 years ago

Using your HAL code, I'm getting this error:

u8g2_esp32_i2c_byte_cb u8g2_esp32_hal.c:179 (0 && "i2c_master_cmd_begin(I2C_MASTER_NUM, handle_i2c, I2C_TIMEOUT_MS / portTICK_RATE_MS)")

I'm in the process of figuring out why, but opening an issue might be worthwhile.

ghost commented 2 years ago
␛[0;32mI (558) u8g2_hal: sda_io_num 21␛[0m
␛[0;32mI (558) u8g2_hal: scl_io_num 22␛[0m
␛[0;32mI (558) u8g2_hal: clk_speed 50000␛[0m
␛[0;32mI (568) u8g2_hal: i2c_param_config 1␛[0m
␛[0;32mI (568) u8g2_hal: i2c_driver_install 1␛[0m
␛[0;31mE (878) err: esp_err_t = -1␛[0m

assert failed: u8g2_esp32_i2c_byte_cb u8g2_esp32_hal.c:179 (0 && "i2c_master_cmd_begin(I2C_MASTER_NUM, handle_i2c, I2C_TIMEOUT_MS / portTICK_RATE_MS)")

Backtrace:0x40082243:0x3ffdd040 0x40089e0d:0x3ffdd060 0x40090d39:0x3ffdd080 0x400d4dd6:0x3ffdd1a0 0x4013c09d:0x3ffdd1e0 0x400d5a03:0x3ffdd200 0x400d5991:0x3ffdd220 0x400d5cb5:0x3ffdd250 0x400d5dc4:0x3ffdd270 0x4013bcc9:0x3ffdd290 0x400d3e92:0x3ffdd2b0 0x400d49b4:0x3ffdd3a0 0x40140451:0x3ffdd560 0x4008d395:0x3ffdd580
ghost commented 2 years ago

OLED is 128x64, board is Wemos/TTGO ESP32.

This I2C initialization works for me, but the library is painfully limited and I cannot put time into fixing someone else's shortcomings, just in case you see anything useful:

https://github.com/nopnop2002/esp-idf-ssd1306/blob/master/main/ssd1306_i2c.c

The HAL in this one is admittedly a bit ugly.

mkfrey commented 2 years ago

According to the docs the error code -1 is returned when the client does not ACK the transfer. Since it works with another library, I assume that the problem lies somwhere in your I2C setup.

ghost commented 2 years ago

TTGO LORA32 board, absolutely zero changes. I will check again but so far I came up with no explanations for this error. The linked I2C initialization code uses different frequency for master clock and timeouts and works perfectly.

r12f commented 1 year ago

I have had the same issue. And the reason is because the I2C address is not passed correctly. The library is expecting the (address << 1) instead of the raw address.

thedeadliestcatch commented 2 months ago

Seeing the same thing:

assert failed: u8g2_esp32_i2c_byte_cb u8g2_esp32_hal.c:180 (0 && "i2c_master_cmd_begin(I2C_MASTER_NUM, handle_i2c, pdMS_TO_TICKS(I2C_TIMEOUT_MS))")

Backtrace: 0x4008196a:0x3ffb76f0 0x40086c41:0x3ffb7710 0x4008c8b1:0x3ffb7730 0x400d830a:0x3ffb7850 0x400ee3c1:0x3ffb7890 0x400d7cc9:0x3ffb78b0 0x400d7de9:0x3ffb78d0 0x400ee2ba:0x3ffb78f0 0x400d7fb0:0x3ffb7910 0x400d8028:0x3ffb7930 0x400ee315:0x3ffb7950 0x400d71f2:0x3ffb7980 0x400d7211:0x3ffb79a0 0x400d7279:0x3ffb79c0 0x400d6eee:0x3ffb79e0 0x400876e9:0x3ffb7a00
0x4008196a: panic_abort at /esp-idf/components/esp_system/panic.c:463
0x40086c41: esp_system_abort at /esp-idf/components/esp_system/port/esp_system_chip.c:92
0x4008c8b1: __assert_func at /esp-idf/components/newlib/assert.c:80
0x400d830a: u8g2_esp32_i2c_byte_cb at project/components/u8g2-hal/src/u8g2_esp32_hal.c:180 (discriminator 17)
0x400ee3c1: u8x8_byte_EndTransfer at project/components/u8g2/csrc/u8x8_byte.c:61
0x400d7cc9: u8x8_i2c_data_transfer at project/components/u8g2/csrc/u8x8_cad.c:479
0x400d7de9: u8x8_cad_ssd13xx_fast_i2c at project/components/u8g2/csrc/u8x8_cad.c:581
0x400ee2ba: u8x8_cad_SendData at project/components/u8g2/csrc/u8x8_cad.c:110
0x400d7fb0: u8x8_d_st7567_enh_dg128064_generic at project/components/u8g2/csrc/u8x8_d_st7567.c:676
0x400d8028: u8x8_d_st7567_enh_dg128064i at project/components/u8g2/csrc/u8x8_d_st7567.c:733
0x400ee315: u8x8_DrawTile at project/components/u8g2/csrc/u8x8_display.c:89
0x400d71f2: u8g2_send_tile_row at project/components/u8g2/csrc/u8g2_buffer.c:63
0x400d7211: u8g2_send_buffer at project/components/u8g2/csrc/u8g2_buffer.c:86
0x400d7279: u8g2_NextPage at project/components/u8g2/csrc/u8g2_buffer.c:119

The creator of the issue provided absolutely zero usable/useful information about his I2C routines.

This is what I am doing, in essence:

    while (1)
    {
        /* i2c is failing with a timeout sometimes! */
        u8g2_FirstPage(&u8g2);

        do {
            screen_draw_ui(state);
        } while (u8g2_NextPage(&u8g2));

        vTaskDelay(400 / portTICK_PERIOD_MS);
    }

Inside a dedicated task for the screen/UI rendering.

Using a st7567 via I2C. (u8x8_d_st7567_enh_dg128064i)

There is a new HAL here: https://github.com/nopnop2002/esp-idf-ssd1306/blob/master/components/ssd1306/ssd1306_i2c_new.c

Anyone has any ideas?