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