Hi All,
I put together the steps to get MySensors running on the OrangePi Zero:
Take note of the SPI part, 1 typo and you will not see /dev/spidev1.0
sudo apt-get update
sudo apt-get install sunxi-tools
- How to add /dev/spidev1.0 (which is required since /dev/spidev0.0 is used for the onboard NAND flash)
cd /boot
bin2fex /boot/script.bin /root/myscript.txt
Now edit /root/myscript.bin and add/change the following so it looks exactly like the part below:
[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
- Then recompile the script file:
fex2bin /root/myscript.txt /boot/script.bin
Reboot the system
reboot
2 device files should exist now:
root@orangepizero:~# ls -l /dev/spi*
crw------- 1 root root 153, 0 Jan 11 16:31 /dev/spidev0.0
crw------- 1 root root 153, 1 Jan 11 16:31 /dev/spidev1.0
Load the gpio module
modprobe gpio-sunxi
To load the module gpio-sunxi automagically load at boot time, add gpio-sunxi to /etc/modules
echo gpio-sunxi >> /etc/modules
- Now it is time to install the GW.
cd /root
git clone https://github.com/marceloaqno/MySensors.git orangepi
cd orangepi/
git pull origin spidev
./configure --spi-spidev-device=/dev/spidev1.0
make
Working like a charm!
If you tested "/bin/mysgw -d" and all works as expected, make the installation permanent:
make install
Additional
If you want to read data into a controller using a device file (i.e Mycontroller) use the build string below
./configure --spi-spidev-device=/dev/spidev1.0 --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyMySensorsGateway
Hope this helps!! have fun!!