This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi all,
since adding sprintf to my project, it crashed. I tried to debug it and located a stack problem inside sprintf - it uses > 400 words ("ADD @SP,#422" in _printfi) of stack.
That's more stack than I have.
So I will have to use my own hand-written sprintf functions.
I am using cgtools 5.2.4 with large memory model.
Where can I find how many resources the library functions need?
Between compiler versions 4.1.x and 5.2.x, the printf routines were reworked to support multiple levels of support for printf format specifiers and general clean up to reduce code size and overall memory size (including bss). The function _printfi (which is indirectly called from sprintf) uses a local array with a size of 400 elements. This has always been there and needs to be that big to be compliant, and we want to avoid using malloc. The difference is that in earlier versions of the tools, this array was previously static and went into bss instead of on the stack. The thinking behind this was that if the user is using C I/O they would probably be using a decent stack size anyway and still want to minimize bss.
Knowing that the C I/O support may not suit every user as provided, we support the different levels of format specifier (via the compiler option --printf_support=full, minimal, nofloat) and also provide source so customers can change it to suit their needs. For instance, the source file _printfi.c can be changed to make the array static and _printfi.c can be recompiled.
With your infos, I have really tried hard to get the information about the compiler option -printf_support and about memory and stack usage.
I have found NO INFO at all.
The compiler option is not mentioned in the compiler readme since 5.0 - and definitely not in the only compiler manual spru514c.pdf which is still preliminary and from September 2007.
I have only found the info that there is a compiler option -printf_support in the help that is shown when calling the compiler without any parameters.
No info regarding memory and stack usage.
I think it all shows that the actual cgtools documentation is really poor and outdated and should definitely be reworked - including rts library documentation.
Stephan,
I agree, the C28x compiler documentation very much needs to be updated. There are a few activities going on with the compiler this year and one of them is definitly updated documentation. I know that very unfortunately this won't help you at this moment.
I started searching and I did find this in the C6x documentation. I'm not sure if this gives you more infor than you already found:
========
--printf_support={full| Enables support for smaller, limited versions of the printf and sprintf
nofloat|minimal} run-time-support functions. The valid values are:
* full: Supports all format specifiers. This is the default.
* nofloat: Excludes support for printing floating point values. Supports all format specifiers except %f, %g, %G, %e, and %E.
* minimal: Supports the printing of integer, char, or string values without width or precision flags. Specifically, only the %%, %d, %o, %c, %s, and %x format specifiers are supported
There is no run-time error checking to detect if a format specifier is used
for which support is not included. The --printf_support option precedes
the --run_linker option, and must be used when performing the final link.
========
I'm going to move this thread to the codegen forum to see if anyone there can help out.
-Lori
I can verify that the information in the posts by Aarti and Lori is correct and relevant for C2000.
Thanks and regards,
-George
Okay, thank you all.
I will wait for the updated documentation and live with the self-written sprintf until then.