BeagleBoard/GSoC/2023 Proposal/BeagleBone Cape add-on board compatibility layer

=Cape Compatibility layer for BeagleBone Black, AI, AI-64, PocketBeagle and BeaglePlay =

Student: | LIM SOON WEI Mentors: Deepak Khatri (lorforlinux) Proposal: https://elinux.org/BeagleBoard/GSoC/2023_Proposal/BeagleBone_Cape_add-on_board_compatibility_layer

=Status= This project is currently just a proposal.

=Proposal= Completed all the requirements listed on the ideas page. the code for the cross-compilation task can be found here submitted through the pull request #178.

About you
Github: limsoonweiutm School: University of Technology Malaysia Country: Malaysia Primary language: English, Chinese Typical work hours: 7PM - 11PM(Weekdays) & 9AM - 6PM(Weekends) Malaysia Standard Time UTC +8 Previous GSoC participation: This is my first time attending GSoC. Reason for participation: I am very interested in the learning new things in using Linux OS and device tree is new to me which will be fun learning how to construct device tree and add to the board to supports the cape and clickboards. Therefore, I would like to be involved in updating the cape compatibility layer for BeaglePocket Cape, which are Tech Lape Cape and GamePup Cape. In addition, for the clickboards compatibility parts will be updated on BeaglePlay with Interface category such as PWM, CAN, I2C, etc.

About your project
Project name: Cape Compatibility layer for BeagleBone Black, AI, AI-64, PocketBeagle and BeaglePlay

Description
This project include enabling the overlay compatibility and support for the board BeagleBone Black, AI, AI-64 under kernel v5.10 and implement device tree overlays for PocketBeagle's capes which are Tech Lape Cape and GamePup Cape while for BeaglePlay, the clickboards compatibility parts will be updated with Interface category such as PWM, CAN, I2C, etc and other Categories such as Wireless Connectivity, Sensors, etc.

Enabling overlay compatibility:
BeagleBone boards utilize U-Boot as their Tertiary Program Loader (TPL) to load the Linux kernel, Flattened Device Tree (FDT), and Initial Ram File System (initramfs) into DRAM. U-Boot is responsible for managing boot time MUX_MODE for the GPIOs, symlinks for peripherals, and other hardware-specific configurations by loading particular FDT. By updating the FDT for the hardware we want to support, we can regulate the configuration(s). Boot-time device tree overlays can enable device compatibility, such as Cape compatibility, which can be found in most capes from the bb.org-overlays repository. Achieving cape compatibility will require creating device tree overlays and loading them at boot time. To load the necessary driver for the hardware at boot time, the uEnv.txt file must be edited. Required overlays can be exported at boot time, and the hardware will be compatible immediately upon board boot. Most capes utilize EEPROM to store CAPE-related hardware information, and individual pin configuration details can be extracted from the EEPROM, making it simpler to manage.

Previous Work
Deepak Khatri has developed a method to enable P8 and P9 connectors on the BeagleBone AI (am572x) with the same pin assignments as the BeagleBone Black (am335x). This involves three steps: creating a symlink in the device tree of the AI that corresponds to other BeagleBones, using this symlink in udev rules to create the symbolic link, and configuring the pinmux to adjust the behavior of peripherals depending on the application. A universal device tree overlay is utilized to select the appropriate peripheral from multiple choices in the pinmux, and the user can choose the desired peripheral for each Cape by changing the device tree overlay used.

Problems and Solutions
The current implementation is facing some problems as mentioned below, but this proposal aims to resolve these issues.

Symbolic links in Black and AI under kernel v5.10.

 * GPIO (for gpio-leds and gpio-keys)
 * PWM
 * SPI
 * CAN

Device Tree and Device Tree Overlay
A device tree overlay is a configuration file that describes additional hardware devices and their respective configurations to be added to the base device tree during runtime. For BeagleBone boards such as the BeagleBone Black, BeagleBone AI, BeagleBone AI-64, PocketBeagle, and BeaglePlay, device tree overlays are commonly used to add support for new hardware components and interfaces that are not included in the default device tree.

To create a device tree overlay for a BeagleBone board, we first need to define the hardware device or interface we want to add. This can include, for example, an I2C device, a PWM output, or a custom cape with specific pin configurations.

Once we have defined the hardware device or interface, we can create the device tree overlay file in the following format:

/dts-v1/; /plugin/; / {   compatible = "ti,beaglebone", "ti,beaglebone-black"; fragment@0 { target = <&am33xx_pinmux>; __overlay__ { /* Define pin configuration for new device */ };   };    fragment@1 { target = <&ocp>; __overlay__ { /* Define device configuration and properties */ };   }; };

In this example, the device tree overlay defines two fragments that modify the base device tree for the BeagleBone board. The first fragment targets the am33xx_pinmux node, which controls the pinmuxing and configuration of the pins on the board. Here, we can define the pin configuration for the new hardware device or interface we want to add.

The second fragment targets the ocp node, which represents the onboard parallel port, and can be used to add new devices to the board. Here, we can define the configuration and properties for the new device or interface we want to add.

Once we have defined the device tree overlay, we can compile and load it into the kernel at runtime using the dtc and dtoverlay commands. This will add the new hardware device or interface to the base device tree, and it will be available for use immediately.

Overall, device tree overlays are a powerful tool for extending the functionality of BeagleBone boards, and can be used to add support for a wide range of new hardware devices and interfaces.

Hardware Required:

 * 1) BeagleBone Black
 * 2) BeagleBone AI-64
 * 3) BeaglePlay
 * 4) clickboards
 * 5) mikroBus cape
 * 6) WiFi Click
 * 7) CAN
 * 8) SPI
 * 9) ADC-DAC
 * 10) OLED
 * 11) SpeakUp Click
 * 12) PocketBeagle
 * 13) PocketBeagle TechLab Cape
 * 14) PocketBeagle GamePup Cape

Experience and approach
I have strong understanding and high grade on my C, C++ and python programming language. Finished my internship with Intel during second year(Extra) and third year(official) of my study. Currently, I also take Intel DV engineer job as my part time in order to learn more and sharpening my skill alongside to compete the position in Singapore in the future. As a Design Verification(DV) engineer I did a lot of scripting especially to automate the test processes using Python Scripting and Linux OS/Env has been very familiar to me. In addition, C++ is my future career path skill where I picked up since second year of my study, mostly mastered in OOP so I could venture into Embedded Software Programming Engineer Fresh Graduate position in Singapore. Going through a lot of mock interviews and problem questions by solving them using C++. Lastly, I also received award from my school of Electrical Engineering for being the best of track in Electrical Educational Theme where our team uses C to program Arduino and lead to the best of track.

Contingency
I believe that if I get stuck on my project and my mentor isn’t around, I will use the resources that are available to me. Some of those information portals are listed below.


 * 1) Derek Molly's beagle bone guide provides all the information needed for getting up and running with my beagle.
 * 2) Content on e-ALE.org is very useful for information that ranges from tutorials and walkthroughs to the level of very advanced stuff.
 * 3) BeagleBone cookbook from Mark A. Yoder & Jason Kridner is the best source for test projects during the prototyping period.
 * 4) The technical reference manuals provided by TI on am3358 and am5729 are the best source for getting the insights on the SoC used in Black and Ai.
 * 5) Deepak Khatri (lorforlinux) source code on 2020 Beaglebone Cape Compatibility
 * 6) Utilize technology nowadays such as ChatGPT

Benefit
I believe that the project is very important as:
 * 1) the adoption of the device tree
 * 2) support for BeagleBone Black, BeagleBone AI under kernel-64
 * 3) execution of same user space examples
 * 4) support for PocketBeagle Capes
 * 5) support for BeaglePlay clickboards