.. | |||
CMakeLists.txt | 2 years ago | ||
README.md | 3 years ago | ||
mbed_printf_armlink_overrides.c | 4 years ago | ||
mbed_printf_implementation.c | 2 years ago | ||
mbed_printf_implementation.h | 4 years ago | ||
mbed_printf_wrapper.c | 4 years ago |
Library supports both printf and snprintf in around 1300 bytes of flash.
Prints directly to stdio/UART without using malloc. Width size and prepending zero modifiers are supported. All other flags are ignored. There is no error handling if a writing error occurs.
Supports:
Note that support for:
minimal-printf-enable-64-bit
config is set to true
(default).minimal-printf-enable-floating-point
config is set to true
(disabled by default).Unrecognized format specifiers are treated as ordinary characters.
Floating point limitations:
As of Mbed OS 6.0 this is enabled by default. To replace the standard implementation of the printf functions with the ones in this library for older versions of Mbed:
Modify your application configuration file to override the parameter target.printf_lib
with the value minimal-printf
as shown below:
{ "target_overrides": { "*": { "target.printf_lib": "minimal-printf" } } }
If your application requires more advanced functionality, you'll need to revert to using standard version of printf/snprintf. Please note that it will result in significant ROM usage increase. In case you are using minimal version of standard C library advanced functionality may not be present.
Modify your application configuration in mbed_app.json
file to override the parameter target.printf_lib
with the value std
as shown below:
"target_overrides": { "*": { "target.printf_lib": "std" } }
Minimal printf is configured by the following parameters defined in platform/mbed_lib.json
:
{ "name": "platform", "config": { "minimal-printf-enable-64-bit": { "help": "Enable printing 64 bit integers when using minimal printf library", "value": true }, "minimal-printf-enable-floating-point": { "help": "Enable floating point printing when using minimal printf library", "value": false }, "minimal-printf-set-floating-point-max-decimals": { "help": "Maximum number of decimals to be printed when using minimal printf library", "value": 6 } } }
By default, 64 bit integers support is enabled, but floating point support is disabled to increase memory savings.
If your application needs to override the default configuration add following section to your mbed_app.json
:
"target_overrides": { "*": { "target.printf_lib": "minimal-printf", "platform.minimal-printf-enable-floating-point": false, "platform.minimal-printf-set-floating-point-max-decimals": 6, "platform.minimal-printf-enable-64-bit": false } }
https://github.com/ARMmbed/mbed-os-example-blinky application compiled with the different toolchains.
Blinky application size on K64F/GCC_ARM
Floating point | 64 bit integers | Flash | RAM | |
---|---|---|---|---|
mbed-printf | 32,972 | 11,608 | ||
mbed-printf | X | 33,116 | 11,608 | |
mbed-printf | X | X | 35,856 | 11,608 |
std printf | X | X | 55,766 | 12,104 |
Blinky application size on K64F/ARMC6
Floating point | 64 bit integers | Flash | RAM | |
---|---|---|---|---|
mbed-printf | 33,585 | xxxxx | ||
mbed-printf | X | 33,679 | xxxxx | |
mbed-printf | X | X | 36,525 | xxxxx |
std printf | X | X | 39,128 | xxxxx |
Blinky application size on K64F/IAR
Floating point | 64 bit integers | Flash | RAM | |
---|---|---|---|---|
mbed-printf | 31,439 | 8,493 | ||
mbed-printf | X | 31,579 | 8,493 | |
mbed-printf | X | X | 33,387 | 8,493 |
std printf | X | X | 36,643 | 8,553 |
https://github.com/ARMmbed/mbed-os-example-blinky-baremetal application compiled with the different toolchains.
Blinky application size on K64F/GCC_ARM
Floating point | 64 bit integers | Flash | RAM | |
---|---|---|---|---|
mbed-printf | 19,660 | 5,368 | ||
mbed-printf | X | 19,804 | 5,368 | |
mbed-printf | X | X | 22,548 | 5,368 |
std printf | X | X | 35,292 | 5,864 |
Blinky application size on K64F/ARMC6
Floating point | 64 bit integers | Flash | RAM | |
---|---|---|---|---|
mbed-printf | 18,764 | xxxxx | ||
mbed-printf | X | 18,764 | xxxxx | |
mbed-printf | X | X | 18,764 | xxxxx |
std printf | X | X | 25,403 | xxxxx |
Blinky application size on K64F/IAR
Floating point | 64 bit integers | Flash | RAM | |
---|---|---|---|---|
mbed-printf | 19,623 | 1,737 | ||
mbed-printf | X | 19,763 | 1,737 | |
mbed-printf | X | X | 21,571 | 1,737 |
std printf | X | X | 18,059 | 1,281 |