Prepare Raspberry Pi and starting with Rust Embedded
I just got my Raspberry Pi 3 (along with sensors kit), and below how I did the setup and got it run:
- Download Etcher for copying the iso.
- Download Raspbian Stretch Lite (Minimal image based on Debian Stretch), the November 2018 version is only 351MB (the Raspbian Stretch with desktop is 1GB, while the Raspbian Stretch with desktop and recommended software is 1.8GB)
- Flash the SD card with Etcher
- Connect the Raspberry Pi 3 to:
- HDMI cable connected toscreen
- Keyboard
- Mouse
- USB cable connected to power source (or computer)
- Ethernet cable (if you or your device do not have WiFi network)
- Insert the flashed SD card into the Raspberry slot.
- Power on the device (by connecting the other edge of the USB cable to computer or power source)
- Once the device boot up (may take 2 minutes depending on your SD card speed), you'll be prompted to enter your login, default user is:
pi
, default pswd israsbperry
:
Raspbian GNU/Linux 9 raspberrypi tty1
rasbperrypi login: pi Password: raspberry
Then you'll get the device ready to use showing a:
pi@raspberrypi:~$
- Do the require changes in the configuration, like
user password
,WiFi
andssh
connection as below:
pi@raspberrypi:~$ sudo raspi-config
- For
changing password
select1 Change Password
- For
wifi
select2 Network Options
, you'll be asked to select country of the WiFi, then entering the SSID (i.e. the wifi name) and the wifi passphrase, BE CAREFULL both network name and password are case-sensetive. - For
ssh
select5 Interfacing Options
, scroll down toP2 SSH
, and confirmYes
as an answer toWould you like the SSH server to be enabled
- For
Updating the OS
select8 Update
- for
Auto login
, i.e avoid being asked everytime for username and password, select3 Boot Options
thenB1 Desktop / Cli
thenB2 Console Autologin
- Change the
keyboard layout if required
you can check if the correct one selected or no, by trying printing#
and|
- Click finish once done to go back to the command prompt:
pi@raspberrypi:~$
- Setup
static ip
// check your current ip
pi@raspberrypi:~$ sudo ifconfig
// update your ip in the DHCPCD configeration file as static ip
pi@raspberrypi:~$ sudo nano /etc/dhcpcd.conf
- Scroll down to
define static profile
, and uncommit (i.e. remove the#
)notice the ip is appearing asstatic ip_address=192.168.x.xx
- Press
Ctrl+X
to exit, confirmYes
that you want to save, then pressEnter
to save with the same name
- Reboot your device:
pi@raspberrypi:~$ sudo reboot
- To check if your device is connected to internet, run the below:
$ sudo ping -c 5 www.google.com
- Now you can disconnect the monitor, keyboard and mouse.
- In your other device, ssh login to your raspberry pi as:
ssh pi@192.168.x.xx
- If you want to map the raspberry files with your system, so you can open the files saved in the raspberry with the apps in your PC, you need to have Fuse and SSHFS from here
- Create mapped folder in your pc, let's say
ssh_pi
$ mkdir ~/ssh_pi $ sshfs pi@192.168.x.xx:/home/pi ~/ssh_pi
pi@192.168.1.43's password:
Install your apps, and work the way you like, from keyboard / ssh / FUSE_SSHFS, I was able to install rust
$ curl https://sh.rustup.rs -sSf | sh
Make my first app
$ cargo new my_rust
And open the files at Intellij at my mac. Now will start playing with Rust Embeded and physical-computing-with-rust-on-raspberry-pi and physical-computing-rust
Note: Compiling at Raspberry itself is slow, so better to compile for raspberry platform in your PC, work at your ssh_pi
folder, then it will sync smoothly with the Pi.
In your PC, open the ssh_pi
folder at the terminal, and write:
// get the raspberry pi platform target
$ rustup target add armv7-unknown-linux-gnueabihf
// set the raspberry pi platform as default target for this folder (ssh_pi if covring all the folders in the raspberry pi)
$ rustup override set stable-armv7-unknown-linux-gnueabihf
// To confirm you set the atrget correctly
$ rustup show
// To compile for rasberry pi in your pc
$cargo build
To shutdown your Pi
$ sudo shutdown