From 62c995e5df4b6ab6334e5a7594e5b3f14f57dd33 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Thu, 10 Oct 2019 13:43:55 +0100 Subject: [PATCH 01/16] Use threads comms to blink and add baremetal version The application has been re-written to use inter-thread communication in order to blink the LED. It now shows how threads can be created, started and how they can communicate with each other. Runtime statistics are made optional via an application configuration file. Instructions have been provided to use the configuration to enable runtime statistics to be printed on the serial output. Finally, a configuration file has been provided to build the application with Mbed OS bare metal profile --- .vscode/settings.json | 25 ++++ README.md | 149 +++++++++++++----------- blinky_bare_metal.cpp | 23 ++++ blinky_rtos.cpp | 111 ++++++++++++++++++ config_bare_metal.json | 9 ++ mbed_app.json => config_rtos_stats.json | 2 + main.cpp | 8 +- 7 files changed, 255 insertions(+), 72 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 blinky_bare_metal.cpp create mode 100644 blinky_rtos.cpp create mode 100644 config_bare_metal.json rename mbed_app.json => config_rtos_stats.json (83%) diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..08d05dd5 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,25 @@ +{ + "files.associations": { + "*.original": "c", + "mbed_printf_implementation.h": "c", + "mstd_iterator": "cpp", + "array": "cpp", + "initializer_list": "cpp", + "mstd_utility": "cpp", + "string_view": "cpp", + "utility": "cpp", + "*.tpp": "cpp", + "*.tcc": "cpp", + "cerrno": "cpp", + "mstd_type_traits": "cpp", + "mstd_functional": "cpp", + "mstd_memory": "cpp", + "chrono": "cpp", + "functional": "cpp", + "istream": "cpp", + "ostream": "cpp", + "ratio": "cpp", + "tuple": "cpp", + "type_traits": "cpp" + } +} \ No newline at end of file diff --git a/README.md b/README.md index 2252959a..e5cc9bf4 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,90 @@ -# Getting started example for Mbed OS +# Blinky Mbed OS Example -This guide reviews the steps required to get Blinky with the addition of dynamic OS statistics working on an Mbed OS platform. (Note: To see a rendered example you can import into the Arm Online Compiler, please see our [quick start](https://os.mbed.com/docs/mbed-os/latest/quick-start/online-with-the-online-compiler.html#importing-the-code).) +## Introduction +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. -Please install [Mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli). +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). -## Import the example application +Depending on the target, the example project can be built with GCC_ARM, ARM or IAR toolchain. Run the command below after installing ARM Mbed CLI to determine which toolchain support your target. -From the command-line, import the example: - -``` -mbed import mbed-os-example-blinky -cd mbed-os-example-blinky +```bash +$ mbed compile -S ``` -### Now compile +Clone this repository on your system and change the current directory to where the project was cloned. -Invoke `mbed compile`, and specify the name of your platform and your favorite toolchain (`GCC_ARM`, `ARM`, `IAR`). For example, for the Arm Compiler: +Select the section for the version of the application you wish to build: +* [Building and Running the RTOS application](#blinky_rtos) +* [Building and Running the bare metal application](#blinky_bare_metal) -``` -mbed compile -m K64F -t ARM -``` +## Building and Running the RTOS application -Your PC may take a few minutes to compile your code. At the end, you see the following result: +1. Connect a USB cable between the USB port on the target and the host computer. +2. Run the following command to build the example project and program the microcontroller flash memory: + ```bash + $ mbed compile -m -t --flash + ``` +The binary is located at `./BUILD///mbed-os-example-blinky.bin` and can alternatively be manually copied to the target which gets mounted on the host computer via USB. -``` -[snip] +### Application functionality + +The `main()` function calls `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. -Image: ./BUILD/K64F/GCC_ARM/mbed-os-example-blinky.bin +### Optional RTOS runtime statistics + +`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. + +Run the following command to build the example project with runtime statistics output: +```bash +$ mbed compile -m -t --app-config=config_rtos_stats.json --flash ``` -### Program your board +### View the serial output + +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. -1. Connect your Mbed device to the computer over USB. -1. Copy the binary file to the Mbed device. -1. Press the reset button to start the program. +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). -The LED on your platform turns on and off. The main thread will additionally take a snapshot of the device's runtime statistics and display it over serial to your PC. The snapshot includes: +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): +```bash +=============================== SYSTEM INFO ================================ +Mbed OS Version: 999999 +CPU ID: 0x410fc241 +Compiler ID: 2 +Compiler Version: 60300 +RAM0: Start 0x20000000 Size: 0x30000 +RAM1: Start 0x1fff0000 Size: 0x10000 +ROM0: Start 0x0 Size: 0x100000 +================= CPU STATS ================= +Idle: 98% Usage: 2% +================ HEAP STATS ================= +Current heap: 1096 +Max heap size: 1096 +================ THREAD STATS =============== +ID: 0x20001eac +Name: main_thread +State: 2 +Priority: 24 +Stack Size: 4096 +Stack Space: 3296 + +ID: 0x20000f5c +Name: idle_thread +State: 1 +Priority: 1 +Stack Size: 512 +Stack Space: 352 + +ID: 0x20000f18 +Name: timer_thread +State: 3 +Priority: 40 +Stack Size: 768 +Stack Space: 664 +``` + +The snapshot includes: * System Information: * Mbed OS Version: Will currently default to 999999 * Compiler ID @@ -84,59 +132,28 @@ The LED on your platform turns on and off. The main thread will additionally tak | | | 0xD21 = Cortex-M33 | |[3:0] | Revision | Minor revision: 0x1 = Patch 1 | - - 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). -### Output +## Building and Running the bare metal application -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. +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. -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). - -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): +1. Connect a USB cable between the USB port on the target and the host computer. +2. Run the following command to build the example project with runtime statistics output: + ```bash + $ mbed compile -m -t --app-config=config_bare_metal.json --flash + ``` +The binary is located at `./BUILD///mbed-os-example-blinky.bin` and can alternatively be manually copied to the target which gets mounted on the host computer via USB. -``` -=============================== SYSTEM INFO ================================ -Mbed OS Version: 999999 -CPU ID: 0x410fc241 -Compiler ID: 2 -Compiler Version: 60300 -RAM0: Start 0x20000000 Size: 0x30000 -RAM1: Start 0x1fff0000 Size: 0x10000 -ROM0: Start 0x0 Size: 0x100000 -================= CPU STATS ================= -Idle: 98% Usage: 2% -================ HEAP STATS ================= -Current heap: 1096 -Max heap size: 1096 -================ THREAD STATS =============== -ID: 0x20001eac -Name: main_thread -State: 2 -Priority: 24 -Stack Size: 4096 -Stack Space: 3296 +`"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. -ID: 0x20000f5c -Name: idle_thread -State: 1 -Priority: 1 -Stack Size: 512 -Stack Space: 352 +### Application functionality -ID: 0x20000f18 -Name: timer_thread -State: 3 -Priority: 40 -Stack Size: 768 -Stack Space: 664 +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. -``` ## Troubleshooting - If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it. ## Related Links @@ -144,6 +161,8 @@ If you have problems, you can review the [documentation](https://os.mbed.com/doc * [Mbed OS Stats API](https://os.mbed.com/docs/latest/apis/mbed-statistics.html) * [Mbed OS Configuration](https://os.mbed.com/docs/latest/reference/configuration.html) * [Mbed OS Serial Communication](https://os.mbed.com/docs/latest/tutorials/serial-communication.html) +* [Mbed OS bare metal](https://os.mbed.com/docs/mbed-os/v5.14/reference/mbed-os-bare-metal.html) +* [Mbed boards](https://os.mbed.com/platforms/) ### License and contributions diff --git a/blinky_bare_metal.cpp b/blinky_bare_metal.cpp new file mode 100644 index 00000000..1fc13d0b --- /dev/null +++ b/blinky_bare_metal.cpp @@ -0,0 +1,23 @@ +/* mbed Microcontroller Library + * Copyright (c) 2019 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + */ +#ifdef MBED_BARE_METAL +#include "mbed.h" +#include "platform/mbed_thread.h" + + +// Blinking rate in milliseconds +#define BLINKING_RATE_MS 500 + +// Initialise the digital pin LED1 as an output +DigitalOut led(LED1); + +void blinky_bare_metal() +{ + while (true) { + led = !led; + thread_sleep_for(BLINKING_RATE_MS); + } +} +#endif // MBED_BARE_METAL diff --git a/blinky_rtos.cpp b/blinky_rtos.cpp new file mode 100644 index 00000000..dc5c0d53 --- /dev/null +++ b/blinky_rtos.cpp @@ -0,0 +1,111 @@ +/* mbed Microcontroller Library + * Copyright (c) 2019 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef MBED_BARE_METAL +#include "mbed.h" +#include "platform/mbed_thread.h" +#include "rtos/Queue.h" +#include "rtos/Thread.h" +#include "rtos/MemoryPool.h" + + +#if MBED_SYS_STAT_REPORT +#include "stats_report.h" +#endif // MBED_SYS_STAT_REPORT + + +// Maximum number of item in the inter-thread communication queue +#define MAX_QUEUE_SIZE 1 + +// Thread priorities +#define THREAD_PRIORITY_PRODUCER osPriorityAboveNormal +#define THREAD_PRIORITY_CONSUMER osPriorityHigh + +// Delay between sending messages in milliseconds +#define THREAD_SLEEP_TIME_MS_PRODUCER 500 + +#if MBED_SYS_STAT_REPORT +// Main thread delay in milliseconds +#define THREAD_SLEEP_TIME_MS_MAIN (THREAD_SLEEP_TIME_MS_PRODUCER * 20) +#endif // MBED_SYS_STAT_REPORT + +// Message to be sent from producer thread to consumer thread +#define THREAD_PRODUCER_MSG 0xDEADBEEF + +// Fixed size memory pool to hold messages +MemoryPool mem_pool; + +// Queue used for inter-thread communications +Queue queue; + +// Producer thread handle +Thread thread_producer_handle( + THREAD_PRIORITY_PRODUCER, + OS_STACK_SIZE, + nullptr, + "PRODUCER" +); + +// Consumer thread handle +Thread thread_consumer_handle( + THREAD_PRIORITY_CONSUMER, + OS_STACK_SIZE, + nullptr, + "CONSUMER" +); + +// Initialise the digital pin LED1 as an output +DigitalOut led(LED1); + + +static void thread_consumer(); +static void thread_producer(); + +// The function `blinky_rtos()` runs in the main thread in the OS +void blinky_rtos() +{ + // Start execution of the functions in the threads + thread_consumer_handle.start(callback(thread_consumer)); + thread_producer_handle.start(callback(thread_producer)); + +#if MBED_SYS_STAT_REPORT + SystemReport sys_state(THREAD_SLEEP_TIME_MS_MAIN); + + while (true) { + thread_sleep_for(THREAD_SLEEP_TIME_MS_MAIN); + sys_state.report_state(); + } +#endif // MBED_SYS_STAT_REPORT +} + + +static void thread_consumer() +{ + while (true) { + osEvent evt = queue.get(); + + if (evt.status == osEventMessage) { + unsigned long *msg = (unsigned long *)evt.value.p; + + if (*msg == THREAD_PRODUCER_MSG) { + led = !led; + } + + mem_pool.free(msg); + } + } +} + +static void thread_producer() +{ + while (true) { + unsigned long *msg = mem_pool.alloc(); + *msg = THREAD_PRODUCER_MSG; + + queue.put(msg); + + thread_sleep_for(THREAD_SLEEP_TIME_MS_PRODUCER); + } +} +#endif // MBED_BARE_METAL diff --git a/config_bare_metal.json b/config_bare_metal.json new file mode 100644 index 00000000..e54754d7 --- /dev/null +++ b/config_bare_metal.json @@ -0,0 +1,9 @@ +{ + "requires": ["bare-metal"], + "target_overrides": { + "*": { + "target.default_lib" : "small", + "target.macros_add" : ["MBED_BARE_METAL"] + } + } +} diff --git a/mbed_app.json b/config_rtos_stats.json similarity index 83% rename from mbed_app.json rename to config_rtos_stats.json index 3b191ff4..c64e34c5 100644 --- a/mbed_app.json +++ b/config_rtos_stats.json @@ -1,6 +1,8 @@ { + "target_overrides": { "*": { + "target.macros_add" : ["MBED_SYS_STAT_REPORT"], "platform.stack-stats-enabled": true, "platform.heap-stats-enabled": true, "platform.cpu-stats-enabled": true, diff --git a/main.cpp b/main.cpp index 8760e604..28982828 100644 --- a/main.cpp +++ b/main.cpp @@ -1,5 +1,5 @@ /* mbed Microcontroller Library - * Copyright (c) 2018 ARM Limited + * Copyright (c) 2018-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 */ @@ -7,12 +7,6 @@ #include "platform/mbed_thread.h" #include "stats_report.h" -DigitalOut led1(LED1); - -#define SLEEP_TIME 500 // (msec) -#define PRINT_AFTER_N_LOOPS 20 - -// main() runs in its own thread in the OS int main() { SystemReport sys_state( SLEEP_TIME * PRINT_AFTER_N_LOOPS /* Loop delay time in ms */); From 7b12e797b549b9581e314d9a193eb537a87c5eb6 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Sat, 12 Oct 2019 15:23:24 +0100 Subject: [PATCH 02/16] 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. --- README.md | 151 +++++------------- .../blinky_multithreaded.cpp | 45 ++---- .../config_blinky_multithreaded.json | 7 + .../blinky_wait.cpp | 10 +- .../config_blinky_wait_bare_metal.json | 8 + config_bare_metal.json | 9 -- config_rtos_stats.json | 13 -- stats_report.h | 133 --------------- 8 files changed, 73 insertions(+), 303 deletions(-) rename blinky_rtos.cpp => blinky_multithreaded/blinky_multithreaded.cpp (70%) create mode 100644 blinky_multithreaded/config_blinky_multithreaded.json rename blinky_bare_metal.cpp => blinky_wait/blinky_wait.cpp (72%) create mode 100644 blinky_wait/config_blinky_wait_bare_metal.json delete mode 100644 config_bare_metal.json delete mode 100644 config_rtos_stats.json delete mode 100644 stats_report.h diff --git a/README.md b/README.md index e5cc9bf4..047a3c8a 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,8 @@ # Blinky Mbed OS Example -## Introduction -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. +The example project contains variants of an application to blink an LED on supported [Mbed boards](https://os.mbed.com/platforms/). -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). +The project can be built with all supported [Mbed OS build tools](https://os.mbed.com/docs/mbed-os/latest/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). Please install Arm Mbed CLI. Depending on the target, the example project can be built with GCC_ARM, ARM or IAR toolchain. Run the command below after installing ARM Mbed CLI to determine which toolchain support your target. @@ -13,11 +12,20 @@ $ mbed compile -S Clone this repository on your system and change the current directory to where the project was cloned. -Select the section for the version of the application you wish to build: -* [Building and Running the RTOS application](#blinky_rtos) -* [Building and Running the bare metal application](#blinky_bare_metal) +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/latest/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. -## Building and Running the RTOS application +Select the section for the variant of the application you wish to build: +* [Blinky Wait application](#blinky_wait) + * [Bare metal](#blinky_wait_bare_metal) +* [Blinky multi-threaded application](#blinky_multi_threaded) + +## Blinky Wait application + +### Application functionality + +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. + +### Building and Running 1. Connect a USB cable between the USB port on the target and the host computer. 2. Run the following command to build the example project and program the microcontroller flash memory: @@ -26,131 +34,48 @@ Select the section for the version of the application you wish to build: ``` The binary is located at `./BUILD///mbed-os-example-blinky.bin` and can alternatively be manually copied to the target which gets mounted on the host computer via USB. +<<<<<<< HEAD ### Application functionality The `main()` function calls `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. ### Optional RTOS runtime statistics +======= +### Bare metal +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/latest/reference/mbed-os-bare-metal.html) profile. +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. +>>>>>>> Add application variants and Mbed OS bare metal tutorial -`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. +1. Connect a USB cable between the USB port on the target and the host computer. +2. Run the following command to build the example project with runtime statistics output: + ```bash + $ mbed compile -m -t --app-config=./blinky_wait/config_blinky_bare_metal.json --flash + ``` +The binary is located at `./BUILD///mbed-os-example-blinky.bin` and can alternatively be manually copied to the target which gets mounted on the host computer via USB. -Run the following command to build the example project with runtime statistics output: -```bash -$ mbed compile -m -t --app-config=config_rtos_stats.json --flash -``` +`"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. -### View the serial output -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. +## Blinky multi-threaded application -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). +This variant shows Mbed OS features suchs as threads, thread delay, and inter-thread communication to blink an LED. -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): +### Application functionality -```bash -=============================== SYSTEM INFO ================================ -Mbed OS Version: 999999 -CPU ID: 0x410fc241 -Compiler ID: 2 -Compiler Version: 60300 -RAM0: Start 0x20000000 Size: 0x30000 -RAM1: Start 0x1fff0000 Size: 0x10000 -ROM0: Start 0x0 Size: 0x100000 -================= CPU STATS ================= -Idle: 98% Usage: 2% -================ HEAP STATS ================= -Current heap: 1096 -Max heap size: 1096 -================ THREAD STATS =============== -ID: 0x20001eac -Name: main_thread -State: 2 -Priority: 24 -Stack Size: 4096 -Stack Space: 3296 - -ID: 0x20000f5c -Name: idle_thread -State: 1 -Priority: 1 -Stack Size: 512 -Stack Space: 352 - -ID: 0x20000f18 -Name: timer_thread -State: 3 -Priority: 40 -Stack Size: 768 -Stack Space: 664 -``` +The `main()` function calls `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. -The snapshot includes: -* System Information: - * Mbed OS Version: Will currently default to 999999 - * Compiler ID - * ARM = 1 - * GCC_ARM = 2 - * IAR = 3 - * [CPUID Register Information](#cpuid-register-information) - * [Compiler Version](#compiler-version) -* CPU Statistics - * Percentage of runtime that the device has spent awake versus in sleep -* Heap Statistics - * Current heap size - * Max heap size which refers to the largest the heap has grown to -* Thread Statistics - * Provides information on all running threads in the OS including - * Thread ID - * Thread Name - * Thread State - * Thread Priority - * Thread Stack Size - * Thread Stack Space - -#### Compiler Version - -| Compiler | Version Layout | -| -------- | -------------- | -| ARM | PVVbbbb (P = Major; VV = Minor; bbbb = build number) | -| GCC | VVRRPP (VV = Version; RR = Revision; PP = Patch) | -| IAR | VRRRPPP (V = Version; RRR = Revision; PPP = Patch) | - -#### CPUID Register Information - -| Bit Field | Field Description | Values | -| --------- | ----------------- | ------ | -|[31:24] | Implementer | 0x41 = ARM | -|[23:20] | Variant | Major revision 0x0 = Revision 0 | -|[19:16] | Architecture | 0xC = Baseline Architecture | -| | | 0xF = Constant (Mainline Architecture) | -|[15:4] | Part Number | 0xC20 = Cortex-M0 | -| | | 0xC60 = Cortex-M0+ | -| | | 0xC23 = Cortex-M3 | -| | | 0xC24 = Cortex-M4 | -| | | 0xC27 = Cortex-M7 | -| | | 0xD20 = Cortex-M23 | -| | | 0xD21 = Cortex-M33 | -|[3:0] | Revision | Minor revision: 0x1 = Patch 1 | - -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). - - -## Building and Running the bare metal application - -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. +### Building and Running 1. Connect a USB cable between the USB port on the target and the host computer. -2. Run the following command to build the example project with runtime statistics output: +2. Run the following command to build the example project and program the microcontroller flash memory: ```bash - $ mbed compile -m -t --app-config=config_bare_metal.json --flash + $ mbed compile -m -t --flash --app-config=./blinky_multithreaded/config_blinky_multithreaded.json ``` The binary is located at `./BUILD///mbed-os-example-blinky.bin` and can alternatively be manually copied to the target which gets mounted on the host computer via USB. -`"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. - -### Application functionality +### Optional RTOS runtime statistics -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. +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). ## Troubleshooting @@ -161,7 +86,7 @@ If you have problems, you can review the [documentation](https://os.mbed.com/doc * [Mbed OS Stats API](https://os.mbed.com/docs/latest/apis/mbed-statistics.html) * [Mbed OS Configuration](https://os.mbed.com/docs/latest/reference/configuration.html) * [Mbed OS Serial Communication](https://os.mbed.com/docs/latest/tutorials/serial-communication.html) -* [Mbed OS bare metal](https://os.mbed.com/docs/mbed-os/v5.14/reference/mbed-os-bare-metal.html) +* [Mbed OS bare metal](https://os.mbed.com/docs/mbed-os/latest/reference/mbed-os-bare-metal.html) * [Mbed boards](https://os.mbed.com/platforms/) ### License and contributions diff --git a/blinky_rtos.cpp b/blinky_multithreaded/blinky_multithreaded.cpp similarity index 70% rename from blinky_rtos.cpp rename to blinky_multithreaded/blinky_multithreaded.cpp index dc5c0d53..a73f1da0 100644 --- a/blinky_rtos.cpp +++ b/blinky_multithreaded/blinky_multithreaded.cpp @@ -2,7 +2,8 @@ * Copyright (c) 2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 */ -#ifndef MBED_BARE_METAL +#ifdef BLINKY_MULTITHREADED + #include "mbed.h" #include "platform/mbed_thread.h" #include "rtos/Queue.h" @@ -10,28 +11,19 @@ #include "rtos/MemoryPool.h" -#if MBED_SYS_STAT_REPORT -#include "stats_report.h" -#endif // MBED_SYS_STAT_REPORT - - // Maximum number of item in the inter-thread communication queue #define MAX_QUEUE_SIZE 1 // Thread priorities -#define THREAD_PRIORITY_PRODUCER osPriorityAboveNormal -#define THREAD_PRIORITY_CONSUMER osPriorityHigh +#define THREAD_PRIORITY_PRODUCER osPriorityAboveNormal +#define THREAD_PRIORITY_CONSUMER osPriorityHigh // Delay between sending messages in milliseconds -#define THREAD_SLEEP_TIME_MS_PRODUCER 500 - -#if MBED_SYS_STAT_REPORT -// Main thread delay in milliseconds -#define THREAD_SLEEP_TIME_MS_MAIN (THREAD_SLEEP_TIME_MS_PRODUCER * 20) -#endif // MBED_SYS_STAT_REPORT +#define THREAD_SLEEP_TIME_MS_PRODUCER 500 // Message to be sent from producer thread to consumer thread -#define THREAD_PRODUCER_MSG 0xDEADBEEF +#define THREAD_PRODUCER_MSG 0xDEADBEEF + // Fixed size memory pool to hold messages MemoryPool mem_pool; @@ -55,33 +47,25 @@ Thread thread_consumer_handle( "CONSUMER" ); -// Initialise the digital pin LED1 as an output -DigitalOut led(LED1); - static void thread_consumer(); static void thread_producer(); -// The function `blinky_rtos()` runs in the main thread in the OS -void blinky_rtos() + +// The function `blinky_multithreaded()` runs in the main thread in the OS +void blinky_multithreaded() { // Start execution of the functions in the threads thread_consumer_handle.start(callback(thread_consumer)); thread_producer_handle.start(callback(thread_producer)); - -#if MBED_SYS_STAT_REPORT - SystemReport sys_state(THREAD_SLEEP_TIME_MS_MAIN); - - while (true) { - thread_sleep_for(THREAD_SLEEP_TIME_MS_MAIN); - sys_state.report_state(); - } -#endif // MBED_SYS_STAT_REPORT } static void thread_consumer() { + // Initialise the digital pin LED1 as an output + DigitalOut led(LED1); + while (true) { osEvent evt = queue.get(); @@ -108,4 +92,5 @@ static void thread_producer() thread_sleep_for(THREAD_SLEEP_TIME_MS_PRODUCER); } } -#endif // MBED_BARE_METAL + +#endif // BLINKY_MULTITHREADED diff --git a/blinky_multithreaded/config_blinky_multithreaded.json b/blinky_multithreaded/config_blinky_multithreaded.json new file mode 100644 index 00000000..55d65804 --- /dev/null +++ b/blinky_multithreaded/config_blinky_multithreaded.json @@ -0,0 +1,7 @@ +{ + "target_overrides": { + "*": { + "target.macros_add" : ["BLINKY_MULTITHREADED"] + } + } +} diff --git a/blinky_bare_metal.cpp b/blinky_wait/blinky_wait.cpp similarity index 72% rename from blinky_bare_metal.cpp rename to blinky_wait/blinky_wait.cpp index 1fc13d0b..5ab567d1 100644 --- a/blinky_bare_metal.cpp +++ b/blinky_wait/blinky_wait.cpp @@ -2,7 +2,7 @@ * Copyright (c) 2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 */ -#ifdef MBED_BARE_METAL + #include "mbed.h" #include "platform/mbed_thread.h" @@ -10,14 +10,14 @@ // Blinking rate in milliseconds #define BLINKING_RATE_MS 500 -// Initialise the digital pin LED1 as an output -DigitalOut led(LED1); -void blinky_bare_metal() +void blinky_wait() { + // Initialise the digital pin LED1 as an output + DigitalOut led(LED1); + while (true) { led = !led; thread_sleep_for(BLINKING_RATE_MS); } } -#endif // MBED_BARE_METAL diff --git a/blinky_wait/config_blinky_wait_bare_metal.json b/blinky_wait/config_blinky_wait_bare_metal.json new file mode 100644 index 00000000..71675d9d --- /dev/null +++ b/blinky_wait/config_blinky_wait_bare_metal.json @@ -0,0 +1,8 @@ +{ + "requires": ["bare-metal"], + "target_overrides": { + "*": { + "target.default_lib" : "small" + } + } +} diff --git a/config_bare_metal.json b/config_bare_metal.json deleted file mode 100644 index e54754d7..00000000 --- a/config_bare_metal.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "requires": ["bare-metal"], - "target_overrides": { - "*": { - "target.default_lib" : "small", - "target.macros_add" : ["MBED_BARE_METAL"] - } - } -} diff --git a/config_rtos_stats.json b/config_rtos_stats.json deleted file mode 100644 index c64e34c5..00000000 --- a/config_rtos_stats.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - - "target_overrides": { - "*": { - "target.macros_add" : ["MBED_SYS_STAT_REPORT"], - "platform.stack-stats-enabled": true, - "platform.heap-stats-enabled": true, - "platform.cpu-stats-enabled": true, - "platform.thread-stats-enabled": true, - "platform.sys-stats-enabled": true - } - } -} diff --git a/stats_report.h b/stats_report.h deleted file mode 100644 index 50f6f2ef..00000000 --- a/stats_report.h +++ /dev/null @@ -1,133 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2018 ARM Limited - * SPDX-License-Identifier: Apache-2.0 - */ - -#ifndef STATS_REPORT_H -#define STATS_REPORT_H - -#include -#include "mbed.h" - -/** - * System Reporting library. Provides runtime information on device: - * - CPU sleep, idle, and wake times - * - Heap and stack usage - * - Thread information - * - Static system information - */ -class SystemReport { - mbed_stats_heap_t heap_stats; - mbed_stats_cpu_t cpu_stats; - mbed_stats_sys_t sys_stats; - - mbed_stats_thread_t *thread_stats; - uint8_t thread_count; - uint8_t max_thread_count; - uint32_t sample_time_ms; - -public: - /** - * SystemReport - Sample rate in ms is required to handle the CPU percent awake logic - */ - SystemReport(uint32_t sample_rate) : max_thread_count(8), sample_time_ms(sample_rate) - { - thread_stats = new mbed_stats_thread_t[max_thread_count]; - - // Collect the static system information - mbed_stats_sys_get(&sys_stats); - - printf("=============================== SYSTEM INFO ================================\r\n"); - printf("Mbed OS Version: %" PRIu32 " \r\n", sys_stats.os_version); - printf("CPU ID: 0x%" PRIx32 " \r\n", sys_stats.cpu_id); - printf("Compiler ID: %d \r\n", sys_stats.compiler_id); - printf("Compiler Version: %" PRIu32 " \r\n", sys_stats.compiler_version); - - for (int i = 0; i < MBED_MAX_MEM_REGIONS; i++) { - if (sys_stats.ram_size[i] != 0) { - printf("RAM%d: Start 0x%" PRIx32 " Size: 0x%" PRIx32 " \r\n", i, sys_stats.ram_start[i], sys_stats.ram_size[i]); - } - } - for (int i = 0; i < MBED_MAX_MEM_REGIONS; i++) { - if (sys_stats.rom_size[i] != 0) { - printf("ROM%d: Start 0x%" PRIx32 " Size: 0x%" PRIx32 " \r\n", i, sys_stats.rom_start[i], sys_stats.rom_size[i]); - } - } - } - - ~SystemReport(void) - { - free(thread_stats); - } - - /** - * Report on each Mbed OS Platform stats API - */ - void report_state(void) - { - report_cpu_stats(); - report_heap_stats(); - report_thread_stats(); - - // Clear next line to separate subsequent report logs - printf("\r\n"); - } - - /** - * Report CPU idle and awake time in terms of percentage - */ - void report_cpu_stats(void) - { - static uint64_t prev_idle_time = 0; - - printf("================= CPU STATS =================\r\n"); - - // Collect and print cpu stats - mbed_stats_cpu_get(&cpu_stats); - - uint64_t diff = (cpu_stats.idle_time - prev_idle_time); - uint8_t idle = (diff * 100) / (sample_time_ms * 1000); // usec; - uint8_t usage = 100 - ((diff * 100) / (sample_time_ms * 1000)); // usec;; - prev_idle_time = cpu_stats.idle_time; - - printf("Idle: %d%% Usage: %d%% \r\n", idle, usage); - } - - /** - * Report current heap stats. Current heap refers to the current amount of - * allocated heap. Max heap refers to the highest amount of heap allocated - * since reset. - */ - void report_heap_stats(void) - { - printf("================ HEAP STATS =================\r\n"); - - // Collect and print heap stats - mbed_stats_heap_get(&heap_stats); - - printf("Current heap: %" PRIu32 "\r\n", heap_stats.current_size); - printf("Max heap size: %" PRIu32 "\r\n", heap_stats.max_size); - } - - /** - * Report active thread stats - */ - void report_thread_stats(void) - { - printf("================ THREAD STATS ===============\r\n"); - - // Collect and print running thread stats - int count = mbed_stats_thread_get_each(thread_stats, max_thread_count); - - for (int i = 0; i < count; i++) { - printf("ID: 0x%" PRIx32 " \r\n", thread_stats[i].id); - printf("Name: %s \r\n", thread_stats[i].name); - printf("State: %" PRIu32 " \r\n", thread_stats[i].state); - printf("Priority: %" PRIu32 " \r\n", thread_stats[i].priority); - printf("Stack Size: %" PRIu32 " \r\n", thread_stats[i].stack_size); - printf("Stack Space: %" PRIu32 " \r\n", thread_stats[i].stack_space); - } - } -}; - -#endif // STATS_REPORT_H From 007b92b23535c6648643cc80fa1faa56971c27cc Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Tue, 15 Oct 2019 09:42:13 +0100 Subject: [PATCH 03/16] Remove multithreaded application --- README.md | 27 +++--- blinky_multithreaded/blinky_multithreaded.cpp | 96 ------------------- .../config_blinky_multithreaded.json | 7 -- blinky_wait/blinky_wait.cpp | 23 ----- ..._bare_metal.json => config_bare_metal.json | 0 main.cpp | 24 ++--- 6 files changed, 25 insertions(+), 152 deletions(-) delete mode 100644 blinky_multithreaded/blinky_multithreaded.cpp delete mode 100644 blinky_multithreaded/config_blinky_multithreaded.json delete mode 100644 blinky_wait/blinky_wait.cpp rename blinky_wait/config_blinky_wait_bare_metal.json => config_bare_metal.json (100%) diff --git a/README.md b/README.md index 047a3c8a..8c706e7a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Blinky Mbed OS Example -The example project contains variants of an application to blink an LED on supported [Mbed boards](https://os.mbed.com/platforms/). +The example project contains an application to blink an LED on supported [Mbed boards](https://os.mbed.com/platforms/). The project can be built with all supported [Mbed OS build tools](https://os.mbed.com/docs/mbed-os/latest/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). Please install Arm Mbed CLI. @@ -14,18 +14,11 @@ Clone this repository on your system and change the current directory to where t 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/latest/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. -Select the section for the variant of the application you wish to build: -* [Blinky Wait application](#blinky_wait) - * [Bare metal](#blinky_wait_bare_metal) -* [Blinky multi-threaded application](#blinky_multi_threaded) +## Application functionality -## Blinky Wait application +The `main()` function is the single thread in the application, it toggles the state of a digital output connected to an LED on the target. -### Application functionality - -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. - -### Building and Running +## Building and Running 1. Connect a USB cable between the USB port on the target and the host computer. 2. Run the following command to build the example project and program the microcontroller flash memory: @@ -34,6 +27,7 @@ The `main()` function calls `blinky_wait()`, as part of the single thread, which ``` The binary is located at `./BUILD///mbed-os-example-blinky.bin` and can alternatively be manually copied to the target which gets mounted on the host computer via USB. +<<<<<<< HEAD <<<<<<< HEAD ### Application functionality @@ -45,17 +39,23 @@ The `main()` function calls `blinky_rtos()`, as part of the main thread, which s 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/latest/reference/mbed-os-bare-metal.html) profile. 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. >>>>>>> Add application variants and Mbed OS bare metal tutorial +======= +## Bare metal +The application above 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/latest/reference/mbed-os-bare-metal.html) profile. +An application configuration file, [`config_bare_metal.json`](./config_bare_metal.json) is provided to build a binary with Mbed OS bare metal profile. +>>>>>>> Remove multithreaded application 1. Connect a USB cable between the USB port on the target and the host computer. 2. Run the following command to build the example project with runtime statistics output: ```bash - $ mbed compile -m -t --app-config=./blinky_wait/config_blinky_bare_metal.json --flash + $ mbed compile -m -t --app-config config_bare_metal.json --flash ``` The binary is located at `./BUILD///mbed-os-example-blinky.bin` and can alternatively be manually copied to the target which gets mounted on the host computer via USB. `"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. +<<<<<<< HEAD ## Blinky multi-threaded application This variant shows Mbed OS features suchs as threads, thread delay, and inter-thread communication to blink an LED. @@ -74,6 +74,9 @@ The `main()` function calls `blinky_multithreaded()`, as part of the main thread The binary is located at `./BUILD///mbed-os-example-blinky.bin` and can alternatively be manually copied to the target which gets mounted on the host computer via USB. ### Optional RTOS runtime statistics +======= +## Optional RTOS runtime statistics +>>>>>>> Remove multithreaded application 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). diff --git a/blinky_multithreaded/blinky_multithreaded.cpp b/blinky_multithreaded/blinky_multithreaded.cpp deleted file mode 100644 index a73f1da0..00000000 --- a/blinky_multithreaded/blinky_multithreaded.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2019 ARM Limited - * SPDX-License-Identifier: Apache-2.0 - */ -#ifdef BLINKY_MULTITHREADED - -#include "mbed.h" -#include "platform/mbed_thread.h" -#include "rtos/Queue.h" -#include "rtos/Thread.h" -#include "rtos/MemoryPool.h" - - -// Maximum number of item in the inter-thread communication queue -#define MAX_QUEUE_SIZE 1 - -// Thread priorities -#define THREAD_PRIORITY_PRODUCER osPriorityAboveNormal -#define THREAD_PRIORITY_CONSUMER osPriorityHigh - -// Delay between sending messages in milliseconds -#define THREAD_SLEEP_TIME_MS_PRODUCER 500 - -// Message to be sent from producer thread to consumer thread -#define THREAD_PRODUCER_MSG 0xDEADBEEF - - -// Fixed size memory pool to hold messages -MemoryPool mem_pool; - -// Queue used for inter-thread communications -Queue queue; - -// Producer thread handle -Thread thread_producer_handle( - THREAD_PRIORITY_PRODUCER, - OS_STACK_SIZE, - nullptr, - "PRODUCER" -); - -// Consumer thread handle -Thread thread_consumer_handle( - THREAD_PRIORITY_CONSUMER, - OS_STACK_SIZE, - nullptr, - "CONSUMER" -); - - -static void thread_consumer(); -static void thread_producer(); - - -// The function `blinky_multithreaded()` runs in the main thread in the OS -void blinky_multithreaded() -{ - // Start execution of the functions in the threads - thread_consumer_handle.start(callback(thread_consumer)); - thread_producer_handle.start(callback(thread_producer)); -} - - -static void thread_consumer() -{ - // Initialise the digital pin LED1 as an output - DigitalOut led(LED1); - - while (true) { - osEvent evt = queue.get(); - - if (evt.status == osEventMessage) { - unsigned long *msg = (unsigned long *)evt.value.p; - - if (*msg == THREAD_PRODUCER_MSG) { - led = !led; - } - - mem_pool.free(msg); - } - } -} - -static void thread_producer() -{ - while (true) { - unsigned long *msg = mem_pool.alloc(); - *msg = THREAD_PRODUCER_MSG; - - queue.put(msg); - - thread_sleep_for(THREAD_SLEEP_TIME_MS_PRODUCER); - } -} - -#endif // BLINKY_MULTITHREADED diff --git a/blinky_multithreaded/config_blinky_multithreaded.json b/blinky_multithreaded/config_blinky_multithreaded.json deleted file mode 100644 index 55d65804..00000000 --- a/blinky_multithreaded/config_blinky_multithreaded.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "target_overrides": { - "*": { - "target.macros_add" : ["BLINKY_MULTITHREADED"] - } - } -} diff --git a/blinky_wait/blinky_wait.cpp b/blinky_wait/blinky_wait.cpp deleted file mode 100644 index 5ab567d1..00000000 --- a/blinky_wait/blinky_wait.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2019 ARM Limited - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "mbed.h" -#include "platform/mbed_thread.h" - - -// Blinking rate in milliseconds -#define BLINKING_RATE_MS 500 - - -void blinky_wait() -{ - // Initialise the digital pin LED1 as an output - DigitalOut led(LED1); - - while (true) { - led = !led; - thread_sleep_for(BLINKING_RATE_MS); - } -} diff --git a/blinky_wait/config_blinky_wait_bare_metal.json b/config_bare_metal.json similarity index 100% rename from blinky_wait/config_blinky_wait_bare_metal.json rename to config_bare_metal.json diff --git a/main.cpp b/main.cpp index 28982828..54dbe21f 100644 --- a/main.cpp +++ b/main.cpp @@ -1,27 +1,23 @@ /* mbed Microcontroller Library - * Copyright (c) 2018-2019 ARM Limited + * Copyright (c) 2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 */ #include "mbed.h" #include "platform/mbed_thread.h" -#include "stats_report.h" + + +// Blinking rate in milliseconds +#define BLINKING_RATE_MS 500 + int main() { - SystemReport sys_state( SLEEP_TIME * PRINT_AFTER_N_LOOPS /* Loop delay time in ms */); + // Initialise the digital pin LED1 as an output + DigitalOut led(LED1); - int count = 0; while (true) { - // Blink LED and wait 0.5 seconds - led1 = !led1; - thread_sleep_for(SLEEP_TIME); - - if ((0 == count) || (PRINT_AFTER_N_LOOPS == count)) { - // Following the main thread wait, report on the current system status - sys_state.report_state(); - count = 0; - } - ++count; + led = !led; + thread_sleep_for(BLINKING_RATE_MS); } } From b3e0e50544a3e5e8b09fdf95b43cf231eaa810ff Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Tue, 15 Oct 2019 14:12:23 +0100 Subject: [PATCH 04/16] Remove `tests` as no longer relevant The test was checking the serial output from the runtime stats. Runtime stats have been removed. --- tests/README.md | 12 ------------ tests/blinky.log | 29 ----------------------------- 2 files changed, 41 deletions(-) delete mode 100644 tests/README.md delete mode 100644 tests/blinky.log diff --git a/tests/README.md b/tests/README.md deleted file mode 100644 index 9418aabd..00000000 --- a/tests/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# Testing examples - -Examples are tested using tool [htrun](https://github.com/ARMmbed/mbed-os-tools/tree/master/packages/mbed-host-tests) and templated print log. - -To run the test, use following command after you build the example: -``` -mbedhtrun -d D: -p COM4 -m K64F -f .\BUILD\K64F\GCC_ARM\blinky.bin --compare-log tests\blinky.log -``` - - -More details about `htrun` are [here](https://github.com/ARMmbed/mbed-os-tools/tree/master/packages/mbed-host-tests#testing-mbed-os-examples). - diff --git a/tests/blinky.log b/tests/blinky.log deleted file mode 100644 index 9347dce7..00000000 --- a/tests/blinky.log +++ /dev/null @@ -1,29 +0,0 @@ -=============================== SYSTEM INFO ================================ -Mbed OS Version: -CPU ID: 0x[0-9a-fA-F]+ -Compiler ID: \d+ -Compiler Version: -================= CPU STATS ================= -Idle: \d+% Usage: \d+% -================ HEAP STATS ================= -Current heap: \d+ -Max heap size: \d+ -================ THREAD STATS =============== -ID: 0x[0-9a-fA-F]+ -Name: main -State: \d+ -Priority: \d+ -Stack Size: \d+ -Stack Space: \d+ -ID: 0x[0-9a-fA-F]+ -Name: rtx_idle -State: \d+ -Priority: \d+ -Stack Size: \d+ -Stack Space: \d+ -ID: 0x[0-9a-fA-F]+ -Name: rtx_timer -State: \d+ -Priority: \d+ -Stack Size: \d+ -Stack Space: \d+ From 9f4477fa8c94dc7c11a8daa38d9622aaab923d0c Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Tue, 15 Oct 2019 14:23:14 +0100 Subject: [PATCH 05/16] Correct the last force push resulting from rebasing from the master branch --- .vscode/settings.json | 25 ------------------------- README.md | 37 +------------------------------------ mbed-os.lib | 2 +- 3 files changed, 2 insertions(+), 62 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 08d05dd5..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "files.associations": { - "*.original": "c", - "mbed_printf_implementation.h": "c", - "mstd_iterator": "cpp", - "array": "cpp", - "initializer_list": "cpp", - "mstd_utility": "cpp", - "string_view": "cpp", - "utility": "cpp", - "*.tpp": "cpp", - "*.tcc": "cpp", - "cerrno": "cpp", - "mstd_type_traits": "cpp", - "mstd_functional": "cpp", - "mstd_memory": "cpp", - "chrono": "cpp", - "functional": "cpp", - "istream": "cpp", - "ostream": "cpp", - "ratio": "cpp", - "tuple": "cpp", - "type_traits": "cpp" - } -} \ No newline at end of file diff --git a/README.md b/README.md index 8c706e7a..7d2dc241 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Blinky Mbed OS Example +# Blinky Mbed OS Example [Official] The example project contains an application to blink an LED on supported [Mbed boards](https://os.mbed.com/platforms/). @@ -27,23 +27,9 @@ The `main()` function is the single thread in the application, it toggles the st ``` The binary is located at `./BUILD///mbed-os-example-blinky.bin` and can alternatively be manually copied to the target which gets mounted on the host computer via USB. -<<<<<<< HEAD -<<<<<<< HEAD -### Application functionality - -The `main()` function calls `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. - -### Optional RTOS runtime statistics -======= -### Bare metal -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/latest/reference/mbed-os-bare-metal.html) profile. -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. ->>>>>>> Add application variants and Mbed OS bare metal tutorial -======= ## Bare metal The application above 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/latest/reference/mbed-os-bare-metal.html) profile. An application configuration file, [`config_bare_metal.json`](./config_bare_metal.json) is provided to build a binary with Mbed OS bare metal profile. ->>>>>>> Remove multithreaded application 1. Connect a USB cable between the USB port on the target and the host computer. 2. Run the following command to build the example project with runtime statistics output: @@ -55,28 +41,7 @@ The binary is located at `./BUILD///mbed-os-example-blinky.bi `"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. -<<<<<<< HEAD -## Blinky multi-threaded application - -This variant shows Mbed OS features suchs as threads, thread delay, and inter-thread communication to blink an LED. - -### Application functionality - -The `main()` function calls `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. - -### Building and Running - -1. Connect a USB cable between the USB port on the target and the host computer. -2. Run the following command to build the example project and program the microcontroller flash memory: - ```bash - $ mbed compile -m -t --flash --app-config=./blinky_multithreaded/config_blinky_multithreaded.json - ``` -The binary is located at `./BUILD///mbed-os-example-blinky.bin` and can alternatively be manually copied to the target which gets mounted on the host computer via USB. - -### Optional RTOS runtime statistics -======= ## Optional RTOS runtime statistics ->>>>>>> Remove multithreaded application 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). diff --git a/mbed-os.lib b/mbed-os.lib index 04231156..f9c9a23d 100644 --- a/mbed-os.lib +++ b/mbed-os.lib @@ -1 +1 @@ -https://github.com/ARMmbed/mbed-os/#b6e5a0a8afa34dec9dae8963778aebce0c82a54b +https://github.com/ARMmbed/mbed-os/#5941d1718339116cd12914238ec331c84da3d08f \ No newline at end of file From 3e5b7dff15204f6c249c185394bbd37d7625302b Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Tue, 15 Oct 2019 14:41:19 +0100 Subject: [PATCH 06/16] Marked the example as official --- README.md | 3 ++- resources/official_armmbed_example_badge.png | Bin 0 -> 7037 bytes 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 resources/official_armmbed_example_badge.png diff --git a/README.md b/README.md index 7d2dc241..1a23aae7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -# Blinky Mbed OS Example [Official] +![](./resources/official_armmbed_example_badge.png) +# Blinky Mbed OS Example The example project contains an application to blink an LED on supported [Mbed boards](https://os.mbed.com/platforms/). diff --git a/resources/official_armmbed_example_badge.png b/resources/official_armmbed_example_badge.png new file mode 100644 index 0000000000000000000000000000000000000000..46867af28c2aa936d9b97340ae771af968c8d56f GIT binary patch literal 7037 zcmYj$cQoAJ^Zx2q7oDhy5+%rLQDc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^)NA*oSCjtt)aaV``}b^^Me5n|nYgOe}zRfoz+N`scTe|z?0cMnwVGnzVkEBzyG zaOEw8aUa5Y=XePZn;&D$+y$1@G89c6a+2E`{v%W@`s#?M@Ur^SBObT{(4zkjp3M$M z167I=r=oQIAHzd Date: Wed, 16 Oct 2019 07:57:23 +0100 Subject: [PATCH 07/16] Addressing PR review comments and adding a smaller badge --- README.md | 23 ++++++++----------- mbed-os.lib | 2 +- resources/official_armmbed_example_badge.png | Bin 7037 -> 3762 bytes 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 1a23aae7..683a8e7b 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ ![](./resources/official_armmbed_example_badge.png) # Blinky Mbed OS Example -The example project contains an application to blink an LED on supported [Mbed boards](https://os.mbed.com/platforms/). +The example project is part of the [Arm Mbed OS quick start guide](https://os.mbed.com/docs/mbed-os/v5.14/quick-start/index.html). It contains an application to repeatedly blink an LED on supported [Mbed boards](https://os.mbed.com/platforms/). The project can be built with all supported [Mbed OS build tools](https://os.mbed.com/docs/mbed-os/latest/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). Please install Arm Mbed CLI. -Depending on the target, the example project can be built with GCC_ARM, ARM or IAR toolchain. Run the command below after installing ARM Mbed CLI to determine which toolchain support your target. +Depending on the target, the example project can be built with GCC_ARM, ARM or IAR toolchain. Run the command below after installing ARM Mbed CLI to determine which toolchain supports your target. ```bash $ mbed compile -S @@ -13,7 +13,7 @@ $ mbed compile -S Clone this repository on your system and change the current directory to where the project was cloned. -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/latest/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. +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/latest/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 a configuration a file to modify default parameters of Mbed OS later on in the tutorial. ## Application functionality @@ -22,25 +22,20 @@ The `main()` function is the single thread in the application, it toggles the st ## Building and Running 1. Connect a USB cable between the USB port on the target and the host computer. -2. Run the following command to build the example project and program the microcontroller flash memory: +2. Run the following command to build the example project and program the microcontroller flash memory: ```bash $ mbed compile -m -t --flash ``` The binary is located at `./BUILD///mbed-os-example-blinky.bin` and can alternatively be manually copied to the target which gets mounted on the host computer via USB. ## Bare metal -The application above 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/latest/reference/mbed-os-bare-metal.html) profile. +The binary above is built with the full Mbed OS library including its RTOS components. However, for single-threaded applications running on ultra-constrained targets, 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/latest/reference/mbed-os-bare-metal.html) profile. An application configuration file, [`config_bare_metal.json`](./config_bare_metal.json) is provided to build a binary with Mbed OS bare metal profile. -1. Connect a USB cable between the USB port on the target and the host computer. -2. Run the following command to build the example project with runtime statistics output: - ```bash - $ mbed compile -m -t --app-config config_bare_metal.json --flash - ``` -The binary is located at `./BUILD///mbed-os-example-blinky.bin` and can alternatively be manually copied to the target which gets mounted on the host computer via USB. - -`"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. - +Run the following command instead of the one [above](#build_cmd) to build with Mbed OS bare metal profile: +```bash +$ mbed compile -m -t --app-config config_bare_metal.json --flash +``` ## Optional RTOS runtime statistics diff --git a/mbed-os.lib b/mbed-os.lib index f9c9a23d..03aa1964 100644 --- a/mbed-os.lib +++ b/mbed-os.lib @@ -1 +1 @@ -https://github.com/ARMmbed/mbed-os/#5941d1718339116cd12914238ec331c84da3d08f \ No newline at end of file +https://github.com/ARMmbed/mbed-os/#5941d1718339116cd12914238ec331c84da3d08f diff --git a/resources/official_armmbed_example_badge.png b/resources/official_armmbed_example_badge.png index 46867af28c2aa936d9b97340ae771af968c8d56f..9f66abe54256b9e2f98088b23b602d502b7fa365 100644 GIT binary patch literal 3762 zcmV;j4o&fiP)*ON z1lU9zHzt#+KlkWrIYNaBtSQ2wTwr5rv2-pUsTr8)cwjE2_q%##YE? z#&V7enlM7hQz4hlj1^4R%?Fw?tS`b=G=dIiCD#_mk(0uSDTNt*;$Yv+k4>m!o7xt& zY$_fiLe!o<9O`vy`W(q-#?qB~f`W5D z1mcQo=ZA2Yk847F#f1hp1MDqQn!LrrpZklW1B z6HnfmnOOVqD~IX%{~n`nT(p)hJ$n^ROife!iX}92>;&ERmlx@tpZ#&mbsej>-0+ce zcL&!jTURZ?ft8i8IvgiYDv0{@hOKBuQ)ay%MO-WVZd?GI}<@MCzY^}r2USBPHu5UZ1?7;=!@sK z(-r5PK@U9rPx{Q*I9=PmlJ-40O&7E-q0vumrhR{#qLJqg(c^n_^zaw9B&yhfc*oi! z4o!lfV)Gak=y>uhESaVj-~F*pkZVmX-^Kgj=FwaLNKJgsrGf ziV^JcWyi$5jU)=BO}i%C=a7iurS)qOJB+|`8`0Wxq9Y`THjRLPy|Q{TNy7KZ=~4k}$`2Rl&uUtqrC4r>+@_D6pjD?WvaK;MC`)bn*m2tV z)Is~IU*xCgYZsqGj~$*NAA#PO`0ndr1d*{~M=;zR*g$unc3Ew@&Sx+Jpu?6gCZoR3QgNt|=EH;SFgLBwUHyVpxcB&eeGOL84`Z3nEAv zWYmo|ju@@lTn!{^%|{3TYaxKmON}M3ZL|ULJfnixymYZ2@mZ;hah#K}Z<4a*Y6inx z#|`mu?k@mB?AFH7jWNbt^q>srBc&;0jo5DK>qm~?a_4i0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^@n=A8Oss;-k)Es4cGUTd^hEq5*vH(Qo02EbrUI5&}@uBaQ(M`Tnp{?2fihq*K`6`mnee$j-OnIkg2pY zgmW8CNM-cE2#^#1_0#`IkZ>{j;K{c5+s)lFyJ!lB+TZHCmWJ2p+nKp=@xJ16)SiQs z^s^)NA*oSCjtt)aaV``}b^^Me5n|nYgOe}zRfoz+N`scTe|z?0cMnwVGnzVkEBzyG zaOEw8aUa5Y=XePZn;&D$+y$1@G89c6a+2E`{v%W@`s#?M@Ur^SBObT{(4zkjp3M$M z167I=r=oQIAHzd Date: Mon, 21 Oct 2019 14:23:49 +0100 Subject: [PATCH 08/16] Remove bare metal information in the project --- README.md | 16 +--------------- config_bare_metal.json | 8 -------- 2 files changed, 1 insertion(+), 23 deletions(-) delete mode 100644 config_bare_metal.json diff --git a/README.md b/README.md index 683a8e7b..91ec6f41 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ The example project is part of the [Arm Mbed OS quick start guide](https://os.mb The project can be built with all supported [Mbed OS build tools](https://os.mbed.com/docs/mbed-os/latest/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). Please install Arm Mbed CLI. -Depending on the target, the example project can be built with GCC_ARM, ARM or IAR toolchain. Run the command below after installing ARM Mbed CLI to determine which toolchain supports your target. +Depending on the target, the example project can be built with `GCC_ARM`, `ARM` or `IAR` toolchain. Run the command below after installing ARM Mbed CLI to determine which toolchain supports your target. ```bash $ mbed compile -S @@ -13,7 +13,6 @@ $ mbed compile -S Clone this repository on your system and change the current directory to where the project was cloned. -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/latest/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 a configuration a file to modify default parameters of Mbed OS later on in the tutorial. ## Application functionality @@ -28,19 +27,6 @@ The `main()` function is the single thread in the application, it toggles the st ``` The binary is located at `./BUILD///mbed-os-example-blinky.bin` and can alternatively be manually copied to the target which gets mounted on the host computer via USB. -## Bare metal -The binary above is built with the full Mbed OS library including its RTOS components. However, for single-threaded applications running on ultra-constrained targets, 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/latest/reference/mbed-os-bare-metal.html) profile. -An application configuration file, [`config_bare_metal.json`](./config_bare_metal.json) is provided to build a binary with Mbed OS bare metal profile. - -Run the following command instead of the one [above](#build_cmd) to build with Mbed OS bare metal profile: -```bash -$ mbed compile -m -t --app-config config_bare_metal.json --flash -``` - -## Optional RTOS runtime statistics - -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). - ## Troubleshooting If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it. diff --git a/config_bare_metal.json b/config_bare_metal.json deleted file mode 100644 index 71675d9d..00000000 --- a/config_bare_metal.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "requires": ["bare-metal"], - "target_overrides": { - "*": { - "target.default_lib" : "small" - } - } -} From 00100851670621ea0d4f1b6262bfe353b7eb48c9 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Wed, 30 Oct 2019 15:40:42 +0000 Subject: [PATCH 09/16] Move supported toolchain info to the "Building and Running" section --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 91ec6f41..14c30eaa 100644 --- a/README.md +++ b/README.md @@ -5,15 +5,8 @@ The example project is part of the [Arm Mbed OS quick start guide](https://os.mb The project can be built with all supported [Mbed OS build tools](https://os.mbed.com/docs/mbed-os/latest/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). Please install Arm Mbed CLI. -Depending on the target, the example project can be built with `GCC_ARM`, `ARM` or `IAR` toolchain. Run the command below after installing ARM Mbed CLI to determine which toolchain supports your target. - -```bash -$ mbed compile -S -``` - Clone this repository on your system and change the current directory to where the project was cloned. - ## Application functionality The `main()` function is the single thread in the application, it toggles the state of a digital output connected to an LED on the target. @@ -27,6 +20,11 @@ The `main()` function is the single thread in the application, it toggles the st ``` The binary is located at `./BUILD///mbed-os-example-blinky.bin` and can alternatively be manually copied to the target which gets mounted on the host computer via USB. +Depending on the target, the example project can be built with `GCC_ARM`, `ARM` or `IAR` toolchain. Run the command below after installing ARM Mbed CLI to determine which toolchain supports your target. + +```bash +$ mbed compile -S +``` ## Troubleshooting If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it. From 96c4eba10ef3d667af8beeb46da52f32e3664540 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Wed, 30 Oct 2019 15:46:09 +0000 Subject: [PATCH 10/16] Add an "Expected output" section to README. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 14c30eaa..1a5fb6a3 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,10 @@ Depending on the target, the example project can be built with `GCC_ARM`, `ARM` $ mbed compile -S ``` +## Expected output +The LED on your target turns on and off every 500 milliseconds. + + ## Troubleshooting If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it. From 77b6b31ec81f398046d76eae568c8c4ef69eae20 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Thu, 31 Oct 2019 13:14:48 +0000 Subject: [PATCH 11/16] Add information about importing to the online compiler. --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1a5fb6a3..3515818f 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,10 @@ The example project is part of the [Arm Mbed OS quick start guide](https://os.mbed.com/docs/mbed-os/v5.14/quick-start/index.html). It contains an application to repeatedly blink an LED on supported [Mbed boards](https://os.mbed.com/platforms/). -The project can be built with all supported [Mbed OS build tools](https://os.mbed.com/docs/mbed-os/latest/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). Please install Arm Mbed CLI. +The project can be built with all supported [Mbed OS build tools](https://os.mbed.com/docs/mbed-os/latest/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). +(Note: To see a rendered example you can import into the Arm Online Compiler, please see our [import quick start](https://os.mbed.com/docs/mbed-os/latest/quick-start/online-with-the-online-compiler.html#importing-the-code).) + +Please install Arm Mbed CLI. Clone this repository on your system and change the current directory to where the project was cloned. From effcefb11afb9af5c5117b0db341a1d7b982ebf5 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Thu, 31 Oct 2019 13:19:49 +0000 Subject: [PATCH 12/16] Say that the example is part of the official Mbed OS examples --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3515818f..2a57e084 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ![](./resources/official_armmbed_example_badge.png) # Blinky Mbed OS Example -The example project is part of the [Arm Mbed OS quick start guide](https://os.mbed.com/docs/mbed-os/v5.14/quick-start/index.html). It contains an application to repeatedly blink an LED on supported [Mbed boards](https://os.mbed.com/platforms/). +The example project is part of the [Arm Mbed OS Official Examples](https://os.mbed.com/code/) and is the [getting started example for Mbed OS](https://os.mbed.com/docs/mbed-os/v5.14/quick-start/index.html). It contains an application that repeatedly blinks an LED on supported [Mbed boards](https://os.mbed.com/platforms/). The project can be built with all supported [Mbed OS build tools](https://os.mbed.com/docs/mbed-os/latest/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). (Note: To see a rendered example you can import into the Arm Online Compiler, please see our [import quick start](https://os.mbed.com/docs/mbed-os/latest/quick-start/online-with-the-online-compiler.html#importing-the-code).) From 1b45642257997c208517f49089b6b306f2661fcd Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Fri, 1 Nov 2019 11:58:00 +0000 Subject: [PATCH 13/16] Add commands to download the project with `git clone` and `mbed import`. --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2a57e084..75ad672b 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,18 @@ The project can be built with all supported [Mbed OS build tools](https://os.mbe Please install Arm Mbed CLI. -Clone this repository on your system and change the current directory to where the project was cloned. +Clone this repository on your system and change the current directory to where the project was cloned: + +```bash +$ git clone git@github.com:armmbed/mbed-os-example-blinky && cd mbed-os-example-blinky +``` + +It is also possible to download the example project with Arm Mbed CLI using the `import` sub-command as follows: + +```bash +$ mbed import mbed-os-example-blinky && cd mbed-os-example-blinky +``` + ## Application functionality From 5213199eb999af9cf32e1ede8bd02a0df3cc37d6 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Mon, 4 Nov 2019 07:39:40 +0000 Subject: [PATCH 14/16] Apply suggestions from code review Co-Authored-By: Amanda Butler --- README.md | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 75ad672b..62d932b2 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,20 @@ ![](./resources/official_armmbed_example_badge.png) -# Blinky Mbed OS Example +# Blinky Mbed OS example The example project is part of the [Arm Mbed OS Official Examples](https://os.mbed.com/code/) and is the [getting started example for Mbed OS](https://os.mbed.com/docs/mbed-os/v5.14/quick-start/index.html). It contains an application that repeatedly blinks an LED on supported [Mbed boards](https://os.mbed.com/platforms/). -The project can be built with all supported [Mbed OS build tools](https://os.mbed.com/docs/mbed-os/latest/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). +You can build the project with all supported [Mbed OS build tools](https://os.mbed.com/docs/mbed-os/latest/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). (Note: To see a rendered example you can import into the Arm Online Compiler, please see our [import quick start](https://os.mbed.com/docs/mbed-os/latest/quick-start/online-with-the-online-compiler.html#importing-the-code).) -Please install Arm Mbed CLI. +1. [Install Mbed CLI](https://os.mbed.com/docs/mbed-os/latest/quick-start/offline-with-mbed-cli.html). -Clone this repository on your system and change the current directory to where the project was cloned: +1. Clone this repository on your system, and change the current directory to where the project was cloned: ```bash $ git clone git@github.com:armmbed/mbed-os-example-blinky && cd mbed-os-example-blinky ``` -It is also possible to download the example project with Arm Mbed CLI using the `import` sub-command as follows: +Alternatively, you can download the example project with Arm Mbed CLI using the `import` subcommand: ```bash $ mbed import mbed-os-example-blinky && cd mbed-os-example-blinky @@ -23,18 +23,20 @@ $ mbed import mbed-os-example-blinky && cd mbed-os-example-blinky ## Application functionality -The `main()` function is the single thread in the application, it toggles the state of a digital output connected to an LED on the target. +The `main()` function is the single thread in the application. It toggles the state of a digital output connected to an LED on the board. -## Building and Running +## Building and running -1. Connect a USB cable between the USB port on the target and the host computer. +1. Connect a USB cable between the USB port on the board and the host computer. 2. Run the following command to build the example project and program the microcontroller flash memory: ```bash $ mbed compile -m -t --flash ``` -The binary is located at `./BUILD///mbed-os-example-blinky.bin` and can alternatively be manually copied to the target which gets mounted on the host computer via USB. +The binary is located at `./BUILD///mbed-os-example-blinky.bin`. -Depending on the target, the example project can be built with `GCC_ARM`, `ARM` or `IAR` toolchain. Run the command below after installing ARM Mbed CLI to determine which toolchain supports your target. +Alternatively, you can manually copy the binary to the board, which you mount on the host computer over USB. + +1. Depending on the target, you can build the example project with the `GCC_ARM`, `ARM` or `IAR` toolchain. After installing Arm Mbed CLI, run the command below to determine which toolchain supports your target. ```bash $ mbed compile -S @@ -52,7 +54,7 @@ If you have problems, you can review the [documentation](https://os.mbed.com/doc * [Mbed OS Stats API](https://os.mbed.com/docs/latest/apis/mbed-statistics.html) * [Mbed OS Configuration](https://os.mbed.com/docs/latest/reference/configuration.html) * [Mbed OS Serial Communication](https://os.mbed.com/docs/latest/tutorials/serial-communication.html) -* [Mbed OS bare metal](https://os.mbed.com/docs/mbed-os/latest/reference/mbed-os-bare-metal.html) +* [Mbed OS bare metal](https://os.mbed.com/docs/mbed-os/latest/reference/mbed-os-bare-metal.html). * [Mbed boards](https://os.mbed.com/platforms/) ### License and contributions From de2bd2cfafd1f376ccf9784438aeaf46352efcf9 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Mon, 4 Nov 2019 07:42:10 +0000 Subject: [PATCH 15/16] Correct indentation --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 62d932b2..a721d37a 100644 --- a/README.md +++ b/README.md @@ -10,15 +10,15 @@ You can build the project with all supported [Mbed OS build tools](https://os.mb 1. Clone this repository on your system, and change the current directory to where the project was cloned: -```bash -$ git clone git@github.com:armmbed/mbed-os-example-blinky && cd mbed-os-example-blinky -``` + ```bash + $ git clone git@github.com:armmbed/mbed-os-example-blinky && cd mbed-os-example-blinky + ``` -Alternatively, you can download the example project with Arm Mbed CLI using the `import` subcommand: + Alternatively, you can download the example project with Arm Mbed CLI using the `import` subcommand: -```bash -$ mbed import mbed-os-example-blinky && cd mbed-os-example-blinky -``` + ```bash + $ mbed import mbed-os-example-blinky && cd mbed-os-example-blinky + ``` ## Application functionality @@ -36,11 +36,11 @@ The binary is located at `./BUILD///mbed-os-example-blinky.bi Alternatively, you can manually copy the binary to the board, which you mount on the host computer over USB. -1. Depending on the target, you can build the example project with the `GCC_ARM`, `ARM` or `IAR` toolchain. After installing Arm Mbed CLI, run the command below to determine which toolchain supports your target. +Depending on the target, you can build the example project with the `GCC_ARM`, `ARM` or `IAR` toolchain. After installing Arm Mbed CLI, run the command below to determine which toolchain supports your target. -```bash -$ mbed compile -S -``` + ```bash + $ mbed compile -S + ``` ## Expected output The LED on your target turns on and off every 500 milliseconds. From 4eb2565fc9442fceaf33c019f065bb80f9b60188 Mon Sep 17 00:00:00 2001 From: Amanda Butler Date: Mon, 4 Nov 2019 09:39:23 -0600 Subject: [PATCH 16/16] Add nitpicky punctuation Add/change punctuation to follow our style guide for consistency across documents. --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a721d37a..6094a0fb 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ The binary is located at `./BUILD///mbed-os-example-blinky.bi Alternatively, you can manually copy the binary to the board, which you mount on the host computer over USB. -Depending on the target, you can build the example project with the `GCC_ARM`, `ARM` or `IAR` toolchain. After installing Arm Mbed CLI, run the command below to determine which toolchain supports your target. +Depending on the target, you can build the example project with the `GCC_ARM`, `ARM` or `IAR` toolchain. After installing Arm Mbed CLI, run the command below to determine which toolchain supports your target: ```bash $ mbed compile -S @@ -51,11 +51,11 @@ If you have problems, you can review the [documentation](https://os.mbed.com/doc ## Related Links -* [Mbed OS Stats API](https://os.mbed.com/docs/latest/apis/mbed-statistics.html) -* [Mbed OS Configuration](https://os.mbed.com/docs/latest/reference/configuration.html) -* [Mbed OS Serial Communication](https://os.mbed.com/docs/latest/tutorials/serial-communication.html) +* [Mbed OS Stats API](https://os.mbed.com/docs/latest/apis/mbed-statistics.html). +* [Mbed OS Configuration](https://os.mbed.com/docs/latest/reference/configuration.html). +* [Mbed OS Serial Communication](https://os.mbed.com/docs/latest/tutorials/serial-communication.html). * [Mbed OS bare metal](https://os.mbed.com/docs/mbed-os/latest/reference/mbed-os-bare-metal.html). -* [Mbed boards](https://os.mbed.com/platforms/) +* [Mbed boards](https://os.mbed.com/platforms/). ### License and contributions