Skip to content

Commit f3e7fc7

Browse files
committed
Review comments
1 parent 4730530 commit f3e7fc7

File tree

1 file changed

+33
-17
lines changed

1 file changed

+33
-17
lines changed

docs/program-setup/bare_metal/mbed2_porting.md

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Porting an Mbed 2 target to Mbed OS 6 bare metal
1+
# Porting an Mbed OS 2 target to Mbed OS 6 bare metal
22

3-
The Mbed OS bare metal profile removes the RTOS and provides fewer features compared to Mbed OS 6. This profile offers the same functionality as Mbed 2 and allows targets to access features that we've added to Mbed OS 5 and 6. This document describes how to configure an Mbed 2 target to run in Mbed OS 6 bare metal and how to validate the port.
3+
The Mbed OS bare metal profile removes the RTOS and provides fewer features compared to Mbed OS 6. This profile offers the same functionality as Mbed OS 2 and allows targets to access features that we have added to more recent versions of Mbed OS. This document describes how to configure an Mbed OS 2 target for bare metal and validate the port.
44

55
## Configuring your target
66

@@ -9,51 +9,67 @@ You will use the blinky bare metal Mbed OS example and make it run on your targe
99
The main steps are:
1010
1. Clone [mbed-os-example-blinky-baremetal](https://github.com/ARMmbed/mbed-os-example-blinky-baremetal).
1111
1. Edit `targets.json`. In this step, you will configure your target to support Mbed OS 6 and add bare metal configuration parameters.
12-
1. Compile and run mbed-os-example-blinky-baremetal. In this step, you will validate the configuration and troubleshoot any issue.
12+
1. Build and run mbed-os-example-blinky-baremetal. In this step, you will validate the configuration and troubleshoot any issue.
1313

1414
### Clone mbed-os-example-blinky-baremetal
1515

16-
Run the following commands:
17-
1. `git clone https://github.com/ARMmbed/mbed-os-example-blinky-baremetal`
18-
1. `cd mbed-os-example-blinky-baremetal`
16+
Run the following command:
17+
- `git clone https://github.com/ARMmbed/mbed-os-example-blinky-baremetal`
18+
19+
And then change directory:
20+
- `cd mbed-os-example-blinky-baremetal`
1921

2022
### Edit targets.json
2123

2224
Find your target in `mbed-os/targets/targets.json` and update its configuration as described below.
2325

2426
Configure your target to support Mbed OS 6:
25-
- Remove the `release_versions` property as it is no longer necessary to specify the list of major versions of Mbed OS that the target supports.
27+
- Remove the `release_versions` property as it is no longer required.
2628
```
2729
"release_versions": ["2"]
2830
```
2931

30-
- Add the `supported_application_profiles` property to indicate that the application profile supported by this target is bare metal. This property is currently ignored by the build tools as it is not yet supported.
32+
- Add the `supported_application_profiles` property to indicate that the application profile supported by this target is bare metal.
3133
```
32-
"supported_application_profiles" : ["BARE-METAL"]
34+
"supported_application_profiles" : ["bare-metal"]
3335
```
3436

35-
- Override the default `supported_c_libs` property to link with the smaller C libraries. Both the ARM and GCC_ARM toolchains support optimized versions of the C standard libraries, microlib and newlib-nano respectively. We recommend using them with the bare metal profile to achieve lower memory footprints. For each toolchain, if there is enough memory to link with the standard library, then add the corresponding "std" library to the list. For example:
37+
- Override `supported_c_libs` property to link with the smaller C libraries. The default for all targets is defined as follows:
38+
```
39+
"supported_c_libs": {
40+
"arm": ["std"],
41+
"gcc_arm": ["std"], ["small"],
42+
"iar": ["std"]
43+
}
44+
```
3645

46+
Both the ARM and GCC_ARM toolchains support optimized versions of the C standard libraries, microlib and newlib-nano respectively. We recommend using them with the bare metal profile to achieve lower memory footprints. Ultra constrained targets should override `supported_c_libs` as follows:
47+
```
48+
"supported_c_libs": {
49+
"arm": ["small"],
50+
"gcc_arm": ["small"]
51+
}
52+
```
53+
54+
For each toolchain, if there is enough memory to link with the standard library, then add the corresponding "std" library to the list. For example:
3755
```
3856
"supported_c_libs": {
3957
"arm": ["std"], ["small"],
4058
"gcc_arm": ["std"], ["small"],
4159
"iar": ["std"]
4260
}
4361
```
44-
<span class="notes">**Note:** For ARM, your target scatter file needs to have a two-region memory model. If the build system throws an error when compiling with microlib, you can find more information [here](https://os.mbed.com/docs/mbed-os/v6.0-preview/reference/using-small-c-libraries.html).</span>
62+
<span class="notes">**Note:** For ARM, your target scatter file needs to have a two-region memory model. If the build system throws an error (presence of undefined symbols `Image$$ARM_LIB_HEAP$$ZI$$Base`, `Image$$ARM_LIB_HEAP$$ZI$$Length`, `Image$$ARM_LIB_HEAP$$ZI$$Limit`) when compiling with microlib, you can find more information [here](https://os.mbed.com/docs/mbed-os/v6.0-preview/reference/using-small-c-libraries.html).</span>
4563

4664
<span class="notes">**Note:** The IAR toolchain does not have a small C library.</span>
4765

48-
- Set the `c_lib` property to indicate which C library should be linked by the build tools. If your target has `"default_lib": "small"` defined, then replace with `"c_lib" : "small"`. Otherwise add `"c_lib" : "small"`. We recommend that ultra constrained devices running bare metal applications link with the small C libraries by default.
66+
- Set the `c_lib` property to indicate which C library should be used by the build tools. If your target has `"default_lib": "small"` defined, then replace it with `"c_lib" : "small"`. Otherwise add `"c_lib" : "small"`. We recommend that ultra constrained devices running bare metal applications link with the small C libraries by default.
4967

5068
<span class="notes">**Note:** If a toolchain does not support a small C library and `c_lib` is set to `small`, the build tools will revert to linking with the standard C library, provided that it is listed in `supported_c_libs` for the given toolchain.</span>
5169

5270
- If `default_toolchain` is set to `uARM`, then replace it with `ARM` and remove `uARM` from `supported_toolchains`. Support for the uARM toolchain, which is the ARM toolchain with microlib, has been removed. Setting `c_lib` to `small` ensures that microlib is used when the ARM toolchain is selected.
5371

54-
<span class="notes">**Note:** As mentioned above, to successfully build with microlib, the target must define a two-region memory model. You might need to replace the content of the TOOLCHAIN_ARM_STD linker file with that of TOOLCHAIN_ARM_MICRO which already includes a two-region memory model linker file.
55-
56-
you might need to replace the content of the TOOLCHAIN_ARM_STD scatter file with that of TOOLCHAIN_ARM_MICRO. This is because the TOOLCHAIN_ARM_MICRO linker file defines a two-region memory model which is necessary to build with microlib.</span>
72+
<span class="notes">**Note:** As mentioned above, to successfully build with microlib, the target must define a two-region memory model. You might need to replace the content of the TOOLCHAIN_ARM_STD linker file with that of TOOLCHAIN_ARM_MICRO which includes a two-region memory model linker file.</span>
5773

5874
- If your board does not have a low power ticker, ensure that tickless is enabled using the microsecond ticker as follows:
5975
```
@@ -62,14 +78,14 @@ you might need to replace the content of the TOOLCHAIN_ARM_STD scatter file with
6278
}
6379
```
6480

65-
- It might be necessary to reduce the stack size allocated for your target if it does not have enough RAM. The stack size is configured by setting a value for the `boot-stack-size` attribute; this value must be a multiple of 8 for alignment purposes. By default all targets are configured to have a boot stack size of 0x1000 (4096 bytes) in bare metal. However, this must be overridden if inadequate for your target. We recommend to reduce the boot stack size to 0x400 (1096 bytes) if your target has 8KB of RAM and to 0x300 (768 bytes) if your target has 4KB of RAM.
81+
- It might be necessary to reduce the stack size allocated for your target if it does not have enough RAM. The stack size is configured by setting a value for the `boot-stack-size` attribute; this value must be a multiple of 8 for alignment purposes. By default all targets are configured to have a boot stack size of 0x1000 (4096 bytes) in bare metal. However, this must be overridden if inadequate for your target. We recommend to reduce the boot stack size to 0x400 (1024 bytes) if your target has 8KB of RAM and to 0x300 (768 bytes) if your target has 4KB of RAM.
6682
```
6783
"overrides": {
6884
"boot-stack-size": "0x400"
6985
}
7086
```
7187

72-
### Compile and run mbed-os-example-blinky-baremetal
88+
### Build and run mbed-os-example-blinky-baremetal
7389

7490
Build the application and program your target: `mbed compile -m <YOUR_TARGET> -t <TOOLCHAIN> --flash --sterm`.
7591

0 commit comments

Comments
 (0)