Skip to content

Commit 3cba0c0

Browse files
authored
Merge pull request #310 from screamerbg/0.9-polishing
mbed CLI 0.9.1
2 parents db86474 + 0d2507f commit 3cba0c0

File tree

4 files changed

+266
-154
lines changed

4 files changed

+266
-154
lines changed

README.md

Lines changed: 75 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ With this in mind, let's create a new program (we'll call it `mbed-os-program`):
131131

132132
```
133133
$ mbed new mbed-os-program
134+
[mbed] Creating new program "mbed-os-program" (git)
135+
[mbed] Adding library "mbed-os" from "https://github.com/ARMmbed/mbed-os" at latest revision in the current branch
136+
[mbed] Updating reference "mbed-os" -> "https://github.com/ARMmbed/mbed-os/#89962277c20729504d1d6c95250fbd36ea5f4a2d"
134137
```
135138

136139
This creates a new folder "mbed-os-program", initializes a new repository and imports the latest revision of the mbed-os dependency to your program tree.
@@ -142,23 +145,8 @@ Use `mbed ls` to list all the libraries imported to your program:
142145
```
143146
$ cd mbed-os-program
144147
$ mbed ls -a
145-
mbed-os-program (mbed-os-program#189949915b9c)
146-
`- mbed-os (0d5eb2b8cee8)
147-
|- core (737a7809f9e7)
148-
|- features\FEATURE_CLIENT\coap-service (7a11be1ccb07)
149-
|- features\FEATURE_CLIENT\mbed-client (a6a46726f027)
150-
|- features\FEATURE_CLIENT\mbed-client-c (086b9c97f65b)
151-
|- features\FEATURE_CLIENT\mbed-client-classic (c8ccada6b9ff)
152-
|- features\FEATURE_CLIENT\mbed-client-mbed-tls (b14e7b3303c8)
153-
|- features\FEATURE_CLIENT\mbed-client-randlib (80f5c491dd4d)
154-
|- features\FEATURE_IPV6\mbed-mesh-api (0e92921f3dce)
155-
|- features\FEATURE_IPV6\mbed-trace (e419c488f4f8)
156-
|- features\FEATURE_IPV6\nanostack-hal-mbed-cmsis-rtos (36968fc133c7)
157-
|- features\FEATURE_IPV6\nanostack-libservice (f61c845e0c59)
158-
|- features\FEATURE_IPV6\sal-stack-nanostack-eventloop (c163be9183b0)
159-
|- features\FEATURE_IPV6\sal-stack-nanostack-private (5d3365ce7df3)
160-
|- frameworks\greentea-client (d0cbb41ae793)
161-
`- frameworks\unity (14fd303f30f9)
148+
mbed-os-program (mbed-os-program)
149+
`- mbed-os (https://github.com/ARMmbed/mbed-os#89962277c207)
162150
```
163151

164152
<span class="notes">**Note**: If you want to start from an existing folder in your workspace, you can simply use `mbed new .`, which will initialize an mbed program, as well as a new Git or Mercurial repository in that folder. </span>
@@ -169,6 +157,12 @@ mbed CLI is also compatible with mbed OS 2 programs based on the [mbed library](
169157

170158
```
171159
$ mbed new mbed-classic-program --mbedlib
160+
[mbed] Creating new program "mbed-classic-program" (git)
161+
[mbed] Adding library "mbed" from "https://mbed.org/users/mbed_official/code/mbed/builds" at latest revision in the current branch
162+
[mbed] Downloading mbed library build "f9eeca106725" (might take a minute)
163+
[mbed] Unpacking mbed library build "f9eeca106725" in "D:\Work\examples\mbed-classic-program\mbed"
164+
[mbed] Updating reference "mbed" -> "https://mbed.org/users/mbed_official/code/mbed/builds/f9eeca106725"
165+
[mbed] Couldn't find build tools in your program. Downloading the mbed 2.0 SDK tools...
172166
```
173167
### Creating a new program without OS version selection
174168

@@ -180,13 +174,18 @@ Use `mbed import` to clone an existing program and all its dependencies to your
180174

181175
```
182176
$ mbed import https://github.com/ARMmbed/mbed-os-example-blinky
177+
[mbed] Importing program "mbed-os-example-blinky" from "https://github.com/ARMmbed/mbed-os-example-blinky" at latest revision in the current branch
178+
[mbed] Adding library "mbed-os" from "https://github.com/ARMmbed/mbed-os" at rev #dd36dc4228b5
183179
$ cd mbed-os-example-blinky
184180
```
185181

186182
mbed CLI also supports programs based on mbed OS 2, which are automatically detected and do not require additional options:
187183

188184
```
189-
$ mbed import https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-blinky/
185+
$ mbed import https://mbed.org/teams/mbed/code/mbed_blinky/
186+
[mbed] Importing program "mbed_blinky" from "https://mbed.org/teams/mbed/code/mbed_blinky" at latest revision in the current branch
187+
[mbed] Adding library "mbed" from "http://mbed.org/users/mbed_official/code/mbed/builds" at rev #f9eeca106725
188+
[mbed] Couldn't find build tools in your program. Downloading the mbed 2.0 SDK tools...
190189
$ cd mbed-os-example-blinky
191190
```
192191

@@ -208,10 +207,7 @@ If you have manually cloned a git repository into your workspace and you want to
208207

209208
```
210209
$ mbed deploy
211-
[mbed] Creating new program "test-prog" (git)
212-
[mbed] Adding library "mbed-os" from "https://github.com/ARMmbed/mbed-os/" at latest revision in the current branch
213-
[mbed] Adding library "mbed-os/core" from "https://github.com/mbedmicro/mbed/" at rev #b4bb088876cb72bda7006e423423aba4895d380c
214-
...
210+
[mbed] Adding library "mbed-os" from "https://github.com/ARMmbed/mbed-os" at rev #dd36dc4228b5
215211
```
216212

217213
Don't forget to set the current directory as the root of your program:
@@ -260,18 +256,50 @@ If at any point you decide that you don't need a library any more, you can use `
260256
```
261257
$ mbed remove text-lcd
262258
```
259+
263260
## Compiling code
264261

265262
### Toolchain selection
266263

267-
After importing a program or creating a new one, you need to tell mbed CLI where to find the toolchains that you want to use for compiling your source tree. mbed CLI gets this information from a file named `mbed_settings.py`, which is automatically created at the top of your cloned repository (if it doesn't already exist).
264+
After importing a program or creating a new one, you need to tell mbed CLI where to find the toolchains that you want to use for compiling your source tree.
268265

269-
Edit `mbed_settings.py` to set your toolchain:
266+
There are two ways to do this:
267+
* Through the mbed CLI configuration
268+
* Via mbed_settings.py file in the root of your program, which is automatically created (if it doesn't already exist).
269+
270+
#### Through mbed CLI configuration
271+
272+
You can set the ARM Compiler 5 location via the command:
273+
274+
```
275+
$ mbed config --global ARM_PATH "C:\Program Files\ARM"
276+
[mbed] C:\Program Files\ARM now set as global ARM_PATH
277+
```
278+
279+
The `-G` switch tells mbed CLI to set this as a global setting, rather than local for the current program.
280+
281+
Supported settings for toolchain paths are `ARM_PATH`, `GCC_ARM_PATH` and `IAR_PATH`
282+
283+
You can see the active mbed CLI configuration via:
284+
285+
```
286+
$ mbed config --list
287+
[mbed] Global config:
288+
ARM_PATH=C:\Program Files\ARM\armcc5.06
289+
IAR_PATH=C:\Program Files\IAR Workbench 7.0\arm
270290
271-
* If you want to use the [ARM Compiler toolchain](https://developer.arm.com/products/software-development-tools/compilers/arm-compiler-5/downloads), set `ARM_PATH` to the *base* directory of your ARM Compiler installation (example: c:\software\armcc5.06). The recommended version of the ARM Compiler toolchain is 5.06.
272-
* If you want to use the [GCC ARM Embedded toolchain](https://launchpad.net/gcc-arm-embedded), set `GCC_ARM_PATH` to the *binary* directory of your GCC ARM installation (example: c:\software\GNUToolsARMEmbedded\4.82013q4\bin). Use versions 4.8 or 4.9 of GCC ARM Embedded; version 5.0 or any version above might be incompatible with the tools.
291+
[mbed] Local config (D:\temp\mbed-os-program):
292+
No local configuration is set
293+
```
294+
295+
More information about mbed CLI configuration is available in the [configuration section](#mbed-cli-configuration) of this document.
296+
297+
#### Through mbed_settings.py
273298

274-
<span class="tips">**Tips:** You can set more than one toolchain, and select between them for each build, as explained below.</span>
299+
Edit `mbed_settings.py` to set your toolchain:
300+
301+
* If you want to use the [ARM Compiler toolchain](https://developer.arm.com/products/software-development-tools/compilers/arm-compiler-5/downloads), set `ARM_PATH` to the *base* directory of your ARM Compiler installation (example: C:\Program Files\ARM\armcc5.06). The recommended version of the ARM Compiler toolchain is 5.06.
302+
* If you want to use the [GCC ARM Embedded toolchain](https://launchpad.net/gcc-arm-embedded), set `GCC_ARM_PATH` to the *binary* directory of your GCC ARM installation (example: C:\Program Files\GNU Tools ARM Embedded\4.9 2015q2\bin). Use versions 4.9 of GCC ARM Embedded; version 5.0 or any version above might be incompatible with the tools.
275303

276304
As a rule, since `mbed_settings.py` contains local settings (possibly relevant only to a single OS on a single machine), it should not be versioned.
277305

@@ -315,6 +343,7 @@ The arguments for *compile* are:
315343
* `-t <TOOLCHAIN>` to select a toolchain (of those defined in `mbed_settings.py`, see above). The value can be either `ARM` (ARM Compiler 5), `GCC_ARM` (GNU ARM Embedded), or `IAR` (IAR Embedded Workbench for ARM).
316344
* `--source <SOURCE>` to select the source directory. The default is `.` (the current directorty). You can specify multiple source locations, even outside the program tree.
317345
* `--build <BUILD>` to select the build directory. Default: `.build/` inside your program.
346+
* `--options <OPTIONS>` to select compile options. Examples: "debug-info": will generate debugging information; "small-build" will use microlib/nanolib, but limit RTOS to single thread; "save-asm": will save the asm generated by the compiler
318347
* `--library` to compile the code as a [static .a/.ar library](#compiling-static-libraries).
319348
* `--config` to inspect the run-time compile configuration (see below).
320349
* `-S` or `--supported` shows a matrix of the supported targets and toolchains.
@@ -574,27 +603,14 @@ To push the changes in your local tree upstream, run `mbed publish`. `publish` w
574603
This is best explained by an example. Let's assume that the list of dependencies of your program (obtained by running `mbed ls`) looks like this:
575604

576605
```
577-
mbed-os-program (189949915b9c)
578-
`- mbed-os (e39199afa2da)
579-
|- frameworks/greentea-client (571cfef17dd0)
580-
|- frameworks/unity (7483099b9df1)
581-
|- core (d1ec4beabef3)
582-
|- mbedtls (bef26f687287)
583-
|- net/coap-service (eae41d1df943)
584-
|- net/mbed-client (5dc62d168aa4)
585-
|- net/mbed-client-c (ce64d6a0bdef)
586-
|- net/mbed-client-classic (abda3cef87f0)
587-
|- net/mbed-client-mbed-tls (8c436e5d1109)
588-
|- net/mbed-client-randlib (80f5c491dd4d)
589-
|- net/mbed-mesh-api (8187d3d275cc)
590-
|- net/mbed-trace (07ce2714915d)
591-
|- net/nanostack-hal-mbed-cmsis-rtos (023fd8906ce7)
592-
|- net/nanostack-libservice (f61c845e0c59)
593-
|- net/sal-stack-nanostack-eventloop (c163be9183b0)
594-
`- net/sal-stack-nanostack (cd18b5a50df4)
595-
```
596-
597-
Furthermore, let's assume that you make changes to `mbed-mesh-api`. `publish` detects the change on the leaf `mbed-mesh-api` dependency and asks you to commit it. Then it detects that `mbed-os` depends on `mbed-mesh-api`, updates the `mbed-os` dependency on `mbed-mesh-api` to its latest version (by updating the `mbed-mesh-api.lib` file inside `mbed-os/net/`) and asks you to commit it. This propagates up to `mbed-os` and finally to your program `mbed-os-program`.
606+
my-mbed-os-example (a5ac4bf2e468)
607+
|- mbed-os (5fea6e69ec1a)
608+
`- my-libs (e39199afa2da)
609+
|- my-libs/iot-client (571cfef17dd0)
610+
`- my-libs/test-framework (cd18b5a50df4)
611+
```
612+
613+
Let's assume that you make changes to `ot-client`. `publish` detects the change on the leaf `ot-client` dependency and asks you to commit it. Then it detects that `my-libs` depends on `iot-client`, updates the `my-libs` dependency on `iot-client` to its latest version (by updating the `iot-client.lib` file) and asks you to commit it. This propagates up to `my-libs` and finally to your program `my-mbed-os-example`.
598614

599615
### Forking workflow
600616

@@ -709,6 +725,7 @@ mbed config [--global] <var> [value] [--unset]
709725
* The **local** configuration (without `--global`) is per mbed program and allows overriding of global or default mbed CLI settings within the scope of a program or library and its dependencies.
710726
* If **no value** is specified then mbed CLI will print the currently set value for this settings from either the local or global scope.
711727
* The `--unset` option allows removing of a setting.
728+
* The `--list` option allows to list global and local configuration.
712729

713730
Here is a list of currently implemented configuration settings:
714731

@@ -718,3 +735,13 @@ Here is a list of currently implemented configuration settings:
718735
* `protocol` - defines the default protocol used for importing or cloning of programs and libraries. The possible values are `https`, `http` and `ssh`. Use `ssh` if you have generated and registered SSH keys (Public Key Authentication) with a service like GitHub, GitLab, Bitbucket, etc. Read more about SSH keys [here](https://help.github.com/articles/generating-an-ssh-key/) Default: `https`.
719736
* `depth` - defines the *clone* depth for importing or cloning and applies only to *Git* repositories. Note that while this option may improve cloning speed, it may also prevent you from correctly checking out a dependency tree when the reference revision hash is older than the clone depth. Read more about shallow clones [here](https://git-scm.com/docs/git-clone). Default: none.
720737
* `cache` (EXPERIMENTAL) - defines the local path that will be used to store minimalistic copies of the imported or cloned repositories, and attempts to use them to minimize traffic and speed up future importing. This feature is still under development, so this should not be used within a production environment. Default: none (disabled).
738+
739+
## Troubleshooting
740+
741+
#### Unable to import Mercurial based (mbed.org) programs or libraries.
742+
1. Check whether you have Mercurial installed in your system path by running `hg` in command prompt. If you're receiving "command not found" or similar message, then you need to install Mercurial and add it to your system path.
743+
744+
2. Try to clone a Mercurial repository directly, e.g. `hg clone https://developer.mbed.org/teams/mbed/code/mbed_blinky/`. If you're receiving error similar to `abort: error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.:590)` then your system certificates are very old. You need to update your system certificates and possibly add the host certificate fingerprint of `mbed.com` and `mbed.org`. Read more about Mercurial's certificate management [here](https://www.mercurial-scm.org/wiki/CACertificates).
745+
746+
#### Various issues when running mbed CLI in cygwin environment
747+
Currently mbed CLI is not compatible with cygwin environment and cannot be executed inside it (https://github.com/ARMmbed/mbed-cli/issues/299)

circle.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ test:
77
- mbed config -G protocol ssh
88
- cd .tests && mbed new new-test
99
- cd .tests/new-test && mbed ls
10-
- cd .tests/new-test/mbed-os && pip install -r requirements.txt
1110
- cd .tests/new-test && mbed compile --source=. --source=mbed-os/TESTS/integration/basic -j 0
1211
- cd .tests/new-test && mbed test --compile -n tests-integration-threaded_blinky -j 0
1312
- cd .tests && mbed import https://developer.mbed.org/teams/Morpheus/code/mbed-Client-Morpheus-hg hg-test

0 commit comments

Comments
 (0)