AnsweredAssumed Answered

use sprintf on S32 Power Studio

Question asked by Roger Helfenberger on Jan 15, 2018
Latest reply on Jan 15, 2018 by Roger Helfenberger

Hay everybody,

 

I am working with the S32 Studio on a S32R274 Processor.

I have the issue that sprintf is not working properly and saw that there are already many (old) threads about this.

In one of them a relation between the sbrk function an the sprintf was mentioned. This seems important to me, as I was facing the following  error:

C:/NXP/S32DS_Power_v2017.R1/Cross_Tools/powerpc-eabivle-4_9/powerpc-eabivle/newlib/lib/e200z4/fp\libnosys.a(sbrk.o): In function `sbrk':
sbrk.c:(.text.sbrk+0x10): undefined reference to `end'
sbrk.c:(.text.sbrk+0x16): undefined reference to `end'
collect2.exe: error: ld returned 1 exit status

 

and solved it by changing the sections.ld file to:

/* Core 0 stack */
.c0_stack_and_heap (NOLOAD) : ALIGN(16)
{
__HEAP = . ;
. += __C0_HEAP_SIZE ;
PROVIDE (_end = . );
PROVIDE (end = . );
__HEAP_END = . ;

_stack_end = . ;
. += __C0_STACK_SIZE ;
_stack_addr = . ;
__SP_INIT = . ;
} > c0_stack_and_heap

 

Building the Project worked great, but I faced IVOR1 errors during runtime.

I found, that:

char str[80];
char test_str_1[] = "test_1";

char test_str_2[] = "test_2";

 

int test1 = 1;

int test2 = 2;

sprintf(str, "%s", test_str_1);

 

worked for every library, but:

sprintf(str, "%02i%02i", test1, test2);

only worked with the "newlib_nano no I/O" library, whereas:

 

sprintf(str, "%s%s", test_str_1, test_str_2);

Did not work for any library.

 

 

Do you have any idea, why sprintf is not working?

 

Thanks and best regards,

Roger

Outcomes