BeagleBoard/GSoC/2021 Proposal/usb configfs in device tree

= Proposal for Device Tree Improvement =


 * Student: Shreyas Atre
 * Mentors: Deepak Khatri (IRC: lorforlinux)
 * Code: [N/A]
 * Proposal : https://elinux.org/index.php?title=BeagleBoard/GSoC/2021_Proposal/usb_configfs_in_device_tree
 * Wiki: [N/A]
 * GSoC: [N/A]

= Status =
 * Pre-application phase

= Proposal =
 * Completed all the general requirements
 * Completed "Hello Wolrd" of cross compilation mentioned in the requirements list.
 * Sent a PR to the mentioned upstream #145

About You

 * IRC : satacker (@satacker:matrix.org)
 * Github: https://github.com/SAtacker/
 * School: Veermata Jijabai Technological Institute (VJTI)
 * Country: India
 * Primary language : English, Hindi, Marathi
 * Typical work hours : 10AM - 7PM Indian Standard Time
 * Experience :
 * PID-Tuning-GUI is my Graphing Qt application as well as for sending data to esp32 microcontroller using Boost.ASIO as Networking stack in order to configure the Proportional-Integral-Derivative (PID) Controller.
 * kernel learn is a repo I had created for kernel learning purposes in which I had learned Kernel module development Basics.
 * I have realised the beauty of embedded systems after working on esp32 dev board and reading Exploring Linux with Beaglebone by Derek Molloy while in Society of Robotics and Automation as a core team member.
 * This is the first time i am participating in GSoC

= About Your Project =


 * Project name: USB configfs in device tree

Description

 * ConfigFS which along with libcomposite allows to set up custom gadget. This can be achieved using simple, command-line file system operation like mkdir, rmdir, ln -s, read and write. It is possible to configure USB gadget using only the command line but each time after reboot user needs to recreate all gadgets once again. This means that after each reboot user needs to use commands.
 * Also scripts can be edited and are obviously less secure.
 * Secondly it's really hard to modify such a script because many calls have a hard-coded path where for example echo should be done. There is a lot of simple, but low-level operations which can cause a lot of confusion for a beginner.
 * This leads us to another solution : libusbgx which is a userspace library to configure USB gadgets
 * However a better solution to this could be using device trees for configuration. The idea with this GSoC project is to create a device-tree node that could specify the USB gadget through libcomposite on bootup. Thus users of USB gadget wouldn’t have to rely on custom boot scripts or libusbgX.
 * Goal: USB configfs in device tree such that they can be configured statically in device tree ahead of boot and speed the boot process.

Implementation Details
A device tree is a tree data structure with nodes that describe the physical devices in a system. From wiki we can see the basic usage guide of device tree. We can look at the bindings here.

USB:&USB { compatible = "chip,subset"; reg = ; reset-gpios = <&gpio1 NUM GPIO_ACTIVE_LOW>; vendor-id = /bits/ 16 ; product-id = /bits/ 16 ; string-support; manufacturer = "Foo"; product = "Foo-Bar"; serial = "1234567890A"; configs: configs{ configuration = "BeagleBone Composite"; max_power = 500; }                              functions:functions{ class=; sub-class = <04>; protocol = <01>; }                               interface:interface{

}                               symlink = "functions/acm.usb0"; };

Experience and approach

 * Previously I have worked with Qt and Boost.ASIO . PID-Tuning-GUI is an application that sends data to ESP32 micro controller which supports WiFi connectivity. Handled Application threads and Plotting of data as well as sending user input to microcontroller.
 * kernel learn is a repository I had created for kernel learning purpose in which I had learned several Kernel development Basics.
 * I have played with Pocketbeagle for a month and learned a lot about u-boot, device trees and Loadable Kernel Modules.
 * This gives me best of both the worlds embedded as well as a bit in frontend (Qt).

Contingency

 * There is a good documentation of FXTUI and Qt
 * Plenty of examples to get me through if I am stuck.
 * Past experience regarding Qt and DOM manipulation combined with experience in embedded and loadable kernel modules development will pay off in this duration.

Benefit

 * Having a seamless one-click experience to configure is enjoyed by any user, be it production or a robotics team.
 * Provides a configuration file to the users. Remembers defaults and helps in accidental modification to low level configurations.

Misc

 * For hello_world of cross-compilation, sent a PR to the mentioned upstream #145