Difference between revisions of "BeagleBoard/GSoC/2021 Proposal/usb configfs in device tree"

From eLinux.org
Jump to: navigation, search
(Created page with "= Proposal for Device Tree Improvement = * Student: [https://elinux.org/User:Satacker Shreyas Atre] * Mentors: Not Assigned * Code: [N/A] * Proposal : https://elinux.org/inde...")
 
 
(5 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
* Student: [https://elinux.org/User:Satacker Shreyas Atre]
 
* Student: [https://elinux.org/User:Satacker Shreyas Atre]
* Mentors: Not Assigned
+
* Mentors: Deepak Khatri (IRC: lorforlinux)
 
* Code: [N/A]
 
* Code: [N/A]
* Proposal : https://elinux.org/index.php?title=BeagleBoard/GSoC/2021_Proposal/device_tree_improvement
+
* Proposal : https://elinux.org/index.php?title=BeagleBoard/GSoC/2021_Proposal/usb_configfs_in_device_tree
 
* Wiki: [N/A]
 
* Wiki: [N/A]
 
* GSoC: [N/A]
 
* GSoC: [N/A]
Line 12: Line 12:
  
 
= Proposal =
 
= Proposal =
 +
* Completed all the general requirements
 
* Completed "Hello Wolrd" of cross compilation mentioned in the requirements list.
 
* Completed "Hello Wolrd" of cross compilation mentioned in the requirements list.
 
* Sent a PR to the mentioned upstream [https://github.com/jadonk/gsoc-application/pull/145 #145]
 
* Sent a PR to the mentioned upstream [https://github.com/jadonk/gsoc-application/pull/145 #145]
Line 24: Line 25:
 
* Typical work hours : 10AM - 7PM Indian Standard Time
 
* Typical work hours : 10AM - 7PM Indian Standard Time
 
* Experience :  
 
* Experience :  
* [https://github.com/SAtacker/kernel_learn kernel learn] is a repo I had created for kernel learning purpose in which I had learned several Kernel development Basics .
+
* [https://github.com/SAtacker/pid-tuning-gui/tree/satacker/cpp_port 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.
* [https://github.com/SAtacker/pid-tuning-gui/tree/satacker/cpp_port Qt Embedded] is my Qt application for sending data to esp32 uC using Boost.ASIO for Netowrking stack
+
* [https://github.com/SAtacker/kernel_learn 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 [http://exploringbeaglebone.com/ Exploring Linux with Beaglebone by  Derek Molloy] while in [https://www.sravjti.in/ Society of Robotics and Automation] as a core team member. This is the first time i am participating in GSoC
+
* I have realised the beauty of embedded systems after working on esp32 dev board and reading [http://exploringbeaglebone.com/ Exploring Linux with Beaglebone by  Derek Molloy] while in [https://www.sravjti.in/ Society of Robotics and Automation] as a core team member.  
 +
* This is the first time i am participating in GSoC
  
 
= About Your Project =
 
= About Your Project =
Line 34: Line 36:
 
== Description ==
 
== 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 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 [https://github.com/RobertCNelson/boot-scripts/blob/master/boot/bbai_usb_gadget.sh commands]. This is definitely not acceptable for those who used legacy gadgets and write only modprobe g_ether.
+
* 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 [https://github.com/RobertCNelson/boot-scripts/blob/master/boot/bbai_usb_gadget.sh commands].  
 
* Also scripts can be edited and are obviously less secure.
 
* Also scripts can be edited and are obviously less secure.
* Secondly it's really hard to modify such a script because many calls has 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 beginner.
+
* 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 our solution of [https://github.com/libusbgx/libusbgx libusbgx] which is a more recent version of libusbg which is no longer maintained.
+
* This leads us to another solution : [https://github.com/libusbgx/libusbgx libusbgx] which is a userspace library to configure USB gadgets
* It provides Light weight configuration files which describes composition of functions into gadget. They can be simply loaded using usbg_import_*() and exported using usbg_export_*(). This makes them easy to use equivalent of modprobe gadget_module.
+
* 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 by providing configfs and using libusbgx gadget schemes
+
* Goal: USB configfs in device tree such that they can be configured statically in device tree ahead of boot and speed the boot process.
* An example from libusbgx docs [https://github.com/libusbg/libusbg/blob/master/examples/gadget-acm-ecm.c acm-ecm device]
 
  
 
== Implementation Details ==
 
== Implementation Details ==
 +
A device tree is a tree data structure with nodes that describe the physical devices in a system. From [https://elinux.org/Device_Tree_Usage wiki] we can see the basic usage guide of device tree.
 +
We can look at the bindings [https://github.com/beagleboard/linux/tree/4.14/Documentation/devicetree/bindings/usb here].
  
* Configure uboot with static Device trees instead of compiling it every time.
+
                USB:&USB {
* To compile configfs as a module with support for USB gadget creation
+
                                compatible = "chip,subset";
* Provide libusbgx gadget schemes or configuration files
+
                                reg = <USB_hub_port_HEX>;
* Add udev rules for modules
+
                                reset-gpios = <&gpio1 NUM GPIO_ACTIVE_LOW>;
* Implement tests for module configuration
+
                                vendor-id = /bits/ 16 <0x0000>;
* Benchmark performance difference
+
                                product-id = /bits/ 16 <0x0000>;
* Add support for gadget tools
+
                                string-support;
 +
                                manufacturer = "Foo";
 +
                                product = "Foo-Bar";
 +
                                serial = "1234567890A";
 +
                                configs: configs{
 +
                                      configuration = "BeagleBone Composite";
 +
                                      max_power = 500;
 +
                                }
 +
                              functions:functions{
 +
                                      class=<EF>;
 +
                                      sub-class = <04>;
 +
                                      protocol = <01>;
 +
                                }
 +
                                interface:interface{
 +
 
 +
                                }
 +
                                symlink = "functions/acm.usb0";
 +
                            };
  
 
== Timeline ==
 
== Timeline ==
Line 72: Line 92:
 
| 21/06/2021 || Milestone #2 ||  
 
| 21/06/2021 || Milestone #2 ||  
 
* Build and Test A prototype of Device Tree
 
* Build and Test A prototype of Device Tree
* Configure kernel for configfs module
+
* This will allow me to get more info on the process of setting up the device trees for future reference.
* Build and test the kernel with minimal configfs implementation
 
 
|-
 
|-
 
| 28/06/2021 || Milestone #3 ||  
 
| 28/06/2021 || Milestone #3 ||  
* Integrate libusbgx for providing configuration files
+
* Implement a generic usb node in device tree
* Configure USB Nodes in /config/devicetree using libusbgx
+
* Create child nodes with configurations
* Test libusbgx and implement unit tests for functions
+
* Test the configurations thoroughly
 
|-
 
|-
 
| 05/07/2021 - 10/07/2021 || Milestone #4 ||  
 
| 05/07/2021 - 10/07/2021 || Milestone #4 ||  
Line 86: Line 105:
 
|-
 
|-
 
| 17/07/2021 || Milestone #5 ||  
 
| 17/07/2021 || Milestone #5 ||  
* Verify the usb functions  
+
* Add USB functions and test for Abstract Control Model or ACM
* Rewrite with the changes required and verify with mentor
+
* Verify the USB functionality
 
|-
 
|-
 
| 24/07/2021 || Milestone #6 ||   
 
| 24/07/2021 || Milestone #6 ||   
* Integrate with libusbg gadget schemes
 
 
* Build and test functionality on all Beagle Devices  
 
* Build and test functionality on all Beagle Devices  
* Implement examples for cdc-acm-ecm
+
* Implement examples for USB configurations
 
|-
 
|-
 
| 31/07/2021 - 03/07/2021|| Milestone #7 ||  
 
| 31/07/2021 - 03/07/2021|| Milestone #7 ||  
Line 101: Line 119:
 
| 10/08/2021 || Milestone #8 ||  
 
| 10/08/2021 || Milestone #8 ||  
 
* Compile with other latest kernels  
 
* Compile with other latest kernels  
* Test the kernel modules and Verify the functionality  
+
* Test the kernel modules for mass storage and Verify the functionality  
* Implement unit tests for the same
 
 
|-
 
|-
 
| 17/08/2021 || Milestone #9 ||  
 
| 17/08/2021 || Milestone #9 ||  
* Add additional configurations for overlays
 
 
* Document If anything remaining
 
* Document If anything remaining
 
* If finished early solve the kernel bugs
 
* If finished early solve the kernel bugs
Line 116: Line 132:
 
|}
 
|}
  
== Benefit ==
+
===Experience and approach===
=== Quotes ===
+
* Previously I have worked with Qt and Boost.ASIO . [https://github.com/SAtacker/pid-tuning-gui/tree/satacker/cpp_port 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.
 +
* [https://github.com/SAtacker/kernel_learn 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.
 +
==== Quotes ====
 +
 
 +
==Misc==
 +
* For hello_world of cross-compilation , sent a PR to the mentioned upstream [https://github.com/jadonk/gsoc-application/pull/145 #145]

Latest revision as of 11:30, 6 April 2021

Proposal for Device Tree Improvement

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

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 = <USB_hub_port_HEX>;
                               reset-gpios = <&gpio1 NUM GPIO_ACTIVE_LOW>;
                               vendor-id = /bits/ 16 <0x0000>;
                               product-id = /bits/ 16 <0x0000>;
                               string-support;
                               manufacturer = "Foo";
                               product = "Foo-Bar";
                               serial = "1234567890A";
                               configs: configs{
                                      configuration = "BeagleBone Composite";
                                      max_power = 500;
                               }
                              functions:functions{
                                      class=<EF>;
                                      sub-class = <04>;
                                      protocol = <01>;
                               }
                               interface:interface{
                               }
                               symlink = "functions/acm.usb0";
                           };

Timeline

Date Status Details
13/04/2021 to 17/05/2021 Application Review Period Right After submitting the application I will go through rigorous set of reference materials udemy course which has practical implementation with device tree. Resource 1 Resource 2 Resource 3 Resource 4
17/05/2021 to 07/06/2021 Community Bonding
  • Complete College exams , vivas, practicals and stuff
  • Make sure that stuff for project is available
  • Coding Begins
14/06/2021 Milestone #1
  • Introductory Video
  • Build and test the already present device tree files
  • Update as per mentioned kernel version and bindings as necessary
21/06/2021 Milestone #2
  • Build and Test A prototype of Device Tree
  • This will allow me to get more info on the process of setting up the device trees for future reference.
28/06/2021 Milestone #3
  • Implement a generic usb node in device tree
  • Create child nodes with configurations
  • Test the configurations thoroughly
05/07/2021 - 10/07/2021 Milestone #4
  • Eliminate the boot scripts for usb-gadget configuration
  • Review the configurations for errors
  • Documentation for everything till now
17/07/2021 Milestone #5
  • Add USB functions and test for Abstract Control Model or ACM
  • Verify the USB functionality
24/07/2021 Milestone #6
  • Build and test functionality on all Beagle Devices
  • Implement examples for USB configurations
31/07/2021 - 03/07/2021 Milestone #7
  • Documentation of everything till now
  • Brief overview and discussion with mentor
  • Bring in required changes
10/08/2021 Milestone #8
  • Compile with other latest kernels
  • Test the kernel modules for mass storage and Verify the functionality
17/08/2021 Milestone #9
  • Document If anything remaining
  • If finished early solve the kernel bugs
24/08/2021 Milestone #10
  • Students submit final work product and final mentor evaluation
  • Completion of youtube video
31/08/2021 Milestone #11 Completion of GSoC

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.

Quotes

Misc

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