Let there be light.

Committer:
bcc6
Date:
Fri Feb 03 08:34:55 2017 +0000
Revision:
0:2a941acd6108
Blinky LED HelloWorld

Who changed what in which revision?

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