PRU device tree and running programs

Hi guys,
I’m just starting with the BeagleBone Black and got very interested in the PRU module. So after a couple of headbanging research I’ve managed to narrow it down to these simple steps for usage.

First we need to setup the environment:
(These steps where taken directly from Youngtae Jo in his Thread of ADC reading by PRU)

· [ Install compile environment ]

· 1. Get a copy of the am335x_pru_package → https://github.com/beagleboard/am335x_pru_package

· You also can download the am335x_pru_package here → https://github.com/beagleboard/am335x_pru_package/archive/master.zip

· 2. If you downloaded the archive, unpack it somewhere under your home directory.

· 3. Make a new directory /usr/include/pruss/ and copy the files prussdrv.h

· and pruss_intc_mapping.h into it (from am335x_pru_package-master/pru_sw/app_loader/include). IMPORTANT: If you downloaded the .zip file it will show as am335x_pru_package-master, else it will just be am335x_pru_package

· Check the permissions; if you used the .zip file, these headers will likely have the execute bits on.

· It doesn’t really hurt anything, but is certainly not what you want.

· 4. Change directory to am335x_pru_package-master/pru_sw/app_loader/interface

· then run: CROSS_COMPILE= make (note the space between the = and the command).

· 5. The previous step should have created four files in am335x_pru_package-master/pru_sw/app_loader/lib: libprussdrv.a, libprussdrvd.a, libprussdrvd.so and libprussdrv.so.

· Copy these all to /usr/lib then run ldconfig.

· 6. Change directory to am335x_pru_package-master/pru_sw/utils/pasm_source

· then run source linuxbuild to create a pasm executable one directory level up. [ #cd … ]

· - If linuxbuild doesn’t have permission to execution, give the permission by run this

· : chmod +x linuxbuild

· Copy it to /usr/bin and make sure you can run it.

· If you invoke it with no arguments, you should get a usage statement.

·

· [ Enable PRU ]

· Before using PRU, we need to enable the PRU core, you can do it as shown below

· # echo BB-BONE-PRU-01 > /sys/devices/bone_capemgr.*/slots

So this is the part where I just stumbled into a “NOW WHAT?”

we need to test the setup: So for this step we go into the example_apps folder: (if you are still in am335x_pru_package-master/pru_sw/utils) #cd …/example_apps

Next you can go into any of the example folders, I will use the PRU_memAccess_DDR_PRUsharedRAM, so next we do : gcc [the C file].c -lpthread -lprussdrv -o [output file name]

pasm -b [asm code].p

Ok now, we run it using: # ./[output file name]

If everything is ok, it will print something like this:

INFO: Starting PRU_memAcc_DDR_sharedRAM example.

INFO: Initializing example.

INFO: Executing example.

INFO: Waiting for HALT command.

INFO: PRU completed transfer.

Example executed succesfully.