MichaIng / DietPi

Lightweight justice for your single-board computer!
https://dietpi.com/
GNU General Public License v2.0
4.78k stars 496 forks source link

ASUS Tinker Board | I2C toggle #6946

Open cserl opened 6 months ago

cserl commented 6 months ago

Creating a bug report/issue

Required Information

Additional Information (if applicable)

Steps to reproduce after a fresh install

  1. Python 3: Runtime system, pip package installer and development headers were installed via dietpi-software config tool
  2. sudo apt install python3-smbus
  3. sudo apt-get install i2c-tools
  4. sudo reboot
  5. i2cdetect -y 1

Expected behaviour

       0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f 10:                                 -- -- -- -- -- -- -- 0f 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- uu -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --

Actual behaviour

Error: Could not open file /dev/i2c-1' or/dev/i2c/1': No such file or directory

The command runs as expected, not displaying any error message, when using these parameters: i2cdetect -y 0 i2cdetect -y 2

ls -l /dev/i2c* crw-rw---- 1 root i2c 89, 0 Mar 1 02:17 /dev/i2c-0 crw-rw---- 1 root i2c 89, 2 Mar 1 02:17 /dev/i2c-2 crw-rw---- 1 root i2c 89, 5 Mar 1 02:17 /dev/i2c-5

find /proc/device-tree/ -type d -name 'i2c' -exec ls -l {}/status \; -exec cat {}/status \; -exec echo \; 2> /dev/null -r--r--r-- 1 root root 5 Mar 1 12:01 /proc/device-tree/i2c@ff660000/status okay -r--r--r-- 1 root root 5 Mar 1 12:01 /proc/device-tree/i2c@ff170000/status okay -r--r--r-- 1 root root 9 Mar 1 12:01 /proc/device-tree/i2c@ff140000/status disabled -r--r--r-- 1 root root 9 Mar 1 12:01 /proc/device-tree/i2c@ff150000/status disabled -r--r--r-- 1 root root 5 Mar 1 12:01 /proc/device-tree/i2c@ff650000/status okay -r--r--r-- 1 root root 9 Mar 1 12:01 /proc/device-tree/i2c@ff160000/status disabled

Content of /boot/dietpiEnv.txt: image

Extra details

A "S.USV Tinker" hat is connected to the Tinkerboard. For the power supply and data transmission of the "S.USV Tinker" hat the following pins are in use: image

See Also https://github.com/MichaIng/DietPi/issues/5362 and https://dietpi.com/forum/t/dietpi-for-asus-thinker-board-i2c/16168

Please provide clear step by step instructions for workaround and support fixing. I am not familiar with the overlay concept, I found this link for rpi, but do not know if it is related or how to solve the issue: firmware/boot/overlays/README

I wish an I2C configuration menu under dietpi-config > Advanced Options.

I did a cross-test with a different SD card installing a fresh Tinker_Board-Debian-Stretch-v2.2.9-20210624.img on it. After fresh install issue seems to be the same: image But after changing the below 2 lines in /boot/config.txt it started working under Debian Stretch. Changes: before: overlay= after: overlay=i2c-gpio The line "intf:i2c1=off" was uncommented and changed to "intf:i2c1=on" image

How to achieve the same on DietPI?

MichaIng commented 4 months ago

Sorry for missing your issue. Please try the following:

current_overlays=$(sed -n '/^[[:blank:]]*overlays=/{s/^[^=]*=//p;q}' /boot/dietpiEnv.txt)
[[ $current_overlays =~ (^|[[:blank:]])i2c1([[:blank:]]|$) ]] || G_CONFIG_INJECT 'overlays=' "overlays=${current_overlays:+$current_overlays }i2c1" /boot/dietpiEnv.txt

The code checks whether the overlay has been added already, and does so if not. This is how I would add a dietpi-config option. In essence, you can just add i2c1 to the end of the overlays= line in /boot/dietpiEnv.txt and reboot. Let me know whether this works.