TheRemote / Ubuntu-Server-raspi4-unofficial

Ubuntu Server 18.04.4 Raspberry Pi 4 Image + Build Script (unofficial)
https://jamesachambers.com/raspberry-pi-4-ubuntu-server-desktop-18-04-3-image-unofficial/
Apache License 2.0
535 stars 93 forks source link

i2c issues #87

Closed fjp closed 4 years ago

fjp commented 4 years ago

Hi, thank you for the arm64 version. I am using your pre installed desktop release v21. Everything is working so far but I couldn't get i2c working.

I try to connect a grove oled display but when I execute sudo i2cdetect -y 1 I get the following error:

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

Using sudo raspi-config and enabeling i2c I got rid of this error. However, I still cannot see that the oled display is connected. I only get:

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

Ok I found the issue. I connected the device to i2c0 (physical pins 27 and 28, BCM 0 and 1, see pinout.xyz), which did not list any device. After I connected the oled display to i2c1 (physical pins 3 (sda) and 5 (scl)) i2cdetect -y 1 lists the device and I can send text to the display.

Is it normal that i2c0 is not working? How is it possible to enable both i2c pins?

TheRemote commented 4 years ago

Hey fjp,

If I'm reading this right then i2c 0 works but only if you manually run the i2cdetect command on it?

It may be a udev rule that isn't present in Ubuntu but is in Raspbian

fjp commented 4 years ago

Hi @TheRemote sorry for the confusion, it was rather late when I tried this. I slightly edited my previous post. i2c0 (physical pins 27 and 28) seemed to be not working but I will try again soon to verify that both i2c interfaces are working.

fjp commented 4 years ago

@TheRemote I can confirm that I have troubles to get i2c0 (physical pins 27 and 28) working. Here is the output of i2cdetect for both i2c interfaces:

fjp@ubuntu:~$ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
fjp@ubuntu:~$ sudo i2cdetect -y 0
Error: Could not open file `/dev/i2c-0' or `/dev/i2c/0': No such file or directory

And to get i2c1 working in the first place I had to run sudo raspi-config and enable I2C in the interfacing options. I don't know why this was necessary because I saw that /boot/config.txt already contained the option dtparam=i2c_arm=on. Any ideas why the i2c didn't work out of the box after installing release v21? Is the raspi-config doing something else to enable i2c? If so, something seems to be still wrong with i2c0.

TheRemote commented 4 years ago

This can be fixed by adding the following to config.txt:

dtparam=i2c1=on dtparam=i2c0=on

TheRemote commented 4 years ago

I added these options into the config.txt to make them easy to find.

Marking as fixed for v23.