Matheus Castro / Mbed OS mbed-os-example-blinky
Committer:
matheusctro
Date:
Thu Oct 17 13:14:00 2019 +0000
Revision:
0:0d27bd05c2d2
teste

Who changed what in which revision?

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