mbed-os5 only for TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Committer:
kenjiArai
Date:
Tue Dec 31 06:02:27 2019 +0000
Revision:
1:9db0e321a9f4
updated based on mbed-os5.15.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kenjiArai 1:9db0e321a9f4 1 # Minimal printf and snprintf
kenjiArai 1:9db0e321a9f4 2
kenjiArai 1:9db0e321a9f4 3
kenjiArai 1:9db0e321a9f4 4 Library supports both printf and snprintf in 1252 bytes of flash.
kenjiArai 1:9db0e321a9f4 5
kenjiArai 1:9db0e321a9f4 6 Prints directly to stdio/UART without using malloc. All flags and precision modifiers are ignored.
kenjiArai 1:9db0e321a9f4 7 There is no error handling if a writing error occurs.
kenjiArai 1:9db0e321a9f4 8
kenjiArai 1:9db0e321a9f4 9 Supports:
kenjiArai 1:9db0e321a9f4 10 * %d: signed integer [h, hh, (none), l, ll, z, j, t].
kenjiArai 1:9db0e321a9f4 11 * %i: signed integer [h, hh, (none), l, ll, z, j, t].
kenjiArai 1:9db0e321a9f4 12 * %u: unsigned integer [h, hh, (none), l, ll, z, j, t].
kenjiArai 1:9db0e321a9f4 13 * %x: unsigned integer [h, hh, (none), l, ll, z, j, t], printed as hexadecimal number (e.g., ff).
kenjiArai 1:9db0e321a9f4 14 * %X: unsigned integer [h, hh, (none), l, ll, z, j, t], printed as hexadecimal number (e.g., FF).
kenjiArai 1:9db0e321a9f4 15 * %f: floating point (enabled by default).
kenjiArai 1:9db0e321a9f4 16 * %F: floating point (enabled by default, treated as %f).
kenjiArai 1:9db0e321a9f4 17 * %g: floating point (enabled by default, treated as %f).
kenjiArai 1:9db0e321a9f4 18 * %G: floating point (enabled by default, treated as %f).
kenjiArai 1:9db0e321a9f4 19 * %c: character.
kenjiArai 1:9db0e321a9f4 20 * %s: string.
kenjiArai 1:9db0e321a9f4 21 * %p: pointer (e.g. 0x00123456).
kenjiArai 1:9db0e321a9f4 22
kenjiArai 1:9db0e321a9f4 23 Unrecognized format specifiers are treated as ordinary characters.
kenjiArai 1:9db0e321a9f4 24
kenjiArai 1:9db0e321a9f4 25 Floating point limitations:
kenjiArai 1:9db0e321a9f4 26 * All floating points are treated as %f.
kenjiArai 1:9db0e321a9f4 27 * No support for inf, infinity or nan
kenjiArai 1:9db0e321a9f4 28
kenjiArai 1:9db0e321a9f4 29 ## Usage
kenjiArai 1:9db0e321a9f4 30
kenjiArai 1:9db0e321a9f4 31
kenjiArai 1:9db0e321a9f4 32 To replace the standard implementation of the printf functions with the ones in this library:
kenjiArai 1:9db0e321a9f4 33
kenjiArai 1:9db0e321a9f4 34 Modify your application configuration file to override the parameter `target.printf` with the value `minimal-printf` as shown below:
kenjiArai 1:9db0e321a9f4 35
kenjiArai 1:9db0e321a9f4 36 ```json
kenjiArai 1:9db0e321a9f4 37 "target_overrides": {
kenjiArai 1:9db0e321a9f4 38 "*": {
kenjiArai 1:9db0e321a9f4 39 "target.printf": "minimal-printf",
kenjiArai 1:9db0e321a9f4 40 }
kenjiArai 1:9db0e321a9f4 41 }
kenjiArai 1:9db0e321a9f4 42 ```
kenjiArai 1:9db0e321a9f4 43
kenjiArai 1:9db0e321a9f4 44
kenjiArai 1:9db0e321a9f4 45 ## Configuration
kenjiArai 1:9db0e321a9f4 46
kenjiArai 1:9db0e321a9f4 47
kenjiArai 1:9db0e321a9f4 48 Minimal printf is configured by the following parameters defined in `platform/mbed_lib.json`:
kenjiArai 1:9db0e321a9f4 49
kenjiArai 1:9db0e321a9f4 50 ```json
kenjiArai 1:9db0e321a9f4 51 {
kenjiArai 1:9db0e321a9f4 52 "name": "platform",
kenjiArai 1:9db0e321a9f4 53 "config": {
kenjiArai 1:9db0e321a9f4 54 "minimal-printf-enable-64-bit": {
kenjiArai 1:9db0e321a9f4 55 "help": "Enable printing 64 bit integers when using minimal-printf profile",
kenjiArai 1:9db0e321a9f4 56 "value": true
kenjiArai 1:9db0e321a9f4 57 },
kenjiArai 1:9db0e321a9f4 58 "minimal-printf-enable-floating-point": {
kenjiArai 1:9db0e321a9f4 59 "help": "Enable floating point printing when using minimal-printf profile",
kenjiArai 1:9db0e321a9f4 60 "value": false
kenjiArai 1:9db0e321a9f4 61 },
kenjiArai 1:9db0e321a9f4 62 "minimal-printf-set-floating-point-max-decimals": {
kenjiArai 1:9db0e321a9f4 63 "help": "Maximum number of decimals to be printed",
kenjiArai 1:9db0e321a9f4 64 "value": 6
kenjiArai 1:9db0e321a9f4 65 }
kenjiArai 1:9db0e321a9f4 66 }
kenjiArai 1:9db0e321a9f4 67 }
kenjiArai 1:9db0e321a9f4 68 ```
kenjiArai 1:9db0e321a9f4 69
kenjiArai 1:9db0e321a9f4 70 By default, 64 bit integers support is enabled.
kenjiArai 1:9db0e321a9f4 71
kenjiArai 1:9db0e321a9f4 72 If your target does not require some options then you can override the default configuration in your application `mbed_app.json` and achieve further memory optimisation (see next section for size comparison numbers).
kenjiArai 1:9db0e321a9f4 73
kenjiArai 1:9db0e321a9f4 74 In mbed_app.json:
kenjiArai 1:9db0e321a9f4 75
kenjiArai 1:9db0e321a9f4 76 ```json
kenjiArai 1:9db0e321a9f4 77 "target_overrides": {
kenjiArai 1:9db0e321a9f4 78 "*": {
kenjiArai 1:9db0e321a9f4 79 "target.printf": "minimal-printf",
kenjiArai 1:9db0e321a9f4 80 "platform.minimal-printf-enable-floating-point": false,
kenjiArai 1:9db0e321a9f4 81 "platform.minimal-printf-set-floating-point-max-decimals": 6,
kenjiArai 1:9db0e321a9f4 82 "platform.minimal-printf-enable-64-bit": false
kenjiArai 1:9db0e321a9f4 83 }
kenjiArai 1:9db0e321a9f4 84 }
kenjiArai 1:9db0e321a9f4 85 ```
kenjiArai 1:9db0e321a9f4 86
kenjiArai 1:9db0e321a9f4 87 ## Size comparison
kenjiArai 1:9db0e321a9f4 88
kenjiArai 1:9db0e321a9f4 89
kenjiArai 1:9db0e321a9f4 90 ### Blinky application
kenjiArai 1:9db0e321a9f4 91
kenjiArai 1:9db0e321a9f4 92 https://github.com/ARMmbed/mbed-os-example-blinky application compiled with the different toolchains.
kenjiArai 1:9db0e321a9f4 93
kenjiArai 1:9db0e321a9f4 94 Blinky application size on K64F/GCC_ARM
kenjiArai 1:9db0e321a9f4 95
kenjiArai 1:9db0e321a9f4 96 | | Floating point | 64 bit integers | Flash | RAM |
kenjiArai 1:9db0e321a9f4 97 | - | - | - | - | - |
kenjiArai 1:9db0e321a9f4 98 | mbed-printf | | | 32,972 | 11,608 |
kenjiArai 1:9db0e321a9f4 99 | mbed-printf | | X | 33,116 | 11,608 |
kenjiArai 1:9db0e321a9f4 100 | mbed-printf | X | X | 35,856 | 11,608 |
kenjiArai 1:9db0e321a9f4 101 | std printf | X | X | 55,766 | 12,104 |
kenjiArai 1:9db0e321a9f4 102
kenjiArai 1:9db0e321a9f4 103 Blinky application size on K64F/ARMC6
kenjiArai 1:9db0e321a9f4 104
kenjiArai 1:9db0e321a9f4 105 | | Floating point | 64 bit integers | Flash | RAM |
kenjiArai 1:9db0e321a9f4 106 | - | - | - | - | - |
kenjiArai 1:9db0e321a9f4 107 | mbed-printf | | | 33,585 | xxxxx |
kenjiArai 1:9db0e321a9f4 108 | mbed-printf | | X | 33,679 | xxxxx |
kenjiArai 1:9db0e321a9f4 109 | mbed-printf | X | X | 36,525 | xxxxx |
kenjiArai 1:9db0e321a9f4 110 | std printf | X | X | 39,128 | xxxxx |
kenjiArai 1:9db0e321a9f4 111
kenjiArai 1:9db0e321a9f4 112 Blinky application size on K64F/IAR
kenjiArai 1:9db0e321a9f4 113
kenjiArai 1:9db0e321a9f4 114 | | Floating point | 64 bit integers | Flash | RAM |
kenjiArai 1:9db0e321a9f4 115 | - | - | - | - | - |
kenjiArai 1:9db0e321a9f4 116 | mbed-printf | | | 31,439 | 8,493 |
kenjiArai 1:9db0e321a9f4 117 | mbed-printf | | X | 31,579 | 8,493 |
kenjiArai 1:9db0e321a9f4 118 | mbed-printf | X | X | 33,387 | 8,493 |
kenjiArai 1:9db0e321a9f4 119 | std printf | X | X | 36,643 | 8,553 |
kenjiArai 1:9db0e321a9f4 120
kenjiArai 1:9db0e321a9f4 121 ### Blinky bare metal application
kenjiArai 1:9db0e321a9f4 122
kenjiArai 1:9db0e321a9f4 123 https://github.com/ARMmbed/mbed-os-example-blinky-baremetal application compiled with the different toolchains.
kenjiArai 1:9db0e321a9f4 124
kenjiArai 1:9db0e321a9f4 125 Blinky application size on K64F/GCC_ARM
kenjiArai 1:9db0e321a9f4 126
kenjiArai 1:9db0e321a9f4 127 | | Floating point | 64 bit integers | Flash | RAM |
kenjiArai 1:9db0e321a9f4 128 | - | - | - | - | - |
kenjiArai 1:9db0e321a9f4 129 | mbed-printf | | | 19,660 | 5,368 |
kenjiArai 1:9db0e321a9f4 130 | mbed-printf | | X | 19,804 | 5,368 |
kenjiArai 1:9db0e321a9f4 131 | mbed-printf | X | X | 22,548 | 5,368 |
kenjiArai 1:9db0e321a9f4 132 | std printf | X | X | 35,292 | 5,864 |
kenjiArai 1:9db0e321a9f4 133
kenjiArai 1:9db0e321a9f4 134 Blinky application size on K64F/ARMC6
kenjiArai 1:9db0e321a9f4 135
kenjiArai 1:9db0e321a9f4 136 | | Floating point | 64 bit integers | Flash | RAM |
kenjiArai 1:9db0e321a9f4 137 | - | - | - | - | - |
kenjiArai 1:9db0e321a9f4 138 | mbed-printf | | | 18,764 | xxxxx |
kenjiArai 1:9db0e321a9f4 139 | mbed-printf | | X | 18,764 | xxxxx |
kenjiArai 1:9db0e321a9f4 140 | mbed-printf | X | X | 18,764 | xxxxx |
kenjiArai 1:9db0e321a9f4 141 | std printf | X | X | 25,403 | xxxxx |
kenjiArai 1:9db0e321a9f4 142
kenjiArai 1:9db0e321a9f4 143 Blinky application size on K64F/IAR
kenjiArai 1:9db0e321a9f4 144
kenjiArai 1:9db0e321a9f4 145 | | Floating point | 64 bit integers | Flash | RAM |
kenjiArai 1:9db0e321a9f4 146 | - | - | - | - | - |
kenjiArai 1:9db0e321a9f4 147 | mbed-printf | | | 19,623 | 1,737 |
kenjiArai 1:9db0e321a9f4 148 | mbed-printf | | X | 19,763 | 1,737 |
kenjiArai 1:9db0e321a9f4 149 | mbed-printf | X | X | 21,571 | 1,737 |
kenjiArai 1:9db0e321a9f4 150 | std printf | X | X | 18,059 | 1,281 |