Skip to content

Commit 8b2d66c

Browse files
committed
Enable minimal-printf by default for all builds
Also reenable floating point by default.
1 parent dc63202 commit 8b2d66c

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

platform/mbed_lib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
},
146146
"minimal-printf-enable-floating-point": {
147147
"help": "Enable floating point printing when using mprintf profile",
148-
"value": false
148+
"value": true
149149
},
150150
"minimal-printf-set-floating-point-max-decimals": {
151151
"help": "Maximum number of decimals to be printed",

platform/source/minimal-printf/README.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ Supports:
1212
* %u: unsigned integer [h, hh, (none), l, ll, z, j, t].
1313
* %x: unsigned integer [h, hh, (none), l, ll, z, j, t], printed as hexadecimal number (e.g., ff).
1414
* %X: unsigned integer [h, hh, (none), l, ll, z, j, t], printed as hexadecimal number (e.g., FF).
15-
* %f: floating point (disabled by default).
16-
* %F: floating point (disabled by default, treated as %f).
17-
* %g: floating point (disabled by default, treated as %f).
18-
* %G: floating point (disabled by default, treated as %f).
15+
* %f: floating point (enabled by default).
16+
* %F: floating point (enabled by default, treated as %f).
17+
* %g: floating point (enabled by default, treated as %f).
18+
* %G: floating point (enabled by default, treated as %f).
1919
* %c: character.
2020
* %s: string.
2121
* %p: pointer (e.g. 0x00123456).
@@ -28,19 +28,29 @@ Floating point limitations:
2828

2929
## Usage
3030

31+
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:
3132

32-
To replace the standard implementation of the printf functions with the ones in this library:
33-
34-
Modify your application configuration file to override the parameter `target.printf` with the value `minimal-printf` as shown below:
33+
Modify your application configuration in `mbed_app.json` file to override the parameter `target.printf_lib` with the value `minimal-printf` as shown below:
3534

3635
```json
3736
"target_overrides": {
3837
"*": {
39-
"target.printf": "minimal-printf",
38+
"target.printf_lib": "minimal-printf"
4039
}
4140
}
4241
```
4342

43+
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.
44+
45+
Modify your application configuration in `mbed_app.json` file to override the parameter `target.printf_lib` with the value `std` as shown below:
46+
47+
```json
48+
"target_overrides": {
49+
"*": {
50+
"target.printf_lib": "std"
51+
}
52+
}
53+
```
4454

4555
## Configuration
4656

@@ -57,7 +67,7 @@ Minimal printf is configured by the following parameters defined in `platform/mb
5767
},
5868
"minimal-printf-enable-floating-point": {
5969
"help": "Enable floating point printing when using minimal-printf profile",
60-
"value": false
70+
"value": true
6171
},
6272
"minimal-printf-set-floating-point-max-decimals": {
6373
"help": "Maximum number of decimals to be printed",
@@ -67,7 +77,7 @@ Minimal printf is configured by the following parameters defined in `platform/mb
6777
}
6878
```
6979

70-
By default, 64 bit integers support is enabled.
80+
By default, 64 bit integers and floating point support is enabled.
7181

7282
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).
7383

targets/targets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"default_lib": "std",
1616
"bootloader_supported": false,
1717
"static_memory_defines": true,
18-
"printf_lib": "std",
18+
"printf_lib": "minimal-printf",
1919
"supported_c_libs": {
2020
"arm": ["std"],
2121
"gcc_arm": ["std", "small"],

0 commit comments

Comments
 (0)