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
Add application variants and Mbed OS bare metal tutorial
The example project has been re-written to include variants of an application
to blink an LED. The variants include a simple variant that uses a delay within
a loop and a more complex that creates threads and shows inter-thread
communication.
As the simpler variant is single-threaded, it showcases that some of Mbed OS
APIs can be used both with and without rtos (using Mbed OS bare metal profile).
Instructions are also provided to build the simple blinky application with
Mbed OS bare metal profile.
Runtime statistics has been removed and is only mentioned in the README. The
reader is invited to find out more. Runtime statistics is a topic on its own
and should not be implemented here.
The example project also exposes the user to Mbed OS parameter configuration
option.
The example shows Mbed OS features suchs as threads, thread delay, and inter-thread communication to blink an LED on supported [Mbed boards](https://os.mbed.com/platforms/). It also comes with configuration files to enable RTOS statistic and to build with [Mbed OS bare metal](https://os.mbed.com/docs/mbed-os/v5.14/reference/mbed-os-bare-metal.html) profile.
4
+
The example project contains variants of an application to blink an LED on supported [Mbed boards](https://os.mbed.com/platforms/).
5
5
6
6
The project can be built with all supported [Mbed OS build tools](https://os.mbed.com/docs/mbed-os/v5.14/tools/index.html). However, this example project specifically refers to the command line interface tool [Arm Mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli).
7
7
@@ -13,11 +13,20 @@ $ mbed compile -S
13
13
14
14
Clone this repository on your system and change the current directory to where the project was cloned.
15
15
16
-
Select the section for the version of the application you wish to build:
17
-
*[Building and Running the RTOS application](#blinky_rtos)
18
-
*[Building and Running the bare metal application](#blinky_bare_metal)
16
+
Modifying default Mbed OS configuration parameters can be done at application level using an application configuration file. By default ARM Mbed CLI looks for [`mbed_app.json`](https://os.mbed.com/docs/mbed-os/v5.14/reference/configuration.html), however the configuration file can be named anything. It can be passed to ARM Mbed CLI using the optional argument `--app-config` of the `compile` sub-command. This project comes with configuration files for the different variants and configurations of the blinky application.
19
17
20
-
## <aname="blinky_rtos"></a> Building and Running the RTOS application
18
+
Select the section for the variant of the application you wish to build:
The `main()` function calls `blinky_wait()`, as part of the single thread, which toggles the state of a digital output connected to an LED on the target.
28
+
29
+
### <aname="build_blinky_wait_rtos"></a> Building and Running
21
30
22
31
1. Connect a USB cable between the USB port on the target and the host computer.
23
32
2. Run the following command to build the example project and program the microcontroller flash memory:
@@ -26,131 +35,40 @@ Select the section for the version of the application you wish to build:
26
35
```
27
36
The binary is located at `./BUILD/<TARGET>/<TOOLCHAIN>/mbed-os-example-blinky.bin` and can alternatively be manually copied to the target which gets mounted on the host computer via USB.
28
37
29
-
### Application functionality
30
-
31
-
The `main()`functioncalls`blinky_rtos()`, as part of the main thread, which starts two threads: `thread_producer()` and `thread_consumer`. `thread_producer()` periodically send messages to `thread_consumer()` via an inter-thread queue. `thread_consumer()` verifies the message correctness and toggle the state of a digital output connected to an LED on the target.
32
-
33
-
### Optional RTOS runtime statistics
38
+
### <a name="blinky_wait_bare_metal"></a> Bare metal
39
+
The variant of the application [above](#build_blinky_wait_rtos) is built with the full Mbed OS library including its RTOS components. However, for single-threaded applications running on targets with ultraconstrains, it is possible to obtain an application with an even smaller memory footprint using [Mbed OS bare metal](https://os.mbed.com/docs/mbed-os/v5.14/reference/mbed-os-bare-metal.html) profile.
40
+
An application configuration file, [`config_blinky_wait_bare_metal.json`](./blinky_wait/config_blinky_wait_bare_metal.json) is provided to build a binary with Mbed OS bare metal profile.
34
41
35
-
`blinky_rtos()` can optionally take a snapshot of the device's runtime statistics and display it over serial to your PC. The example project has to be re-built with modified Mbed OS configuration parameters. Modifying default Mbed OS configuration parameters can be done at application level using an application configuration file. By default ARM Mbed CLI looks for `mbed_app.json`, however the configuration file can be named anything. It can be passed to ARM Mbed CLI using the optional argument `--app-config` of the `compile` sub-command. The application configuration file `config_rtos_stats.json` has been provided to enable runtime statistics to be printed.
42
+
1. Connect a USB cable between the USB port on the target and the host computer.
43
+
2. Run the following command to build the example project with runtime statistics output:
The binary is located at `./BUILD/<TARGET>/<TOOLCHAIN>/mbed-os-example-blinky.bin` and can alternatively be manually copied to the target which gets mounted on the host computer via USB.
36
48
37
-
Run the following command to build the example project with runtime statistics output:
`"target.default_lib":"small"` tells the build tool to use a small implementation of the C standard library for the toolchain selected if available. That would be Newlib-nano and MicroLib for GCC_ARM and ARM toolchains respectively.
41
50
42
-
### View the serial output
43
51
44
-
To view the serial output you can use any terminal client of your choosing such as [PuTTY](http://www.putty.org/) or [CoolTerm](http://freeware.the-meiers.org/). Unless otherwise specified, printf defaults to a baud rate of 9600 on Mbed OS.
You can find more information on the Mbed OS configuration tools and serial communication in Mbed OS in the related [related links section](#related-links).
54
+
This variant shows Mbed OS features suchs as threads, thread delay, and inter-thread communication to blink an LED.
47
55
48
-
The output should contain the following block transmitted at the blinking LED frequency (actual values may vary depending on your target, build profile, and toolchain):
56
+
### Application functionality
49
57
50
-
```bash
51
-
=============================== SYSTEM INFO ================================
52
-
Mbed OS Version: 999999
53
-
CPU ID: 0x410fc241
54
-
Compiler ID: 2
55
-
Compiler Version: 60300
56
-
RAM0: Start 0x20000000 Size: 0x30000
57
-
RAM1: Start 0x1fff0000 Size: 0x10000
58
-
ROM0: Start 0x0 Size: 0x100000
59
-
================= CPU STATS =================
60
-
Idle: 98% Usage: 2%
61
-
================ HEAP STATS =================
62
-
Current heap: 1096
63
-
Max heap size: 1096
64
-
================ THREAD STATS ===============
65
-
ID: 0x20001eac
66
-
Name: main_thread
67
-
State: 2
68
-
Priority: 24
69
-
Stack Size: 4096
70
-
Stack Space: 3296
71
-
72
-
ID: 0x20000f5c
73
-
Name: idle_thread
74
-
State: 1
75
-
Priority: 1
76
-
Stack Size: 512
77
-
Stack Space: 352
78
-
79
-
ID: 0x20000f18
80
-
Name: timer_thread
81
-
State: 3
82
-
Priority: 40
83
-
Stack Size: 768
84
-
Stack Space: 664
85
-
```
58
+
The `main()`functioncalls`blinky_multithreaded()`, as part of the main thread, which starts two threads: `thread_producer()` and `thread_consumer`. `thread_producer()` periodically send messages to `thread_consumer()` via an inter-thread queue. `thread_consumer()` verifies the message correctness and toggles the state of a digital output connected to an LED on the target.
86
59
87
-
The snapshot includes:
88
-
* System Information:
89
-
* Mbed OS Version: Will currently default to 999999
You can view individual examples and additional API information of the statistics collection tools at the bottom of the page in the [related links section](#related-links).
136
-
137
-
138
-
## <a name="blinky_bare_metal"></a> Building and Running the bare metal application
139
-
140
-
An application configuration file, `config_bare_metal.json` is provided to build a version that uses [Mbed OS bare metal](https://os.mbed.com/docs/mbed-os/v5.14/reference/mbed-os-bare-metal.html) profile to create a single threaded application.
60
+
### Building and Running
141
61
142
62
1. Connect a USB cable between the USB port on the target and the host computer.
143
-
2. Run the following command to build the example project with runtime statistics output:
63
+
2. Run the following command to build the example project and program the microcontroller flash memory:
The binary is located at `./BUILD/<TARGET>/<TOOLCHAIN>/mbed-os-example-blinky.bin` and can alternatively be manually copied to the target which gets mounted on the host computer via USB.
148
68
149
-
`"target.default_lib" : "small"` tells the build tool to use a small version of the C standard library for the toolchain selected if available. That would be Newlib-nano and MicroLib for GCC_ARM and ARM toolchains respectively.
150
-
151
-
### Application functionality
69
+
### Optional RTOS runtime statistics
152
70
153
-
The `main()` function calls `blinky_bare_metal()`, as part of the single thread, which toggles the state of a digital output connected to an LED on the target.
71
+
It is possible to take a snapshot of the device's runtime statistics and display it over serial to your PC. See how [here](https://os.mbed.com/docs/latest/apis/mbed-statistics.html).
0 commit comments