Difference between revisions of "BeagleBoard/GSoC/2022 Proposal/PRU-based USB stack"

From eLinux.org
Jump to: navigation, search
(Benefit)
(Benefit)
Line 220: Line 220:
 
==Benefit==
 
==Benefit==
 
     "Also, the pay-off for doing this for Bela users is the ability to have low-latency audio rendering."
 
     "Also, the pay-off for doing this for Bela users is the ability to have low-latency audio rendering."
~ Jkinder
+
~ jkridner
  
 
==Misc==
 
==Misc==

Revision as of 18:22, 17 April 2022


Proposal Template

About Student: Seak Jian De
Mentors: Jason Kridner, giuliomoro
Code: [N/A]
Wiki: https://elinux.org/index.php?title=BeagleBoard/GSoC/2022_Proposal/PRU-based_USB_stack
GSoC: PRU-based USB stack

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 #158.

About you

IRC: Jian De
Github: https://github.com/Fred-JD
School: Universiti Teknologi Malaysia
Course: 3rd Year Electronics Engineering
Country: Malaysia
Language: English, Mandarin, Malay
Typical work hours: 4PM - 11PM UTC +8
Previous GSoC participation: First year apply gsoc.

About your project

Project Name

PRU-based USB stack

Description

Why develop PRU-Based USB stack?
As we know, Linux wasn’t designed as a real-time operating system that can guarantee a rate of data transfer with a peripheral. With multi-tasking, multiple programs run at the same time, and the OS grants a portion of the valuable time to each thread. Different threads can have different priorities. RPU is a solution of this which BeagleBoard device can be beneficial of minimize the latency for USB peripherals.

Features

  • Implement USB Host Controller for PRU
  • Implement USB Host Core for PRU
  • Support USB class driver for (MIDI, HID, AUDIO)
  • Providing detailed Documentation for USB Host API

Introduction

USB Concept

Transfer Types[1]

  • Control Transfers
  • Bulk Transfers
  • Interrupt Transfers
  • Isochronous Transfers

USB Protocol[2]
Descriptors

Each device contains Descriptors which contain information about the device.

Interfaces

USB devices publish their endpoints as part of an Interface.

Endpoints

USB pipes are opened to Endpoints. Devices publish Endpoint descriptors to enable clients to query what endpoint are available and what characteristics they have. Endpoint descriptors contain information about the I/O direction (IN which is from the device to the host or OUT which is from the host to the device), the transfer type (Control, Bulk, Interrupt, or Isochronous) and the maximum supported packet size.

Pipes

Communication between the host and a USB device is performed through Pipes.

Method of Implementation

PRU Access USB Peripheral

PRU Memory Access In order to read/write to an memory address external to the PRU subsystem, the OCP master port need to be enabled in the PRU‐ICSS CFG register space, SYSCFG[STANDBY_INIT].


USB Host Controller

The USB Host Controller Driver is the layer between the USB Host Controller Hardware and the USB Host Core. This layer handles hardware specific interfaces.

Enumeration

The host enumerate the device by issuing control transfers containing standard USB requests to the device. All USB devices must support control transfers, standard requests, and endpoint zero.

Descriptors

USB descriptors are the data structures that enable the host to learn about a device. Each descriptor contains information about the device as a whole or an element of the device.

Types of descriptor:-

  • Device Descriptors
  • Configuration Descriptors
  • Interface Descriptors
  • Endpoint Descriptors
  • String Descriptors

USB Host Core

The USB Host Core is a hardware independent layer and contains the functions to manage USB peripherals and the USB bus. This layer is an interface between the USB Host Controller Driver and the USB Host Class Driver.

Elements of a Control Transfer

  • Setup Stage
  • Data Stage
  • Status Stage

Error Handling

Standard Requests

  • Get Status
  • Clear Feature
  • Set Feature
  • Set Address
  • Get Descriptor
  • Set Descriptor
  • Get Configuration
  • Set Configuration
  • Get Interface
  • Set Interface
  • Synch Frame
  • Set SEL
  • Set Isochronous Delay

USB Host Device Class

USB defines class code information that is used to identify a device’s functionality and to nominally load a device driver based on that functionality.

Base Class Descriptor Usage Description
01h Interface Audio
03h Interface HID

Audio (MIDI)

Device Class Definition for MIDI

HID

Device Class Definition for HID

Timeline

For this projects I dived into 6 milestone which each milestone took 2 week to complete. The milestone phase are setup, USB host Controller (Enumeration), USB host Controller (Transfer), USB host core, USB class driver and Finalize.

Date Status Details
Pre-submission
  • Understand USB Host function
  • Research how RTOS implement USB stack
  • Plan the code structure for USB stack
May 20th - June 12th Community Bonding
  • Required hardware will be available to me, and I will start test to read USB using PRU.
  • Start going through the PRU documentation.
  • Playing with PRU memory mapping
June 13th - June 26th Milestone #1

Setup Phase

  • Introductory Video
  • Setup the Board
  • Initialize PRU and Play around with it.
June 27th - July 10th Milestone #2

USB Host Controller (Enumeration)

  • Handling USB Enumeration
  • Events and Requests
  • Configured State
  • Descriptors
July 11th - July 25 No Code

Final Exam

June 26th - Aug 7th Milestone #3

USB Host Controller

  • Control Transfer
  • Setup Stage
  • Data Stage
  • Status Stage
  • Handling Error
Aug 8th - Aug 21th Milestone #4

USB Host Core (Standard Requests)

  • Get Status
  • Clear Feature
  • Set Feature
  • Set Address
  • Get Descriptor
  • Set Descriptor
  • Get Configuration
  • Set Configuration
  • Get Interface
  • Set Interface
  • Synch Frame
  • Set SEL
  • Set Isochronous Delay
Aug 22th - Sept 04th Milestone #5

USB Class Driver

  • MIDI
  • HID
Sept 05th - Sept 19th Milestone #6

Finalize

  • Interaction with Application Layer
  • Testing and Debug
  • Write Document
Nov 21 - 18:00 UTC Final date for all GSoC contributors to submit their final work product
  • Completion of GSoC

Experience and approach

In 5-15 sentences, convince us you will be able to successfully complete your project in the timeline you have described.

  • In my first year of University I have passed the 3 month junior training program by ROBOCON UTM which include basic programming, basic electronics and basic Mechanisms.
    • I have built a line following robot with dsPIC30f4011 microcontroller. Solder and design my own hardware with the PIC microcontroller. Understand about GPIO, PWM, UART, ADC/DAC. I have experience in C programming and know how circuit connection with breadboard. photo.
    • I have build a custom PCB to control robotic pneumatic valve with Altium designer. photo
  • I have build a flutter mobile app which read and display sensor value from Bluetooth module with Maker Uno (similar with Arduino Uno). Then store the value on AWS with MQTT protocol.\
  • I have build Footfall Counter with openCV github
  • In order to successfully to complete the projects, I will start it early which start to work with the technology before official code period so I have extra time for debug and testing.

Contingency

What will you do if you get stuck on your project and your mentor isn’t around?

Benefit

   "Also, the pay-off for doing this for Bela users is the ability to have low-latency audio rendering."

~ jkridner

Misc

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 #158.

Suggestions

Is there anything else we should have asked you?

Reference