Skip to content

Commit 486cfe5

Browse files
authored
Merge pull request #114 from ferrous-systems/suggest-cyme
Suggest cyme
2 parents 621e99b + 1314d1a commit 486cfe5

File tree

20 files changed

+310
-41
lines changed

20 files changed

+310
-41
lines changed

build.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,17 @@ pushd radio-app
4141
cargo build --target=thumbv7em-none-eabihf --release
4242
cargo fmt --check
4343
popd
44-
for i in usb-lib usb-lib-solutions/*; do
44+
for i in usb-lib-solutions/*; do
4545
pushd $i
4646
cargo build --target=thumbv7em-none-eabihf --release
4747
cargo fmt --check
48+
cargo test
4849
popd
4950
done
51+
pushd usb-lib
52+
cargo build --target=thumbv7em-none-eabihf --release
53+
cargo fmt --check
54+
popd
5055
pushd usb-app
5156
cargo build --target=thumbv7em-none-eabihf --release
5257
cargo fmt --check

exercise-book/src/nrf52-hardware.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ After connecting the DK to your PC/laptop it will show up as:
6666
```console
6767
$ lsusb
6868
(..)
69-
Bus 001 Device 014: ID 1366:1015 SEGGER 4-Port USB 2.0 Hub
69+
Bus 001 Device 014: ID 1366:1051 SEGGER 4-Port USB 2.0 Hub
7070
```
7171

7272
The device will also show up in the `/dev` directory as a `ttyACM` device:

exercise-book/src/nrf52-radio-dongle.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ When put in bootloader mode the Dongle will run a bootloader program instead of
1515

1616
When the Dongle is in bootloader mode its red LED will pulsate. The Dongle will also appear as a USB CDC ACM device with vendor ID `0x1915` and product ID `0x521f`.
1717

18-
You can also use our `cargo xtask usb-list` tool, a minimal cross-platform version of the `lsusb` tool, to check out the status of the Dongle.
18+
You can also use `cyme`, a cross-platform version of the `lsusb` tool, to check out the status of the Dongle.
1919

20-
✅ Run `cargo xtask usb-list` **in the root** of the rust-exercises checkout to list all USB devices; the Dongle will be highlighted in the output, along with a note if in bootloader mode.
20+
✅ Run `cyme` to list all USB devices.
2121

2222
Output should look like this:
2323

2424
```console
25-
radio-app/ $ cd ../..
26-
rust-exercises/ $ cargo xtask usb-list
25+
$ cyme
26+
(..)
27+
2 16  0x1915 0x521f Open DFU Bootloader E1550CA275E7 12.0 Mb/s
2728
(..)
28-
Bus 001 Device 016: ID 1915:521f <- nRF52840 Dongle (in bootloader mode)
2929
```
3030

31-
🔎 [`cargo xtask`](https://github.com/matklad/cargo-xtask) lets us extend `cargo` with custom commands which are installed as you run them for the first time. We've used it to add some helper tools to our workshop materials while keeping the preparation installations as minimal as possible.
31+
The first two values depend on your host computer and which USB port you used, so they will be different for you. The hex-string is the device's unique ID and that will also be different.
3232

3333
Now that the device is in bootloader mode browse to the [`nrf52-code/boards/dongle-fw`](../../nrf52-code/boards/dongle-fw) directory. You'll find some `ELF` files (without a file ending) there. These are pre-compiled Rust programs to be flashed onto your dongle.
3434

@@ -56,19 +56,19 @@ After the device has been programmed it will automatically reset and start runni
5656

5757
🔎 The `loopback` application will make the Dongle enumerate itself as a CDC ACM device.
5858

59-
✅ Run `cargo xtask usb-list` tool to see the newly enumerated Dongle in the output:
59+
✅ Run `cyme` to see the newly enumerated Dongle in the output:
6060

6161
```console
62-
$ cargo xtask usb-list
62+
$ cyme
6363
(..)
64-
Bus 001 Device 020: ID 1209:0309 <- nRF52840 Dongle (loopback-fw)
64+
2 16  0x1209 0x0309 Dongle Loopback - 12.0 Mb/s
6565
```
6666

6767
The `loopback` app will log messages over the USB interface. To display these messages on the host we have provided a cross-platform tool: `cargo xtask serial-term`.
6868

6969
❗ Do not use serial terminal emulators like `minicom` or `screen`. They use the USB TTY ACM interface in a slightly different manner and may result in data loss.
7070

71-
✅ Run `cargo xtask serial-term`. It shows you the logging output the Dongle is sending on its serial interface to your computer. This helps you monitor what's going on at the Dongle and debug connection issues. Start with the Dongle unplugged and you should see the following output:
71+
✅ Run `cargo xtask serial-term` from the root of the extracted tarball / git checkout. It shows you the logging output the Dongle is sending on its serial interface to your computer. This helps you monitor what's going on at the Dongle and debug connection issues. Start with the Dongle unplugged and you should see the following output:
7272

7373
```console
7474
$ cargo xtask serial-term

exercise-book/src/nrf52-tools.md

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ In Zadig's graphical user interface,
8282

8383
2. From the device (top) drop down menu select "BULK interface (Interface nnn)"
8484

85-
3. Once that device is selected, `1366 1015` should be displayed in the USB ID field. That's the Vendor ID - Product ID pair.
85+
3. Once that device is selected, `1366 1051` should be displayed in the USB ID field. That's the Vendor ID - Product ID pair.
8686

8787
4. Select 'WinUSB' as the target driver (right side)
8888

@@ -104,10 +104,6 @@ Go to [https://rustup.rs](https://rustup.rs/) and follow the instructions.
104104

105105
**Windows**: It's OK to ignore the message about `git` not being installed, if you get one!
106106

107-
### Better TOML
108-
109-
**All**: For better handling of `Cargo.toml` files, we recommend you install [Better TOML](https://marketplace.visualstudio.com/items?itemName=bungcip.better-toml) if you're using VS Code.
110-
111107
### Rust Cross compilation support
112108

113109
**All**: Run this command in a terminal:
@@ -125,9 +121,9 @@ cargo install cargo-binutils
125121
rustup +stable component add llvm-tools
126122
```
127123

128-
### General purpose tools
124+
### Third-party tools written in Rust
129125

130-
Install the [`flip-link`](https://crates.io/crates/flip-link) and [`nrf-dfu`](https://crates.io/crates/nrfdfu) tools from source using the following Cargo commands:
126+
Install the [`flip-link`](https://crates.io/crates/flip-link), [`nrf-dfu`](https://crates.io/crates/nrfdfu) and [`cyme`](https://crates.io/crates/cyme) tools from source using the following Cargo commands:
131127

132128
```console
133129
$ cargo install flip-link
@@ -137,6 +133,10 @@ Installed package `flip-link v0.1.7` (..)
137133
$ cargo install nrfdfu
138134
(..)
139135
Installed package `nrfdfu v0.1.3` (..)
136+
137+
$ cargo install cyme
138+
(..)
139+
Installed package `cyme v1.7.0` (..)
140140
```
141141

142142
Install `probe-rs` 0.24 pre-compiled binaries on Linux or macOS with:
@@ -162,6 +162,27 @@ cargo-size 0.3.6
162162

163163
✅ Connect the nRF52840-DK with your computer by plugging the usb-cable into the J2 connector on the DK (the usb connector on the short side of the board).
164164

165+
✅ Use `cyme` to list the USB devices on your computer.
166+
167+
```console
168+
$ cyme
169+
(..)
170+
2 15  0x1366 0x1051 J-Link 001050255503 12.0 Mb/s
171+
(..)
172+
```
173+
174+
Your nRF52840-DK should appear as "J-Link" with USB Vendor ID (VID) of 0x1366 and a USB Product ID (PID) 0x1051.
175+
176+
🔎 If `cyme` doesn't work for any reason, you can use `cargo xtask usb-list`, which does the same thing but is much more basic. Run it from the root of the extracted tarball / git checkout:
177+
178+
```console
179+
$ cargo xtask usb-list
180+
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.04s
181+
Running `xtask/target/debug/xtask usb-list`
182+
Bus 002 Device 015: ID 1366:1051 <- J-Link on the nRF52840 Development Kit
183+
(...) random other USB devices will be listed
184+
```
185+
165186
✅ In the terminal run the following command from the [`nrf52-code/radio-app`](../../nrf52-code/radio-app) folder. This will build and run a simple program on the DK to test the set-up.
166187

167188
```console

exercise-book/src/nrf52-usb-data-stage.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ The raw values you need to pack into the descriptor are as follows. Note, we won
2828
- `bDescriptorType = 1`, device descriptor type (must always be this value)
2929
- `bDeviceClass = bDeviceSubClass = bDeviceProtocol = 0`, these are unimportant for enumeration
3030
- `bMaxPacketSize0 = 64`, this is the most performant option (minimizes exchanges between the device and the host) and it's assumed by the `Ep0In` abstraction
31-
- `idVendor = consts::VID`, value expected by `cargo xtask usb-list` (\*)
32-
- `idProduct = consts::PID`, value expected by `cargo xtask usb-list` (\*)
31+
- `idVendor = consts::VID`, our example's USB Vendor ID (\*)
32+
- `idProduct = consts::PID`, our example's USB Product ID (\*)
3333
- `bcdDevice = 0x0100`, this means version 1.0 but any value should do
3434
- `iManufacturer = iProduct = iSerialNumber = None`, string descriptors not supported
3535
- `bNumConfigurations = 1`, must be at least `1` so this is the minimum value

exercise-book/src/nrf52-usb-idle-state.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,13 @@ You can find traces for other OSes in these files (they are in the [`nrf52-code/
5555
- `macos-enumeration.txt`
5656
- `win-enumeration.txt`
5757

58-
✅ Double check that the enumeration works by running [`cargo xtask usb-list`](./nrf52-usb-listing-usb-devices.md) while `usb-4.rs` is running.
58+
✅ Double check that the enumeration works by running [`cyme`](./nrf52-usb-listing-usb-devices.md) while `usb-4.rs` is running.
5959

6060
```console
61-
Bus 001 Device 013: ID 1366:1015 <- J-Link on the nRF52840 Development Kit
62-
(..)
63-
Bus 001 Device 016: ID 1209:0717 <- nRF52840 on the nRF52840 Development Kit
61+
$ cyme
62+
(...) random other USB devices will be listed
63+
2 15  0x1366 0x1051 J-Link 001050255503 12.0 Mb/s
64+
2 16  0x1209 0x0717 composite_device - 12.0 Mb/s
6465
```
6566

6667
Both the J-Link and the device implemented by your firmware should appear in the list.
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
# Listing USB Devices
22

3-
✅ To list all USB devices, run `cargo xtask usb-list` from the top-level checkout.
3+
As we showed in [Preparation/Software Tools](./nrf52-tools.md), we can use `cyme` to list USB devices on our system.
4+
5+
✅ To list all USB devices, run `cyme` from the top-level checkout.
46

57
```console
6-
$ cargo xtask usb-list
8+
$ cyme
79
(...) random other USB devices will be listed
8-
Bus 001 Device 010: ID 1366:1015 <- J-Link on the nRF52840 Development Kit
10+
2 15  0x1366 0x1051 J-Link 001050255503 12.0 Mb/s
911
```
1012

11-
The goal of this workshop is to get the nRF52840 SoC to show in this list. The embedded application will use the USB Vendor ID (VID) and USB Product ID (PID) defined in [`nrf52-code/consts`](../../nrf52-code/consts); `cargo xtask usb-list` will highlight the USB device that matches that VID/PID pair, like this:
13+
The goal of this workshop is to get the nRF52840 SoC to show in this list. The embedded application will use the USB Vendor ID (VID) 0x1209 and USB Product ID (PID) 0x0717, as defined in [`nrf52-code/consts`](../../nrf52-code/consts):
1214

1315
```console
14-
$ cargo xtask usb-list
16+
$ cyme
1517
(...) random other USB devices will be listed
16-
Bus 001 Device 010: ID 1366:1015 <- J-Link on the nRF52840 Development Kit
17-
Bus 001 Device 059: ID 1209:0717 <- nRF52840 on the nRF52840 Development Kit
18-
```
18+
2 15  0x1366 0x1051 J-Link 001050255503 12.0 Mb/s
19+
2 16  0x1209 0x0717 composite_device - 12.0 Mb/s
20+
````

nrf52-code/usb-app-solutions/Cargo.lock

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nrf52-code/usb-app-solutions/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ defmt = "0.3.5"
1919
defmt-rtt = "0.4"
2020
dk = { path = "../boards/dk", features = ["advanced"] }
2121
panic-probe = { version = "0.3.0", features = ["print-defmt"] }
22-
usb = { path = "../usb-lib" }
22+
usb = { path = "../usb-lib-solutions/complete" }
2323
usb2 = "0.0.1"
2424

2525
[dependencies.heapless]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target
2+
Cargo.lock

0 commit comments

Comments
 (0)