lorabasics / basicstation

LoRa Basics™ Station - The LoRaWAN Gateway Software
https://doc.sm.tc/station
Other
357 stars 183 forks source link

Build fails on Raspberry Pi 4 Model B #171

Open md4k9 opened 2 years ago

md4k9 commented 2 years ago

I'm trying to build Basics Station on a Raspberry Pi 4 Model B running Raspberry Pi OS Lite 64-bit. I tried following the compilation instructions, but ran into errors on Step 2. I'm not sure if it matters, but I have the Seeed WM1302 (SPI) attached via Seeed's Pi HAT.

The first issue it reports is, "../../setup.gmk:60: No toolchain for platform 'rpi' and local arch is not 'arm-linux-gnueabihf'" The instructions specify "platform=rpi", so why is it throwing an error stating there's no toolchain for platform 'rpi'?

Any ideas on how to get this to compile? My OS is near stock, except that I've enabled SPI and I2C, disabled Bluetooth.

Compilation output from command "make platform=rpi variant=std":

setup.gmk:60: No toolchain for platform 'rpi' and local arch is not 'arm-linux-gnueabihf' mkdir -p build-local/bin gcc -std=gnu11 -Isrc -DCFG_prog_crc32 src/crc32.c -o build-local/bin/crc32 mkdir -p build-local/bin gcc -std=gnu11 -Isrc -DCFG_prog_genkwcrcs src/genkwcrcs.c -o build-local/bin/genkwcrcs build-local/bin/genkwcrcs $(cat src/kwlist.txt | sed -e '/^#/d;s/[ \t]+#.*//') > build-local/temp-kwcrc.h mv build-local/temp-kwcrc.h src/kwcrc.h platform=rpi variant=std make -C deps/mbedtls make[1]: Entering directory '/home/user/basicstation/deps/mbedtls' ../../setup.gmk:60: No toolchain for platform 'rpi' and local arch is not 'arm-linux-gnueabihf' platform=rpi variant=std ./prep.sh Cloning into 'git-repo'... remote: Enumerating objects: 1362, done. remote: Counting objects: 100% (1362/1362), done. remote: Compressing objects: 100% (1138/1138), done. remote: Total 1362 (delta 335), reused 665 (delta 201), pack-reused 0 Receiving objects: 100% (1362/1362), 3.81 MiB | 1.06 MiB/s, done. Resolving deltas: 100% (335/335), done. Note: switching to '8b3f26a5ac38d4fdccbc5c5366229f3e01dafcc0'.

You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may do so (now or later) by using -c with the switch command. Example:

git switch -c

Or undo this operation with:

git switch -

Turn off this advice by setting config variable advice.detachedHead to false

Cloning into 'platform-rpi'... remote: Enumerating objects: 1362, done. remote: Counting objects: 100% (1362/1362), done. remote: Compressing objects: 100% (1004/1004), done. remote: Total 1362 (delta 335), reused 1362 (delta 335), pack-reused 0 Receiving objects: 100% (1362/1362), 3.81 MiB | 10.87 MiB/s, done. Resolving deltas: 100% (335/335), done. Note: switching to '8b3f26a5ac38d4fdccbc5c5366229f3e01dafcc0'.

You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may do so (now or later) by using -c with the switch command. Example:

git switch -c

Or undo this operation with:

git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 8b3f26a Merge pull request #868 from ARMmbed/mbedtls-2.28.0rc0-pr make[2]: Entering directory '/home/user/basicstation/deps/mbedtls/platform-rpi' make[3]: Entering directory '/home/user/basicstation/deps/mbedtls/platform-rpi/library' make[3]: Leaving directory '/home/user/basicstation/deps/mbedtls/platform-rpi/library' make[3]: Entering directory '/home/user/basicstation/deps/mbedtls/platform-rpi/programs' make[4]: Entering directory '/home/user/basicstation/deps/mbedtls/platform-rpi/programs/fuzz' make[4]: Leaving directory '/home/user/basicstation/deps/mbedtls/platform-rpi/programs/fuzz' make[3]: Leaving directory '/home/user/basicstation/deps/mbedtls/platform-rpi/programs' make[3]: Entering directory '/home/user/basicstation/deps/mbedtls/platform-rpi/tests' make[3]: Leaving directory '/home/user/basicstation/deps/mbedtls/platform-rpi/tests' make[2]: Leaving directory '/home/user/basicstation/deps/mbedtls/platform-rpi' make --no-print-directory all platform=rpi variant=std ../../setup.gmk:60: No toolchain for platform 'rpi' and local arch is not 'arm-linux-gnueabihf' make -C platform-rpi lib CC="NO-TOOLCHAIN-FOUND-gcc" AR="NO-TOOLCHAIN-FOUND-ar" LD="NO-TOOLCHAIN-FOUND-ld" CFLAGS="-Wall -std=gnu11" CC aes.c make[4]: NO-TOOLCHAIN-FOUND-gcc: No such file or directory make[4]: [Makefile:284: aes.o] Error 127 make[3]: [Makefile:17: lib] Error 2 make[2]: [makefile:43: platform-rpi/library/libmbedtls.a] Error 2 make[1]: [makefile:56: platform-rpi] Error 2 make[1]: Leaving directory '/home/user/basicstation/deps/mbedtls' make: *** [makefile:67: deps/mbedtls] Error 2

beitler commented 2 years ago

Hi @md4k9 ,

thank you for submitting the issue. Indeed, the rpi platform in Basics Station assumes a 32 bit toolchain for now. If you run on a 64 bit pi, a workaround for now is to do a small change to setup.gmk to explicitly set the toolchain architecture to 64 bit for the rpi platform:

diff --git a/setup.gmk b/setup.gmk
index d7c4363..e821a01 100644
--- a/setup.gmk
+++ b/setup.gmk
@@ -44,7 +44,7 @@ ARCH.linux   = x86_64-linux-gnu
 ARCH.linuxV2 = x86_64-linux-gnu
 ARCH.linuxpico = x86_64-linux-gnu
 ARCH.corecell  = arm-linux-gnueabihf
-ARCH.rpi     = arm-linux-gnueabihf
+ARCH.rpi     = aarch64-linux-gnu
 ARCH.kerlink = arm-klk-linux-gnueabi
 ARCH=${ARCH.${platform}}

In the next release we will add support for 64 bit Raspberry Pi.

md4k9 commented 2 years ago

This workaround does get station to compile, but yes - supporting 64-bit would be great. Not to throw shade, but why is this project updated so infrequently? I get the impression that Basics Station is the way to go going forward (I think AWS LNS requires it), so shouldn't something this critical be getting more attention?

beitler commented 2 years ago

Thanks for the feedback. I appreciate your openness about your perception of the project.

The reason you see updates so infrequently is due to a combination of factors. The most important of which is probably the fact that we have very few to none open critical bugs which would necessitate a new release. I'm with you on the observation that a project with infrequent updates could be perceived as dormant. However, we are actively developing and improving the code base between releases, albeit not being visible to the public. I can assure you that the LoRa Basics Station project is receiving the attention it needs in order to fulfil its role in the ecosystem.

Do you have particular new features or fixes you are looking for in a new release - beyond this one?

md4k9 commented 1 year ago

@beitler That sounds great. I just wanted to make sure this wasn't abandonware before I implement it. But assuming I get this working with my Pi 4 + WM1302 + WM1302 HAT, no requests on my end so far other than perhaps some documentation clarification (TBD).

chaudhariatul commented 1 year ago

+1 on the 64 bit support. We see a good adoption Raspberry Pi's used to create gateways. Kindly add support for RAK2287 too!.

I get this error while trying to use basicstation to connect to AWS IoT Core.

2022-11-28 05:08:21.917 [TCE:VERB] Connecting to MUXS...
2022-11-28 05:08:22.312 [AIO:DEBU] [4] HTTP connection shutdown...
2022-11-28 05:08:22.312 [CUP:INFO] Interaction with CUPS done (no updates) - next regular check in 1d
2022-11-28 05:08:22.492 [TCE:VERB] Connected to MUXS.
2022-11-28 05:08:22.569 [S2E:WARN] Unknown field in router_config - ignored: protocol (0xFD309030)
2022-11-28 05:08:22.569 [S2E:WARN] Unknown field in router_config - ignored: regionid (0xE6FFB211)
2022-11-28 05:08:22.570 [SYS:VERB] rinit.sh: Forked, waiting...
2022-11-28 05:08:22.570 [SYS:DEBU] execvp argv[0]: </bin/bash>
2022-11-28 05:08:22.570 [SYS:DEBU]        argv[1]: <rinit.sh>
2022-11-28 05:08:22.570 [SYS:DEBU]        argv[2]: <rinit.sh>
2022-11-28 05:08:22.570 [SYS:DEBU]        argv[3]: </dev/spidev0.0>
CoreCell reset through GPIO17...
CoreCell power enable through GPIO18...
2022-11-28 05:08:23.287 [SYS:INFO] Process rinit.sh (pid=2348) completed
2022-11-28 05:08:23.287 [RAL:INFO] Lora gateway library version: Version: 2.1.0;
2022-11-28 05:08:23.290 [RAL:INFO] [LGW sx1302] full_duplex=0 clksrc=0 lorawan_public=1
2022-11-28 05:08:23.290 [RAL:DEBU] SX130x txlut table (16 entries)
2022-11-28 05:08:23.290 [RAL:INFO] SX1302 txlut  0:  rf_power=12 pa_gain=0 pwr_idx=15
2022-11-28 05:08:23.290 [RAL:INFO] SX1302 txlut  1:  rf_power=13 pa_gain=0 pwr_idx=16
2022-11-28 05:08:23.290 [RAL:INFO] SX1302 txlut  2:  rf_power=14 pa_gain=0 pwr_idx=17
2022-11-28 05:08:23.290 [RAL:INFO] SX1302 txlut  3:  rf_power=15 pa_gain=0 pwr_idx=19
2022-11-28 05:08:23.291 [RAL:INFO] SX1302 txlut  4:  rf_power=16 pa_gain=0 pwr_idx=20
2022-11-28 05:08:23.291 [RAL:INFO] SX1302 txlut  5:  rf_power=17 pa_gain=0 pwr_idx=22
2022-11-28 05:08:23.291 [RAL:INFO] SX1302 txlut  6:  rf_power=18 pa_gain=1 pwr_idx=1
2022-11-28 05:08:23.291 [RAL:INFO] SX1302 txlut  7:  rf_power=19 pa_gain=1 pwr_idx=2
2022-11-28 05:08:23.291 [RAL:INFO] SX1302 txlut  8:  rf_power=20 pa_gain=1 pwr_idx=3
2022-11-28 05:08:23.291 [RAL:INFO] SX1302 txlut  9:  rf_power=21 pa_gain=1 pwr_idx=4
2022-11-28 05:08:23.291 [RAL:INFO] SX1302 txlut 10:  rf_power=22 pa_gain=1 pwr_idx=5
2022-11-28 05:08:23.291 [RAL:INFO] SX1302 txlut 11:  rf_power=23 pa_gain=1 pwr_idx=6
2022-11-28 05:08:23.291 [RAL:INFO] SX1302 txlut 12:  rf_power=24 pa_gain=1 pwr_idx=7
2022-11-28 05:08:23.291 [RAL:INFO] SX1302 txlut 13:  rf_power=25 pa_gain=1 pwr_idx=9
2022-11-28 05:08:23.291 [RAL:INFO] SX1302 txlut 14:  rf_power=26 pa_gain=1 pwr_idx=11
2022-11-28 05:08:23.291 [RAL:INFO] SX1302 txlut 15:  rf_power=27 pa_gain=1 pwr_idx=14
2022-11-28 05:08:23.291 [RAL:INFO]  RX/TX RF0:    904.3MHz rssi_offset=-215.4 type=5 rssi_tcomp=0.000 0.000 20.410 2162.560 0.000
2022-11-28 05:08:23.291 [RAL:INFO]  RX    RF1:    905.3MHz rssi_offset=-215.4 type=5 rssi_tcomp=0.000 0.000 20.410 2162.560 0.000
2022-11-28 05:08:23.291 [RAL:INFO]  [mSF]   0:    903.9MHz rf=0 freq=-400.0 datarate=0
2022-11-28 05:08:23.291 [RAL:INFO]  [mSF]   1:    904.1MHz rf=0 freq=-200.0 datarate=0
2022-11-28 05:08:23.291 [RAL:INFO]  [mSF]   2:    904.3MHz rf=0 freq=  +0.0 datarate=0
2022-11-28 05:08:23.291 [RAL:INFO]  [mSF]   3:    904.5MHz rf=0 freq=+200.0 datarate=0
2022-11-28 05:08:23.291 [RAL:INFO]  [mSF]   4:    904.7MHz rf=0 freq=+400.0 datarate=0
2022-11-28 05:08:23.291 [RAL:INFO]  [mSF]   5:    904.9MHz rf=1 freq=-400.0 datarate=0
2022-11-28 05:08:23.291 [RAL:INFO]  [mSF]   6:    905.1MHz rf=1 freq=-200.0 datarate=0
2022-11-28 05:08:23.291 [RAL:INFO]  [mSF]   7:    905.3MHz rf=1 freq=  +0.0 datarate=0
2022-11-28 05:08:23.291 [RAL:INFO]  channel 8 disabled
2022-11-28 05:08:23.291 [RAL:INFO]  channel 9 disabled
2022-11-28 05:08:23.291 [RAL:INFO] Station device: spi:/dev/spidev0.0 (PPS capture disabled)
2022-11-28 05:08:23.291 [HAL:INFO] [lgw_com_open:84] Opening SPI communication interface
2022-11-28 05:08:23.291 [HAL:INFO] [lgw_spi_open:88] Setting SPI speed to 2000000
2022-11-28 05:08:23.292 [HAL:INFO] [lgw_connect:1192] chip version is 0x10 (v1.0)
2022-11-28 05:08:25.502 [HAL:INFO] [timestamp_counter_mode:431] using legacy timestamp
2022-11-28 05:08:25.650 [HAL:INFO] [lgw_start:1111] no temperature sensor found on port 0x39
2022-11-28 05:08:25.650 [HAL:INFO] [lgw_start:1111] no temperature sensor found on port 0x3B
2022-11-28 05:08:25.651 [HAL:INFO] [lgw_start:1111] no temperature sensor found on port 0x38
2022-11-28 05:08:25.651 [HAL:ERRO] [lgw_start:1120] no temperature sensor found.
2022-11-28 05:08:25.651 [RAL:ERRO] Concentrator start failed: lgw_start
2022-11-28 05:08:25.651 [RAL:ERRO] ral_config failed with status 0x08
2022-11-28 05:08:25.651 [any:ERRO] Closing connection to muxs - error in s2e_onMsg
2022-11-28 05:08:25.651 [AIO:DEBU] [3] ws_close reason=1000
2022-11-28 05:08:25.651 [AIO:DEBU] Echoing close - reason=1000
2022-11-28 05:08:25.695 [AIO:DEBU] [3|WS] Server sent close: reason=1000
2022-11-28 05:08:25.695 [AIO:DEBU] [3] WS connection shutdown...
2022-11-28 05:08:25.695 [TCE:VERB] Connection to MUXS closed in state -1
2022-11-28 05:08:25.695 [TCE:INFO] INFOS reconnect backoff 10s (retry 1)
2022-11-28 05:08:35.696 [AIO:INFO] ./../awsGateway01/tc.trust: 

Second attempt:

2022-11-28 05:12:51.298 [SYS:DEBU]        argv[3]: </dev/spidev0.0>
CoreCell reset through GPIO17...
CoreCell power enable through GPIO18...
2022-11-28 05:12:52.219 [SYS:INFO] Process rinit.sh (pid=2419) completed
2022-11-28 05:12:52.219 [RAL:INFO] Lora gateway library version: Version: 2.1.0;
2022-11-28 05:12:52.221 [RAL:INFO] [LGW sx1302] full_duplex=0 clksrc=0 lorawan_public=1
2022-11-28 05:12:52.221 [RAL:DEBU] SX130x txlut table (16 entries)
2022-11-28 05:12:52.221 [RAL:INFO] SX1302 txlut  0:  rf_power=12 pa_gain=0 pwr_idx=15
2022-11-28 05:12:52.221 [RAL:INFO] SX1302 txlut  1:  rf_power=13 pa_gain=0 pwr_idx=16
2022-11-28 05:12:52.221 [RAL:INFO] SX1302 txlut  2:  rf_power=14 pa_gain=0 pwr_idx=17
2022-11-28 05:12:52.221 [RAL:INFO] SX1302 txlut  3:  rf_power=15 pa_gain=0 pwr_idx=19
2022-11-28 05:12:52.221 [RAL:INFO] SX1302 txlut  4:  rf_power=16 pa_gain=0 pwr_idx=20
2022-11-28 05:12:52.221 [RAL:INFO] SX1302 txlut  5:  rf_power=17 pa_gain=0 pwr_idx=22
2022-11-28 05:12:52.221 [RAL:INFO] SX1302 txlut  6:  rf_power=18 pa_gain=1 pwr_idx=1
2022-11-28 05:12:52.221 [RAL:INFO] SX1302 txlut  7:  rf_power=19 pa_gain=1 pwr_idx=2
2022-11-28 05:12:52.221 [RAL:INFO] SX1302 txlut  8:  rf_power=20 pa_gain=1 pwr_idx=3
2022-11-28 05:12:52.221 [RAL:INFO] SX1302 txlut  9:  rf_power=21 pa_gain=1 pwr_idx=4
2022-11-28 05:12:52.221 [RAL:INFO] SX1302 txlut 10:  rf_power=22 pa_gain=1 pwr_idx=5
2022-11-28 05:12:52.221 [RAL:INFO] SX1302 txlut 11:  rf_power=23 pa_gain=1 pwr_idx=6
2022-11-28 05:12:52.221 [RAL:INFO] SX1302 txlut 12:  rf_power=24 pa_gain=1 pwr_idx=7
2022-11-28 05:12:52.221 [RAL:INFO] SX1302 txlut 13:  rf_power=25 pa_gain=1 pwr_idx=9
2022-11-28 05:12:52.221 [RAL:INFO] SX1302 txlut 14:  rf_power=26 pa_gain=1 pwr_idx=11
2022-11-28 05:12:52.221 [RAL:INFO] SX1302 txlut 15:  rf_power=27 pa_gain=1 pwr_idx=14
2022-11-28 05:12:52.221 [RAL:INFO]  RX/TX RF0:    904.3MHz rssi_offset=-215.4 type=5 rssi_tcomp=0.000 0.000 20.410 2162.560 0.000
2022-11-28 05:12:52.221 [RAL:INFO]  RX    RF1:    905.3MHz rssi_offset=-215.4 type=5 rssi_tcomp=0.000 0.000 20.410 2162.560 0.000
2022-11-28 05:12:52.221 [RAL:INFO]  [mSF]   0:    903.9MHz rf=0 freq=-400.0 datarate=0
2022-11-28 05:12:52.221 [RAL:INFO]  [mSF]   1:    904.1MHz rf=0 freq=-200.0 datarate=0
2022-11-28 05:12:52.222 [RAL:INFO]  [mSF]   2:    904.3MHz rf=0 freq=  +0.0 datarate=0
2022-11-28 05:12:52.222 [RAL:INFO]  [mSF]   3:    904.5MHz rf=0 freq=+200.0 datarate=0
2022-11-28 05:12:52.222 [RAL:INFO]  [mSF]   4:    904.7MHz rf=0 freq=+400.0 datarate=0
2022-11-28 05:12:52.222 [RAL:INFO]  [mSF]   5:    904.9MHz rf=1 freq=-400.0 datarate=0
2022-11-28 05:12:52.222 [RAL:INFO]  [mSF]   6:    905.1MHz rf=1 freq=-200.0 datarate=0
2022-11-28 05:12:52.222 [RAL:INFO]  [mSF]   7:    905.3MHz rf=1 freq=  +0.0 datarate=0
2022-11-28 05:12:52.222 [RAL:INFO]  channel 8 disabled
2022-11-28 05:12:52.222 [RAL:INFO]  channel 9 disabled
2022-11-28 05:12:52.222 [RAL:INFO] Station device: spi:/dev/spidev0.0 (PPS capture disabled)
ERROR: Failed to set SX1250_0 in STANDBY_RC mode
2022-11-28 05:12:52.222 [HAL:INFO] [lgw_com_open:84] Opening SPI communication interface
2022-11-28 05:12:52.222 [HAL:INFO] [lgw_spi_open:88] Setting SPI speed to 2000000
2022-11-28 05:12:52.222 [HAL:INFO] [lgw_connect:1192] chip version is 0x10 (v1.0)
2022-11-28 05:12:53.824 [HAL:ERRO] [lgw_start:906] failed to setup radio 0
2022-11-28 05:12:53.824 [RAL:ERRO] Concentrator start failed: lgw_start
2022-11-28 05:12:53.824 [RAL:ERRO] ral_config failed with status 0x08
2022-11-28 05:12:53.824 [any:ERRO] Closing connection to muxs - error in s2e_onMsg
2022-11-28 05:12:53.824 [AIO:DEBU] [3] ws_close reason=1000
2022-11-28 05:12:53.824 [AIO:DEBU] Echoing close - reason=1000
2022-11-28 05:12:53.865 [AIO:DEBU] [3|WS] Server sent close: reason=1000
2022-11-28 05:12:53.865 [AIO:DEBU] [3] WS connection shutdown...
2022-11-28 05:12:53.865 [TCE:VERB] Connection to MUXS closed in state -1
2022-11-28 05:12:53.865 [TCE:INFO] INFOS reconnect backoff 10s (retry 1)
2022-11-28 05:13:03.866 [AIO:INFO] ./tc.trust: 
mrpher commented 1 year ago

Hi @md4k9 ,

thank you for submitting the issue. Indeed, the rpi platform in Basics Station assumes a 32 bit toolchain for now. If you run on a 64 bit pi, a workaround for now is to do a small change to setup.gmk to explicitly set the toolchain architecture to 64 bit for the rpi platform:

diff --git a/setup.gmk b/setup.gmk
index d7c4363..e821a01 100644
--- a/setup.gmk
+++ b/setup.gmk
@@ -44,7 +44,7 @@ ARCH.linux   = x86_64-linux-gnu
 ARCH.linuxV2 = x86_64-linux-gnu
 ARCH.linuxpico = x86_64-linux-gnu
 ARCH.corecell  = arm-linux-gnueabihf
-ARCH.rpi     = arm-linux-gnueabihf
+ARCH.rpi     = aarch64-linux-gnu
 ARCH.kerlink = arm-klk-linux-gnueabi
 ARCH=${ARCH.${platform}}

In the next release we will add support for 64 bit Raspberry Pi.

+1 for this fix, though I don't quite understand why wait for the next major release. There is a pending PR https://github.com/lorabasics/basicstation/pull/84 for this exact fix. Perhaps at a minimum the docs could be updated to point out that platform=rpi is for 32 bit Pis only - I'm sure it would save a bunch of people some headaches.

gagan1469 commented 1 year ago

I ran into the same issue on Raspberry PI 3 B+ with a 64-bit Raspberry PI Desktop OS (release date May 3rd 2023). Wish I had come across this issue sooner but the fix is the same for 64-bit OS on RPI 3B+ (i.e., set ARCH.rpi = aarch64-linux-gnu in the setup.gmk file.)