Mysensors Gateway on OrangePi (Zero) (opi)
-
I created the draft for the official article: https://www.mysensors.org/build/orange
@marceloaqno
thank you. but i have error:root@OrangePI:~# ls /sys/class/gpio/export ls: cannot access /sys/class/gpio/export: No such file or directory root@OrangePI:~# modprobe gpio-sunxi root@OrangePI:~# ls /sys/class/gpio/export ls: cannot access /sys/class/gpio/export: No such file or directoryin class folder i dont have gpio folder (i use a orangepi one with ubuntu os )

i
-
@marceloaqno
thank you. but i have error:root@OrangePI:~# ls /sys/class/gpio/export ls: cannot access /sys/class/gpio/export: No such file or directory root@OrangePI:~# modprobe gpio-sunxi root@OrangePI:~# ls /sys/class/gpio/export ls: cannot access /sys/class/gpio/export: No such file or directoryin class folder i dont have gpio folder (i use a orangepi one with ubuntu os )

i
-
root@OrangePI:~# git clone https://github.com/marceloaqno/MySensors.git orangepi Cloning into 'orangepi'... remote: Counting objects: 13858, done. remote: Compressing objects: 100% (50/50), done. remote: Total 13858 (delta 17), reused 0 (delta 0), pack-reused 13808 Receiving objects: 100% (13858/13858), 9.68 MiB | 79.00 KiB/s, done. Resolving deltas: 100% (8304/8304), done. Checking connectivity... done. root@OrangePI:~# cd orangepi/ root@OrangePI:~/orangepi# git pull origin spidev From https://github.com/marceloaqno/MySensors * branch spidev -> FETCH_HEAD Updating 570b607..63e1a81 Fast-forward Makefile | 16 +++ MyConfig.h | 4 + MySensors.h | 2 +- configure | 79 ++++++++++--- core/MyHwLinuxGeneric.cpp | 17 +++ core/MyHwLinuxGeneric.h | 12 +- core/MyHwRPi.cpp | 1 + core/MyHwRPi.h | 28 ----- core/MyMainLinux.cpp | 30 ++--- drivers/{RPi => BCM}/SPI.cpp | 10 +- drivers/{RPi => BCM}/SPI.h | 116 ++++++++++++------- drivers/{RPi => BCM}/Wire.cpp | 0 drivers/{RPi => BCM}/Wire.h | 1 + drivers/Linux/Arduino.h | 22 +++- drivers/Linux/GPIO.cpp | 119 ++++++++++++++++++++ drivers/Linux/GPIO.h | 47 ++++++++ drivers/Linux/Stream.h | 1 + drivers/Linux/compatibility.cpp | 11 +- drivers/{RPi/rpi_util.cpp => Linux/interrupt.cpp} | 144 +++++------------------- drivers/Linux/interrupt.h | 45 ++++++++ drivers/RF24/RF24.cpp | 4 +- drivers/RF24/RF24.h | 2 +- drivers/RPi/RPi.cpp | 59 ++++++++++ drivers/RPi/RPi.h | 22 ++++ drivers/RPi/piHiPri.c | 49 -------- drivers/RPi/rpi_util.h | 76 ------------- drivers/RPi/wiring.cpp | 72 ++++++++++++ drivers/RPi/wiring.h | 24 ++++ drivers/SPIDEV/SPI.cpp | 223 +++++++++++++++++++++++++++++++++++++ drivers/SPIDEV/SPI.h | 178 +++++++++++++++++++++++++++++ 30 files changed, 1054 insertions(+), 360 deletions(-) rename drivers/{RPi => BCM}/SPI.cpp (100%) rename drivers/{RPi => BCM}/SPI.h (62%) rename drivers/{RPi => BCM}/Wire.cpp (100%) rename drivers/{RPi => BCM}/Wire.h (99%) create mode 100644 drivers/Linux/GPIO.cpp create mode 100644 drivers/Linux/GPIO.h rename drivers/{RPi/rpi_util.cpp => Linux/interrupt.cpp} (63%) create mode 100644 drivers/Linux/interrupt.h create mode 100644 drivers/RPi/RPi.cpp create mode 100644 drivers/RPi/RPi.h delete mode 100644 drivers/RPi/piHiPri.c delete mode 100644 drivers/RPi/rpi_util.h create mode 100644 drivers/RPi/wiring.cpp create mode 100644 drivers/RPi/wiring.h create mode 100644 drivers/SPIDEV/SPI.cpp create mode 100644 drivers/SPIDEV/SPI.h root@OrangePI:~/orangepi# ./configure [SECTION] Detecting target machine. [OK] machine detected: SoC=H3, Type=unknown, CPU=armv7l. [SECTION] Detecting SPI driver. [OK] SPI driver detected:SPIDEV. [SECTION] Detecting init system. [OK] init system detected: systemd. [SECTION] Saving configuration. [SECTION] Cleaning previous builds. [OK] Finished. root@OrangePI:~/orangepi# make gcc -MT build/drivers/Linux/log.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_ARCH_ORANGEPI -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/log.c -o build/drivers/Linux/log.o g++ -MT build/drivers/Linux/IPAddress.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_ARCH_ORANGEPI -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/IPAddress.cpp -o build/drivers/Linux/IPAddress.o g++ -MT build/drivers/Linux/noniso.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_ARCH_ORANGEPI -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/noniso.cpp -o build/drivers/Linux/noniso.o g++ -MT build/drivers/Linux/GPIO.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_ARCH_ORANGEPI -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/GPIO.cpp -o build/drivers/Linux/GPIO.o g++ -MT build/drivers/Linux/Print.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_ARCH_ORANGEPI -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/Print.cpp -o build/drivers/Linux/Print.o g++ -MT build/drivers/Linux/EthernetClient.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_ARCH_ORANGEPI -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/EthernetClient.cpp -o build/drivers/Linux/EthernetClient.o g++ -MT build/drivers/Linux/SerialPort.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_ARCH_ORANGEPI -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/SerialPort.cpp -o build/drivers/Linux/SerialPort.o g++ -MT build/drivers/Linux/Stream.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_ARCH_ORANGEPI -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/Stream.cpp -o build/drivers/Linux/Stream.o g++ -MT build/drivers/Linux/compatibility.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_ARCH_ORANGEPI -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/compatibility.cpp -o build/drivers/Linux/compatibility.o g++ -MT build/drivers/Linux/interrupt.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_ARCH_ORANGEPI -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/interrupt.cpp -o build/drivers/Linux/interrupt.o drivers/Linux/interrupt.cpp: In function ‘void* interruptHandler(void*)’: drivers/Linux/interrupt.cpp:107:26: warning: ignoring return value of ‘ssize_t read(int, void*, size_t)’, declared with attribute warn_unused_result [-Wunused-result] (void)read (fd, &c, 1) ; ^ g++ -MT build/drivers/Linux/SoftEeprom.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_ARCH_ORANGEPI -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/SoftEeprom.cpp -o build/drivers/Linux/SoftEeprom.o g++ -MT build/drivers/Linux/EthernetServer.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_ARCH_ORANGEPI -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c drivers/Linux/EthernetServer.cpp -o build/drivers/Linux/EthernetServer.o g++ -MT build/examples_linux/mysgw.o -MMD -MP -march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_SPIDEV -DLINUX_ARCH_ORANGEPI -Ofast -g -Wall -Wextra -I. -I./core -I./drivers/Linux -I./drivers/SPIDEV -c examples_linux/mysgw.cpp -o build/examples_linux/mysgw.o In file included from ./MySensors.h:294:0, from examples_linux/mysgw.cpp:74: ./drivers/RF24/RF24.cpp:39:11: error: Not supported on this platform. hwDigitalWrite(MY_RF24_CS_PIN, level); ^ ./drivers/RF24/RF24.cpp:44:11: error: Not supported on this platform. hwDigitalWrite(MY_RF24_CE_PIN, level); ^ ./drivers/RF24/RF24.cpp:388:11: error: Not supported on this platform. hwPinMode(MY_RF24_CE_PIN,OUTPUT); ^ ./drivers/RF24/RF24.cpp:389:11: error: Not supported on this platform. hwPinMode(MY_RF24_CS_PIN,OUTPUT); ^ ./drivers/RF24/RF24.cpp:37:32: warning: unused parameter ‘level’ [-Wunused-parameter] LOCAL void RF24_csn(const bool level) ^ ./drivers/RF24/RF24.cpp:42:31: warning: unused parameter ‘level’ [-Wunused-parameter] LOCAL void RF24_ce(const bool level) ^ ./drivers/RF24/RF24.cpp: In function ‘uint8_t RF24_spiMultiByteTransfer(uint8_t, uint8_t*, uint8_t, bool)’: ./drivers/RF24/RF24.cpp:56:11: error: ‘LOW’ was not declared in this scope RF24_csn(LOW); ^ ./drivers/RF24/RF24.cpp:99:11: error: ‘HIGH’ was not declared in this scope RF24_csn(HIGH); ^ ./drivers/RF24/RF24.cpp: In function ‘void RF24_startListening()’: ./drivers/RF24/RF24.cpp:235:10: error: ‘HIGH’ was not declared in this scope RF24_ce(HIGH); ^ ./drivers/RF24/RF24.cpp: In function ‘void RF24_stopListening()’: ./drivers/RF24/RF24.cpp:241:10: error: ‘LOW’ was not declared in this scope RF24_ce(LOW); ^ ./drivers/RF24/RF24.cpp: In function ‘void RF24_powerDown()’: ./drivers/RF24/RF24.cpp:251:10: error: ‘LOW’ was not declared in this scope RF24_ce(LOW); ^ ./drivers/RF24/RF24.cpp: In function ‘bool RF24_sendMessage(uint8_t, const void*, uint8_t)’: ./drivers/RF24/RF24.cpp:269:10: error: ‘HIGH’ was not declared in this scope RF24_ce(HIGH); ^ ./drivers/RF24/RF24.cpp:276:10: error: ‘LOW’ was not declared in this scope RF24_ce(LOW); ^ ./drivers/RF24/RF24.cpp: In function ‘bool RF24_initialize()’: ./drivers/RF24/RF24.cpp:395:10: error: ‘LOW’ was not declared in this scope RF24_ce(LOW); ^ ./drivers/RF24/RF24.cpp:396:11: error: ‘HIGH’ was not declared in this scope RF24_csn(HIGH); ^ Makefile:114: recipe for target 'build/examples_linux/mysgw.o' failed make: *** [build/examples_linux/mysgw.o] Error 1 root@OrangePI:~/orangepi#``` -
You need to create the files after each boot.
After the modprobe, Issue this command:
sudo for A in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do echo "$A" > /sys/class/gpio/export ; doneThis will get you the files.
-
You need to create the files after each boot.
After the modprobe, Issue this command:
sudo for A in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do echo "$A" > /sys/class/gpio/export ; doneThis will get you the files.
-
@Tag said:
sudo for A in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do echo "$A" > /sys/class/gpio/export ; done
orangepi one have 40 pins
@Reza Is there /sys/class/gpio/export file on your OPi?
-
@Reza Is there /sys/class/gpio/export file on your OPi?
@marceloaqno
no i have not folder "gpio" in my orangepi -
@marceloaqno It still doesn't work on my OPi Zero :confused:
root@opi-zero-1:~/orangepi# bin/mysgw -d
mysgw: Starting gateway...
mysgw: Protocol version - 2.2.0-beta
mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.2.0-beta
mysgw: TSM:INIT
mysgw: TSF:WUR:MS=0
mysgw: !TSM:INIT:TSP FAIL
mysgw: TSM:FAIL:CNT=1
mysgw: TSM:FAIL:PDT
mysgw: Received SIGINTI do have the /sys/class/gpio/export and I ran for A in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do echo "$A" > /sys/class/gpio/export ; done
For the record, here's my OS:
BOARD=orangepizero BOARD_NAME="Orange Pi Zero" VERSION=5.24 LINUXFAMILY=sun8i BRANCH=default ARCH=arm PRETTY_NAME="Debian GNU/Linux 8 (jessie)" NAME="Debian GNU/Linux" VERSION_ID="8" VERSION="8 (jessie)" ID=debian HOME_URL="http://www.debian.org/" SUPPORT_URL="http://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/" -
@marceloaqno It still doesn't work on my OPi Zero :confused:
root@opi-zero-1:~/orangepi# bin/mysgw -d
mysgw: Starting gateway...
mysgw: Protocol version - 2.2.0-beta
mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.2.0-beta
mysgw: TSM:INIT
mysgw: TSF:WUR:MS=0
mysgw: !TSM:INIT:TSP FAIL
mysgw: TSM:FAIL:CNT=1
mysgw: TSM:FAIL:PDT
mysgw: Received SIGINTI do have the /sys/class/gpio/export and I ran for A in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do echo "$A" > /sys/class/gpio/export ; done
For the record, here's my OS:
BOARD=orangepizero BOARD_NAME="Orange Pi Zero" VERSION=5.24 LINUXFAMILY=sun8i BRANCH=default ARCH=arm PRETTY_NAME="Debian GNU/Linux 8 (jessie)" NAME="Debian GNU/Linux" VERSION_ID="8" VERSION="8 (jessie)" ID=debian HOME_URL="http://www.debian.org/" SUPPORT_URL="http://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"@mihai.aldea The gateway does the exporting when needed, you don't need to run:
for A in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do echo "$A" > /sys/class/gpio/export ; doneCould you send the output of this command?
ls -lah /dev/spidev* -
@mihai.aldea The gateway does the exporting when needed, you don't need to run:
for A in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do echo "$A" > /sys/class/gpio/export ; doneCould you send the output of this command?
ls -lah /dev/spidev*Still issues here:
root@orangepizero:~/orangepi/bin# ll /dev/spi* crw------- 1 root root 153, 0 Jan 9 22:51 /dev/spidev0.0 crw------- 1 root root 153, 1 Jan 9 22:51 /dev/spidev1.0Then:
./configure --spi-spidev-device=/dev/spidev1.0added to examples_linux/mysgw.cpp
#define MY_RF24_CE_PIN 2 #define MY_RF24_CS_PIN 13end enabled radio debugging:
output:
root@orangepizero:~/orangepi/bin# ./mysgw -d mysgw: Starting gateway... mysgw: Protocol version - 2.2.0-beta mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.2.0-beta mysgw: TSM:INIT mysgw: TSF:WUR:MS=0 mysgw: RF24:write register, reg=0, value=14 mysgw: RF24:write register, reg=3, value=3 mysgw: RF24:write register, reg=4, value=95 mysgw: RF24:write register, reg=5, value=76 mysgw: RF24:write register, reg=6, value=39 mysgw: RF24:write register, reg=16, value=115 mysgw: RF24:write register, reg=29, value=6 mysgw: RF24:read register, reg=6, value=39 mysgw: RF24:read register, reg=5, value=76 mysgw: RF24:write register, reg=2, value=2 mysgw: RF24:write register, reg=1, value=0 mysgw: RF24:write register, reg=28, value=3 mysgw: RF24:flushRX mysgw: RF24:flushTX mysgw: RF24:write register, reg=7, value=112 mysgw: TSM:INIT:TSP OK mysgw: TSM:INIT:GW MODE mysgw: RF24:write register, reg=2, value=3 mysgw: RF24:write register, reg=1, value=1 mysgw: RF24:STRT LIS mysgw: RF24:write register, reg=0, value=15 mysgw: RF24:write register, reg=10, value=0 mysgw: TSM:READY:ID=0,PAR=0,DIS=0 mysgw: MCO:REG:NOT NEEDED mysgw: RF24:read register, reg=23, value=17 Illegal instruction root@orangepizero:~/orangepi/bin#Almost there?
-
@Reza Is there /sys/class/gpio/export file on your OPi?
@marceloaqno
in "orangepi one"(ubuntu os) there is not gpio folder in sys/class. but i think after run "modprobe gpio-sunxi" built a folder that name is "gpio_sw" and in this folder there are this files: normal_led,pa3,pa6,pa8 and 9,10,13,14,15,21 ,... -
@marceloaqno
in "orangepi one"(ubuntu os) there is not gpio folder in sys/class. but i think after run "modprobe gpio-sunxi" built a folder that name is "gpio_sw" and in this folder there are this files: normal_led,pa3,pa6,pa8 and 9,10,13,14,15,21 ,...@Reza Is it too complicated to switch to Debian?
-
@Reza Is it too complicated to switch to Debian?
@mihai.aldea said:
Is it too complicated to switch to Debian?
you told me i change my os ? to armbian ?
-
@marceloaqno
in "orangepi one"(ubuntu os) there is not gpio folder in sys/class. but i think after run "modprobe gpio-sunxi" built a folder that name is "gpio_sw" and in this folder there are this files: normal_led,pa3,pa6,pa8 and 9,10,13,14,15,21 ,... -
@Reza I wouldn't even dream of not using Armbian on OrangePi and NanoPi. Compared to Raspbian it's years ahead in terms of optimization and tidyness. Armbian is the reason I'm avoiding RPi when possible. So go ahead and install a proper OS for your OPi. Not sure if Xenial or Debian, maybe we should wait for @marceloaqno to respond to my comment with the running OS.
-
@Reza
More info on armbian.comI use the debian jessie, works like a charm!
-
That I can not say.
-
@Reza
More info on armbian.comI use the debian jessie, works like a charm!
-
I confirm it's not working on the OPi PC where TMRh20 works.
-
@Tag Oops, did I get it right this time (I reuploaded the image)?