nedoskiv Posted April 17, 2017 Posted April 17, 2017 Hello, I have tried to enable second SPI interface on orange PI, so far without any success, here is what I done (orange pi pc+) first I look at script.bin/fex and saw there is spi1 configuration, uncommend lines, edit a little: [spi0] spi_used = 1 spi_cs_bitmap = 1 spi_mosi = port:PC00<3><default><default><default> spi_miso = port:PC01<3><default><default><default> spi_sclk = port:PC02<3><default><default><default> spi_cs0 = port:PC03<3><1><default><default> [spi1] spi_used = 1 spi_cs_bitmap = 1 spi_cs0 = port:PA13<2><1><default><default> spi_sclk = port:PA14<2><default><default><default> spi_mosi = port:PA15<2><default><default><default> spi_miso = port:PA16<2><default><default><default> [spi_devices] spi_dev_num = 2 [spi_board0] modalias = "spidev" max_speed_hz = 33000000 bus_num = 0 chip_select = 0 mode = 0 full_duplex = 1 manual_cs = 0 [spi_board1] modalias = "spidev" max_speed_hz = 33000000 bus_num = 1 chip_select = 0 mode = 0 full_duplex = 1 manual_cs = 0 convert it to .bin, rebooted and I though it is all ok, but when started to connect my spi device, noticed that PA15, PA16 do not exists on 40 pin slot........... so I decided to configure different GPIO on place of PA15, PA16, no matter what I trieed kernel returned an error : [ 0.522781] sunxi_spi_chan_cfg()1376 - [spi-0] has no spi_regulator. [ 0.522795] sunxi_spi_chan_cfg()1376 - [spi-1] has no spi_regulator. [ 0.523526] spi spi0: master is unqueued, this is deprecated [ 0.523983] sunxi_spi_request_gpio()1420 - SPI1 devm_pinctrl_get() failed! return -22 [ 0.523999] sunxi_spi_hw_init()1538 - [spi-1] Request GPIO failed! [ 0.524009] sunxi_spi_probe()1703 - spi hw init failed! [ 0.524091] spi: probe of spi1 failed with error -1 I basically tried to replace just one gpio PA15 or PA16 with all of the available GPIOs, it is all the same, checked if it is not initialized for something else, and commented if it. Still no success, what am I doing wrong? Triend and on my zero - it is same. Please help.
zador.blood.stained Posted April 17, 2017 Posted April 17, 2017 35 minutes ago, nedoskiv said: so I decided to configure different GPIO on place of PA15, PA16 You can't change the SPI pins
nedoskiv Posted April 18, 2017 Author Posted April 18, 2017 damn that can't be helped, I want to use dual MFRC522, last thing I gonna try will be do remove SPI NOR flash from Orange PI zero and use SPI from there, hope not to burn it. MX25L1606E was used there. Any idea do I need to place any resistors before connect pins to MFRC522 module?
martinayotte Posted April 18, 2017 Posted April 18, 2017 But why removing the LED PA15 from FEX becomes a pain ? Is the MFRC522 is 3.3V or 5V ? If 5V, you will need voltage level shifters. If you wish to keep the SPI-NOR, you can probably use a I2C-to-SPI bridge such SC18IS602, but it will be more trouble on software side.
nedoskiv Posted April 19, 2017 Author Posted April 19, 2017 orange pi zero comes with usable SPI1.0 interface (actually second one) (PA13, PA14,PA15,PA16), first is up too (spi0.0) but is used for that SPI nor flash, so only way to do it on zero is to remove that chip and place wires ....... in other hand zero have big temperature issue and I do not want to use it anyway. Gonna try orange pi ONE (when arrives from china) I guess reconfiguring and soldering a wire to PA15 (red led) not gonna be a problem, but what about PA16 - MUTE, got no idea where to find it.
nedoskiv Posted April 23, 2017 Author Posted April 23, 2017 I can confirm it is working on orange pi zero. successful removed SPI NOR flash - MX25L1606E and soldier wires on it's place. Connected MFRC522 and it working fine. My goal is finally achieved, to use 2 MFRC 522 on one orange pi board. Now need to focus on another issue, how far can be reader module from OPI board, tried 10M FTP using one pair for a SPI signal, works unstable, read about lowering SPI clock, passed it as parameter from MFRC522.PY but nothing changed, not sure it change it. Anyone got experience in that direction?
martinayotte Posted April 23, 2017 Posted April 23, 2017 What do you mean ? Do you mean "how long SPI wiring can be" ? Shortest as possible ! SPI isn't design to work on long distance, especially with high speed. Although reducing speed could help, it is not designed to support more than few inch of wires. You are better having two OPiZero is the MFC are meters away from each other ...
nedoskiv Posted April 24, 2017 Author Posted April 24, 2017 well I made few test, almost all of SPI signals got no problem to run on 10m FTP using one wire pair signal. only MISO do not work well. So I decided to shorten cable to 5M using one wire per signal. - do not work at all. Then I tried to use 2 wires for MISO - do not work at all. Well I start wonder why, on 10 meters it worked unstable on 5 meters do not work at all.......... Finally I used another 5M FTP cable for MISO m got 2 pairs this time and other was just unused - works without a problem. I suspect there is some interference when other wires of FTP cable was used for something. Gonna test with 10m later and post the results. PS I figure out that SPI usage makes ZERO CPU go really hot, it goes to 65 by just reading 2 SPI readers. So I decide to lower the SPI speed: def __init__(self,spd=1000000): changed it to def __init__(self,spd=100000): restart the scripts and temperature do down with 10 degree! yahooo .......... but ............ one of my readers stop working, one connected thru 5m FTP cable .......... everywhere I read, lower speed is longer cable can be used and now it is opposite. PS. after some testing value of 200000 make it work stable, and lower temperature with 4-5 degree. So it is acceptable for now. Gonna use heatsink later
martinayotte Posted April 24, 2017 Posted April 24, 2017 You're lucky ... SPI is designed only for few inches of wire. So, in you case, it is really out of specs.
nedoskiv Posted April 25, 2017 Author Posted April 25, 2017 This is out of the topic, but what is the lowest CPU freq orange pi can go, I set Zero PI freq to 240000 and temperature drops with 10 ! It have higher CPU load than before, but CPU temperature is more important in my case. And seconds question, I have read in orange pi forum working temperature of 75 C is normal, is that correct?
easyterm Posted April 26, 2017 Posted April 26, 2017 Can you please show how to setup rc522? After try from http://www.orangepi.org/orangepibbsen/forum.php?mod=redirect&goto=findpost&ptid=2419&pid=18357 : swig -python wiringpi.i bindings.i:55: Error: Unknown SWIG preprocessor directive: int (if this is a block of target language code, delimit it with %{ and %}) bindings.i:56: Error: Unknown SWIG preprocessor directive: int (if this is a block of target language code, delimit it with %{ and %}) or swig3.0 -thread -python wiringpi.i swig error : Unrecognized option -thread or swig3.0 -python wiringpi.i bindings.i:55: Error: Unknown SWIG preprocessor directive: int (if this is a block of target language code, delimit it with %{ and %}) bindings.i:56: Error: Unknown SWIG preprocessor directive: int (if this is a block of target language code, delimit it with %{ and %}) May be already exist C only library for this device?
martinayotte Posted April 26, 2017 Posted April 26, 2017 Why are you trying to use swig on wiringpi ? If you wish to use python instead of C library, there is an python library : https://github.com/duxingkei33/orangepi_PC_gpio_pyH3
easyterm Posted April 26, 2017 Posted April 26, 2017 Thanks, Martin for fast answer! I follow to this instruction only, and probable mean that WiringOP has support of SPI. Doing it with help python or not - no matter. I searched instruction now: But seems there no good for all.. May be this link different from your link and already adaptation for Zero: https://github.com/nvl1109/orangepi_PC_gpio_pyH3 May be anybody already use RC522 on Ubuntu legacy(official supported) kernel and answer how to use it for Zero on last version of armbian?
martinayotte Posted April 27, 2017 Posted April 27, 2017 You're right, there are 2 versions of this python library, one for PC and one for Zero, where only the mapping.h file should differ.
nedoskiv Posted April 29, 2017 Author Posted April 29, 2017 I used same on both boards, just edit MFRC522.py to use second SPI interface, because on Orange PI zero, first one is used for NOR FLASH here is the topic explained how to use single MFRC522 on orange PI, as I said on zero you need to edit MFRC522.PY find line: spi.openSPI(speed=spd,device="/dev/spidev0.0") and replace: spi.openSPI(speed=spd,device="/dev/spidev1.0")
solvess Posted August 9, 2017 Posted August 9, 2017 So where on the Orange PI One board we find PA15 and PA16 for the second reader Linux orangepione 3.4.113-sun8i # 16 SMP PREEMPT Tue Jun 13 14:15:57 CEST 2017 armv7l armv7l armv7l GNU / Linux @orangepione: # ls / dev / spi * /dev/spidev0.0 /dev/spidev1.0 leds_para leds_used = 0 Thank you
martinayotte Posted August 9, 2017 Posted August 9, 2017 PA15/PA16 are not available on header, they are STATUS_LED and MUTE.
solvess Posted August 9, 2017 Posted August 9, 2017 But you can find out If it is still possible to connect two readers on pin On which contacts: SCLK - 10pin SDA - 8pin MOSI - ? MISO - ? RST - pin 19, 21, 23, 24, 22 use first reader spi0 Where to connect and where to rule pyA20 or MFRC522 for RST-conact on reader
chwe Posted August 9, 2017 Posted August 9, 2017 3 hours ago, solvess said: SCLK - 10pin SDA - 8pin MOSI - ? MISO - ? RST - 3 hours ago, martinayotte said: PA15/PA16 are not available on header, they are STATUS_LED and MUTE. 15/16 are the pins from opi 0 maybe this confused him..
martinayotte Posted August 9, 2017 Posted August 9, 2017 2 hours ago, chwe said: 15/16 are the pins from opi 0 maybe this confused him.. Not really, because he was asking for OPiOne and before answering about STATUS_LED and MUTE, I've verified in the OPiOne schematic.
solvess Posted October 6, 2017 Posted October 6, 2017 HI what will happen if you change the FEX up to this type [spi0] spi_used = 1 spi_cs_bitmap = 1 spi_mosi = port:PC00<3><default><default><default> spi_miso = port:PC01<3><default><default><default> spi_sclk = port:PC02<3><default><default><default> spi_cs0 = port:PC03<3><1><default><default> [spi1] spi_used = 1 spi_cs_bitmap = 1 spi_cs0 = port:PA13<2><1><default><default> spi_sclk = port:PA14<2><default><default><default> spi_mosi = port:PС00<2><default><default><default> spi_miso = port:PС01<2><default><default><default> [spi_devices] spi_dev_num = 2 will both devices work?
martinayotte Posted October 6, 2017 Posted October 6, 2017 No ! This is conflicting ... But you can add a spi_cs1 definition to have 2 devices on the same SPI bus, then you should get /dev/spidev0.1
solvess Posted October 9, 2017 Posted October 9, 2017 tell me how to do it correctly all my attempts are unsuccessful generally disappears / dev / spidev i have orange pi one
martinayotte Posted October 9, 2017 Posted October 9, 2017 This guide should help : http://linux-sunxi.org/Fex_Guide#spi_configuration As you can see in example #1, it shows SPI0 with both CS0 and CS1. But this example has a small typo with spi_cs_bitmap = 1, since it says a bit above : Quote spi_cs_bitmap: 1 use cs0, 2 use cs1, 3 use cs0 & cs1 According to OPiOne schematic, the CS1 should be PA21.
solvess Posted October 9, 2017 Posted October 9, 2017 does not help I do not know @OrangePI:# dmesg | grep spi [ 1.756723] sunxi_spi_chan_cfg()1355 - [spi-0] has no spi_regulator. [ 1.767699] sunxi_spi_chan_cfg()1355 - [spi-1] has no spi_regulator. [ 1.778578] sunxi_spi_register_spidev()1986 - Get spi devices modalias failed [ 1.790354] sunxi_spi_init()2050 - register spi devices board info failed [ 1.802208] sunxi_spi_request_gpio()1399 - SPI0 devm_pinctrl_get() failed! return -22 [ 1.814885] sunxi_spi_hw_init()1517 - [spi-0] Request GPIO failed! [ 1.825682] sunxi_spi_probe()1680 - spi hw init failed! [ 1.835432] spi: probe of spi0 failed with error -1 )
martinayotte Posted October 9, 2017 Posted October 9, 2017 Does it work if there only CS0 ? If Yes, then, the PA21 for CS1 is in-use somewhere else like in plain GPIOs, you should then removing it from there. Also, doing "cat /sys/kernel/debug/gpio" could help figured out such conflicts ...
Recommended Posts