2014-10-29 3 views
3

Я использую MCU на базе ARM M3, CC2538. Я использую Code Composer Studio v6 в качестве среды IDE. Когда я выбираю GNU v4.7.4 (Linaro) в качестве компилятора, появляется предупреждающее сообщение о том, что «выбранное устройство в настоящее время не предоставляет детали инициализации проекта в инструментальную цепочку GNU». Я предполагаю, что это связано с setup.c (?), Которое будет добавлено позже.GNU-C toolchain setup.c для ARM Cortex M3

компилятор имеет следующие флаги

`"-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»»

ли исходный код есть ошибка? Я использую неправильный набор инструментов ли (я скачал инструмент цепь ГНУ от центра APP TI как «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

@Artless шум, спасибо. Я не мог понять, что не так, но он решает проблему, возможно, было бы неплохо опубликовать ее в качестве ответа. Поэтому я удалил «#include» setup.c «» на startup_gcc.c, затем добавлю #include и «#define SYS_CTRL_EMUOVR 0x400D20B4» теперь он компилируется правильно, а бинарный файл отлично работает на EVM. Это был код по умолчанию, это другой вопрос, TI, если они скомпилировать код перед публикацией кода :) – Angs

+0

Он по-прежнему выдает два предупреждения сообщение о том, Описание \t \t Resource Path \t \t Расположение Тип ../cc2538_512_gcc.cmd содержит выходные секции ; ты забыл? \t cc2328em_test \t \t \t C/C++ Задача не может найти символ входа _start; defaulting to 00200000 \t cc2328em_test \t \t \t C/C++ Problem Вы знаете, что с ними делать? – Angs

+0

не создавайте setup.c ... поскольку он уже включен в stup_gcc.c ... таким образом, он скомпилирован дважды ... или вы можете удалить include «setup.c» из setup_gcc/c – theadnangondal

ответ

2

Первая линия startup_gcc.c является #include "setup.c"; вы видите проблему? Не строите setup.c отдельно, если вы сделаете это.

Чтение сообщения об ошибке многократное определение '__cca' поможет; компьютеры редко лгут. Вы можете скомпилировать это дважды. Кроме того, ваш выходной раздел .flashcca в скрипте компоновщика не имеет входных файлов, и это должно быть исправлено.

Например,

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

Без *(.flashcca);, то .flashcca :{} > FLASH_CCA бесполезно. Первый .flashcca - это выходной раздел (т. Е. Место в конечном двоичном формате). Материал внутри скобок представляет собой раздел ввода (т. Е. Ваш источник/объект). Главный хор компоновщика должен взять несколько разделов ввода и поместить их в выходной раздел. Другая задача - вращать внешние символы; он не может этого сделать, когда он имеет два одинаковых имени; нет способа узнать, какой из них использовать. Вот почему у вас есть несколько определений '__cca'.