u8g2-hal-esp-idf
u8g2-hal-esp-idf copied to clipboard
Build issues on esp-idf 5.
Hi Markus, really appreciate building this lib! I am trying to use this lib to make u8g2 working with esp32. And I am running into a few build issues.
Issue 1: I2C_NUM_1 is not defined, because esp32-c3 only have 1 i2c port.
Compiling .pio\build\seeed_xiao_esp32c3\components\u8g2-hal-esp-idf\src\u8g2_esp32_hal.o
components\u8g2-hal-esp-idf\src\u8g2_esp32_hal.c: In function 'u8g2_esp32_i2c_byte_cb':
components\u8g2-hal-esp-idf\include/u8g2_esp32_hal.h:20:24: error: 'I2C_NUM_1' undeclared (first use in this function); did you mean 'I2C_NUM_0'?
20 | #define I2C_MASTER_NUM I2C_NUM_1 // I2C port number for master dev
Issue 2: portTICK_RATE_MS is removed in later FreeRTOS.
Compiling .pio\build\seeed_xiao_esp32c3\u8g2_esp32_hal.o
X:\Code\homemon\firmwares\third_party\u8g2-hal-esp-idf\src\u8g2_esp32_hal.c: In function 'u8g2_esp32_i2c_byte_cb':
X:\Code\homemon\firmwares\third_party\u8g2-hal-esp-idf\src\u8g2_esp32_hal.c:185:61: error: 'portTICK_RATE_MS' undeclared (first use in this function); did you mean 'portTICK_PERIOD_MS'?
185 | I2C_TIMEOUT_MS / portTICK_RATE_MS));
Issue 3: HSPI_HOST is deprecated after esp32-s2.
components\u8g2-hal-esp-idf\src\u8g2_esp32_hal.c: In function 'u8g2_esp32_spi_byte_cb':
components\u8g2-hal-esp-idf\src\u8g2_esp32_hal.c:68:42: error: 'HSPI_HOST' undeclared (first use in this function); did you mean 'SPI3_HOST'?
68 | ESP_ERROR_CHECK(spi_bus_initialize(HSPI_HOST, &bus_config, 1));
Since these issues seems to be straight forward to fix, I directly went ahead and made a naïve PR here: https://github.com/mkfrey/u8g2-hal-esp-idf/pull/8. Please let me know how they looks and hopefully they makes sense to you!
I had an issue when building u8g2 lib with ESP-IDF V5.2.
So I copy csrc and cppsrc into my components/u8g2. And create CMakeLists.txt with :
set(COMPONENT_ADD_INCLUDEDIRS csrc) file(GLOB COMPONENT_SRCS csrc/.c) file(GLOB COMPONENT_HDRS csrc/.h)
idf_component_register(SRCS ${COMPONENT_SRCS} ${COMPONENT_HDRS} INCLUDE_DIRS "csrc" "cppsrc")
I hope this can help.
@eehsx Could you open a separate issue or even create a repo showcasing your working fix?