Home > Ubuntu Operating System
- Ubuntu Operating System
- Base Operating System
- GitHub
- PyCharm
- I2C Interface
- GPIO
- Raspberry Pi Video Camera
Ubuntu Operating System
Raspberry Pi now provides a 64-bit Debian-based operating system (OS) via the Raspberry Pi Imager. However, in my experience, this OS can be non-performant, particularly with regard to PyCharm, which is my preferred Python integrated development environment (IDE). I’ve found that a combination of Ubuntu Server and Xubuntu Desktop performs quite well. The installation is a bit more complicated than the standard Raspberry Pi operating system, and the steps are listed below.
Base Operating System
- Download Ubuntu Server 22.04.2 64-bit LTS for Raspberry Pi. At the time of writing, this was the most recent LTS version that was distributed with version 5 of the Linux kernel. This is important because the raspberry-py package uses the RPi.GPIO package, which is based on a legacy GPIO interface that was removed from more recent Ubuntu Server versions that come with version 6 of the Linux kernel. A compatibility shim exists in the form of rpi-lgpio; however, I’ve had trouble installing this shim into Python virtual environments. In the end, until things change, Ubuntu version 22.04.2 and version 5 of the Linux kernel will work.
- Install and start the Raspberry Pi Imager.
- Select the Ubuntu image that you downloaded and write the image to the micro-SD card. Be sure to configure WiFi and SSH services on the image if needed.
- Boot the Raspberry Pi on the micro-SD card and log in.
- Upgrade and install a few dependencies, general tools and applications, and the Xubuntu desktop environment:
sudo apt update sudo apt upgrade sudo apt install xubuntu-core emacs firefox python3-venv raspi-config i2c-tools apache2 net-tools sudo systemctl reboot
The Pi should reboot into the Xubuntu desktop environment. Log in.
- If you’re planning to use OctoPrint for 3D printing, also install the following packages:
sudo apt install libjpeg-turbo8-dev imagemagick ffmpeg libv4l-dev cmake libgphoto2-dev libopencv-dev libsdl-dev libprotobuf-c-dev v4l-utils
GitHub
- Run
ssh-keygen
and upload the content of~/.ssh/id_rsa.pub
to GitHub. - Clone the raspberry-py repository with
git clone git@github.com:MatthewGerber/raspberry-py.git
.
PyCharm
- Download the community version here. Be sure to download the Linux ARM distribution, which is required for the Pi.
- Extract the archive and move the extracted directory to
/opt/
- Add the PyCharm
bin
directory to yourPATH
in~/.bashrc
. - Start PyCharm and open the raspberry-py repository.
I2C Interface
- Run
raspi-config
and enable the I2C interface. - Run
i2cdetect -y 1
to confirm. A blank I2C readout will be displayed if no I2C peripherals are connected.
GPIO
By default, Ubuntu does not give the user permission to interact with the GPIO pins of the Raspberry Pi. To grant GPIO permissions when the Raspberry Pi boots:
- Edit
/etc/udev/rules.d/99-gpiomem.rules
as follows to assign allgpio*
device to thedialout
group, which the user is a member of by default:KERNEL=="gpio*", OWNER="root", GROUP="dialout"
- Reboot for the new permissions to take effect.
Raspberry Pi Video Camera
- Modify boot config:
sudo emacs /boot/firmware/config.txt
and addstart_x=1
andgpu_mem=256
at the end. - Enable camera: Run
raspi-config
and enable the camera. - Give permission:
sudo usermod -a -G video ubuntu
- Restart:
sudo shutdown -r now
- Test:
raspistill -o test.jpg