Skip to content
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

Failed to start the concentrator with kernel 6.6.22 (Pi 4B Bookworm + SX130X) #120

Open
timiman opened this issue Apr 20, 2024 · 29 comments
Labels
fixed_next_release This will be fixed with next release

Comments

@timiman
Copy link

timiman commented Apr 20, 2024

I'm unable to start a SX130X as concentrator under kernel 6.6.22 on a Pi 4B.
Running reset_lgw.sh, outputs:
./reset_lgw.sh: 26: echo: echo: I/O error ./reset_lgw.sh: 27: echo: echo: I/O error ./reset_lgw.sh: 28: echo: echo: I/O error ./reset_lgw.sh: 29: echo: echo: I/O error ./reset_lgw.sh: 32: cannot create /sys/class/gpio/gpio17/direction: Directory nonexistent ./reset_lgw.sh: 33: cannot create /sys/class/gpio/gpio22/direction: Directory nonexistent ./reset_lgw.sh: 34: cannot create /sys/class/gpio/gpio18/direction: Directory nonexistent ./reset_lgw.sh: 35: cannot create /sys/class/gpio/gpio13/direction: Directory nonexistent CoreCell reset through GPIO17... SX1261 reset through GPIO17... CoreCell power enable through GPIO18... CoreCell ADC reset through GPIO13... ./reset_lgw.sh: 45: cannot create /sys/class/gpio/gpio18/value: Directory nonexistent ./reset_lgw.sh: 47: cannot create /sys/class/gpio/gpio17/value: Directory nonexistent ./reset_lgw.sh: 48: cannot create /sys/class/gpio/gpio17/value: Directory nonexistent ./reset_lgw.sh: 50: cannot create /sys/class/gpio/gpio22/value: Directory nonexistent ./reset_lgw.sh: 51: cannot create /sys/class/gpio/gpio22/value: Directory nonexistent ./reset_lgw.sh: 53: cannot create /sys/class/gpio/gpio13/value: Directory nonexistent ./reset_lgw.sh: 54: cannot create /sys/class/gpio/gpio13/value: Directory nonexistent

By default the reset GPIO pin was pointing to 23, but found that 17 is the correct one for this SX130X.
It seems like the GPIO number has changed for 6.6.22 , as I'm getting:
grep -s . /sys/class/gpio/gpiochip*/* /sys/class/gpio/gpiochip512/base:512 /sys/class/gpio/gpiochip512/label:pinctrl-bcm2711 /sys/class/gpio/gpiochip512/ngpio:58 /sys/class/gpio/gpiochip570/base:570 /sys/class/gpio/gpiochip570/label:raspberrypi-exp-gpio /sys/class/gpio/gpiochip570/ngpio:8

User running all above is in group 'gpio'.

Does the reset_lgw.sh needs changes to work with new GPIO numbering ?

@wildekek
Copy link

wildekek commented Apr 20, 2024

Just for confirmation: I just ran into the same issue.
[Edit] Seems like GPIO sysfs is deprecated and superseded by libgpiod. We can make a patch to fix the sysfs paths for now, but support for this will likely end in the near future.
https://waldorf.waveform.org.uk/2022/the-one-where-dave-breaks-stuff.html

@timiman
Copy link
Author

timiman commented Apr 20, 2024

I've seen that article too.
I've also sent a tech support to waveshare.

@wildekek
Copy link

Looks like it is fairly trivial to use the gpiod command line tools for the reset script:
https://manpages.debian.org/experimental/gpiod/index.html

I'll give that a go and let you know if that fixes everything.

@wildekek
Copy link

I think that this repo should be marked as deprecated.

I switched to Basic Station using this repo which supports libgpiod.

working docker-compose example for your convenience:

services:

  basicstation:
    image: xoseperez/basicstation:latest
    container_name: basicstation
    restart: unless-stopped
    privileged: true
    network_mode: host      # required to read main interface MAC instead of virtual one
    environment:
      MODEL: "WM1302"
      DEVICE: "AUTO"
      USE_LIBGPIOD: 1
      RESET_GPIO: 17
      POWER_EN_GPIO: 18
      TC_KEY: "***"
      CUPS_KEY: "***"
      SERVER: "***"

wildekek added a commit to wildekek/WM1302-doc that referenced this issue Apr 21, 2024
Packet forwarder is old and does not work on the latest debian kernel. See: Lora-net/sx1302_hal#120
@timiman
Copy link
Author

timiman commented Apr 22, 2024

I think that this repo should be marked as deprecated.

I switched to Basic Station using this repo which supports libgpiod.

working docker-compose example for your convenience:

services:

  basicstation:
    image: xoseperez/basicstation:latest
    container_name: basicstation
    restart: unless-stopped
    privileged: true
    network_mode: host      # required to read main interface MAC instead of virtual one
    environment:
      MODEL: "WM1302"
      DEVICE: "AUTO"
      USE_LIBGPIOD: 1
      RESET_GPIO: 17
      POWER_EN_GPIO: 18
      TC_KEY: "***"
      CUPS_KEY: "***"
      SERVER: "***"

I think it misses GPS support which Waveshare's SX130X includes in its hardware implementation

@mcoracin
Copy link
Contributor

Hello,
This issue will be addressed with the next release of this repo, sorry for the inconvenience. :/
Thanks for the feedback.

@KonRoz
Copy link

KonRoz commented May 3, 2024

Is there any fix for the time being?

@mcoracin
Copy link
Contributor

mcoracin commented May 6, 2024

@KonRoz for now nothing official, but in the meantime you can check what has been done here:
https://github.com/xoseperez/basicstation-docker/blob/master/runner/reset.sh.gpiod

@timiman
Copy link
Author

timiman commented May 6, 2024

@KonRoz for now nothing official, but in the meantime you can check what has been done here: https://github.com/xoseperez/basicstation-docker/blob/master/runner/reset.sh.gpiod

From a quick test I've done, it seems to reset correctly now, by using the following values for a Waveshare SX130X board on a RPi4 w/ 6.6.28 Kernel:
GPIO_CHIP="gpiochip0"
RESET_GPIO="23"
POWER_EN_GPIO="18"
POWER_EN_LOGIC="18"

@davidgs
Copy link

davidgs commented May 24, 2024

I'm also hitting this problem on a Pi 4. Looks like this repo hasn't had a release in 3 years, and isn't being actively maintained. Is there a better solution? I'd rather not go the Docker route.

@mcoracin
Copy link
Contributor

Hello,
I am currently looking into this. I'll post here a new reset_lgw.sh script for gpiod usage to unblock until the release is done.
For the later release, I was thinking about making the reset.sh script configurable through the command line, so that one can use the sysfs one of the gpiod one depending on its setup.

@timiman
Copy link
Author

timiman commented May 24, 2024

That's good news. Although Lora is working just fine on TTN v3, it seems that its GPS cannot return valid data even under clear and direct sky, always while running packet_forwarder. It logs:

### [GPS] ###
# Valid time reference (age: 0 sec)
# no valid GPS coordinates available yet

Maybe this issue should also be checked if it has been broken too, due to newest kernel of Linux ?

@mcoracin
Copy link
Contributor

Hello all,
Please find attached an updated reset script using gpiod.
I've quickly tested it on a Raspberry Pi 4.
@davidgs let me know if it fixes your issue.
reset_lgw.gpiod.sh.tar.gz
Best regards,
Michael

@mcoracin
Copy link
Contributor

@timiman I'll check the GPS on RPi4 too

@davidgs
Copy link

davidgs commented May 24, 2024

At least on my RPI4, with a WM1302, no.

*** Packet Forwarder ***
Version: 2.1.0
*** SX1302 HAL library version info ***
Version: 2.1.0;
***
INFO: Little endian host
INFO: found configuration file global_conf.json, parsing it
INFO: global_conf.json does contain a JSON object named SX130x_conf, parsing SX1302 parameters
INFO: com_type SPI, com_path /dev/spidev0.0, lorawan_public 1, clksrc 0, full_duplex 0
INFO: antenna_gain 0 dBi
INFO: Configuring legacy timestamp
INFO: Configuring Tx Gain LUT for rf_chain 0 with 16 indexes for sx1250
INFO: radio 0 enabled (type SX1250), center frequency 867500000, RSSI offset -215.399994, tx enabled 1, single input mode 0
INFO: radio 1 enabled (type SX1250), center frequency 868500000, RSSI offset -215.399994, tx enabled 0, single input mode 0
INFO: Lora multi-SF channel 0>  radio 1, IF -400000 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora multi-SF channel 1>  radio 1, IF -200000 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora multi-SF channel 2>  radio 1, IF 0 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora multi-SF channel 3>  radio 0, IF -400000 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora multi-SF channel 4>  radio 0, IF -200000 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora multi-SF channel 5>  radio 0, IF 0 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora multi-SF channel 6>  radio 0, IF 200000 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora multi-SF channel 7>  radio 0, IF 400000 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora std channel> radio 1, IF -200000 Hz, 250000 Hz bw, SF 7, Explicit header
INFO: FSK channel> radio 1, IF 300000 Hz, 125000 Hz bw, 50000 bps datarate
INFO: global_conf.json does contain a JSON object named gateway_conf, parsing gateway parameters
INFO: gateway MAC address is configured to AA555A0000000000
INFO: server hostname or IP address is configured to "localhost"
INFO: upstream port is configured to "1730"
INFO: downstream port is configured to "1730"
INFO: downstream keep-alive interval is configured to 10 seconds
INFO: statistics display interval is configured to 30 seconds
INFO: upstream PUSH_DATA time-out is configured to 100 ms
INFO: packets received with a valid CRC will be forwarded
INFO: packets received with a CRC error will NOT be forwarded
INFO: packets received with no CRC will NOT be forwarded
INFO: GPS serial port path is configured to "/dev/ttyS0"
INFO: Reference latitude is configured to 0.000000 deg
INFO: Reference longitude is configured to 0.000000 deg
INFO: Reference altitude is configured to 0 meters
INFO: Beaconing period is configured to 0 seconds
INFO: Beaconing signal will be emitted at 869525000 Hz
INFO: Beaconing datarate is set to SF9
INFO: Beaconing modulation bandwidth is set to 125000Hz
INFO: Beaconing TX power is set to 14dBm
INFO: Beaconing information descriptor is set to 0
INFO: global_conf.json does contain a JSON object named debug_conf, parsing debug parameters
INFO: got 2 debug reference payload
INFO: reference payload ID 0 is 0xCAFE1234
INFO: reference payload ID 1 is 0xCAFE2345
INFO: setting debug log file name to loragw_hal.log
INFO: [main] TTY port /dev/ttyS0 open for GPS synchronization
CoreCell power enable on through GPIO18...
CoreCell reset through GPIO17...
SX1261 reset through GPIO5...
CoreCell ADC reset through GPIO13...
Opening SPI communication interface
Note: chip version is 0x00 (v0.0)
ERROR: Failed to set SX1250_0 in STANDBY_RC mode
ERROR: failed to setup radio 0
ERROR: [main] failed to start the concentrator

@mcoracin
Copy link
Contributor

mcoracin commented May 24, 2024

@davidgs which version of the WM1302 do you have exactly (seeed product reference) ?
Are the GPIOs correct for your setup ?
SPI is properly configured on your RPi ?

@mcoracin
Copy link
Contributor

@timiman I've tested the GPS on my RPi4, and I see no issue, it is working as expected for me.

What do you get when you do a "cat /dev/ttyS0" ?

Have you enabled the serial interface, and modified the /boot/firmware/cmdline.txt to free the serial0 ?

@timiman
Copy link
Author

timiman commented May 27, 2024

Serial Port is enabled.

With "sudo cat /dev/sttyS0" I get fast scrolling text with ( hide/altered with ##'s location data ):
01NTENNA ▒▒▒▒ 300.000,####.553##.95298,E,1,12,M,,*7C 757.5539E,134300.000,A,A02,03,08,10,21,20.9,1.1,1*38 $G1,72,,,,,,,,,1.4,2*31 $43,312,4248,23,0,##,10,3GPGSV,3,21,60,326,28,05,*69 $GP09,32,###*5E $G,09,78,06,05,203183,,65,3,0*70 ,72,038,,118,,8126,71,05SV,3,3,0032,18,0RMC,1343398,N,02,33.97,2A,V*39 3.97,T,,A*1D $G300.000,24,00,001,01,ANT35 ▒b ▒▒ GA,13430,N,023##,1,12,0.,*7F $G7.55395,95298,E,00,A,A*4A,A,3,020,21,27,,,1.4,0.38 $GNG72,,,,,,.9,1.1,2GSV,3,1,,312,43,8,23,08,7,10,31,GSV,3,2,,313,,21,171,27,2,15,0*6,32,50,05E $GLG9,78,09,05,203,,3,,65,820*70 $G,09,88,7,87,29,19,325,2626,,0*7172,22,03D $GNRM.000,A,35,N,0233E,0.00,3V*35 $G97,T,,M,.00,K,A*DA,13430,05,20248 $GPTX01,ANTEN ▒b ,134302..55392,N,12,0.9,7B $GNG55392,N,4302.000 $GNGSA,21,27,281.4,0.9,,A,3,65,,1.4,0.91 $GPGS,02,43,3,19,248,,217,##,4 3,3,09,3,06,30,324,3##1,27,2815,0*68 $GLGSV,3,1,09,,203,,75,22,183,70 $GLGSV,3,2,07,29,118,,81,29,,,0*71 $GLGSV,318,0*4D $GNRMC,7.55392,N,023##.97,27052TG,33.97,T,,M,0. ,ANTENNA OK*350,00*4B k▒$GNGGA,15389,N,023##.952.9,M,##.9,M,,*71,##57.553##.9529,A*4F $GNGSA,A,,27,28,34,0.9,1.1,1*38 ,81,72,,,,,,,,,1 3,2,09,1,,21,60,7,39,1715,122,15GPGSV,3,50,073,3$GLGSV,3,09,262,03,,75,25,82,052 $GLGSV88,72,0329,118,,5,26,71,0*71 $G,09,72,2,0*4D $,A,##57.298,E,0.,,A,V*3A,,M,0.00$GNZDA,10,27,05,00*4A $,01,01,AK*35 ▒b NGGA,134##57.553##.952980.9,41.9M,,*78 757.55387.95298,.000,A,AGSA,A,3,,10,21,2,,,,1.4,1*38 $G,65,88,8,,,,,1.4,2*31 $1,09,02,43,312,44,8,24,08,7,10,31,GSV,3,2,09,14,0633,27,39,171,27,8 $GPGSV,3,3,095D $GLGSV,3,1,005,203,,75,22,180*70 $GLGSV,3,2,87,29,118,,81,226,,0*71 $GLGSV2,18,0*4D $GNRM757.55387,N,02333.97,270524,,,A,97,T,,M,0.00,N,0DA,134304.000,27D $GPTXT,01,01, ▒b ▒,134305.000,##575298,E,1,12,0.9,7A $GNGLL,##57.298,E,134305.000A,3,02,03,08,10,1.4,0.9,1.1,1*3888,81,72,,,,,,,,1 $GPGSV,3,1,09,19,248,24,08,640,33,0*64 2,50,073,32,0*5D78,09,26,203,,75,65,82,0SV,3,2,07,29,118,,81,29,,22,0*7172,22,03C,1343054,N,02333.97,270V*31 $G97,T,,M,1D $GNZDA,13430,00,00*4C $GPTX01,ANTENx6$GNGGA.55381,N,12,0.9,76 $GNGL5381,N,023##.952A,A*42 $GNGSA,A,08,10,21,27,28,.1,1*38 $GNGSA,,,,,,,,,1.4,0.9,,3,1,09,02,43,314,08,64,217,##,1 $GPGSV,3,2,09,,324,33,27,39,175,0*68 8,09,26222,183,,0 $GLGS,88,72,0,81,29,322,0*71 $GLGSV,,18,0*4D $GNRMC57.55381,0.00,33*## #134307.000,##57.299,E,1,12,0.9,4F0A OK*35 $GNGLL,##57.523##.95299,E,134A,A*4B $GNGSA,A,08,10,21,27,28,34,0.9,1.$GNGSA,A,81,72,,.4,0.9,1 3,2,09,1,,21,60,7,39,171^C,64,233,0*64

From the test python code of L76K found on Waveshare's site, the GPS data is generated just fine.
It seems that its output is clear without any errors or missed characters as shown below:
Baidu coordinate ##.96389292167206 , ##.646300276335587 $GNGSA,A,3,02,03,08,21,27,28,32,,,,,,1.8,1.0,1.5,1*39 $GNGSA,A,3,66,88,81,,,,,,,,,,1.8,1.0,1.5,2*37 $GPGSV,3,1,09,02,50,317,41,03,25,255,40,08,56,207,40,10,24,054,08,0*6F $GPGSV,3,2,09,14,06,305,,21,67,333,36,27,30,171,24,28,10,116,23,0*67 $GPGSV,3,3,09,32,46,062,35,0*5D $GLGSV,3,1,10,78,09,262,,66,52,211,36,76,05,203,,75,22,183,,0*77 $GLGSV,3,2,10,65,81,047,21,88,74,076,19,87,22,126,,81,38,329,26,0*7D $GLGSV,3,3,10,71,05,026,,72,21,032,,0*78 $GNRMC,140135.000,A,##57.54932,N,0##37.95252,E,0.00,33.97,270524,,,A,V*33 $GNVTG,33.97,T,,M,0.00,N,0.00,K,A*1D $GNZDA,140135.000,27,05,2024,00,00*4E $GPTXT,01,01,01,ANTENNA OK*35 $GNGGA,140136.000,##57.54932,N,0##37.95253,E,1,10,1.0,47.6,M,37.9,M,,*79 $GNGLL,##57.54932,N,0##37.95253,E,140136.000,A,A*44

Also, if I run packet_forwarder and try the python GPS example,
packet_forwarder shows endless scrolling of text, "WARNING: [gps] read() returned value 0",
because of the conflict of accessing GPS from two applications at the same time, I guess.

Finally, the baud-rate of the serial port from python example above is set to 9600.
Maybe the baud-rate is different on packet-forwarder ?

@mcoracin
Copy link
Contributor

@timiman I've never used the Waveshare board, but I've ordered one to test.

What do you get if you do "cat /boot/firmware/cmdline.txt" on your RPi ?

The baudrate is the same as what is used by the hal to configure the serial port:

#define DEFAULT_BAUDRATE B9600

Maybe you could create a separate issue for this, it is quite different from the initial issue reported here. :)

@timiman
Copy link
Author

timiman commented May 27, 2024

cat /boot/firmware/cmdline.txt gives:
console=tty1 console=serial0,115200 root=PARTUUID=0a5e2d69-02 rootfstype=ext4 fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles cfg80211.ieee80211_regdom=GR

@mcoracin
Copy link
Contributor

Could you try to remove the console=serial0,115200 from this file ?
This was already required to be removed on previous RPi versions, it creates a conflict on /dev/ttyS0 access.
This should allow the packet forwarder to read the output of the GPS.

@timiman
Copy link
Author

timiman commented May 27, 2024

Could you try to remove the console=serial0,115200 from this file ? This was already required to be removed on previous RPi versions, it creates a conflict on /dev/ttyS0 access. This should allow the packet forwarder to read the output of the GPS.

No change. Same message. I will open a new issue.

@mcoracin
Copy link
Contributor

@timiman even after a reboot of the RPi ?
When opening the new issue, could you indicate :

  • the exact hardware you are using
  • the RPi config you did to enable the serial interface and the /boot/firmware/cmdline.txt change
  • the logs of the packet forwarder startup
    thanks !

@davidgs
Copy link

davidgs commented May 28, 2024

@davidgs which version of the WM1302 do you have exactly (seeed product reference) ? Are the GPIOs correct for your setup ? SPI is properly configured on your RPi ?

WM1302
Model #WM1302-SPI-EU868-M
SPI is set up properly, and the Pins are correct (as best I can tell)

GPIO_CHIP=gpiochip0
GPIO_PIN_SX1302_RESET=17     # SX1302 reset
GPIO_PIN_SX1302_POWER_EN=18  # SX1302 power enable
GPIO_PIN_SX1261_RESET=5     # SX1261 reset (LBT / Spectral Scan)
GPIO_PIN_AD5338R_RESET=13    # AD5338R reset (full-duplex CN490 reference design)

@davidgs
Copy link

davidgs commented May 31, 2024

I have gotten it working. The problem was that I was not using a Pi HAT. I was trying to use the card directly via the M.2 slot on our board, which it turns out does not have access to any of the Pi-header pins.

@mcoracin
Copy link
Contributor

mcoracin commented Jun 3, 2024

I have gotten it working. The problem was that I was not using a Pi HAT. I was trying to use the card directly via the M.2 slot on our board, which it turns out does not have access to any of the Pi-header pins.

Ok, good news. :)
So the script that I shared is working for you, right ?

@mcoracin mcoracin added the fixed_next_release This will be fixed with next release label Jun 12, 2024
@FMMT666
Copy link

FMMT666 commented Jun 13, 2024

Ok, good news. :) So the script that I shared is working for you, right ?

Also thx from over here.

Created a RPi CM4 test setup a couple of days ago and immediately got stuck
due to this obsolete pin control issues.

Thx for sharing; exactly what I needed. A true time saver :)

@hereismeaw
Copy link

Hello all, Please find attached an updated reset script using gpiod. I've quickly tested it on a Raspberry Pi 4. @davidgs let me know if it fixes your issue. reset_lgw.gpiod.sh.tar.gz Best regards, Michael

Comfirmed this Works on WM1302 module in SenseCAP M1 AS923 Region.

Debian 12, Kernel 6.6.31

Great work!

@MichielBruijn
Copy link

Hello all, Please find attached an updated reset script using gpiod. I've quickly tested it on a Raspberry Pi 4. @davidgs let me know if it fixes your issue. reset_lgw.gpiod.sh.tar.gz Best regards, Michael

Excellent work!
Works on a vanilla RPI zero 2W with dragino RPI 32bit disk image + pg 1302 lora hat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed_next_release This will be fixed with next release
Projects
None yet
Development

No branches or pull requests

8 participants