Skip to content

I2C bus hardcoded to /dev/i2c-1 — should be configurable #26

@hybotix

Description

@hybotix

Problem

The compiled library liboptigatrust-i2c-linux-aarch64.so has /dev/i2c-1
hardcoded in the binary. On some Linux systems (such as Raspberry Pi 4B running
Trixie), the OPTIGA Trust M is not on bus 1.

For example, on Raspberry Pi 4B with Trixie, i2cdetect confirms the Trust M
is visible at address 0x30 on /dev/i2c-21, but the library always tries
/dev/i2c-1 and fails to connect.

Expected Behavior

The I2C bus should be configurable — either via an environment variable
(e.g. OPTIGA_I2C_DEV) or a configuration file — so the library works on
systems where the Trust M is not on bus 1.

Steps to Reproduce

  1. Connect Trust M breakout to Raspberry Pi 4B via QWIIC
  2. Run i2cdetect -y 21 — Trust M visible at 0x30
  3. Run python3 -c "import optigatrust; c = optigatrust.Chip(interface='i2c'); print(c)"
  4. Result: i2c: Failed to connect

Additional Information

  • Hardware: Raspberry Pi 4B running Debian 13 (Trixie)
  • Trust M breakout: Adafruit OPTIGA Trust M (ADA4351)
  • The source file extras/pal/linux/target/rpi3/pal_ifx_i2c_config.c
    hardcodes /dev/i2c-1 — this should read from an environment variable

Suggested Fix

In pal_ifx_i2c_config.c, read the I2C device from an environment variable:

const char *env = getenv("OPTIGA_I2C_DEV");
if (env != NULL) {
    strncpy(i2c_dev, env, sizeof(i2c_dev) - 1);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions