This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SPI and I2C for Rockchip
#1
Question 
Hi everyone here. I was wondering is there any way to enable the SPI and I2C interfaces for Tinker? They have posted the kernel source and it seems that drivers for those are present there. Is there any chance to use SPI and I2C as of now?
Reply
#2
SPI (3x) and I2C (6x) are in use now. You can study DeviceTree or newer from kernel sources and/or rk3288 Technical resource manuals (i2c) and (spi), schematics, connector and hardware config:

Code:
# cat /boot/hw_intf.conf
intf:i2c1=on
intf:i2c4=on
intf:spi2=on
intf:pwm2=on
intf:pwm3=on
intf:uart1=on

i2c0 - "pmu" - used internally for power management - chip rk808
i2c1 - "sensor" - on connector pin3+5
i2c2 - "audio" - on connector MIPI-CSI (camera) + eeprom (at24c08)
i2c3 - "cam" - on connector MIPI-DSI (display)
i2c4 - "tp" - on connector pin27+28
i2c5 - "hdmi" - used as hdmi ddc

spi0 - disabled - multiplexed with GPIO on connector pins 11,13,15,29,31
spi1 - disabled
spi2 - on connector pins 19,21,23,24,26

devices:
/dev/i2c*
/dev/spi*
find /sys/devices/platform/*i2c
find /sys/devices/platform/*spi
find /sys/firmware/devicetree/base/i2c*
find /sys/firmware/devicetree/base/spi*

(04-12-2017, 05:11 PM)Seraphim Wrote: Is there any chance to use SPI and I2C as of now?

Yes, you can use it too to be happy tinker/hacker.
I left this community in Aug 2017 due to ASUS bad product quality and ASUS community support that did not match my expectation.  Sad
Reply
#3
(04-13-2017, 05:57 PM)mcerveny Wrote: SPI (3x) and I2C (6x) are in use now. You can study DeviceTree or newer from kernel sources and/or rk3288 Technical resource manuals (i2c) and (spi), schematics, connector and hardware config:

Code:
# cat /boot/hw_intf.conf
intf:i2c1=on
intf:i2c4=on
intf:spi2=on
intf:pwm2=on
intf:pwm3=on
intf:uart1=on

i2c0 - "pmu" - used internally for power management - chip rk808
i2c1 - "sensor" - on connector pin3+5
i2c2 - "audio" - on connector MIPI-CAM (touch+camera module) + eeprom (at24c08)
i2c3 - "cam" - on connector MIPI-DSI
i2c4 - "tp" - on connector pin27+28
i2c5 - "hdmi" - used as hdmi ddc

spi0 - disabled - multiplexed with GPIO on connector pins 11,13,15,29,31
spi1 - disabled
spi2 - on connector pins 19,21,23,24,26

devices:
/dev/i2c*
/dev/spi*
find /sys/devices/platform/*i2c
find /sys/devices/platform/*spi
find /sys/firmware/devicetree/base/i2c*
find /sys/firmware/devicetree/base/spi*

(04-12-2017, 05:11 PM)Seraphim Wrote: Is there any chance to use SPI and I2C as of now?

Yes, you can use it too to be happy tinker/hacker.

I understand that. However I can not find out how to place new drivers in system and how interface with them (My tries with Python an C fails). As of now system sees the interfaces, but when I run i2cdetect -y 1 there is no recognition. Please, advice the algorithm. Thank you in advance.
Reply
#4
(04-13-2017, 07:04 PM)Seraphim Wrote: I understand that. However I can not find out how to place new drivers in system and how interface with them (My tries with Python an C fails). As of now system sees the interfaces, but when I run i2cdetect -y 1 there is no recognition. Please, advice the algorithm. Thank you in advance.

If you need kernel-level drivers you need modify main DeviceTree or make DeviceTree overlay (see CONFIG_OF_CONFIGFS) and enable driver in kernel. Search the internet.
If you need userspace access python is sufficient.

I attached BMP180 gadget [Image: _vyrp11_22BMP180-2.jpg] to pins 1+3+5+9 (eg. i2c1). It is i2c bus gadget and it has embedded bus pull-up resistors on PCB.
"i2cdetect" works for me okay (TinkerOS1.4 kernel). I also prepared simple testing code (attached) for BMP180 in python and run it without problems.

Code:
# i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- 77                         
# apt-get install python-smbus
# python bmp180.py
calibration data: 7321 -1007 -14425 33081 25481 21174 6515 32 -32768 -11786 2313
22.4 °C     980.7 hPa (rel. pres=1008.5 hPa)
22.4 °C     980.7 hPa (rel. pres=1008.5 hPa)
22.4 °C     980.8 hPa (rel. pres=1008.6 hPa)
22.4 °C     980.8 hPa (rel. pres=1008.5 hPa)
^C


Attached Files
.zip   bmp180.zip (Size: 1.15 KB / Downloads: 19)
I left this community in Aug 2017 due to ASUS bad product quality and ASUS community support that did not match my expectation.  Sad
Reply
#5
More examples: https://github.com/sabrigultekin/Asus-Tinker-Board
I left this community in Aug 2017 due to ASUS bad product quality and ASUS community support that did not match my expectation.  Sad
Reply
#6
Bug 
(04-13-2017, 05:57 PM)mcerveny Wrote: spi2 - on connector pins 19,21,23,24,26
Do not use TinkerOS (or rockchip-linux derivates) with SPI driver "CONFIG_SPI_ROCKCHIP" ! It works only up to 32 bytes length transfers and sends random length and random data to device if more data is requested (and results to SPI chip is unpredictable). Issue#19 was logged. UPDATE: resolved with TinkerOS >= 2.0.1
I left this community in Aug 2017 due to ASUS bad product quality and ASUS community support that did not match my expectation.  Sad
Reply
#7
Hi all,

Stupid question: finally, can I use SPI0, or its permanently disabled?

I have this config now:
cat /boot/hw_intf.conf
intf: spi0=off
...
intf: spi2=on
Reply
#8
Small addition to the old post: even if I enable
Code:
"intf:spi0=on" in /boot/hw_intf.conf, "ls /dev/spi*"
 does not show it.
Reply
#9
(06-26-2018, 12:35 PM)DVE Wrote: Small addition to the old post: even if I enable
Code:
"intf:spi0=on" in /boot/hw_intf.conf, "ls /dev/spi*"
 does not show it.

Hi DVE,

That is our know issue...but have been fixed.
You can take a try by compiling and replace with new kernel, base-on https://github.com/TinkerBoard/debian_kernel/ (develop branch).

Or wait our next release image version.
Thanks.
[-] The following 1 user Likes Tinker Board's post:
  • DVE
Reply
#10
Thanks. Will it be in 2.0.7, or later?

I am using SPI0 in my project but I don't want to replace kernel myself, so it would be nice to know, do I need to add software SPI in the project or not.
[-] The following 1 user Likes DVE's post:
  • AuerE
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)