Giter Club home page Giter Club logo

Comments (4)

smasher816 avatar smasher816 commented on May 31, 2024

Here is some guidance:

Each device interface can have multiple alternative settings as described here - http://www.beyondlogic.org/usbnutshell/usb5.shtml#AlternateSetting. Section 4.2.3 of the USB DFU interface may be helpful - http://www.usb.org/developers/docs/devclass_docs/DFU_1.1.pdf, along with this patch not from u-boot's implementation - http://lists.denx.de/pipermail/u-boot/2011-November/108003.html.

Looking at the source code, dfu-util will call libusb_get_string_descriptor_ascii() to receive a string descriptor in unicode. I am not sure what index must be set but the line of code that finds it is here - https://github.com/Stefan-Schmidt/dfu-util/blob/fdc72a8a738994dc72cfd63ff08f690e5145277e/src/main.c#L193.

From the looks of the line, and examining the libusb_get_config_descriptor_by_value() code it returns a libusb_config_descriptor struct, which then has an array of libusb_interface structs, each of which has an array of libusb_interface_descriptor's (altsettings), which then have an index. This index is what is used to query the string. As far as I can tell there is no string field in the struct, so I am not sure where it is stored, perhaps the extra field is of use... Looking at this log it seems like the iInterface somehow has a descriptive string to go with it - https://github.com/cjheath/dfu-util/blob/99ddc0c15021065512dca5c98ce57bec79513261/device-logs/stm32f4discovery.lsusb#L37.

It would be helpful if I knew more about how string descriptors worked in the usb standard. [EDIT: Just did some searching...] According to this page, http://www.beyondlogic.org/usbnutshell/usb5.shtml#InterfaceDescriptors, iInterface is the "Index of string descriptor describing interface - set to 0 if no string". That makes a lot more sense. In that case I believe this line must be updated - https://github.com/kiibohd/controller/blob/master/Bootloader/dfu.desc.c#L53, and a string descriptor must be added somewhere. Looking for other string descriptors my best guess is in the string_descs array found here - https://github.com/kiibohd/controller/blob/master/Bootloader/usb.h#L140. USB_INIT_DEVICE does not seem to be used anywhere but it seems like the best place. I'll give it a shot and report back.

Happy debugging.

from controller.

smasher816 avatar smasher816 commented on May 31, 2024

Got my buspirate wired up and tested this thing out. Turns out it didn't read my ID=4 I added, but using id 3 (serialno) worked fine. This lead me to find out that the defines in usb.h do not seem to be used, instead the string must be added to dfu_device_str_desc in dfu.desc.c. After doing that and adding a define to _buildvars.h I could successfully set iInterface to the index of the new string and had it show up as the name in dfu-util --list. See here: http://ix.io/gNP

If you say what you want the name to be I will send a pull request over. I could send one now but then you would probably end up changing it anyways. Also, it might be worthwhile to look at usb.h and see if some of that stuff is actually needed (it appears it is not).

from controller.

haata avatar haata commented on May 31, 2024

Cool. Awesome work.

Probably the easiest thing to name it would be "Kiibohd DFU". Usually for names like this I put it in one of the CMake build files (through _buildvars.h). Probably Lib/CMake/arm.cmake would be the ideal place for it.

from controller.

smasher816 avatar smasher816 commented on May 31, 2024

Created a pull request using your preferred name and define location. Tested working on my infinity, but feel free to review the code. It's a pretty simple change overall, but the research going into it is what made it more difficult :)

from controller.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.