Skip to content

Commit 16ed5f2

Browse files
committed
Added newlib-nano
1 parent eb18b79 commit 16ed5f2

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed
Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
1-
# Using ARM microlib in Mbed OS
1+
# Using code optimised C libraries in Mbed OS
2+
3+
Both the `ARM` and `GCC_ARM` toolchains support code optimised versions of their C standard libraries. You can build with them by creating a `mbed_app.json` with the following contents:
4+
5+
```
6+
{
7+
"target_overrides": {
8+
"*": {
9+
"target.c_lib": "small"
10+
}
11+
}
12+
}
13+
```
14+
This will link your application with `microlib` in the case of the `ARM` toolchain and `newlib-nano` for the `GCC_ARM` toolchain.
15+
16+
## Newlib-nano
17+
18+
[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.
19+
20+
## ARM microlib
221

3-
## What is microlib
422
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.
523
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).
624

7-
## Differences between ARM C standard library and microlib
25+
### Differences between ARM C standard library and microlib
826
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.
927

1028
In particular:
11-
* Microlib has no reentrant variant. Microlib does not provide mutex locks to guard against code that is not thread safe.
29+
* Microlib has no reentrant variant. Microlib does not provide mutex locks to guard against code that is not thread-safe.
1230
* 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.
1331

1432
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.
@@ -29,24 +47,11 @@ Once you have completed the steps above, add `small` to the `supported_c_libs` p
2947
}
3048
```
3149

32-
## Building Mbed OS with microlib
33-
You can build with microlib by creating a `mbed_app.json` with the following contents:
34-
35-
```
36-
{
37-
"target_overrides": {
38-
"*": {
39-
"target.c_lib": "small"
40-
}
41-
}
42-
}
43-
```
44-
4550
### Note on uARM toolchain
4651
The uARM toolchain is the ARMC6 toolchain with the ARM microlib, the C micro-library. This toolchain will be deprecated after 5.15.
4752

48-
### Note on bare metal
53+
## Bare metal mode
4954

50-
If your application does not use a RTOS then you should build it in the bare metal mode to achieve memory savings. It is safe to use microlib in bare metal mode and we recommend using it.
55+
If your application does not use a RTOS then you should build it in the bare metal mode to achieve memory savings. It is safe to use microlib or newlib-nano in bare metal mode and we recommend using them.
5156

52-
An application can build with microlib in non bare metal mode. Be aware of the microlib restrictions noted earlier, in particular that it is not thread safe.
57+
A Mbed OS application can build with microlib or newlib-nano in non bare metal mode. Be aware of the libraries restrictions noted earlier, in particular in regard to thread-safety.

0 commit comments

Comments
 (0)