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
+23-19Lines changed: 23 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -1,38 +1,38 @@
1
1
# Porting an Mbed 2 target to Mbed OS 6 bare metal
2
2
3
-
Mbed OS bare metal provides fewer features compared to a full RTOS platform which makes it suitable for constrained microcontrollers. This document describes how to configure an Mbed 2 target to run in bare metal mode 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 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.
4
4
5
5
## Configuring your target
6
6
7
-
You will use the blinky bare metal Mbed OS example and make it run on your target. The configuration will be validated upon successful compilation of the example.
7
+
You will use the blinky bare metal Mbed OS example and make it run on your target. The configuration will be validated upon successful run of the example.
1. Edit `targets.json`. In this step, you will configure your target to run in Mbed OS 6 and then add configuration parameters for the bare metal mode.
12
-
1. Compile mbed-os-example-blinky-baremetal. In this step, you will validate the configuration and troubleshoot any issue.
11
+
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.
Find your target in `targets.json` and update its configuration as described below.
22
+
Find your target in `mbed-os/targets/targets.json` and update its configuration as described below.
23
23
24
-
Configure your target to run in Mbed OS 6:
24
+
Configure your target to support Mbed OS 6:
25
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.
26
26
```
27
27
"release_versions": ["2"]
28
28
```
29
29
30
-
- Add a new property (this property is not supported by the tools yet therefore it is ignored) `supported_application_modes` to indicate that the application mode supported by this target is bare metal.
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.
31
31
```
32
-
"supported_application_modes" : ["BARE-METAL"]
32
+
"supported_application_profiles" : ["BARE-METAL"]
33
33
```
34
34
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 their C standard libraries, microlib and newlib-nano. We recommend using them with the bare metal profile. 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:
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:
36
36
37
37
```
38
38
"supported_c_libs": {
@@ -49,9 +49,11 @@ Configure your target to run in Mbed OS 6:
49
49
50
50
<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
51
52
-
- If `default_toolchain` is set to `uARM`, then replace with `ARM` and remove `uARM` from `supported_toolchains`. The uARM toolchain, which is the ARMC6 toolchain with the micro C library has been deprecated and it is no longer possible to use it. In the previous step, `c_lib`was set to `small`to ensure that the micro C library will be linked by the tools when using the ARM toolchain.
52
+
- 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
53
54
-
<spanclass="notes">**Note:** As mentionned above, to successfully build with the ARM micro C library, 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>
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>
55
57
56
58
- If your board does not have a low power ticker, ensure that tickless is enabled using the microsecond ticker as follows:
57
59
```
@@ -60,28 +62,30 @@ Configure your target to run in Mbed OS 6:
60
62
}
61
63
```
62
64
63
-
- 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 mode, 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 if your target has 4KB of RAM.
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.
64
66
```
65
67
"overrides": {
66
68
"boot-stack-size": "0x400"
67
69
}
68
70
```
69
71
70
-
### Compile mbed-os-example-blinky-baremetal
72
+
### Compile and run mbed-os-example-blinky-baremetal
73
+
74
+
Build the application and program your target: `mbed compile -m <YOUR_TARGET> -t <TOOLCHAIN> --flash --sterm`.
71
75
72
-
Compile the example for all three toolchains: `mbed compile -m <YOUR_TARGET> -t <TOOLCHAIN>`.
76
+
The application running on the target should print a text on the console. Repeat for all supported toolchains.
73
77
74
78
Troubleshoot any issue.
75
79
76
80
## Validating the port
77
81
78
-
To validate the bare metal target configuration, you will execute the Mbed OS greentea test suite in bare metal mode. A subset of the tests are automatically skipped by the framework because they are not supported in bare metal mode, either because the underlying functionality has not been ported to bare metal or some tests require RTOS features, for examples tests based on multi-threading.
82
+
To validate the bare metal target configuration, you will execute the Mbed OS greentea test suite with the bare metal configuration. A subset of the tests are automatically skipped by the framework either because the underlying functionality has not been ported to bare metal or because some tests require RTOS features, for examples more complex tests based on multi-threading.
79
83
80
84
- First, change directory.
81
85
```
82
86
cd mbed-os
83
87
```
84
-
- Then execute the greentea test suite in bare metal mode for both GCC_ARM and ARM toolchains.
88
+
- Then execute the greentea test suite with the bare metal configuration for the supported toolchains.
85
89
```
86
90
mbed test -m <YOUR_TARGET> -t <TOOLCHAIN> --app-config TESTS/configs/baremetal.json
0 commit comments