PMK 2018

Committer:
nenad
Date:
Fri May 11 15:42:03 2018 +0000
Revision:
0:9e3d8cb294c5
PMK2018;

Who changed what in which revision?

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