Monty Bot
/
mbed-os-example-blinky-latest
sada
README.md@0:a8a90ba73c3a, 2019-02-02 (annotated)
- Committer:
- montybot
- Date:
- Sat Feb 02 09:41:52 2019 +0000
- Revision:
- 0:a8a90ba73c3a
as
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
montybot | 0:a8a90ba73c3a | 1 | # Getting started example for Mbed OS |
montybot | 0:a8a90ba73c3a | 2 | |
montybot | 0:a8a90ba73c3a | 3 | This guide reviews the steps required to get Blinky with the addition of dynamic OS statistics working on an Mbed OS platform. |
montybot | 0:a8a90ba73c3a | 4 | |
montybot | 0:a8a90ba73c3a | 5 | Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli). |
montybot | 0:a8a90ba73c3a | 6 | |
montybot | 0:a8a90ba73c3a | 7 | ## Import the example application |
montybot | 0:a8a90ba73c3a | 8 | |
montybot | 0:a8a90ba73c3a | 9 | From the command-line, import the example: |
montybot | 0:a8a90ba73c3a | 10 | |
montybot | 0:a8a90ba73c3a | 11 | ``` |
montybot | 0:a8a90ba73c3a | 12 | mbed import mbed-os-example-blinky |
montybot | 0:a8a90ba73c3a | 13 | cd mbed-os-example-blinky |
montybot | 0:a8a90ba73c3a | 14 | ``` |
montybot | 0:a8a90ba73c3a | 15 | |
montybot | 0:a8a90ba73c3a | 16 | ### Now compile |
montybot | 0:a8a90ba73c3a | 17 | |
montybot | 0:a8a90ba73c3a | 18 | Invoke `mbed compile`, and specify the name of your platform and your favorite toolchain (`GCC_ARM`, `ARM`, `IAR`). For example, for the ARM Compiler 5: |
montybot | 0:a8a90ba73c3a | 19 | |
montybot | 0:a8a90ba73c3a | 20 | ``` |
montybot | 0:a8a90ba73c3a | 21 | mbed compile -m K64F -t ARM |
montybot | 0:a8a90ba73c3a | 22 | ``` |
montybot | 0:a8a90ba73c3a | 23 | |
montybot | 0:a8a90ba73c3a | 24 | Your PC may take a few minutes to compile your code. At the end, you see the following result: |
montybot | 0:a8a90ba73c3a | 25 | |
montybot | 0:a8a90ba73c3a | 26 | ``` |
montybot | 0:a8a90ba73c3a | 27 | [snip] |
montybot | 0:a8a90ba73c3a | 28 | +----------------------------+-------+-------+------+ |
montybot | 0:a8a90ba73c3a | 29 | | Module | .text | .data | .bss | |
montybot | 0:a8a90ba73c3a | 30 | |--------------------|-----------|----------|----------| |
montybot | 0:a8a90ba73c3a | 31 | | [fill] | 98(+0) | 0(+0) | 2211(+0) | |
montybot | 0:a8a90ba73c3a | 32 | | [lib]/c.a | 27835(+0) | 2472(+0) | 89(+0) | |
montybot | 0:a8a90ba73c3a | 33 | | [lib]/gcc.a | 3168(+0) | 0(+0) | 0(+0) | |
montybot | 0:a8a90ba73c3a | 34 | | [lib]/misc | 248(+0) | 8(+0) | 28(+0) | |
montybot | 0:a8a90ba73c3a | 35 | | [lib]/nosys.a | 32(+0) | 0(+0) | 0(+0) | |
montybot | 0:a8a90ba73c3a | 36 | | main.o | 924(+0) | 0(+0) | 12(+0) | |
montybot | 0:a8a90ba73c3a | 37 | | mbed-os/components | 134(+0) | 0(+0) | 0(+0) | |
montybot | 0:a8a90ba73c3a | 38 | | mbed-os/drivers | 56(+0) | 0(+0) | 0(+0) | |
montybot | 0:a8a90ba73c3a | 39 | | mbed-os/features | 42(+0) | 0(+0) | 184(+0) | |
montybot | 0:a8a90ba73c3a | 40 | | mbed-os/hal | 2087(+0) | 8(+0) | 152(+0) | |
montybot | 0:a8a90ba73c3a | 41 | | mbed-os/platform | 3633(+0) | 260(+0) | 209(+0) | |
montybot | 0:a8a90ba73c3a | 42 | | mbed-os/rtos | 9370(+0) | 168(+0) | 6053(+0) | |
montybot | 0:a8a90ba73c3a | 43 | | mbed-os/targets | 9536(+0) | 12(+0) | 382(+0) | |
montybot | 0:a8a90ba73c3a | 44 | | Subtotals | 57163(+0) | 2928(+0) | 9320(+0) | |
montybot | 0:a8a90ba73c3a | 45 | Total Static RAM memory (data + bss): 12248(+0) bytes |
montybot | 0:a8a90ba73c3a | 46 | Total Flash memory (text + data): 60091(+0) bytes |
montybot | 0:a8a90ba73c3a | 47 | |
montybot | 0:a8a90ba73c3a | 48 | Image: ./BUILD/K64F/GCC_ARM/mbed-os-example-blinky.bin |
montybot | 0:a8a90ba73c3a | 49 | ``` |
montybot | 0:a8a90ba73c3a | 50 | |
montybot | 0:a8a90ba73c3a | 51 | ### Program your board |
montybot | 0:a8a90ba73c3a | 52 | |
montybot | 0:a8a90ba73c3a | 53 | 1. Connect your mbed device to the computer over USB. |
montybot | 0:a8a90ba73c3a | 54 | 1. Copy the binary file to the mbed device. |
montybot | 0:a8a90ba73c3a | 55 | 1. Press the reset button to start the program. |
montybot | 0:a8a90ba73c3a | 56 | |
montybot | 0:a8a90ba73c3a | 57 | 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: |
montybot | 0:a8a90ba73c3a | 58 | |
montybot | 0:a8a90ba73c3a | 59 | * System Information: |
montybot | 0:a8a90ba73c3a | 60 | * Mbed OS Version: Will currently default to 999999 |
montybot | 0:a8a90ba73c3a | 61 | * Compiler ID |
montybot | 0:a8a90ba73c3a | 62 | * ARM = 1 |
montybot | 0:a8a90ba73c3a | 63 | * GCC_ARM = 2 |
montybot | 0:a8a90ba73c3a | 64 | * IAR = 3 |
montybot | 0:a8a90ba73c3a | 65 | * [CPUID Register Information](#cpuid-register-information) |
montybot | 0:a8a90ba73c3a | 66 | * [Compiler Version](#compiler-version) |
montybot | 0:a8a90ba73c3a | 67 | * CPU Statistics |
montybot | 0:a8a90ba73c3a | 68 | * Percentage of runtime that the device has spent awake versus in sleep |
montybot | 0:a8a90ba73c3a | 69 | * Heap Statistics |
montybot | 0:a8a90ba73c3a | 70 | * Current heap size |
montybot | 0:a8a90ba73c3a | 71 | * Max heap size which refers to the largest the heap has grown to |
montybot | 0:a8a90ba73c3a | 72 | * Thread Statistics |
montybot | 0:a8a90ba73c3a | 73 | * Provides information on all running threads in the OS including |
montybot | 0:a8a90ba73c3a | 74 | * Thread ID |
montybot | 0:a8a90ba73c3a | 75 | * Thread Name |
montybot | 0:a8a90ba73c3a | 76 | * Thread State |
montybot | 0:a8a90ba73c3a | 77 | * Thread Priority |
montybot | 0:a8a90ba73c3a | 78 | * Thread Stack Size |
montybot | 0:a8a90ba73c3a | 79 | * Thread Stack Space |
montybot | 0:a8a90ba73c3a | 80 | |
montybot | 0:a8a90ba73c3a | 81 | #### Compiler Version |
montybot | 0:a8a90ba73c3a | 82 | |
montybot | 0:a8a90ba73c3a | 83 | | Compiler | Version Layout | |
montybot | 0:a8a90ba73c3a | 84 | | -------- | -------------- | |
montybot | 0:a8a90ba73c3a | 85 | | ARM | PVVbbbb (P = Major; VV = Minor; bbbb = build number) | |
montybot | 0:a8a90ba73c3a | 86 | | GCC | VVRRPP (VV = Version; RR = Revision; PP = Patch) | |
montybot | 0:a8a90ba73c3a | 87 | | IAR | VRRRPPP (V = Version; RRR = Revision; PPP = Patch) | |
montybot | 0:a8a90ba73c3a | 88 | |
montybot | 0:a8a90ba73c3a | 89 | #### CPUID Register Information |
montybot | 0:a8a90ba73c3a | 90 | |
montybot | 0:a8a90ba73c3a | 91 | | Bit Field | Field Description | Values | |
montybot | 0:a8a90ba73c3a | 92 | | --------- | ----------------- | ------ | |
montybot | 0:a8a90ba73c3a | 93 | |[31:24] | Implementer | 0x41 = ARM | |
montybot | 0:a8a90ba73c3a | 94 | |[23:20] | Variant | Major revision 0x0 = Revision 0 | |
montybot | 0:a8a90ba73c3a | 95 | |[19:16] | Architecture | 0xC = Baseline Architecture | |
montybot | 0:a8a90ba73c3a | 96 | | | | 0xF = Constant (Mainline Architecture) | |
montybot | 0:a8a90ba73c3a | 97 | |[15:4] | Part Number | 0xC20 = Cortex-M0 | |
montybot | 0:a8a90ba73c3a | 98 | | | | 0xC60 = Cortex-M0+ | |
montybot | 0:a8a90ba73c3a | 99 | | | | 0xC23 = Cortex-M3 | |
montybot | 0:a8a90ba73c3a | 100 | | | | 0xC24 = Cortex-M4 | |
montybot | 0:a8a90ba73c3a | 101 | | | | 0xC27 = Cortex-M7 | |
montybot | 0:a8a90ba73c3a | 102 | | | | 0xD20 = Cortex-M23 | |
montybot | 0:a8a90ba73c3a | 103 | | | | 0xD21 = Cortex-M33 | |
montybot | 0:a8a90ba73c3a | 104 | |[3:0] | Revision | Minor revision: 0x1 = Patch 1 | |
montybot | 0:a8a90ba73c3a | 105 | |
montybot | 0:a8a90ba73c3a | 106 | |
montybot | 0:a8a90ba73c3a | 107 | |
montybot | 0:a8a90ba73c3a | 108 | 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). |
montybot | 0:a8a90ba73c3a | 109 | |
montybot | 0:a8a90ba73c3a | 110 | |
montybot | 0:a8a90ba73c3a | 111 | ### Output |
montybot | 0:a8a90ba73c3a | 112 | |
montybot | 0:a8a90ba73c3a | 113 | 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. |
montybot | 0:a8a90ba73c3a | 114 | |
montybot | 0:a8a90ba73c3a | 115 | 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). |
montybot | 0:a8a90ba73c3a | 116 | |
montybot | 0:a8a90ba73c3a | 117 | 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): |
montybot | 0:a8a90ba73c3a | 118 | |
montybot | 0:a8a90ba73c3a | 119 | ``` |
montybot | 0:a8a90ba73c3a | 120 | =============================== SYSTEM INFO ================================ |
montybot | 0:a8a90ba73c3a | 121 | Mbed OS Version: 999999 |
montybot | 0:a8a90ba73c3a | 122 | CPU ID: 0x410fc241 |
montybot | 0:a8a90ba73c3a | 123 | Compiler ID: 2 |
montybot | 0:a8a90ba73c3a | 124 | Compiler Version: 60300 |
montybot | 0:a8a90ba73c3a | 125 | RAM0: Start 0x20000000 Size: 0x30000 |
montybot | 0:a8a90ba73c3a | 126 | RAM1: Start 0x1fff0000 Size: 0x10000 |
montybot | 0:a8a90ba73c3a | 127 | ROM0: Start 0x0 Size: 0x100000 |
montybot | 0:a8a90ba73c3a | 128 | ================= CPU STATS ================= |
montybot | 0:a8a90ba73c3a | 129 | Idle: 98% Usage: 2% |
montybot | 0:a8a90ba73c3a | 130 | ================ HEAP STATS ================= |
montybot | 0:a8a90ba73c3a | 131 | Current heap: 1096 |
montybot | 0:a8a90ba73c3a | 132 | Max heap size: 1096 |
montybot | 0:a8a90ba73c3a | 133 | ================ THREAD STATS =============== |
montybot | 0:a8a90ba73c3a | 134 | ID: 0x20001eac |
montybot | 0:a8a90ba73c3a | 135 | Name: main_thread |
montybot | 0:a8a90ba73c3a | 136 | State: 2 |
montybot | 0:a8a90ba73c3a | 137 | Priority: 24 |
montybot | 0:a8a90ba73c3a | 138 | Stack Size: 4096 |
montybot | 0:a8a90ba73c3a | 139 | Stack Space: 3296 |
montybot | 0:a8a90ba73c3a | 140 | |
montybot | 0:a8a90ba73c3a | 141 | ID: 0x20000f5c |
montybot | 0:a8a90ba73c3a | 142 | Name: idle_thread |
montybot | 0:a8a90ba73c3a | 143 | State: 1 |
montybot | 0:a8a90ba73c3a | 144 | Priority: 1 |
montybot | 0:a8a90ba73c3a | 145 | Stack Size: 512 |
montybot | 0:a8a90ba73c3a | 146 | Stack Space: 352 |
montybot | 0:a8a90ba73c3a | 147 | |
montybot | 0:a8a90ba73c3a | 148 | ID: 0x20000f18 |
montybot | 0:a8a90ba73c3a | 149 | Name: timer_thread |
montybot | 0:a8a90ba73c3a | 150 | State: 3 |
montybot | 0:a8a90ba73c3a | 151 | Priority: 40 |
montybot | 0:a8a90ba73c3a | 152 | Stack Size: 768 |
montybot | 0:a8a90ba73c3a | 153 | Stack Space: 664 |
montybot | 0:a8a90ba73c3a | 154 | |
montybot | 0:a8a90ba73c3a | 155 | ``` |
montybot | 0:a8a90ba73c3a | 156 | |
montybot | 0:a8a90ba73c3a | 157 | ## Troubleshooting |
montybot | 0:a8a90ba73c3a | 158 | |
montybot | 0:a8a90ba73c3a | 159 | 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. |
montybot | 0:a8a90ba73c3a | 160 | |
montybot | 0:a8a90ba73c3a | 161 | ## Related Links |
montybot | 0:a8a90ba73c3a | 162 | |
montybot | 0:a8a90ba73c3a | 163 | * [Mbed OS Stats API](https://os.mbed.com/docs/latest/apis/mbed-statistics.html) |
montybot | 0:a8a90ba73c3a | 164 | * [Mbed OS Configuration](https://os.mbed.com/docs/latest/reference/configuration.html) |
montybot | 0:a8a90ba73c3a | 165 | * [Mbed OS Serial Communication](https://os.mbed.com/docs/latest/tutorials/serial-communication.html) |
montybot | 0:a8a90ba73c3a | 166 | |
montybot | 0:a8a90ba73c3a | 167 | ### License and contributions |
montybot | 0:a8a90ba73c3a | 168 | |
montybot | 0:a8a90ba73c3a | 169 | The software is provided under Apache-2.0 license. Contributions to this project are accepted under the same license. Please see contributing.md for more info. |
montybot | 0:a8a90ba73c3a | 170 | |
montybot | 0:a8a90ba73c3a | 171 | This project contains code from other projects. The original license text is included in those source files. They must comply with our license guide. |