2014-10-29 96 views
3

我正在使用基於ARM M3的MCU CC2538。我使用Code Composer Studio v6作爲IDE。當我選擇GNU v4.7.4(Linaro)作爲編譯器時,我收到一條警告消息,指出「選定的設備當前沒有向GNU工具鏈提供項目初始化細節」。我認爲這是由於setup.c(?)將在稍後添加。ARM Cortex M3的GNU-C工具鏈setup.c問題

編譯器具有以下標誌

`"-mcpu=cortex-m3 -mthumb -mfpu=vfp -I"c:/ti/ccsv6/tools/compiler/gcc-arm-none-eabi-4_7-2013q3/arm-none-eabi/include" -g -gstrict-dwarf -Wall -mno -thumb-interwork -msoft-float -mfix-cortex-m3-ldrd" 

和連接器選項:-mthumb -g -gstrict-dwarf -Wall -Wl,-Map,"cc2328em_test.map"

我用TI http://www.ti.com/lit/zip/swra443

我添加main.c中提供的源文件,setup.c中,setup_gcc .c和cc2538_512.cmd寫入一個空白項目,然後編譯它。這裏是編譯輸出:

**** Build of configuration Debug for project cc2328em_test **** 

"c:\\ti\\ccsv6\\utils\\bin\\gmake" -k all 
'Building file: ../main.c' 
'Invoking: GNU Compiler' 
"c:/ti/ccsv6/tools/compiler/gcc-arm-none-eabi-4_7-2013q3/bin/arm-none-eabi-gcc.exe" -c -mcpu=cortex-m3 -mthumb -mfpu=vfp -I"c:/ti/ccsv6/tools/compiler/gcc-arm-none-eabi-4_7-2013q3/arm-none-eabi/include" -ffunction-sections -fdata-sections -g -gstrict-dwarf -Wall -MMD -MP -MF"main.d" -MT"main.d" -mno-thumb-interwork -msoft-float -mfix-cortex-m3-ldrd -fshort-enums -fomit-frame-pointer -fno-strict-aliasing -o"main.o" "../main.c" 
'Finished building: ../main.c' 
' ' 
'Building file: ../setup.c' 
'Invoking: GNU Compiler' 
"c:/ti/ccsv6/tools/compiler/gcc-arm-none-eabi-4_7-2013q3/bin/arm-none-eabi-gcc.exe" -c -mcpu=cortex-m3 -mthumb -mfpu=vfp -I"c:/ti/ccsv6/tools/compiler/gcc-arm-none-eabi-4_7-2013q3/arm-none-eabi/include" -ffunction-sections -fdata-sections -g -gstrict-dwarf -Wall -MMD -MP -MF"setup.d" -MT"setup.d" -mno-thumb-interwork -msoft-float -mfix-cortex-m3-ldrd -fshort-enums -fomit-frame-pointer -fno-strict-aliasing -o"setup.o" "../setup.c" 
'Finished building: ../setup.c' 
' ' 
'Building file: ../startup_gcc.c' 
'Invoking: GNU Compiler' 
"c:/ti/ccsv6/tools/compiler/gcc-arm-none-eabi-4_7-2013q3/bin/arm-none-eabi-gcc.exe" -c -mcpu=cortex-m3 -mthumb -mfpu=vfp -I"c:/ti/ccsv6/tools/compiler/gcc-arm-none-eabi-4_7-2013q3/arm-none-eabi/include" -ffunction-sections -fdata-sections -g -gstrict-dwarf -Wall -MMD -MP -MF"startup_gcc.d" -MT"startup_gcc.d" -mno-thumb-interwork -msoft-float -mfix-cortex-m3-ldrd -fshort-enums -fomit-frame-pointer -fno-strict-aliasing -o"startup_gcc.o" "../startup_gcc.c" 
'Finished building: ../startup_gcc.c' 
' ' 
'Building target: cc2328em_test.out' 
'Invoking: GNU Linker' 
"c:/ti/ccsv6/tools/compiler/gcc-arm-none-eabi-4_7-2013q3/bin/arm-none-eabi-gcc.exe" -mthumb -ffunction-sections -fdata-sections -g -gstrict-dwarf -Wall -Wl,-Map,"cc2328em_test.map" -nostartfiles -mcpu=cortex-m3 -mthumb -ffunction-sections -fdata-sections -g -gstrict-dwarf -Wall -o"cc2328em_test.out" "./main.o" "./setup.o" "./startup_gcc.o" "../cc2538_512_gcc.cmd" -Wl,--start-group -l"c" -l"gcc" -l"nosys" -Wl,--end-group 
./startup_gcc.o:(.flashcca+0x0): multiple definition of `__cca' 
./setup.o:(.flashcca+0x0): first defined here 
c:/ti/ccsv6/tools/compiler/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/bin/ld.exe: warning: ../cc2538_512_gcc.cmd contains output sections; did you forget -T? 
c:/ti/ccsv6/tools/compiler/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/bin/ld.exe: cc2328em_test.out section `.flashcca' will not fit in region `FLASH_CCA' 
c:/ti/ccsv6/tools/compiler/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/bin/ld.exe: region `FLASH_CCA' overflowed by 12 bytes 
c:/ti/ccsv6/tools/compiler/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/bin/ld.exe: warning: cannot find entry symbol _start; defaulting to 00200000 
collect2.exe: error: ld returned 1 exit status 
gmake: *** [cc2328em_test.out] Error 1 
gmake: Target `all' not remade because of errors. 

**** Build Finished **** 

這裏是第一錯誤 「./startup_gcc.o:(.flashcca+0x0):`__cca」的多個定義

是否源代碼有一個失誤?難道我用錯了工具鏈(我下載TI的APP中心GNU工具鏈「ARM GCC」與GCC標誌還是我錯過任何配置


這裏是源文件TI用品:?

的main.c

#define GPIO_C_DIR    0x400DB400 
#define GPIO_C_DATA    0x400DB000 

#define HWREG(x)                \ 
    (*((volatile unsigned long *)(x))) 

int main(void) 
{ 
    volatile unsigned long ulLoopCount; 

    // Set direction output and initial value for PC2 and PC0 
    // Greed LED on PC2 
    // Red LED on PC0 
    HWREG(GPIO_C_DIR) |= 0x05; 
    HWREG(GPIO_C_DATA + (0x05 << 2)) = 0; 

    // Loop forever. 
    while(1) 
    { 
     // Turn on both LED's. 
     HWREG(GPIO_C_DATA + (0x05 << 2)) ^= 0x05; 

     // Delay for a bit 
     for(ulLoopCount = 200000; ulLoopCount > 0; ulLoopCount--) 
     { 
     } 
    } 

    return 0; 
} 

setup.c中

#include <stdint.h> 

#define FLASH_START_ADDR    0x00200000 
#define BOOTLOADER_BACKDOOR_DISABLE  0xEFFFFFFF 
#define SYS_CTRL_EMUOVR     0x400D20B4 
#define SYS_CTRL_I_MAP     0x400D2098 


//***************************************************************************** 
// 
// Customer Configuration Area in Lock Page 
// Holds Image Vector table address (bytes 2013 - 2015) and 
// Image Valid bytes (bytes 2008 -2011) 
// 
//***************************************************************************** 
typedef struct 
{ 
    uint32_t ui32BootldrCfg; 
    uint32_t ui32ImageValid; 
    uint32_t ui32ImageVectorAddr; 
} 
lockPageCCA_t; 

#ifdef __IAR_SYSTEMS_ICC__ 
__root const lockPageCCA_t __cca @ ".flashcca" = 
#elif __TI_COMPILER_VERSION__ 
#pragma DATA_SECTION(__cca, ".flashcca") 
#pragma RETAIN(__cca) 
const lockPageCCA_t __cca = 
#else 
__attribute__ ((section(".flashcca"), used)) 
const lockPageCCA_t __cca = 
#endif 
{ 
    BOOTLOADER_BACKDOOR_DISABLE, // Bootloader backdoor disabled 
    0,       // Image valid bytes 
    FLASH_START_ADDR    // Vector table located at flash start address 
}; 

startup_gcc.c

#include "setup.c" 


//***************************************************************************** 
// 
// Macro for hardware access, both direct and via the bit-band region. 
// 
//***************************************************************************** 
#ifndef HWREG 
#define HWREG(x)                \ 
     (*((volatile unsigned long *)(x))) 
#endif 


extern int main (void); 

void ResetISR(void); 
void NmiSR(void); 
void FaultISR(void); 
void IntDefaultHandler(void); 

//***************************************************************************** 
// 
// Reserve space for the system stack. 
// 
//***************************************************************************** 
static uint32_t pui32Stack[128]; 



__attribute__ ((section(".vectors"), used)) 
void (* const gVectors[])(void) = 
{ 
    (void (*)(void))((uint32_t)pui32Stack + sizeof(pui32Stack)), // Stack pointer 
    ResetISR,        // Reset handler 
    NmiSR,         // The NMI handler 
    FaultISR,        // The hard fault handler 
    IntDefaultHandler,      // 4 The MPU fault handler 
    IntDefaultHandler,      // 5 The bus fault handler 
    IntDefaultHandler,      // 6 The usage fault handler 
    0,          // 7 Reserved 
    0,          // 8 Reserved 
    0,          // 9 Reserved 
    0,          // 10 Reserved 
    IntDefaultHandler,      // 11 SVCall handler 
    IntDefaultHandler,      // 12 Debug monitor handler 
    0,          // 13 Reserved 
    IntDefaultHandler,      // 14 The PendSV handler 
    IntDefaultHandler,      // 15 The SysTick handler 
    IntDefaultHandler,      // 16 GPIO Port A 
    IntDefaultHandler,      // 17 GPIO Port B 
    IntDefaultHandler,      // 18 GPIO Port C 
    IntDefaultHandler,      // 19 GPIO Port D 
    0,          // 20 none 
    IntDefaultHandler,      // 21 UART0 Rx and Tx 
    IntDefaultHandler,      // 22 UART1 Rx and Tx 
    IntDefaultHandler,      // 23 SSI0 Rx and Tx 
    IntDefaultHandler,      // 24 I2C Master and Slave 
    0,          // 25 Reserved 
    0,          // 26 Reserved 
    0,          // 27 Reserved 
    0,          // 28 Reserved 
    0,          // 29 Reserved 
    IntDefaultHandler,      // 30 ADC Sequence 0 
    0,          // 31 Reserved 
    0,          // 32 Reserved 
    0,          // 33 Reserved 
    IntDefaultHandler,      // 34 Watchdog timer, timer 0 
    IntDefaultHandler,      // 35 Timer 0 subtimer A 
    IntDefaultHandler,      // 36 Timer 0 subtimer B 
    IntDefaultHandler,      // 37 Timer 1 subtimer A 
    IntDefaultHandler,      // 38 Timer 1 subtimer B 
    IntDefaultHandler,      // 39 Timer 2 subtimer A 
    IntDefaultHandler,      // 40 Timer 2 subtimer B 
    IntDefaultHandler,      // 41 Analog Comparator 0 
    IntDefaultHandler,      // 42 RFCore Rx/Tx 
    IntDefaultHandler,      // 43 RFCore Error 
    IntDefaultHandler,      // 44 IcePick 
    IntDefaultHandler,      // 45 FLASH Control 
    IntDefaultHandler,      // 46 AES 
    IntDefaultHandler,      // 47 PKA 
    IntDefaultHandler,      // 48 Sleep Timer 
    IntDefaultHandler,      // 49 MacTimer 
    IntDefaultHandler,      // 50 SSI1 Rx and Tx 
    IntDefaultHandler,      // 51 Timer 3 subtimer A 
    IntDefaultHandler,      // 52 Timer 3 subtimer B 
    0,          // 53 Reserved 
    0,          // 54 Reserved 
    0,          // 55 Reserved 
    0,          // 56 Reserved 
    0,          // 57 Reserved 
    0,          // 58 Reserved 
    0,          // 59 Reserved 
    IntDefaultHandler,      // 60 USB 2538 
    0,          // 61 Reserved 
    IntDefaultHandler,      // 62 uDMA 
    IntDefaultHandler,      // 63 uDMA Error 
#ifndef CC2538_USE_ALTERNATE_INTERRUPT_MAP 
    0,          // 64 64-155 are not in use 
    0,          // 65 
    0,          // 66 
    0,          // 67 
    0,          // 68 
    0,          // 69 
    0,          // 70 
    0,          // 71 
    0,          // 72 
    0,          // 73 
    0,          // 74 
    0,          // 75 
    0,          // 76 
    0,          // 77 
    0,          // 78 
    0,          // 79 
    0,          // 80 
    0,          // 81 
    0,          // 82 
    0,          // 83 
    0,          // 84 
    0,          // 85 
    0,          // 86 
    0,          // 87 
    0,          // 88 
    0,          // 89 
    0,          // 90 
    0,          // 91 
    0,          // 92 
    0,          // 93 
    0,          // 94 
    0,          // 95 
    0,          // 96 
    0,          // 97 
    0,          // 98 
    0,          // 99 
    0,          // 100 
    0,          // 101 
    0,          // 102 
    0,          // 103 
    0,          // 104 
    0,          // 105 
    0,          // 106 
    0,          // 107 
    0,          // 108 
    0,          // 109 
    0,          // 110 
    0,          // 111 
    0,          // 112 
    0,          // 113 
    0,          // 114 
    0,          // 115 
    0,          // 116 
    0,          // 117 
    0,          // 118 
    0,          // 119 
    0,          // 120 
    0,          // 121 
    0,          // 122 
    0,          // 123 
    0,          // 124 
    0,          // 125 
    0,          // 126 
    0,          // 127 
    0,          // 128 
    0,          // 129 
    0,          // 130 
    0,          // 131 
    0,          // 132 
    0,          // 133 
    0,          // 134 
    0,          // 135 
    0,          // 136 
    0,          // 137 
    0,          // 138 
    0,          // 139 
    0,          // 140 
    0,          // 141 
    0,          // 142 
    0,          // 143 
    0,          // 144 
    0,          // 145 
    0,          // 146 
    0,          // 147 
    0,          // 148 
    0,          // 149 
    0,          // 150 
    0,          // 151 
    0,          // 152 
    0,          // 153 
    0,          // 154 
    0,          // 155 
    IntDefaultHandler,      // 156 USB 
    IntDefaultHandler,      // 157 RFCORE RX/TX 
    IntDefaultHandler,      // 158 RFCORE Error 
    IntDefaultHandler,      // 159 AES 
    IntDefaultHandler,      // 160 PKA 
    IntDefaultHandler,      // 161 SMTimer 
    IntDefaultHandler,      // 162 MACTimer 
#endif 
}; 

//***************************************************************************** 
// 
// The following are constructs created by the linker, indicating where the 
// the "data" and "bss" segments reside in memory. The initializers for the 
// for the "data" segment resides immediately following the "text" segment. 
// 
//***************************************************************************** 
extern uint32_t _etext; 
extern uint32_t _data; 
extern uint32_t _edata; 
extern uint32_t _bss; 
extern uint32_t _ebss; 

// 
// And here are the weak interrupt handlers. 
// 
void 
NmiSR (void) 
{ 
    ResetISR(); 
    while(1) 
    { 
    } 
} 


void 
FaultISR (void) 
{ 
    while(1) 
    { 
    } 
} 


void 
IntDefaultHandler (void) 
{ 
    while(1) 
    { 
    } 
} 

void 
ResetISR (void) 
{ 
    uint32_t *pui32Src, *pui32Dest; 

    // 
    // Workaround for PM debug issue 
    // 
    HWREG(SYS_CTRL_EMUOVR) = 0xFF; 

    // 
    // Copy the data segment initializers from flash to SRAM. 
    // 
    pui32Src = &_etext; 
    for(pui32Dest = &_data; pui32Dest < &_edata;) 
    { 
     *pui32Dest++ = *pui32Src++; 
    } 

    // 
    // Zero fill the bss segment. 
    // 
    __asm(" ldr  r0, =_bss\n" 
      " ldr  r1, =_ebss\n" 
      " mov  r2, #0\n" 
      " .thumb_func\n" 
      "zero_loop:\n" 
      "  cmp  r0, r1\n" 
      "  it  lt\n" 
      "  strlt r2, [r0], #4\n" 
      "  blt  zero_loop"); 

#ifdef CC2538_USE_ALTERNATE_INTERRUPT_MAP 
    // 
    // Enable alternate interrupt mapping 
    // 
    HWREG(SYS_CTRL_I_MAP) |= 1; 
#endif 

    // 
    // Call the application's entry point. 
    // 
    main(); 

    // 
    // End here if return from main() 
    // 
    while(1) 
    { 
    } 
} 

cc2538_512_gcc.cmd

/****************************************************************************** 
* 
* 
* cc2538_512_gcc.cmd - Example GCC linker configuration file for CC2538 
* 
* 
*****************************************************************************/ 

MEMORY 
{ 
    FLASH (rx) : ORIGIN = 0x200000, LENGTH = 0x0007FFD4 
    FLASH_CCA (RX) : ORIGIN = 0x0027FFD4, LENGTH = 12 
    SRAM_NON_RETENTION (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00004000 
    SRAM_RETENTION (RWX) : ORIGIN = 0x20004000, LENGTH = 0x00004000 
} 

SECTIONS 
{ 
    .text : 
    { 
     _text = .; 
     KEEP(*(.vectors)) 
     *(.text*) 
     *(.rodata*) 
     _etext = .; 
    } > FLASH= 0 
    .data : AT(ADDR(.text) + SIZEOF(.text)) 
    { 
     _data = .; 
     *(vtable) 
     *(.data*) 
     _edata = .; 
    } > SRAM_NON_RETENTION 
    .bss : 
    { 
     _bss = .; 
     *(.bss*) 
     *(COMMON) 
     _ebss = .; 
    } > SRAM_NON_RETENTION 
    .flashcca : 
    { 
    } > FLASH_CCA 
} 

這裏是一個PRINTSCREEN示出的配置和左側菜單 enter image description here

+0

@藝術噪音,謝謝。我不明白什麼是錯誤的,但它解決了這個問題,將它作爲答案發布可能是件好事。因此,我在startup_gcc.c中刪除了「#include」setup.c「」,然後添加#include 和「#define SYS_CTRL_EMUOVR 0x400D20B4」,現在它編譯正確,並且二進制文件在EVM上正常工作。這是默認的代碼,這是TI另外一個問題,如果他們發佈的代碼:) – Angs 2014-10-29 16:01:44

+0

之前編譯代碼它仍然輸出兩個警告消息,說明\t資源\t路徑\t位置\t類型 ../cc2538_512_gcc.cmd包含輸出部分;你忘了 - T? \t cc2328em_test \t \t \t C/C++問題 無法找到條目符號_start;默認爲00200000 \t cc2328em_test \t \t \t C/C++問題 你知道該怎麼處理它們嗎? – Angs 2014-10-29 16:02:25

+0

不會構建setup.c ...,因爲它已經包含在stup_gcc.c中......這樣它會被編譯兩次......或者您可以從setup_gcc/c中刪除包含「setup.c」的文件。 – theadnangondal 2015-04-24 07:51:58

回答

2

在相關文件startup_gcc.c的第一行是#include "setup.c";你有沒有看到問題?如果你這樣做,不要單獨建立setup.c

閱讀錯誤信息多重定義'__cca'將有所幫助;電腦很少說謊。你可以編譯兩次。另外,鏈接描述文件中的輸出部分.flashcca沒有輸入文件,應該修復此問題。

例如,

.flashcca :{*(.flashcca);} > FLASH_CCA 

沒有*(.flashcca);,所述.flashcca :{} > FLASH_CCA是無用的。第一個.flashcca是一個輸出段(即最後二進制中的某個地方)。括號內的東西是輸入部分(即您的源/對象)。鏈接器的主要合唱團是將多個輸入部分放置在輸出部分。另一項工作是旋轉外部符號;當它提供了兩個相同的名稱時,它不能這樣做;沒有辦法知道使用哪個。這就是爲什麼你有'__cca'的多重定義