Code from N.Outram lecture 23 Oct 2017

Committer:
martinsimpson
Date:
Tue Oct 24 14:01:04 2017 +0000
Revision:
0:24610a6f4e59
edited from N.Outram code lecture 23 Oct 2017

Who changed what in which revision?

UserRevisionLine numberNew contents of line
martinsimpson 0:24610a6f4e59 1 # Getting started with Blinky on mbed OS
martinsimpson 0:24610a6f4e59 2
martinsimpson 0:24610a6f4e59 3 This guide reviews the steps required to get Blinky working on an mbed OS platform.
martinsimpson 0:24610a6f4e59 4
martinsimpson 0:24610a6f4e59 5 Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli).
martinsimpson 0:24610a6f4e59 6
martinsimpson 0:24610a6f4e59 7 ## Import the example application
martinsimpson 0:24610a6f4e59 8
martinsimpson 0:24610a6f4e59 9 From the command-line, import the example:
martinsimpson 0:24610a6f4e59 10
martinsimpson 0:24610a6f4e59 11 ```
martinsimpson 0:24610a6f4e59 12 mbed import mbed-os-example-blinky
martinsimpson 0:24610a6f4e59 13 cd mbed-os-example-blinky
martinsimpson 0:24610a6f4e59 14 ```
martinsimpson 0:24610a6f4e59 15
martinsimpson 0:24610a6f4e59 16 ### Now compile
martinsimpson 0:24610a6f4e59 17
martinsimpson 0:24610a6f4e59 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 5:
martinsimpson 0:24610a6f4e59 19
martinsimpson 0:24610a6f4e59 20 ```
martinsimpson 0:24610a6f4e59 21 mbed compile -m K64F -t ARM
martinsimpson 0:24610a6f4e59 22 ```
martinsimpson 0:24610a6f4e59 23
martinsimpson 0:24610a6f4e59 24 Your PC may take a few minutes to compile your code. At the end, you see the following result:
martinsimpson 0:24610a6f4e59 25
martinsimpson 0:24610a6f4e59 26 ```
martinsimpson 0:24610a6f4e59 27 [snip]
martinsimpson 0:24610a6f4e59 28 +----------------------------+-------+-------+------+
martinsimpson 0:24610a6f4e59 29 | Module | .text | .data | .bss |
martinsimpson 0:24610a6f4e59 30 +----------------------------+-------+-------+------+
martinsimpson 0:24610a6f4e59 31 | Misc | 13939 | 24 | 1372 |
martinsimpson 0:24610a6f4e59 32 | core/hal | 16993 | 96 | 296 |
martinsimpson 0:24610a6f4e59 33 | core/rtos | 7384 | 92 | 4204 |
martinsimpson 0:24610a6f4e59 34 | features/FEATURE_IPV4 | 80 | 0 | 176 |
martinsimpson 0:24610a6f4e59 35 | frameworks/greentea-client | 1830 | 60 | 44 |
martinsimpson 0:24610a6f4e59 36 | frameworks/utest | 2392 | 512 | 292 |
martinsimpson 0:24610a6f4e59 37 | Subtotals | 42618 | 784 | 6384 |
martinsimpson 0:24610a6f4e59 38 +----------------------------+-------+-------+------+
martinsimpson 0:24610a6f4e59 39 Allocated Heap: unknown
martinsimpson 0:24610a6f4e59 40 Allocated Stack: unknown
martinsimpson 0:24610a6f4e59 41 Total Static RAM memory (data + bss): 7168 bytes
martinsimpson 0:24610a6f4e59 42 Total RAM memory (data + bss + heap + stack): 7168 bytes
martinsimpson 0:24610a6f4e59 43 Total Flash memory (text + data + misc): 43402 bytes
martinsimpson 0:24610a6f4e59 44 Image: .\.build\K64F\ARM\mbed-os-example-blinky.bin
martinsimpson 0:24610a6f4e59 45 ```
martinsimpson 0:24610a6f4e59 46
martinsimpson 0:24610a6f4e59 47 ### Program your board
martinsimpson 0:24610a6f4e59 48
martinsimpson 0:24610a6f4e59 49 1. Connect your mbed device to the computer over USB.
martinsimpson 0:24610a6f4e59 50 1. Copy the binary file to the mbed device.
martinsimpson 0:24610a6f4e59 51 1. Press the reset button to start the program.
martinsimpson 0:24610a6f4e59 52
martinsimpson 0:24610a6f4e59 53 The LED on your platform turns on and off.
martinsimpson 0:24610a6f4e59 54
martinsimpson 0:24610a6f4e59 55 ## Export the project to Keil MDK, and debug your application
martinsimpson 0:24610a6f4e59 56
martinsimpson 0:24610a6f4e59 57 From the command-line, run the following command:
martinsimpson 0:24610a6f4e59 58
martinsimpson 0:24610a6f4e59 59 ```
martinsimpson 0:24610a6f4e59 60 mbed export -m K64F -i uvision
martinsimpson 0:24610a6f4e59 61 ```
martinsimpson 0:24610a6f4e59 62
martinsimpson 0:24610a6f4e59 63 To debug the application:
martinsimpson 0:24610a6f4e59 64
martinsimpson 0:24610a6f4e59 65 1. Start uVision.
martinsimpson 0:24610a6f4e59 66 1. Import the uVision project generated earlier.
martinsimpson 0:24610a6f4e59 67 1. Compile your application, and generate an `.axf` file.
martinsimpson 0:24610a6f4e59 68 1. Make sure uVision is configured to debug over CMSIS-DAP (From the Project menu > Options for Target '...' > Debug tab > Use CMSIS-DAP Debugger).
martinsimpson 0:24610a6f4e59 69 1. Set breakpoints, and start a debug session.
martinsimpson 0:24610a6f4e59 70
martinsimpson 0:24610a6f4e59 71 ![Image of uVision](img/uvision.png)
martinsimpson 0:24610a6f4e59 72
martinsimpson 0:24610a6f4e59 73 ## Troubleshooting
martinsimpson 0:24610a6f4e59 74
martinsimpson 0:24610a6f4e59 75 1. Make sure `mbed-cli` is working correctly and its version is `>1.0.0`
martinsimpson 0:24610a6f4e59 76
martinsimpson 0:24610a6f4e59 77 ```
martinsimpson 0:24610a6f4e59 78 mbed --version
martinsimpson 0:24610a6f4e59 79 ```
martinsimpson 0:24610a6f4e59 80
martinsimpson 0:24610a6f4e59 81 If not, you can update it:
martinsimpson 0:24610a6f4e59 82
martinsimpson 0:24610a6f4e59 83 ```
martinsimpson 0:24610a6f4e59 84 pip install mbed-cli --upgrade
martinsimpson 0:24610a6f4e59 85 ```
martinsimpson 0:24610a6f4e59 86
martinsimpson 0:24610a6f4e59 87 2. If using Keil MDK, make sure you have a license installed. [MDK-Lite](http://www.keil.com/arm/mdk.asp) has a 32 KB restriction on code size.