This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Loading PRU code via header C array

I know pasm can generate a header with the PRU code compiled in a C array. I am told it's possible to load that C array into the PRU from the host. However, I'm having a difficult time finding examples of how to do that.

I keep coming across what's termed as "old examples" that have a PRU_load function, which appears to handle loading the C array located in a *_bin.h file into the PRU. I am using what I think to be the "new examples" which use the prussdrv.h and pruss_intc_mapping.h headers. These headers do not contain the PRU_load function and all the examples show the use of the prussdrv_exec_program function, which loads a separate binary file into the PRU.

Is it possible to load a PRU program into the PRU via the C array approach? If so, can someone point me to an example using the prussdrv.h headers?

  • Yes, I have. That contains the "old examples" I referred to under prw_sw/old_example/ and the "new examples" I referred to under pru_sw/example_apps/. None of the examples under pru_sw/example_apps/ show how to load code into the PRU with a C array; they only show how to load code into the PRU via the prussdrv_exec_program function (which requires a path to an external binary).

  • There is also now a TI released PRU software package: http://www.ti.com/tool/pru-swpkg . Sorry for providing information in pieces, I couldn't find this link when posting earlier.

  • Oh, it would appear the headers and library I am using are no longer supported by TI. It looks like TI now supports PRU code to be written in C and uses a kernel driver to handle loading code into the PRU. I will digest this new information and return to this question after I figure out how to work with the new PRU support.

  • Erich,

    The pasm compiler is no longer supported officially by TI. Like you mentioned above you can use the pasm compiler to generate an .h has all the instruction code by using a set compiler flagshat. This feature is no longer supported in the new C based compiler. Also as mentioned above you are wanting to use the prussdrv.h file, this file is for the linux user space driver and the linux driver doesn't load the code in this method.

    If you are still wanting to continue to use the pasm compiler ( which is not recommended ) you can load the .h file into instruction memory with a function like the following.

    void ICSSMemLoad(unsigned int StartAddress , unsigned int Length ,const unsigned int *Pointer)

    {

      unsigned int tempCount;

     

      for(tempCount = 0; tempCount < Length ; tempCount++)

        HWREG(StartAddress + tempCount * 4) = Pointer[tempCount];//Fill the Pru with the instructions

     

    }

    If you look into the technical reference manual for the AM335x you can find that the base address for the ICSS_PRU in table 2-4  (0x4A30_0000). This is the starting address for the memory space of the ICSS peripheral. Now by looking at table 4-8 you can see that the instruction memory for pru0 and pru1 is at memory location 0x0003_4000 and 0x0003_8000 respectively. These are global memory address which means if you want to write these locations from the arm they need to have the ICSS offset added to them also. PRU0’s instruction memory is at 0x4A33_4000 with respect from the ARM and this would be the starting address in the above code example.

     

    Also some things to look for are that the ARM cannot access the PRU’s instruction memory space when the PRU is running.  To initialize the ICSS you have to turn on the clock, enable the power in the PRM PER domain, and then enable the clock. Look in chapter 8 for register information for this.

     

    -Jason

     

  • Is the PRU software package not supported in yocto yet? I've been looking for a bit and can't seem to find a recipe for it.

  • We have an internally created bin_to_hex utility that creates the arrays for us (created long ago for other projects),  and I have it working on the PRU stuff with the compiler.  Our application needs to load different PRU files at different times,  and external .bin files will not work for us.

    there are undoubtedly commercial and free utilities that do the same,  or manual methods if you only need to do it a few times.

    You also need to ensure that the linker puts the entry point at 0,  or you need to preset the PRU program counter to the starting address. 

    Hope this helps,

    Bob