Could anyone recommend any wizard-like tool for creating USB device descriptors?

Most (all?) USB firmware examples I've looked into so far define the descriptors as a simple byte array in a .c file, filled manually (with a little help from macros).

It's not black magic, obviously, still I believe that a simple specialized tool could be useful. Googling for it gave no useful results, however.

  • \$\begingroup\$ While not a proper wizard tool, this Perl library seems a bit more readable than multi-line C macros chaining other C macros: metacpan.org/pod/USB::Descriptor \$\endgroup\$ Sep 6, 2022 at 7:42

1 Answer 1


A wizard-like tool may be cute the first time you use it, but then it gets in the way. A better method is a decent structure of the descriptors in memory, and a few helpful macros and other preprocessing logic so that you can supply the information at a higher level and the right bytes and bits automatically get filled in.

My USB stack for the PIC 18 works like that. You can install that and a bunch of other stuff from my software downloads page. The static USB setup is defined in two files. The templates for these are named QQQ_USB.INS.ASPIC and QQQ_USB0.INS.ASPIC in the SOURCE > PIC directory. First you define the VID/PID, which endpoints you use, and which transfer types per endpoint in the usb.ins.aspic file. Then you modify the descriptors in usb0.ins.aspic with the little bit you need to customize. Since it already knows things like the transfer types and buffer sizes, you leave those symbols alone and just change what's unique to your implementation. In most cases, that's only adjusting the manufacturer name and the product name. These you write as ordinary strings and a macro takes care of the proper formatting.

  • \$\begingroup\$ well, both ways have pros and cons. I assume a properly written tool could store the settings in some sort of text file (so one could keep it in the code repository), and allow for re-editing the settings and regenerating the descriptor file whenever you need. I believe this could be useful for at least 2 reasons: a) assure the descriptor is valid, b) provide some sort of useful contextual help for each field. Another useful use case is to import the descriptor from actual USB device connected to PC. \$\endgroup\$ Oct 23, 2011 at 8:56
  • \$\begingroup\$ @Czajnik: Did you look at the code I mentioned at all? It's really not that hard to fill in what you want. \$\endgroup\$ Oct 23, 2011 at 13:15
  • 1
    \$\begingroup\$ Yes, I did (btw, exe file is a bit unfriendly for Linux users). And I've done my own descriptors before, as I said, it's not black magic to me. I guess it's a matter of personal preference, really :) \$\endgroup\$ Oct 23, 2011 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.