Kconfig Mystery Solved
A couple of insights discovered recently to share with you today. LooUQ has a summer intern, Sy, working on developing with our hardware to test and prove out our designs in a class project. His inexperience with Nordic has proven to be insightful, as we see how a fresh perspective asks different questions. So, over the last week a question took some consideration to arrive at an answer, here it is…
Working with a ST ISM330DHCX
Sy’s project incorporates a ISM330DHCX from STMicroelectronics, which is available on an Adafruit breakout and attached via I2C. With a basic devicetree configuration the project built without any errors and ran.
One problem, the values for both the accelerometer and the gyroscope obtained were 0.00 for all three axes.
Further investigation showed the Kconfig symbol CONFIG_ISM330DHCX was configured as y but had a value of n. This is not a completely unknown pattern for Zephyr developers. Seem like a paradox: a “n” value on a config dependency but the project runs (albeit with invalid results).
If examined in Menuconfig and following the dependency up, the configuration symbol DT_HAS_ST_ISM330DHCX_ENABLED was equal to n; since that is an invisible Kconfig symbol you can’t change it.
How is this getting set?
Turns out the secret here was the prefix on the symbol “DT_HAS_”; must have something to do with the devicetree. Sure enough if you examine the .yaml binding file (st,ism330dhcx-common.yaml) there is an answer.
There are two properties that are not required and default to 0: accel-odr and gyro-odr (note that for value 0, the behavior is ISM330DHCX_DT_ODR_OFF). With both of these properties not in the overlay, the chip was essentially disabled and setting the invisible Kconfig symbor. After implementing the change below fixed the configuration (DT_HAS_ST_ISM330DHCX_ENABLED) and the behavior.
Changing
&i2c2 { ism330dhcx: ism330dhcx@6A { compatible = "st,ism330dhcx"; reg = <0x6A>; label = "ISM330DHCX"; }; };
To
&i2c2 { ism330dhcx: ism330dhcx@6A { compatible = "st,ism330dhcx"; reg = <0x6A>; label = "ISM330DHCX"; accel-odr = <1>; gyro-odr = <1>; }; };
Thanks for reading and have a wonderful day.