RAK5148 USB disconnection issue

Hello RAK Forum,

I am experiencing an issue with my Semtech RAK5148, 2.4 G device on my Raspberry Pi. The device intermittently disconnects and reconnects, causing disruptions. Here are the relevant log entries from dmesg:

Jul 11 18:39:14 rakpios kernel: usb 3-1.3: USB disconnect, device number 3
Jul 11 18:39:14 rakpios kernel: usb 3-1.3: new full-speed USB device number 7 using dwc2
Jul 11 18:39:14 rakpios kernel: usb 3-1.3: New USB device found, idVendor=05c9, idProduct=5740, bcdDevice= 2.00
Jul 11 18:39:14 rakpios kernel: usb 3-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jul 11 18:39:14 rakpios kernel: usb 3-1.3: Product: GTW 2G4 VPC
Jul 11 18:39:14 rakpios kernel: usb 3-1.3: Manufacturer: Semtech
Jul 11 18:39:14 rakpios kernel: usb 3-1.3: SerialNumber: 205332843831

after the disconnect happened, this is the output of dmesg | grep tty

rak@rakpios:~ $ dmesg | grep tty
[    0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=0 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 video=HDMI-A-1:1920x1080M@60D smsc95xx.macaddr=D8:3A:DD:05:A5:13 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000  console=ttyS0,115200 console=tty1 root=PARTUUID=3b45ec03-02 rootfstype=ext4 fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles
[    0.000411] printk: console [tty1] enabled
[    1.443060] fe201000.serial: ttyAMA0 at MMIO 0xfe201000 (irq = 19, base_baud = 0) is a PL011 rev2
[    2.777551] systemd[1]: Created slice system-getty.slice.
[    8.497819] cdc_acm 3-1.3:1.0: ttyACM0: USB ACM device
[    8.593959] usb 3-1.4.3: ch341-uart converter now attached to ttyUSB0
[    8.598489] usb 3-1.4.4: ch341-uart converter now attached to ttyUSB1
[   15.396069] usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB2
[   15.397579] usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB3
[   15.402860] usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB4
[   15.403386] usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB5
[25988.976428] cdc_acm 3-1.3:1.0: ttyACM1: USB ACM device

Steps I’ve Taken So Far:

  1. Checked Physical Connections. This should not be an issue since the system is working for a few hours before the disconnection happened

  2. Disabled USB autosuspend:

    • Temporarily disabled USB autosuspend by executing:
      echo -1 | sudo tee /sys/module/usbcore/parameters/autosuspend
    • Made the change persistent by adding usbcore.autosuspend=-1 to /boot/cmdline.txt:
console=serial0,115200 console=tty1 root=PARTUUID=3b45ec03-02 rootfstype=ext4 fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles usbcore.autosuspend=-1
  • Rebooted the system.
  1. Checked Device Logs:**
    • Monitored dmesg logs to verify the device behavior post changes.

Despite these steps, the issue persists. The device continues to disconnect and reconnect sporadically.

System Information:

  • Raspberry Pi Model: CM4
  • Operating System:RAKPIOS
  • Device Model: RAK5148 Semtech-based concentrator

I am seeking help to resolve this issue. I would greatly appreciate any guidance on further troubleshooting steps or configuration adjustments. Has anyone else encountered similar issues with this or similar devices?

Thank you in advance for your assistance!

Best regards,
Iman

Hello. I am having the same problem on a RAK 7391. It disconnects intermittently. I checked phisical connection, changed to a bigger power supply. Did you find solution?

Regards, Joel

Hi @jomolinare , may I know in which slot you have the RAK5148 in your RAK7391?

It is on slot#2, slot#1 has a RAK5146.

I Finally fixed it in the FW. what i did is this:

Step 1: Persistent USB Device Path (udev rule)

Created a udev rule (/etc/udev/rules.d/99-rak5148.rules) to assign a persistent USB device name and create a trigger file upon USB reconnection.

SUBSYSTEM=="tty", ACTION=="add", ATTRS{idVendor}=="05c9", ATTRS{idProduct}=="5740", \
SYMLINK+="rak5148", \
RUN+="/bin/sh -c '/usr/bin/touch /tmp/lora_usb_reconnected && \
/bin/chown rak:rak /tmp/lora_usb_reconnected && \
/bin/chmod 666 /tmp/lora_usb_reconnected'"

Reloaded udev rules:

sudo udevadm control --reload
sudo udevadm trigger

Step 2: Updated Configuration

  • Updated global_conf.json clearly to use persistent device path:
{
  "radio_conf": {
    "tty_path": "/dev/rak5148"
  }
}

Step 3: Automated Restart via Python Script

  • Modified Python script (RAK_lora24G.py in my case) to detect USB reconnection and automatically restart the LoRa packet forwarder using threading:
def restart_packet_forwarder():
    global t1, stop_event
    stop_event.set()
    subprocess.run(['pkill', '-f', app1_executable])
    t1.join(timeout=6)
    stop_event.clear()
    t1 = threading.Thread(target=capture_output, args=(app1_directory, app1_executable, output_queue, stop_event))
    t1.start()

while True:
    if os.path.exists('/tmp/lora_usb_reconnected'):
        restart_packet_forwarder()
        os.remove('/tmp/lora_usb_reconnected')

Step 4: Fixed Permissions

  • Ensured correct file permissions:
sudo chown rak:rak /PATHTOYOURFOLDER/RAK_lora24G.py
sudo chmod +x /PATHTOYOURFOLDER/RAK_lora24G.py

Following these brief steps provided a robust solution for automatically handling the LoRa module’s USB reconnection events.