I have been trying to get my Arduino/Eclipse environment setup. For some reason I keep having trouble with the linker.
Here is the error I receive when trying to build.
So there is a conflict between libgcc and libc?
I have followed these instructions pretty close, but there are some nuances.
**** Build of configuration Debug for project CustomLEDPoi ****
make all
Building target: CustomLEDPoi.elf
Invoking: AVR C++ Linker
avr-gcc -Wl,-Map,CustomLEDPoi.map,--cref -Wl,--gc-sections -L"C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino" -L"C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src" -Xlinker -verbose -mmcu=atmega328p -o "CustomLEDPoi.elf" ./src/glowstick2.o ./lib/CShiftPWM.o ./lib/MeetAndroid.o ./lib/hsv2rgb.o ./arduinolib/HardwareSerial.o ./arduinolib/SPI.o -lArduinoCore
GNU ld (WinAVR 20081205) 2.19
Supported emulations:
avr2
avr1
avr25
avr3
avr31
avr35
avr4
avr5
avr51
avr6
avrxmega1
avrxmega2
avrxmega3
avrxmega4
avrxmega5
avrxmega6
avrxmega7
cannot find script file ldscripts/avr5.x
opened script file c:\users\justin\arduino\arduino-1.0\hardware\tools\avr\avr\bin\../lib\ldscripts/avr5.x
using external linker script:
==================================================
/* Default linker script, for normal executables */
OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
OUTPUT_ARCH(avr:5)
MEMORY
{
text (rx) : ORIGIN = 0, LENGTH = 128K
data (rw!x) : ORIGIN = 0x800060, LENGTH = 0xffa0
eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K
fuse (rw!x) : ORIGIN = 0x820000, LENGTH = 1K
lock (rw!x) : ORIGIN = 0x830000, LENGTH = 1K
signature (rw!x) : ORIGIN = 0x840000, LENGTH = 1K
}
SECTIONS
{
/* Read-only sections, merged into text segment: */
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.text :
{
*(.rel.text)
*(.rel.text.*)
*(.rel.gnu.linkonce.t*)
}
.rela.text :
{
*(.rela.text)
*(.rela.text.*)
*(.rela.gnu.linkonce.t*)
}
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
.rel.rodata :
{
*(.rel.rodata)
*(.rel.rodata.*)
*(.rel.gnu.linkonce.r*)
}
.rela.rodata :
{
*(.rela.rodata)
*(.rela.rodata.*)
*(.rela.gnu.linkonce.r*)
}
.rel.data :
{
*(.rel.data)
*(.rel.data.*)
*(.rel.gnu.linkonce.d*)
}
.rela.data :
{
*(.rela.data)
*(.rela.data.*)
*(.rela.gnu.linkonce.d*)
}
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.bss : { *(.rel.bss) }
.rela.bss : { *(.rela.bss) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
/* Internal text space or external memory. */
.text :
{
*(.vectors)
KEEP(*(.vectors))
/* For data that needs to reside in the lower 64k of progmem. */
*(.progmem.gcc*)
*(.progmem*)
. = ALIGN(2);
__trampolines_start = . ;
/* The jump trampolines for the 16-bit limited relocs will reside here. */
*(.trampolines)
*(.trampolines*)
__trampolines_end = . ;
/* For future tablejump instruction arrays for 3 byte pc devices.
We don't relax jump/call instructions within these sections. */
*(.jumptables)
*(.jumptables*)
/* For code that needs to reside in the lower 128k progmem. */
*(.lowtext)
*(.lowtext*)
__ctors_start = . ;
*(.ctors)
__ctors_end = . ;
__dtors_start = . ;
*(.dtors)
__dtors_end = . ;
KEEP(SORT(*)(.ctors))
KEEP(SORT(*)(.dtors))
/* From this point on, we don't bother about wether the insns are
below or above the 16 bits boundary. */
*(.init0) /* Start here after reset. */
KEEP (*(.init0))
*(.init1)
KEEP (*(.init1))
*(.init2) /* Clear __zero_reg__, set up stack pointer. */
KEEP (*(.init2))
*(.init3)
KEEP (*(.init3))
*(.init4) /* Initialize data and BSS. */
KEEP (*(.init4))
*(.init5)
KEEP (*(.init5))
*(.init6) /* C++ constructors. */
KEEP (*(.init6))
*(.init7)
KEEP (*(.init7))
*(.init8)
KEEP (*(.init8))
*(.init9) /* Call main(). */
KEEP (*(.init9))
*(.text)
. = ALIGN(2);
*(.text.*)
. = ALIGN(2);
*(.fini9) /* _exit() starts here. */
KEEP (*(.fini9))
*(.fini8)
KEEP (*(.fini8))
*(.fini7)
KEEP (*(.fini7))
*(.fini6) /* C++ destructors. */
KEEP (*(.fini6))
*(.fini5)
KEEP (*(.fini5))
*(.fini4)
KEEP (*(.fini4))
*(.fini3)
KEEP (*(.fini3))
*(.fini2)
KEEP (*(.fini2))
*(.fini1)
KEEP (*(.fini1))
*(.fini0) /* Infinite loop after program termination. */
KEEP (*(.fini0))
_etext = . ;
} > text
.data : AT (ADDR (.text) + SIZEOF (.text))
{
PROVIDE (__data_start = .) ;
*(.data)
*(.data*)
*(.rodata) /* We need to include .rodata here if gcc is used */
*(.rodata*) /* with -fdata-sections. */
*(.gnu.linkonce.d*)
. = ALIGN(2);
_edata = . ;
PROVIDE (__data_end = .) ;
} > data
.bss : AT (ADDR (.bss))
{
PROVIDE (__bss_start = .) ;
*(.bss)
*(.bss*)
*(COMMON)
PROVIDE (__bss_end = .) ;
} > data
__data_load_start = LOADADDR(.data);
__data_load_end = __data_load_start + SIZEOF(.data);
/* Global data not cleared after reset. */
.noinit :
{
PROVIDE (__noinit_start = .) ;
*(.noinit*)
PROVIDE (__noinit_end = .) ;
_end = . ;
PROVIDE (__heap_start = .) ;
} > data
.eeprom :
{
*(.eeprom*)
__eeprom_end = . ;
} > eeprom
.fuse :
{
KEEP(*(.fuse))
KEEP(*(.lfuse))
KEEP(*(.hfuse))
KEEP(*(.efuse))
} > fuse
.lock :
{
KEEP(*(.lock*))
} > lock
.signature :
{
KEEP(*(.signature*))
} > signature
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
}
==================================================
attempt to open c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5/crtm328p.o succeeded
c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5/crtm328p.o
attempt to open ./src/glowstick2.o succeeded
./src/glowstick2.o
attempt to open ./lib/CShiftPWM.o succeeded
./lib/CShiftPWM.o
attempt to open ./lib/MeetAndroid.o succeeded
./lib/MeetAndroid.o
attempt to open ./lib/hsv2rgb.o succeeded
./lib/hsv2rgb.o
attempt to open ./arduinolib/HardwareSerial.o succeeded
./arduinolib/HardwareSerial.o
attempt to open ./arduinolib/SPI.o succeeded
./arduinolib/SPI.o
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino/libArduinoCore.so failed
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\libArduinoCore.a failed
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src/libArduinoCore.so failed
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src\libArduinoCore.a succeeded
(C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src\libArduinoCore.a)wiring.c.o
(C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src\libArduinoCore.a)wiring_digital.c.o
(C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src\libArduinoCore.a)main.cpp.o
(C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src\libArduinoCore.a)new.cpp.o
(C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src\libArduinoCore.a)Print.cpp.o
(C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src\libArduinoCore.a)WString.cpp.o
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino/libgcc.so failed
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\libgcc.a failed
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src/libgcc.so failed
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src\libgcc.a failed
attempt to open c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5/libgcc.so failed
attempt to open c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a succeeded
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_mulsi3.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_udivmodhi4.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_divmodhi4.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_udivmodsi4.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_exit.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_copy_data.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_clear_bss.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_ctors.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_dtors.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_fixunssfsi.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_addsub_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_mul_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_div_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_gt_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_ge_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_lt_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_si_to_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_sf_to_si.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_thenan_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_usi_to_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_prologue.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_epilogue.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_tablejump.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_clzsi2.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_pack_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_unpack_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_fpcmp_parts_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_clz.o
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino/libc.so failed
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\libc.a failed
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src/libc.so failed
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src\libc.a failed
attempt to open c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5/libc.so failed
attempt to open c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libc.a failed
attempt to open c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5/libc.so failed
attempt to open c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a succeeded
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)malloc.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)realloc.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)atof.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)atoi.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)atol.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)isspace.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)tolower.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)toupper.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)memcpy.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)memmove.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)strchr.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)strcmp.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)strcpy.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)strncmp.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)strncpy.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)strrchr.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)strstr.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)itoa.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)ltoa.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)mulsi10.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)mul10.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)ultoa.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)utoa.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)strtod.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)cty_isfalse.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)strncasecmp_P.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)strrev.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)cmpsf2.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)fp_cmp.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)errno.o
c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a(cmpsf2.o): In function `__lesf2':
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino/libgcc.so failed
(.text.fplib+0x0): multiple definition of `__ltsf2'
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\libgcc.a failed
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src/libgcc.so failed
c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a(_lt_sf.o):(.text+0x0): first defined here
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src\libgcc.a failed
attempt to open c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5/libgcc.so failed
attempt to open c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a succeeded
make: *** [CustomLEDPoi.elf] Error 1
**** Build Finished ****
I realized that I did not add the libary m. So I appended -lm using the add libraries option.
The make file now has this command.
avr-g++ -o"CustomLEDPoi.elf" ./src/glowstick2.o ./lib/CShiftPWM.o ./lib/MeetAndroid.o ./lib/hsv2rgb.o ./arduinolib/HardwareSerial.o ./arduinolib/SPI.o -larduino_core -lm -Wl,-Map,CustomLEDPoi.map,--cref -Wl,--gc-sections -L"C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino" -L"C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src" -Xlinker -verbose -mmcu=atmega328p
This still gave me the same issue.
Looking at the guide at http://arduino.cc/playground/Code/Eclipse
It says,
If you're using C++ then the hex file can get really big. In the
linker menu, change the command to avr-gcc and the command line
pattern to the following: ${COMMAND} --cref -s -Os
${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} -lm ${FLAGS}
My make file now has this command.
avr-g++ --cref -s -Os -o"CustomLEDPoi.elf" ./src/glowstick2.o ./lib/CShiftPWM.o ./lib/MeetAndroid.o ./lib/hsv2rgb.o ./arduinolib/HardwareSerial.o ./arduinolib/SPI.o -larduino_core -lm -lm -Wl,-Map,CustomLEDPoi.map,--cref -Wl,--gc-sections -L"C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino" -L"C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src" -Xlinker -verbose -mmcu=atmega328p
here is catastrohic error for ATmega32 (avr5) in GCC linker script:
data (rw!x) : ORIGIN = 0x800060, LENGTH = 0xffa0
the manual declares:
(0xC6) UDR0 USART I/O Data Register
the at address (0xC6) will be owerwritten by by user .data
Related
I am trying to cross-compile a simple c/cpp file the target is an stm32f030F4P, I was successfully able to setup the CMake files, and cmake successfully build the build.ninja file for ninja.
When I execute ninja I get the following error
PS C:\Users\varun\Desktop\Projects\stm32f030f4p\Firmware\Blinky\build>
ninja.exe [1/1] Linking CXX executable .elf FAILED: .elf cmd.exe /C
"cd . && C:\DEV-TO~1\TOOLCH~1\GCC-AR~1\102020~1\bin\AR10B2~1.EXE
-march=armv6-m -mcpu=cortex-m0 -mthumb -DSTM32F030x4 -Og -ggdb -Wall -Wextra -ffunction-sections -fdata-sections -ffreestanding -fno-builtin --specs=nano.specs -fno-rtti -fno-exceptions -Wno-volatile -std=c++1z -g CMakeFiles/.elf.dir/src/main.cpp.obj -o .elf && cd ."
c:/dev-to~1/toolch~1/gcc-ar~1/102020~1/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe:
c:/dev-to~1/toolch~1/gcc-ar~1/102020~1/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp\libg_nano.a(lib_a-exit.o):
in function exit': exit.c:(.text.exit+0x1e): undefined reference to _exit' collect2.exe: error: ld returned 1 exit status ninja: build
stopped: subcommand failed. PS
Please find my CMakeLists.txt.
CMAKE_MINIMUM_REQUIRED(VERSION 3.20)
INCLUDE("CMake/arm-none-eabi.cmake")
SET(CMAKE_C_STANDARD 11)
SET(CMAKE_CXX_STANDARD 17)
PROJECT(BLINKY VERSION 1.0.1 DESCRIPTION "Blinky Example")
FILE(GLOB_RECURSE
LDSCRIPTS
"ldscripts/*.ld"
)
FOREACH(file ${LDSCRIPTS})
SET(CMAKE_CAMKE_LINKER_FLAGS "${CAMKE_LINKER_FLAGS} -T \"${file}\" ")
ENDFOREACH()
#Setup project headers
INCLUDE_DIRECTORIES(
)
#Setup porject sources
FILE(GLOB_RECURSE
APPLICATION_SOURCE
"src/*.c"
"src/*.cpp"
)
ADD_EXECUTABLE(${PROJECT}.elf ${APPLICATION_SOURCE})
Please find my arm-none-eabi.cmake(excuse the copy paste toolchain name, had no clue what to name it)
MESSAGE("Running : arm-none-eabi.cmake")
SET(CMAKE_SYSTEM_PROCESSOR arm)
SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_C_COMPILER_WORKS TRUE)
SET(CMAKE_CXX_COMPILER_WORKS TRUE)
SET(CMAKE_TRY_COMPILE_TARGTE_TYPE STATIC_LIBRARY)
SET(TARGET STM32F030x4)
SET(ARCH armv6-m)
SET(CPU cortex-m0)
SET(ARM_ISA mthumb)
SET(CMAKE_C_COMPILER arm-none-eabi-gcc)
SET(CMAKE_CXX_COMPILER arm-none-eabi-g++)
SET(CMAKE_ASM_COMPILER arm-none-eabi-g++)
SET(CMAKE_SIZE arm-none-eabi-size)
SET(CMAKE_OBJDUMP arm-none-eabi-objdump)
SET(CMAKE_OBJCOPY arm-none-eabi-objcopy)
SET(OPTIMISATION Og)
SET(DEBUG "ggdb")
SET(CMAKE_COMMON_FLAGS "-march=${ARCH} -mcpu=${CPU} -${ARM_ISA} -D${TARGET} -${OPTIMISATION} -${DEBUG} -Wall -Wextra -ffunction-sections -fdata-sections -ffreestanding -fno-builtin --specs=nano.specs")
SET(CMAKE_ASM_FLAGS "${CMAKE_COMMON_FLAGS} ")
SET(CMAKE_C_FLAGS "${CMAKE_COMMON_FLAGS} -std=gnull")
SET(CMAKE_CXX_FLAGS "${CMAKE_COMMON_FLAGS} -fno-rtti -fno-exceptions -Wno-volatile -std=c++1z")
SET(CAMKE_LINKER_FLAGS "${CMAKE_COMMON_FLAGS} -nostartfiles -Wl, -Map, \"${TARGET}.map\" --specs-nano.specs")
My linker script is a copy paste from STM32CubeIDE
> /* Entry Point */ ENTRY(Reset_Handler)
>
> /* Highest address of the user mode stack */
> _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
>
> _Min_Heap_Size = 0x200 ; /* required amount of heap */
> _Min_Stack_Size = 0x400 ; /* required amount of stack */
>
> /* Memories definition */ MEMORY { RAM (xrw) : ORIGIN =
> 0x20000000, LENGTH = 4K FLASH (rx) : ORIGIN = 0x8000000,
> LENGTH = 16K }
>
> /* Sections */ SECTIONS { /* The startup code into "FLASH" Rom type
> memory */ .isr_vector : {
> . = ALIGN(4);
> KEEP(*(.isr_vector)) /* Startup code */
> . = ALIGN(4); } >FLASH
>
> /* The program code and other data into "FLASH" Rom type memory */
> .text : {
> . = ALIGN(4);
> *(.text) /* .text sections (code) */
> *(.text*) /* .text* sections (code) */
> *(.glue_7) /* glue arm to thumb code */
> *(.glue_7t) /* glue thumb to arm code */
> *(.eh_frame)
>
> KEEP (*(.init))
> KEEP (*(.fini))
>
> . = ALIGN(4);
> _etext = .; /* define a global symbols at end of code */ } >FLASH
>
> /* Constant data into "FLASH" Rom type memory */ .rodata : {
> . = ALIGN(4);
> *(.rodata) /* .rodata sections (constants, strings, etc.) */
> *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
> . = ALIGN(4); } >FLASH
>
> .ARM.extab : {
> . = ALIGN(4);
> *(.ARM.extab* .gnu.linkonce.armextab.*)
> . = ALIGN(4); } >FLASH
>
> .ARM : {
> . = ALIGN(4);
> __exidx_start = .;
> *(.ARM.exidx*)
> __exidx_end = .;
> . = ALIGN(4); } >FLASH
>
> .preinit_array : {
> . = ALIGN(4);
> PROVIDE_HIDDEN (__preinit_array_start = .);
> KEEP (*(.preinit_array*))
> PROVIDE_HIDDEN (__preinit_array_end = .);
> . = ALIGN(4); } >FLASH
>
> .init_array : {
> . = ALIGN(4);
> PROVIDE_HIDDEN (__init_array_start = .);
> KEEP (*(SORT(.init_array.*)))
> KEEP (*(.init_array*))
> PROVIDE_HIDDEN (__init_array_end = .);
> . = ALIGN(4); } >FLASH
>
> .fini_array : {
> . = ALIGN(4);
> PROVIDE_HIDDEN (__fini_array_start = .);
> KEEP (*(SORT(.fini_array.*)))
> KEEP (*(.fini_array*))
> PROVIDE_HIDDEN (__fini_array_end = .);
> . = ALIGN(4); } >FLASH
>
> /* Used by the startup to initialize data */ _sidata =
> LOADADDR(.data);
>
> /* Initialized data sections into "RAM" Ram type memory */ .data :
> {
> . = ALIGN(4);
> _sdata = .; /* create a global symbol at data start */
> *(.data) /* .data sections */
> *(.data*) /* .data* sections */
> *(.RamFunc) /* .RamFunc sections */
> *(.RamFunc*) /* .RamFunc* sections */
>
> . = ALIGN(4);
> _edata = .; /* define a global symbol at data end */
>
> } >RAM AT> FLASH
>
> /* Uninitialized data section into "RAM" Ram type memory */ . =
> ALIGN(4); .bss : {
> /* This is used by the startup in order to initialize the .bss section */
> _sbss = .; /* define a global symbol at bss start */
> __bss_start__ = _sbss;
> *(.bss)
> *(.bss*)
> *(COMMON)
>
> . = ALIGN(4);
> _ebss = .; /* define a global symbol at bss end */
> __bss_end__ = _ebss; } >RAM
>
> /* User_heap_stack section, used to check that there is enough "RAM"
> Ram type memory left */ ._user_heap_stack : {
> . = ALIGN(8);
> PROVIDE ( end = . );
> PROVIDE ( _end = . );
> . = . + _Min_Heap_Size;
> . = . + _Min_Stack_Size;
> . = ALIGN(8); } >RAM
>
> /* Remove information from the compiler libraries */ /DISCARD/ :
> {
> libc.a ( * )
> libm.a ( * )
> libgcc.a ( * ) }
>
> .ARM.attributes 0 : { *(.ARM.attributes) } }
And finally c file is simple
unsigned int counter;
int main(void)
{
for(;;)
{
counter++;
}
}
Using VxWorks 653 2.5.0.2 for P2020RDB-PC target, using BSP1.0/4
I have a very simple test application
void usrAppInit (void)
{
RETURN_CODE_TYPE errCode;
printf("\n I am alive!");
PROCESS_ATTRIBUTE_TYPE processAttributes;
PROCESS_ID_TYPE thandle;
processAttributes.BASE_PRIORITY = 10;
processAttributes.DEADLINE = SOFT;
processAttributes.ENTRY_POINT = (SYSTEM_ADDRESS_TYPE)task;
strncpy(processAttributes.NAME, "TASK", MAX_NAME_LENGTH);
processAttributes.PERIOD = INFINITE_TIME_VALUE;
processAttributes.STACK_SIZE = 1024;
processAttributes.TIME_CAPACITY = INFINITE_TIME_VALUE;
CREATE_PROCESS(&processAttributes, &thandle, &errCode);
if(errCode != NO_ERROR)
{
printf("Just had an error creating the task: %d", errCode);
}
else
{
START(thandle, &errCode);
if(errCode != NO_ERROR)
{
printf("Just had an error starting the task: %d", errCode);
}
}
SET_PARTITION_MODE (NORMAL, &errCode);
if (errCode != NO_ERROR){
printf("\nError changing partition mode: %d", errCode);
}
while(1);
}
void task()
{
printf("\nI am a process.");
while(1);
}
When the program gets to the START line, it reboots. If I comment out the START line, it executes till the end of the main and obviously does nothing. I have tried to increase partition memory and I am adding the APEX components to the makefile.
What could be causing this?
PS: system output
VxWorks 653 System Boot
Copyright (c) 1984-2016 Wind River Systems, Inc.
CPU: Freescale P2020E - Security Engine
Version: 2.5.0.2
BSP version: 1.0/4
Creation date: Apr 29 2020, 15:00:10
Press any key to stop auto-boot...
0
auto-booting...
boot device : mottsec
unit number : 0
processor number : 0
host name : felipe
file name : D:\Projects\WindRiver\helloWorld\boot.txt
inet on ethernet (e) : 192.168.1.172
host inet (h) : 192.168.1.75
gateway inet (g) : 192.168.1.1
user (u) : felipe
ftp password (pw) : pass
flags (f) : 0x0
target name (tn) : board
Attached TCP/IP interface to mottsec0.
Warning: netmask value is 0.
Attaching interface lo0...done
Loading D:\Projects\WindRiver\helloWorld\boot.txt
sm0=D:\Projects\WindRiver\helloWorld\configRecord.reloc
0x00001a00 + (0x000fe600)
sm1=D:\Projects\WindRiver\helloWorld\coreOS.sm
0x00050e08 + 0x00007130 + 0x00006084 + 0x00015cac
sm2=D:\Projects\WindRiver\helloWorld\vxSysLib.sm
0x00031078 + 0x00004b20 + 0x00000918 + 0x00001d90
sm3=D:\Projects\WindRiver\helloWorld\fsl_p2020_rdb_part1.sm
0x000027c8 + 0x000000d0 + 0x00000010 + 0x00000008
Starting at 0x100000...
After this, it returns to the beggining and repeats the process forever
So, in case anyone else drops here with similar issue, in my case there were two main things affecting the functionality.
First, in the usrAppInit() function, one cannot define the while(1) loop in the end of the function. On opposite to other ARINC-653 systems, where the partition main is the same as the user main, for VxWorks it does not seems to be the case. This way, after SET_PARTITION_MODE, nothing else can be defined.
Second, the stack size for the process was too small. That fit perfectly for different targets and ARINC RTOS (in-house OS, executing on ARMv7 target), but for VxWorks on the P2020 target it requires a bigger stack. In this case, I've used 4096.
Here is the complete example code, now functional, in case anyone needs this.
void usrAppInit (void)
{
RETURN_CODE_TYPE errCode;
printf("\n I am alive!");
PROCESS_ATTRIBUTE_TYPE processAttributes;
PROCESS_ID_TYPE thandle;
processAttributes.BASE_PRIORITY = 10;
processAttributes.DEADLINE = SOFT;
processAttributes.ENTRY_POINT = (SYSTEM_ADDRESS_TYPE)task;
strncpy(processAttributes.NAME, "TASK", MAX_NAME_LENGTH);
processAttributes.PERIOD = INFINITE_TIME_VALUE;
processAttributes.STACK_SIZE = 4096;
processAttributes.TIME_CAPACITY = INFINITE_TIME_VALUE;
CREATE_PROCESS(&processAttributes, &thandle, &errCode);
if(errCode != NO_ERROR)
{
printf("Just had an error creating the task: %d", errCode);
}
else
{
START(thandle, &errCode);
if(errCode != NO_ERROR)
{
printf("Just had an error starting the task: %d", errCode);
}
}
SET_PARTITION_MODE (NORMAL, &errCode);
if (errCode != NO_ERROR){
printf("\nError changing partition mode: %d", errCode);
}
}
void task()
{
printf("\nI am a process.");
while(1);
}
I'm writing firmware for TM4C1231H6PZ now. Some time ago I was helped to set-up IDE and toolchain, that were generating neat and working binaries for my project, ~8 kB large. After that, I did some directory moving and so on, and now the same IDE, working with the same project (I have restored whole project directory from archive) generates binary 520 Mb large, which is obviously wrong.
Looking into new binary, I see that there is code from 00000000 to 0000079b, after that there are only NULLs, and then some code from 20000000 to 2000002b. I believe that it has to be some code intended for SRAM, but I don't know what to do with it. I tried to just delete code starting from 20000000, but the resulting binary doesn't work on MCU.
May somebody help me to repair my IDE+toolchain to generate normal binaries as before?
I use Eclipse Kepler 2.0.2, Codesourcery Lite for ARM Toolchain (arm-2013.11-24-arm-none-eabi.exe installer) and TivaWare (SW-TM4C-2.1.0.12573.exe).
Here's my linker script file:
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 16K
SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
}
SECTIONS
{
.text :
{
_text = .;
KEEP(*(.isr_vector))
*(.text*)
*(.rodata)
*(.rodata*)
_etext = .;
} > FLASH
/* C++ initialization and finalization data */
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >FLASH
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array*))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH
.data : AT(ADDR(.text) + SIZEOF(.text) + SIZEOF(.preinit_array) + SIZEOF(.init_array) + SIZEOF(.fini_array))
{
. = ALIGN(4);
_data = .;
*(.data)
*(.data*)
. = ALIGN(4);
_edata = .;
} > SRAM
. = ALIGN(4);
.bss :
{
_bss = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .;
} > SRAM
}
Somewhere your code contains initial values or program code to be placed in RAM. You need to check your linker map file to figure out the name of this segment.
Let's say, you'll find
.ramfunc 0x123
0x20000000
In this case you need to add this section to your .data segment by adding
*(.data)
*(.data*)
*(.ramfunc) <-- this line
to your linker script.
The data segment will be placed in flash and copied to RAM by the initialization code before main() is called.
I have been writing a lcd kernel driver for a LCD module. All was going well, I can write to the display, create a /dev/lcd node that I can write into and it will display the results on the screen. I thought using the llseek fops callback to position the cursor on the lcd would be good, this way I could use rewind fseek etc. However it is not working as I expected, below is a summary of what I am seeing:
The relevant lines of code from the driver side are:
loff_t lcd_llseek(struct file *filp, loff_t off, int whence)
{
switch (whence) {
case 0: // SEEK_SET
if (off > 4*LINE_LENGTH || off < 0) {
printk(KERN_ERR "unsupported SEEK_SET offset %llx\n", off);
return -EINVAL;
}
lcd_gotoxy(&lcd, off, 0, WHENCE_ABS);
break;
case 1: // SEEK_CUR
if (off > 4*LINE_LENGTH || off < -4*LINE_LENGTH) {
printk(KERN_ERR "unsupported SEEK_CUR offset %llx\n", off);
return -EINVAL;
}
lcd_gotoxy(&lcd, off, 0, WHENCE_REL);
break;
case 2: // SEEK_END (not supported, hence fall though)
default:
// how did we get here !
printk(KERN_ERR "unsupported seek operation\n");
return -EINVAL;
}
filp->f_pos = lcd.pos;
printk(KERN_INFO "lcd_llseek complete\n");
return lcd.pos;
}
int lcd_open(struct inode *inode, struct file *filp)
{
if (!atomic_dec_and_test(&lcd_available)) {
atomic_inc(&lcd_available);
return -EBUSY; // already open
}
return 0;
}
static struct file_operations fops = {
.owner = THIS_MODULE,
.write = lcd_write,
.llseek = lcd_llseek,
.open = lcd_open,
.release = lcd_release,
};
int lcd_init(void)
{
...
// allocate a new dev number (this can be dynamic or
// static if passed in as a module param)
if (major) {
devno = MKDEV(major, 0);
ret = register_chrdev_region(devno, 1, MODULE_NAME);
} else {
ret = alloc_chrdev_region(&devno, 0, 1, MODULE_NAME);
major = MAJOR(devno);
}
if (ret < 0) {
printk(KERN_ERR "alloc_chrdev_region failed\n");
goto fail;
}
// create a dummy class for the lcd
cl = class_create(THIS_MODULE, "lcd");
if (IS_ERR(cl)) {
printk(KERN_ERR "class_simple_create for class lcd failed\n");
goto fail1;
}
// create cdev interface
cdev_init(&cdev, &fops);
cdev.owner = THIS_MODULE;
ret = cdev_add(&cdev, devno, 1);
if (ret) {
printk(KERN_ERR "cdev_add failed\n");
goto fail2;
}
// create /sys/lcd/fplcd/dev so udev will add our device to /dev/fplcd
device = device_create(cl, NULL, devno, NULL, "lcd");
if (IS_ERR(device)) {
printk(KERN_ERR "device_create for fplcd failed\n");
goto fail3;
}
...
}
To test the lseek call I have the following unit test:
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#define log(msg, ...) fprintf(stdout, __FILE__ ":%s():[%d]:" msg, __func__, __LINE__, __VA_ARGS__)
int lcd;
void test(void)
{
int k;
// a lot of hello's
log("hello world test\n",1);
if (lseek(lcd, 0, SEEK_CUR) == -1) {
log("failed to seek\n", 1);
}
}
int main(int argc, char **argv)
{
lcd = open("/dev/lcd", O_WRONLY);
if (lcd == -1) {
perror("unable to open lcd");
exit(EXIT_FAILURE);
}
test();
close(lcd);
return 0;
}
The files are cross compiled like so:
~/Workspace/ts4x00/lcd-module$ cat Makefile
obj-m += fls_lcd.o
all:
make -C $(KPATH) M=$(PWD) modules
$(CROSS_COMPILE)gcc -g -fPIC $(CFLAGS) lcd_unit_test.c -o lcd_unit_test
clean:
make -C $(KPATH) M=$(PWD) clean
rm -rf lcd_unit_test
~/Workspace/ts4x00/lcd-module$ make CFLAGS+="-march=armv4 -ffunction-sections -fdata-sections"
make -C ~/Workspace/ts4x00/linux-2.6.29 M=~/Workspace/ts4x00/lcd-module modules
make[1]: Entering directory `~/Workspace/ts4x00/linux-2.6.29'
CC [M] ~/Workspace/ts4x00/lcd-module/fls_lcd.o
~/Workspace/ts4x00/lcd-module/fls_lcd.c:443: warning: 'lcd_entry_mode' defined but not used
Building modules, stage 2.
MODPOST 1 modules
CC ~/Workspace/ts4x00/lcd-module/fls_lcd.mod.o
LD [M] ~/Workspace/ts4x00/lcd-module/fls_lcd.ko
make[1]: Leaving directory `~/Workspace/ts4x00/linux-2.6.29'
~/Workspace/ts4x00/arm-2008q3/bin/arm-none-linux-gnueabi-gcc -g -fPIC -march=armv4 -ffunction-sections -fdata-sections lcd_unit_test.c -o lcd_unit_test
This is the output of running the driver with the unit test is:
root#ts4700:~/devel# insmod ./fls_lcd.ko
root#ts4700:~/devel# ./lcd_unit_test
lcd_unit_test.c:test():[61]:hello world test
lcd_unit_test.c:test():[63]:failed to seek
root#ts4700:~/devel# dmesg
FLS LCD driver started
unsupported SEEK_SET offset bf0a573c
I cannot figure out why the parameters are being mucked up so badly on the kernel side, I tried to SEEK_CUR to position 0 and in the driver I get a SEEK_SET (no matter what I put in the unit test) and a crazy big number for off?
Does anyone know what is going on please ?
btw I am compiling for kernel 2.6.29 on a arm dev kit
OK sorry guys after trying to debug this all last night it comes down to compiling against the wrong kernel (I had KPATH left to a different config of the kernel than was on the sdcard)
sorry for wasting everyones time, but hopefully if someone is seeing what looks like a crazy stack in their kernel driver this might set them straight.
oh and thanks for all the help :)
I'm working on a cortex-m3 chip. The stack space was reserved in the source code with an uninitialized array on the bss section. The linker script I used is as follows:
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256k
SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 64k
}
SECTIONS {
.text : {
KEEP(*(.isr_vector))
*(.text*)
*(.rodata*)
__text_end = .;
} >FLASH
.data : {
__data_start = .;
*(.data*)
__data_end = .;
} >SRAM AT>FLASH
.bss : {
__bss_start = .;
*(.bss*)
__bss_end = .;
} >SRAM
}
I'm trying to allocate a section for the stack in the beginning of the SRAM region so that i could detect stack overflow with usage fault.
I added a section named .stack:
SECTIONS {
.text : {
:
} >FLASH
.stack : {
__stack_size = 4k;
__stack_start = .;
. = . + __stack_size;
. = ALIGN(8); /* cortex-m3 uses full-descending stack aligned with 8 bytes */
__stack_end = .;
} >SRAM
.data : {
:
} >SRAM AT>FLASH
.bss : {
:
} >SRAM
}
Linking is done without any error or warning, but the problem is that __stack_end is not on the SRAM region but on the FLASH region.
I know I can use a separate section given with __attribute__((section("name"))) but I think it would be better if I can deal with it in the linker script.
How can I make an empty section on SRAM region?
Just split the RAM area in two:
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256k
SRAM_STACK (rwx) : ORIGIN = 0x20000000, LENGTH = 4k
SRAM (rwx) : ORIGIN = 0x20001000, LENGTH = 60k
}
SECTIONS {
.text : {
KEEP(*(.isr_vector))
*(.text*)
*(.rodata*)
__text_end = .;
} >FLASH
.data : {
__data_start = .;
*(.data*)
__data_end = .;
} >SRAM AT>FLASH
.bss : {
__bss_start = .;
*(.bss*)
__bss_end = .;
} >SRAM
.stack : {
__stack_size = 4k;
__stack_start = .;
. = . + __stack_size;
. = ALIGN(8); /* cortex-m3 uses full-descending stack aligned with 8 bytes */
__stack_end = .;
} >SRAM_STACK
}