1

Committer:
taminhhien
Date:
Tue Sep 10 06:41:16 2019 +0000
Revision:
0:1cb528f651d6
123

Who changed what in which revision?

UserRevisionLine numberNew contents of line
taminhhien 0:1cb528f651d6 1 # Getting started example for Mbed OS
taminhhien 0:1cb528f651d6 2
taminhhien 0:1cb528f651d6 3 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).)
taminhhien 0:1cb528f651d6 4
taminhhien 0:1cb528f651d6 5 Please install [Mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli).
taminhhien 0:1cb528f651d6 6
taminhhien 0:1cb528f651d6 7 ## Import the example application
taminhhien 0:1cb528f651d6 8
taminhhien 0:1cb528f651d6 9 From the command-line, import the example:
taminhhien 0:1cb528f651d6 10
taminhhien 0:1cb528f651d6 11 ```
taminhhien 0:1cb528f651d6 12 mbed import mbed-os-example-blinky
taminhhien 0:1cb528f651d6 13 cd mbed-os-example-blinky
taminhhien 0:1cb528f651d6 14 ```
taminhhien 0:1cb528f651d6 15
taminhhien 0:1cb528f651d6 16 ### Now compile
taminhhien 0:1cb528f651d6 17
taminhhien 0:1cb528f651d6 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:
taminhhien 0:1cb528f651d6 19
taminhhien 0:1cb528f651d6 20 ```
taminhhien 0:1cb528f651d6 21 mbed compile -m K64F -t ARM
taminhhien 0:1cb528f651d6 22 ```
taminhhien 0:1cb528f651d6 23
taminhhien 0:1cb528f651d6 24 Your PC may take a few minutes to compile your code. At the end, you see the following result:
taminhhien 0:1cb528f651d6 25
taminhhien 0:1cb528f651d6 26 ```
taminhhien 0:1cb528f651d6 27 [snip]
taminhhien 0:1cb528f651d6 28
taminhhien 0:1cb528f651d6 29 Image: ./BUILD/K64F/GCC_ARM/mbed-os-example-blinky.bin
taminhhien 0:1cb528f651d6 30 ```
taminhhien 0:1cb528f651d6 31
taminhhien 0:1cb528f651d6 32 ### Program your board
taminhhien 0:1cb528f651d6 33
taminhhien 0:1cb528f651d6 34 1. Connect your Mbed device to the computer over USB.
taminhhien 0:1cb528f651d6 35 1. Copy the binary file to the Mbed device.
taminhhien 0:1cb528f651d6 36 1. Press the reset button to start the program.
taminhhien 0:1cb528f651d6 37
taminhhien 0:1cb528f651d6 38 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:
taminhhien 0:1cb528f651d6 39
taminhhien 0:1cb528f651d6 40 * System Information:
taminhhien 0:1cb528f651d6 41 * Mbed OS Version: Will currently default to 999999
taminhhien 0:1cb528f651d6 42 * Compiler ID
taminhhien 0:1cb528f651d6 43 * ARM = 1
taminhhien 0:1cb528f651d6 44 * GCC_ARM = 2
taminhhien 0:1cb528f651d6 45 * IAR = 3
taminhhien 0:1cb528f651d6 46 * [CPUID Register Information](#cpuid-register-information)
taminhhien 0:1cb528f651d6 47 * [Compiler Version](#compiler-version)
taminhhien 0:1cb528f651d6 48 * CPU Statistics
taminhhien 0:1cb528f651d6 49 * Percentage of runtime that the device has spent awake versus in sleep
taminhhien 0:1cb528f651d6 50 * Heap Statistics
taminhhien 0:1cb528f651d6 51 * Current heap size
taminhhien 0:1cb528f651d6 52 * Max heap size which refers to the largest the heap has grown to
taminhhien 0:1cb528f651d6 53 * Thread Statistics
taminhhien 0:1cb528f651d6 54 * Provides information on all running threads in the OS including
taminhhien 0:1cb528f651d6 55 * Thread ID
taminhhien 0:1cb528f651d6 56 * Thread Name
taminhhien 0:1cb528f651d6 57 * Thread State
taminhhien 0:1cb528f651d6 58 * Thread Priority
taminhhien 0:1cb528f651d6 59 * Thread Stack Size
taminhhien 0:1cb528f651d6 60 * Thread Stack Space
taminhhien 0:1cb528f651d6 61
taminhhien 0:1cb528f651d6 62 #### Compiler Version
taminhhien 0:1cb528f651d6 63
taminhhien 0:1cb528f651d6 64 | Compiler | Version Layout |
taminhhien 0:1cb528f651d6 65 | -------- | -------------- |
taminhhien 0:1cb528f651d6 66 | ARM | PVVbbbb (P = Major; VV = Minor; bbbb = build number) |
taminhhien 0:1cb528f651d6 67 | GCC | VVRRPP (VV = Version; RR = Revision; PP = Patch) |
taminhhien 0:1cb528f651d6 68 | IAR | VRRRPPP (V = Version; RRR = Revision; PPP = Patch) |
taminhhien 0:1cb528f651d6 69
taminhhien 0:1cb528f651d6 70 #### CPUID Register Information
taminhhien 0:1cb528f651d6 71
taminhhien 0:1cb528f651d6 72 | Bit Field | Field Description | Values |
taminhhien 0:1cb528f651d6 73 | --------- | ----------------- | ------ |
taminhhien 0:1cb528f651d6 74 |[31:24] | Implementer | 0x41 = ARM |
taminhhien 0:1cb528f651d6 75 |[23:20] | Variant | Major revision 0x0 = Revision 0 |
taminhhien 0:1cb528f651d6 76 |[19:16] | Architecture | 0xC = Baseline Architecture |
taminhhien 0:1cb528f651d6 77 | | | 0xF = Constant (Mainline Architecture) |
taminhhien 0:1cb528f651d6 78 |[15:4] | Part Number | 0xC20 = Cortex-M0 |
taminhhien 0:1cb528f651d6 79 | | | 0xC60 = Cortex-M0+ |
taminhhien 0:1cb528f651d6 80 | | | 0xC23 = Cortex-M3 |
taminhhien 0:1cb528f651d6 81 | | | 0xC24 = Cortex-M4 |
taminhhien 0:1cb528f651d6 82 | | | 0xC27 = Cortex-M7 |
taminhhien 0:1cb528f651d6 83 | | | 0xD20 = Cortex-M23 |
taminhhien 0:1cb528f651d6 84 | | | 0xD21 = Cortex-M33 |
taminhhien 0:1cb528f651d6 85 |[3:0] | Revision | Minor revision: 0x1 = Patch 1 |
taminhhien 0:1cb528f651d6 86
taminhhien 0:1cb528f651d6 87
taminhhien 0:1cb528f651d6 88
taminhhien 0:1cb528f651d6 89 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).
taminhhien 0:1cb528f651d6 90
taminhhien 0:1cb528f651d6 91
taminhhien 0:1cb528f651d6 92 ### Output
taminhhien 0:1cb528f651d6 93
taminhhien 0:1cb528f651d6 94 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.
taminhhien 0:1cb528f651d6 95
taminhhien 0:1cb528f651d6 96 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).
taminhhien 0:1cb528f651d6 97
taminhhien 0:1cb528f651d6 98 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):
taminhhien 0:1cb528f651d6 99
taminhhien 0:1cb528f651d6 100 ```
taminhhien 0:1cb528f651d6 101 =============================== SYSTEM INFO ================================
taminhhien 0:1cb528f651d6 102 Mbed OS Version: 999999
taminhhien 0:1cb528f651d6 103 CPU ID: 0x410fc241
taminhhien 0:1cb528f651d6 104 Compiler ID: 2
taminhhien 0:1cb528f651d6 105 Compiler Version: 60300
taminhhien 0:1cb528f651d6 106 RAM0: Start 0x20000000 Size: 0x30000
taminhhien 0:1cb528f651d6 107 RAM1: Start 0x1fff0000 Size: 0x10000
taminhhien 0:1cb528f651d6 108 ROM0: Start 0x0 Size: 0x100000
taminhhien 0:1cb528f651d6 109 ================= CPU STATS =================
taminhhien 0:1cb528f651d6 110 Idle: 98% Usage: 2%
taminhhien 0:1cb528f651d6 111 ================ HEAP STATS =================
taminhhien 0:1cb528f651d6 112 Current heap: 1096
taminhhien 0:1cb528f651d6 113 Max heap size: 1096
taminhhien 0:1cb528f651d6 114 ================ THREAD STATS ===============
taminhhien 0:1cb528f651d6 115 ID: 0x20001eac
taminhhien 0:1cb528f651d6 116 Name: main_thread
taminhhien 0:1cb528f651d6 117 State: 2
taminhhien 0:1cb528f651d6 118 Priority: 24
taminhhien 0:1cb528f651d6 119 Stack Size: 4096
taminhhien 0:1cb528f651d6 120 Stack Space: 3296
taminhhien 0:1cb528f651d6 121
taminhhien 0:1cb528f651d6 122 ID: 0x20000f5c
taminhhien 0:1cb528f651d6 123 Name: idle_thread
taminhhien 0:1cb528f651d6 124 State: 1
taminhhien 0:1cb528f651d6 125 Priority: 1
taminhhien 0:1cb528f651d6 126 Stack Size: 512
taminhhien 0:1cb528f651d6 127 Stack Space: 352
taminhhien 0:1cb528f651d6 128
taminhhien 0:1cb528f651d6 129 ID: 0x20000f18
taminhhien 0:1cb528f651d6 130 Name: timer_thread
taminhhien 0:1cb528f651d6 131 State: 3
taminhhien 0:1cb528f651d6 132 Priority: 40
taminhhien 0:1cb528f651d6 133 Stack Size: 768
taminhhien 0:1cb528f651d6 134 Stack Space: 664
taminhhien 0:1cb528f651d6 135
taminhhien 0:1cb528f651d6 136 ```
taminhhien 0:1cb528f651d6 137
taminhhien 0:1cb528f651d6 138 ## Troubleshooting
taminhhien 0:1cb528f651d6 139
taminhhien 0:1cb528f651d6 140 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.
taminhhien 0:1cb528f651d6 141
taminhhien 0:1cb528f651d6 142 ## Related Links
taminhhien 0:1cb528f651d6 143
taminhhien 0:1cb528f651d6 144 * [Mbed OS Stats API](https://os.mbed.com/docs/latest/apis/mbed-statistics.html)
taminhhien 0:1cb528f651d6 145 * [Mbed OS Configuration](https://os.mbed.com/docs/latest/reference/configuration.html)
taminhhien 0:1cb528f651d6 146 * [Mbed OS Serial Communication](https://os.mbed.com/docs/latest/tutorials/serial-communication.html)
taminhhien 0:1cb528f651d6 147
taminhhien 0:1cb528f651d6 148 ### License and contributions
taminhhien 0:1cb528f651d6 149
taminhhien 0:1cb528f651d6 150 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.
taminhhien 0:1cb528f651d6 151
taminhhien 0:1cb528f651d6 152 This project contains code from other projects. The original license text is included in those source files. They must comply with our license guide.