meshtastic / firmware

Meshtastic device firmware
https://meshtastic.org
GNU General Public License v3.0
3.22k stars 777 forks source link

[Feature Request]: Meshtasticd on other fruit computers. #3711

Closed madeofstown closed 3 months ago

madeofstown commented 4 months ago

Platform

NRF52, ESP32

Description

(ignore the platform as there was no option for Linux native)

With the raspberry pi shortage still in mostly full effect I was wondering what is the possibility of getting Meshtasticd running on the Chinese clones (OrangePi, BananaPi, Radxa)? I have an OrangePi Zero 2w that I MUCH prefer to the RaspberryPi Zero 2w and I would love to use it for Meshtastic. The .deb file will install and run just fine (OrangePi Debian Bookworm) but fails to find/initialize the radio (-2 error). The radio is a Waveshare 1262 LoRa Hat.

markbirss commented 4 months ago

@madeofstown

The deb file generation is currently a github workflow only for Raspberry Pi OS  64 bit (Bookworm Debian) as far i know

Im looking at maybe some RISCV64 Ubuntu 22.04 deb builds on my own Milkv-Mars board using docker

You could follow the steps required to build the deb file yourself - [build .debpkg section]

https://github.com/meshtastic/firmware/blob/master/.github/workflows/package_raspbian.yml

Installing the Raspberry Pi deb might allow the meshtasticd to run but your GPIO numbering could differ (true for RISCV board uses higher GPIO numbers)

or 

you may need to enable via dtb orverlay your spi bus or specify it diffirently to the config.yaml file

If possible discuss your spefiic board on Discord - linux native channel - share your dmesg logs and output

also output of running

gpioinfo

gpiodetect

jp-bennett commented 4 months ago

We've worked pretty hard to use generic Linux interfaces, so things will generally work on the other devices. The issue is going to be the different GPIO numbering, the different gpiochipx device name, and getting the SPI device configured correctly.

madeofstown commented 4 months ago

While the .deb file will run on the OPZ2W I was unable to get it to build. I have been successful building a Pi4 and PiZero(32 bit) so I think it's a dependency issue or something. The build fails and gives an error when trying to compile what I believe are display drivers...

Discord.... 😮‍💨, why not a proper web-searchable forum?

jp-bennett commented 4 months ago

The build fails and gives an error when trying to compile what I believe are display drivers...

I know the bug you hit. Should be fixed with https://github.com/meshtastic/firmware/pull/3715

madeofstown commented 4 months ago

I did find out that the OPZ2W does use high number GPIO pins. Specifically the ones I want to use range from 72 - 260. When I swap those out in the config.yaml Meshtasticd throws an error that points to line 36 in PortduinoGPIO.cpp. I'm not really a programmer and I have never really tried C but it appears that portduino is set to have 64 GPIO pins and my numbers over that are causing the crash.

How does portduino map the physical GPIO to its internal emulated(?) ones? If I compile on the host will it automatically map the pins?

jp-bennett commented 4 months ago

Specifically the ones I want to use range from 72 - 260.

Oh. Yeah, that's not gonna work. I can work on that in Portduino.

How does portduino map the physical GPIO to its internal emulated(?) ones? If I compile on the host will it automatically map the pins?

It's a one-to-one mapping, where all the pins are virtual unless gpioBind() is called on them. See https://github.com/meshtastic/firmware/blob/master/src/platform/portduino/PortduinoGlue.cpp#L325 You bind the real pin number, as shown by something like gpioinfo.

jp-bennett commented 4 months ago

Part one of fixing this: https://github.com/meshtastic/framework-portduino/pull/23/commits/fb18cac747d1e4597467785f9e5d4e6317e0d0c7

madeofstown commented 4 months ago

Forgive my ignorance. How would I go about incorporating those source changes into a build? I'm not understanding when or where the source for portduino is pulled.

jp-bennett commented 4 months ago

Forgive my ignorance. How would I go about incorporating those source changes into a build? I'm not understanding when or where the source for portduino is pulled.

Coming soon! Once we add code to framework-portduino, the commit hash in platform-native gets updated. Then we can update the platform-native commit hash in Meshtastic.

madeofstown commented 4 months ago

I appreciate your response. Thank you for your great work on this project and especially for taking time to explain how it all works to a newbie like me.

jp-bennett commented 3 months ago

I appreciate your response. Thank you for your great work on this project and especially for taking time to explain how it all works to a newbie like me.

The GPIO stuff has landed in meshtastic master.

madeofstown commented 3 months ago

It's working with the nightly build 2.3.9.4d9081b Heres my config.yaml

### Define your devices here using Broadcom pin numbering
### Uncomment the block that corresponds to your hardware
### Including the "Module:" line!
---
Lora:
  Module: sx1262  # Waveshare SX126X XXXM & OrangePi Zero 2W
  DIO2_AS_RF_SWITCH: true
  CS: 259 # 21
  IRQ: 76 # 16
  Busy: 260 # 20
  Reset: 257 # 18
  spidev: spidev1.0

#  Module: sx1262  # Waveshare SX1302 LISTEN ONLY AT THIS TIME!
#  CS: 7
#  IRQ: 17
#  Reset: 22

#  Module: sx1262  # pinedio
#  CS: 0
#  IRQ: 10
#  Busy: 11
#  spidev: spidev0.1

#  Module: RF95  # Adafruit RFM9x
#  Reset: 25
#  CS: 7
#  IRQ: 22
#  Busy: 23

#  Module: RF95  # Elecrow Lora RFM95 IOT https://www.elecrow.com/lora-rfm95-iot-board-for-rpi.html
#  Reset: 22
#  CS: 7
#  IRQ: 25

#  Module: sx1280  # SX1280
#  CS: 21
#  IRQ: 16
#  Busy: 20
#  Reset: 18

#  Module: sx1268  # SX1268-based modules, tested with Ebyte E22 400M33S
#  CS: 21
#  IRQ: 16
#  Busy: 20
#  Reset: 18
#  TXen: 6
#  RXen: 12
#  DIO3_TCXO_VOLTAGE: true

#  DIO3_TCXO_VOLTAGE: true  # the Waveshare Core1262 and others are known to need this setting

#  TXen: x  # TX and RX enable pins
#  RXen: x

### Set gpio chip to use in /dev/. Defaults to 0.
### Notably the Raspberry Pi 5 puts the GPIO header on gpiochip4
#  gpiochip: 4

### Specify the SPI device to use in /dev/. Defaults to spidev0.0
### Some devices, like the pinedio, may require spidev0.1 as a workaround.
#  spidev: spidev0.1

### Define GPIO buttons here:

GPIO:
#  User: 6

### Define GPS

GPS:
#  SerialPath: /dev/ttyS0

### Specify I2C device, or leave blank for none

I2C:
#  I2CDevice: /dev/i2c-1

### Set up SPI displays here. Note that I2C displays are generally auto-detected.

Display:

### Waveshare 2.8inch RPi LCD
#  Panel: ST7789
#  CS: 8
#  DC: 22        # Data/Command pin
#  Backlight: 18
#  Width: 240
#  Height: 320
#  Reset: 27
#  Rotate: true
#  Invert: true

### Waveshare 1.44inch LCD HAT
#  Panel: ST7735S
#  CS: 8         #Chip Select
#  DC: 25        # Data/Command pin
#  Backlight: 24
#  Width: 128
#  Height: 128
#  Reset: 27
#  OffsetX: 0
#  OffsetY: 0

### Adafruit PiTFT 2.8 TFT+Touchscreen
#  Panel: ILI9341
#  CS: 8
#  DC: 25
#  Width: 240
#  Height: 320
#  Rotate: true

Touchscreen:
### Note, at least for now, the touchscreen must have a CS pin defined, even if you let Linux manage the CS switching.

#  Module: STMPE610 # Option 1 for Adafruit PiTFT 2.8
#  CS: 7
#  IRQ: 24

#  Module: FT5x06 # Option 2 for Adafruit PiTFT 2.8
#  IRQ: 24
#  I2CAddr: 0x38

#  Module: XPT2046 # Waveshare 2.8inch
#  CS: 7
#  IRQ: 17

### Configure device for direct keyboard input

Input:
#  KeyboardDevice: /dev/input/by-id/usb-_Raspberry_Pi_Internal_Keyboard-event-kbd

###

Logging:
  LogLevel: debug # debug, info, warn, error

Webserver:
#  Port: 443 # Port for Webserver & Webservices
#  RootPath: /usr/share/doc/meshtasticd/web # Root Dir of WebServer

General:
  MaxNodes: 200

@jp-bennett you gave me the best Birthday present yesterday