mbed Workshops
/
Workshop-1-Example-3
A threaded blinky implementation.
README.md@0:04fa7fb0681e, 2016-09-26 (annotated)
- Committer:
- sarahmarshy
- Date:
- Mon Sep 26 16:14:45 2016 +0000
- Revision:
- 0:04fa7fb0681e
Initial commit. Threaded blinky.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sarahmarshy | 0:04fa7fb0681e | 1 | # Getting started with Blinky on mbed OS |
sarahmarshy | 0:04fa7fb0681e | 2 | |
sarahmarshy | 0:04fa7fb0681e | 3 | This is a very simple guide, reviewing the steps required to get Blinky working on an mbed OS platform. |
sarahmarshy | 0:04fa7fb0681e | 4 | |
sarahmarshy | 0:04fa7fb0681e | 5 | Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli). |
sarahmarshy | 0:04fa7fb0681e | 6 | |
sarahmarshy | 0:04fa7fb0681e | 7 | ## Get the example application! |
sarahmarshy | 0:04fa7fb0681e | 8 | |
sarahmarshy | 0:04fa7fb0681e | 9 | From the command line, import the example: |
sarahmarshy | 0:04fa7fb0681e | 10 | |
sarahmarshy | 0:04fa7fb0681e | 11 | ``` |
sarahmarshy | 0:04fa7fb0681e | 12 | mbed import mbed-os-example-blinky |
sarahmarshy | 0:04fa7fb0681e | 13 | cd mbed-os-example-blinky |
sarahmarshy | 0:04fa7fb0681e | 14 | ``` |
sarahmarshy | 0:04fa7fb0681e | 15 | |
sarahmarshy | 0:04fa7fb0681e | 16 | ### Now compile |
sarahmarshy | 0:04fa7fb0681e | 17 | |
sarahmarshy | 0:04fa7fb0681e | 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: |
sarahmarshy | 0:04fa7fb0681e | 19 | |
sarahmarshy | 0:04fa7fb0681e | 20 | ``` |
sarahmarshy | 0:04fa7fb0681e | 21 | mbed compile -m K64F -t ARM |
sarahmarshy | 0:04fa7fb0681e | 22 | ``` |
sarahmarshy | 0:04fa7fb0681e | 23 | |
sarahmarshy | 0:04fa7fb0681e | 24 | Your PC may take a few minutes to compile your code. At the end you should get the following result: |
sarahmarshy | 0:04fa7fb0681e | 25 | |
sarahmarshy | 0:04fa7fb0681e | 26 | ``` |
sarahmarshy | 0:04fa7fb0681e | 27 | [snip] |
sarahmarshy | 0:04fa7fb0681e | 28 | +----------------------------+-------+-------+------+ |
sarahmarshy | 0:04fa7fb0681e | 29 | | Module | .text | .data | .bss | |
sarahmarshy | 0:04fa7fb0681e | 30 | +----------------------------+-------+-------+------+ |
sarahmarshy | 0:04fa7fb0681e | 31 | | Misc | 13939 | 24 | 1372 | |
sarahmarshy | 0:04fa7fb0681e | 32 | | core/hal | 16993 | 96 | 296 | |
sarahmarshy | 0:04fa7fb0681e | 33 | | core/rtos | 7384 | 92 | 4204 | |
sarahmarshy | 0:04fa7fb0681e | 34 | | features/FEATURE_IPV4 | 80 | 0 | 176 | |
sarahmarshy | 0:04fa7fb0681e | 35 | | frameworks/greentea-client | 1830 | 60 | 44 | |
sarahmarshy | 0:04fa7fb0681e | 36 | | frameworks/utest | 2392 | 512 | 292 | |
sarahmarshy | 0:04fa7fb0681e | 37 | | Subtotals | 42618 | 784 | 6384 | |
sarahmarshy | 0:04fa7fb0681e | 38 | +----------------------------+-------+-------+------+ |
sarahmarshy | 0:04fa7fb0681e | 39 | Allocated Heap: unknown |
sarahmarshy | 0:04fa7fb0681e | 40 | Allocated Stack: unknown |
sarahmarshy | 0:04fa7fb0681e | 41 | Total Static RAM memory (data + bss): 7168 bytes |
sarahmarshy | 0:04fa7fb0681e | 42 | Total RAM memory (data + bss + heap + stack): 7168 bytes |
sarahmarshy | 0:04fa7fb0681e | 43 | Total Flash memory (text + data + misc): 43402 bytes |
sarahmarshy | 0:04fa7fb0681e | 44 | Image: .\.build\K64F\ARM\mbed-os-example-blinky.bin |
sarahmarshy | 0:04fa7fb0681e | 45 | ``` |
sarahmarshy | 0:04fa7fb0681e | 46 | |
sarahmarshy | 0:04fa7fb0681e | 47 | ### Program your board |
sarahmarshy | 0:04fa7fb0681e | 48 | |
sarahmarshy | 0:04fa7fb0681e | 49 | 1. Connect your mbed device to the computer over USB. |
sarahmarshy | 0:04fa7fb0681e | 50 | 1. Copy the binary file to the mbed device . |
sarahmarshy | 0:04fa7fb0681e | 51 | 1. Press the reset button to start the program. |
sarahmarshy | 0:04fa7fb0681e | 52 | |
sarahmarshy | 0:04fa7fb0681e | 53 | You should see the LED of your platform turning on and off. |
sarahmarshy | 0:04fa7fb0681e | 54 | |
sarahmarshy | 0:04fa7fb0681e | 55 | Congratulations if you managed to complete this test! |
sarahmarshy | 0:04fa7fb0681e | 56 | |
sarahmarshy | 0:04fa7fb0681e | 57 | ## Export the project to Keil MDK and debug your application |
sarahmarshy | 0:04fa7fb0681e | 58 | |
sarahmarshy | 0:04fa7fb0681e | 59 | From the command line, run the following command: |
sarahmarshy | 0:04fa7fb0681e | 60 | |
sarahmarshy | 0:04fa7fb0681e | 61 | ``` |
sarahmarshy | 0:04fa7fb0681e | 62 | mbed export -m K64F -i uvision |
sarahmarshy | 0:04fa7fb0681e | 63 | ``` |
sarahmarshy | 0:04fa7fb0681e | 64 | |
sarahmarshy | 0:04fa7fb0681e | 65 | You should see the following output: |
sarahmarshy | 0:04fa7fb0681e | 66 | |
sarahmarshy | 0:04fa7fb0681e | 67 | ``` |
sarahmarshy | 0:04fa7fb0681e | 68 | Successful exports: |
sarahmarshy | 0:04fa7fb0681e | 69 | * K64F::uvision .\projectfiles\uvision_K64F\Unnamed_Project |
sarahmarshy | 0:04fa7fb0681e | 70 | ``` |
sarahmarshy | 0:04fa7fb0681e | 71 | |
sarahmarshy | 0:04fa7fb0681e | 72 | To debug the application: |
sarahmarshy | 0:04fa7fb0681e | 73 | |
sarahmarshy | 0:04fa7fb0681e | 74 | 1. Start uVision. |
sarahmarshy | 0:04fa7fb0681e | 75 | 1. Import the uVision project generated earlier. |
sarahmarshy | 0:04fa7fb0681e | 76 | 1. Compile your application and generate an `.axf` file. |
sarahmarshy | 0:04fa7fb0681e | 77 | 1. Make sure uVision is configured to debug over CMSIS-DAP (From the Project menu > Options for Target '...' > Debug tab > Use CMSIS-DAP Debugger). |
sarahmarshy | 0:04fa7fb0681e | 78 | 1. Set breakpoints and start a debug session. |
sarahmarshy | 0:04fa7fb0681e | 79 | |
sarahmarshy | 0:04fa7fb0681e | 80 | ![Image of uVision](img/uvision.png) |
sarahmarshy | 0:04fa7fb0681e | 81 | |
sarahmarshy | 0:04fa7fb0681e | 82 | ## Troubleshooting |
sarahmarshy | 0:04fa7fb0681e | 83 | |
sarahmarshy | 0:04fa7fb0681e | 84 | 1. Make sure `mbed-cli` is working correctly and its version is greater than `0.8.9` |
sarahmarshy | 0:04fa7fb0681e | 85 | |
sarahmarshy | 0:04fa7fb0681e | 86 | ``` |
sarahmarshy | 0:04fa7fb0681e | 87 | mbed --version |
sarahmarshy | 0:04fa7fb0681e | 88 | ``` |
sarahmarshy | 0:04fa7fb0681e | 89 | |
sarahmarshy | 0:04fa7fb0681e | 90 | If not, you can update it easily: |
sarahmarshy | 0:04fa7fb0681e | 91 | |
sarahmarshy | 0:04fa7fb0681e | 92 | ``` |
sarahmarshy | 0:04fa7fb0681e | 93 | pip install mbed-cli --upgrade |
sarahmarshy | 0:04fa7fb0681e | 94 | ``` |
sarahmarshy | 0:04fa7fb0681e | 95 | |
sarahmarshy | 0:04fa7fb0681e | 96 | 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. |