esp-idf-cxx icon indicating copy to clipboard operation
esp-idf-cxx copied to clipboard

Fix for esp32c6

Open ptxmac opened this issue 10 months ago • 2 comments

Description

A minor fix so esp-idf-cxx can compile correctly for esp32c6 (and maybe other?)

i2c_cxx incorrectly assumed that I2C_NUM_1 would exist if SOC_I2C_NUM >= 2. But that's not the case when the device has 1 HP i2c and 1 LP i2c.

This changes i2c_cxx to look at only the HP SOC_HP_I2C_NUM instead

Testing

My own code compiles now 😄


Checklist

Before submitting a Pull Request, please ensure the following:

  • [x] 🚨 This PR does not introduce breaking changes.
  • [ ] All CI checks (GH Actions) pass.
  • [x] Documentation is updated as needed.
  • [x] Tests are updated or added as necessary.
  • [x] Code is well-commented, especially in complex areas.
  • [x] Git history is clean — commits are squashed to the minimum necessary.

ptxmac avatar Jan 12 '25 18:01 ptxmac

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jan 12 '25 18:01 CLAassistant

Tests fails for unrelated reasons

ptxmac avatar Jan 14 '25 11:01 ptxmac

https://github.com/espressif/esp-idf/issues/14291 I think same issue by the way. Can you rerun tests?

AnatoliiShablov avatar May 31 '25 07:05 AnatoliiShablov

Can you rerun tests?

I don't think I have permissions to do that

ptxmac avatar Jun 01 '25 09:06 ptxmac

This will not fix the issue! Please see my proposed request: oops - removing the fork obviously closes a pull request.

I'm sorry. At least this should be rejected as the logic is not OK at all!

SOC_I2C_NUM is the total of I2C devices of the CPU. It's the sum of SOC_HP_I2C_NUM and SOC_LP_I2C_NUM. The problem arises from that respective check not accounting for this fact.

#if SOC_I2C_NUM >= 2
    /* fix issue #38 "Build fails on ESP32-C6 due to missing I2C_NUM_1 in i2c_cxx.cpp".     **
     * This fix only adresses the problem at hand in case of the C6, where SOC_I2C_NUM == 2 **
     * and we have "I2C_NUM_0" as well as "LP_I2C_NUM_0" defined, but no "I2C_NUM_1".       */
#	if SOC_LP_I2C_SUPPORTED && SOC_I2C_NUM == 2
		static_assert( (LP_I2C_NUM_0 == 1), "LP_I2C_NUM_0 must be equal to 1, as I2C_NUM_0 already is equal to 0");
#	else
		static_assert( (I2C_NUM_1 == 1), "I2C_NUM_1 must be equal to 1");
#	endif
#endif // SOC_I2C_NUM >= 2

Even this could logically be not completely correct. Please review.

St0fF-NPL-ToM avatar Nov 05 '25 21:11 St0fF-NPL-ToM