I am new to Atmel Studio. I created new GCC C Execute project with ATSAMV71Q21 device. In main.c file added printf then run build and got bunch of "undefined reference to (_write, _fsta, etc) error. I tried Atmel "getting-started" example and it worked fine. How can I fix this problem? Below are the code and error message. Thanks for help.
#include "sam.h"
#include <stdio.h>
#include <stdbool.h>
int main(void)
{
/* Initialize the SAM system */
SystemInit();
while (1)
{
printf("abc");
//TODO:: Please write your application code
}
}
d:/atmel/atmel toolchain/arm gcc/native/4.8.1443/arm-gnu-toolchain/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib/armv7e-m\libc.a(lib_a-sbrkr.o): In function '_sbrk_r': D:\Atmel\samv71_softpack_1.4_for_astudio_6_2\studio\Atmel\samv71_Xplained_Ultra\examples\test\test\Debug\sbrkr.c(1,1): error: undefined reference to '_sbrk'
If you just want to fix that link error, then you can add Standard serial I/O by going to the Project->ASF Wizard and scrolling down to Standard serial I/O and clicking add.
While this will fix the linker error, it probably is not going to do what you expect. Where are you trying to print to? Is there a display connected to your embedded device? Then you'll need to use a specific driver for that display and its associated api.
If you're just using printf() for debugging purposes while connected to your pc, then I recommend using the atmel debugger to follow the code execution, inspect variables, etc.