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.

Compiler/TMS320F28335: Call to __memcpy_ff generated

Part Number: TMS320F28335

Tool/software: TI C/C++ Compiler

Hello

I am doing something like this:

struct BIG { lots of fields };
struct BIG A, B;
:
A = B;

The compiler is generating a call to __memcpy_ff to do this, and as we are not using library functions (aviation) this is a bother.

I can write a copy function, but have never got this issue before when copying structures.

So, why is it happening?  Is it just that it is a big struct?

Thanks.

  • Structure assignment is always implemented by calling a variant of memcpy.  (Except for structures that are only 1 word big.)  There is no compiler option for disabling this behavior.

    Giles Robnson said:
    I can write a copy function

    That is the best way to go.

    Thanks and regards,

    -George

  • Is that really so?  Example code:

    struct AA {
        int a;
        unsigned int d[8];
    };
    
    struct BB {
        long g;
        struct AA h[32];
    };
    
    struct AA x = {1};
    struct BB s = {9};
    
    void main(void)
    {
        static struct AA y;
        y = x;
        y.a++;
    
        static struct BB t;
    //    t = s;
        t.g = 0;
        t.g++;
    }
    

    This compiles and links.  But if I uncomment "t = s;", I get the link error

    Description    Resource    Path    Location    Type
    #10010 errors encountered during linking; "aa.out" not built    aa             C/C++ Problem
    <a href="file:/C:/ti/ccsv5/tools/compiler/dmed/HTML/10234.html">#10234-D</a>  unresolved symbols remain    aa             C/C++ Problem
    unresolved symbol ___memcpy_ff, first referenced in ./try.obj    aa             C/C++ Problem

    I have used Project -> Properties -> Build -> C2000 Linker -> File Search Path to remove all libraries, and included our own version of c_int00 in the project.

    Possibly it is the size, but the limit must be more than 1 word.

    Regards

  • The latest version of the compiler no longer supports memcpy_ff. Because your example shows the compiler using memcpy_ff, I know that you are using an older version of the C2000 compiler. Which version is it? (It is not the same as the CCS version.)

    memcpy_ff is a memory copy from "far" memory to "far" memory. Otherwise it is the same as memcpy. You must be using large data memory model; this model is probably set for you by CCS when you select the specific C2000 device.

    I would think the C2000 could generate a RPT instruction to perform a memcpy operation inline, but I don't know offhand whether it does so. It would help to know your exact compiler command-line options. These are easiest to see in the build console.
  • Thanks for your reply.

    You're right, large memory model and an old compiler version - 6.1.0 (I am re-looking at code for aviation software, so currently sticking with the version that was used for certification). To compile I'm using:
    "C:/ti/ccsv5/tools/compiler/c2000_6.1.0/bin/cl2000" -v28 -ml -mt --float_support=fpu32 -Ooff -g --diag_error=225 --display_error_number --gen_func_subsections=on -z --stack_size=0x300 --warn_sections --reread_libs --disable_auto_rts --issue_remarks --mapfile_contents=all --rom_model

    I am copying larger amounts of memory than I would like, but it is very useful at the moment for the purposes of see exactly what the hardware controlled by the TMS320F28335 is doing (I'm saving old values and comparing)

    It looks to me as if there is a size threshold, at which the use of memcpy_ff is started, but maybe indirectly. I was wondering what exactly triggers the change.
  • Note: this is true for 6.1.0; I haven't looked at any other version.

    The limit is 255 words, because the maximum value of k for the "RPT k" instruction is 255.
  • Aha! Looking at the generated assembler, it all makes sense. The compiler is generating nice, terse assembler, until I ask it to do too much.
    Thanks for your help.