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/TMDXIDK5718: Memcpy fails

Part Number: TMDXIDK5718
Other Parts Discussed in Thread: AM5716

Tool/software: Code Composer Studio

Hi.

I am making a boot program for MPU (A15) using "TMDXIDK5718".
As shown below, when four processes are described, only the fourth memcpy is not processed correctly.
Stops at runtime.

Please tell me what is wrong.

#include <stdio.h>
#include <string.h>

/**
 * main.c
 */
int main(void)
{

    uint8_t buf[500];
    uint8_t *setPos = buf;

    memset(buf, 0x00, 500);

    memcpy(setPos, "12345678", 4);     // (1) OK
    memcpy(setPos, "12345678", 8);     // (2) OK
    memcpy(setPos+1, "23456789", 4);   // (3) OK
    memcpy(setPos+1, "23456789", 8);   // (4) NG

    return 0;
}

The project is created with the following settings.

The figure below shows the memory when processing up to processing 3 is executed.
It is set correctly.

The figure below shows when process 4 is executed.
The debugger exits.

Thank you.

  • Hi Koji,

    It seems to me that your C program is not correct. I am not sure what exactly you need to do, but note that when setPos points to 0x80018EBC, then setPos + 1 points to 0x80018EBD

    I would suggest you to explore the below memcpy program example and to align to it.

    https://www.includehelp.com/c-programs/memcpy-function-in-c-with-example.aspx

    Regards,
    Pavel

  • Thank you for your reply.

    “SetPos + 1” is intentional, so there is no problem.
    Present the problem more simply.
    In the following code, (4) is not processed for some reason.
    The debugger stops.
    It may only occur in my environment.
    Please let me know if you have any settings to check.

    #include <stdio.h>
    #include <string.h>
    
    
    /**
     * main.c
     */
    int main(void)
    {
    
        uint8_t buf[100];
    
        memset(buf, 0x00, 100);
    
        memcpy(buf, "123456789", 4);   // (1) OK
        memcpy(buf, "123456789", 5);   // (2) OK
        memcpy(buf, "123456789", 6);   // (3) OK
        memcpy(buf, "123456789", 7);   // (4) NG
        memcpy(buf, "123456789", 8);   // Unreachable
    
        return 0;
    }

    Thank you.

  • Koji,

    It is working fine on my side. All memcpy operations are performed. Please check the below screen shot:


    You can put one printf function and HW breakpoint, like in the screen shot I have sent.

    You can refer to below CCS settings for bare metal example in Cortex-A15:

    http://software-dl.ti.com/processor-sdk-rtos/esd/docs/latest/rtos/index_examples_demos.html#id47

    Regards,
    Pavel

  • software-dl.ti.com/.../index_examples_demos.html

    If you follow this procedure, the problem is reproduced.

    Looking at "Disassembly"
    80000264: FA00002C blx memcpy
    Executing the line stops the debugger.
    And the dialog as shown below will be displayed all the time.


    Note that the 7-byte copy fails, but the 8-byte copy succeeds.


    Also, if you create your own memcopy function "myMemcpy", the 7-byte copy succeeds.


    Is there anything else to check?

    Thank you.

  • Koji,

    Sorry but I am not able to understand your issue.

    Could you please provide me the exact steps you are using to reproduce the issue?

    Regards,
    Pavel

  • Thank you for your reply.
    The procedure is as follows.

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

    CCS Version: 7.4.0.00015

    1. Start CCS, right click on the Project Explorer, and create a new "CCS Project".
    2. Create a project with the following settings.
    ・ Target = “AM571x-Cortex A15: AM5716”
    ・ Project name = Test
    ・ Compiler version = GNU v6.3.1 (Linaro)
    ・ Tool-chain = default
    ・ Project templates and examples = Empty Project (with main.c)


    3. Write the following code in “main.c”.

    #include <stdio.h>
    #include <string.h>
    
    
    /**
     * main.c
     */
    int main(void)
    {
    
        uint8_t buf[100];
    
        memset(buf, 0x00, 100);
    
        memcpy(buf, "123456789", 4);   // (1) OK
        memcpy(buf, "123456789", 5);   // (2) OK
        memcpy(buf, "123456789", 6);   // (3) OK
        memcpy(buf, "123456789", 7);   // (4) NG
        memcpy(buf, "123456789", 8);   // Unreachable
    
    	return 0;
    }
    

    4. Build and generate “Test.out”.
    5. Connect to EVM. Connect to "Texas Instruments XDS100v2USB Debug Probe_0 / CortexA15_0"
    6. Load “Test.out”.
    7. Step execution will terminate the debugger at position (4).

  • koji fukumoto said:
    7. Step execution will terminate the debugger at position (4).

    Could you please provide more  details here. Do you have any error message? Can you provide a screen shot of the issue?

    What I can observe on my side, when I do step by step execution of the code through button "Step Over (F6)" is that only the last memcpy() operation (5th in our usecase) is executed, while 4 memcpy() operations are just skipped. But I am able to reach 5th memcpy() and able to execute it successful with step by step execution. Please check the screen shot below.

    Note that I am using CCS v9.1.0, GNU v7.2.1 (Linaro) toolchain and New–> CCS Project -> Basic Examples-> Hello World

    Regards,
    Pavel

  • Thank you for your reply.

    "7. Step execution will terminate the debugger at position (4)."
    At this point, no error message is displayed.
    See the first post for a screenshot.
    ("Disassembly Window" stops at "No debug context")
    -> The figure below shows when process 4 is executed.
         The debugger exits.


    I have discovered something new.
    When the compiler version was set to “Ti v16.9.11.Tls” in the project creation settings, all memcpy was executed correctly.
    "GNU v7.3.1" and "GNU v6.3.1 (Linaro)" will fail.

    "When memcpy function is executed with GNU compiler, 7 bytes cannot be copied"
    This is the problem.

    Fortunately, there is a workaround.
    ・ Use your own memcpy function
    ・ Use TI compiler

    However, I feel uneasy when the cause is unknown, so I want to solve it fundamentally.
    Please let me know if there are other things to check.

    Thank you.

  • Koji,

    I would suggest you to try with CCS v9.1.0. With this CCS version and GNU v7.2.1 (Linaro) toochain, I am able to process memcpy() function with 7 bytes. Please refer to below scree shots for reference.First one is just before memcpy(7) execution, second one is right after.


    Regards,
    Pavel

  • It was confirmed that memcpy works correctly with the combination of "CCS v9.1.0" and "GNU v7.2.1".
    Thank you very much.

    What is the cause?
    Is there a problem with the GNU compiler of "CCS v7.3.1"?

    I want to know the cause, because I have to tell the cause to the customer.

    Thank you.

  • Koji,

    I have the same successful execution of memcpy() function with 7 bytes, with CCS v9.1.0 and GNU v7.3.1 (Linaro).

    Regards,
    Pavel

  • It seems to occur only in my environment, what do you think is the cause?
    I think you can guess the cause better than me.
    Please let me know if there are any confirmation items necessary to guess the cause.

    Do you also verify with TMDXIDK5718?

    Thank you.

  • Koji,

    I suspect that using old version of CCS is the problem.

    What result you have for memcpy() function with 7 bytes, with CCS v9.1.0 and GNU v7.3.1 (Linaro) ?

    Regards,
    Pavel

  • I tried it again, but it failed in CCSv9.
    Previously it was successful.
    The result is not stable.
    There may be a problem on the board side.

    I tried the following combinations, but all "7byte memcpy" fails.
    ・CCSv7.4.0 x GNUv7.3.1
    ・CCSv7.4.0 x GNUv6.3.1(Linaro)
    ・CCSv9.1.0 x GNUv6.3.1(Linaro)
    ・CCSv9.1.0 x GNUv7.2.1(Linaro)
    ・CCSv9.1.0 x GNUv7.3.1(Linaro)


    Execute "7byte memcpy" and press the suspend button when there is no response.
    Then it stops at the lower capture position.
    I don't know what this means.
    Is it useful information for you?

    Thank you.

  • Koju,

    Regarding "CCSv9.1.0 x GNUv7.3.1(Linaro)", can you provide your latest C file?

    And what is the result when you are making step-by-step execution? If you have any error, can you make a screen shot of that error?

    koji fukumoto said:
    Is it useful information for you?

    Not at all.

    Regards,
    Pavel

  • Provides a complete project including C files.
    This is a project where “7byte memcpy” failed in “CCSv9.1.0 x GNUv7.3.1 (Linaro)”.

    Thank you.

    TEST20191202.zip

  • Koji,

    I have tested “7byte memcpy” on two TI board with CCS v9.1.0 and GNU v7.3.1 (Linaro):

    1. AM572x IDK rev1.3B, XDS100v2 JTAG emulator

    2. AM572x EVM revA3A, USB560M 20-pin JTAG emulator


    “7byte memcpy” operation is successful in both boards.

    What I observe is that ONLY the last memcpy() operation is executed. But the code never stuck and never fail with error. Let take for example your code:

    memcpy(buf, "123456789", 4);   // (1) OK
    memcpy(buf, "123456789", 5);   // (2) OK
    memcpy(buf, "123456789", 6);   // (3) OK
    memcpy(buf, "123456789", 7);   // (4) NG ---> not executed at all, but no stuck or error occur
    memcpy(buf, "123456789", 8);   // Unreachable  ---> it is reachable, but it is the only one executed


    From this code only the last "8byte memcpy" is executed, the rest 4 memcpy() functions are just skipped.

    If I remove the last "8byte memcpy", then "7byte memcpy” (which is now last) is executed successful. 

    memcpy(buf, "123456789", 4);   // (1) OK
    memcpy(buf, "123456789", 5);   // (2) OK
    memcpy(buf, "123456789", 6);   // (3) OK
    memcpy(buf, "123456789", 7);   // (4) NG  ----> it is executed successful, no stuck, no error
    //memcpy(buf, "123456789", 8);   // Unreachable


    If I leave only the first "4byte memcpy" function, it is successfully executed.


    To sum up, I will suggest you to use only one memcpy() function.


    Regards,
    Pavel