hi

Dependencies:   CANMsg

Committer:
davidyu
Date:
Wed Dec 11 18:55:34 2019 +0000
Revision:
1:983b2e230859
Parent:
0:69bbc94cae9a
final bps sim and temp

Who changed what in which revision?

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