Running OpenWrt on an Orange Pi Zero, it is working well in general but I cannot get i2c to work.
root@OpenWrt:~# cat /etc/os-release
OPENWRT_RELEASE="OpenWrt SNAPSHOT r11925-414d054138"
root@OpenWrt:~# i2cdetect -y 0
Error: Could not open file `/dev/i2c-0' or `/dev/i2c/0': No such file or directory
root@OpenWrt:~# modprobe i2c-dev
failed to find a module named i2c-dev
root@OpenWrt:~# opkg list | grep i2c
i2c-tools - 4.1-3
kmod-i2c-algo-bit - 4.19.93-1
kmod-i2c-core - 4.19.93-1
kmod-i2c-gpio - 4.19.93-1
kmod-i2c-smbus - 4.19.93-1
libi2c - 4.1-3
root@OpenWrt:~# rmmod i2c-gpio
root@OpenWrt:~# insmod i2c-gpio
# Seems to do nothing; no message in dmesg
What might be the reason for the missing /dev/i2c-0
?
Are CONFIG_I2C_CHARDEV
and/or CONFIG_REGMAP_I2C
set in the sunxi armv7 kernel? How can I check this? (For comparison, both are set to "y" in miZy, see the next post below)
Is the .dts file configured to use i2c on sunxi armv7 and how can I check this? (why does zcat /proc/config.gz
not work on OpenWrt trunk)?
It works when I am using the OpenWrt-based miZy instead of OpenWrt trunk:
_ ____
_ _ (_)_ / __
/ ' '| |/ /\/ /
|_|_|_|_/ /\ /
/___/_/
tiny fast embeded linux
BASE: OpenWrt DESIGNATED DRIVER (Bleeding Edge, 50015)
AUTHOR: ## hyphop ##
MOD: miZy musicbox
alsa + ffmpeg + mpd + mpc + wifi + net + ir
BUILD: Tue Feb 20 12:30:18 ICT 2018 / board: h2 / net: 1
root@miZy:~# ls /dev/
bus/ mtd0ro rfkill tty23 tty45 ttyS0
console mtd1 root tty24 tty46 uhid
cpu_dma_latency mtd1ro rtc0 tty25 tty47 uinput
disp mtd2 shm/ tty26 tty48 urandom
full mtd2ro snd/ tty27 tty49 usbdev2.1
i2c-0 mtdblock0 sunxi-reg tty28 tty5 usbdev3.1
input/ mtdblock1 sunxi_soc_info tty29 tty50 usbdev4.1
ion mtdblock2 tty tty3 tty51 usbdev6.1
kmsg net/ tty0 tty30 tty52 usbdev7.1
lirc0 network_latency tty1 tty31 tty53 usbdev8.1
log network_throughput tty10 tty32 tty54 vcs
loop-control null tty11 tty33 tty55 vcs1
loop0 psaux tty12 tty34 tty56 vcs4
loop1 ptmx tty13 tty35 tty57 vcsa
loop2 pts/ tty14 tty36 tty58 vcsa1
loop3 ram0 tty15 tty37 tty59 vcsa4
loop4 ram1 tty16 tty38 tty6 vmouse
loop5 ram2 tty17 tty39 tty60 watchdog
loop6 ram3 tty18 tty4 tty61 zero
loop7 ram4 tty19 tty40 tty62
mapper/ ram5 tty2 tty41 tty63
mem ram6 tty20 tty42 tty7
mmcblk0 ram7 tty21 tty43 tty8
mtd0 random tty22 tty44 tty9
root@miZy:~# ls /dev/i2c-0
root@miZy:~# lsmod
cfg80211 157396 2 xradio_wlan,mac80211
cifs 231070 0
exfat 104413 0
ext4 392367 0
fat 45709 1 vfat
g_ether 38606 0
i2c_sunxi 12618 0
ir_lirc_codec 3685 0
ir_nec_decoder 1556 0
jbd2 69453 1 ext4
lirc_dev 7846 1 ir_lirc_codec
mac80211 359963 1 xradio_wlan
mbcache 5494 1 ext4
rc_core 12751 4 ir_nec_decoder,ir_lirc_codec,sunxi_cir
sun8iw7_sndcodec 18072 1
sunxi_cir 1601 0
sunxi_codec 1395 1
sunxi_codecdma 3779 1
sunxi_sndcodec 1974 1
vfat 8826 0
xradio_wlan 210762 0
root@miZy:~# zcat /proc/config.gz | grep CONFIG_I2C_CHARDEV
CONFIG_I2C_CHARDEV=y
root@miZy:~# zcat /proc/config.gz | grep CONFIG_REGMAP_I2C
CONFIG_REGMAP_I2C=y
https://github.com/melsem/openwrt-lede_xradio-xr819_soc-audio/issues/2 says one needs to add in the (which?) DTS file:
&i2c0 {
status = "okay";
};
&i2c1 {
status = "okay";
};
&i2c2 {
status = "okay";
};
What would be necessary for OpenWrt to do this by default out-of-the-box?
mk24
January 8, 2020, 10:10pm
5
I think that i2c-gpio emulates I2C by "bit-banging" GPIO pins. This may or may not work on your hardware. You probably need to at least tell it which pins to use using options at load time. To use the chip's hardware I2c you would need to first set up the DTS file to re-map the pins from GPIO to the I2C hardware, then install a different kmod. The DTS file is sort of integral to the kernel so you need to re-compile the kernel to change it.
I2C0.patch
Included wifi-xr819 and built-in support for soc-audio , SPI NOR, usb2-usb3 .
Support sunxi-ir , 1Wire (PA06 gpio-6), i2c0 (SCA-PA11 SDA-PA12).
Support cpufreq -dt, thermal-sunxi (ths).
Finished Images.
orangepi-zero-ext4-sdcard.img.gz
orangepi-zero-LTS-ext4-sdcard.img.gz
Ir-remote control: 192.168.10.1/cgi-bin/modules/ev-irc/Setup.cgi.
Info themperature, cpu freq: 192.168.10.1/cgi-bin/modules/about/index.cgi
1 Like
Thanks @skreyda , very useful. Do you plan to send a pull request to the OpenWrt project so that your improvements will become part of standard OpenWrt?
The reason I am asking is that I am using the OpenWrt Image Builder to make customized images.
@skreyda how do I use i2c?
The i2c_dev
module is loaded by default, but there is no /dev/i2c-0
device and the following does not work for me:
root@orangepi-zero:~# i2cdetect 0
Error: Could not open file `/dev/i2c-0' or `/dev/i2c/0': No such file or directory
dmesg | grep i2c
[ 8.883368] i2c /dev entries driver
I can confirm that WLAN works.
skreyda
January 10, 2020, 10:56pm
9
I’ll connect the LCD and check it myself.
1 Like
skreyda
January 12, 2020, 10:48pm
10
Fixed.
Patch
cat /etc/os-release
root@orangepi-zero-lts:~# cat /etc/os-release
NAME="OpenWrt"
VERSION="SNAPSHOT"
ID="openwrt"
ID_LIKE="lede openwrt"
PRETTY_NAME="OpenWrt SNAPSHOT"
VERSION_ID="snapshot"
HOME_URL="https://openwrt.org/ "
BUG_URL="https://bugs.openwrt.org/ "
SUPPORT_URL="https://forum.openwrt.org/ "
BUILD_ID="r11788-db992e7"
OPENWRT_BOARD="sunxi/cortexa7"
OPENWRT_ARCH="arm_cortex-a7_neon-vfpv4"
OPENWRT_TAINTS="no-all"
OPENWRT_DEVICE_MANUFACTURER="OpenWrt"
OPENWRT_DEVICE_MANUFACTURER_URL="https://openwrt.org/ "
OPENWRT_DEVICE_PRODUCT="Generic"
OPENWRT_DEVICE_REVISION="v0"
OPENWRT_RELEASE="OpenWrt SNAPSHOT r11788-db992e7"
root@orangepi-zero-lts:~#
i2cdetect -y 0
root@orangepi-zero-lts:~# i2cdetect -y 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- 27 -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
root@orangepi-zero-lts:~#
root@orangepi-zero-lts:~# i2cdetect -l
i2c-0 i2c mv64xxx_i2c adapter I2C adapter
root@orangepi-zero-lts:~#
root@orangepi-zero-lts:~# 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 no
SMBus Block Process Call no
SMBus PEC yes
I2C Block Write yes
I2C Block Read yes
root@orangepi-zero-lts:~#
root@orangepi-zero-lts:~# echo pcf8574 0x27 > /sys/bus/i2c/devices/i2c-0/new_device
[ 5341.319886] i2c i2c-0: new_device: Instantiated device pcf8574 at 0x27
root@orangepi-zero-lts:~#
Finished Images.
orangepi-zero-ext4
orangepi-zero-LTS-ext4
imagebuilder
1 Like
probono
January 15, 2020, 7:40am
11
Thank you very much @skyreda . Unfortunately the Image Builder refuses to run on a 64-bit Travis CI build instance:
ERROR: ld.so: object '/home/travis/build/.../openwrt-for-orangepi-zero/openwrt-imagebuilder-sunxi-cortexa7.Linux-i686/staging_dir/host/bin/../lib/runas.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
Is there any chance you could make a 64-bit version, or give instructions how to build the Image Builder myself?
Do you plan to send your patches to the OpenWrt project so that they can be included in the main OpenWrt versions?
Again, thank you very much.
skreyda
January 15, 2020, 6:56pm
12
Maybe on the weekend I will run a 64-bit build.
I do not speak English.
Google translates poorly.
For (Pull Requests) I need to write normal commits for patches.
Divide the patches into small parts, it would be more convenient to read ..
1 Like
probono
January 19, 2020, 1:17pm
13
How do I need to configure so that I can install packages from normal OpenWrt?
When I use this repositories.conf
## Place your custom repositories here, they must match the architecture and version.
# src/gz %n http://downloads.openwrt.org/snapshots
# src custom file:///usr/src/openwrt/bin/sunxi/packages
## This is the local package repository, do not remove!
src imagebuilder file:packages
src opicyberwrt file:arm_cortex-a7_neon-vfpv4/opicyberwrt
src base file:arm_cortex-a7_neon-vfpv4/base
# src luci file:arm_cortex-a7_neon-vfpv4/luci
# src packages file:arm_cortex-a7_neon-vfpv4/packages
# src oldpackages file:arm_cortex-a7_neon-vfpv4/oldpackages
src/gz openwrt_core http://downloads.openwrt.org/snapshots/targets/sunxi/cortexa7/packages
# src/gz openwrt_base http://downloads.openwrt.org/snapshots/packages/arm_cortex-a7_neon-vfpv4/base
src/gz openwrt_luci http://downloads.openwrt.org/snapshots/packages/arm_cortex-a7_neon-vfpv4/luci
src/gz openwrt_packages http://downloads.openwrt.org/snapshots/packages/arm_cortex-a7_neon-vfpv4/packages
src/gz openwrt_routing http://downloads.openwrt.org/snapshots/packages/arm_cortex-a7_neon-vfpv4/routing
src/gz openwrt_telephony http://downloads.openwrt.org/snapshots/packages/arm_cortex-a7_neon-vfpv4/telephony
then I get these errors:
Collected errors:
* opkg_install_cmd: Cannot install package zram-swap.
* satisfy_dependencies_for: Cannot satisfy the following dependencies for luci-mod-admin-full:
* libubox20191228
* libubus20191227
* libubox20191228
* libubus20191227
* opkg_install_cmd: Cannot install package luci-mod-admin-full.
* satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-usb-audio:
* kernel (= 4.19.93-1-0ce53808f166f1306f4e32a4c6b0a698)
* opkg_install_cmd: Cannot install package kmod-usb-audio.
* satisfy_dependencies_for: Cannot satisfy the following dependencies for node-red:
* libnghttp2-14
* opkg_install_cmd: Cannot install package node-red.
* satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-cpufreq-dt:
* kernel (= 4.19.93-1-0ce53808f166f1306f4e32a4c6b0a698)
* opkg_install_cmd: Cannot install package kmod-cpufreq-dt.
* satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-rtc-sunxi:
* kernel (= 4.19.93-1-0ce53808f166f1306f4e32a4c6b0a698)
* opkg_install_cmd: Cannot install package kmod-rtc-sunxi.
* satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-sound-soc-sun4i-codec:
* kernel (= 4.19.93-1-0ce53808f166f1306f4e32a4c6b0a698)
* opkg_install_cmd: Cannot install package kmod-sound-soc-sun4i-codec.
* satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-xradio:
* kernel (= 4.19.93-1-0ce53808f166f1306f4e32a4c6b0a698)
* opkg_install_cmd: Cannot install package kmod-xradio.
* satisfy_dependencies_for: Cannot satisfy the following dependencies for mtd:
* libubox20191228
* opkg_install_cmd: Cannot install package mtd.
How can I use the kernel and kernel modules from your Image Builder and everything else from the normal OpenWrt repositories?
probono
January 19, 2020, 1:48pm
14
Even with much experimentation, I was not able to find a working repositories.conf
that allows me:
make image PROFILE=xunlong_orangepi-zero PACKAGES="-dnsmasq -iptables -ip6tables -ppp -ppp-mod-pppoe -firewall -odhcpd-ipv6only -odhcp6c -kmod-ipt-offload zram-swap nano libustream-mbedtls ca-bundle ca-certificates openssh-sftp-avahi-service avahi-daemon-service-http avahi-daemon-service-ssh uhttpd luci-mod-admin-full luci-base libiwinfo-lua luci-theme-bootstrap luci-i18n-base-de luci-compat asterisk16 asterisk16-pjsip asterisk16-bridge-simple asterisk16-codec-alaw asterisk16-codec-g722 asterisk16-codec-g726 asterisk16-sounds asterisk16-codec-gsm asterisk16-format-wav asterisk16-format-gsm asterisk16-res-rtp-asterisk asterisk16-util-astcanary asterisk16-voicemail kmod-usb-audio kmod-sound-core usbutils asterisk16-chan-alsa asterisk16-app-senddtmf alsa-utils shadow-usermod asterisk16-app-mp3 asterisk16-res-agi node-red mosquitto luci-i18n-travelmate-de" FILES="${FILES}" EXTRA_IMAGE_NAME="asterisk"
Please help.
skreyda
January 20, 2020, 8:40am
15
Edit: repositories.conf
## Place your custom repositories here, they must match the architecture and version.
# src/gz %n http://downloads.openwrt.org/snapshots
# src custom file:///usr/src/openwrt/bin/sunxi/packages
## This is the local package repository, do not remove!
src imagebuilder file:packages
Delete: / temp