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 a
m335x_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.

         *----------------------------------------------------------------- 

         Now it's getting more exciting.  I wont go too much into the 
details, but what we did was compile a C code that ran a .bin file which we 
got from assembling the .p file. The .p file contains the assembly 
instructions and the .c file is the whole execution. I recommend using 
these links for a more complete reference:

        https://www.npmjs.org/package/pru

·         http://www.programering.com/a/MDMyETNwATk.html

         Ok now let's say you need to access more of the pins.  Matt 
Ranostay built a device tree overlay that lets you gain access into a 
single pin.. For more information about what is device tree and how it 
works please read the following links: 

https://docs.google.com/document/d/17P54kZkZO_-JtTjrFuVz-Cp_RMMg7GB_8W9JK9sLKfA/edit?hl=en&forcehl=1#
 
<https://docs.google.com/document/d/17P54kZkZO_-JtTjrFuVz-Cp_RMMg7GB_8W9JK9sLKfA/edit?hl=en&forcehl=1>
 [This 
one in particular is very good]

·         
http://derekmolloy.ie/gpios-on-the-beaglebone-black-using-device-tree-overlays/

·         
https://github.com/jadonk/validation-scripts/tree/master/test-capemgr

        Matt made the device tree which we've used before 
BB-BONE-PRU-01-00A0.dts (we echoed it into slots).

        o   
https://github.com/jadonk/cape-firmware/blob/master/arch/arm/boot/dts/BB-BONE-PRU-01-00A0.dts

         If you read the google docs file you'll see that we need to 
reserve pins for our usage and also change the pinmux. So what I did to get 
my 10 parallel output signals from PRU0 is modify the .dts so the final 
device tree overlay looks like this one:

        /*

* Copyright (C) 2013 Matt Ranostay <[email protected]>

* Modified by Jose Miguel Fernandez <[email protected]>

* This program is free software; you can redistribute it and/or modify

* it under the terms of the GNU General Public License version 2 as

* published by the Free Software Foundation.

* This overlay exposes PRU0 reg30 [0:7] and [14:15] as outputs.

*/

/dts-v1/;

/plugin/;


/ {

compatible = "ti,beaglebone", "ti,beaglebone-black";


/* identification */

part-number = "BBB-PRU-JMF";

version = "00A0";


/* state the resources this cape uses */

exclusive-use =

/* the pin header uses */

"P9.27", /* pru0: pr1_pru0_pru_r30_5 */

"P8.11", /* pru0: pr1_pru0_pru_r30_15 */

"P8.12", /* pru0: pr1_pru0_pru_r30_14 */

"P9.25", /* pru0: pr1_pru0_pru_r30_7 */

"P9.41", /* pru0: pr1_pru0_pru_r30_6 */

"P9.42", /* pru0: pr1_pru0_pru_r30_4 */

"P9.28", /* pru0: pr1_pru0_pru_r30_3 */

"P9.30", /* pru0: pr1_pru0_pru_r30_2 */

"P9.29", /* pru0: pr1_pru0_pru_r30_1 */

"P9.31", /* pru0: pr1_pru0_pru_r30_0 */

/* the hardware IP uses */

"pru0";


fragment@0 {

target = <&am33xx_pinmux>;

__overlay__ {


pru_gpio_pins: pinmux_pru_gpio_pins {

pinctrl-single,pins = <

0x1a4 0x0f /* P9 27 GPIO3_19: mcasp0_fsr.gpio3[19] | MODE7 | OUTPUT */

>;

};


pru_pru_pins: pinmux_pru_pru_pins {

pinctrl-single,pins = <

0x1a4 0x25 /* mcasp0_fsr.pr1_pru0_pru_r30_5, MODE5 | OUTPUT | PRU */

0x034 0x26 /* gpmc_ad13.pr1_pru0_pru_r30_15, MODE6 | OUTPUT | PRU */

0x030 0x26 /* gpmc_ad12.pr1_pru0_pru_r30_14, MODE6 | OUTPUT | PRU */

0x1ac 0x25 /* mcasp0_ahclkx.pr1_pru0_pru_r30_7, MODE5 | OUTPUT | PRU */

0x1a8 0x25 /* mcasp0_axr1.pr1_pru0_pru_r30_6, MODE5 | OUTPUT | PRU */

0x1a0 0x25 /* mcasp0_aclkr.pr1_pru0_pru_r30_4, MODE5 | OUTPUT | PRU */

0x19c 0x25 /* mcasp0_ahclkr.pr1_pru0_pru_r30_3, MODE5 | OUTPUT | PRU */

0x198 0x25 /* mcasp0_axr0.pr1_pru0_pru_r30_2, MODE5 | OUTPUT | PRU */

0x194 0x25 /* mcasp0_fsx.pr1_pru0_pru_r30_1, MODE5 | OUTPUT | PRU */

0x190 0x25 /* mcasp0_aclkx.pr1_pru0_pru_r30_0, MODE5 | OUTPUT | PRU */

>;

};

};

};

Ok I know this seems like a lot of reading and digging in. But trust me, 
I've narrowed it down pretty much to everything you need.
Now we compile the new overlay using: 
   dtc -O dtb -o BBB-PRU-JMF-00A0.dtbo -b 0 -@ BBB-PRU-JMF-00A0.dts
Then we need to copy the new .dtbo file into /lib/firmware

cp BBB-PRU-JMF-00A0.dtbo /lib/firmware/

 Now if you haven't restarted your BBB, the you might want to take out 
Matt's Overlay first:  #echo -[number of cape] > 
/sys/devices/bone-capemgr*/slots

If you dont know what number of cape to disable simply type: #cat  
/sys/devices/bone-capemgr*/slots

E.g.: 
 0: 54:PF---
 1: 55:PF---
 2: 56:PF---
 3: 57:PF---
 4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
 5: ff:P-O-- Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
 6: ff:P-O-- Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN
 7: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-BONE-PRU-01

So in my case it's 7, but that number can change
now we echo in the new overlay 

echo BBB-PRU-JMF > /sys/devices/bone-capemgr.*/slots

 
and there you go, 10 PRU0 reg30 output pins at your disposal.

I know I might have been a little vague and I miss some details, feel free 
to write to me if you have any issues or want to continue the explanation. 
I'll be happy to answer to you. If the experts have anything else to add 
please I would love some feedback. This is my first post in a forum by the 
way XD..  


Oh and if someone could please explain to me why modifying 
BB-BONE-PRU-04.dts wouldn't help ? Thanks.

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to