hologram-io / hologram-python

Hologram device-side Python SDK - Send messages to the cloud in just 3 lines of code!
https://hologram.io/
MIT License
89 stars 47 forks source link

DriverLoader/Module Error #65

Closed teganburns closed 3 years ago

teganburns commented 3 years ago

Describe the problem

Unable to activate sim/nova on a Google-Coral Dev board.

Expected behavior

Activating sim and registering with the network.

Actual behavior

Device is a Google-Coral Dev board running Mendel (custom Debian).

mendel@google-coral:~$ uname -a
Linux google-coral 4.14.98-imx #1 SMP PREEMPT Fri Nov 8 23:28:21 UTC 2019 aarch64 GNU/Linux

Traceback

mendel@google-coral:~$ sudo !!
sudo hologram activate
modprobe: FATAL: Module option not found in directory /lib/modules/4.14.98-imx
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/NetworkManager.py", line 68, in network
    self._network.autodetect_modem()
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Cellular.py", line 50, in autodetect_modem
    raise NetworkError('Modem not detected')
Exceptions.HologramError.NetworkError: Modem not detected

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/hologram", line 181, in <module>
    if __name__ == '__main__': main()
  File "/usr/local/bin/hologram", line 169, in main
    run_hologram_activate(args)
  File "/usr/local/lib/python3.7/dist-packages/scripts/hologram_activate.py", line 36, in run_hologram_activate
    hologram = HologramCloud(dict(), network='cellular')
  File "/usr/local/lib/python3.7/dist-packages/Hologram/HologramCloud.py", line 70, in __init__
    network=network)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/CustomCloud.py", line 35, in __init__
    network=network)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Cloud.py", line 36, in __init__
    self.initializeNetwork(network)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Cloud.py", line 50, in initializeNetwork
    self._networkManager = NetworkManager.NetworkManager(self.event, network)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/NetworkManager.py", line 37, in __init__
    self.network = network
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/NetworkManager.py", line 71, in network
    self._network.load_modem_drivers()
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Cellular.py", line 54, in load_modem_drivers
    self._load_modem_drivers()
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Cellular.py", line 188, in _load_modem_drivers
    dl.force_driver_for_device(syspath, vid_pid[0], vid_pid[1])
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/DriverLoader.py", line 38, in force_driver_for_device
    with open(syspath, "w") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/sys/bus/usb-serial/drivers/option1/new_id'

List of modules

mendel@google-coral:~$ sudo lsmod
Module                  Size  Used by
crc32_ce               16384  0
crct10dif_ce           16384  0
wlan                 4952064  0
galcore               401408  2
ina2xx                 16384  0
imx_sdma               36864  2
ip_tables              24576  0
x_tables               45056  1 ip_tables

Device is found

mendel@google-coral:~$ sudo lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 05c6:90b2 Qualcomm, Inc. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Device details

mendel@google-coral:~$ sudo lsusb -d 05c6:90b2 -v

Bus 001 Device 004: ID 05c6:90b2 Qualcomm, Inc. 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x05c6 Qualcomm, Inc.
  idProduct          0x90b2 
  bcdDevice            0.00
  iManufacturer           1 Qualcomm CDMA Technologies MSM
  iProduct                2 QHSUSB__BULK
  iSerial                 3 95fb2822
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0020
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower                2mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol    255 Vendor Specific Protocol
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
can't get device qualifier: Resource temporarily unavailable
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0000
  (Bus Powered)

PPP installed

mendel@google-coral:~$ apt-cache policy ppp
ppp:
  Installed: 2.4.7-2+4.1+deb10u1
  Candidate: 2.4.7-2+4.1+deb10u1
  Version table:
 *** 2.4.7-2+4.1+deb10u1 500
        500 https://packages.cloud.google.com/apt mendel-day/main arm64 Packages
        100 /var/lib/dpkg/status

Steps to reproduce the behavior

curl -L hologram.io/python-install | bash curl -L hologram.io/python-update | bash sudo hologram activate

System information

teganburns commented 3 years ago

Posted on the Hologram Community Forum

DomAmato commented 3 years ago

Can you use the python serial package and list what it enumerates: https://pyserial.readthedocs.io/en/latest/tools.html#module-serial.tools.list_ports. Thats what we use to get the available devices so if its not enumerated by that package then it wouldn't get picked up by the modem detection code we wrote https://pyserial.readthedocs.io/en/latest/tools.html#module-serial.tools.list_ports.

teganburns commented 3 years ago

Here is what you requested.

mendel@google-coral:~$ python -m serial.tools.list_ports
no ports found

I believe it is a module issue. The device is picked up by dmesg when unplugging and plugging it back in for the record.

[ 1792.900063] usb 1-1: USB disconnect, device number 2
[ 2343.692316] usb 1-1: new high-speed USB device number 3 using xhci-hcd
DomAmato commented 3 years ago

hmm, im not sure we can properly handle it if that serial library doesn't detect it. I realize I linked the same thing twice in my previous comment instead of the code snippet I meant to. https://github.com/hologram-io/hologram-python/blob/develop/Hologram/Network/Modem/Modem.py#L199

Its possible we could rewrite this to use the system calls but afaik this is the first time we've encountered this. If you plug other serial devices into the usb ports does it enumerate them?

teganburns commented 3 years ago

If you plug other serial devices into the usb ports does it enumerate them?

Yes, official Arduino products work fine. Knock-off Arduino's didn't work for a similar reason.

Below is a response from the Google-Coral Team.

Hi Tegan, It looks like the Nova module enumerates as a custom vendor device, not a communication class device: https://en.wikipedia.org/wiki/USB_communications_device_class

That makes it difficult to use any standard tools to debug the connection.

What kernel modules are required in Mendel?

Have you tried using with an Ubuntu 18.04/20.04 laptop? If you get it working there, you can see what modules were added to support that and we can find out if those are ready for Mendel.

Also, see if there is an alternate driver available, perhaps something with less performance but more compatibility.

Best Regards,

Coral Support Team

I can't get the Hologram Python CLI to work on a Raspberry Pi V2 (it's excruciatingly slow and I run into a BadMagicNumber Error).

Can you tell me what modules the Nova uses on a working device so I can see about getting the proper modules installed on the Coral Dev board?

DomAmato commented 3 years ago

The pi v2 should work but it probably means the raspbian version is outdated. Right now the CLI only works for python 3.7 and if you have an older version of raspbian it would likely be python 3.6 which would give you the bad magic number error. I will check what modules are required and get back to you.

teganburns commented 3 years ago

Thank you, I got it working on the Pi v2 (very exciting! 😊). I was using Ubuntu not Raspbian.

I would still like to confirm the modules you believe are required for the Nova to operate.

Maybe I can add an unofficial aarm64 Debian repository to get these modules. 🤔

DomAmato commented 3 years ago

Sorry its been a bit, holidays hit and took up more time than expected. Will try to get around to it this week

teganburns commented 3 years ago

I'm going to close this issue. The Google Coral team doesn't seem to provide a reasonable solution and I've since moved on to the RPI 4B anyways.

In case anyone else stumbles across this here is the response I've received from the Google Coral team.

TLDR; Build the kernel yourself and figure out the correct modules required on your own (and hope it works ). 👎

As with most embedded OSes, Mendel doesn't come with non essential kernel module by default in order to save resources. However, we do have the procedure to download the source code and build it yourself: https://coral.googlesource.com/docs/+/refs/heads/master/GettingStarted.md

You can follow that guide to get the source code. For your case, you wouldn't need to build the entire OS but rather just the kernel. Here are the steps:

Get the code from the getting started guide

Open this file: packages/linux-imx/debian/defconfig and add the kernel config that you's need. At this step, you'll need to find out the exact kernel config that is needed. We don't support adding kernel module for other vendors HW.

Copy the new kernel to the dev board:

$ scp out/product/packages/bsp/linux-image-4.14.98-imx_11–4_arm64.deb mendel@ip-addr

mdt into the dev board and install it: $ sudo dpkg -i linux-image-4.14.98-imx_11–4_arm64.deb Thanks, Coral Support Team

Thank you for your help regardless @DomAmato 👍