BeagleBoard/GSoC/2020 Projects/PRU Improvements

=Proposal for Implement a REPL interpreter for PRU =

Student: Vedant Paranjape Mentors: Kumar Abhishek, Pratim Ugale, Andrew Henderson Code: [N/A] Wiki: https://elinux.org/BeagleBoard/GSoC/2020Proposal/VedantParanjape2 GSoC: [N/A]

=Status= This project is selected for GSoC 2020

=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 #138.

About you
IRC: vedant16 Github: https://github.com/vedantparanjape/ School: Veermata Jijabai Technological Institute (VJTI) Country: India Primary language : English, Hindi, Marathi Typical work hours : 10AM - 7PM Indian Standard Time Previous GSoC participation: I find embedded pretty interesting, given I have experience with ESP32, I think I will be able to excel in this project. This is the first time i am participating in GSoC

About your project
Project name: Implement a REPL interpreter for PRU

Description

 * The PRU is a dual core micro-controller system present on the AM335x SoC which powers the BeagleBone. It is meant to be used for high speed jitter free IO control. Being independent from the linux scheduler and having direct access to the IO pins of the BeagleBone Bhilack, the PRU is ideal for offloading IO intensive tasks.


 * Programming the PRU is a uphill task for a beginner, since it involves several steps, writing the firmware for the PRU, writing a loader program. This can be a easy task for a experienced developer, but it keeps many creative developers away. So, I propose to implement a REPL based control of the PRU, hiding all the low level things behind the REPL and providing a clean interface to uses PRU.


 * This can be achieved by implementing a language on top of the PRU Assembly. It will directly compile down to PRU assembly. This could also be solved by implementing a bytecode engine on the PRU, but this will result in waste of already limited resources on PRU. With this approach, both PRU cores can be run independent of each other.

Deliverables:
 * 1) Implement a language for PRU which compiles down to PRU Assembly.
 * 2) Solve issues on am335x_pru_package github.
 * 3) Update PRUSpeak to work with the latest kernel.

Implementation Details

 * Implement a language for PRU which compiles down to PRU Assembly.


 * Language Name: SimpPRU
 * Statically typed language
 * TAB or 4 spaces for indentation


 * Primitive data types:
 * `int`
 * `bool`

operator precedence, as arranged
 * Arithmetic operators
 * `/` divide
 * `*` multiply
 * `+` plus
 * `-` minus
 * Relational operators
 * `>` greater than
 * `>=` greater than or equal to
 * `<` less than
 * `<=` less than or equal to
 * `=` equal to
 * `!=` not equal to
 * Bitwise operators
 * `&` unary and
 * `|` unary or
 * `~` unary not
 * logical operators
 * `and` logical and
 * `or` logical or
 * `not` logical not


 * Arithmetic operations
 * `int` and `float` can be operated together, `int` will be promoted to float
 * `bool` cannot be operated with anything other than `bool`
 * `bool` only supports unary operators
 * Variable assignment
 * ` := `
 * int value := 34


 * if elif else loop

if : elif : else:


 * for loop

for, , :

( variable name, ...):
 * functions

int add(int a, int b): return a + b
 * Each functions must always return something, since void data type is not included

bool read_register(register_name, bit_to_be_read) bool write_register(register_name, bit_to_be_written, bool value_to_be_written)
 * Register Access
 * Implementing utility functions like GPO/GPI control, delay, setting Pin out and automatically setting pinmux.
 * Packaging the compiler with system images
 * Solve issues on am335x_pru_package github
 * 1) Solve issue #44, #41, #49

Experience and approach
I have decent experience in C++, C and Python. I have done several projects involving embedded systems like ESP32, I well-versed with freeRTOS. I recently did a project on ESP32, in which I used ESP to control and plot PID loop running on the embedded device, plotting the values on a python GUI. Other than that I have developed firmware for a 3 DOF arm based on a ESP32 custom board. I did a internship with a embedded deviced startup, where I built:
 * 1) Built TCP network stack for embedded IoT Devices
 * 2) Implemented Synchronous TCP server using Boost.Asio(C++) and Boost.Thread(C++)
 * 3) Implemented a tool to calculate round trip time(RTT) of tcp packets

I actively contribute to open source and do a lot of mini projects throughout the year, you can find my several more interesting projects at my github page

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) https://git.ti.com/pru-software-support-package
 * 2) https://processors.wiki.ti.com/index.php/PRU_Training:_Hands-on_Labs PRU Guide
 * 3) https://markayoder.github.io/PRUCookbook/ Mark Yoder's cookbook is a excellent guide
 * 4) Derek Molly's beagle bone guide provides all the information needed for getting up and running with my beagle.
 * 5) The technical reference manuals provided by TI on am3358 and am5729 are the best source
 * 6) Processor SDK Linux Software Guide is a good reference material

Benefit

 * Currently interfacing with the PRU requires a lot of makefile manipulation, kernel drivers and stuff. There's no working around that for more advanced applications but if you can get something simple up and running quickly with a REPL, that'd be great.
 * -Abhishek Kumar