Friday 30 August 2019

BeagleBone Black PRU

BeagleBone Black - Adventures with PRU

 Part of 'How fast can you make a GPIO toggle, I have now just done a torture GPIO toggle on BeagleBone just to see how fast it can run.

From the looks... it may just do the trick! - hopefully emulate a RAM chip and peripherals in an Amiga!

The Setup,

From The PRU guide on Element 14 the setup is pretty straight forward main difference is you dont need to install the code composer studio as the BBB gets configured with all the PRU software. What you do need are the samples; and put them anywhere you like.

 Update the kernel - nice but not really needed
  1. sudo /opt/scripts/tools/update_kernel.sh  
  2. sudo apt update  
  3. sudo apt upgrade  
  4. sudo apt dist-upgrade 
Connect to the BBB and link the compilers and do the export.
ln -s /usr/bin/ /usr/share/ti/cgt-pru/bin
export PRU_CGT=/usr/share/ti/cgt-pru

Next to get the sample code from GIT

git clone git://git.ti.com/pru-software-support-package/pru-software-support-package.git 
Change to the directory with the examples downloaded in the previous step - and run the makefiles
cd /opt/source/pru-software-support-package/examples/am335x
make
 Once compiled, set the IO pins
sudo config-pin P9_27 output
sudo config-pin P9_27 pruout
 and then copy the firmware files to /lib/firmware on the BBB

cd /sys/class/remoteproc/remoteproc1
 echo '<firmware name>' firmware
 echo 'start' > state
*NOTE - the example in the download does not toggle P9_27 - change to 0x0020 in the sources ffor gpio.

From the small application - Toggling P9_27; there is 25nSecond for one pulse. Loaded in to the PRU and voila!

#include <stdint.h>
#include <pru_cfg.h>
#include "resource_table_empty.h"

volatile register uint32_t __R30;
volatile register uint32_t __R31;

void main(void)
{
        volatile uint32_t gpio;

        /* Clear SYSCFG[STANDBY_INIT] to enable OCP master port */
        CT_CFG.SYSCFG_bit.STANDBY_INIT = 0;

        /* Toggle GPO pins TODO: Figure out which to use */
        gpio = 0x0020;
        while (1) {
                __R30 ^= gpio;
//              __delay_cycles(100000000);
        }
}
 
From the FFT trace - there is all sorts of frequencies in there.. the harmonics are awesome!


Update:

Even without using high speed PRU GPIO pins, the access to normal pins from the PRU is still quite a respectable 80nSeconds. (ignore the yellow trace, its connected to the high speed line which is doing nothing)


Avaliable Pins on a BeagleBone Black




No comments:

Post a Comment