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/TM4C1294NCPDT: memset causing Fault in GCC compiler

Part Number: TM4C1294NCPDT


Tool/software: Code Composer Studio

Hello, 

Some background: 

I am using a custom board with the TM4C1294NCPDT chip. I have been using the TI TLS compilers for a number of years but had to switch to GNU v7.2.1 (Linaro) to get an important library to compile correctly. Due to this change I have moved all of my libraries to the GNU compiler and despite some cursing at my computer have been able to get the linker file to actually point at and start debugging at main(). 

My problem: 

After getting through clock initialization and pin initialization functions I have a function that requires the use of memset(PTR, int, size_t). It is at this point that my code faults into a NVIC_FAULT_STAT of 0x00080400 (No Coprocessor Usage Fault, and Imprecise Data Bus Fault). 

Things I have tried: 

1. Turning it on and off again. 

2. Making sure I have the libc.a library. 

3. Trying to figure out how to allocate more memory to the heap. (Still have no idea how to do this in GNU. )

4.  Creating a new project with only the call to memset (Couldnt get it to link correctly to main())

5. Looked on the forums for anything remotely similar. 

6. This post. 

Any help is appreciated at this point.

Daniel  

  • Can you set a breakpoint on the call to memset() that causes the issue? Once you hit that breakpoint, open a disassembly window and look for the assembly instruction that calls memset ( bl memset). Right click on that instruction and select run to line. Now view the registers. R0 should contain the address where memset() will start writing. R1 should contain the character that will be written and R2 should contain the number of bytes to write. The most likely culprit is the address not being correct.

  • Thank you for replying so quickly.

    Following your instructions I get the following: 

    R0 0x20003830 General Purpose Register 0 [Core]
    R1 0x000000CD General Purpose Register 1 [Core]
    R2 0x00000010 General Purpose Register 2 [Core]

    Disassembly: 

    0001b7ec: 2210           movs r2, #0x10
    0001b7ee: 21CD          movs r1, #0xcd
    0001b7f0: 68F8             ldr r0, [r7, #0xc]
    0001b7f2: F011FD35    bl #0x2d260  

    memset code: memset(m, 0xcd, MEMP_SANITY_REGION_BEFORE_ALIGNED); 

    R7 0x20025FA8 General Purpose Register 7 [Core]

    MEMP_SANITY_REGION_BEFORE_ALIGNED is defined to be 16. 


    If I am understanding this correctly it is writing 16 bytes to location m and the data is "205". 
    Is there a reason that it would fail to write to a location with more than enough space despite it not really needing all the space to write the data?

  • I agree with your analysis and don't see anything wrong with the parameters passed to meminit(). What is the value in the SP? Can you single step the assembly code until the exception happens?

  • SP 0x20025FA8 General Purpose Register 13 - Stack Pointer [Core]

    I can single step through the assembly the only problem is that once I get into memset() CCS says "Break at address "0x2d262" with no debug information available, or outside of program code." The assembly faults when i get to "FE99EBFF           .word       0xebfffe99" and register reads: 

    SP 0x20025FA8 General Purpose Register 13 - Stack Pointer [Core]

    R0 0x00000018 General Purpose Register 0 [Core]
    R1 0x000000CD General Purpose Register 1 [Core]
    R2 0x00000010 General Purpose Register 2 [Core]

    I did notice playing with memset() that something like "memset(&test[3], 0xcd, sizeof(char));" works but a call to test[3]'s address through a pointer variable does not. in this case test is a char array. 

  • I tried to recreate your issue with a simple test project, but had no issue. Can you import my project from the attached .zip file and run the GCC.out file without rebuilding? If that works, try rebuilding and running again. If my simple project is insufficient to recreate the problem, can you post a simple project. I suspect something is wrong with the settings used to build the library, but not sure what.

    /cfs-file/__key/communityserver-discussions-components-files/908/GCC.zip

  • You were correct on the settings for the libraries being wrong. I apparently removed a call to the library named "c" assuming that calls to libc.a, libm.a and other ones like that were sufficient. After adding c back into my library calls memset() does not cause a fault when using a pointer reference. 

    Im not sure why this would cause this problem, but it seems to be the fix. 

    Thank you for all the help! 

    Daniel