This document outlines the required packages for your Raspberry Pi project, organized into logical groups. Each section includes installation commands, confirmation steps, and optional cleanup.
sudo apt-get install build-essential git bc bison flex libssl-dev -ybuild-essential: Provides GCC,make, and other essential build tools.git: Source code management and cloning repositories.bc,bison,flex: Often required for building kernels and modules.libssl-dev: Provides SSL development libraries.
- Check Tools:
gcc --version # Confirms GCC is installed make --version # Confirms `make` is installed git --version # Confirms `git` is installed
- Check Libraries:
Look for
libssl-dev:dpkg -l | grep libssl-dev
sudo apt-get install raspberrypi-kernel-headers device-tree-compiler -yraspberrypi-kernel-headers: Required for building kernel modules.device-tree-compiler: Compiles.dtsfiles into.dtbooverlays for display configuration.
- Check Kernel Headers:
ls /lib/modules/$(uname -r)/build- If this directory exists, the kernel headers are installed correctly.
- Check Device Tree Compiler:
dtc --version
- Confirms
dtcis installed.
- Confirms
sudo apt-get install libdrm-dev libdrm-tests kmscube drm-info -ylibdrm-dev: Development libraries for interacting with the Direct Rendering Manager (DRM).libdrm-tests: Tools for debugging DRM resources.kmscube: Tests KMS (Kernel Mode Setting) functionality.drm-info: Provides detailed DRM resource information.
- Check Development Libraries:
dpkg -l | grep libdrm-dev - Test DRM Tools:
- Run
kmscube:kmscube
- Tests KMS and DRM pipeline functionality.
- Check DRM info:
drm-info
- Run
sudo apt-get install fbi -yfbi: A framebuffer image viewer for testing display configurations.
- Test Framebuffer Devices:
- Display an image on the framebuffer:
sudo fbi -d /dev/fb0 -T 1 /path/to/test-image.jpg
- Replace
/path/to/test-image.jpgwith an actual image file.
- Replace
- Display an image on the framebuffer:
sudo apt install micro -ymicro: A lightweight and user-friendly text editor, useful for editing configuration files likeconfig.txtor.jsonsettings.
sudo apt install vim -y- Open the editor:
micro --version
- Configure settings (optional):
micro ~/.config/micro/settings.json
sudo apt-get install python3 python3-pip -ypython3: Provides Python 3 for scripting and development tasks.python3-pip: Allows installing Python packages viapip.
- Check Python Version:
python3 --version
- Test Pip:
pip3 --version
sudo apt-get install dkms -ydkms: Automates building and installing kernel modules, useful for maintaining module compatibility during kernel upgrades.
- Check DKMS status:
dkms status
sudo apt-get install htop -yhtop: A terminal-based system monitor to observe CPU, memory, and processes.
- Run
htop:htop
After completing all installations, confirm that all packages are installed:
dpkg -l | grep -E "build-essential|git|bc|bison|flex|libssl-dev|raspberrypi-kernel-headers|device-tree-compiler|libdrm-dev|libdrm-tests|kmscube|drm-info|fbi|micro|python3|pip3|dkms|htop"- Each installation command completes without errors.
- Confirmation commands verify the tools and libraries are available.
- Optional cleanup removes unnecessary packages:
sudo apt autoremove
sudo apt update && sudo apt upgrade -y
sudo reboot
-
Instal Raspberry Pi Imager
https://www.raspberrypi.com/software/. -
Plug a micro SD card into an addapter on your computer.
-
Set the following:
- Rasberry Pi Device:
Raspberry Pi 5 - Operating System:
Raspberry Pi OS (64-bit) - Operating System: The drive associated with your SD card.
- Rasberry Pi Device:
-
Edit settings when prompted:
- Set username and password
- Username:
nc4 - Password:
1434
- Username:
- Configure wireless LAN
- SSID:
NC4_Neurogenesis_Exposure - Password:
nc4lab1434 - Wireless LAN Country:
CA
- SSID:
- Set lacale settings
- Check the box
- Timezone:
US/Vanvouver - Keyboard:
us
- Set username and password
- SERVICES Tab
- Enable SSH: Checked and set to
Use password authentication
- Enable SSH: Checked and set to
-
Apply the setup settings to the SD card.
-
Install Updates
Plug in the SD card and power on the Pi Open a terminal and run:
sudo apt update sudo apt full-upgrade -yReboot:
sudo reboot
-
Boot the Raspberry Pi.
-
Open a terminal on the Pi and run:
sudo raspi-config -
Enable SSH:
- Interface Options > SSH
- Select Enable.
-
Enable SPI:
- Interface Options > SPI
- Select Enable.
-
Enable I2C:
- Interface Options > I2C
- Select Enable.
-
Reboot
sudo reboot
-
Power off the Raspberry Pi by running:
sudo poweroff -
Wait for the Pi to shut down, then remove the SD card.
-
Insert the SD card into your computer and open the boot partition.
-
Open
/boot/firmware/cmdline.txtusing a text editor. -
Add the following to the end of the single line (ensure everything remains on a single line):
ip=<IP>::0.0.0.0:255.255.0.0::eth0:off
- Explanation:
<IP>: Static IP for the Raspberry Pi’s Ethernet interface.0.0.0.0: No default gateway for Ethernet (traffic won’t be routed through this interface).255.255.0.0: Subnet mask for the Ethernet interface.eth0:off: Specifies the Ethernet interface and disables DHCP.
-
At this stage you can also disable the Pi from loading the desktop by adding this line as well:
systemd.unit=multi-user.target autologin-user=nc4 nosplash -
You can also setup the debugging stuff
drm.debug=0x1f log_buf_len=16M -
Save the file and close the editor.
-
Or just run this:
echo "your_desired_cmdline_content" | sudo tee /boot/firmware/cmdline.txt > /dev/null
- Create or edit the
wpa_supplicant.conffile in the boot partition. You can do this from your SSH connection using:
sudo micro /etc/wpa_supplicant/wpa_supplicant.conf
- Add the following content(s):
country=CA
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="poserguru_s24"
psk="funkstar"
}
country=CA
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="NC4_Neurogenesis_Exposure"
psk="nc4lab1434"
}
- Save the file and eject the SD card.
-
Reinsert the SD card into the Raspberry Pi.
-
Connect an Ethernet cable between your computer and the Pi.
-
Power on the Raspberry Pi.
-
On your computer, open a terminal or SSH client.
-
Ping the Raspberry Pi:
ping 169.254.55.240169.254.55.240 ssh-ed25519 3. If the ping is successful, SSH into the Raspberry Pi:
ssh nc4@169.254.55.240If you get a warning about the hot key changing open:
C:\Users\lester\.ssh\known_hosts
Delete the line: ssh-keygen -R 169.254.55.240
- When prompted:
- Type
yesto continue connecting. - Enter the password:
1434.
- After connecting via SSH, varify the Wi-Fi connection:
ping -c 4 google.com
- Verify the connection works, then exit the SSH session:
exit-
Open Visual Studio Code on your Windows PC.
-
Press
Ctrl + Shift + Pto open the Command Palette. -
Search for and select:
Remote-SSH: Add New SSH Host...
- Enter the Raspberry Pi's SSH connection string:
nc4@169.254.55.240
-
Save the configuration when prompted (e.g.,
~/.ssh/config). -
Click Connect.
-
A new VS Code window will open.
-
When prompted to select the platform, choose:
Linux
-
Enter the password again:
1434. -
VS Code will automatically download and set up the remote server on the Raspberry Pi.
- Open the ~/.bashrc file for editing:
nano ~/.bashrc
- Add the following lines to your ~/.bashrc:
# Enable history search with up/down arrows
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
- Save the pashrc and source it:
source ~/.bashrc
-
Generate a new SSH key:
ssh-keygen -t ed25519 -C "your_email@example.com"- Replace
your_email@example.comwith your GitHub email.
ssh-keygen -t ed25519 -C "adamwardlester@gmail.com"- Press
Enterto accept all defaults and skip passphrase.
- Replace
-
Print the public key:
cat ~/.ssh/id_ed25519.pub- Copy the generated key.
-
Add the key to GitHub:
- Go to https://github.com/settings/keys.
- Click New SSH key.
- Title:
nc4-raspi5_x(e.g.,nc4-raspi5_1) - Paste the copied key and save.
-
Test the connection:
ssh -T git@github.comType
yesand pressEnter. -
Clone the repository:
git clone git@github.com:NC4Lab/TouchscreenApparatus.git -
Set Your Git Username: Run this command in the VS Code terminal (connected to your Pi):
git config --global user.name "Your Name"git config --global user.name "AdamWardLester" -
Set Your Git Email: Run this command in the same terminal:
git config --global user.email "your_email@example.com"git config --global user.email "adamwardlester@gmail.com" -
Verify Configuration:
git config --global --list
-
Open Visual Studio Code on your Windows PC.
-
Press
Ctrl + Shift + Pto open the Command Palette. -
Search for and select:
Remote-SSH: Connect to Host... -
Select the Raspberry Pi's SSH connection string:
nc4@169.254.55.240 -
Enter the Pi password
1434in the VS Code search bar. -
Open the repo in VS Code:
code . -
Close the VS Code instance when you are done.
-
Edit the Configuration File: Open the config.txt file:
sudo micro /boot/firmware/config.txt -
Add the Following Lines to enable additional buses 3 and 4 after
dtparam=i2c_arm=on:dtoverlay=i2c3 # Enables I²C Bus 3 dtoverlay=i2c4 # Enables I²C Bus 4 -
Save and Exit: Save the file (Ctrl+O, Enter, Ctrl+X)
-
Reboot:
sudo reboot -
Varify the busses by listing them:
ls /dev/i2c-*You should see:
/dev/i2c-1 /dev/i2c-3 (or some other number sufix) /dev/i2c-4 (or some other number sufix)
See the driver README:
src/drivers/nc4_ili9488/README.md
Retain only 10 MB of log data (M, K):
sudo journalctl --vacuum-size=15M
Remove logs older than 1 hour (h, d, w):
sudo journalctl --vacuum-time=6h
Remove all logs
sudo rm -rf /var/log/journal/*
sudo systemctl restart systemd-journald
Check all logs
sudo journalctl
Check log disk usage
sudo journalctl --disk-usage
Check what network we are on:
iwgetid -r
Disconnect from network:
sudo nmcli dev disconnect wlan0
Rescan for Networks:
sudo nmcli dev wifi rescan
nmcli dev wifi list
Connect to one of the wifi networks:
sudo nmcli dev wifi connect "NC4_Neurogenesis_Exposure" password "nc4lab1434"
sudo nmcli dev wifi connect "poserguru_s24" password "funkstar"
Varify
nmcli connection show --active
Corrupt Recovery:
cd /home/nc4
sudo rm -r TouchscreenApparatus_backup
sudo cp -r ~/TouchscreenApparatus ~/TouchscreenApparatus_backup
diff -r --exclude='.lgd-nfy0' /home/nc4/TouchscreenApparatus /home/nc4/TouchscreenApparatus_backup
cd /home/nc4/TouchscreenApparatus
rm -f .git/objects/*/*
git fetch origin main
git fetch --depth=1
git reset --hard origin/main
sudo cp -r ../TouchscreenApparatus_backup/* .
git add .
git commit -m "Restoring local changes after fixing Git corruption"
git push
Merge conflict
git pull --no-rebase
sudo cp -r /boot /boot_backup
sudo cp -r /lib/modules /lib/modules_backup
- Download and install
balenaEtcher
https://etcher.balena.io/#download-etcher
-
Insert the SD cards you are cloning from and to
-
Select
Clone Drive -
Choose the card to clone from and click
Select 1 -
Select
Select Traget -
Choose the card to clone to and click
Select 1 -
Click
Flash!
- Download USB Image Tool
https://www.alexpage.de/usb-image-tool/download/
-
Extract and run the exe.
-
Insert SD into a reader.
-
Select it in the left pannel of the UI.
-
Click backup.
-
Name it something like
Pi_4_Backup_24_12_29 -
Click Save.