Skip to content

Commit 8fc7704

Browse files
authored
Merge pull request #1031 from bridadan/collaborate_cleanup
Mbed CLI Collaborate section cleanup
2 parents 324dff0 + a965077 commit 8fc7704

File tree

3 files changed

+65
-119
lines changed

3 files changed

+65
-119
lines changed

docs/tools/CLI/cli-collaborate.md

Lines changed: 4 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,7 @@
11

22
## Collaborate
33

4-
### Importing an existing program
5-
6-
Use `mbed import` to clone an existing program and all its dependencies to your machine:
7-
8-
```
9-
$ mbed import https://github.com/ARMmbed/mbed-os-example-blinky
10-
[mbed] Importing program "mbed-os-example-blinky" from "https://github.com/ARMmbed/mbed-os-example-blinky" at latest revision in the current branch
11-
[mbed] Adding library "mbed-os" from "https://github.com/ARMmbed/mbed-os" at rev #dd36dc4228b5
12-
$ cd mbed-os-example-blinky
13-
```
14-
15-
Mbed CLI also supports programs based on Mbed OS 2, which it automatically detects and which do not require additional options:
16-
17-
```
18-
$ mbed import https://mbed.org/teams/mbed/code/mbed_blinky/
19-
[mbed] Importing program "mbed_blinky" from "https://mbed.org/teams/mbed/code/mbed_blinky" at latest revision in the current branch
20-
[mbed] Adding library "mbed" from "http://mbed.org/users/mbed_official/code/mbed/builds" at rev #f9eeca106725
21-
[mbed] Couldn't find build tools in your program. Downloading the mbed 2.0 SDK tools...
22-
$ cd mbed-os-example-blinky
23-
```
24-
25-
You can use the "import" command without specifying a full URL; Mbed CLI adds a [prefix](https://github.com/ARMmbed) to the URL if one is not present. For example, this command:
26-
27-
```
28-
$ mbed import mbed-os-example-blinky
29-
```
30-
31-
is equivalent to this command:
32-
33-
```
34-
$ mbed import https://github.com/ARMmbed/mbed-os-example-blinky
35-
```
36-
37-
### Importing from a Git or GitHub clone
4+
### Importing from a cloned repository
385

396
If you have manually cloned a Git repository into your workspace and you want to add all missing libraries, then you can use the `deploy` command:
407

@@ -49,87 +16,6 @@ Don't forget to set the current directory as the root of your program:
4916
$ mbed new .
5017
```
5118

52-
### Adding and removing libraries
53-
54-
While working on your code, you may need to add another library to your application or remove existing libraries.
55-
56-
Adding a new library to your program is not the same as cloning the repository. Don't clone a library using `hg` or `git`; use `mbed add` to add the library. This ensures that all libraries and sublibraries are populated as well.
57-
58-
Removing a library from your program is not the same as deleting the library directory. Mbed CLI updates and removes library reference files. Use `mbed remove` to remove the library; don't remove its directory with `rm`.
59-
60-
#### Adding a library
61-
62-
Use `mbed add` to add the latest revision of a library:
63-
64-
```
65-
$ mbed add https://developer.mbed.org/users/wim/code/TextLCD/
66-
```
67-
68-
Use the `URL#hash` format to add a library from a URL at a specific revision hash:
69-
70-
```
71-
$ mbed add https://developer.mbed.org/users/wim/code/TextLCD/#e5a0dcb43ecc
72-
```
73-
74-
#### Specifying a destination directory
75-
76-
If you want to specify a directory to which to add your library, you can give an additional argument to ``add``, which names that directory. For example, If you'd rather add the previous library in a directory called "text-lcd" (instead of TextLCD):
77-
78-
```
79-
$ mbed add https://developer.mbed.org/users/wim/code/TextLCD/ text-lcd
80-
```
81-
82-
Although Mbed CLI supports this functionality, we don't encourage it. Adding a library with a name that differs from its source repository can lead to confusion.
83-
84-
#### Removing a library
85-
86-
If at any point you decide that you don't need a library any more, you can use `mbed remove` with the path of the library:
87-
88-
```
89-
$ mbed remove text-lcd
90-
```
91-
92-
### Exporting to desktop IDEs
93-
94-
If you need to debug your code, you can export your source tree to an IDE project file to use the IDE's debugging facilities. Mbed CLI supports exporting to Keil uVision, IAR Workbench, a Makefile using GCC Arm, Eclipse using GCC Arm and other IDEs.
95-
96-
For example, to export to uVision, run:
97-
98-
```
99-
$ mbed export -i uvision -m K64F
100-
```
101-
102-
Mbed CLI creates a `.uvprojx` file in the root project directory. You can open the project file with uVision.
103-
104-
#### Serial terminal
105-
106-
You can open a serial terminal to the serial port of a connected Mbed target (usually board) using the `mbed sterm` command. If no serial port is specified, Mbed CLI will attempt to detect the connected Mbed targets and their serial ports.
107-
108-
There are various options to `mbed sterm`:
109-
110-
- `--port <serial port>` to specify system serial port to connect to.
111-
- `--baudrate <numeric>` to select the communication baudrate, where the default value is 9600.
112-
- `--echo <on|off>` to switch local echo (default is `on`).
113-
- `--reset` to reset the connected target by sending Break before opening the serial terminal.
114-
115-
You can also set default port, baudrate and echo mode using the `TERM_PORT`, `TERM_BAUDRATE` and `TERM_ECHO` Mbed CLI configuration options.
116-
117-
The following shortcuts are available within the serial terminal:
118-
119-
- Ctrl+b - Send Break (reset target)
120-
- Ctrl+c - Exit terminal
121-
- Ctrl+e - Toggle local echo
122-
- Ctrl+h - Help
123-
- Ctrl+t - Menu escape key
124-
125-
More shortcuts can be viewed within the serial terminal's help menu (Ctrl+h).
126-
127-
You can also add the `--sterm` option to `mbed compile -f` to compile a new program, flash the program/firmware image to the connected target and then open the serial terminal to its serial port:
128-
129-
```
130-
$ mbed compile -t GCC_ARM -m K64F -f --sterm
131-
```
132-
13319
### Publishing changes
13420

13521
#### Checking status
@@ -182,15 +68,15 @@ When you create a new (local) version control managed program or library, its re
18268
1. Copy the URL/location of the new repository in your clipboard.
18369
1. Open command-line in the local repository directory (for example, change directory to `mbed-os-example/local-lib`).
18470
1. To associate the local repository:
185-
71+
18672
- For Git, run `git remote add origin <url-or-path-to-your-remote-repo>`.
18773
- For Mercurial, edit .hg/hgrc and add (or replace if exists):
188-
74+
18975
```
19076
[paths]
19177
default = <url-or-path-to-your-remote-repo>
19278
```
193-
79+
19480
1. Run `mbed publish` to publish your changes.
19581
19682
In a scenario with nested local repositories, start with the leaf repositories first.

docs/tools/CLI/cli-create.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,45 @@ $ mbed import https://github.com/ARMmbed/mbed-os-example-blinky#mbed-os-5.11.0
121121

122122
You can specify which version to import using `#` followed by a commit hash, a branch name, or a tag name. If you do not provide any of these (nor the `#` character), the latest commit on the `master` branch will be imported.
123123

124-
A project's default name is the last part of the URL (excluding `#` and its value). In the example above, the imported program's project folder is `mbed-os-example-blinky`. To specify a different name, supply it as an extra positional argument in the import command. For example, to name your project `my-blinky`, run:
124+
A project's default name is the last part of the URL (excluding `#` and its value). In the example above, the imported program's project folder is `mbed-os-example-blinky`. To specify a different name, supply it as an extra positional argument in the `mbed import` command. For example, to name your project `my-blinky`, run:
125125

126126
```
127127
$ mbed import https://github.com/ARMmbed/mbed-os-example-blinky#mbed-os-5.11.0 my-blinky
128128
```
129129

130130
<span class="tips">**Tip**: Running `mbed import` within an existing program will result in an error. To add a library to an existing project, use the `mbed add` command.</span>
131131

132+
### Adding libraries to programs
133+
134+
You can use the `mbed add` command to add a library to a program. Run the following command within your project directory:
135+
136+
```
137+
$ mbed add https://github.com/ARMmbed/mbed-cloud-client
138+
[mbed] Working path "C:\dev\mbed-os-example-blinky" (program)
139+
[mbed] Adding library "mbed-cloud-client" from "https://github.com/ARMmbed/mbed-cloud-client" at latest revision in the current branch
140+
[mbed] Updating reference "mbed-cloud-client" -> "https://github.com/ARMmbed/mbed-cloud-client/#377c6b8fb0f8b66be03408a438ff0cd96be0c454"
141+
```
142+
143+
Like the `mbed import` command, you can specify which version to use by using `#` at the end of the URL followed by a commit hash, a branch name, or a tag name. If you do not provide any of these (nor the `#` character), the latest commit on the `master` branch will be used.
144+
145+
The `mbed add` command will clone the repository specified, checkout to the correct version, and write the URL and _commit hash_ to a `.lib` file. Branches and tags can point to different commits over the lifetime of a repository, so to ensure the project's state is always reproducible, the commit hash is written to the `.lib` file. This `.lib` file should be committed to the project repository to track the dependency.
146+
147+
A library's default name is the last part of the URL (excluding `#` and its value). In the example above, the cloned library's folder is `mbed-cloud-client`. To specify a different name, supply it as an extra positional argument in the `mbed add` command. For example, to name your library `my-mcc`, run:
148+
149+
```
150+
$ mbed add https://github.com/ARMmbed/mbed-cloud-client my-mcc
151+
```
152+
153+
### Removing libraries
154+
155+
Remove a library (and it's `.lib` file) from your project by supplying the path to the library to the `mbed remove` command. Continuing the example from above, run the following from your project directory to remove the library that was added previously:
156+
157+
```
158+
$ mbed remove mbed-cloud-client
159+
```
160+
161+
Commit the removal of the `.lib` file from your project to remove the dependency.
162+
132163
### Updating programs and libraries
133164

134165
You can update programs and libraries on your local machine, so they update to the latest released version from the remote sources (Git or Mercurial).

docs/tools/CLI/cli-test-debug.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,35 @@ All unit tests are under the `mbed-os/UNITTESTS` directory. You can **generate**
271271
$ mbed test --unittests --new rtos/Semaphore.cpp
272272
```
273273

274+
### Serial terminal
275+
276+
You can open a serial terminal to the serial port of a connected Mbed target (usually board) using the `mbed sterm` command. If no serial port is specified, Mbed CLI will attempt to detect the connected Mbed targets and their serial ports.
277+
278+
There are various options to `mbed sterm`:
279+
280+
- `--port <serial port>` to specify system serial port to connect to.
281+
- `--baudrate <numeric>` to select the communication baudrate, where the default value is 9600.
282+
- `--echo <on|off>` to switch local echo (default is `on`).
283+
- `--reset` to reset the connected target by sending Break before opening the serial terminal.
284+
285+
You can also set default port, baudrate and echo mode using the `TERM_PORT`, `TERM_BAUDRATE` and `TERM_ECHO` Mbed CLI configuration options.
286+
287+
The following shortcuts are available within the serial terminal:
288+
289+
- Ctrl+b - Send Break (reset target)
290+
- Ctrl+c - Exit terminal
291+
- Ctrl+e - Toggle local echo
292+
- Ctrl+h - Help
293+
- Ctrl+t - Menu escape key
294+
295+
More shortcuts can be viewed within the serial terminal's help menu (Ctrl+h).
296+
297+
You can also add the `--sterm` option to `mbed compile -f` to compile a new program, flash the program/firmware image to the connected target and then open the serial terminal to its serial port:
298+
299+
```
300+
$ mbed compile -t GCC_ARM -m K64F -f --sterm
301+
```
302+
274303
### Troubleshooting
275304

276305
#### Import Mercurial (mbed.org) programs or libraries

0 commit comments

Comments
 (0)