Hardware I2C doesn't work on ESP32-C5
Port, board and/or hardware
esp32 port, ESP32-C5-DevKitC-1 v1.2
MicroPython version
MicroPython v1.27.0 on 2025-12-09; ESP32C5 module with ESP32C5
Reproduction
import machine
i2c0 = machine.I2C(id=0)
i2c1 = machine.I2C(id=1)
i2c0.scan()
i2c1.scan()
Expected behaviour
i2c0 and i2c1 should be created with no errors, and both should be able to scan and perform read/write operations.
Observed behaviour
Attempting to create i2c0 causes a reboot:
MicroPython v1.27.0 on 2025-12-09; ESP32C5 module with ESP32C5
Type "help()" for more information.
>>> import machine
>>> i2c0 = machine.I2C(id=0)
ESP-ROM:esp32c5-eco2-20250121
Build:Jan 21 2025
rst:0x1a (CPU_LOCKUP),boot:0x5b (SPI_FAST_FLASH_BOOT)
Core0 Saved PC:0x4200757e
SPI mode:DIO, clock div:1
load:0x408556b0,len:0xdfc
load:0x4084bba0,len:0xc4c
load:0x4084e5a0,len:0x2ee8
entry 0x4084bba0
MicroPython v1.27.0 on 2025-12-09; ESP32C5 module with ESP32C5
Type "help()" for more information.
>>>
Attempting to create i2c1 results in error messages. The I2C scan (and read/write methods) complains that the driver is not installed:
MicroPython v1.27.0 on 2025-12-09; ESP32C5 module with ESP32C5
Type "help()" for more information.
>>> import machine
>>> i2c1 = machine.I2C(id=1)
E (22747) i2c: i2c_driver_install(305): LP_I2C is not supported via i2c_driver_intall()
>>> i2c1 = machine.I2C(id=1)
E (24887) i2c: i2c_driver_delete(484): i2c driver install error
E (24887) i2c: i2c_driver_install(305): LP_I2C is not supported via i2c_driver_intall()
>>> i2c1.scan()
E (29467) i2c: i2c_master_cmd_begin(1552): i2c driver not installed
E (29467) i2c: i2c_master_cmd_begin(1552): i2c driver not installed
E (29467) i2c: i2c_master_cmd_begin(1552): i2c driver not installed
...
E (30107) i2c: i2c_master_cmd_begin(1552): i2c driver not installed
E (30107) i2c: i2c_master_cmd_begin(1552): i2c driver not installed
E (30117) i2c: i2c_master_cmd_begin(1552): i2c driver not installed
[]
>>>
Additional Information
I also noticed i2c1 (which is presumably the LP I2C peripheral) uses scl=9, sda=8:
>>> i2c1
I2C(1, scl=9, sda=8, freq=400000, timeout=50000)
However LP I2C on the ESP32-C5 can only be used on pins 2 and 3 (see the ESP32-C5 datasheet, section 4.2.1.3, "Pin Assignment").
FWIW SoftI2C() seems to work fine.
Code of Conduct
Yes, I agree
CONFIG_XTAL_FREQ = 0 for esp32c5
Port, board and/or hardware
esp32c5
MicroPython version
Hello, I have a question regarding MicroPython that I'm having trouble understanding.
Please take a look at my forked repository. I'm working on adding MicroPython support for the ESP32C5 (some code has already been committed to GitHub).
When compiling with the command make BOARD=SEEED_XIAO_ESP32C5, I encounter an error:
ports/esp32/machine_i2c.c (#error "I2C uses XTAL but no configured freq")
I checked the generated sdkconfig and quickly identified the issue:
grep -r "CONFIG_XTAL_FREQ" ./build-SEEED_XIAO_ESP32C5/sdkconfig CONFIG_XTAL_FREQ_AUTO=y CONFIG_XTAL_FREQ=0
I then tried to modify it following the approach used for ESP32C2 (where CONFIG_XTAL_FREQ is set to 26), but unfortunately, my modifications were unsuccessful.
No matter what I try, the value of CONFIG_XTAL_FREQ remains 0.
The methods I've attempted are as follows:
1、In boards/SEEED_XIAO_ESP32C5/mpconfigboard.cmake, directly include boards/sdkconfig.c2 (using C2's configuration directly, which sets CONFIG_XTAL_FREQ to 26)
<img width="971" height="380" alt="Image" src="https://github.com/user-attachments/assets/48e6c603-7647-4cc9-b077-ecf25b4fc16e" />
2、In boards/SEEED_XIAO_ESP32C5/sdkconfig.board, set "CONFIG_XTAL_FREQ_AUTO=n"
<img width="993" height="237" alt="Image" src="https://github.com/user-attachments/assets/563e8501-a41f-49ce-b20b-de5fb5e761fc" />
3、Use idf.py -DBOARD=SEEED_XIAO_ESP32C5 menuconfig to configure it through the menu interface
<img width="1041" height="190" alt="Image" src="https://github.com/user-attachments/assets/10340eca-595c-46f3-aa60-0b178b336a5e" />
However, all three methods have failed. I can't understand why this is happening. Could there be something I'm missing in the configuration process?
Reproduction
1 git clone https://github.com/AZKKXL/micropython.git
2 git checkout xiao_esp32c5
3 make BOARD=SEEED_XIAO_ESP32C5
Expected behaviour
No response
Observed behaviour
[1204/1472] Generating ../../genhdr/qstr.i.last
FAILED: genhdr/qstr.i.last /home/itcast/Code/micropython/ports/esp32/build-SEEED_XIAO_ESP32C5/genhdr/qstr.i.last
/bin/sh esp-idf/main/CMakeFiles/qstr.i.last-93c470f.sh f83c7955379aa9c2
/home/itcast/Code/micropython/ports/esp32/machine_i2c.c:43:2: error: #error "I2C uses XTAL but no configured freq"
43 | #error "I2C uses XTAL but no configured freq"
Additional Information
No, I've provided everything above.
Code of Conduct
Yes, I agree