我正在使用基于ARM M3的MCU CC2538。我使用Code Composer Studio v6作为IDE。当我选择GNU v4.7.4(Linaro)作为编译器时,我收到一条警告消息"所选设备当前不向GNU工具链提供项目初始化详细信息"。我认为这是由于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
}
这是一个打印屏幕,显示左侧菜单中的配置和相关文件
答案 0 :(得分:2)
startup_gcc.c的第一行是#include "setup.c"
;你看到了什么问题吗?如果您这样做,请不要单独构建 setup.c 。
阅读错误消息&#39; __ cca&#39; 的多个定义将有所帮助;电脑很少说谎。你可以编译两次。此外,链接描述文件中的 .flashcca 输出部分没有输入文件,应修复此问题。
例如,
.flashcca :{*(.flashcca);} > FLASH_CCA
如果没有*(.flashcca);
,.flashcca :{} > FLASH_CCA
就没用了。第一个 .flashcca 是输出部分(即最终二进制中的某个位置)。括号内的内容是输入节(即您的源/对象)。链接器的主要合唱者是获取多个输入节并将它们放在输出节中。另一项工作是旋转外部符号;当它有两个相同的名字时,它不能这样做;没有办法知道使用哪个。这就是为什么你有&#39; __ cca&#39; 的多重定义。