I am attempting to introduce bus errors on the I2C bus using the i2c-gpio fault injector already available under drivers/i2c/busses/. For my target platform (AST2600), I’ve enabled the following configuration options by manually editing the ast2600 deconfig file added these 2 lines:
CONFIG_I2C_GPIO=y
CONFIG_I2C_GPIO_FAULT_INJECTOR=y
After building and deploying the kernel, I cannot locate the expected interface:
/sys/kernel/debug/i2c-gpio-fault-injection
Could you please advise what step or configuration might be missing in this process?
- Linux kernel: v6.6.x
- Toolchain: arm-none-eabi-gcc
2 Answers 2
I’ve enabled the following configuration options by manually editing the ast2600 deconfig file added these 2 lines:
That's a mistake.
The defconfig and .config files used by the kconfig system should not be manually edited. You risk circumvention of a system of declared forward and backward dependencies that could yield an improper build.
You need to use the menuconfig (or similar) make target (e.g. make menuconfig) to ensure that all dependencies are satisfied and that all auto-selects will be enabled.
The CONFIG_I2C_GPIO option that you want to enable is a good example of a configuration option that is complex and will cause problems if hacked in.
Its Kconfig entry is:
config I2C_GPIO
tristate "GPIO-based bitbanging I2C"
depends on GPIOLIB || COMPILE_TEST
select I2C_ALGOBIT
help
This is a very simple bitbanging I2C driver utilizing the
arch-neutral GPIO API to control the SCL and SDA lines.
The "depends on" line declares that either CONFIG_GPIOLIB or CONFIG_COMPILE_TEST are dependencies or prerequites that must be enabled before this CONFIG_I2C_GPIO option can be enabled.
The "select" line declares that CONFIG_I2C_ALGOBIT will also be automatically enabled if this CONFIG_I2C_GPIO option is enabled.
Because this CONFIG_I2C_GPIO option has dependencies, you will not even see its
"GPIO-based bitbanging I2C"
menu line as long as the dependency is not satisfied.
Typically you would use the "search" feature of the menuconfig program to get the information to navigate the menus.
First you would search on this I2C_GPIO option that you want to enable.
That will return the Kconfig entry (as shown above) plus more information from which you can glean the dependencies (if any).
So then search on a dependency, such as GPIOLIB, to retrieve its Kconfig entry/description from which you can glean its menu path.
So navigate through the menus to enable that option, and expose the original option.
Addendum
Enabled GPIOLIB in Kconfig , dependencies for CONFIG_I2C_GPIO, still issue not resolved
That's a rather terse update some four weeks later.
Assuming that you now have a correct kernel config, then you can build a kernel image with the necessary driver (i2c-gpio). However (properly) configuring and building the driver into the kernel is only half the required task.
The other half is getting the kernel to execute the driver's init/probe routine.
This part of the task is satisfied (on ARM systems) by the Device Tree, which is a data structure (in a file passed to the kernel) which describes the hardware. This description of the system hardware also specifies the device driver assigned to each device using the compatible property.
Refer to the Documentation/devicetree/bindings/i2c/i2c-gpio.yaml file in kernel source on what properties are used in a DT node for the i2c-gpio driver.
Note that this DT node is how you would inform the kernel which GPIO pins you would use to inject errors into the I2C bus you have wired together.
If the i2c-gpio driver does (sucessfully) execute its probe routine, then expect to see a message in the syslog from the statement:
static int i2c_gpio_probe(struct platform_device *pdev)
{
...
dev_info(dev, "using lines %u (SDA) and %u (SCL%s)\n",
desc_to_gpio(priv->sda), desc_to_gpio(priv->scl),
pdata->scl_is_output_only
? ", no clock stretching" : "");
...
}
2 Comments
Actually changing defconfig manually or using menuconfig will lets you select I2CGPIO and I2CGPIO Fault Injector so the kernel knows about the driver but does not create any bus instance or inform the kernel which pins to use.
You should create a device Tree to tells the kernel "make a software I2C bus using these GPIO pins."The i2c-gpio driver looks for a specific node in the device tree to understand which GPIO pins to use for the I2C bus. Without this node, the driver has no bus to attach to.
This node must be added to your AST2600's specific .dts file or one of the .dtsi files it includes.
1 Comment
Explore related questions
See similar questions with these tags.