markqvist / RNode_Firmware

RNode is an open, free and flexible digital radio interface with many uses
https://unsigned.io/rnode
GNU General Public License v3.0
166 stars 56 forks source link

Allow building for Linux as a Linux binary #16

Closed interfect closed 2 years ago

interfect commented 2 years ago

This is my first attempt at making the RNode firmware build for Linux.

I've tested this with my board where I have a HopeRF RFM95W on /dev/spidev0.0, with only SPI and no reset or DIO connections, and it seems to work. I can set an EEPROM with rnodeconf, and configure it as long as I have https://github.com/markqvist/rnodeconfigutil/pull/8 so it doesn't time out on the EEPROM dump.

Since there's no reset, I have code for Linux to set all the important registers at startup to the values that the rest of the code seems to be expecting to be working with. I got some of these from dumps with https://github.com/interfect/spi-lora/blob/master/lora_util.py; I try to note where what I get from the dump disagrees with what the datasheet says really ought to be there.

Since there's no DIO interrupts, I have code for Linux to poll the interrupt flags byte. This seems to be quick enough that I'm not seeing a lot of lost second parts of packets (except when the node decides to transmit its own packet while expecting the second part).

I've tested using tncattach to send IP packets back and forth. With rnodeconf /dev/pts/3 -T --freq 903000000 --bw 250000 --txp 13 --sf 7 --cr 5 and then sudo tncattach /dev/pts/3 115200 -e -n -m 478 -i 10.99.0.1/24 I'm getting a back-and-forth ping time of something like 500 ms, which seems long. Is that about what I should expect? The pings shouldn't be up anywhere near the ~10 kilobit bitrate I would expect to be able to get.

I haven't yet tested the Arduino build after all my changes; I still need to make sure the Makefile can build it, and ideally get an actual device to try it on.

This will fix #14.

markqvist commented 2 years ago

Thank you. For now I am merging this into a new branch, linux-daemon, until all the physical device targets can be tested and verified. There is a lot of changes here, and the potential that something subtle could modify on-device behaviour, so let's keep it separate for now.

I will start testing out this branch on the physical targets as soon as time allows.