Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenWrt master 运行出错 #10

Closed
fanck0605 opened this issue Jul 14, 2020 · 13 comments
Closed

OpenWrt master 运行出错 #10

fanck0605 opened this issue Jul 14, 2020 · 13 comments

Comments

@fanck0605
Copy link
Contributor

fanck0605 commented Jul 14, 2020

自己用 OpenWrt master 的源码编译的,无法正常启动。
是不是依赖没装全,麻烦大佬看一下。

root@OpenWrt:~# /usr/bin/oled 0 0 1 1 0 60 0 0 0 0 0 0 0 0 0 0 0 1 OPENWRT
I2C: Failed to open device |: No such file or directory
(Main)i2c-2: OOPS! Something Went Wrong
@NateLol
Copy link
Owner

NateLol commented Jul 14, 2020

已merge PR

@NateLol NateLol closed this as completed Jul 14, 2020
@fanck0605
Copy link
Contributor Author

@NateLol
这是似乎是另一个问题😆,那个 pr 只解决了 luci 显示。
看了一下报错,应该是这两行的错误信息。

https://github.com/NateLol/luci-app-oled/blob/master/src/I2C_Library/I2C.c#L271
https://github.com/NateLol/luci-app-oled/blob/master/src/Example_Code/Main.c#L73

@NateLol NateLol reopened this Jul 14, 2020
@NateLol
Copy link
Owner

NateLol commented Jul 14, 2020

ssh上去试试这个

i2cdetect -y 0

看会不会出来3c

没有的话就有可能依赖没安全。

还可以去看是否有这个目录/dev/i2c-0

@fanck0605
Copy link
Contributor Author

fanck0605 commented Jul 14, 2020

没有 i2c-0,只找到了个 i2c-1

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


@NateLol 应该是我的依赖问题,我再看看

@NateLol
Copy link
Owner

NateLol commented Jul 14, 2020

因为这个程序中是写死了的,一定要是/dev/i2c-0

@fanck0605
Copy link
Contributor Author

fanck0605 commented Jul 14, 2020

jayanta525 的 openwrt 的 kernel config 里一股脑把 i2c 驱动全选了,所以用着没问题。

我用的是 blocktrron 的 openwrt 编译时,需要手动添加 kmod-i2c-xxx

NateLol added a commit that referenced this issue Aug 5, 2020
Update link for issue #10
@yoyojacky
Copy link

yoyojacky commented Sep 18, 2021

Hi, I have same issue, and am using Raspberry Pi CM4 router board.
OS information:

pi@upstest:~ $ ssh [email protected]
The authenticity of host '192.168.1.1 (192.168.1.1)' can't be established.
ED25519 key fingerprint is SHA256:NWZsaa/lvdIosladk3AmESFtMX907u7mhEEw1qZQNAY.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.1' (ED25519) to the list of known hosts.


BusyBox v1.34.0 (2021-09-05 21:52:35 UTC) built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt SNAPSHOT, r0-46dec99
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------

and I have already compile the kernel with selected i2c driver.

root@OpenWrt:~# dmesg |grep i2c
[    6.937830] i2c /dev entries driver
root@OpenWrt:~# lsmod |grep i2c
i2c_algo_bit           16384  1 i2c_gpio
i2c_bcm2835            16384  0
i2c_dev                20480  0
i2c_gpio               16384  0
i2c_mux                16384  1 i2c_mux_gpio
i2c_mux_gpio           16384  0
i2c_smbus              16384  0
root@OpenWrt:~# /usr/bin/oled 0 0 1 1 0 60 0 0 0 0 0 0 0 0 0 0 0 1 OPENWRT
I2C: Failed to open device |: No such file or directory
(Main)i2c-2: OOPS! Something Went Wrong
root@OpenWrt:~# i2cdetect -y 0
Error: Could not open file `/dev/i2c-0' or `/dev/i2c/0': No such file or directory
root@OpenWrt:~# i2cdetect -y 1
Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory

root@OpenWrt:~#  modprobe i2c-dev
root@OpenWrt:~# opkg list | grep i2c
i2c-tools - 4.3-1
kmod-i2c-algo-bit - 5.10.64-1
kmod-i2c-bcm2835 - 5.10.64-1
kmod-i2c-core - 5.10.64-1
kmod-i2c-gpio - 5.10.64-1
kmod-i2c-mux - 5.10.64-1
kmod-i2c-mux-gpio - 5.10.64-1
kmod-i2c-smbus - 5.10.64-1
libi2c - 4.3-1

and what i need to add into the kernel ? Could you please help me out?

@fanck0605
Copy link
Contributor Author

fanck0605 commented Sep 18, 2021

For NanoPi R2S the following patch needs to be applied to activate i2c-0.

https://github.com/immortalwrt/immortalwrt/blob/e26c0c7b3152c65c4e9eebd92b7ebd961c28711c/target/linux/rockchip/patches-5.4/201-rockchip-rk3328-add-i2c0-controller-for-nanopi-r2s.patch

Raspberry Pi CM4 may also require a similar patch.

I don't know much about this issue either. I'm sorry that I can't be of more help to you.

@yoyojacky
Copy link

For NanoPi R2S the following patch needs to be applied to activate i2c-0.

https://github.com/immortalwrt/immortalwrt/blob/e26c0c7b3152c65c4e9eebd92b7ebd961c28711c/target/linux/rockchip/patches-5.4/201-rockchip-rk3328-add-i2c0-controller-for-nanopi-r2s.patch

Raspberry Pi CM4 may also require a similar patch.

I don't know much about this issue either. I'm sorry that I can't be of more help to you.

thanks for your reply, and i have tried another way. and it seems works, but it always show "OLED is not working " in LuCI interface in browser.

I have tried to add this dtoverlay=i2c-gpio,i2c_gpio_sda=2,i2c_gpio_scl=3,i2c_gpio_delay_ us=2,bus=1 to /boot/config.txt and reboot my Raspberry Pi CM4.
now, i can detect the oled 0.91 display 's address via i2cdetec -y 1
but it still not working well.

root@OpenWrt:~# 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: -- -- -- -- -- -- -- --

image
when i ran /usr/bin/oled 0 0 1 1 0 60 0 0 0 0 0 0 0 0 0 0 0 1 OPENWRT command to test it still no luck.

@yoyojacky
Copy link

yoyojacky commented Sep 18, 2021

This program will only use i2c-0, which is written in the source code. If you connect the OLED to i2c-1, you need to modify the source code.

if(init_i2c_dev(I2C_DEV0_PATH, SSD1306_OLED_ADDR) == 0)

  
 
     /* Initialize I2C bus and connect to the I2C Device */
-    if(init_i2c_dev(I2C_DEV0_PATH, SSD1306_OLED_ADDR) == 0)
+    if(init_i2c_dev(I2C_DEV1_PATH, SSD1306_OLED_ADDR) == 0)
     {
         printf("(Main)i2c-2: Bus Connected to SSD1306\r\n");
     }

I2C_DEVx_PATH is defined here

#define I2C_DEV0_PATH "/dev/i2c-0"

thanks for your tips, I have already change the test command to :

/usr/bin/oled 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 60 0 1 openwrt 1

and it works.
image
image
The key parameters is to change the /boot/config.txt file and add:

dtoverlay=i2c-gpio,i2c_gpio_sda=2,i2c_gpio_scl=3,i2c_gpio_delay_us=2,bus=1

and BTW, need to change the permission of the etc/init.d/oled from 644 to 755. and restart /etc/init.d/oled restart.
and save it, reboot CM4, it will works fine.

@NateLol
Copy link
Owner

NateLol commented Sep 18, 2021

Good, thank you both @yoyojacky @fanck0605 for the effort and this great information.

I am linking this in README for other Raspberry Pi CM4 users who might find it helpful.

@yoyojacky
Copy link

Good, thank you both @yoyojacky @fanck0605 for the effort and this great information.

I am linking this in README for other Raspberry Pi CM4 users who might find it helpful.

Thanks for your effort so that i can use your repo to build my custom router via Raspberry Pi CM4 module, it was so nice to have an oled 0.91 display on my router, thanks a lot ...

@daleking
Copy link

daleking commented Jan 1, 2024

For the Rpi4/CM4 using the bit-banged kmod-i2c-gpio driver I was seeing 1-2% CPU utilisation from the oled process. strace seemed to indicate this was during write to the driver - makes sense.

I installed kmod-i2c-bcm2835 which is the pi hardware driver which also uses the same pins 2,3 and CPU dropped dramatically.

To enable hardware I2C bus driver for the OLED display if using pins 2,3:

opkg install kmod-i2c-bcm2835
From /boot/config.txt replace:
dtoverlay=i2c-gpio,i2c_gpio_sda=2,i2c_gpio_scl=3,i2c_gpio_delay_us=2,bus=1
with:
dtparam=i2c1=on

After reboot /dev/i2c-1 will be the hardware I2C bus not the bit banged GPIO driver. You should see a 1-2% CPU reduction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants