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.

CCS: Expand code space on AM335x memory map

Other Parts Discussed in Thread: AM3358

Tool/software: Code Composer Studio

I created a PRU AM3358 project on CCS and tryed to use `sprintf`, which use all my code memory. By standard the `AM335x_PRU.cmd` memory map file is:

/* Specify the System Memory Map */
MEMORY
{
      PAGE 0:
    PRU_IMEM        : org = 0x00000000 len = 0x00002000  /* 8kB PRU0 Instruction RAM */
      PAGE 1:
    /* RAM */
    PRU_DMEM_0_1    : org = 0x00000000 len = 0x00002000 CREGISTER=24 /* 8kB PRU Data RAM 0_1 */
    PRU_DMEM_1_0    : org = 0x00002000 len = 0x00002000    CREGISTER=25 /* 8kB PRU Data RAM 1_0 */
      PAGE 2:
    PRU_SHAREDMEM    : org = 0x00010000 len = 0x00003000 CREGISTER=28 /* 12kB Shared RAM */
    DDR                : org = 0x80000000 len = 0x00000100    CREGISTER=31
    L3OCMC            : org = 0x40000000 len = 0x00010000    CREGISTER=30

    /* Peripherals */
   ... // I did put here because I though that this can't be modified.
}

Is it possible to change the `PRUY_IMEM` space to fit my code? Which manual have the "CCS MEMORY{ " directives? What are the limit?

  • Hello,

    Hildo Guillardi Junior said:
    Is it possible to change the `PRUY_IMEM` space to fit my code?

    You cannot not arbitrarily change the length of these sections without checking to see if it will conflict with the actual debugger memory map of the actual physical memory of the target.

    I would take a look at the below link. While you are not getting the error described in the document, it is a good primer regarding the delicate relationship between the linker command file, the debugger memory map, and the available target memory:

    http://software-dl.ti.com/ccs/esd/documents/troubleshooting-data_verification_errors.html

    Hildo Guillardi Junior said:
    Which manual have the "CCS MEMORY{ " directives?

    See: http://processors.wiki.ti.com/index.php/Linker_Command_File_Primer#The_MEMORY_Directive

    Actually I would read that entire article also. It can give you some hints on how to find space for your code.

    Thanks

    ki

  • Yes, change this without understand can overwrite memory regions.

    So far I understood, and to keep a register here:
    PAGE 1:
    PRU_DMEM_0_1 : org = 0x00000000 len = 0x00002000 CREGISTER=24
    The space `PRU_DMEM_0_1` starts on 0x000 of map region page 1 and have the size of 0x2000 words. In the `SECTION` directive (not shown here) the linker associate the code/variables/constants blocks generate by the compiler with the memory regions defined on `MEMORY{`.

    But, whats the function of `CREGISTER=24` directive?
  • The CREGISTER specifier associates a PRU constant table entry with a memory range. The PRU supports LBCO and SBCO instructions of the form

    LBCO &REG1, Cn2, OP(255), IM(124)

    Where Cn2 specifies a constant table register. The compiler will generate this instruction if the  cregister attribute is used on a given type. The attribute specifies a memory range that must correspond to a memory range in your linker command file with a CREGISTER specification.

    int x __attribute__((cregister("PRU_DMEM_0_1", [near|far]), peripheral));

    You can read more about that syntax in section 5.14.4 in the PRU compiler user guide (http://www.ti.com/lit/ug/spruhv7b/spruhv7b.pdf). The attribute will cause compiler to generate the LBCO/SBCO instruction. The CREGISTER specification will cause the linker to bind the Cn2 operand to a specific number, in this case 24.