RTOS Template for ELEC35X 2019

Committer:
noutram
Date:
Wed Sep 25 15:02:03 2019 +0000
Revision:
0:2f993270f60e
RTOS Template for 2019

Who changed what in which revision?

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