Course project for LE484 at Thammasat University, class of 2016

Committer:
vsupacha
Date:
Mon May 08 05:11:22 2017 +0000
Revision:
12:845639da2f03
Parent:
0:aefb68fd2505
Fix wrong code

Who changed what in which revision?

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