meshtastic / firmware

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

fix native compilation for linux PCs #3895

Closed mverch67 closed 1 month ago

mverch67 commented 1 month ago

It looks like the native target is running only on machines that have SPI and GPIO (e.g. raspberry), otherwise it will crash with a message that spidev0.0 cannot be opened. It's not simulating SpiChip anymore.

Note: this PR relies on https://github.com/meshtastic/framework-portduino/pull/27 and needs pull in the corresponding platform-native.

mverch67 commented 1 month ago

For tests I've added a target native-linux-pc, which runs well on my fedora linux PC. Should we add that target permanently?

[env:native-linux-pc]
extends = portduino_base
; The pkg-config commands below optionally add link flags.
; the || : is just a "or run the null command" to avoid returning an error code
build_unflags = -DPORTDUINO_LINUX_HARDWARE
build_flags = ${portduino_base.build_flags} -O0 -DARCH_PORTDUINO -I variants/portduino -I /usr/include
  !pkg-config --libs libulfius --silence-errors || :
  !pkg-config --libs openssl --silence-errors || :
board = cross_platform
lib_deps = ${portduino_base.lib_deps}
build_src_filter = ${portduino_base.build_src_filter}
jp-bennett commented 1 month ago

For tests I've added a target native-linux-pc, which runs well on my fedora linux PC. Should we add that target permanently?

I don't love it. At least not for working around an issue.

mverch67 commented 1 month ago

For tests I've added a target native-linux-pc, which runs well on my fedora linux PC. Should we add that target permanently?

I don't love it. At least not for working around an issue.

I think the issue was introduced in #3049 by defining PORTDUINO_LINUX_HARDWARE. Normally this could be detected during runtime. I remember there was some logic that uses SimSPIChip when the spidev cannot be opened.

caveman99 commented 1 month ago

https://github.com/meshtastic/framework-portduino/pull/27 merged