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

Investigate if we need to depend on libudev #711

Open
SergioGasquez opened this issue Dec 19, 2024 · 6 comments
Open

Investigate if we need to depend on libudev #711

SergioGasquez opened this issue Dec 19, 2024 · 6 comments
Labels
investigation Issue requires further investigation port detection Issues related with ports detection
Milestone

Comments

@SergioGasquez
Copy link
Member

serialport can now work without libudev, see serialport/serialport-rs#220, this can lead to weird ports being shown but it might be worth to explore how this performs, some initial tests show good signs, see #709

@jessebraham
Copy link
Member

Do we know how/if this affects Linux systems based on MUSL? IIRC we have some custom logic for these systems in our port detection code, perhaps it is no longer necessary if serialport is now reading port info directly from /sys/.

@SergioGasquez
Copy link
Member Author

Do we know how/if this affects Linux systems based on MUSL?

No idea, @sirhcel sorry for the ping, do you have any idea on this?

@sirhcel
Copy link
Contributor

sirhcel commented Dec 20, 2024

Do we know how/if this affects Linux systems based on MUSL? IIRC we have some custom logic for these systems in our port detection code, perhaps it is no longer necessary if serialport is now reading port info directly from /sys/.

Especially since serialport/serialport-rs#220 things look almost shiny even without libudev. On my test system, two serial ports from a PCIe card are missing, but ttyS0 from the main board and the USB ports are reported identically now (as of 944e9e9, serial numbers redacted):

$ cargo run --target x86_64-unknown-linux-gnu --features usbportinfo-interface --example list_ports
[...]
Found 7 ports:
    /dev/ttyS0
        Type: Unknown
    /dev/ttyS4
        Type: PCI
    /dev/ttyS5
        Type: PCI
    /dev/ttyUSB2
        Type: USB
        VID: 0403
        PID: 6001
        Interface: 00
        Serial Number: FTFOO
        Manufacturer: FTDI
        Product: UT232R
    /dev/ttyUSB3
        Type: USB
        VID: 0403
        PID: 6010
        Interface: 00
        Serial Number: FTBAR
        Manufacturer: FTDI
        Product: FT2232H MiniModule
    /dev/ttyUSB4
        Type: USB
        VID: 0403
        PID: 6010
        Interface: 01
        Serial Number: FTBAR
        Manufacturer: FTDI
        Product: FT2232H MiniModule
    /dev/ttyUSB5
        Type: USB
        VID: 10c4
        PID: ea60
        Interface: 00
        Serial Number: YOURCP2102NSERIALHERE
        Manufacturer: Silicon Labs
        Product: CP2102N USB to UART Bridge Controller
$ cargo run --target x86_64-unknown-linux-musl --no-default-features --features usbportinfo-interface --example list_ports
[...]
Found 5 ports:
    /dev/ttyS0
        Type: Unknown
    /dev/ttyUSB2
        Type: USB
        VID: 0403
        PID: 6001
        Interface: 00
        Serial Number: FTFOO
        Manufacturer: FTDI
        Product: UT232R
    /dev/ttyUSB3
        Type: USB
        VID: 0403
        PID: 6010
        Interface: 00
        Serial Number: FTBAR
        Manufacturer: FTDI
        Product: FT2232H MiniModule
    /dev/ttyUSB4
        Type: USB
        VID: 0403
        PID: 6010
        Interface: 01
        Serial Number: FTBAR
        Manufacturer: FTDI
        Product: FT2232H MiniModule
    /dev/ttyUSB5
        Type: USB
        VID: 10c4
        PID: ea60
        Interface: 00
        Serial Number: YOURCP2102NSERIALHERE
        Manufacturer: Silicon Labs
        Product: CP2102N USB to UART Bridge Controller

Do you have some secret sauce for PCI port detection in place at espflash you can give we a reference to? I would love to get the port enumeration with and without libudev at a par.

@SergioGasquez
Copy link
Member Author

Do you have some secret sauce for PCI port detection in place at espflash you can give we a reference to? I would love to get the port enumeration with and without libudev at a par.

Here is where all the finding/selecting of serial ports happens, the only "magic" that we do is with linux-musl that we parse sysfs, see the two implementations of detect_usb_serial_ports

@sirhcel
Copy link
Contributor

sirhcel commented Jan 4, 2025

Thank you for the reference @SergioGasquez! At a first glance, it looks like the USB ports enumerated by espflash should be enumerated by serialport-rs as well. But the enumeration will additionally return some more ports from the motherboard of my Linux machine from #711 (comment). So the result from using the non-libudev enumeration from serialport-rs will be "between" espflash's enumeration without and with libudev.

The discrepancy between the devices enumerated by libudev and our manual for MUSL/non-libudev is bugging me since a while and I found some time to look into it and serialport/serialport-rs#238 sets out to close this gap and should bring the enumeration en par with libudev.

Do you have some interesting corner cases from the enumeration done by espflash? May be there is something relevant for serialport-rs too.

@jessebraham jessebraham added this to the v4 milestone Jan 9, 2025
@jessebraham jessebraham added the investigation Issue requires further investigation label Jan 9, 2025
@SergioGasquez SergioGasquez added the port detection Issues related with ports detection label Jan 9, 2025
@SergioGasquez
Copy link
Member Author

Do you have some interesting corner cases from the enumeration done by espflash?

I dont recall any

serialport/serialport-rs#238 looks promising, maybe we can do some tests after it lands. We are working on planning espflash v4, so this should definitely be investigated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigation Issue requires further investigation port detection Issues related with ports detection
Projects
Status: Todo
Development

No branches or pull requests

3 participants