xdk-asf and sam d20

Discussions around product based on ARM Cortex M0+ core.

Moderator: nferre

matwey
Posts: 4
Joined: Sun Dec 15, 2013 6:29 pm

xdk-asf and sam d20

Sun Dec 15, 2013 6:37 pm

Hi,

I am trying to compile examples from xdk-asf-3.13.1 for my atsamd20-xpro board.

The question is do I need newlib as system library in my toolchain? I've built one from scratch (gcc 4.8.2 newlib 2.0.0 binutils 2.24).

When I try to compile an examples, I get the following:

Code: Select all

/opt/arm-none-eabi/lib/gcc/arm-none-eabi/4.8.2/../../../../arm-none-eabi/lib/thumb/libc.a(lib_a-syscalls.o): In function `_lseek':
/home/matwey/src/newlib-2.0.0/build/arm-none-eabi/thumb/newlib/libc/sys/arm/../../../../../../../newlib/libc/sys/arm/syscalls.c:303: multiple definition of `_lseek'
sam0/utils/syscalls/gcc/syscalls.o:/home/matwey/src/xdk-asf-3.13.1/sam0/drivers/sercom/usart/quick_start/samd20_xplained_pro/gcc/../../../../../../../sam0/utils/syscalls/gcc/syscalls.c:107: first defined here
/opt/arm-none-eabi/lib/gcc/arm-none-eabi/4.8.2/../../../../arm-none-eabi/lib/thumb/libc.a(lib_a-syscalls.o): In function `_close':
/home/matwey/src/newlib-2.0.0/build/arm-none-eabi/thumb/newlib/libc/sys/arm/../../../../../../../newlib/libc/sys/arm/syscalls.c:434: multiple definition of `_close'
sam0/utils/syscalls/gcc/syscalls.o:/home/matwey/src/xdk-asf-3.13.1/sam0/drivers/sercom/usart/quick_start/samd20_xplained_pro/gcc/../../../../../../../sam0/utils/syscalls/gcc/syscalls.c:89: first defined here
/opt/arm-none-eabi/lib/gcc/arm-none-eabi/4.8.2/../../../../arm-none-eabi/lib/thumb/libc.a(lib_a-syscalls.o): In function `_kill':
/home/matwey/src/newlib-2.0.0/build/arm-none-eabi/thumb/newlib/libc/sys/arm/../../../../../../../newlib/libc/sys/arm/syscalls.c:440: multiple definition of `_kill'
sam0/utils/syscalls/gcc/syscalls.o:/home/matwey/src/xdk-asf-3.13.1/sam0/drivers/sercom/usart/quick_start/samd20_xplained_pro/gcc/../../../../../../../sam0/utils/syscalls/gcc/syscalls.c:119: first defined here
/opt/arm-none-eabi/lib/gcc/arm-none-eabi/4.8.2/../../../../arm-none-eabi/lib/thumb/libc.a(lib_a-syscalls.o): In function `_exit':
/home/matwey/src/newlib-2.0.0/build/arm-none-eabi/thumb/newlib/libc/sys/arm/../../../../../../../newlib/libc/sys/arm/syscalls.c:459: multiple definition of `_exit'
sam0/utils/syscalls/gcc/syscalls.o:/home/matwey/src/xdk-asf-3.13.1/sam0/drivers/sercom/usart/quick_start/samd20_xplained_pro/gcc/../../../../../../../sam0/utils/syscalls/gcc/syscalls.c:110: first defined here
/opt/arm-none-eabi/lib/gcc/arm-none-eabi/4.8.2/../../../../arm-none-eabi/lib/thumb/libc.a(lib_a-syscalls.o): In function `_getpid':
/home/matwey/src/newlib-2.0.0/build/arm-none-eabi/thumb/newlib/libc/sys/arm/../../../../../../../newlib/libc/sys/arm/syscalls.c:473: multiple definition of `_getpid'
sam0/utils/syscalls/gcc/syscalls.o:/home/matwey/src/xdk-asf-3.13.1/sam0/drivers/sercom/usart/quick_start/samd20_xplained_pro/gcc/../../../../../../../sam0/utils/syscalls/gcc/syscalls.c:123: first defined here
/opt/arm-none-eabi/lib/gcc/arm-none-eabi/4.8.2/../../../../arm-none-eabi/lib/thumb/libc.a(lib_a-syscalls.o): In function `_sbrk':
/home/matwey/src/newlib-2.0.0/build/arm-none-eabi/thumb/newlib/libc/sys/arm/../../../../../../../newlib/libc/sys/arm/syscalls.c:482: multiple definition of `_sbrk'
sam0/utils/syscalls/gcc/syscalls.o:/home/matwey/src/xdk-asf-3.13.1/sam0/drivers/sercom/usart/quick_start/samd20_xplained_pro/gcc/../../../../../../../sam0/utils/syscalls/gcc/syscalls.c:68: first defined here
/opt/arm-none-eabi/lib/gcc/arm-none-eabi/4.8.2/../../../../arm-none-eabi/lib/thumb/libc.a(lib_a-syscalls.o): In function `_fstat':
/home/matwey/src/newlib-2.0.0/build/arm-none-eabi/thumb/newlib/libc/sys/arm/../../../../../../../newlib/libc/sys/arm/syscalls.c:512: multiple definition of `_fstat'
sam0/utils/syscalls/gcc/syscalls.o:/home/matwey/src/xdk-asf-3.13.1/sam0/drivers/sercom/usart/quick_start/samd20_xplained_pro/gcc/../../../../../../../sam0/utils/syscalls/gcc/syscalls.c:94: first defined here
/opt/arm-none-eabi/lib/gcc/arm-none-eabi/4.8.2/../../../../arm-none-eabi/lib/thumb/libc.a(lib_a-syscalls.o): In function `_isatty':
/home/matwey/src/newlib-2.0.0/build/arm-none-eabi/thumb/newlib/libc/sys/arm/../../../../../../../newlib/libc/sys/arm/syscalls.c:616: multiple definition of `_isatty'
sam0/utils/syscalls/gcc/syscalls.o:/home/matwey/src/xdk-asf-3.13.1/sam0/drivers/sercom/usart/quick_start/samd20_xplained_pro/gcc/../../../../../../../sam0/utils/syscalls/gcc/syscalls.c:102: first defined here
collect2: error: ld returned 1 exit status
When I use -nostdlib -nostdinc flags in my config.mk, I get the following:

Code: Select all

CC      common/utils/interrupt/interrupt_sam_nvic.o
In file included from ../../../../../../../common/utils/interrupt/interrupt_sam_nvic.h:47:0,
                 from ../../../../../../../common/utils/interrupt/interrupt_sam_nvic.c:44:
../../../../../../../sam0/utils/compiler.h:58:20: fatal error: stddef.h: No such file or directory
 #include <stddef.h>
                    ^
compilation terminated.
make: *** [common/utils/interrupt/interrupt_sam_nvic.o] Error 1
When I use -nostdlib but no -nostdinc, I get the following:

Code: Select all

sam0/utils/cmsis/samd20/source/gcc/startup_samd20.o: In function `Reset_Handler':
/home/matwey/src/xdk-asf-3.13.1/sam0/drivers/sercom/usart/quick_start/samd20_xplained_pro/gcc/../../../../../../../sam0/utils/cmsis/samd20/source/gcc/startup_samd20.c:179: undefined reference to `__libc_init_array'
sam0/drivers/sercom/sercom.o: In function `_sercom_get_sync_baud_val':
/home/matwey/src/xdk-asf-3.13.1/sam0/drivers/sercom/usart/quick_start/samd20_xplained_pro/gcc/../../../../../../../sam0/drivers/sercom/sercom.c:78: undefined reference to `__aeabi_uidiv'
sam0/drivers/sercom/sercom.o: In function `_sercom_get_async_baud_val':
/home/matwey/src/xdk-asf-3.13.1/sam0/drivers/sercom/usart/quick_start/samd20_xplained_pro/gcc/../../../../../../../sam0/drivers/sercom/sercom.c:111: undefined reference to `__aeabi_uldivmod'
sam0/drivers/system/clock/gclk.o: In function `system_gclk_gen_get_hz':
/home/matwey/src/xdk-asf-3.13.1/sam0/drivers/sercom/usart/quick_start/samd20_xplained_pro/gcc/../../../../../../../sam0/drivers/system/clock/gclk.c:275: undefined reference to `__aeabi_uidiv'
collect2: error: ld returned 1 exit status
make: *** [usart_quick_start_flash.elf] Error 1
It seems, that my toolchain is tuned in a wrong way. Any ideas?
blue_z
Location: USA
Posts: 1762
Joined: Thu Apr 19, 2007 10:15 pm

Re: xdk-asf and sam d20

Mon Dec 16, 2013 3:48 am

matwey wrote:The question is do I need newlib as system library in my toolchain? I've built one from scratch (gcc 4.8.2 newlib 2.0.0 binutils 2.24).
Please clarify what you mean by "from scratch".
I've built a cross-compiler for bare-metal ARM926ej-s using crosstool-NG (that by default incorporates newlib although you could specify 'none'), and had no compilation issues for an Atmel SAM9 Softpack(age).
matwey wrote:When I try to compile an examples, I get the following:
Sorry to ask the obvious, but is there a trivial example to start with, such as a "hello world" that has a minimal number of externals/syscalls?
matwey wrote:It seems, that my toolchain is tuned in a wrong way. Any ideas?
So how is it "tuned" in the first place?

Instead of -nostdlib, have you tried -nodefaultlibs?

Do your -I<path to the sam0 package include files> and -L<path to the sam0 package libraries> look correct and complete? You only posted the error messages, and not the full compile command line for a source file.

Regards
matwey
Posts: 4
Joined: Sun Dec 15, 2013 6:29 pm

Re: xdk-asf and sam d20

Mon Dec 16, 2013 10:18 am

"From scratch" means downloaded binutils,gcc,newlib sources and compiled them.

My gcc configure is:

Code: Select all

../configure  --target=arm-none-eabi --prefix=/opt/arm-none-eabi --enable-languages="c,c++" --enable-interwork --enable-multilib  --with-newlib --with-headers=/home/matwey/src/newlib-2.0.0/newlib/libc/include/  --disable-nls --disable-libssp  --with-system-zlib
Reset_Handler at startup_samd20.c calls __libc_init_array() so I think stdlib is needed.
__aeabi_uidiv is a kind of division function and must be located in libgcc.a
matwey
Posts: 4
Joined: Sun Dec 15, 2013 6:29 pm

Re: xdk-asf and sam d20

Mon Dec 16, 2013 1:31 pm

Ok, solved.

compiling newlib with --disable-newlib-supplied-syscalls sorted the things out

Return to “SAM D20 Cortex-M0+ MCU”

Who is online

Users browsing this forum: No registered users and 4 guests