Topic : sscanf sprintf

Forum : ARM

Original Post
Post Information Post
July 10, 2009 - 1:38pm
Guest

Hello,

i wrote a main with only a sprintf and a sscanf

i use the STM32F101RB6

in ride7 options : ST library=yes / UART0 Putcha=yes / small printf=no / small no-float printf=no
i have this message : region FLASH overflowed by 8456 bytes

in ride7 options : ST library=yes / UART0 Putcha=no/ small printf=no / small no-float printf=no
i have this message : region FLASH overflowed by 6964 bytes + errors on newlib (_sbrk_r,_write_r...)

Is there any problem with newlib and ride7 or STM32 lib?

Thanks

Replies
Post Information Post
+1
0
-1
July 10, 2009 - 1:46pm
Raisonance Support Team

Hi Seb,

If you choose not to use small printf versions (either with or without float support) your project will link in the printf from the GNU C library, which is big.
So try to just select the no-float printf to check if this fixes your problem.

Regards,
Bruno

+1
0
-1
July 10, 2009 - 2:10pm
Raisonance Support Team

Hi,

In the second configuration that you describe, the link fails because sprintf and sscanf use dynamic allocation, which requires a _sbrk function that is present in the UART0_putchar library. It should not be there and we will change that in a future release, but for now you must either include the UART0_putchar library, or take the syscalls.c file from this library's sources and include it in your project.

In the first configuration that you describe, you are using the original sprintf and sscanf from gcc, which (probably) work but are designed for running in a Unix environment. As a result, they do a lot of things with streams, processes, etc. that are useless for you, but that take code space. A lot of it. As a result, your code exceeds the 32K limitation that is probably in place because of the "Starter-kit limit" linker option. You can simply uncheck this option, and then you will be able to link up to the full size of your device Flash, but you will not be able to debug unless you have a RLink Pro. The solution we recommend, as Bruno said, is to use the small printf library. (with floats or not depending on what you do in your application) These libraries have been designed exactly for this problem: the original printf from gcc is too large. You can easily extract the sprintf and sscanf from these library's sources if you really don't want printf/scanf, only sprintf/sscanf.

You can find the libraries sources in this directory:
\lib\ARM\...

You can find more information on the UART0 and small printf things in the GettingStartedARM document.

I hope it helps.

Best Regards,

Vincent

+1
0
-1
July 10, 2009 - 2:13pm
Guest

Hi Bruno,

thank you for your reply,

but i need float-printf

Besides, i think my problem is not due to the size of the flash. If i try to change the STM32 in my project and i take the STM32101RE(512K) i have the same problem.

I don't know the size of newlib but it is less than the max size of the flash.

+1
0
-1
July 10, 2009 - 2:15pm
Raisonance Support Team

Hi,

If you select this configuration, you will have a small printf that handles float:
ST library=yes / UART0 Putcha=yes / small printf=yes / small no-float printf=no

Changing the device for a bigger one doesn't change anything because of the Starter kit limit option.

See the the GettingStartedARM document for more information on these two points.

Best Regards,

Vincent

+1
0
-1
July 10, 2009 - 2:18pm
Guest

Hi,

Thank you VincentC

it was a stupid error... i took an old project of primer i think.

Best regards