Difference between revisions of "BeagleBoard/GSoC/2023 Proposal/AyushSingh"

From eLinux.org
Jump to: navigation, search
(Description)
(Greybus Driver)
Line 61: Line 61:
  
 
====Greybus Driver====
 
====Greybus Driver====
Currently, the upstream Greybus driver uses netlink (which is added using a [https://git.beagleboard.org/beagleconnect/freedom/-/blob/master/sw/linux/0006-greybus-add-gb_netlink-patch.patch patch]). However, netlink will not be needed since GBridge is being removed. Instead, a platform driver will be used to directly communicate with cc1352.  
+
Currently, the upstream Greybus driver uses netlink (which is added using a [https://git.beagleboard.org/beagleconnect/freedom/-/blob/master/sw/linux/0006-greybus-add-gb_netlink-patch.patch patch]). However, netlink will not be needed since GBridge is being removed. Instead, a platform driver will be used to communicate directly with cc1352.  
  
The actual types that are used in communication can be found at [`include/linux/greybus/greybus_protocols.h`](https://github.com/torvalds/linux/blob/master/include/linux/greybus/greybus_protocols.h) in upstream linux kernel. While, there are many request and response types, all of them have a header with the following signature:
+
The actual types that are used in communication can be found at [https://github.com/torvalds/linux/blob/master/include/linux/greybus/greybus_protocols.h '''include/linux/greybus/greybus_protocols.h`'''] in upstream Linux kernel. While there are many request and response types, all of them have a header with the following signature:
  
 
<pre>
 
<pre>
Line 75: Line 75:
 
</pre>
 
</pre>
  
Depnding on the choice of the driver, the data might need to be formatted in some specific way.
+
Depending on the driver's choice, the data might need to be formatted in some specific way.
  
 
====Platform Driver====
 
====Platform Driver====

Revision as of 10:16, 23 March 2023


BeagleBoard/GSoC/2023 Proposal/AyushSingh

About Student: Ayush Singh
Mentors: Jason Kridner, Vaishnav
Wiki: BeagleConnect
GSoC: TBD

Status

This project is currently just a proposal.

Proposal

  • Completed All the requirements listed on the ideas page.
  • The PR request for cross-compilation task: #170

About you

IRC: @ayush1325:matrix.org
Github: Ayush1325
School: Indian Institute of Technology (ISM), Dhanbad
Country: India
Primary language: English, Hindi
Typical work hours: 12PM - 01AM Indian Standard Time
Previous GSoC participation: I have previously participated in GSoC 2022 for Tianocore Organization. I have been quite interested in working on the Linux Kernel, the biggest Open-Source project in the world, for a long time. While I have worked on low-level stuff like UEFI, I still haven’t contributed to upstream Linux. Initially, the barrier of entry was simply too high for me. After completing the GSoC 2022 project, I was more confident about working on upstream Linux. However, I couldn’t find strong enough motivation to drop my other open-source projects to work on Linux Kernel. With this project, I hope to change this and start contributing to upstream Linux. I am also quite interested in BeagleConnect and its implications in the Internet of Things applications. Thus I would like to help improve it.

About your project

Project name: Replace GBridge<be>

Description

Overview

The goal of the project is to eliminate the need for GBridge completely and simplify the architecture of BeagleConnect. The current architecture is as follows:

Greybus <--Netlink--> GBridge <--wpanusb--> cc1532 <--6lowpan--> BeagleConnect

The new architecture will look as follows:

Greybus <--Platform Driver--> cc1532 <--6lowpan--> BeagleConnect

The subtasks I have identified are the following:

  1. Allow the Greybus Linux driver to directly communicate with cc1352
  2. Move SVC and APBridge roles into cc1352
  3. Eliminate the need for GBridge

GBridge Overview

To eliminate GBridge, we must first understand it's different parts. Thus I will discuss each part here in brief.

SVC

It is in charge of module hot plug / hot unplug detection, create / destroy connections, etc.

Netlink

GBridge is using netlink to communicate with Greybus.

Controller

The controller is actually the link between the SVC, netlink and all the modules. There are 4 main controllers present in GBridge currently:

  1. Bluetooth Controller: It scans continuously to detect new bluetooth module. When a Bluetooth module with the "GREYBUS" string in its name show up, the controller will generate an hotplug event and create a connection.
  2. TCP/IP: It use avahi to detect a new module.
  3. GBSHIM: It provides a way to test quickly and easily Greybus, Greybus netlink and gbridge.
  4. UART: This does not seem to be in the README, but is being registered if a `p` option is supplied.

Greybus Driver

Currently, the upstream Greybus driver uses netlink (which is added using a patch). However, netlink will not be needed since GBridge is being removed. Instead, a platform driver will be used to communicate directly with cc1352.

The actual types that are used in communication can be found at include/linux/greybus/greybus_protocols.h` in upstream Linux kernel. While there are many request and response types, all of them have a header with the following signature:

struct gb_operation_msg_hdr {
	__le16	size;		/* Size in bytes of header + payload */
	__le16	operation_id;	/* Operation unique id */
	__u8	type;		/* E.g GB_I2C_TYPE_* or GB_GPIO_TYPE_* */
	__u8	result;		/* Result of request (in responses only) */
	__u8	pad[2];		/* must be zero (ignore when read) */
};

Depending on the driver's choice, the data might need to be formatted in some specific way.

Platform Driver

This new driver will be responsible for communication between Greybus and cc1352. Since this will be a Platform Driver, it will follow the standard convention:

struct platform_driver {
      int (*probe)(struct platform_device *);
      int (*remove)(struct platform_device *);
      void (*shutdown)(struct platform_device *);
      int (*suspend)(struct platform_device *, pm_message_t state);
      int (*suspend_late)(struct platform_device *, pm_message_t state);
      int (*resume_early)(struct platform_device *);
      int (*resume)(struct platform_device *);
      struct device_driver driver;
};

cc1352 Firmware

Most of the heavy lifting will be done by the cc1352 firmware. It now needs to take care of both the SVC and APBridge roles.

SVC Role

The cc1352 firmware will need to detect the hotplug and removal of modules.

APBridge Role

This role involves converting UART to something like TCP/IP, which can be implemented in cc1352. I will try to make the parts as modular as possible (to add more transport protocols in the future), but I will be sticking to TCP/IP for now.

Timeline

TODO

Experience and approach

I have a very good knowledge of Rust programming language in firmware development. I work a lot on `no_std` environments, i.e. environments where Rust standard library is not available due to some reason. I also have experience with Rust FFI for things like UEFI specification. I have some experience with C and C++ as well. Some of my previous projects include

  1. Rust UEFI std: PR for implementation of Rust std for UEFI. This project was initially done as a part of the Google Summer of Code 2022. However, at this point it has evolved into its own thing and I am still actively working on it.
  2. r-efi: UEFI Reference Specification Protocol Constants and Definitions in Rust. I am just one of the frequent contributors. This project requires deep knowledge of Rust FFI.
  3. kconfig-rs: Rust bindings for KConfig KDE Framework. This project was done as a part of the Season of KDE 2022.
  4. Qmetaobject: I am one of the collaborators in this project. It allows the creation of Qt applications in Rust.

I also regularly contribute to other open-source projects I am using at the time.

Contingency

If I get stuck on my project and my mentor isn’t around, I will use the following resources:

Benefit

The completed project would allow using BeagleConnect without requiring an intermediary (GBridge). Also, due to the presence of GBridge, the upstream Greybus drivers need to be patched for netlink support, which will be eliminated by this project. Thus, it will eventually be possible to just use mainline Linux kernel for BeagleConnect. This should help increase the adoption of BeagleConnect as an industry standard.