Skip to content

Commit 246c0cb

Browse files
author
Amanda Butler
authored
Edit c_small_libs.md
Make minor copy edits, mostly for active voice.
1 parent eb59b50 commit 246c0cb

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed
Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<h1 id="using-small-c-libraries">Using small C libraries in Mbed OS bare metal</h1>
22

3-
If your application does not use a RTOS then you should build it in the bare metal mode to achieve memory savings. Both the `ARM` and `GCC_ARM` toolchains support code optimised versions of their C standard libraries, `microlib` and `newlib-nano`. It is safe to use these smaller C libraries in bare metal mode and we recommend using them.
3+
If your application does not use an RTOS, build it in the bare metal mode to achieve memory savings. Both the `ARM` and `GCC_ARM` toolchains support code optimized versions of their C standard libraries, `microlib` and `newlib-nano`. It is safe to use these smaller C libraries in bare metal mode, and we recommend using them.
44

5-
You can build with the smaller C libraries by creating a `mbed_app.json` with the following contents:
5+
You can build with the smaller C libraries by creating an `mbed_app.json` with the following contents:
66

77
```
88
{
@@ -15,34 +15,40 @@ You can build with the smaller C libraries by creating a `mbed_app.json` with th
1515
}
1616
```
1717

18-
This will link your application with `microlib` in the case of the `ARM` toolchain and `newlib-nano` for the `GCC_ARM` toolchain.
18+
This links your application with `microlib` for the `ARM` toolchain and `newlib-nano` for the `GCC_ARM` toolchain.
1919

2020
## Newlib-nano
2121

22-
[Newlib-nano](https://community.arm.com/developer/ip-products/system/b/embedded-blog/posts/shrink-your-mcu-code-size-with-gcc-arm-embedded-4-7) is an open source C library targeting embedded microcontrollers. It is based on newlib but is much smaller in size. One restriction is that newlib-nano is not thread-safe and should not be used by an application that uses the RTOS.
22+
[Newlib-nano](https://community.arm.com/developer/ip-products/system/b/embedded-blog/posts/shrink-your-mcu-code-size-with-gcc-arm-embedded-4-7) is an open source C library targeting embedded microcontrollers. It is based on newlib but is much smaller. One restriction is that newlib-nano is not thread-safe, so an application that uses the RTOS should not use it.
2323

24-
## ARM microlib
24+
## Arm microlib
2525

26-
Microlib is an alternative library to the default C library. It is intended for use with deeply embedded applications that must fit into extremely small memory footprints.
27-
These applications do not run under an operating system. More information can be found [here](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0808e/chr1358938937854.html).
26+
Microlib is an alternative library to the default C library. It is intended for deeply embedded applications that must fit into extremely small memory footprints.
2827

29-
### Differences between ARM C standard library and microlib
30-
There are a number of differences between microlib and the default C library. Follow [this link](https://developer.arm.com/docs/100073/0613/the-arm-c-micro-library/differences-between-microlib-and-the-default-c-library) for a complete list.
28+
These applications do not run under an operating system. You can find more information at the [Arm developer documentation](https://developer.arm.com/docs/100073/0613/the-arm-c-micro-library).
29+
30+
### Differences between Arm C standard library and microlib
31+
32+
To see a complete list of the differences between microlib and the default C library, please see the [Arm developer documentation](https://developer.arm.com/docs/100073/0613/the-arm-c-micro-library/differences-between-microlib-and-the-default-c-library).
3133

3234
In particular:
33-
* Microlib has no reentrant variant. Microlib does not provide mutex locks to guard against code that is not thread-safe.
34-
* Microlib does not support selectable one or two region memory models as the standard library does. Microlib provides only the two region memory model with separate stack and heap regions.
3535

36-
Since 5.12, Mbed OS supports a two region memory model for heap and stack. This means that the same scatter file can be used with both ARM C standard library and microlib.
36+
- Microlib has no re-entrant variant. Microlib does not provide mutex locks to guard against code that is not thread-safe.
37+
- Microlib does not support selectable one- or two-region memory models as the standard library does. Microlib provides only the two-region memory model with separate stack and heap regions.
38+
39+
Mbed OS supports a two-region memory model for heap and stack. This means you can use the same scatter file with both the Arm C standard library and microlib.
40+
41+
### Scatter file for Arm toolchain
3742

38-
### Scatter file for ARM toolchain
39-
By default, only a few targets have been tested with microlib. If your target has not been tested then the build system will throw an error. In that case, you need to check if the ARM scatter file for your target supports the two region memory model i.e. are `ARM_LIB_HEAP` and `ARM_LIB_STACK` regions defined? This file is located in `targets/.../device/TOOLCHAIN_ARM_STD/your_target_scatter_file.sct`)
40-
* If yes then the scatter file can be used unmodified for microlib.
41-
* If no then check if your target was ported to uARM:
42-
* If yes then replace the `TOOLCHAIN_ARM_STD` scatter file with `../TOOLCHAIN_ARM_MICRO/microlib_scatter_file.sct`
43-
* If no then you need to update the scatter file to use the two region memory model. More information on the two region memory model can be found [here](https://github.com/ARMmbed/mbed-os/blob/master/docs/design-documents/platform/memory-model/ram_memory_model.md#proposed-ram-memory-model). An example of a scatter file updated for the two region memory model can be found [here](https://github.com/ARMmbed/mbed-os/pull/9571/files?file-filters%5B%5D=.sct#diff-0ce0bec61a6d5ac63ab5ae3afcfe7119).
43+
By default, only a few targets have been tested with microlib. If your target has not been tested, the build system will throw an error. In that case, you need to check if the Arm scatter file for your target supports the two-region memory model. In other words, are the `ARM_LIB_HEAP` and `ARM_LIB_STACK` regions defined? This file is located in `targets/.../device/TOOLCHAIN_ARM_STD/your_target_scatter_file.sct`):
44+
45+
- If yes, you can use the scatter file unmodified for microlib.
46+
- If no, check if your target was ported to uARM:
47+
- If yes, replace the `TOOLCHAIN_ARM_STD` scatter file with `../TOOLCHAIN_ARM_MICRO/microlib_scatter_file.sct`.
48+
- If no, you need to update the scatter file to use the two-region memory model. You can find more information on the two-region memory model in the [design document](https://github.com/ARMmbed/mbed-os/blob/master/docs/design-documents/platform/memory-model/ram_memory_model.md#proposed-ram-memory-model). For more details, see this example of a [scatter file updated for the two-region memory model](https://github.com/ARMmbed/mbed-os/pull/9571/files?file-filters%5B%5D=.sct#diff-0ce0bec61a6d5ac63ab5ae3afcfe7119).
49+
50+
After you have completed the steps above, add `small` to the `supported_c_libs` parameter for your target in `targets.json`:
4451

45-
Once you have completed the steps above, add `small` to the `supported_c_libs` parameter for your target in `targets.json`:
4652
```
4753
"supported_c_libs": {
4854
"arm": ["std", "small"],
@@ -52,4 +58,5 @@ Once you have completed the steps above, add `small` to the `supported_c_libs` p
5258
```
5359

5460
### Note on uARM toolchain
55-
The uARM toolchain is the ARMC6 toolchain with the ARM microlib, the C micro-library. This toolchain will be deprecated after 5.15.
61+
62+
The uARM toolchain is the ARMC6 toolchain with the Arm microlib, the C micro-library. This toolchain will be deprecated after 5.15.

0 commit comments

Comments
 (0)