Infineon / linux-optiga-trust-m

Linux tools and examples for OPTIGA™ Trust V1/V3 security solution
MIT License
22 stars 18 forks source link

Problem: Failed to open gpio direction for writing! #12

Closed filip-dahlberg closed 3 years ago

filip-dahlberg commented 3 years ago

Environment: Embedded Linux

I'm receiving following error no matter what program I'm invoking from CLI bin. It seems like the CLI programs cannot establish I2C communication to the optiga trust IC due to permission faults. image

I know that the I2C connection to the optiga trust m is available from executing trustx_scan. See output of trustx_scan -b /dev/i2c-0:

image

Would very much appreciate any help that can point me in right direction.

ayushev commented 3 years ago

Hello @MScMechatronics just to quickly check, did you change the GPIO settings here according to your board? Did you sucesfully compile the code with no problems on this board?

filip-dahlberg commented 3 years ago

Thank you very much for your prompt response.

Yes I successfully compiled the code by executing the commands in the README: make workaround_patch make sudo make install

Thanks for your advice on the PAL, I'll check that one out. It could also be some kind of driver issue on my side.

However, as the trustx_scan program finds the optiga chip through the I2C driver I was thinking that the Infineon/cli-optiga-trust-m bin program were also to work.

ayushev commented 3 years ago

The trustx_scan tool is indeed a first tool to understand whether you have a proper communcation in general. It just uses a generic /dev/i2c-1 device to probe the connection. Whereas the cli uses also the Reset and Power Control Lines (GPIOs) to communication with the chip. If you would like to skip this part and not use the GPIO (use e.g. software reset), you can just change the configuration (here for m1 or here for m3)

filip-dahlberg commented 3 years ago

Thanks ayushev , I very much appreciate your help. I now think I have clear understanding of how to proceed.

filip-dahlberg commented 3 years ago

I now manage to get response from the optiga IC by changing to /dev/i2c-0 here. I'm still experiencing the problem with "Problem: Failed to open gpio direction for writing!" which then seem to be a result of trying to write to reset/vdd GPIO, even if I configure it to not use the reset and vdd GPIOs by setting OPTIGA_COMMS_DEFAULT_RESET_TYPE to 1.

ayushev commented 3 years ago

To make fast and working setup you might just change this and this lines to NULL as soon as they are defined, the code will try to initialise the gpios. It shouldn't use them, but will try to initialize. With the address changed, were you able to run the commands?