From 6ef3740665e3b0ec4e466dc2e4b23900700b2ab3 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 18 Feb 2019 15:09:33 +0000 Subject: Add usage example to readme --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/README.md b/README.md index a31e315..91def3a 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,54 @@ development and supports: - `GET_STATUS` - `READ_SLOT_NAME` +## Usage Example + +To be able to compile `ntw`, you have to add the thumbv7m-none-eabi target to +your Rust installation, for example by running: + +``` +$ rustup target add thumbv7m-none-eabi +``` + +Now you can compile `ntw`: + +``` +$ cargo build --release +``` + +To communicate with an MCU connected using an ST-Link debugger, start `openocd` +using the provided configuration file: + +``` +$ openocd --file etc/openocd.cfg +``` + +Now you can use `gdb` to flash `ntw` to the MCU and to start a debugging +session. `cargo run` is configured to execute `gdb`, flash the MCU and add +breakpoints at the beginning of the program and at the panic handlers. Once +you see the `gdb` prompt, type `c` to continue the program execution. + +``` +$ cargo run --release +``` + +Depending on your operating system, you might have to change the name of the +`gdb` executable in `.cargo/config`. + +To verify that everything works as expected, you can try to access the device: + +``` +$ nitrocli status +Status: + model: Pro + serial number: 0x00000000 + firmware version: 0.1 + user retry count: 0 + admin retry count: 0 +``` + +If this does not work, check the output of `dmesg`, `lsusb` and `usbhid-dump`. + ## Resources ### Development Setup -- cgit v1.2.3