Skip to content

Compute ‐ Raspberry Pi

JonasFrey96 edited this page Sep 2, 2024 · 40 revisions

Setup Overview

We are using the Raspberry Pi Compute Module 4. We run RasbianOS 64bit light with Debian 11 Bullseye with Kernel 6.1.21-v8+ This allows for native PTP support and we run ROS1 inside a Ubuntu Focal container. Kernel modules are added outside the container directly to the native OS and the buffer files mapped inside the container. The GPIOs are mainly controlled using the pigpio library http://abyz.me.uk/rpi/pigpio/.

Lessons Learned

  • PTP is not straight forward to get running with any Ubuntu Image available
  • Therefore using Raspberry Pi OS Lite 64 bit
  • Problem here latest version is on Debian Version 12 which does not work with ROS1 Buster - therefore we use the docker container
  • On the latest Debian 12 the GPIO API changed which made it tricky to use the existing Debian Kernal Modules - therefore we use Debian 11.

Kernel Module

Kernel modules are quite straight forward to install - we created in all drivers that need kernel modules the corresponding C-Files which require to be built and can then be added to the kernel using insmode. For more details refer to the individual kernel driver modules.

We currently need kernel modules for:

  • STIM320
  • AP20
  • ADIS16475

Step 1: Flashing the PI with Debian Bookworm

We followed the following: https://www.jeffgeerling.com/blog/2020/how-flash-raspberry-pi-os-compute-module-4-emmc-usbboot

  • Use the development board
  • Connect directly to EMMC via USB Micro cable
sudo apt install libusb-1.0-0-dev
cd git
git clone --depth=1 https://github.com/raspberrypi/usbboot
cd usbboot
make
  • Set jumper to disable eMMC boot
  • Verify good USB micro USB cable which allows for data transmission
  • Power cycle the dev board
sudo ./rpiboot

Install the RPI Imager:

sudo snap install rpi-imager

image

We created a copy of the image here: https://drive.google.com/drive/folders/1Jrnnmyx1K0XbNu_suW2S03UzyD-9fVt2?usp=drive_link

Raspberry Pi OS Lite 64 bit

rsl@pi:~ $ cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 11 (Bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye

Setup Networking

First lets obtain a static IP address without using netplan such that we can download netplan.

Copy to sudo vi /etc/network/interfaces

source /etc/network/interfaces.d/*

auto lo

auto eth0
iface eth0 inet static
    address 192.168.2.58
    netmask 255.255.255.0
    gateway 192.168.2.51
    dns-nameservers 8.8.8.8

Restart the networking:

sudo systemctl restart networking

Setup SSH_keys by copying over from other PC

ssh [email protected] -o PubkeyAuthentication=no -o PreferredAuthentications=password
scp -r -o PubkeyAuthentication=no -o PreferredAuthentications=password /home/rsl/.ssh/* [email protected]:/home/rsl/.ssh
killall ssh-agent; eval "$(ssh-agent)"
ssh-add /home/rsl/.ssh/id_rsa
killall ssh-agent; eval "$(ssh-agent)"

Given that the internet is now working on the PI one can install netplan

sudo apt install netplan.io -y
# and then continue follow the pi installation script within the grandtour repo

PTP Setup

Follow tutorial here: https://github.com/jclark/rpi-cm4-ptp-guide/blob/main/os.md

Make the changes to the sudo raspi-config

enable serial port (under Interface/Serial Port); Answer *No to login shell accessible over serial

  • Yes to enable serial port hardware

Then append to /boot/firmware/config.txt

# Enable GPIO pin 18 for PPS (not always necessary, but useful for testing)
dtoverlay=pps-gpio,gpiopin=18
# realtime clock
dtoverlay=i2c-rtc,pcf85063a,i2c_csi_dsi
# fan
dtoverlay=i2c-fan,emc2301,i2c_csi_dsi
# Make /dev/ttyAMA0 be connected to GPIO header pins 8 and 10
# This always disables Bluetooth
dtoverlay=disable-bt

Restart some things

sudo systemctl disable hciuart
sudo dpkg-reconfigure tzdata

Check if this looks good

ethtool -T eth0
sudo hwclock --show

Setting up the rest:

From this point one can follow grand_tour_box/box_configuration/pi/pi_configure.sh This includes setting up system services for:PTP, PIGPIO, Docker, creating a ROS docker image, Fan Control, Boxi, Modifying the bashrc. Warning: The docker container is currently sketchy given that it requires you to just fetch the latest docker image from github then add some installations and docker commit it. We should add a clean Dockerfile to this.

PCB

grand_tour_pi_breakout_board.pdf

(Always output trigger - feedback pin)

FAN_PWM_25kHz

  • PWM0_0 -> GPIO18
  • GPIO16 (feedback for PWM speed) ->

CAM_PWM_30Hz

  • PWM0_1 -> GPIO19
  • GPIO26

ADIS_CLK_1.6kHz

  • GPCLK0 -> GPIO4
  • GPIO27
    • (SPI)

SAFRAN_CLK_2kHz

  • GPCLK1 -> GPIO5
  • GPIO22
  • (+RS422)

HONEY_CLK_1.2kHz

  • GPCLK2 -> GPIO6
  • GPIO25
  • (+RS422)

NTC (I2C):

  • SCL - I2C1_SCL -> GPIO3
  • SDA - I2C1_SDA -> GPIO2

pi_breakout_old

Links

Clone this wiki locally