Hello,

Thank you for all the help! 

I have finally been able to get this array constructed by a user space C 
program into the external DDR ram, and access the array directly from PRU0 
using uio_pruss! I wanted to give an update on what I did for anyone else 
who might try to do something similar in the future.

TJF and the others were right, I could not find an easy way to do this 
using rproc, but with uio_pruss it is fairly straight forward. While the 
suggestions made to help me get this going were surely valid, I found what 
seemed to be the simplest way for me using the example 
PRU_memAccess_DDR_PRUsharedRAM found in the am335x_pru_package which I just 
cloned from here <https://github.com/beagleboard/am335x_pru_package>.

I was unable to do this before because I did not set up my beaglebone for 
uio_pruss correctly, and would always get errors when using commands like 
prussdrv_open(). But from the suggestions in this post I was able to figure 
out what I was doing wrong, and got uio_pruss set up properly so that I 
could run this example. The example uses a c script to mmap() a block of 
memory in DDR and stores 3 values in the first 3 addresses of the mapped 
memory, then it programs the pru with an assembly file that is compiled 
with pasm, to simply configure OCP master port, configure one programmable 
pointer to point at the DDR memory where the 3 values are, and configure 
another programmable pointer to point to the pru's shared RAM. The pru 
loads in the three values into 3 of its 32 registers, and then places them 
in the first 3 address of its 12kB shared RAM. Then the pru halts after 
interrupting the host c program that it finished, and the c program checks 
the 3 registers in the shared RAM to see if they are the same values that 
it originally stored in DDR RAM. 

I was able to modify this example to mmap() a larger block of memory, and 
store the ~300,000 integer bytes into the DDR registers, then have the PRU 
check all of them and confirm that it is as it should be, then it loops and 
does what it needs to do set its GPIOs appropriately at very high 
frequency! It works great!

Some things I had to do to set up the executable:

1) set up Beaglebone to enable uio_pruss
        -(This worked on several different linux images that I tried it on, 
but currently I've installed 4.4.88-ti-r125) in the uEnv.txt file, I added 
this line "dtb=am335x-boneblack-emmc-overlay.dtb", and uncommented these 
lines "disable_uboot_overlay_video=1 disable_uboot_overlay_audio=1" but 
most importantly comment out 
"#uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-4-TI-00A0.dtbo" and 
uncomment "uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo".  Then 
after rebooting you should see this if you enter lsmod | grep pru :
     uio_pruss            4629  0
     uio                     11100  2 uio_pruss,uio_pdrv_genirq
     pru_rproc          15879  0
     pruss                 12346  1 pru_rproc
     pruss_intc           9009  1 pru_rproc

        -If there are any GPIOs that you want to give to the PRU, find the 
pins that will work using the BBB reference manual, and simply config-pin 
them for use by pru. for example " config-pin P9_31 pruout ", check that it 
worked with "config-pin -q P9_31", it should print "P9_31 Mode: pruout"

2) set up everything for the make files in the am335x_pru_package to work: 
(this only needs to be done once)
       This 
<https://www.element14.com/community/community/designcenter/single-board-computers/next-gen_beaglebone//blog/2013/05/22/bbb--working-with-the-pru-icssprussv2>
 
is example tutorial was very helpful, but I had to do a few things slightly 
differently:
     -before anything, type " export CROSS_COMPILE= " 
     -cd to /am335x_pru_package/pru_sw/app_loader/interface and enter " 
make ". This creates 4 files - libprussdrv.a  libprussdrvd.a  
libprussdrvd.so  libprussdrv.so, copy them all into /usr/lib and enter " 
ldconfig "
     -cd to /am335x_pru_package/pru_sw/utils/pasm_source and enter " source 
./linuxbuild " . This creates the pasm executable one directory up in 
/am335x_pru_package/pru_sw/utils , copy pasm into /usr/bin , and make sure 
it works by just typing " pasm " with no arguments. If it's done correctly 
you will get a usage instruction statement because no arguments were given.
     
3) now that the uio_pruss is working, and am335x_pru_package has been 
correctly "built", the examples can be used to do all sorts of cool stuff 
by modifying .c scripts, .p (assembly) scripts, and .hp (assembly header) 
scripts. To compile an example or modified example do this:
     -cd /am335x_pru_package/pru_sw/example_apps and run first "make clean" 
and then "make". All the examples will be compiled.
     -inside /am335x_pru_package/pru_sw/example_apps/bin are all the 
compiled binary files created from each example's assembly code. Copy the 
one you want into /am335x_pru_package/pru_sw/example_apps/<the example you 
want folder>/obj
     -compile the .o and .bin files within /obj by linking with a command 
like "gcc <the example you want>.o -L../../../app_loader/lib -lprussdrv 
-lpthread -o myexecutable.out
     -This makes an executable myexecutable.out in the same /obj folder, 
which is ready to run with ./myexecutable.out !!! All done!

If anyone wants to know more about the ways I modified the .c script to 
mmap() a larger DDR memory block, or the .p script which tells the pru how 
to deal with a much larger memory block, I can also post code about that 
stuff as well.

I hope this is helpful to any beginners out there like me!
Thanks again for the help,
Evan





On Tuesday, February 27, 2018 at 12:19:58 PM UTC-8, Evan Carter wrote:
>
> Hello,
>
> I've been working with PRU0 on the Beaglebone Black for a couple weeks now 
> (only a beginner) and have made some hopeful progress towards developing a 
> real time system that will change gpio logic states based on given location 
> data from a pupil tracking system. 
>
> So far I've been using the examples given in the BeagleScope project 
> (found here 
> <https://elinux.org/EBC_Exercise_30_PRU_via_remoteproc_and_RPMsg>) to 
> program the PRU using pru_rpmsg, and I'm currently using: Linux beaglebone 
> 4.4.113-ti-r147 #1 SMP Tue Feb 20 20:58:22 UTC 2018 armv7l GNU/Linux
>
> Things are going well! 
> *But I wanted to ask the community about the simplest way to build a large 
> 1-D array (look up table of ~310,000 indexes of just integers) that can be 
> accessed by PRU0 on the fly* to know how to set the gpios when it 
> receives a new set of pupil location values. Previously I've built this 
> array in userspace from an existing .txt file that is read byte by byte 
> from a C script that builds the array, but I need that array to be 
> accessible from PRU0. What is the simplest way to do this?
>
> I've looked into trying to build the array in DDR memory (which could in 
> theory be accessed by the PRU using address pointers), but allocating that 
> kind of space to be available to a user space program looks pretty 
> complicated (especially to ME who has never done any kernel space 
> programming). I'm hoping that someone out there can give me inspiration for 
> a simpler way to get this array to PRU0.
>
> Please get back to me soon! Thank you for reading
>

-- 
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 beagleboard+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/06e0d184-0201-4bcb-b46a-0b133c258479%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to