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.

FPU check will not catch enabled FPU

Other Parts Discussed in Thread: TM4C1294NCPDT

I want to be clear on how to enable the FPU with the TM4C129x (specifically the connected launchpad). I have enabled the _FPU_PRESENT=1 in code composer under predefined symbols and the core_cm4.h files in the CMSIS DSP library still gives me "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"

I can run the program if I set the floating point support to vfplib but I can only run it if I don't include the float array. I think this has to deal with the FPU enabling.

I am trying to do an fft on data from the ADC. I am retrieving the data and then trying to cast it into a float32_t array. I am very new to microcontrollers and even newer to Tiva launchpads. When the vfplib is set as my floating point support the ADC will retrieve data but as soon as I try to use the float32_t array in the main the program FaultISR. I know using vfplib is incorrect however and I want to know and learn how to correctly enable the FPU. I followed the exact rules on the CMSIS with Tiva document provided and the results are the same. 

With all of that I have several questions that maybe will help me resolve the issue.

1. When building the CMSIS library is all that needs to be defined in the predefined symbols _FPU_PRESENT and ARM_MATH_CM4?

2. Is there anything I need to change in the arm_math.h header files?

3. If the answer to those questions are yes and no respectively then what is the next step I need to take?

I have tried to be as detailed as possible without posting code (which isn't really anything considering I can't get the FPU to work properly). If there is any other detail I need to add in order to troubleshoot this problem I will be glad to do so.

  • As described in the CMSIS header (arm_math.h), it is sufficient to define both ARM_MATH_CM4 and _FPU_PRESENT to build the CMSIS code for a M4 core, and with FPU code. You don't need to change the CMSIS header (they are not intended to be changed by the user).

    However, this does not enable the FPU, which is an optional part of the M4 core, and by default disabled after POR. To enable the FPU, you have to tweak some system registers. You can check out either TI's manuals or ARM's core reference manuals on how to do this, but in most cases, the toolchain comes with a version of the startup code (usually as assembler code) which does that for you. One has to define this somewhere in the project settings, and the proper startup code is automatically selected. Now, how that is done in CCS is beyond my knowledge - I'm using Crossworks. Perhaps some more CCS-experienced guys can help here (or check the help tutorials).

    And BTW, the project settings ("wizards") usually have another option to choose the floating point ABI ("soft","softfp" or "hard"), which influences what libraries (especially which version of "libm.a") the project is linked against.

    Additionally, be aware about issues when using the FPU in normal code and interrupts (keyword "lazy stacking") !

  • Hello Jordan.

    Before starting the code in my application, I use FPUEnable and FPULazyStackingEnable and I do not see a FaultISR when using floating point arrays.

    Regards
    Amit
  • The problem first comes with trying to build the CMSIS dsp library. If I am not supposed to change the arm header files and _FPU_PRESENT and ARM_MATH_CM4 are enabled in CCS then the library should build. I am not supposed to enable FPU with FPUEnable() except for in my own source sode and project, correct? My DSP library will not build and maybe I need to enable something in that project so that it knows that the registers will be enabled once I write my own code. I am quite confused by this still. I know this is an error on my part I just can't seem to find where I am making it.

    So maybe let's start with just the library. In CCS I have enabed _FPU_PRESENT and ARM_MATH_CM4. From my understanding there should not be a startup file for a static library. What do I need to change in order to either make the core_cm4.h file see that FPU is enabled or actually enable the FPU(which is what I am guessing I am doing wrong)?
  • Jordan Alexander said:
    My DSP library will not build

    That's rather too vague a problem statement.  The ways in which a library will not build is legion. 

    I can't help with CCS specifics but you are going to need error messages etc.. to help people narrow it down a bit.

    Robert

  • The only error that was given was the "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" which comes directly from the core_cmr.h file. The specific error code that is given I do not know at the moment. I am working on a clean install of everything to try to find and eradicate my problem. That however was the only error given. That is the error that is given when building the library after following the TI instructions for building the CMSIS DSP library word for word line by line. I understand that what I have given isn't a lot to go off of but that is the nature of troubleshooting. If there is anything else that anyone can think of please continue to reply. Also, as soon as I am able I will post screen shots of everything that I have done and maybe that will help more.
  • Hi,

    Please see also this application note: 

  • //////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////
    >> Compilation failure
    gmake: *** [BasicMathFunctions/arm_sub_q31.obj] Error 1
    'Building file: C:/CMSIS-SP-00300-r4p5-00rel0/CMSIS/DSP_Lib/Source/BasicMathFunctions/arm_sub_q7.c'
    'Invoking: ARM Compiler'
    "C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 --abi=eabi -me -O2 --opt_for_speed=1 --include_path="C:/ti/TivaWare_C_Series-2.1.1.71" --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include" --include_path="C:/CMSIS-SP-00300-r4p5-00rel0/CMSIS/Include" -g --gcc --define=ccs="ccs" --define=ARM_MATH_CM4 --define=_FPU_PRESENT=1 --define=PART_TM4C1294NCPDT --diag_wrap=off --diag_warning=225 --gen_func_subsections=on --ual --preproc_with_compile --preproc_dependency="BasicMathFunctions/arm_sub_q7.pp" --obj_directory="BasicMathFunctions" "C:/CMSIS-SP-00300-r4p5-00rel0/CMSIS/DSP_Lib/Source/BasicMathFunctions/arm_sub_q7.c"
    "C:\CMSIS-SP-00300-r4p5-00rel0\CMSIS\Include\core_cm4.h", line 180: fatal error: #error directive: "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
    1 catastrophic error detected in the compilation of "C:/CMSIS-SP-00300-r4p5-00rel0/CMSIS/DSP_Lib/Source/BasicMathFunctions/arm_sub_q7.c".
    Compilation terminated.

    >> Compilation failure
    gmake: *** [BasicMathFunctions/arm_sub_q7.obj] Error 1
    gmake: Target `all' not remade because of errors.

    **** Build Finished ****
    //////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////

    This is the precise error that I'm getting for every one of the functions in the library(obviously). I know this means that I am failing at enabling the FPU but I'm not sure that I understand how I'm supposed to enable it for a static library. At the same time I have to build it the library in order to use it. I read in the data sheet about the register manipulation that must occur. Which from my understanding is what the following instruction does:

    ; CPACR is located at address 0xE000ED88
    LDR.W R0, =0xE000ED88
    ; Read CPACR
    LDR R1, [R0]
    ; Set bits 20-23 to enable CP10 and CP11 coprocessors
    ORR R1, R1, #(0xF << 20)
    ; Write back the modified value to the CPACR
    STR R1, [R0]; wait for store to complete
    DSB
    ;reset pipeline now the FPU is enabled
    ISB

    I believe that this needs to be placed in a startup file (I could be wrong I haven't gotten to this point). I want to continue focusing on the building of the dsp lib. Here are screenshots of all of the windows in which I modified following the instructions from TI.

    http://imgur.com/a/K6PQb
  • Now that's a lot better than it doesn't build. Hopefully someone can suggest a way forward from that.

    Robert
  • Btw, this appears not to be an issue with a startup file. That would give you a link or runtime error. This is indicating a configuration error. Whatever CPU/core configuration you have setup is either noted as not having an fpu or is not noted as having one, depending on how the configuration works. One obvious way for this to happen is if your CPU is newer than the library.

    Robert
  • Well after a week of chasing an over complicated error I found out the problem. "_FPU_PRESENT=1" is incorrect. There is a missing underscore. The core definition is "__FPU_PRESENT=1" (notice the extra underscore in the front. One underscore set me back so much time but I guess that is the nature of coding. Thanks for trying to help anyway.