Raspberry Pi: OS Install and Configuration (18.04) - LoCO-AUV/loco_config GitHub Wiki
Back to overall Raspberry Pi Configuration
Base Install
Confirm Your Hardware
You should be using a Raspberry Pi 4 (4GB). Make sure you have heat sinks attached to the relevant places, and make sure you have keyboard, monitor, and mouse available. Also make sure you have a network connection, ideally Ethernet or an non-enterprise WiFi available, as we'll need network connection to upgrade from a command-line only environment, and enterprise WiFi is difficult to connect to from command line.
NOTE: The following OS install process is from 12/3/19, when there was no official RPI4 support for an Ubuntu image also supported by ROS/Spinnaker. This process is based on the work of James Chambers. If this has changed, please update this.
Update the Firmware
You need the most recent version of the Raspberry Pi firmware (which since RPI4 is stored onboard a separate chip). So, install Raspbian on an MicroSD (I recommend balenaEtcher for flashing MicroSDs), boot it and connect to a network, and update the firmware by running the following commands.
sudo apt-get update && sudo apt-get dist-upgrade -y
sudo rpi-update
sudo rpi-eeprom-update -a
Of course, you will need a network connection for this. Use WiFi or Ethernet, whatever is at your disposal.
Install Ubuntu 18.04
Download the most recent preinstalled-desktop image from here, flash it onto your MicroSD, then boot. Your first boot may take some time.
The username and password are the always the same on first boot: ubuntu/ubuntu. The image is set up to require you to change the password on first login, and it is recommended that you change the username as well. Our configuration steps are below, but you can follow what you want. The one thing you should make sure to do is update your packages.
User Space Configuration (Optional)
Change Hostname
In /etc/hostname and /etc/hosts (in the second line), change ubuntu to your preferred hostname. We use rpi. Reboot after changing the hostname, so that it can take effect.
Create a New User
If you don't want to use the username ubuntu, the easiest way to do this is to create a new user with the following commands:
sudo adduser <new-username>
sudo usermod -aG sudo <new-username>
In our case, I use irvlab and select a password that I share with others. After logging in, consider deleting the ubuntu user with sudo userdel -r ubuntu. You don't have to, of course. I would also recommend setting the user up for automatic login.
Update Packages
sudo apt update
sudo apt upgrade
Required Configuration
Enable Serial/I2C
Use sudo raspi-config, select option 5 (Interfacing Options), and enable Serial and I2C. Do not make a login shell available over serial, just the hardware port.
Storage Disk Configuration
In order to store data on the Raspberry Pi, it is recommended that you mount a USB device to store data on. We don't store data on the MicroSD card, due to the volatility and likelihood that it would be corrupted. Once you have a USB drive that you plan to use, format it with exFAT and follow the instructions below.
Firstly, we need exFAT support.
sudo apt install exfat-fuse exfat-utils
Now, plug in your USB. If it automatically mounts, that's fine. Use df or lsblk to figure out your device's uuid. Ours is /dev/sda1. Now, we need to unmount it from whatever it's mounted to and create a new mount folder.
sudo unmount /dev/sda1
sudo mkdir /data
Lastly, we need something which will mount the disk to that location every time the robot starts up. The unmounting is automatically managed by the system, so no worries there. We have a service for this (which you can find in the loco_config repository under /rpi_config_files), called mount-usb.service. Put it into /etc/systemd/system, then run the following command.
sudo systemctl enable mount-usb.service
That should do it! Reboot and make sure your USB drive works.
Optional Configuration
Overclock (Carefully)
DO NOT DO THIS WITHOUT HEAT SINKS
Thanks to Tom's Hardware for the instructions.
Overclocking the CPU
Edit /boot/firmware/config.txt in a sudo'd text editor. Go to the bottom of the file, looking for [pi4] In a new line under that heading, add these lines:
over_voltage=2
arm_freq=1750
This increases the voltage provided to the SoC slightly, and increases the frequency of the CPU to 1.75 GHz. We have the latest firmware, so you could also try:
over_voltage=6
arm_freq=2147
We now need to reboot in order to reload this file. Don't use anything over the second set of commands given, as it voids the warranty of the Pi.
Overclocking the GPU
We can edit the same file (/boot/firmware/config.txt), in the same place (below [pi4]), and add a line for GPU overclocking:
gpu_freq=600
You can go all the way up to 750 with our firmware.
I don't recommend overclocking the GPU, because it overtaxes the power we have, and we don't really need it (AFAIK)