Skip to content

Commit fdff8dd

Browse files
authored
Docs (#6)
* [RUST EMBEDDED] more documentation * [GITHUB] pull request template
1 parent 19dd865 commit fdff8dd

File tree

3 files changed

+102
-1
lines changed

3 files changed

+102
-1
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Background
2+
3+
# Related issues
4+
5+
# Breaking Changes
6+
N/A

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Davide Asnaghi
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
</p>
2828

29-
# Bazel Rust Embedded Tools
29+
# Rust Embedded Tools
3030

3131
This repository contains useful, cross-platform embedded tools that work out of the box in any Bazel project.
3232

@@ -57,6 +57,21 @@ rust_embedded_deps()
5757

5858
Head to the [Releases](https://github.com/d-asnaghi/bazel-rust-embedded/releases) page for more specific `WORKSPACE` settings
5959

60+
## Dependencies
61+
62+
At the moment, this is still a pre-release project. The build is not completely hermetic (it will be in the future) and requires to install the following dependencies based on your operating system
63+
64+
### Linux
65+
66+
`sudo apt install -y pkg-config libusb-1.0-0-dev libftdi1-dev`
67+
### Windows
68+
69+
`vcpkg install libftdi1:x64-windows-static-md libusb:x64-windows-static-md`
70+
71+
## Examples
72+
73+
Head to the [examples](examples) directory where you can see how to use the rules in this repo to flash and debug ARM firmware targets using a custom toolchain.
74+
6075
## [Cargo Flash](https://crates.io/crates/cargo-flash)
6176

6277
You can use cargo flash to load binaries or elf files to any target that uses a supported probe (JLink, STLink, Etc).
@@ -95,5 +110,64 @@ cargo_flash(
95110
```
96111

97112
Then `bazel run //package:flash_elf` and `bazel run //package:flash_bin` will load the file to the target
113+
## [Cargo Embed](https://crates.io/crates/cargo-embed)
114+
115+
Cargo embed is a more powerful version of cargo-flash. It can be used to start a gdb server after flashing the probe. You have an option to specify a custom config to feed into cargo flash for maximum configurability.
116+
117+
That config can also be an actual `.toml` file if you would rather have even more options.
98118

119+
```python
120+
# package/BUILD
99121

122+
load("@rust_embedded//:rules.bzl", "cargo_embed_config", "cargo_embed")
123+
124+
cc_binary(
125+
name = "firmware_elf",
126+
...
127+
)
128+
129+
cargo_emebd_config(
130+
name = "config",
131+
flash = "true",
132+
halt = "true",
133+
gdb_enabled = "true",
134+
)
135+
136+
cargo_embed(
137+
name = "flash_debug",
138+
file = ":firmware_elf",
139+
chip = "STM32F103C8",
140+
custom_config = ":config",
141+
)
142+
```
143+
144+
# GDB targets
145+
146+
Cargo embed exposes a GDB server, which can be connected to. For convenience, there are rules that specifically instantiate a GDB server and even launch the console for you.
147+
148+
```python
149+
# package/BUILD
150+
151+
load("@rust_embedded//:rules.bzl", "gdb_server", "gdb_console")
152+
153+
cc_binary(
154+
name = "firmware_elf",
155+
...
156+
)
157+
158+
gdb_server(
159+
name = "gdb-server",
160+
file = ":firmware",
161+
chip = "STM32F103C8",
162+
)
163+
164+
gdb_console(
165+
name = "gdb-console",
166+
file = ":firmware_elf",
167+
chip = "STM32F103C8",
168+
gdb = "<label to gdb binary>",
169+
gdb_commands = [
170+
"b main",
171+
]
172+
)
173+
```

0 commit comments

Comments
 (0)