RFC: Configuring USB Gadget through configfs #27
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
DO NOT MERGE
configfs seems to be the most modern and flexible way to configure USB Gadgets from the Linux user space.
From the config fs docs:
Using configfs, we can dynamically add and remove gadget functions at runtime without having to recompile the linux kernel. This PR demonstrates some of my findings.
/etc/gadget_start.sh
Represents recreating the current configuration where we have a CDC device with 1xACM and 1xECM. This setup is kinda neat, because we get to control the device name and serial number. In this example, I am able to set the device serial number to the
boardid
.I added a busybox config because I needed to enable
ln
because callingFile.ln_s
was returning errors because the directories already existed. There might be a work around here, not sure.In addition, I attempted to update the erlinit.config to execute the gadget script pre exec so that it might be able to use the
ttyGS0
port that it creates. Unfortunately, this did not work and the serial console ended up coming acrossttyACM0
.RFC
This is labeled as RFC because it has drawbacks but I wanted to demonstrate something interesting. I think that its really neat to be able to programmatically control the gadget properties and functions at runtime. In addition, you can enable a lot more combinations of functions that the gadget could serve such as USB HID, mass storage device, and more. I just through that this stuf was really cool and I wanted to share it with everyone.
Relevant Docs
ConfigFS Gadgets
http://elixir.free-electrons.com/linux/latest/source/Documentation/usb/gadget_configfs.txt
ConfigFS
https://www.kernel.org/doc/Documentation/filesystems/configfs/configfs.txt