DietPi icon indicating copy to clipboard operation
DietPi copied to clipboard

ASUS Tinker Board | I2C toggle

Open cserl opened this issue 2 years ago • 1 comments

Creating a bug report/issue

  • [ ] I have searched the existing open and closed issues

Required Information

  • DietPi version | cat /boot/dietpi/.version G_DIETPI_VERSION_CORE=9 G_DIETPI_VERSION_SUB=1 G_DIETPI_VERSION_RC=1 G_GITBRANCH='master' G_GITOWNER='MichaIng' G_LIVE_PATCH_STATUS[0]='not applicable' (The problem is existing since dietpi v6.28 for all versions. Before v6.28 it did work well.)
  • Distro version | echo $G_DISTRO_NAME $G_RASPBIAN bullseye
  • Kernel version | uname -a Linux DietPi 6.1.63-current-rockchip #1 SMP PREEMPT Mon Nov 20 10:52:19 UTC 2023 armv7l GNU/Linux
  • SBC model | echo $G_HW_MODEL_NAME or (EG: RPi3) ASUS Tinker Board (armv7l) (HW version: Tinker Board released in April 2017 2GB model, see https://en.wikipedia.org/wiki/Asus_Tinker_Board)
  • Power supply used | (EG: 5V 1A RAVpower) rpi power supply 5V, 2.5A
  • SD card used | (EG: SanDisk ultra) 2GB microSD from a Samsung Android phone, without branding

Additional Information (if applicable)

  • Context: Python3, python3-smbus, i2c-tools and the boot configuration of dietpi on Tinkerboard
  • All software including dietpi was installed freshly
  • Bug report ID | echo $G_HW_UUID 43e97bfe-1677-4705-b68a-4f07b545b076

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?

cserl avatar Mar 01 '24 10:03 cserl

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.

MichaIng avatar May 07 '24 15:05 MichaIng