cancel
Showing results for 
Search instead for 
Did you mean: 

How do I disable printf in library?

TV
Associate II

Greetings!

I'm using this printf library: https://github.com/mpaland/printf

And would like to completely disable the printf in the C Libraries that come with STM32CubeIDE. I went as far as renaming my printf to DBG, but when I look in the map file there is still printf included from the library. Here is an example:

 .text._vfprintf_r

               0x000000000800dc4c     0x260 c:/st/stm32cubeide_1.7.0/stm32cubeide/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.0.202111181127/tools/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard\libc_nano.a(lib_a-nano-vfprintf.o)

               0x000000000800dc4c               _vfprintf_r

               0x000000000800dc4c               _vfiprintf_r

 .text._printf_common

               0x000000000800deac      0xda c:/st/stm32cubeide_1.7.0/stm32cubeide/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.0.202111181127/tools/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard\libc_nano.a(lib_a-nano-vfprintf_i.o)

               0x000000000800deac               _printf_common

 *fill*        0x000000000800df86       0x2

 .text._printf_i

               0x000000000800df88     0x24c c:/st/stm32cubeide_1.7.0/stm32cubeide/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.0.202111181127/tools/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard\libc_nano.a(lib_a-nano-vfprintf_i.o)

               0x000000000800df88               _printf_i

Is there anyway to get rid of this extra code that I just do not want to use?

Thank you!

5 REPLIES 5
TDK
Guru

Not sure, but if I don't use printf, it doesn't appear in the map file. Are you sure it's not being used somewhere in the program? Is the replacement printf include appearing before all instances of printf?

There is this checkbox, but it had no effect for me when I tried it with printf.

0693W00000LzUFHQA3.png 

As a note, I use the same printf replacement in my code. It works well.

If you feel a post has answered your question, please click "Accept as Solution".
TV
Associate II

That box is checked.

I did a global search for "printf" and don't see anything in the project other than things like vsnprintf_ that is in the third party library I mentioned.

I would have thought this would be trivial fix. I don't see a way to disable the nano lib, seems like it gets included in some form.

Thanks for your response.

I guess technically you need to look for "printf_". If that's not in your map file, your program is not using the replacement printf library.

If you feel a post has answered your question, please click "Accept as Solution".
TV
Associate II

I had renamed the function to DBG and that is in the map file. I can trace into it with the debugger too. So i know that is being used.

Was there any resolution to this? Anyway to disable the built in printf libraries to guarantee our own is being used?