-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Have usable VID/PIDs for standard situations and prototype ones for examples #12273
Comments
I've prepared a branch for a PR to pid.codes at https://github.com/chrysn-pull-requests/pidcodes.github.com/tree/riot-codes (chrysn-pull-requests/pidcodes.github.com@1aea5b9), but not sent it as I'm not convinced this is all correct. To summarize that request, it's asking for one PID for when only RIOT-OS is setting up peripherals (serial, Ethernet, bootloader reset), one RIOT specific Test PID that has similar policy as the existing test PIDs but can still capture RIOT shipped peripherals, and one for RIOT's DFU bootloader (that, AFAICT, is so far just an idea). Especially, I'm not sure we get away with a single number for the "just what the board ships" case, as that may include serial and/or Ethernet only if the application demands a stdio or a network interface, resulting in different USB behaviors. As I understand the IDs are largely relevant for Windows drivers (as in Linux and MacOS things always work out of the box, and things like udev can hook into any attribute to decide permissions/groups/names etc). Can a single Windows … driver description? … be created that would encompass, on a single VID/PID pair, all the variation there can be on that? (I've been wondering that before, and pidcodes/pidcodes.github.com#289 reaffirms my doubts that one would be enough). If it is, can someone confirm that? If it is not, how many "bits" do we need to set aside? I suppose we'll have the (bootloader) reset all the time once it's there, but serial and Ethernet are the two variables, so I'd be asking for 4 IDs then (or 8, 4 for regular and 4 for the Test PID)? Do we anticipate other peripherals to be enabled on a board by default? (I don't really see how a mass storage device would interact there, unless it's the bootloader that gets its own ID anyway.) Is there any reason why devices running test cases can not just use the Test PID? |
@kaspar030 @dylad @aabadie: Any opinions on this? |
This is also how I've always understood VID/PID pairs, as one product with a specific and fixed feature set.
Linux and MacOS seem to match USB interface class and subclass numbers. Not sure if it is possible to use that with Windows too. IMHO the bootloader really requires a separate PID as it makes DFU flashing a lot more convenient. I would prefer to also have a VID/PID for examples, but I can imagine that they don't allow that use case. |
How set-in-stone do they need to be? Can the USB stack give long-term guarantees that applications that pull in ECM and ACM will always have the ACM at If=0 and the ECM at If=2? Are we sufficiently far along that we feel comfortable picking a virtual reset-pin feature that'd go into that feature set? (If those are difficult questions to answer, I suggest we keep using the Test PIDs for some more time, let nothing block on this issue, and maybe start experimenting with internal conventions on the use of the Test PIDs before we apply for real ones; a la "Test1 is for bootloader, Test2 is for what we'd later call Generic Application with ACM+ECM+Reset etc").
Yes, sketched as such.
The examples have a tendency of getting copy-pasted around as skeletons, so if they use a non-screaming-red pair, that'd easily get out of hand -- and the build system couldn't really know when the example is pristine, when someone's just tweaking it a little, and when it's a separate application. That's what I'm suggesting the RIOT test PID for, it'd scream less loudly (yellow?) and say that this is for RIOT examples and you should pick a real one at some point in time. (Examples that are not USB examples would use the "Only using RIOT system USB-emulated peripherals" anyway, which never scream but conflict with the |
Hello, I was interested in using the USB port for data transfer from a datalogger that captures data on flash memory, and due to the amount of data, transfer via serial port becomes too long to complete. It would be great to be able to use an address freely for situation like: pendrive-like device and generic serial port-like device, like FTDI/CH340 etc. This library below allows the STM32F103 to operate as a USB stick and serial port at the same time (In conjunction with another library, flash memory can be used in place of SD card, ideal for dataloggers): I searched a bit about buying only PID (resale), but found several posts on the internet saying that USB-IF is preventing this procedure. See what I found:
Source: http://www.arachnidlabs.com/blog/2013/10/18/usb-if-no-vid-for-open-source/ So for countries where wireless networking is allowed, it is a more attractive alternative. (In my country the wireless communication device must be government approved, and this approval is costly, so there is no alternative between WiFi / Bluetooth etc and USB, both are unfeasible for small developers, and is one of the reasons so many projects stored in the drawer that get lost over time). |
It would be great to be able to use an address freely for situation
like: pendrive-like device and generic serial port-like device, like
FTDI/CH340 etc.
That's where I think the "RIOT device with system peripherals" would
come in; when used on a serial-only device, it'd instruct the OS/user to
treat the device like you would a generic UART adapter, with the
higher-level protocol being application defined. (The application's name
should probably be indicated in a uniform and locatable way in the
idVendor/idProduct).
I searched a bit about buying only PID (resale), but found several
posts on the internet saying that USB-IF is preventing this procedure.
Not quite, according to pid.codes. When someone first did this, the IF
changed their policy to prevent that. However, the VIDs assigned to
pid.codes, openmoko and probably some others were bought when transfer
of individual PIDs was not forbidden yet, and the IF apparently had no
clause for unilateral change of the contract in there.
We're not trying to buy a VID here (for which we'd get a
cease-and-desist like in the quoted text), but asking someone who got a
VID block back when the old rules applied for some of their PIDs.
So for countries where wireless networking is allowed, it is a more
attractive alternative.
It's probably off-topic here, but let me add two notes:
* Some radio modules come pre-certified, which should make it a lot
easier to go through the necessary approval steps (though it won't
spare you all the trouble). Some legislations have provisions for
prototyping that can be used until certification can be obtained.
* If you are considering network-based access to a data logger, you may
want to go that way already for pendrive-based designs; USB Ethernet
(CDC-ECM) support is available in RIOT. That would allow you to keep
your host-side software unmodified when you switch between USB-, WiFi
or other network services. I do have some interest in and experience
with network-based; if you want to follow up on that, drop me a mail
to chrysn-at-fsfe.org or stop by #RIOT on freenode.org IRC.
|
With today's tests with Windows, I'm confident that the proposed PIDs for OS-only and testing can be used as such. A code for a bootloader can still be requested later when we do have code for one. With that, I've opened a PR for the RIOT organization to be created and two PIDs 7D00 and 7D01 (72xx are taken in the meantime, and with all those n3rds out there it's obviously impossible to start a pseudblock with anything that's 42 or 23 in BCD or hex encoding, or even the ASCII code for "r") to be assigned at pidcodes/pidcodes.github.com#468. |
While this is being processed at pid.codes, I remembered another "codes for free use with X" installment at v-usb (a bit-banging USB low-speed implementation for attiny & co). While not directly relevant if the pid.codes application works out, they do have an interesting policy that says to use domain names for device identification. I like that (though I'd rather go with URIs and some rule a la "the last valid substring that is a URI" to make it unambiguous), and if nothing else (because we probably don't strictly need such a policy) to use it as default values in the examples and in OS-provided setups. |
Now that we have the codes, I'd like to follow this plan for VID/PID handling: Goal: Allow applications without custom USB code to Just Build, and to use 7D00 (the RIOT-builtin peripherals code) without further configuration. Fail the build if the user wants to do anything manual about USB unless a VID/PID pair is set (with a message that tells to use 7D01 (the test code) in the Makefile, or to get own codes). Warn whenever building with 7D01. Constraints: Don't require the user to include any pseudomodules or similar if it can be avoided.
This will only result in "inconsistent" responses in the error case (in which the build will fail eventually), and have result in the desired over-all behavior. I'm starting a test implementation to see whether I missed anything, but if not, that will be my PR. |
This * renames DEFAULT_xID to USB_xID_TESTING as it is not really a default (if anyting, the 7D00 is, and it's not that) * moves the check into Makefile * generalizes the check to all test PID/VID pairs * in doing so, fixes the "or" (which would have ruled out warning-free use of an allocated pid.codes number), and compares to the actual testing PID rather than the RIOT-peripheral PID * removes all occurrences of duplicated checks in examples or tests, leaving definitions only where they are needed * moves the Kconfig defaults of the usbus_minimal example into the main Kconfig, as these are good defaults for all cases when USB is enabled manually Closes: RIOT-OS#12273
This * renames DEFAULT_xID to USB_xID_TESTING as it is not really a default (if anyting, the 7D00 is, and it's not that) * moves the check into Makefile * generalizes the check to all test PID/VID pairs * in doing so, fixes the "or" (which would have ruled out warning-free use of an allocated pid.codes number), and compares to the actual testing PID rather than the RIOT-peripheral PID * removes all occurrences of duplicated checks in examples or tests, leaving definitions only where they are needed * moves the Kconfig defaults of the usbus_minimal example into the main Kconfig, as these are good defaults for all cases when USB is enabled manually Closes: RIOT-OS#12273
This * renames DEFAULT_xID to USB_xID_TESTING as it is not really a default (if anyting, the 7D00 is, and it's not that) * moves the check into Makefile * generalizes the check to all test PID/VID pairs * in doing so, fixes the "or" (which would have ruled out warning-free use of an allocated pid.codes number), and compares to the actual testing PID rather than the RIOT-peripheral PID * removes all occurrences of duplicated checks in examples or tests, leaving definitions only where they are needed * moves the Kconfig defaults of the usbus_minimal example into the main Kconfig, as these are good defaults for all cases when USB is enabled manually Closes: RIOT-OS#12273
This * renames DEFAULT_xID to USB_xID_TESTING as it is not really a default (if anyting, the 7D00 is, and it's not that) * moves the check into Makefile * generalizes the check to all test PID/VID pairs * in doing so, fixes the "or" (which would have ruled out warning-free use of an allocated pid.codes number), and compares to the actual testing PID rather than the RIOT-peripheral PID * removes all occurrences of duplicated checks in examples or tests, leaving definitions only where they are needed * moves the Kconfig defaults of the usbus_minimal example into the main Kconfig, as these are good defaults for all cases when USB is enabled manually Closes: RIOT-OS#12273
This * renames DEFAULT_xID to USB_xID_TESTING as it is not really a default (if anyting, the 7D00 is, and it's not that) * moves the check into Makefile * generalizes the check to all test PID/VID pairs * in doing so, fixes the "or" (which would have ruled out warning-free use of an allocated pid.codes number), and compares to the actual testing PID rather than the RIOT-peripheral PID * removes all occurrences of duplicated checks in examples or tests, leaving definitions only where they are needed * moves the Kconfig defaults of the usbus_minimal example into the main Kconfig, as these are good defaults for all cases when USB is enabled manually Closes: RIOT-OS#12273
This * renames DEFAULT_xID to USB_xID_TESTING as it is not really a default (if anyting, the 7D00 is, and it's not that) * moves the check into Makefile * generalizes the check to all test PID/VID pairs * in doing so, fixes the "or" (which would have ruled out warning-free use of an allocated pid.codes number), and compares to the actual testing PID rather than the RIOT-peripheral PID * removes all occurrences of duplicated checks in examples or tests, leaving definitions only where they are needed * moves the Kconfig defaults of the usbus_minimal example into the main Kconfig, as these are good defaults for all cases when USB is enabled manually Closes: RIOT-OS#12273
This * renames DEFAULT_xID to USB_xID_TESTING as it is not really a default (if anyting, the 7D00 is, and it's not that) * moves the check into Makefile * generalizes the check to all test PID/VID pairs * in doing so, fixes the "or" (which would have ruled out warning-free use of an allocated pid.codes number), and compares to the actual testing PID rather than the RIOT-peripheral PID * removes all occurrences of duplicated checks in examples or tests, leaving definitions only where they are needed * moves the Kconfig defaults of the usbus_minimal example into the main Kconfig, as these are good defaults for all cases when USB is enabled manually Closes: RIOT-OS#12273
Description
Currently, all examples use generic prototype VID/PID pairs that should really not make it into widespread use; building with them shows a big red warning to please get own IDs before handing out anything.
With USB support becoming more usable, boards like the nrf52840-dongle (#12189) whose default console is a USB serial device become available to RIOT. Those flashing USB warnings to developers who didn't even touch a line of USB code or intentionally use USB (other than for
make term
) is confusing, and those situations may qualify for some of the ID pair pools for Free Software.The hard parts here are to
Applicability
The IMO clear-cut corner cases for applicability are "user is building a demo like
gcoap
on a board that happens to have default USB UART and networking" (that should get a VID/PID that says 'RIOT built-in serial adapter'), and "user is building an application with own USB peripherals" (clearly, the prototype pair should be used here and flash the red). Examples should probably show the latter behavior as well as to indicate what a developer should do in own code.It would be easiest to have one code that just says "RIOT built-in peripherals", and has serial and/or Ethernet configured as applicable or configured. There may be room for a third endpoint that allows for reset into the bootloader by whichever means. If that flexibility within an ID pair is asking too much, there'd be 3 (or 7, with bootloader) IDs for whichever combination of features is active.
Detection
Detection of whether a build is eligible for the "RIOT built-in foo" IDs is another open point; relying on users to do the right thing might not cut it here.
One suggestion for detection would be to create a
usbus_user
(pseudo?)module(?). The core USB module headers would check for whether either that is active or aUSBUS_INTERNAL
define is present (outside of their include guards), and otherwise#error
out with a message asking to activateusbus_user
. The internal users of USB that are sanctioned to use the VID/PID pair set that define for while they're including the USB headers. All this is easy to circumvent intentionally (and there's no ambition to avoid that), but both accidental use of the RIOT IDs and "I'm lazy and will do the quickest thing that'll make things work" cases should be curbed by that.(The build system would then set the default VID/PIDs to the current prototype ones if
usbus_user
is active, and to the internal ones otherwise. Either could be overridden. The red warning would show iff the prototype ones are in use, independent of the modules).Useful links
Context
This was brought up by @bergzand in an IRC discussion of VID/PID pairs.
(edit: added pid.codes link)
The text was updated successfully, but these errors were encountered: