- Linux is natively supported.
- Windows can be used with WSL2.
- MacOS is untested but should be supported. If something doesn't work, please open an issue.
Install wsl with PowerShell
wsl --install
To open a WSL shell, open the run dialog with Win + R and type in wsl.
Alternatively, you can launch wsl in an existing terminal by running the command wsl.
You can follow the below instructions in the WSL shell using your code editor of choice. Visual Studio Code is recommended because it has excellent WSL integration.
Other editors such as Zed may require custom setup or may need rustup to be installed on Windows for code linting or autocompletion to work properly.
- If using Windows(WSL), see the official Windows tutorial.
- If using macOS, see the official MacOS tutorial.
- If using native Linux, see my tutorial.
Ubuntu (WSL)
sudo apt update && sudo apt upgrade
sudo apt install git make upx curl build-essentialFedora
sudo dnf install git make upx curl
sudo dnf groupinstall "Development Tools"Arch
sudo pacman -S git make upx curl base-develMacOS
brew install upx gccYou may have to close and re-open the terminal for the rustup command to be available after installing.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup target add armv5te-unknown-linux-musleabigit clone https://github.com/shaggysa/ev3dev-rs-template.git
cd ev3dev-rs-templateOne major issue when using scp and ssh to send files and run commands is that it always prompts for a password and takes a several seconds to establish a connection. This command will set up an ssh key on your computer and robot to allow for passwordless logins and create a socket to keep the robot connected when idle.
make ssh-setup TARGET=robot@<ip> where <ip> is the ip address in the top left corner of your robot.
For example, if the ip address was 169.254.255.255:
make ssh-setup TARGET=robot@169.254.255.255You can send the same ssh key to another robot using make ssh-send-key TARGET=robot@<ip>. For example:
make ssh-send-key TARGET=robot@169.254.255.255If the robot's ip address changes (which can happen on each connection when using WSL),
you can update the computer's entry with make ssh-update-ip TARGET=robot@<new-ip>. For example:
make ssh-update-ip TARGET=robot@169.254.255.254A long compile time at the first compile is completely normal. Incremental compiles should be much faster.
make buildmake deployWhile you can run the program directly from the robot's file browser, it is much easer to do it from the computer. This also allows you to see any console output directly on the computer
make runTo compile, deploy, and run in a single command, you can simply run
makeThis project uses several "neat tricks" to optimize compile and deploy times.
You can expect turnaround times (running make to the program starting) of about
6 seconds for incremental builds assuming you did make ssh-setup.
These optimizations are automatically done when using the above instructions to compile and deploy
Under [profile.release], we use a opt-level = s to and strip = true to remove debug symbols.
We are not using lto = true because it only saves about 25kb of binary size and ballons compile times.
[profile.release]
strip = true
opt-level = "s"
To take advantage of the file size reductions in the release profile, we use cargo build --release --target armv5te-unknown-linux-musleabi.
Additionally, we run upx on the generated binary to compress it. Binaries compressed with upx are about half the
size, function identically to uncompressed variants, and have practically zero compression or decompression overhead.
Using the above optimizations, we get a binary of about 320kb. At this size, scp transfers the binary in about 4 second.
Note that we are not using rsync to transfer the binary. It isn't preinstalled on the hub and doesn't produce
any speed benefits compared to scp when using upx to compress the binary. Even on an incremental build, rsync
gives a 1.5x speedup whereas upx halves the binary size.