Author Topic: Putting MPLAB / Harmony 3 project .text section on a diet...  (Read 1576 times)

0 Members and 1 Guest are viewing this topic.

Offline fearlessTopic starter

  • Contributor
  • Posts: 20
  • Country: us
Putting MPLAB / Harmony 3 project .text section on a diet...
« on: March 03, 2022, 09:49:53 pm »
(This is largely cross-posted from https://www.microchip.com/forums/m1200895.aspx, but folks over here appear more attuned to this sort of thing...)

I've written and debugged a project using MPLAB.X V6.0.0 + Microchip Harmony 3.  The resulting .text section seemed somewhat large, so I looked at the .map file and noticed a bunch of unexpected library functions -- notably _printf_float -- were included.  (As far as I can tell, _printf_float drags in a boatload of other functions, like __pow5mult, _Balloc, _Bfree, etc).

I don't see any place in my code that I'm actually printing floating point number.  Nor did I see any options in the Project => Properties =>  Conf => XC32 => xc32-ld or other places that would give me a trimmed-down version of printf().  (This was something that Microchip Studio offered...)
 
So: is there a way to either:

    find what code I've written that triggers the loading of _printf_float, or
    set some options that forces a trimmed-down library

?
 
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: Putting MPLAB / Harmony 3 project .text section on a diet...
« Reply #1 on: March 04, 2022, 03:22:00 am »
FWIW, The example project here: https://microchipdeveloper.com/harmony3:same54-getting-started-training-module also ends up including the float printf functions, and I don't see it using them either.  (I checked through the whole disassembly for calls to printf-like functions.  There weren't any.)

XC32 for MIPS PIC32 has a "-msmart-io" option that is supposed to intelligently choose appropriate printf() libraries, but it doesn't seem to have any effect on ARM chips.

I don't see any options for specifying which system libraries are used.    There is an option in the XC32 "general" panel to "exclude floating point code", but it only lists "not applicable" for SAME54.

It's sucking in .../pic32c/lib/thumb/v7e-m+fp/hard/libc_nano.a - perhaps the assumption is that any CPU with hardware floating point would always use the floating point printf...  (not that single precision floating point HW helps much when C wants everything to be "double"...)

 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5907
  • Country: es
Re: Putting MPLAB / Harmony 3 project .text section on a diet...
« Reply #2 on: June 02, 2022, 02:31:33 am »
Late, but try using iprintf instead printf, might remove the extra float support.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf