0
\$\begingroup\$

I have the following

Tiva C Board (TM4C123GXL) Code Composer Studio v6 using GCC

Compiling this sample code:

/*
 * main.c
 */
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"

int main(void)
{
    uint8_t ui8LED = 2;
    SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
    while(1)
    {
        // Turn on the LED
        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, ui8LED);
        // Delay for a bit
        SysCtlDelay(2000000);
        // Cycle through Red, Green and Blue LEDs
        if (ui8LED == 8) {ui8LED = 2;} else {ui8LED = ui8LED*2;}
    }
}

This sample code is provided within the TivaWare works fine with the TI compiler (following all the steps in the workshop pdf). When I choose to compile with GCC using, If I do not include the driverlib.lib file it says undefined reference to the functions used above. If I include it it says two errors on the four functions

error: C:/ti/TivaWare_C_Series-2.1.0.12573/driverlib/ccs/Debug/driverlib.lib(cpu.obj) uses VFP register arguments, Test.out does not

failed to merge target specific data of file C:/ti/TivaWare_C_Series-2.1.0.12573/driverlib/ccs/Debug/driverlib.lib(cpu.obj)

I think everything should be fine when using TI compiler but I want to try GCC.

\$\endgroup\$
  • \$\begingroup\$ BTW (in addition to my answer), which build of GCC are you using? When I was setting up my environment for the very same chip, I've found that not every build claiming to support Cortex-M4 would support Cortex-M4F. \$\endgroup\$ – Eugene Sh. Dec 15 '14 at 17:18
2
\$\begingroup\$

The driverlib in your case is compiled using the Floating Point Unit (FPU), while the target project does not. Try adding -mfloat-abi=hard -mfpu=fpv4-sp-d16 flags or recompiling driverlib without hardware FPU. In any case the FPU settings should be identical when compiling the library and the project.
UPD: If these flags do not work, the calling convention could be different. So you can try -mfloat-abi=soft -mfpu=fpv4-sp-d16 or -mfloat-abi=softfp -mfpu=fpv4-sp-d16
UPD2: And yes, you might need to clean the project before recompiling.

\$\endgroup\$
  • \$\begingroup\$ I added your flags to the compiler but still the error persists. \$\endgroup\$ – 3bdalla Dec 15 '14 at 17:38
  • \$\begingroup\$ Look at the update \$\endgroup\$ – Eugene Sh. Dec 15 '14 at 17:42
  • \$\begingroup\$ But for my opinion the best thing you can do is to recompile the driverlib with the needed settings. \$\endgroup\$ – Eugene Sh. Dec 15 '14 at 17:43
  • \$\begingroup\$ The problem still exists after all your steps. Here is the flags the gcc is using: -mcpu=cortex-m4 -mthumb -mfloat-abi=soft -mfpu=fpv4-sp-d16 -DPART_TM4C123GH6PM -I"c:/ti/ccsv6/tools/compiler/gcc-arm-none-eabi-4_7-2013q3/arm-none-eabi/include" -I"C:/ti/TivaWare_C_Series-2.1.0.12573/" -ffunction-sections -fdata-sections -g -gstrict-dwarf -Wall I tried all your suggested flags and still gives an error \$\endgroup\$ – 3bdalla Dec 15 '14 at 20:11
  • \$\begingroup\$ Now that's weird. It is clearly the error with fpu instructions calling convention, so either of these flags should help. Have you cleaned the project between the recompilations? Make sure that object files are deleted. \$\endgroup\$ – Eugene Sh. Dec 15 '14 at 20:20
2
\$\begingroup\$

The driverlib folder contains the pre built driverlib library for both the CCS compiler and the GCC, the problem I was importing the CCS version of the library.

In the directory C:\ti\TivaWare_C_Series-2.1.0.12573 [Assuming you installed it to the C] go to driverlib/gcc, you will find the library for the gcc compiler.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.