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.

AM572x PRU Dynamic program load

Other Parts Discussed in Thread: AM5728

Hi everyone!

I have a question about the way PRU houses the instruction and data code of a program. Reading the TRM it is noted that the PRU has the following memory distribution:

  • 12-KiB program RAM (Instruction RAM) per PRU CPU (signified IRAM0 for PRU0 and IRAM1 for PRU1)

  • 8-KiB data RAM per PRU CPU (signified RAM0 for PRU0 and RAM1 for PRU1)

  • 32-KiB general purpose memory RAM (signified RAM2) shared between PRU0 and PRU1

What happen if my firmware program exceeds the 12 KB?

Perhaps there exists an alternative way of houses the program code on the AM5728 memory RAM, and load it in the PRU IRAM in 12KB blocks one by one as needed? 

Thanks in advance on any guidance that you could provide.

-Daniel

  • Hi,

    I will ask the PRU experts to comment if this is possible.
  • Thanks for your help! 

    I will be waiting for your answer.

  • Daniel,

    If your firmware program exceeds 12 KB then the linking phase of the build process will fail because your .text section will be larger than the memory that it is destined for (assuming that you are using the TI provided PRU C compiler/linker).

    One solution would be to build multiple firmwares, each being less than 12 KB in size, and then once you need to switch firmwares you can halt the PRU, change the symlink in /lib/firmware/ to point to a different firmware, and then reload the PRU and run it.

    Unfortunately the PRU can only fetch instructions from its internal IRAM so there is no option to fetch from the external larger RAM2.

    Jason Reeder

  • Hi Jason,

    Thanks a lot for your help, It has been quite profitable.

    But I got another related question that I post on a new topic in Sitara Forum (e2e.ti.com/.../522854).

    The question is the following:

    I am working with the PRU subsystem on AM5728 EVM, and I got a question related with the size of the PRU firmware files.

    Running this command "du -h *" to check the firmware file size, I have noticed that default firmware files provided by ti-processor-sdk-linux-am57xx-evm-02.00.02.11 has a size of 80 KB. The output of the command is shown below:

    dgarbanzo@ridgerun-GA-890FXA-UD5:~/ti-processor-sdk-linux-am57xx-evm-02.00.02.11/targetNFS/lib/firmware/pru$ du -h *
    28K PRU_Halt.out
    80K PRU_RPMsg_Echo_Interrupt1_0.out
    80K PRU_RPMsg_Echo_Interrupt1_1.out
    80K PRU_RPMsg_Echo_Interrupt2_0.out
    80K PRU_RPMsg_Echo_Interrupt2_1.out

    Reading the TRM it is noted that the PRU has the following memory distribution:

    12-KiB program RAM (Instruction RAM) per PRU CPU (signified IRAM0 for PRU0 and IRAM1 for PRU1)
    8-KiB data RAM per PRU CPU (signified RAM0 for PRU0 and RAM1 for PRU1)
    32-KiB general purpose memory RAM (signified RAM2) shared between PRU0 and PRU1
    My questions are:

    1) Why does the PRU firmware file exceeds the size of the internal instruction RAM (even exceeds the size of the sum of the three memories available)?

    2) How can PRU manage and load this firmware file, if it is supposed that don´t fit in its internal memory RAM array? How it is possible? (I have load this firmware and run the basic example, and all seems to work fine)

    3) Is there any tool that gives me a description of the amount of code (KB) corresponding to instructions and data in a separate way, both from source code and executable binary?

    Thanks in advance on any guidance that you could provide.

    -Daniel
  • Daniel,

    The files that you are checking the size of are ELF binaries. These binaries contain all of the sections that are loaded into the different memories (IRAM, DRAM, etc.) as well as other information that is useful to the loader but does not get placed into PRU memory.

    If you want to check the actual size of the firmware/data that is loaded into the PRU memories then you should check the *.map file that gets generated by the linking process of the build. If you use the provided Makefiles to rebuild the firmware the *.map file will be in the 'gen/' directory. If you use CCS to rebuild the firmwares then the *.map file should be either in the 'Debug/' or 'Release/' folder.

    Below is an example showing a portion of the PRU_RPMsg_Echo_Interrupt1_0.map file. You can see on the PRU_IMEM line that the 'used' portion of the instruction RAM is 0x4F4 out of an available 0x3000. This means that the firmware actually only uses 1268 bytes out of 12KB (or ~10.3% of the available instruction RAM).

    ******************************************************************************

                        PRU Linker Unix v2.1.2

    ******************************************************************************

    >> Linked Mon Jun 20 16:55:21 2016

    OUTPUT FILE NAME:   <gen/PRU_RPMsg_Echo_Interrupt1_0.out>

    ENTRY POINT SYMBOL: "_c_int00_noinit_noargs_noexit"  address: 00000000

    MEMORY CONFIGURATION

            name            origin    length      used     unused   attr    fill

    ----------------------  --------  ---------  --------  --------  ----  --------

    PAGE 0:

     PRU_IMEM              00000000   00003000  000004f4  00002b0c  RWIX

    PAGE 1:

     PRU_DMEM_0_1          00000000   00002000  00000396  00001c6a  RWIX

     PRU_DMEM_1_0          00002000   00002000  00000000  00002000  RWIX

    PAGE 2:

     PRU_SHAREDMEM         00010000   00008000  00000000  00008000  RWIX

  • Thanks a lot for the information, my doubts have been clarified.