use sprintf on S32 Power Studio

Showing results for 
Show  only  | Search instead for 
Did you mean: 

use sprintf on S32 Power Studio

Contributor II

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,


Tags (3)
0 Kudos
2 Replies

NXP Employee
NXP Employee

Hi Roger, 

I created new test project for your issue - but I can't reproduce it. The test project is in attachment. In my opinion is your issue related to some dynamic memory allocation - not to sprintf itself. It is possible share your project? 


Contributor II

Hi Jiri,

Thanks for your fast response and the test project, it helped me to solve the problem.

Also at my S32 Studio your test project worked well, so I compared all settings and ended up that the projects mainly differ in the chosen library. I did not use test the ewl_c library because i had build errors with the "abs" function. So i changed all my abs(x) calls to (int)fabs((double)x) ones, which worked, because fabs is in the math.h library.

Afterwards building was possible and also the sprintf command worked.

Best regards,


0 Kudos