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.

  • TI Thinks Resolved

CCS/TMDXIDK5718: Memcpy fails

Intellectual 870 points

Replies: 17

Views: 286

Part Number: TMDXIDK5718

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



  • In reply to Pavel Botev:

    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.

  • In reply to koji fukumoto:

    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



  • In reply to Pavel Botev:

    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.

  • In reply to koji fukumoto:

    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



  • In reply to Pavel Botev:

    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).

  • In reply to koji fukumoto:

    koji fukumoto
    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



  • In reply to Pavel Botev:

    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.

  • In reply to koji fukumoto:

    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



  • In reply to Pavel Botev:

    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.

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.