I2C on EspressoBin Board

after applying what is said in help topic (same subject) here : I2C on Espressobin V7

dtc -I fs -O dts /proc/device-tree | grep -C5 i2c
                                        #gpio-cells = <0x02>;                                                                                                
                                        linux,phandle = <0x0c>;                                                                                              
                                        gpio-ranges = <0x05 0x00 0x00 0x24>;                                                                                 
                                };                                                                                                                           
                                                                                                                                                             
                                i2c2-pins {                                                                                                                  
                                        function = "i2c";                                                                                                    
                                        groups = "i2c2";                                                                                                     
                                };                                                                                                                           
                                                                                                                                                             
                                i2c1-pins {                                                                                                                  
                                        function = "i2c";                                                                                                    
                                        groups = "i2c1";                                                                                                     
                                };                                                                                                                           
                                                                                                                                                             
                                uart2-pins {                                                                                                                 
                                        function = "uart";                                                                                                   
                                        groups = "uart2";                                                                                                    
--                                                                                                                                                           
                                        full-duplex;                                                                                                         
                                        speed = <0x3e8>;                                                                                                     
                                };                                                                                                                           
                        };                                                                                                                                   
                                                                                                                                                             
                        i2c@11080 {                                                                                                                          
                                #address-cells = <0x01>;                                                                                                     
                                mrvl,i2c-fast-mode;                                                                                                          
                                interrupts = <0x00 0x02 0x04>;                                                                                               
                                clocks = <0x02 0x09>;                                                                                                        
                                #size-cells = <0x00>;                                                                                                        
                                compatible = "marvell,armada-3700-i2c";                                                                                      
                                status = "okay";                                                                                                             
                                reg = <0x11080 0x24>;                                                                                                        
                        };                                                                                                                                   
                                                                                                                                                             
                        interrupt-controller@1d00000 {                                                                                                       
--                                                                                                                                                           
                                                };                                                                                                           
                                        };                                                                                                                   
                                };                                                                                                                           
                        };                                                                                                                                   
                                                                                                                                                             
                        i2c@11000 {                                                                                                                          
                                #address-cells = <0x01>;                                                                                                     
                                mrvl,i2c-fast-mode;                                                                                                          
                                interrupts = <0x00 0x01 0x04>;                                                                                               
                                clocks = <0x02 0x0a>;                                                                                                        
                                #size-cells = <0x00>;                                                                                                        
                                compatible = "marvell,armada-3700-i2c";                                                                                      
                                status = "okay";                                                                                                             
                                reg = <0x11000 0x24>;                                                                                                        
                        };                                                                                                                                   
                                                                                                                                                             
                        nb-periph-clk@13000 {                                                                                                                

but still no /dev/i2c after reboot !

root@RELAY:/# opkg list-installed | grep i2c                                                                                                                 
i2c-tools - 4.1-3                                                                                                                                            
kmod-i2c-algo-bit - 4.14.221-1                                                                                                                               
kmod-i2c-core - 4.14.221-1                                                                                                                                   
kmod-i2c-gpio - 4.14.221-1                                                                                                                                   
kmod-i2c-gpio-custom - 4.14.221-3                                                                                                                            
kmod-i2c-smbus - 4.14.221-1                                                                                                                                  
libi2c - 4.1-3                                                                                                                                               
root@RELAY:/# i2cdetect -l                                                                                                                                   
root@RELAY:/# 
root@RELAY:/# uname -ar                                                                                                                                      
Linux RELAY 4.14.221 #0 SMP Mon Feb 15 15:22:37 2021 aarch64 GNU/Linux                                                                                       

OpenWrt release 19.07.7

second try with direct GPIO and kmod-i2c-gpio-custom :

gpio-484 (SDA) = J17-15 (MPP1_8)
gpio-488 (SCL) = J17-16 (MPP1_12)

root@RELAY:/# /sbin/insmod i2c-gpio-custom bus0=0,484,488                                                                                                    
[   36.409883] Custom GPIO-based I2C driver version 0.1.2                                                                                                                                                                                                                                                                 
[   40.808891] i2c-gpio i2c-gpio.0: using pins 484 (SDA) and 488 (SCL)
                                                                                       

root@RELAY:/# i2cdetect -l                                                                                                                                   
i2c-0   i2c             i2c-gpio0                               I2C adapter
                                                                                  

root@RELAY:~# i2cdetect 0
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0.
I will probe address range 0x03-0x77.
Continue? [Y/n] 
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
10: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
20: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
30: -- -- -- -- -- -- -- -- 38 39 3a 3b 3c 3d 3e 3f 
40: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
70: 70 71 72 73 74 75 76 77                         

Note that you don't need those if you're using native I²C support.

Thanks @AndrewZ, but I still don't see /dev/i2c... while they are define in dtb !

root@RELAY:~# i2cdetect -F 0
Functionalities implemented by /dev/i2c-0:
I2C                              yes
SMBus Quick Command              yes
SMBus Send Byte                  yes
SMBus Receive Byte               yes
SMBus Write Byte                 yes
SMBus Read Byte                  yes
SMBus Write Word                 yes
SMBus Read Word                  yes
SMBus Process Call               yes
SMBus Block Write                yes
SMBus Block Read                 yes
SMBus Block Process Call         yes
SMBus PEC                        yes
I2C Block Write                  yes
I2C Block Read                   yes
root@RELAY:~# i2cdetect -y -r 0
     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: -- -- -- -- -- -- -- --                         

git clone https://github.com/polkabana/bsb_ssd1306_i2c.git
opkg install make gcc

cd bsb_ssd1306_i2c/src
make build
make install

nano oled_test.py

from ssd1306_i2c import SSD1306
ssd = SSD1306(0, 0x3c) # /dev/i2c-0, device address 0x3c
ssd.clear()
ssd.circle(25, 25, 15, 1)
ssd.line(0, 0, 127, 20, 1);
ssd.update()
ssd.write("SSD1306 I2C", x=5, y=6)
ssd.update()

ssd.font("Fixed3x5")
ssd.write("1234567890", x=5, y=9, color=1)
ssd.font("Arial14")
ssd.write("1234567890", x=5, y=20, color=1)
ssd.font("Corsiva12")
ssd.write("1234567890", x=5, y=40, color=1)
ssd.update()

python oled_test.py

https://luma-oled.readthedocs.io/en/develop/intro.html

WORKS also...GREAT !!
Full of exemples : https://github.com/rm-hull/luma.examples

python3 starfield.py  --i2c-port 0

1 Like

Its good you finished all the steps, except for one. What you really need now is to enable I2c in Kernel. So do make kernel_menuconfig, find i2c support under device drivers, and enable the correct I2C driver. The armada-3700 I2C host controller driver is “i2c-pxa“. If you are editing the config file, then Config_i2c_pxa=y and rebuild your image.

2 Likes