HelloWorld OS 5.13

Committer:
dfraj
Date:
Mon Aug 26 12:47:56 2019 +0000
Revision:
0:ae9fa2651603
HelloWorld OS 5.13

Who changed what in which revision?

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