owned this note
owned this note
Published
Linked with GitHub
# Rust Embedded Workshop Notepad
This document is for alignment during the workshop. Don't be too shy to extend the document and help others. 🦀:blush:
Workshop page: https://braun-embedded.com/workshop/
Workshop package: https://braun-embedded.com/barcelona-2019-11-09.zip
## Thanks
Thank you for the great workshop Hanno and Matthias!
## Open questions :construction: :tada:
This is your place to add new questions and raise issues. We'll try to answer them collaboratively.
## Known issues
### Installing OpenOCD on NixOS
Use the package from https://pastebin.com/wEYHhM7z . If you need it, you can use the binary cache at https://thequux.cachix.org/ to save some compile time.
### Installing OpenOCD on macOS
You need a pretty recent version of OpenOCD. Homebrew is your friend.
```
brew install open-ocd --HEAD
```
### Error: arm-none-eabi-gdb
```rust
error: could not execute process `arm-none-eabi-gdb -tui -q -x openocd.gdb target/thumbv6m-none-eabi/release/examples/gpio_simple` (never executed)
Caused by:
No such file or directory (os error 2)
```
Please install the [GNU toolchain for your platform](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads). For macOS, you can use [this homebrew tap](https://github.com/osx-cross/homebrew-arm).
> [name=Evan Schwartz] Does anyone know which package to use on Ubuntu?
> [name=Wouter Geraedts] `gdb-multiarch`, also change the path to `gdb-multiarch` in `.cargo/config`.
> [name=Wouter Geraedts]
> It's in the project-folder, i.e. `/minimal/.cargo/config`
> ```
> [target.thumbv6m-none-eabi]
> runner = "gdb-multiarch -tui -q -x openocd.gdb"
> ```
### Error: Clearing lockup after double fault
If you get the following error message when you run your code:
```
lpc84x.cpu -- clearing lockup after double fault
Program received signal SIGINT, Interrupt.
0xfffffffe in ?? ()
(gdb) cont
Continuing.
target not halted
target lpc84x.cpu was not halted when resume was requested
```
Please push the "reset" button on the LPCXpresso. That's the black button next to the white button. :wink:
After that, type `cont` or `continue` and hit `Enter`. The program should now run.
> [name=nrxus] Does this have to be done every time the program is restarted?
> [name=Wouter Geraedts] Mine stays in this mode and does not seem to run my code.
### Device not found
After `lpc8xx-hal$ cargo run --features=845-rt --example gpio_delay`
```
┌──examples/gpio_delay.rs─────────────────────────────────────────────────────────────────────────────────────┐
│8 #[entry] │
│9 fn main() -> ! { │
│10 // Get access to the device's peripherals. Since only one instance of this │
│11 // struct can exist, the call to `take` returns an `Option<Peripherals>`. │
│12 // If we tried to call the method a second time, it would return `None`, but │
│13 // we're only calling it the one time here, so we can safely `unwrap` the │
│14 // `Option` without causing a panic. │
│15 let p = Peripherals::take().unwrap(); │
│16 │
│17 // Initialize the APIs of the peripherals we need. │
│18 let swm = p.SWM.split(); │
│19 let mut delay = Delay::new(p.SYST); │
│20 #[cfg(feature = "82x")] │
│21 let gpio = p.GPIO; // GPIO is initialized by default on LPC82x. │
│22 #[cfg(feature = "845")] │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
exec No process In: L?? PC: ??
Info : only one transport option; autoselect 'swd'
Warn : Transport "swd" was already selected
target/openocd.cfg:8: Error: Can't find target/lpc84x.cfg
in procedure 'script'
at file "embedded:startup.tcl", line 60
at file "target/openocd.cfg", line 8
openocd.gdb:1: Error in sourced command file:
Remote communication error. Target disconnected.: Connection reset by peer.
(gdb)
```
Now what?
> [name=Wouter Geraedts] ~~You probably are running Ubuntu. The scripts provided with the Ubuntu openocd do not have the specific `lpc84x.cfg` file.
> Change the file to `lpc8xx.cfg` in `openocd.cfg`. I.e.~~
> ```
> source [find target/lpc8xx.cfg]
> ```
>
> Ubuntu repository OpenOCD is outdated, compile OpenOCD yourself from [this mirror](https://github.com/ntfreak/openocd).
> Compile openocd with `./configure --enable-cmsis-dap`.
### Can't find target/openocd.cfg
> [name=gakonst] (MacOS).
> There is an openocd.cfg generated under `./target/thumbv6m-none-eabi/release/build/lpc8xx-hal-e9e3756869db2498/out/openocd.cfg`, copying it to `./target/openocd.cfg` doesn't help.
> [name=polly]
> Happens on arch for me
> [This](https://elinux.org/OpenOCD_Troubleshooting:_Can%27t_Find_File.cfg#Can.27t_Find_openocd.cfg) might be relevant
When running `cargo run --features=845-rt --example gpio_delay`
```
Reading symbols from target/thumbv6m-none-eabi/debug/examples/gpio_delay...
Open On-Chip Debugger 0.10.0+dev-00954-gded679902 (2019-11-05-14:28)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
embedded:startup.tcl:26: Error: Can't find target/openocd.cfg
in procedure 'script'
at file "embedded:startup.tcl", line 26
openocd.gdb:1: Error in sourced command file:
Remote communication error. Target disconnected.: Connection reset by peer.
(gdb)
```
**SOLUTION: Revert to git hash `969b67d39a45895783b8e0662a272e8d3ce27d42`, at the moment of writing this HEAD does not work (due to last minute changes before the talk)** ;)
I'm running Debian 9 and the OCD version from apt was 0.9. I uninstalled it and downloaded it for that website. Then I have version 0.10. See question below about where to extract the tgz file?
> [name=gakonst] `brew install openocd` gave 0.10.0, still failing
### Compilation failure (Solved)
When running `cargo run --features=845-rt --example gpio_delay`
> rustc 1.32.0 (9fda7c223 2019-01-16)
```
error[E0658]: renaming imports with `_` is unstable (see issue #48216)
--> src/lib.rs:145:13
|
145 | pub use crate::sleep::Sleep as _;
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.
error: Could not compile `lpc8xx-hal`.
```
**SOLUTION**: Update rust to latest stable version: rustc 1.39.0 (4560ea788 2019-11-04)
> rustup update
### warning: unrecognized item "timeout" in "qSupported" response
Full error:
```
warning: unrecognized item "timeout" in "qSupported" response
openocd.gdb:1: Error in sourced command file:
Remote communication error. Target disconnected.: Connection reset by peer.
```
**Solution**: You're probably using stable openocd. Download the latest git version.
latest git version -- thequux
> [name=Evan Schwartz] I have this version and I'm still seeing the error: `xPack OpenOCD, 64-bit Open On-Chip Debugger 0.10.0+dev (2019-07-17-11:25)`
> [name=gakonst] I have `v0.10.0-esp32-20191008` from [here](https://github.com/espressif/openocd-esp32/releases), same problem.
> [name=flomonster] I might have a solution. After using the latest git version of openocd. Clean your project `cargo clean` then try to run it. (Let me know if it works for you)
> [name=Evan Schwartz] I tried that and still got `openocd.gdb:1: Error in sourced command file:` (this might be the [Unknown Error](#unknown-error) below)
> You need somehow to make OpenOCD view these files: https://github.com/espressif/openocd-esp32/tree/master/tcl/target.
> [name=nrxus] The `cargo clean` command worked for me
> [name=jap] `cargo clean` did not work for me, but unplugging the device did...
> [name=Evan Schwartz] Neither `cargo clean` nor unplugging the device worked for me :crying_cat_face:
> [name=gakonst] this is literally just the system being unable to find the config files, the error in sourced command file is the openocd.cfg file trying to import the file under interfaces/ :/ :sadface:
### Unknown error
> [name=Doc] This means your board is not detected
> In my case it was a bad USB cable !!!!!! <Insert angry face here>
```
openocd.gdb:1: Error in sourced command file:
Remote communication error. Target disconnected.: Connection reset by peer.
```
> [name=pizzamig] You can re-run `cargo run` or type manually the commands contained in the openocd.gdb file:
```
target remote | openocd -f target/openocd.cfg
load
continue
```
Running `target remote` asks me to specify which device I'm connecting to, and even then, `openocd` run with the cfg file does not have the proper interface available
```
Error: The specified debug interface was not found (cmsis-dap)
The following debug interfaces are available:
1: ftdi
2: usb_blaster
3: ft232r
4: jlink
5: vsllink
6: ulink
7: hla
8: osbdm
9: opendous
10: aice
11: xds110
```
>[name=pizzamig] openocd has to be compiled with cmsis-dap enabled. An additional dependency is required, libhidapi, and `--enable-cmsis-dap` during configure
```
target/lpc8xx.cfg:10: Error: Can't find target/lpc1xxx.cfg
in procedure 'script'
at file "embedded:startup.tcl", line 26
at file "./openocd_82x.cfg", line 6
```
>[name=pizzamig]Are you using `--features=845-rt`? `openocd_82x.cfg` is the configuration for a different board
### OCD setup
I downloaded OCD from https://github.com/xpack-dev-tools/openocd-xpack/releases/ an untared it to some dir `xPacks/openocd/0.10.0-13/`.
How is this supposed to be used because just having it unpacked will do nothing with it and the self check command `cargo run --features=845-rt --example gpio_delay` will no know about it. How are the executable and the config files found?
> [name=Evan Schwartz] I just manually added that folder to the path (`export PATH=/path/to/xPacks/openocd/0.10.0-13/:$PATH`)
> [name=pizzamig] openocd is invoked by gdb via the command `target remote | openocd -f target/openocd.cfg` (the first line of openocd.gdb) but it has to be reachable by your shell. Alternatively, you can modify the openocd.gdb file using an absolute pathname for openocd
### udev: configured OK? (Debian)
How to check that it is set up correctly?
Command: ...
Expected response: ....
### LED not working
Level of gpio and LED is counter intuitive for non-embedded developers
Solution:
set_high() -> led off
set_low() -> led on
> [name=Wouter Geraedts] Try running it in release mode with `cargo run --release`. This was what worked for me.
### Did someone got to interact with Touch capacitor?
Trying to read using `.read().istouch().bit_is_set()` but I guess there is some setup to do?