BeagleBoard/GSoC/2021 Proposal/bela on bbai

=ProposalTemplate = About Student: Dhruva Gole Mentors: Giulio Moro Code: https://github.com/BelaPlatform/Bela Wiki: https://learn.bela.io/get-started-guide/say-hello-to-bela/#what-is-bela GSoC: GSoC entry

=Status= This project is currently just a proposal.

=Proposal= Please complete the requirements listed on the ideas page and fill out this template.

About you
IRC: dhruvag2000 Github: https://github.com/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

Description
As given on the official website, Bela is a hardware and software system for creating beautiful interaction with sensors and sound. Bela consists of a Bela cape on top of a BeagleBone Black computer (uptil now). Bela has a lot of analog and digital inputs and outputs for hooking up sensors and controlling other devices, and most importantly Bela has stereo audio i/o allowing you to interact with the world of sound. 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 (http://xenomai.org/). It thus takes advantage of features of the BeagleBone computers and can achieve extremely fast audio and sensor processing times. Bela is ideal for creating anything interactive that uses sensors and sound. So far, Bela has been used to create: and many more applications that are listed here 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 in the BBAI are coming up that need compatiblity with the Bela Software and Hardware. Delegating peripheral initialisation to the mcasp and spi drivers instead of doing it all by setting registers manually should hopefully make it more portable for porting to other boards in the family, present or future. C, PRU, dtb, uboot, make
 * What is Bela?
 * Applications of Bela:
 * 1) musical instruments and audio effects
 * 2) kinetic sculptures
 * 3) wearable devices
 * 4) interactive sound installations
 * Why add support for BBAI?
 * Programming languages and tools to be used:

Proposed method of Implementation and Timeline
The Bela cape is working on the BB AI using ALSA (although one of the clocks seems to be of the wrong frequency), so we can confirm the pinout and pin settings are OK. We have not tried running the Bela code on the PRU yet. You'll need to know (or learn!) a bit about pinmuxing, uboot, PRU assembly and more in general the Sitara family of SoCs and the McASP audio port. (ref. here)

It can be seen from the syntax here that we are ennumerating the hardware the code is running on as follows: typedef enum { 	BelaHw_NoHw = -1, BelaHw_Bela, BelaHw_BelaMini, BelaHw_Salt, BelaHw_CtagFace, BelaHw_CtagBeast, BelaHw_CtagFaceBela, BelaHw_CtagBeastBela, } BelaHw; Compatibility is checked here in the form of bool Bela_checkHwCompatibility(BelaHw userHw, BelaHw detectedHw);
 * Syntax Analysis

Come the BBAI, as seen here int cs_pin = 2 * 32 + 12; // P9.15a on BB AI these lines have been commented out for the older BB boards, which means this code won't really work for BB Black or Blue. To explain In the form of pseudo code how I aim to establish a common code base for supporting all boards, is by using: typedef enum { 	bb_ai, bb_black, bb_blue, } So, once we detect which board it is that we are running on start-up, the constants will be set accordingly and the rest of the code base will become much easier to use without needing to hard code the pins specific to the beagle board the user is currently using.


 * Timeline

Experience and approach

 * 1) I have used C++, C and Python programming languages over the past 3 years in a variety of projects involving embedded systems using the ESP32, Arduino UNO, ESP8266 and am also well-versed with freeRTOS.
 * 2) I have an aptitude for writing good reports and blogs, and have written a small blog on how to use a debugger.
 * 3) I recently did a project using ESP32, in which I used the DHT11 sensor to display humidity and temperature on a local HTML server . Other than that I have worked on developing hardware and making documentation for a 3 DOF arm based on an ESP32 custom board.
 * 4) I also interned at an embedded device startup where I
 * 5) Interfaced ADS1115 ADC with the ESP32 and used it to read battery voltage.
 * 6) Used UART for ESP32 and SIMCOM SIM 7600IE communication to gain LTE support.
 * 7) Published local sensor data to the cloud via LTE.
 * 8) I actively contribute to open source (most recently, I contributed to the ADS1115 library for ESP32 on the unclerus repo and can be seen here).
 * 9) Currently I am working on designing a Development board for the Raspberry Pico (RP2040) using KiCAD.
 * 10) I also 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) Derek Molly's beagle bone guide provides all the information needed for getting up and running with my beagle.
 * 2) Content on e-ALE.org is very useful for information that ranges from tutorials and walkthroughs to the level of very advanced stuff.
 * 3) https://credentiality2.blogspot.com/2015/09/beaglebone-pru-gpio-example.html

Benefit
If successfully completed, this project will add support for the Bela cape + Xenomai + PRU on the BeagleBone AI. as far as the porting to BBAI project is concerned, it's mostly a matter of getting the right pins enabled, running the PRU code with rproc, probably modify some constants in the PRU code accounting for any difference in SPI, MCASP and GPIO between AM3358 and AM5729 and testing that it all runs with a Xenomai kernel. -﻿giuliomoro

Misc
Completed all the requirements listed on the ideas page. The code for the cross-compilation task can be found here submitted through pull request #149.