BeagleBoard/GSoC/2022 Proposal/PRU-based USB stack

From eLinux.org
Jump to: navigation, search


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 TDA4VM 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
    • Consists of a Setup Transaction. Device must return ACK for every Setup Transaction received without a error
  • Data Stage
    • IN or OUT transaction
  • Status Stage
    • The status stage completes the transfers.

Error Handling

  • Timeout conditions after a host-transmitted token or packet. These errors occur when the addressed endpoint is unresponsive or when the structure of the transmission is so badly damaged that the targeted endpoint does not recognize it.
  • Data errors resulting in missing or invalid transmissions:
    • The Host Controller is unable to completely send or receive a packet for host specific reasons, for example, a transmission extending beyond EOF or a lack of resources available to the Host Controller.
    • An invalid CRC field on a received data packet.
  • Protocol errors:
    • An invalid handshake PID, such as a malformed or inappropriate handshake
    • A false EOP
    • A bit stuffing error

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


Date Status Details
Pre-submission
  • Understand USB Host function
  • Read about TDA4VM Documents
  • 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 19th Milestone #1

Setup Phase #1

  • Introductory Video
  • Setup the Board
June 20th - June 26th Milestone #2

Setup Phase #2

  • Initialize PRU and Play around with it.
  • Read TDA4VM Datasheet about PRU and USB detail
June 27th - July 3th Milestone #3

USB Host Controller (Enumeration)

  • Handling USB Enumeration
  • Events and Requests
July 4th - July 24th No Code

Final Exam

July 25th - July 31th Milestone #4

USB Host Controller (Enumeration)

  • Configured State
  • Descriptors
Aug 1th - Aug 7th Milestone #5

USB Host Controller

  • Control Transfer
  • Setup Stage
  • Data Stage
Aug 8th - Aug 14th Milestone #6

USB Host Controller

  • Status Stage
  • Handling Error
Aug 15th - Aug 21th Milestone #7

USB Host Core (Standard Requests)

  • Get Status
  • Clear Feature
  • Set Feature
  • Set Address
  • Get Descriptor
  • Set Descriptor
Aug 22th - Aug 28th Milestone #8

USB Host Core (Standard Requests)

  • Get Configuration
  • Set Configuration
  • Get Interface
  • Set Interface
  • Synch Frame
  • Set SEL
  • Set Isochronous Delay
Aug 29th - Sept 04th Milestone #9

USB Class Driver

  • MIDI
Sept 05th - Sept 11th Milestone #10

USB Class Driver

  • HID
Sept 12th - Sept 19th Milestone #11

Finalize

  • Interaction with Application Layer
  • Testing and Debug
Sept 12th - Sept 19th Milestone #12

Finalize

  • Write Document
  • Make Video
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