This document provides a step-by-step guide for writing the Raspberry Pi OS (Legacy, 64-bit) Lite image to an SD card for the Raspberry Pi Zero 2, and for configuring SSH, Wi-Fi, username, and hostname settings prior to the first boot. It is a visual, practical installation guide designed for headless setup scenarios.
At the first step, the Raspberry Pi Imager application must be downloaded from https://www.raspberrypi.com/software according to the operating system being used.
The preparation of this image will be explained using the Windows operating system.
For ease of use throughout the guide, it is recommended to use c64user as the default username and c64ai as the default hostname.
After writing the RPi image to the SD card, access the Raspberry Pi Zero 2 system using PowerShell with the following command:
ssh c64user@c64ai.localInstalling SSH on Windows 11 (if not already installed):
- Open the Start Menu and search for “Turn Windows features on or off”.
- In the window that appears, locate OpenSSH Client.
- Check the box next to OpenSSH Client and click OK.
- Wait for Windows to apply the changes, then restart PowerShell.
- Verify the installation by running:
ssh -VThis should display the installed SSH version.
If the following command returns an error:
ssh c64user@c64ai.localit is recommended to remove the existing SSH host key using the command below and then retry the connection:
ssh-keygen -R c64ai.localAfter a successful connection, enter the following commands in the console to update the system, install Deno, and restart the device.
sudo apt update -yUpdates the package list from the repositories.
sudo apt upgrade -yUpgrades all installed packages to their latest available versions.
curl -fsSL https://deno.land/install.sh | shDownloads and installs Deno using the official installation script.
sudo apt install mcInstalls Midnight Commander (mc), a text-based file manager that allows easy file and directory management directly from the terminal.
sudo rebootRestarts the system to apply the changes.
For transferring files to the Raspberry Pi Zero 2, it is recommended to use WinSCP or FileZilla. Both applications communicate with the device using the SFTP (SSH File Transfer Protocol).
To establish a connection, use the following settings:
- Protocol: SFTP
- Server / Host name:
c64ai.local - Username:
c64user - Port:
22 - Password: The password defined during image preparation
After entering these details, connect to the device and transfer files between your Windows system and the Raspberry Pi Zero 2 as needed.
Download links:
- WinSCP: https://winscp.net
- FileZilla: https://filezilla-project.org
AP (Access Point) mode allows the device to create its own wireless network without connecting to an external network. This mode is mainly used for initial setup, configuration, and scenarios where no network access is available, enabling direct access to the device.
When AP mode is enabled, the Raspberry Pi broadcasts its own Wi-Fi network. Users can connect to this network using a computer or mobile device to access the system. This allows SSH access, basic configuration, and secure completion of network settings.
If the Wi-Fi SSID configured for the C64AI project is not accessible, the device will automatically enable AP mode and broadcast a wireless network named C64AI-Setup.
If AP mode is active and C64AI-Setup appears in the Wi-Fi scan list, the operation is complete. NetworkManager automatically saves the connection.
Enable the AP using the following command:
sudo nmcli dev wifi hotspot ifname wlan0 ssid C64AI-Setup password 12345678To make the AP start automatically at boot, list the available connections:
nmcli con showYou will most likely see a connection named:
Hotspot
Configure the connection to start at boot:
sudo nmcli con modify "preconfigured" connection.autoconnect yes
sudo nmcli con modify "preconfigured" connection.autoconnect-priority -9
sudo nmcli con modify Hotspot connection.autoconnect yes
sudo nmcli con modify Hotspot connection.autoconnect-priority -10
sudo nmcli radio wifi onUsing WinSCP, copy the setup.service file from the C64AI project directory:
\services\etc\systemd\system\setup.service
to the following directory on the Raspberry Pi Zero 2:
/etc/systemd/system
Run the following commands to activate the service:
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable setup.service
sudo systemctl start setup.serviceCopy the files from the setup directory of the C64AI project to the following location on the Raspberry Pi Zero 2:
/home/c64user/setup
Files to be copied:
server.tspublic/index.html
Using WinSCP, create a directory named build under the following path on the Raspberry Pi Zero 2:
/home/c64user
Upload the following directories from the project folder to:
/home/c64user/build
Directories to upload:
ask2aishutdownledserver
Reconnect to the Raspberry Pi using SSH and access the terminal.
Navigate to the ask2ai build directory:
cd build/ask2ai/Make the build script executable:
chmod a+x build.shRun the build script:
./build.shWait for the build process to complete and for the generated binary file to be copied into the server directory.
Next, navigate to the server directory:
cd ../server/Compile the c64aiserver application:
make
In the same directory, open the .env file using the nano editor:
nano .envLocate the <your_api_key> placeholder, delete it, and paste your Gemini API key using right-click.
Save the file and exit nano by pressing the following keys in order:
CTRL + OENTERCTRL + X
You will now return to the terminal.
Launch Midnight Commander:
mc Using Midnight Commander, copy the following files and directories to:
/home/c64user
Items to copy:
ask2aic64aiserver.env
After the copy operation is completed in Midnight Commander, press F10 to exit and return to the terminal. From the terminal, navigate back to the build directory:
cd /home/c64user/buildEnter the shutdownled directory:
cd shutdownledBefore compiling the application, install the required GPIO libraries:
sudo apt install -y libgpiod-dev gpiodCompile the application:
makeAfter the build process is complete, use Midnight Commander (mc) to copy the generated binary file:
gpio_shutdown_led
to the following directory:
/home/c64user
From the project directory:
\services\etc\systemd\system\
upload the following service files to the Raspberry Pi Zero 2 directory:
/etc/systemd/system
Service files to upload:
c64aiserver.servicegpio-shutdown.service
These files will be used to manage and control the related services on the system.
Run the following commands to activate the services:
# Reload systemd to recognize the new service files
sudo systemctl daemon-reloadStart the services immediately:
sudo systemctl start c64aiserver
sudo systemctl start gpio-shutdownEnable the services to start automatically at boot:
sudo systemctl enable c64aiserver
sudo systemctl enable gpio-shutdownYour SD card image has been configured for the C64AI project. To safely power off the Raspberry Pi Zero 2, run the following command in the terminal:
sudo shutdown -h now








