]> git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/docs/BUILDING.md
Merge commit '1fe4406f374291ab2e86e95a97341fd9c475fcb8'
[tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / docs / BUILDING.md
1 # Mbed SDK build script environment
2 ## Introduction
3 Mbed test framework allows users to test their mbed devices’ applications, build mbed SDK library, re-run tests, run mbed SDK regression, add new tests and get all this results automatically. Everything is done on your machine so you have a full control over compilation, and tests you run.
4
5 It's is using Python 2.7 programming language to drive all tests so make sure Python 2.7 is installed on your system and included in your system PATH. To compile mbed SDK and tests you will need one or more supported compilers installed on your system.
6
7 To follow this short introduction you should already:
8 * Know what mbed SDK is in general.
9 * Know how to install Python 2.7, ARM target cross compilers.
10 * You have C/C++ programming experience and at least willingness to learn a bit about Python.
11
12 ## Test automation
13 Currently our simple test framework allows users to run tests on their machines (hosts) in a fully automated manner. All you need to do is to prepare two configuration files.
14
15 ## Test automation limitations
16 Note that for tests which require connected external peripherals, for example Ethernet, SD flash cards, external EEPROM tests, loops etc. you need to:
17
18 * Modify test source code to match components' pin names to actual mbed board pins where peripheral is connected or
19 * Wire your board the same way test defines it.
20
21 ## Prerequisites
22 mbed test suite and build scripts are Python 2.7 applications and require Python 2.7 runtime environment and [setuptools](https://pythonhosted.org/an_example_pypi_project/setuptools.html) to install dependencies.
23
24 What we need:
25 * Installed [Python 2.7](https://www.python.org/download/releases/2.7) programming language.
26 * Installed [setuptools](https://pythonhosted.org/an_example_pypi_project/setuptools.html#installing-setuptools-and-easy-install)
27 * Optionally you can install [pip](https://pip.pypa.io/en/latest/installing.html) which is the PyPA recommended tool for installing Python packages from command line.
28
29 mbed SDK in its repo root directory specifies ```setup.py``` file which holds information about all packages which are dependencies for it. Bear in mind only few simple steps are required to install all dependencies.
30
31 First, clone mbed SDK repo and go to mbed SDk repo's directory:
32 ```
33 $ git clone https://github.com/mbedmicro/mbed.git
34 $ cd mbed
35 ```
36
37 Second, invoke ```setup.py``` so ```setuptools``` can install mbed SDK's dependencies (external Python modules required by mbed SDK):
38 ```
39 $ python setup.py install
40 ```
41 or
42 ```
43 $ sudo python setup.py install
44 ```
45 when your system requires administrator rights to install new Python packages.
46
47 ## Prerequisites (manual Python package dependency installation)
48 **Please only read this chapter if you had problems installing mbed SDK dependencies to Python packages**.
49
50 Below you can find the list of mbed SDK dependencies to Python modules with instructions how to install them manually.
51
52 You can skip this part if you've already install [Python 2.7](https://www.python.org/download/releases/2.7) and [setuptools](https://pythonhosted.org/an_example_pypi_project/setuptools.html) and successfully [installed all dependencies](#prerequisites).
53
54 * Please make sure you've installed [pip](https://pip.pypa.io/en/latest/installing.html) or [easy_install](https://pythonhosted.org/setuptools/easy_install.html#installing-easy-install)
55 Note: Easy Install is a python module (easy_install) bundled with [setuptools](https://pythonhosted.org/an_example_pypi_project/setuptools.html#installing-setuptools-and-easy-install) that lets you automatically download, build, install, and manage Python packages.
56
57 * Installed [pySerial](https://pypi.python.org/pypi/pyserial) module for Python 2.7.
58 pySerial can be installed from PyPI, either manually downloading the files and installing as described below or using:
59 ```
60 $ pip install pyserial
61 ```
62 or:
63 ```
64 easy_install -U pyserial
65 ```
66 * Installed [prettytable](https://code.google.com/p/prettytable/wiki/Installation) module for Python 2.7.
67 prettytable can be installed from PyPI, either manually downloading the files and installing as described below or using:
68 ```
69 $ pip install prettytable
70 ```
71 * Installed [IntelHex](https://pypi.python.org/pypi/IntelHex) module.
72 IntelHex may be downloaded from https://launchpad.net/intelhex/+download or http://www.bialix.com/intelhex/.
73 Assuming Python is properly installed on your platform, installation should just require running the following command from the root directory of the archive:
74 ```
75 sudo python setup.py install
76 ```
77 This will install the intelhex package into your system’s site-packages directory. After that is done, any other Python scripts or modules should be able to import the package using:
78 ```
79 $ python
80 Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32
81 Type "help", "copyright", "credits" or "license" for more information.
82 >>> from intelhex import IntelHex
83 >>>
84 ```
85 * You can check if you have correctly installed the above modules (or you already have them) by starting Python and importing both modules.
86 ```
87 $ python
88 Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32
89 Type "help", "copyright", "credits" or "license" for more information.
90 >>> import serial
91 >>> import prettytable
92 >>> from intelhex import IntelHex
93 >>>
94 ```
95 * Installed Git open source distributed version control system.
96 * Installed at least one of the supported by Mbed SDK workspace tools compilers:
97
98 Compiler | Mbed SDK Abbreviation | Example Version
99 -----------------------|-----------------------|-----------
100 Keil ARM Compiler | ARM, uARM | ARM C/C++ Compiler, 5.03 [Build 117]
101 GCC ARM | GCC_ARM | gcc version 4.8.3 20131129 (release)
102 GCC CodeSourcery | GCC_CS | gcc version 4.8.1 (Sourcery CodeBench Lite 2013.11-24)
103 GCC CodeRed | GCC_CR | gcc version 4.6.2 20121016 (release)
104 IAR Embedded Workbench | IAR | IAR ANSI C/C++ Compiler V6.70.1.5641/W32 for ARM
105
106 * Mbed board. You can find list of supported platforms [here](https://mbed.org/platforms/).
107
108 ### Getting Mbed SDK sources with test suite
109 So you have already installed Python (with required modules) together with at least one supported compiler you will use with your mbed board. Great!
110
111 Now let's go further and try to get Mbed SDK with test suite together. So let's clone latest Mbed SDK source code and configure path to our compiler(s) in next few steps.
112
113 * Open console and run command below to clone Mbed SDK repository hosted on [Github](https://github.com/mbedmicro/mbed).
114 ```
115 $ git clone https://github.com/mbedmicro/mbed.git
116 Cloning into 'mbed'...
117 remote: Counting objects: 37221, done.
118 remote: Compressing objects: 100% (3/3), done.
119 remote: Total 37221 (delta 0), reused 0 (delta 0), pack-reused 37218
120 Receiving objects: 100% (37221/37221), 20.38 MiB | 511.00 KiB/s, done.
121 Resolving deltas: 100% (24455/24455), done.
122 Checking connectivity... done.
123 Checking out files: 100% (3994/3994), done.
124 ```
125 * Now you can go to mbed directory you've just cloned and you can see root directory structure of our Mbed SDK library sources. Just type following commands:
126 ```
127 $ cd mbed
128 $ ls
129 LICENSE MANIFEST.in README.md libraries setup.py travis workspace_tools
130 ```
131 Directory structure we are interested in:
132 ```
133 mbed/workspace_tools/ - test suite scripts, build scripts etc.
134 mbed/library/tests/ - mbed SDK tests,
135 mbed/library/tests/mbed/ - tests for mbed SDK and peripherals tests,
136 mbed/library/tests/net/echo/ - tests for Ethernet interface,
137 mbed/library/tests/rtos/mbed/ - tests for RTOS.
138 ```
139
140 ### Workspace tools
141 Workspace tools are set of Python scripts used off-line by Mbed SDK team to:
142 * Compile and build mbed SDK,
143 * Compile and build libraries included in mbed SDK repo like e.g. ETH (Ethernet), USB, RTOS or CMSIS,
144 * Compile, build and run mbed SDK tests,
145 * Run test regression locally and in CI server,
146 * Get library, target, test configuration (paths, parameters, names etc.).
147
148 ### Configure workspace tools to work with your compilers
149 Before we can run our first test we need to configure our test environment a little!
150 Now we need to tell workspace tools where our compilers are.
151
152 * Please to go ```mbed/workspace_tools/``` directory and create empty file called ```private_settings.py```.
153 ```
154 $ touch private_settings.py
155 ```
156 * Populate this file the Python code below:
157 ```python
158 from os.path import join
159
160 # ARMCC
161 ARM_PATH = "C:/Work/toolchains/ARMCompiler_5.03_117_Windows"
162 ARM_BIN = join(ARM_PATH, "bin")
163 ARM_INC = join(ARM_PATH, "include")
164 ARM_LIB = join(ARM_PATH, "lib")
165
166 ARM_CPPLIB = join(ARM_LIB, "cpplib")
167 MY_ARM_CLIB = join(ARM_PATH, "lib", "microlib")
168
169 # GCC ARM
170 GCC_ARM_PATH = "C:/Work/toolchains/gcc_arm_4_8/4_8_2013q4/bin"
171
172 # GCC CodeSourcery
173 GCC_CS_PATH = "C:/Work/toolchains/Sourcery_CodeBench_Lite_for_ARM_EABI/bin"
174
175 # GCC CodeRed
176 GCC_CR_PATH = "C:/Work/toolchains/LPCXpresso_6.1.4_194/lpcxpresso/tools/bin"
177
178 # IAR
179 IAR_PATH = "C:/Work/toolchains/iar_6_5/arm"
180
181 SERVER_ADDRESS = "127.0.0.1"
182 LOCALHOST = "127.0.0.1"
183
184 # This is moved to separate JSON configuration file used by singletest.py
185 MUTs = {
186 }
187 ```
188
189 Note: You need to provide the absolute path to your compiler(s) installed on your host machine. Replace corresponding variable values with paths to compilers installed in your system:
190 * ```ARM_PATH``` for armcc compiler.
191 * ```GCC_ARM_PATH``` for GCC ARM compiler.
192 * ```GCC_CS_PATH``` for GCC CodeSourcery compiler.
193 * ```GCC_CR_PATH``` for GCC CodeRed compiler.
194 * ```IAR_PATH``` for IAR compiler.
195
196 If for example you do not use ```IAR``` compiler you do not have to modify anything. Workspace tools will use ```IAR_PATH`` variable only if you explicit ask for it from command line. So do not worry and replace only paths for your installed compilers.
197
198 Note: Because this is a Python script and ```ARM_PATH```, ```GCC_ARM_PATH```, ```GCC_CS_PATH```, ```GCC_CR_PATH```, ```IAR_PATH``` are Python string variables please use double backlash or single slash as path's directories delimiter to avoid incorrect path format. For example:
199 ```python
200 ARM_PATH = "C:/Work/toolchains/ARMCompiler_5.03_117_Windows"
201 GCC_ARM_PATH = "C:/Work/toolchains/gcc_arm_4_8/4_8_2013q4/bin"
202 GCC_CS_PATH = "C:/Work/toolchains/Sourcery_CodeBench_Lite_for_ARM_EABI/bin"
203 GCC_CR_PATH = "C:/Work/toolchains/LPCXpresso_6.1.4_194/lpcxpresso/tools/bin"
204 IAR_PATH = "C:/Work/toolchains/iar_6_5/arm"
205 ```
206
207 Note: Settings in ```private_settings.py``` will overwrite variables with default values in ```mbed/workspace_tools/settings.py``` file.
208
209 ## Build Mbed SDK library from sources
210 Let's build mbed SDK library off-line from sources using your compiler. We've already cloned mbed SDK sources, we've also installed compilers and added their paths to ```private_settings.py```.
211 We now should be ready to use workspace tools script ```build.py``` to compile and build mbed SDK from sources.
212
213 We are still using console. You should be already in ```mbed/workspace_tools/``` directory if not go to ```mbed/workspace_tools/``` and type below command:
214 ```
215 $ python build.py -m LPC1768 -t ARM
216 ```
217 or if you want to take advantage from multi-threaded compilation please use option ```-j X``` where ```X``` is number of cores you want to use to compile mbed SDK. See below:
218 ```
219 $ python build.py -m LPC1768 -t ARM -j 4
220 Building library CMSIS (LPC1768, ARM)
221 Copy: core_ca9.h
222 Copy: core_caFunc.h
223 ...
224 Compile: us_ticker_api.c
225 Compile: wait_api.c
226 Library: mbed.ar
227 Creating archive 'C:\temp\x\mbed\build\mbed\TARGET_LPC1768\TOOLCHAIN_ARM_STD\mbed.ar'
228 Copy: board.o
229 Copy: retarget.o
230
231 Completed in: (42.58)s
232
233 Build successes:
234 * ARM::LPC1768
235 ```
236 Above command will build mbed SDK for [LPC1768](http://developer.mbed.org/platforms/mbed-LPC1768/) platform using ARM compiler.
237
238 Let's have a look at directory structure under ```mbed/build/```. We can see for ```LPC1768``` new directory ```TARGET_LPC1768``` was created. This directory contains all build primitives.
239 Directory ```mbed/TARGET_LPC1768/TOOLCHAIN_ARM_STD/``` conteins mbed SDK library ```mbed.ar```. This directory structure also stores all needed headers which you should use with ```mbed.ar``` when building your own software.
240 ```
241 $ tree ./mbed/build/
242 Folder PATH listing
243 Volume serial number is 006C006F 6243:3EA9
244 ./MBED/BUILD
245 +---mbed
246 +---.temp
247 ¦ +---TARGET_LPC1768
248 ¦ +---TOOLCHAIN_ARM_STD
249 ¦ +---TARGET_NXP
250 ¦ +---TARGET_LPC176X
251 ¦ +---TOOLCHAIN_ARM_STD
252 +---TARGET_LPC1768
253 +---TARGET_NXP
254 ¦ +---TARGET_LPC176X
255 ¦ +---TARGET_MBED_LPC1768
256 +---TOOLCHAIN_ARM_STD
257 ```
258
259 Note: Why ```LCP1768```? For this example we are using ```LPC1768``` because this platform supports all compilers so you are sure you only need to specify proper compiler.
260
261 If you are not using ARM Compiler replace ```ARM``` with your compiler nickname: ```GCC_ARM```, ```GCC_CS```, ```GCC_CR``` or ```IAR```. For example if you are using IAR type command:
262 ```
263 $ python build.py -m LPC1768 -t IAR
264 ```
265
266 Note: Workspace tools track changes in source code. So if for example mbed SDK or test source code changes ```build.py``` script will recompile project with all dependencies. If there are no changes in code consecutive mbed SDK re-builds using build.py will not rebuild project if this is not necessary. Try to run last command once again, we can see script ```build.py``` will not recompile project (there are no changes):
267 ```
268 $ python build.py -m LPC1768 -t ARM
269 Building library CMSIS (LPC1768, ARM)
270 Building library MBED (LPC1768, ARM)
271
272 Completed in: (0.15)s
273
274 Build successes:
275 * ARM::LPC1768
276 ```
277
278 ### build.py script
279
280 Build script located in mbed/workspace_tools/ is our core script solution to drive compilation, linking and building process for:
281
282 * mbed SDK (with libs like Ethernet, RTOS, USB, USB host).
283 * Tests which also can be linked with libraries like RTOS or Ethernet.
284
285 Note: Test suite also uses the same build script, inheriting the same properties like auto dependency tracking and project rebuild in case of source code changes.
286
287 Build.py script is a powerful tool to build mbed SDK for all available platforms using all supported by mbed cross-compilers. Script is using our workspace tools build API to create desired platform-compiler builds. Use script option ```--h``` (help) to check all script parameters.
288 ```
289 $ python build.py --help
290 ```
291
292 * The command line parameter ```-m``` specifies the MCUs/platforms for which you want to build the mbed SDK. More than one MCU(s)/platform(s) may be specified with this parameter using comma as delimiter.
293 Example for one platform build:
294 ```
295 $ python build.py -m LPC1768 -t ARM
296 ```
297 or for many platforms:
298 ```
299 $ python build.py -m LPC1768,NUCLEO_L152RE -t ARM
300 ```
301
302 * Parameter ```-t``` defined which toolchain should be used for mbed SDK build. You can build Mbed SDK for multiple toolchains using one command.
303 Below example (note there is no space after commas) will compile mbed SDK for Freescale Freedom KL25Z platform using ARM and GCC_ARM compilers:
304 ```
305 $ python build.py -m KL25Z -t ARM,GCC_ARM
306 ```
307
308 * You can combine this technique to compile multiple targets with multiple compilers.
309 Below example will compile mbed SDK for Freescale's KL25Z and KL46Z platforms using ARM and GCC_ARM compilers:
310 ```
311 $ python build.py -m KL25Z,KL46Z -t ARM,GCC_ARM
312 ```
313
314 * Building libraries included in mbed SDK's source code. Parameters ```-r```, ```-e```, ```-u```, ```-U```, ```-d```, ```-b``` will add ```RTOS```, ```Ethernet```, ```USB```, ```USB Host```, ```DSP```, ```U-Blox``` libraries respectively.
315 Below example will build Mbed SDK library for for NXP LPC1768 platform together with RTOS (```-r``` switch) and Ethernet (```-e``` switch) libraries.
316 ```
317 $ python build.py -m LPC1768 -t ARM -r -e
318 Building library CMSIS (LPC1768, ARM)
319 Building library MBED (LPC1768, ARM)
320 Building library RTX (LPC1768, ARM)
321 Building library RTOS (LPC1768, ARM)
322 Building library ETH (LPC1768, ARM)
323
324 Completed in: (0.48)s
325
326 Build successes:
327 * ARM::LPC1768
328 ```
329
330 * If you’re unsure which platforms and toolchains are supported please use switch ```-S``` to print simple matrix of platform to compiler dependencies.
331 ```
332 $ python python build.py -S
333 +-------------------------+-----------+-----------+-----------+-----------+-----------+-----------+------------+---------------+
334 | Platform | ARM | uARM | GCC_ARM | IAR | GCC_CR | GCC_CS | GCC_CW_EWL | GCC_CW_NEWLIB |
335 +-------------------------+-----------+-----------+-----------+-----------+-----------+-----------+------------+---------------+
336 | APPNEARME_MICRONFCBOARD | Supported | Default | Supported | - | - | - | - | - |
337 | ARCH_BLE | Default | - | Supported | Supported | - | - | - | - |
338 | ARCH_GPRS | Supported | Default | Supported | Supported | Supported | - | - | - |
339 ...
340 | UBLOX_C029 | Supported | Default | Supported | Supported | - | - | - | - |
341 | WALLBOT_BLE | Default | - | Supported | Supported | - | - | - | - |
342 | XADOW_M0 | Supported | Default | Supported | Supported | Supported | - | - | - |
343 +-------------------------+-----------+-----------+-----------+-----------+-----------+-----------+------------+---------------+
344 *Default - default on-line compiler
345 *Supported - supported off-line compiler
346
347 Total platforms: 90
348 Total permutations: 297
349 ```
350
351 Above list can be overwhelming so please do not hesitate to use switch ```-f``` to filter ```Platform``` column.
352 ```
353 $ python build.py -S -f ^K
354 +--------------+-----------+---------+-----------+-----------+--------+--------+------------+---------------+
355 | Platform | ARM | uARM | GCC_ARM | IAR | GCC_CR | GCC_CS | GCC_CW_EWL | GCC_CW_NEWLIB |
356 +--------------+-----------+---------+-----------+-----------+--------+--------+------------+---------------+
357 | K20D50M | Default | - | Supported | Supported | - | - | - | - |
358 | K22F | Default | - | Supported | Supported | - | - | - | - |
359 | K64F | Default | - | Supported | Supported | - | - | - | - |
360 | KL05Z | Supported | Default | Supported | Supported | - | - | - | - |
361 | KL25Z | Default | - | Supported | Supported | - | - | Supported | Supported |
362 | KL43Z | Default | - | Supported | - | - | - | - | - |
363 | KL46Z | Default | - | Supported | Supported | - | - | - | - |
364 | NRF51_DK | Default | - | Supported | Supported | - | - | - | - |
365 | NRF51_DK_OTA | Default | - | Supported | - | - | - | - | - |
366 +--------------+-----------+---------+-----------+-----------+--------+--------+------------+---------------+
367 *Default - default on-line compiler
368 *Supported - supported off-line compiler
369
370 Total platforms: 9
371 Total permutations: 28
372 ```
373 or just give platform name:
374 ```
375 $ python build.py -S -f LPC1768
376 +----------+---------+-----------+-----------+-----------+-----------+-----------+------------+---------------+
377 | Platform | ARM | uARM | GCC_ARM | IAR | GCC_CR | GCC_CS | GCC_CW_EWL | GCC_CW_NEWLIB |
378 +----------+---------+-----------+-----------+-----------+-----------+-----------+------------+---------------+
379 | LPC1768 | Default | Supported | Supported | Supported | Supported | Supported | - | - |
380 +----------+---------+-----------+-----------+-----------+-----------+-----------+------------+---------------+
381 *Default - default on-line compiler
382 *Supported - supported off-line compiler
383
384 Total platforms: 1
385 Total permutations: 6
386 ```
387
388 * You can be more verbose ```-v``` especially if you want to see each compilation / linking command build.py is executing:
389 ```
390 $ python build.py -t GCC_ARM -m LPC1768 -j 8 -v
391 Building library CMSIS (LPC1768, GCC_ARM)
392 Copy: LPC1768.ld
393 Compile: startup_LPC17xx.s
394 [DEBUG] Command: C:/Work/toolchains/gcc_arm_4_8/4_8_2013q4/bin\arm-none-eabi-gcc
395 -x assembler-with-cpp -c -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers
396 -fmessage-length=0 -fno-exceptions -fno-builtin -ffunction-sections -fdata-sections -MMD
397 -fno-delete-null-pointer-checks -fomit-frame-pointer -mcpu=cortex-m3 -mthumb -O2
398 -DTARGET_LPC1768 -DTARGET_M3 -DTARGET_CORTEX_M -DTARGET_NXP -DTARGET_LPC176X
399 -DTARGET_MBED_LPC1768 -DTOOLCHAIN_GCC_ARM -DTOOLCHAIN_GCC -D__CORTEX_M3 -DARM_MATH_CM3
400 -DMBED_BUILD_TIMESTAMP=1424903604.77 -D__MBED__=1 -IC:\Work\mbed\libraries\mbed\targets\cmsis
401 -IC:\Work\mbed\libraries\mbed\targets\cmsis\TARGET_NXP
402 -IC:\Work\mbed\libraries\mbed\targets\cmsis\TARGET_NXP\TARGET_LPC176X -IC:\Work\mbed\libraries\mbed\targets\cmsis\TARGET_NXP\TARGET_LPC176X\TOOLCHAIN_GCC_ARM
403 -o C:\Work\mbed\build\mbed\.temp\TARGET_LPC1768\TOOLCHAIN_GCC_ARM\TARGET_NXP\TARGET_LPC176X\TOOLCHAIN_GCC_ARM\startup_LPC17xx.o
404 C:\Work\mbed\libraries\mbed\targets\cmsis\TARGET_NXP\TARGET_LPC176X\TOOLCHAIN_GCC_ARM\startup_LPC17xx.s
405 [DEBUG] Return: 0
406 ...
407 ```
408
409 ## CppUCheck analysis
410 [Cppcheck](http://cppcheck.sourceforge.net/) is a static analysis tool for C/C++ code. Unlike C/C++ compilers and many other analysis tools it does not detect syntax errors in the code. Cppcheck primarily detects the types of bugs that the compilers normally do not detect. The goal is to detect only real errors in the code (i.e. have zero false positives).
411
412 Prerequisites:
413 * Please install ```CppCheck``` on your system before you want to use it with build scripts.
414 * You should also add Cppcheck to your system path.
415
416 ```build.py``` script supports switching between compilation and building and just static code analysis testing. You can use switch ```--cppcheck``` to perform CppCheck static code analysis.
417
418 * When you are using --cppcheck switch all macros, toolchain dependencies etc. are preserved so you are sure you are checking exactly the same code you would compile for your application.
419
420 * Cppcheck analysis can take up to few minutes on slower machines.
421
422 * Usually you will use switches ```-t``` and ```-m``` to define toolchain and MCU (platform) respectively. You should do the same in case of CppCheck analysis. Please note that build script can also compile and build RTOS, Ethernet library etc. If you want to check those just use corresponding build script switches (e.g. ```-r```, ```-e```, ...).
423
424 Example:
425 ```
426 $ python build.py -t uARM -m NUCLEO_F334R8 --cppcheck
427 ```
428
429 # make.py script
430 ```make.pt``` is a ```mbed/workspace_tools/``` script used to build tests (we call them sometimes 'programs') one by one manually. Script allows you to flash board with test and execute it. This is deprecated functionality and will not be described here. Instead please use ```singletest.py``` file to build mbed SDK, tests and run automation for test cases included in ```mbedmicro/mbed```.
431 Note: ```make.py``` script depends on existing already built mked SDK and library sources so you need to pre-build mbed SDK and for example RTOS library to link 'program' (test) with mebd SDK and RTOS library. To pre-build mbed SDK please use ```build.py``` script.
432
433 Just for sake of example please see few ways to use ```make.py``` together with Freedom K64F board.
434
435 * We need to build mbed SDK (in directory ```mbed/build/```:
436 ```
437 $ python build.py -t GCC_ARM -m K64F -j 8
438 Building library CMSIS (K64F, GCC_ARM)
439 Building library MBED (K64F, GCC_ARM)
440
441 Completed in: (0.59)s
442
443 Build successes:
444 * GCC_ARM::K64F
445 ```
446 * We can print all 'programs' (test cases) ```make.py``` can build for us:
447 ```
448 $ python make.py
449 .
450 [ 0] MBED_A1: Basic
451 [ 1] MBED_A2: Semihost file system
452 [ 2] MBED_A3: C++ STL
453 [ 3] MBED_A4: I2C TMP102
454 .
455 ```
456 For example 'program' under index ```2``` is ```MBED_A3``` test case we can build and flash onto K64F board.
457 * Building test with ```make.py``` by specifying test case name with ```-n``` option:
458 ```
459 $ python make.py -t GCC_ARM -m K64F -n MBED_A3
460 Building project STL (K64F, GCC_ARM)
461 Compile: main.cpp
462 [Warning] main.cpp@76: In function 'int main()': deprecated conversion from string constant to 'char*' [-Wwrite-strings]
463 .
464 .
465 .
466 [Warning] main.cpp@76: In function 'int main()': deprecated conversion from string constant to 'char*' [-Wwrite-strings]
467 Compile: test_env.cpp
468 Link: stl
469 Elf2Bin: stl
470 Image: C:\Work\mbed\build\test\K64F\GCC_ARM\MBED_A3\stl.bin
471 ```
472 Because we previously have built mbed SDK we are now able to drive test case compilation and linking with mbed SDK and produce ```MBED_A3``` test case binary in build directory:
473 ```
474 C:\Work\mbed\build\test\K64F\GCC_ARM\MBED_A3\stl.bin
475 ```
476
477 For more help type ```$ python make.py --help``` in your command line.
478
479 # project.py script
480 ```project.py``` script is used to export test cases ('programs') from test case portfolio to off-line IDE. This is a easy way to export test project to IDEs such as:
481 * codesourcery.
482 * coide.
483 * ds5_5.
484 * emblocks.
485 * gcc_arm.
486 * iar.
487 * kds.
488 * lpcxpresso.
489 * uvision.
490
491 You can export project using command line. All you need to do is to specify mbed platform name (option ```-m```), your IDE (option ```-i```) and project name you want to export (option ```-n``` or (option ```-p```).
492
493 In below example we export our project so we can work on it using GCC ARM cross-compiler. Building mechanism used to drive exported build will be ```Make```.
494 ```
495 $ python project.py -m K64F -n MBED_A3 -i gcc_arm
496 Copy: test_env.h
497 Copy: AnalogIn.h
498 Copy: AnalogOut.h
499 .
500 .
501 .
502 Copy: K64FN1M0xxx12.ld
503 Copy: main.cpp
504
505 Successful exports:
506 * K64F::gcc_arm C:\Work\mbed\build\export\MBED_A3_gcc_arm_K64F.zip
507 ```
508 You can see exporter placed compressed project export in ```zip``` file in ```mbed/build/export/``` directory.
509
510 Example export file ```MBED_A3_gcc_arm_K64F.zip``` structure:
511 ```
512 MBED_A3
513 ├───env
514 └───mbed
515 ├───api
516 ├───common
517 ├───hal
518 └───targets
519 ├───cmsis
520 │ └───TARGET_Freescale
521 │ └───TARGET_MCU_K64F
522 │ └───TOOLCHAIN_GCC_ARM
523 └───hal
524 └───TARGET_Freescale
525 └───TARGET_KPSDK_MCUS
526 ├───TARGET_KPSDK_CODE
527 │ ├───common
528 │ │ └───phyksz8081
529 │ ├───drivers
530 │ │ ├───clock
531 │ │ ├───enet
532 │ │ │ └───src
533 │ │ ├───interrupt
534 │ │ └───pit
535 │ │ ├───common
536 │ │ └───src
537 │ ├───hal
538 │ │ ├───adc
539 │ │ ├───can
540 │ │ ├───dac
541 │ │ ├───dmamux
542 │ │ ├───dspi
543 │ │ ├───edma
544 │ │ ├───enet
545 │ │ ├───flextimer
546 │ │ ├───gpio
547 │ │ ├───i2c
548 │ │ ├───llwu
549 │ │ ├───lptmr
550 │ │ ├───lpuart
551 │ │ ├───mcg
552 │ │ ├───mpu
553 │ │ ├───osc
554 │ │ ├───pdb
555 │ │ ├───pit
556 │ │ ├───pmc
557 │ │ ├───port
558 │ │ ├───rcm
559 │ │ ├───rtc
560 │ │ ├───sai
561 │ │ ├───sdhc
562 │ │ ├───sim
563 │ │ ├───smc
564 │ │ ├───uart
565 │ │ └───wdog
566 │ └───utilities
567 │ └───src
568 └───TARGET_MCU_K64F
569 ├───device
570 │ ├───device
571 │ │ └───MK64F12
572 │ └───MK64F12
573 ├───MK64F12
574 └───TARGET_FRDM
575 ```
576
577 After unpacking exporter ```zip``` file we can go to directory and see files inside MBED_A3 directory:
578 ```
579 $ ls
580 GettingStarted.htm Makefile env main.cpp mbed
581 ```
582 Exporter generated for us ```Makefile``` so now we can build our software:
583 ```
584 $ make -j 8
585 .
586 .
587 .
588 text data bss dec hex filename
589 29336 184 336 29856 74a0 MBED_A3.elf
590 ```
591
592 We can see root directory of exporter project is now populated with binary files:
593 * MBED_A3.bin.
594 * MBED_A3.elf .
595 * MBED_A3.hex.
596 You have also map file ```MBED_A3.map``` for your disposal.
597 ```
598 $ ls
599 GettingStarted.htm MBED_A3.bin MBED_A3.elf MBED_A3.hex MBED_A3.map Makefile env main.cpp main.d main.o mbed
600 ```
601
Imprint / Impressum