BeagleBoard/GSoC/2021 Proposal/bela on bbai

< BeagleBoard‎ | GSoC
Revision as of 10:57, 1 June 2021 by DhruvaG2000 (talk | contribs) (added forum link)
Jump to: navigation, search

Proposal-Bela support for BBAI

{{#ev:youtube|}} About Student: Dhruva Gole
Mentors: ﻿Giulio Moro
GSoC: GSoC entry


This project proposal has been accepted as part of GSoC 2021.


Bela is a hardware and software system for creating beautiful interaction with sensors and sound. This project proposes to provide restructuring and improvement of existing Bela Software Code to allow for compatibility and easier transition to newer TI chips (like in the BBAI).

About you

IRC: dhruvag2000
School: Veermata Jijabai Technological Inst.
Country: India
Primary language : English, Marathi, Hindi
Typical work hours: 10AM - 7PM Indian Standard Time
Previous GSoC participation: I find embedded and IOT pretty interesting, given I have experience with ESP32, SIMCOM, ESP8266, Atmega, and many other microcontroller devices and 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: Bela support for the BeagleBone AI
Logs : I maintain weekly progress updates here .


What is Bela?

Both Bela systems use the same Bela software. It uses a customised Debian distribution which - most notably - uses a Xenomai kernel instead of a stock kernel. Xenomai is co-kernel for Linux which allows to achieve hard real-time performance on Linux machines ( It thus takes advantage of features of the BeagleBone computers and can achieve extremely fast audio and sensor processing times. Although the proposal Title mentions support for AI, I will try to develop a standardized setup that allows an easy jump across all TI chips.

Applications of Bela


  1. musical instruments and audio effects
  2. kinetic sculptures
  3. wearable devices
  4. interactive sound installations

and many more applications that are listed here

Why add support for BBAI/newer TI chips?

The Beagle Black and PocketBeagle are getting outdated by the day and also it would be better to have a more standardised setup that allows to more easily jump across TI chips, soon newer boards with different and more efficient chips like the AM5X and the TI C66x digital-signal-processor (DSP) cores in the BBAI are coming up that will need compatiblity with the Bela Software and Hardware. As part of the process we will try to offload peripheral initialisation to the mcasp and spi driver to in order to make it more portable for porting to other boards in the family, at present or future.

Programming languages and tools to be used

C, PRU, dtb, uboot, make

Proposed method of Implementation

Current status: The Bela cape is normally used in combination with the TI AM3358 chip on the BeagleBone Black. The hardware is currently working on the BBAI only using ALSA and the SPI driver [1], so the pinout and pin settings are OK, but the Bela real-time code on ARM and PRU is not running on BBAI yet. During this project I will:

  1. create a device tree overlay for the BBAI using the Cape Compatibility layer
  4. install a Xenomai kernel and run the full Bela stack


Syntax Analysis


  4. in order to progress via intermediate steps, I may want to test the code first running on vanilla Linux without Xenomai(Reason: Xenomai kernel has been built for the BBAI, but it has not been tested - to my knowledge - and it may be too old to support cape compatibility.). This requires replacing the __wrap_pthread_{...} calls (in core/RTAudio.cpp, core/AuxiliaryTask.cppm include/xenomai_wraps.h) with the corresponding pthread_{...} functions.
  5. the BBAI can be added to the BelaHw enum in include/Bela.h and used in Bela_detectUserHw() and Bela_checkHwCompatibility() in core/board_detect.cpp. ✓ (testing pending)


Workflow for building the existing pasm PRU code with clpru



4. have the following in main.c:

void main()
     __asm__ __volatile__
#include "included_assembly.h"

5. build main.c with the regular clpru toolchain


#define MCASP0_BASE 0x48038000
#define MCASP1_BASE 0x4803C000
#define MCASP0_DATAPORT 0x46000000
#define MCASP1_DATAPORT 0x46400000



I am yet to figure out pinmuxing to make sure the relevant pins are set to the correct function (they are NOT by default). I will see here and/or ask on the BB slack about for the best way to go about it.



PRU transitioning from libprussdrv to rproc


XENOMAI kernel

Xenomai kernel (of an older version) has been built for the BBAI, but it has not been tested - to my knowledge - and it may be too old to support cape compatibility. I can probably ask Robert Nelson to build a more modern one, but I thought it may be worth exploring the vanilla kernel option first if any of these things gets in the way. The difference in performance would be such that a vanilla kernel will most likely not be able 100% hard real-time performance, but with larger blocksizes we can probably work around it for testing purposes. If everything works as planned, I will look into installing the xenomai kernel through the default procedure to update kernel. If any issues arise, I may have to rebuild the kernel. I will also need to install the user-space Xenomai library as well. That MAY be available through apt-get (Xenomai >= 3.0), or it can be easily built from source.

Hardware required


  1. BeagleBone AI.
  2. Bela cape: The original Bela board.


Apr 13 Proposal complete Submitted to
May 17 Proposal accepted or rejected
  1. Proposal Accepted
  3. Learn about embedded linux structure ✓
Jun 07 Pre-work complete, Coding officially begins!

(some points above are ref. from here )

Jun 17 Milestone #1,
  1. Introductory YouTube video
  3. verify it works running with ALSA using the BB-BONE-AUDI overlay.
June 24 Milestone #2
  1. Start writing the overlay for Bela Cape
  3. Try to implement the PRU code using rproc.
June 30 Milestone #3
  1. Try to run Bela without Xenomai (This requires changing a few calls to __wrap_pthread_...() in the Bela core code to pthread_...() and minor changes.)
  2. run Bela with Xenomai, without rtdm(Real-time data monitoring) ie. generate (PRU->ARM interrupts)
July 12 18:00 UTC Milestone #4
  1. Start documenting everything done so far.

Mentors and students can begin submitting Phase 1 evaluations

July 16 18:00 UTC Phase 1 Evaluation deadline
July 23 Milestone #5
  2. Try to run all the stock tutorials
July 30 Milestone #6
  1. Validate existing work with some functional tests.
  3. Start organizing the codes so far by adding comments and making variable readable.
Aug 06 Milestone #7
  1. Create detailed Documentation about the above implementation.
August 10 Milestone #8
  1. Writing the overall project summary and outcomes.
  2. Start making the Completion YouTube video.

Experience and approach

  4. I also interned at an embedded device startup where I
    3. Published local sensor data to the cloud via LTE.



  2. remoteproc
  3. BBAI vs BBB pin headers Google Sheet
  4. beaglebone pru gpio example
  5. official BELA website
  6. Ask on the forum



-Giulio Moro


Completed all the requirements listed on the ideas page.