Re: Simpler Question (Re: MCP2221 I2C/UART to USB)
Date: Wed, 13 Nov 2024 22:35:15 UTC
On Wed, Nov 13, 2024 at 9:30 PM George Mitchell <george+freebsd@m5p.com> wrote: > On 11/12/24 17:46, George Mitchell wrote: > > Has anyone ever used the MCP2221 chip from Microchip Technology (or any > > device incorporating it) on FreeBSD? If so, does it attach as both a > > serial port (cuaUn) AND human interface (uhidn), or just one? Does it > > work well? Thanks for any information you can give me. -- George > > Does FreeBSD have the concept of one hardware device attaching as two > device nodes? -- George Hey there George :-) Yes USB device may expose several interfaces and each one of them may use different kernel module / subsystem, all over single USB cable, that works well on FreeBSD. For instance Debug Probes (i.e. DAPLink or STLink) offer Serial Port for console access, JTAG/SWD/CMSIS HID interface for debug, and UMS (mass storage) emulation for drag-and-drop bin file for firmware flashing :-) I cannot tell if MCP2221 works well because I did not play with that chip you have to verify in practice sorry.. but it seems something like FT2232 or CH3421 right? I can see 3 options here depending on what you need :-) 1. The serial port emulation uses CDC standard, the same with anything that goes over HID, UMS, and others that are supported here. If this is a generic implementation it should work out of the box.. the only thing here that _may_ need an update is the VID:PID pair for a new chip identification numbers to be added to a specific kernel driver so it attaches on device connect (i.e. CDC so /dev/cuaU* is showed up). 2. If this is some sort of custom implementation (like FT2232) then additional driver would be necessary to translate between device internal registers to something that i.e. CDC can talk with. This is the case when you want to have native OS driver because of reasons. 3. FreeBSD provides native LibUSB interface that can be used by any application that already can talk to the chip directly over LibUSB (i.e. PyMCP2221A [1]). No system drivers are necessary in that case. For example if the chip is not supported at all here by the system but you have application that can talk to the chip on its own over libusb all should work fine :-) https://github.com/nonNoise/PyMCP2221A There are standard tools on FreeBSD like usbconfig that allows you to work with USB subsystem and devices (i.e. view usb device descriptors, reset, configure interfaces, etc), or devd that allows you to tell what system should do on device attach/detach events. USB stack is rock solid :-) https://man.freebsd.org/cgi/man.cgi?usbconfig I hope that helps a bit :-) Tomek -- CeDeROM, SQ7MHZ, http://www.tomek.cedro.info