gcc - GNU-C toolchain setup.c issue for ARM Cortex M3 -



gcc - GNU-C toolchain setup.c issue for ARM Cortex M3 -

i using arm m3 based mcu, cc2538. utilize code composer studio v6 ide. when select gnu v4.7.4 (linaro) compiler, warning message " selected device not provide project initialization details gnu toolchain". assume due setup.c(?) added later on.

the compiler has next flags

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

and linker flags: -mthumb -g -gstrict-dwarf -wall -wl,-map,"cc2328em_test.map"

i utilize source files provided ti http://www.ti.com/lit/zip/swra443

i add together main.c, setup.c, setup_gcc.c, , cc2538_512.cmd empty project, compile it. here compile output:

**** build of configuration debug project cc2328em_test **** "c:\\ti\\ccsv6\\utils\\bin\\gmake" -k '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 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' not fit in part `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: part `flash_cca' overflowed 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 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 ****

here first error "./startup_gcc.o:(.flashcca+0x0): multiple definition of `__cca'"

does source code have mistake? utilize wrong toolchain (i downloaded gnu tool chain ti's app center "arm gcc" gcc logo. or miss configuration?

here source files ti supplies:

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 , initial value pc2 , pc0 // greed led on pc2 // reddish 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 bit for(ulloopcount = 200000; ulloopcount > 0; ulloopcount--) { } } homecoming 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 //***************************************************************************** // // client configuration area in lock page // holds image vector table address (bytes 2013 - 2015) , // 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 @ flash start address };

startup_gcc.c

#include "setup.c" //***************************************************************************** // // macro hardware access, both direct , via 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 scheme 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, // nmi handler faultisr, // hard fault handler intdefaulthandler, // 4 mpu fault handler intdefaulthandler, // 5 bus fault handler intdefaulthandler, // 6 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 pendsv handler intdefaulthandler, // 15 systick handler intdefaulthandler, // 16 gpio port intdefaulthandler, // 17 gpio port b intdefaulthandler, // 18 gpio port c intdefaulthandler, // 19 gpio port d 0, // 20 none intdefaulthandler, // 21 uart0 rx , tx intdefaulthandler, // 22 uart1 rx , tx intdefaulthandler, // 23 ssi0 rx , tx intdefaulthandler, // 24 i2c master , 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 intdefaulthandler, // 36 timer 0 subtimer b intdefaulthandler, // 37 timer 1 subtimer intdefaulthandler, // 38 timer 1 subtimer b intdefaulthandler, // 39 timer 2 subtimer 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 command intdefaulthandler, // 46 aes intdefaulthandler, // 47 pka intdefaulthandler, // 48 sleep timer intdefaulthandler, // 49 mactimer intdefaulthandler, // 50 ssi1 rx , tx intdefaulthandler, // 51 timer 3 subtimer 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 not in utilize 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 }; //***************************************************************************** // // next constructs created linker, indicating // "data" , "bss" segments reside in memory. initializers // "data" segment resides next "text" segment. // //***************************************************************************** extern uint32_t _etext; extern uint32_t _data; extern uint32_t _edata; extern uint32_t _bss; extern uint32_t _ebss; // // , here 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 pm debug issue // hwreg(sys_ctrl_emuovr) = 0xff; // // re-create info segment initializers flash sram. // pui32src = &_etext; for(pui32dest = &_data; pui32dest < &_edata; ) { *pui32dest++ = *pui32src++; } // // 0 fill 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" " 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 // // phone call application's entry point. // main(); // // end here if homecoming main() // while(1) { } }

cc2538_512_gcc.cmd

/****************************************************************************** * * * cc2538_512_gcc.cmd - illustration gcc linker configuration file 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 }

here printscreen shows configurations , related files on left side menu

the first line of startup_gcc.c #include "setup.c"; see problem? don't build setup.c separately if this.

reading error message multiple definition of '__cca' help; computers lie. can compile twice. also, .flashcca output section in linker script has no input files , should fixed.

for example,

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

without *(.flashcca);, .flashcca :{} > flash_cca useless. first .flashcca output section (ie. place in final binary). stuff within brackets input section (ie, source/object). major choir of linker take multiple input sections , place them in output section. other job revolve external symbols; can not when has 2 of same name provided; there no way know on use. why have multiple definition of '__cca'.

c gcc arm texas-instruments gnu-toolchain

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -