-
Notifications
You must be signed in to change notification settings - Fork 964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Linux / Pine / RAK 3172 Support #1364
Comments
|
Doing some preliminary work on this, so far I've come up with a few notes:
|
I think this is the way to go, long term.
I'd be interested to see what you come up with. It's been quite some time since I've fought the Pinedio USB adapter. I've got a couple here. The last thing I remember battling was linux kernel version specific drivers and libgpio. Reach out if you have any questions or run into anything you think we can help with. I'd love to see this working, it was just taking too much of my bandwidth in my last attempt. |
The major hurdle nowadays seems to be that out of tree driver for the SPI part. There's the one that works with the demo code and that's what I'm working with for now, but I'd like to move to the more upstreamable driver when it becomes ready. I have some previous experience with the Linux SPI and GPIO subsystem APIs but I'm not as familiar with the I2C subsystem API yet. Pretty much no experience with VSCodium though so it took me a while to set it up for Meshtastic, but at least it can compile the T-Beam firmware now. My main issue is just finding the time to work on it so I don't want to make any promises on deadlines. |
Sounds like a solid plan!
Yeah, I get this. Ultimately it's why I bounced off of this one and focused more on other aspects of Meshtastic. It was a big time sink and there were higher priority things to tackle. 😅 |
Well, here's some unfortunate news; https://github.com/rogerjames99/spi-ch341-usb no longer compiles since Linux 6.4 with the following (first) error:
This means I'll have to boot into Linux 6.3 to continue development and it won't compile on vanilla Debian Sid without reverting to an older kernel anymore. So with this in mind I'll take a break from this a couple of weeks and enjoy my vacation, hopefully the new driver is ready enough when I get back home. If it isn't I'll keep developing with Linux 6.3 just to get the bulk of the HAL ready and update whatever needs updating later. The new CH341A driver should in theory be compatible as far as the APIs go but the GPIO mappings and SPI configuration sequences are different. I don't feel comfortable releasing what little I have yet because (1) it's too incomplete to be of any use and (2) it's continuously undergoing restructuring as I figure out how to best match up the APIs of RadioLib and Linux. I think I have a fairly complete This is further complicated by how I thought I could write the HAL in mostly pure C rather than C++ (which I am a lot less experienced with), so there's some extra legwork involved there too. The main complication there, aside from mixing C and C++ code, is that |
I've made some progress on this using the new upstreamable driver (or rather, using this WIP branch of the extended GPIO configuration https://github.com/mr-nice/ch341-i2c-spi-gpio/tree/pinedio ) and I've pushed what I have at the moment to this WIP repo https://github.com/Djhg2000/RadioLib/tree/linux-generic-wip It's still missing the code for handling interrupts, I have some ideas on how to do that with threads but I have yet to implement that functionality. The rest of the code should work but I haven't tested the HAL itself beyond compiling it because I haven't had the time to set up separate testing hardware without a radio. Anyway, progress is still being made and I haven't abandoned my efforts. :) |
This is great news, @Djhg2000 as we've just recently made some great strides in getting Meshtasticd running on Raspberry Pi hardware with a real radio. Hoping to have some good collaboration between these two efforts, and eventually a combined solution. |
Taking a quick look at this. We may run into trouble with the Chip Select pin getting claimes by the SPI driver. In my Raspberry Pi work, I've found that radiolib needs access to that pin for things to work. I'm going to see about building the kernel module on a dev machine this weekend, and trying it out. |
@Djhg2000 Hey, I may have something working. Would love for you to take a look. It's not 100% acting right, but I have something. This is using Meshtastic master, the native-unity branch, target native. git clone https://github.com/frank-zago/ch341-i2c-spi-gpio.git echo "spidev 1" | sudo tee /sys/class/spi_master/spi0/new_device In /etc/meshtasticd/config.yaml |
@jp-bennett Sorry for not getting back on this sooner. I can't find the branch "native-unity" in this repo and attempting to build the "native" target from the master branch results in the following errors:
I can't see any other branch with the same purpose so I'm not sure where to go from here. Is is still relevant for me to keep working on the RadioLib side or are we moving forward with PlatformIO (which from what I can tell uses Arduino library abstraction layers) instead? |
@Djhg2000 That branch got merged to master. You're hitting a bug in the LovyanGFX library that I did. Uninstall your system SDL development packages. That will change how the LovyanGFX library compiles, and avoid the error. I think the next release of Lovyan will have a fix. The way Meshtastic supports running on Linux is the Portduino/PlatformIO libraries. That seems to work rather well, except my Pinedio has a problem with sending long packets when using the default long fast preset. I'm wondering if the lack of TCXO is causing the problem. |
Modified for my DIY CH341 SX1262 cd ch341-i2c-spi-gpio echo "spidev 1" | sudo tee /sys/class/spi_master/spi11/new_device `INFO | 14:16:50 89 Rebooting //\ E S H T /\ S T / C DEBUG | ??:??:?? 0 Filesystem files: |
That issue seems to be an erroneous include path then, glad a fix in is the queue. I managed to compile the daemon (output binary is I tried using https://github.com/meshtastic/firmware/blob/master/bin/config-dist.yaml as a base and adding your config in the Would it be possible to have some more detailed debug output regarding the radio init? Mostly interested in if it's trying to open a file descriptor to something in |
Yes, I can add some additional debug messages that should help you figure out what's going on. |
@Djhg2000 Just added some debugging to master. You'll want to add
to your config.yaml. The main things that were added is a message at basically the beginning of the log output, indicating what config file is getting used. And then when trying to init the radio, a debug message gets printed indicating what kind of radio, and which SPI port is being used. Hopefully that helps. Let me know how it goes. |
This is essentially complete now with the burgeoning native linux effort and proven CH341 support. |
The other Pinetab issue is locked so Im making this to add this here; somebody has written and released the driver for these devices:
https://codeberg.org/JF002/pinedio-lora-driver
These are preliminary notes on support for Meshtastic in the Pinetab.
A RF95 is connected via a CH341 USB-SPI chip.
Pin assignments:
CS0 from RF95 goes to CS0 on CH341
DIO0 from RF95 goes to INT on CH341
RST from RF95 goes to RST on CH341
This Linux driver claims to provide USB-SPI support: https://github.com/gschorcht/spi-ch341-usb
Notes here on using that driver: https://www.linuxquestions.org/questions/linux-hardware-18/ch341-usb-to-spi-adaptor-driver-doesn%27t-work-4175622736/
Or if absolutely necessary could bit bang: https://www.cnx-software.com/2018/02/16/wch-ch341-usb-to-serial-chip-gets-linux-driver-to-control-gpios-over-usb/
Portduino tasks
Task list
Port meshtastic to build (under PlatformIO) for a POSIX target. spec: no screen, no GPIOs, SIM network interface, POSIX threads, POSIX semaphores & queues, IO to the console only
Use ARM Linux: https://platformio.org/platforms/linux_arm
And Linux native: https://platformio.org/platforms/native
Test cs341 driver - just test reading/writing a register and detecting interrupts, confirm can see rf95
Make a radiolib SPI module that targets the cs341 (and builds on Linux)
use new radiolib module to hook pinebook LoRa to meshtastic, confirm mesh discovery works
Make a subclass of StreamAPI that works as a POSIX TCP server
Use new TCP endpoint from meshtastic-python
The text was updated successfully, but these errors were encountered: