Raspberry Pi 3 Raspbian Primer

jeikabu

jeikabu

Posted on March 21, 2019

Raspberry Pi 3 Raspbian Primer

That day has come.

There’s been a Raspberry Pi 3 B with a touchscreen running Windows 10 IoT Core on my desk at work for a while now.

We’ve been using docker and Qemu to test aarch64/ARM64, but .NET Core for ARM32 doesn’t work atop Qemu. So we need an actual device running Debian. It just so happens I have another Pi 3!

Install Rasbian

The official installation instructions are good:

  1. Download Raspbian
  2. Install

For example, on macOS:

diskutil list
# Note my SD card reader is /dev/disk2

diskutil unmountDisk /dev/disk2
sudo dd bs=1m if=~/Downloads/2018-11-13-raspbian-stretch.img of=/dev/rdisk2 conv=sync
sudo diskutil eject /dev/rdisk2
Enter fullscreen mode Exit fullscreen mode

SSH and VNC

Pretty much the first thing I ever do is get SSH working so I can use a single keyboard/mouse/screen/etc. While you’re there you can turn on VNC:

sudo raspi-config
Enter fullscreen mode Exit fullscreen mode
  • Interfacing Options > SSH > Yes
  • Interfacing Options > VNC > Yes

When it comes to Linux configuration, one of the best investments you can make is setting up “SSH Key-Based Authentication”. If that means nothing to you, look into it, it will change your life. There’s numerous excellent guides on the internet, but if you’re on Linux/macOS you should be able to:

# Replace with IP address of your Pi
ssh-copy-id pi@192.168.X.Y
# From now on you can ssh in without a password
ssh pi@192.168.X.Y

Enter fullscreen mode Exit fullscreen mode

Speaking of investments, given the premium placed on screen real-estate don’t overlook the -X option to ssh (on macOS/OSX you also need XQuartz):

VNC will give you access to the full desktop (alternatively, look into xrdp).

If you use a VNC client other than RealVNC you may not be able to connect. TigerVNC complains: No matching security types. Either use RealVNC or follow the VNC configuration instructions.

Another option worth looking at is xrdp. It makes sense when:

  • Network connectivity/bandwidth are not an issue (ethernet works best- same goes for VNC)
  • You're already using RDP to connect to Windows machines
  • There's a small screen connected to the Pi
# On the pi
sudo apt-get install -y xrdp
Enter fullscreen mode Exit fullscreen mode

You should then be able to use an RDP client (e.g Microsoft Remote Desktop 10) to connect to raspberrypi.local or the IP address of the Pi.

Screen

If you’ve got some kind of small display (like the 7” touchscreen) you may need additional configuration.

  • Rotate screen 180 degrees. In /boot/config.txt add:
  lcd_rotate=2
Enter fullscreen mode Exit fullscreen mode
  • Adjust screen brightness (max brightness is 255, higher than that results in “I/O Error”):
  sudo sh -c "echo 80 > /sys/class/backlight/rpi_backlight/brightness"
Enter fullscreen mode Exit fullscreen mode
  • Virtual Keyboard. Regardless if you call it a “soft keyboard”, “on-screen keyboard”, or something else, you might want one. Regardless if you prefer iOS or Android, prepare to be disappointed:
sudo apt-get install matchbox-keyboard
Enter fullscreen mode Exit fullscreen mode

Software

Update the firmware (may not be necessary with recent devices):

sudo rpi-update
Enter fullscreen mode Exit fullscreen mode

For case-insensitive shell auto-completion, in ~/.inputrc:

set completion-ignore-case on
Enter fullscreen mode Exit fullscreen mode

Pretty much the first thing you’re going to want to do is:

sudo apt-get update
sudo apt-get install -y vim screen # Other stuff...
Enter fullscreen mode Exit fullscreen mode

If you haven’t already, take the time to learn vim or emacs. Nano/pico are the Linux moral equivalent of Windows Notepad. It takes a month to feel productive, but totally worth it. If you go with emacs and have a gimpy ctrl key (like Mac laptops), you might want to swap “caps lock” and ctrl:

$hexified = "00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00".Split(',') | % { "0x$_"}
$kbLayout = 'HKLM:\System\CurrentControlSet\Control\Keyboard Layout'
New-ItemProperty -Path $kbLayout -Name "Scancode Map" -PropertyType Binary -Value ([byte[]]$hexified)
Enter fullscreen mode Exit fullscreen mode

Because everything takes longer on low-end devices, “screen” is handy if you plan to leave the Pi plugged in somewhere and use a laptop. It allows you to have a session persist after you clam up:

screen # Start a session
screen -S <name> # Start session with <name>
# Ctrl-a d # Detach from the session
screen -x # Attach to running session
screen -r <name> # Attach to session with <name>
screen -dRR # Attach to session creating/detaching as needed (if multiple use first)
screen -ls # List sessions
screen -e xy # Change command character
# For example, since Ctrl-a interferes with bash's default emacs mode:
screen -e^gg
# Now `Ctrl-g d` detaches and `Ctrl-g g` is a literal `Ctrl-g`
Enter fullscreen mode Exit fullscreen mode

More goodies:

💖 💪 🙅 🚩
jeikabu
jeikabu

Posted on March 21, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related