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: Math.h functions causing faultISR in GNU compiler

Part Number: TM4C1294NCPDT

Tool/software: Code Composer Studio

Hello, 

Issue: 

Use of functions like asin, fmod, and others are causing run time faults (NVIC_FAULT_STAT 0x00011400). 

Versions of Everything: 

GNU v7.2.1 (Linaro)

CCS Version: 9.0.1.00004 

TM4C1294ncpdt

XDS200 USB Debug Probe

Example Code: 

#include <stdint.h>
#include <math.h>


int main(void) {

double ans = 0, ang = 0.5;

ans = asin(0.5);// Works
ans = asin(ang); //Crashes

return 0;
}

Configuration: 

-mfloat-abi = hard

Directories: 

"${PROJECT_ROOT}"
"${CG_TOOL_INCLUDE_PATH}"

Libraries: 

c
${CG_TOOL_ROOT}\arm-none-eabi\lib\hard\libm.a

Ive tried: 

ang as a double, float, and int

using asinf, asinl

Using softfp and soft (with the lib appropriately changed)

If I could get any guidance on this it would be appreciated. I am fairly certain im not configuring something correctly but I have no idea what at this point in time. 

Test code included for any clarification: 

math_test.zip

Thank you, 

Daniel 

  • You say you use ...

    Daniel Norris said:
    -mfloat-abi = hard

    But the CCS project you attached uses -mfloat-abi=soft.  Try changing it back to -mfloat-abi=hard.

    Thanks and regards,

    -George

  • Hi George, 

    My apologies, the project I sent still had the soft change I used to verify that it in fact did not work using soft as well. The one attached should be as indicated above, and sadly still faulting. 

    math_test_hard.zip

    Thank you,

    Daniel 

  • Daniel,

    George asked me to take a second look at your project. I identified a non-compatible math library being assigned to your project, which was probably causing the Hard Fault exception to be triggered due to an invalid instruction.

    In this case, the correction is simple: in the linker include options, replace your existing line 

    ${CG_TOOL_ROOT}\arm-none-eabi\lib\hard\libm.a

    With a simple "m"

    With this, GCC will resolve this to the correct library based on the processor options, which is located at:

    c:/ti/ccs/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major-win32/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard\libm.a

    (this information is in the linker .map file, under the project's directory "Debug")

    This modification allowed me to run your project to the end. 

    Hope this helps,

    Rafael

  • Thank you Rafael, 

    That does fix the issue I was having with the math library causing a fault. 

    Daniel