Topic : Problem with sprintf

Forum : ARM

Original Post
Post Information Post
July 1, 2009 - 2:18pm
Guest

Hi
I just updated Ride to version 7.20.09.0162 and Rit-ARM to 1.20.09.0154
and after that I have problems on my STM32 projects.
When I use sprintf with a formatter and parameters (like this):
sprintf((char *) text, "VBat %d mV ", MeasureVBat ());
sprintf((char *) text, "VBat %d mV ", 124);

the code ends up at _exit

If I just use:
sprintf((char *) text, "Something"); //Without parameters there is no problem.

I have selected small printf + USART0 Putchar in the project.

I have searched high and low to figure out what goes wrong, but have not found anything.. I don't know much about how the libraries are selected, but should'ent the small sprintf work without the functions from syscalls (which I do not explicitly include)?

I would be gratefull for any suggestions?

Replies
Post Information Post
+1
0
-1
July 1, 2009 - 2:55pm
Guest

More information.
If I just set UART0 Putchar to No I get the following errors:

d:/ride7/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-isattyr.o): In function `_isatty_r':  
 isattyr.c:(.text+0x12): undefined reference to `_isatty'  
 D:\ride7\Ride\Lib\ARM\e_stdio_thumb.a(syscalls.o): In function `_write':  
 syscalls.c:(.text+0xa0): undefined reference to `__io_putchar'  
 d:/ride7/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-signalr.o): In function `_getpid_r':  
 signalr.c:(.text+0x2): undefined reference to `_getpid'  
 collect2: ld returned 1 exit status 

If i both set UART0 Putchar and use small printf to No I get the following errors:

 d:/ride7/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-sbrkr.o): In function `_sbrk_r':  
 sbrkr.c:(.text+0x12): undefined reference to `_sbrk'  
 d:/ride7/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-writer.o): In function `_write_r':  
 writer.c:(.text+0x16): undefined reference to `_write'  
 d:/ride7/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-closer.o): In function `_close_r':  
 closer.c:(.text+0x12): undefined reference to `_close'  
 d:/ride7/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-fstatr.o): In function `_fstat_r':  
 fstatr.c:(.text+0x14): undefined reference to `_fstat'  
 d:/ride7/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-isattyr.o): In function `_isatty_r':  
 isattyr.c:(.text+0x12): undefined reference to `_isatty'  
 d:/ride7/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-lseekr.o): In function `_lseek_r':  
 lseekr.c:(.text+0x16): undefined reference to `_lseek'  
 d:/ride7/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-readr.o): In function `_read_r':  
 readr.c:(.text+0x16): undefined reference to `_read'  
 collect2: ld returned 1 exit status 

If I set both to Yes I get no errors, but when I debug and do calls to sprintf with formatters I end up at _exit ?

+1
0
-1
July 1, 2009 - 3:34pm
Guest

Switched back to RKit-Arm - 1.18.0903 and Ride7 - 7.18.0903 (Thanks god I have local backups of the different versions) and linked my project (Ride decided only to link when I hit build).. With these versions it works without a glitch..

/Henrik

+1
0
-1
July 1, 2009 - 3:42pm
Guest

By the way setting USART0 Putchar to No gives the following errors with 1.18.0903:

D:\Ride7\Ride\Lib\ARM\e_stdio_thumb.a(_sp_puts.o): In function `_SMALL_PRINTF_puts':  
 _sp_puts.c:(.text+0x48): undefined reference to `__io_putchar'  
 D:\Ride7\Ride\Lib\ARM\e_stdio_thumb.a(_sp_puts.o): In function `puts':  
 _sp_puts.c:(.text+0x70): undefined reference to `__io_putchar'  
 collect2: ld returned 1 exit status  

It looks different from the error I got when using 1.20.09.0154, could it be an issue with the libraries?

+1
0
-1
July 1, 2009 - 6:39pm
Guest

Hi Henrik

The library small printf small float printf and putchar are mismatched.
We noted this issue and we are working on seperate the function call in these libraries.

Thank you for this feedback.

Regards,
Matloub

+1
0
-1
July 2, 2009 - 8:33am
Guest

Thank you for the answer, I will look forward to a fixed version.

BR
Henrik