PiicoDev_Unified.py bookworm config

I am a python noob, but inside the PiicoDev_Unified.py code, shouldn’t this class be using the same logic the i2c_setup.sh is doing in regards to working out the config file location? In bookworm, it should be boot/firmware/config.txt

class I2CUnifiedLinux(I2CBase):
    def __init__(self, bus=None, suppress_warnings=True):
        if suppress_warnings == False:
            with open('/boot/config.txt') as config_file:
                if 'dtparam=i2c_arm=on' in config_file.read():
                    pass
                else:
                    print('I2C is not enabled. To enable' + setupi2c_str)
                config_file.close()
            with open('/boot/config.txt') as config_file:
                if 'dtparam=i2c_arm_baudrate=400000' in config_file.read():
                    pass
                else:
                    print('Slow baudrate detected. If glitching occurs' + setupi2c_str)
                config_file.close()
        if bus is None:
            bus = 1
        self.i2c = SMBus(bus)
2 Likes

Hi @Cam267847,

Welcome to the forums! I can’t say I have much experience in setting up libraries for hardware but I know that that config path is correct for most Pi OS releases.

Looking through some Raspberry Pi forum posts this changed only impacts Bookworm and not the other distributions.

Does this fix work for you?

2 Likes

Instead of hardcoding /boot/config.txt, you can first check if /boot/firmware/config.txt exists and use that. If not, fall back to the default /boot/config.txt.

1 Like

Yes.
Bookworm changed the location of config.txt.
Hard to deal with considering all previous versions did not.
The unified code was written well before Bookworm came out.
I just changed the unified code where I need to.

The suggestion by @lia262073 is the best way to deal with it for now. Who knows what changes may occur in future releases.

Cheers
Jim

3 Likes

Hey All,

There’s a new branch dev-linux-init that should solve all of these warnings appearing.

The startup bash script to install already addresses both pre-bookworm and bookworm

3 Likes