< BeagleBoard‎ | GSoC
Revision as of 07:48, 26 March 2018 by Muneeb17 (talk | contribs) (Added DMA in description and detailed examples)
Jump to: navigation, search

Update to PyPRUSS

Student: Mohammed Muneeb
Mentors: Jason Kridner, Kumar Abhishek


PyPRUSS is a python binding/API for loading firmware and communicating with the PRUs easily. Currently, the project uses PASM which is no longer supported in latest versions and communicates over the older UIO interface.


I have completed the requirements listed on the ideas page and created a pull request here.

About me

IRC: muneeb17
School: Birla Institute of Technology and Science, Pilani
Country: India
Primary language: English
Typical work hours: 9:00 - 21:00 IST (GMT+5:30)
Previous GSoC participation: This is my first GSoC participation. I really like the open source ideology and have been using linux and open source hardware/software for some time. The power and impact of open source hardware/software became evident to me during the 'Arduino boom' and how it triggered the Maker Movement. I have always enjoyed doing DIY projects on community-supported platforms, so I feel that it's my turn now to contribute back to the community and GSoC is the ideal place to get started.

About the project

Project name: Update to PyPRUSS


The PyPRUSS is a python binding/API for controlling the PRUs. It provides an easy to use python-based interface for loading firmware, controlling execution and interrupts/memory management for the PRUs, therefore shortening the learning curve for users new to PRU programming. Currently, the PyPRUSS uses PASM for its examples and communicates using the older Userspace IO (UIO) Driver. The goal of this project is to update the API to use the remoteproc/rpsmg sysfs interfaces for interacting with the PRUs and port the existing examples to gnupru(since PASM is no longer supported by TI) to work on the latest images. I also plan to add DMA Support to the API, since it will enable the users to program both the PRUs for their application, instead of reserving one for ARM-PRU communication(as needed in case of rpmsg).


Essentially, the API will provide the following functions:

  • Remoteproc functions: Load Firmware into the PRU Cores, Control PRU Execution(start/stop) using the remoteproc sysfs interface accessible at /sys/class/remoteproc/remoteprocX
  • Memory Read/Write functions: Read/Write to the PRU Data RAM,PRU Shared RAM, and the external DDR memory using /dev/mem + mmap()
  • RPMsg functions: Sending/receiving messages using the rpmsg character device file found at /dev/rpmsg_pru{CHAN_PORT} which will be configured by the RPMsg framework once the channel is created. PRU->ARM interrupts can be implemented using the poll interface of the character device file.
  • PRU DMA functions: Alternatively, the PRU memory read/write functions and the ARM-PRU communication functions can be implemented using the EDMA controller on the SoC. The PRU DMA project from last year provides a Kernel level API to transfer data between ARM-PRU using the EDMA along with a few examples. Now, I plan on implementing a general purpose driver which will expose a sysfs interface, which can then be used by the Python API for communication/data transfer.
  • Miscellaneous functions: Pin configuration/DTO generation and Resource Table generation functions


1.BeagleScope and pru-software-support package examples: Writing scripts for these examples using the PyPRUSS API(Mainly for testing the remoteproc/rpsmg functions).

2.Moving the existing PASM examples to pru-as(the assembler in the gcc-pru toolchain) to use remoteproc: The gnupru is the unofficial gcc port for the PRUs. The community would like to eventually shift to gcc and this is a step in that direction. The examples include

  • blinkleds - loads a program which blinks the user leds 10 times and sends a notification to the host.
  • mem_write - writes to the PRU DRAM and Shared RAM
  • ddr_write - passes the target DDR address to PRU DRAM and then the PRU writes some data to the DDR.
  • speed_test - performs a speed test by toggling an led for some cycles and passing an interrupt.

3.PRU DMA Examples: Modifying the existing PRU DMA examples to use the API(For testing the dma functions). The examples include

  • led_pattern - the leds blink with a pattern sequence given by the user, transferred to the PRU through DMA.
  • sensor_data - transfers the sensor data from PRU memory to the DDR and outputs the data.
  • loopback_test - transfers the data from RAM to PRU memory and back, to test if DMA is working correctly.


Documentation is a very crucial part of the project since the project is mainly directed towards beginners. I would like to spend a significant amount of time on this. It'll include

  • Detailed explanation of the API functions.
  • Walkthrough of the examples.
  • A quick start guide to programming the PRUs in assembly with gcc-pru (as it is not well documented as of now)
  • Setup/build instructions for the project.


Week 1: May 14 - May 20

  • Go through the kernel documentation and the driver.
  • Go through the PyPRUSS codebase thoroughly, github forks, look up existing bugs/issues.

Week 2: May 21 - May 27

  • Implement basic PRU Control functions (power on/off, load firmware, reset, enable/disable).

Weeks 3-4: May 28 - June 10, End of Phase I

  • Implement Data Memory Read/Write functions.
  • Implement External Memory/DDR access functions.
  • Implement the Interrupts/Event Control functions.
  • Preliminary test the API with available examples.

By the Phase I evaluation, I would deliver a basic API tested with available remoteproc examples.

Week 5: June 11 - June 17, Start of Phase II

  • Port the existing PASM examples to clpru (TI C Compiler).
  • Test the examples on the API.

Week 6: June 18 - June 24

  • Port the examples to pru-as (pru-gcc).
  • Fix Bugs (Not exactly sure how complete pru-as is. I tried some working examples. Had a conversation with dinuxbg, according to him, pru-as and pru-ld are stable and also there is a major release coming up to align gnupru with the TI ABI). Nevertheless, I can use the buffer week to fix major bugs in pru-gcc (if any).

Week 7: June 25 - July 1

  • Complete the work on pru-as examples.
  • Work on a little more advanced additional (C) examples (demonstrating interrupt/events, shared memory).

Week 8: July 2 - July 8, End of Phase II

  • Work on a script to generate resource table for basic examples (The basic examples have most of the part of the resource table similar. For interrupts/event control examples, the script will provide a beginner friendly way to generate the resource_table.h file taking in a few parameters required.)(Details will be included in the documentation).

By the Phase II evaluation, I would deliver a set of working assembly/C remoteproc examples to use with the API

Week 9-10: July 9 - July 22, Start of Phase III

Write Documentation, which will include

  • Detailed explanation of the API functions
  • Step-by-Step Walkthrough of the examples.
  • Quick Start guide to start assembly programming with pru-as.
  • Setup and build instructions for the project.

Week 11: July 22 - July 28

  • Run Final Tests
  • Receive Mentor Feedback, Final Bug Fixes.
  • Cleaning/refactoring the code.

Week 12: July 29 - Aug 5

Buffer Week

Experience and approach

I am a junior-year electronics engineering undergraduate and had a fair amount of coursework related to embedded development. I have experience with programming microcontrollers(AVRs, Arm Cortex M0/3) in C and I've also worked on BeagleBone Black . I have been using linux as my primary OS for some time now, so I can work my way around embedded linux quite easily. Most of my software related coursework has been done in C and python, & therefore I am fairly proficient in both these languages.


  • Python Based Information-Retrieval System with Sentiment Classification: In this project, a large corpus of tweets is indexed locally and the ranked retrieval of tweets is performed in response to a search query, with tweets classified according to their sentiment.


My summer break starts exactly from the GSoC start date and will go on until the first week of August, until when all the work will be essentially completed. I have no other engagements during the summer, so I can devote whole of my time to the project. I plan on dedicating 7-8 hrs per day for the project on weekdays and 4-5 hrs on weekend days which makes the time commitment around 45-50 hrs per week. Since I wont be starting from scratch, I think the timeline above is quite realistic and doable in the time available.


There is an abundance of quality documentation on PRUs and remoteproc/rpmsg like the PRU-ICSS guide, remoteproc/rpmsg kernel documentation, wiki, PRU Assembly Guide, etc. One can always resort to IRC/mailing list and also the community forums like TI E2E but the response time may be high. Though, sometimes a thoughtful google search may suffice.


PRUs are a tough nut to crack for beginners. The ARM to PRU communication is a somewhat complex process and users are expected to know about the low level details upto some level before starting to write any code. Also, using the remoteproc interface tends to be difficult and timetaking for beginners.This project attempts to shorten the learning curve for users new to programming with PRUs by providing an abstraction over the loading, control and communication process with the PRUs so that they can start focusing on the functionality/app instead and get started with minimum time and effort.