my first "os5" bare-metal on online-compiler

Committer:
okano
Date:
Sat Jun 15 06:49:03 2019 +0000
Revision:
0:4cdcddbd6c3d
my first "os5" bare-metal

Who changed what in which revision?

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