Toggles LED and prints debug information

Committer:
Dheeraj22
Date:
Sun May 26 17:20:23 2019 +0000
Revision:
3:a773d045cb0d
Parent:
0:19ea743b1bfa
Baud rate changed to 9600.

Who changed what in which revision?

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