..and espflash
Note:
probe-rshas since making this repo added a "basic remote server" (GitHub PR) as a built-in feature. That may or may not be a better way to go - you should check.
This repo provides scripts to be run on a Mac/Linux developer account that make probe-rs and espflash running on another computer feel like a local tool.
This allows:
- galvanic separation of the attached electronics from the main development computer
- developing open source code so that people can choose, whether they prefer local or remote
probe-rs/espflash, without any changes to the build files
Supported commands
probe-rshelp,list,info,erase,reset,run
espflashhelp,board-info,erase-*,hold-in-reset,monitor,reset,checksum-md5,flash,partition-table,write-bin
-
A Raspberry Pi 3B
- ..with a stable IP address
Use
ifconfigto see the IP address. Below, we use192.168.1.199(replace with yours!).
Following [1]:
Creating a dedicated user (optional)
You might want to create a separate account on the relay machine, just for running
probe-rs. This way, the ssh key pair won't allow access to full resources, just runningprobe-rs.$ sudo adduser probe-rsGive some pw and press
ENTERfor the defaults.
>Note: Consider another user name if you find it confusing to use also `espflash` under the `probe-rs` user. `#legacy`
On the development machine, create a key pair for using ssh without passwords:
$ ssh-keygen -t rsa
Pass the public key to the probe-rs relay:
$ ssh-copy-id [email protected] # use your own user and IP!!!
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/ubuntu/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]'s password:
Number of key(s) added: 1
[...]
Test:
$ ssh [email protected] whoami
probe-rs
Great!!!
The script (that we head towards..) uses this to see, where the remote account is expected to be.
$ echo "export [email protected]" >> ~/.bashrc
$ source ~/.bashrc
$ echo $PROBE_RS_REMOTE
[email protected]
Note! If you use some other shell than Bash, please adjust the commands accordingly.
The PROBE_RS_REMOTE is now available, even if you were to restart.
The official commands for installing probe-rs do not support Raspberry Pi 3B|1|, but it can be cross-compiled for the device.
Follow instructions in docs/cross.md to:
- cross-compile
probe-rsexecutable suitable for the Raspberry Pi - transfer it to the device
- make some system-wide additions (
udevrules) - the same for
espflash, too
Then, let's test it remotely:
$ ssh -q $PROBE_RS_REMOTE -t 'bash -ic "probe-rs --version"'
probe-rs 0.25.0 (git commit: 5805879)
We now have the remote machine all set up for running probe-rs via ssh.
The script to use on your development machine is at sh/probe-rs-remote.sh.
Consider, whether you want to:
-
a) just copy it to your favourite location (e.g.
~/bin/), alongside thePATH, renaming toprobe-rsin the process, or.. -
b) ..have a symbolic link pointing to a clone of this repo. This makes updates easier.
Create a '~/bin' folder on the PATH
$ install -d ~/bin
$ echo PATH="\$PATH:$HOME/bin" >> ~/.bashrc
$ source ~/.bashrc
a) copy; independent
$ cp sh/probe-rs-remote.sh ~/bin/probe-rs
b) link; points to the repo
$ cd ~/bin
$ ln -s {path-to-repo}/sh/probe-rs-remote.sh probe-rs
[!WARN] An
aliaswould work for your interactive prompt, but not for build files which launchbashin a non-interactive mode.
Test:
$ probe-rs list
You can have both a local and the remote probe-rs simultaneously, but most of the time this is not needed, and is just a distraction.
$ ls ~/.cargo/bin/probe-rs
If you have a file there, just remove it:
$ rm ~/.cargo/bin/probe-rs
Please attach a device to the remote machine.
$ probe-rs info
[...]
The script only supports a limited number of commands. Have a look at its contents for more info.
Now you have remote probe-rs working, transparently to your build systems. Yay! 🎉🎉
The process is very similar, but why would you want to have two separate flashing tools, in the first place?
- Many ESP32 projects online use it; it'll be easier to run those.
espflashcan use either of the USB ports (UART or JTAG) of your devkit;probe-rsuses USB/JTAG only- The approaches are different: since
probe-rsgoes deeper into the MCU, its use sometimes causes incompatibilities that use ofespflashavoids.
Follow the same docs/cross.md instructions.
On the development machine:
$ espflash board-info
Naming note!
We currently use the
probe-rsremote user name, andPROBE_RS_REMOTEenv.var. also forespflash. The reason is only historic - did the ssh bridging tossh, first.You may suggest better suiting names!!
