[IoT Edge module] USB Device Persistence Issue in Azure IoT Edge Module

rfuentess 45 Reputation points
2025-07-18T09:05:52.7133333+00:00

Environment and settings

  • Development OS: Linux
  • IoT Edge device: An Raspberry running the raspOS
  • Connection: USB device that can goes down or UP with frequency

The IoT Edge module uses the following CreateOptions configuration:


{

  "HostConfig": {

    "Privileged": true,

    "Devices": [

      {

        "PathOnHost": "/dev/bus/usb",

        "PathInContainer": "/dev/bus/usb",

        "CgroupPermissions": "rwm"

      }

    ]

  }

}

Issue

The USB device binding is not persistent after device re-connections. While the

initial connection at startup works correctly, subsequent re-connections of the USB device

result in device path mismatches between the Rasoberry host and container.

Example

The container's lsusb shows the device as:


Bus 001 Device 052: ID 1fc9:012f NXP Semiconductors SE Blank 8QXP 

Bus 001 Device 004: ID 0424:7800 Microchip Technology, Inc. (formerly SMSC) 

Bus 001 Device 003: ID 0424:2514 Microchip Technology, Inc. (formerly SMSC) USB 2.0 Hub

Bus 001 Device 002: ID 0424:2514 Microchip Technology, Inc. (formerly SMSC) USB 2.0 Hub

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Here, the Device is now 052

However, the container's /dev/bus/usb/001/ directory shows:


drwxr-xr-x 2 root root     140 Jul 18 08:09 .

drwxr-xr-x 3 root root      60 Jul 18 08:09 ..

crw-rw-r-- 1 root root 189,  0 Jul 18 08:09 001

crw-rw-r-- 1 root root 189,  1 Jul 18 08:09 002

crw-rw-r-- 1 root root 189,  2 Jul 18 08:09 003

crw-rw-r-- 1 root root 189,  3 Jul 18 08:09 004

crw-rw-r-- 1 root root 189, 41 Jul 18 08:09 042

Which was the original value when the container was started.

In tests where I directly deploy the container with privileged mode and volume binding everything goes well.

Has anyone encountered similar issue?

Azure IoT Edge
Azure IoT Edge
An Azure service that is used to deploy cloud workloads to run on internet of things (IoT) edge devices via standard containers.
0 comments No comments
{count} votes

Accepted answer
  1. Sander van de Velde | MVP 36,941 Reputation points MVP Volunteer Moderator
    2025-07-18T15:24:53.95+00:00

    Hello @rfuentess ,

    welcome to this moderated Azure community forum.

    As seen in the other answer post, it seems you have found a solution for your question.

    In the past, I have worked with serial connections that are also not reliable regarding the availability.

    It's best to be prepared the connection to (external) hardware is lost and the code will try to reconnect at a descent interval.

    If this does not work, letting the module 'crash' so the fall-back of Docker is kicked in to restart the module is also an approach although this can have side effects like lost data. Keep it in mind as a last resort.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. rfuentess 45 Reputation points
    2025-07-18T13:31:16.1166667+00:00

    Finally, I found the solution. My createoptions were not enough. I could indeed see the USB devices but there was not a full bind between them and the container/module.

    This was my final CreateOption

    {
      "HostConfig": {
        "Privileged": true,
        "Devices": [
          {
            "PathOnHost": "/dev/bus/usb",
            "PathInContainer": "/dev/bus/usb",
            "CgroupPermissions": "rwm"
          }
        ],
        "Binds": [
          "/dev/bus/usb:/dev/bus/usb"
        ]
      },
      "Mounts": [
        {
          "Type": "bind",
          "Source": "/dev/bus/usb",
          "Destination": "/dev/bus/usb",
          "Mode": "",
          "RW": true,
          "Propagation": "rprivate"
        }
      ]
    }
    
    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.