You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/program-setup/bare_metal/mbed2_porting.md
+33-17Lines changed: 33 additions & 17 deletions
Original file line number
Diff line number
Diff 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
2
2
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.
4
4
5
5
## Configuring your target
6
6
@@ -9,51 +9,67 @@ You will use the blinky bare metal Mbed OS example and make it run on your targe
Find your target in `mbed-os/targets/targets.json` and update its configuration as described below.
23
25
24
26
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.
26
28
```
27
29
"release_versions": ["2"]
28
30
```
29
31
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.
31
33
```
32
-
"supported_application_profiles" : ["BARE-METAL"]
34
+
"supported_application_profiles" : ["bare-metal"]
33
35
```
34
36
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
+
```
36
45
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:
37
55
```
38
56
"supported_c_libs": {
39
57
"arm": ["std"], ["small"],
40
58
"gcc_arm": ["std"], ["small"],
41
59
"iar": ["std"]
42
60
}
43
61
```
44
-
<spanclass="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
+
<spanclass="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>
45
63
46
64
<spanclass="notes">**Note:** The IAR toolchain does not have a small C library.</span>
47
65
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.
49
67
50
68
<spanclass="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>
51
69
52
70
- 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.
53
71
54
-
<spanclass="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
+
<spanclass="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>
57
73
58
74
- If your board does not have a low power ticker, ensure that tickless is enabled using the microsecond ticker as follows:
59
75
```
@@ -62,14 +78,14 @@ you might need to replace the content of the TOOLCHAIN_ARM_STD scatter file with
62
78
}
63
79
```
64
80
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.
66
82
```
67
83
"overrides": {
68
84
"boot-stack-size": "0x400"
69
85
}
70
86
```
71
87
72
-
### Compile and run mbed-os-example-blinky-baremetal
88
+
### Build and run mbed-os-example-blinky-baremetal
73
89
74
90
Build the application and program your target: `mbed compile -m <YOUR_TARGET> -t <TOOLCHAIN> --flash --sterm`.
0 commit comments