Clone
4
Optimised set up with Diet Pi
Niellune edited this page 2026-03-28 23:52:19 +02:00
This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Introduction

These are updated instructions for converting a combination of a Raspberry Pi Zero 2W and a Carlinkit dongle into a fully functional CarPlay/Android Auto system. These instructions are evolution of a previous version of the guide, but are focused on a more minimal kiosk setup with faster boot times.

Instead of Raspberry Pi OS Lite, this version uses DietPi OS. However, the previous guide still contains a lot of useful information that is worth reviewing. With this setup, I was able to achieve 12 seconds from power-on to the splash screen, 18 seconds to application load, and 30 seconds until CarPlay starts on a Raspberry Pi Zero 2W.

Warning

This is work in progress from 28.03, content will be added section by section

Steps

  1. Flashing DietPi Os
  2. First boot and inital set up
  3. Connect to WIFI using wpa_supplicant and systemd-networkd
  4. Configure DietPI
  5. Set up FastCarPlay Carplay and Android Auto receiver
  6. Splash screen
  7. Pipewire audio with equalizer
  8. Optimize DietPi boot on RPI
  9. Wi-Fi connection and hotspot scripts
  10. Additional hardware: AUX TV Output, I2S Audio, External key provider

Prerequisites

This guide is build on following hardware:

  • Car Head Unit with HDMI or Analog input - or any other device you will use as a display.
  • Raspberry Pi Zero 2 W - this guide is specifically written for this model. Other models may require different configurations.
  • MicroSD Card - Use UHS-II card for performance. A minimum 16GB Class 10 card should be enough, but faster cards will reduce boot times.
  • Autokit Adapter - CPC200-CCPA CarPlay dongle. Any dongle that works with the Autokit Android application should be fine.
  • USB OTG Adapter - required to connect the dongle and a keyboard.
  • 5V Power Supply - a reliable 5V, 2.5A power supply is essential for stable operation.
  • Optional: I2S Sound Card - this guide is based on PCM5102A I2S module. Any Raspberry Picompatible I2S device should work.

Important

  • Throughout this guide, the username carplay is used for the Raspberry Pi user account. Adjust commands accordingly if you use a different username.

1 Flashing

Warning

Work in progress

Download Diet PI https://dietpi.com/#download Exctract DietPi_RPi234-ARMv8-Trixie Blena etcher Select image Select device Flash Wait Flashing and Validation

2 Initial Setup

Warning

Work in progress

##Initial set up Insert flash card, Connect display, keyboard Boot RPI login root, dietpi Network settings Ethernet off IPv6 off Onboard wifi on WiFi enable Set up country Scan Select network Apply Back Exit Reboot login root, dietpi Wait for diet pi Software Update select keyboard layout new password repeat password software update password repeat Disable serial/UART console -> yes Dietpi software: defaults Desktop [None], SSH Server [Dropbear], Log system [DietPi-RAMlog #1] -> Install Do you wish to continue as a pure minimal image -> yes Diet-Pi survey -> as you wish ip addr to get ip connect with

3 Wpa Supplicant

Warning

Work in progress

sudo iw dev wpa_passphrase WifiSSID WifiPassword | sudo tee /etc/wpa_supplicant/wpa_supplicant-wlan0.conf

sudo nano /etc/wpa_supplicant/wpa_supplicant-wlan0.conf

add ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev country=US

sudo nano /etc/systemd/network/25-wlan.network

[Match] Name=wlan0

[Network] DHCP=yes

sudo nano /etc/resolv.conf replace everuthing with nameserver 8.8.8.8

sudo chmod 600 /etc/wpa_supplicant/wpa_supplicant-wlan0.conf sudo systemctl enable wpa_supplicant@wlan0.service sudo systemctl enable systemd-networkd.service sudo apt purge ifupdown ifupdown2

sudo systemctl disable wpa_supplicant.service sudo systemctl disable systemd-network-generator.service sudo systemctl disable systemd-networkd-wait-online.service sudo systemctl disable systemd-networkd-persistent-storage.service sudo systemctl disable networking.service sudo systemctl disable systemd-hostnamed.service sudo systemctl mask systemd-hostnamed.service sudo reboot

3 Configuration

Warning

Work in progress

login as root / ssh as root rename user

usermod -l carplay dietpi usermod -d /home/carplay -m carplay groupmod -n carplay dietpi chown -R carplay:carplay /home/carplay usermod -aG sudo carplay

add groups usermod -aG input carplay usermod -aG video carplay usermod -aG audio carplay usermod -aG plugdev carplay

systemctl list-unit-files --type=service --state=enabled

systemctl disable console-setup.service systemctl disable cron systemctl disable dietpi-postboot.service systemctl disable dietpi-preboot.service systemctl disable fake-hwclock-load.service systemctl disable fake-hwclock-save.service systemctl disable systemd-pstore.service

systemctl mask alsa-restore.service systemctl mask systemd-hostnamed.service systemctl mask systemd-hostnamed.socket systemctl mask systemd-networkd-persistent-storage.service systemctl mask systemd-journal-flush.service systemctl mask systemd-binfmt.service

systemctl unmask systemd-logind apt install --no-install-recommends dbus libpam-systemd

sudo nano /etc/fstab remove /var/swap none swap sw

sudo reboot

4 FastCarPlay

Warning

Work in progress

sudo apt install --no-install-recommends build-essential git xxd libsdl2-dev libsdl2-ttf-dev libavformat-dev libavcodec-dev libavutil-dev libswscale-dev libusb-1.0-0-dev libssl-dev

sudo apt install --no-install-recommends ffmpeg libsdl2-2.0-0 libsdl2-ttf-2.0-0 libusb-1.0-0 libssl3

sudo nano /boot/firmware/config.txt dtoverlay=vc4-kms-v3d max_framebuffers=2

lsusb Bus 003 Device 066: ID 1314:1520 Magic Communication Tec. Auto Box echo 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="1314", ATTRS{idProduct}=="1520", GROUP="plugdev", MODE="0660"' | sudo tee /etc/udev/rules.d/50-carlinkit.rules

If not set up before sudo usermod -aG plugdev carplay sudo udevadm control --reload-rules sudo udevadm trigger

git clone https://github.com/niellun/FastCarPlay.git cd ./FastCarPlay make clean make release -j2

mkdir ./conf cp ./settings.txt ./conf nano ./conf/settings.txt

vendor-id = 4884 product-id = 5409 width = 1024 height = 576 source-fps = 50 window-mode = 2 hw-decode = true alternative-rendering = true

./out/app ./conf/settings.txt

sudo nano /etc/systemd/system/carplay.service

[Unit] Description=Auto-start FastCarPlay on system boot DefaultDependencies=no After=local-fs.target systemd-user-sessions.service systemd-logind.service dbus.service

[Service] Type=simple User=carplay WorkingDirectory=/home/carplay PAMName=login Environment=XDG_SESSION_TYPE=x11 TTYPath=/dev/tty1 StandardInput=tty UnsetEnvironment=TERM UtmpIdentifier=tty1 UtmpMode=user StandardOutput=journal StandardError=journal

ExecStartPre=-/sbin/modprobe bcm2835-codec ExecStartPre=/usr/bin/chvt 1 ExecStart=/home/carplay/FastCarPlay/out/app /home/carplay/FastCarPlay/conf/settings.txt Restart=on-failure RestartSec=2s

[Install] WantedBy=multi-user.target

sudo systemctl enable carplay.service

if hw-decoding not working rm /etc/modprobe.d/dietpi-disable_rpi_codec.conf

5 Splash Screen

Warning

Work in progress

sudo ffmpeg -i FastCarPlay/src/resource/background.bmp -vf scale=720:576 -pix_fmt rgb565le -f rawvideo /etc/splash.fb

sudo nano /etc/systemd/system/splash.service

[Unit] Description=Framebuffer splash DefaultDependencies=no After=dev-fb0.device

[Service] Type=oneshot ExecStart=/bin/sh -c 'cat /etc/splash.fb > /dev/fb0'

[Install] WantedBy=sysinit.target

sudo nano /etc/systemd/system/splash2.service

[Unit] Description=Framebuffer splash DefaultDependencies=no After=dev-fb0.device systemd-udev-settle.service systemd-logind.service

[Service] Type=oneshot ExecStart=/bin/sh -c 'cat /etc/splash.fb > /dev/fb0'

[Install] WantedBy=multi-user.target

sudo systemctl enable splash.service sudo systemctl enable splash2.service

sudo systemctl disable getty@tty1.service sudo systemctl enable getty@tty2.service

6 Pipewire

Warning

Work in progress

sudo apt install --no-install-recommends pipewire

7 Optimise Boot

Warning

Work in progress

sudo nano /boot/firmware/config.txt

dtoverlay=vc4-kms-v3d,composite max_framebuffers=2 gpu_mem=64

enable_tvout=1 sdtv_mode=2

framebuffer_width=720 framebuffer_height=576 framebuffer_depth=16 disable_fw_kms_setup=0

disable_splash=1 boot_delay=0 enable_uart=0 dtparam=sd_poll_once arm_64bit=1 arm_boost=1 disable_poe_fan=1 auto_initramfs=0 camera_auto_detect=0 force_eeprom_read=0 disable_fw_kms_setup=1 dtparam=sd_overclock=100 initial_turbo=50

temp_limit=65 dtoverlay=disable-bt dtparam=i2c_arm=on dtparam=spi=on dtoverlay=hifiberry-dac

sudo nano /boot/firmware/cmdline.txt video=Composite-1:720x576@50ie,tv_mode=PAL,margin_left=24,margin_right=25,margin_top=11,margin_bottom=8 root=PARTUUID=aad06ec6-02 rootfstype=ext4 rootwait fsck.repair=yes net.ifnames=0 logo.nologo console=tty2 quiet loglevel=0 rd.udev.log_priority=3 vt.global_cursor_default=0 mitigations=off elevator=deadline

8 Wifi Scripts

Warning

Work in progress

sudo nano /etc/hostapd/hostapd.conf sudo nano /opt/scripts/enable_ap.sh

#!/bin/bash

echo "> Stopping services" sudo killall hostapd dnsmasq wpa_supplicant

echo "> Setting static IP on wlan0" sudo ip link set wlan0 down sudo ip addr flush dev wlan0 sudo ip addr add 10.0.10.1/24 dev wlan0 sudo ip link set wlan0 up

echo "> Starting dnsmasq" sudo dnsmasq --interface=wlan0 --bind-interfaces --dhcp-range=10.0.10.2,10.0.10.20,255.255.255.0,12h &

echo "> Starting network services" sudo systemctl start dropbear.service

echo "> Starting hostapd" sudo hostapd /etc/hostapd/hostapd.conf &

sudo chmod +x /opt/scripts/enable_ap.sh sudo nano /opt/scripts/connect_wifi.sh

#!/bin/bash

echo "> Stopping services" sudo killall hostapd dnsmasq wpa_supplicant

echo "> Resetting wlan0" sudo ip link set wlan0 down sudo ip addr flush dev wlan0 sudo ip link set wlan0 up

echo "> Starting wpa_supplicant" sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant-wlan0.conf

echo "> Starting network services" sudo systemctl start systemd-networkd.service sudo systemctl start systemd-timesyncd.service sudo systemctl start dropbear.service

sudo chmod +x /opt/scripts/connect_wifi.sh sudo systemctl disable systemd-timesyncd.service sudo systemctl disable wpa_supplicant.service sudo systemctl disable wpa_supplicant@wlan0.service sudo systemctl disable systemd-networkd.service sudo systemctl disable systemd-networkd.socket sudo systemctl disable dropbear.service

9 Additional Hardware

Warning

Work in progress