audio-box/INSTALLATION.md

4.3 KiB

Installation

Flash image

Format sd-card

Identify your sd-card

$ fdisk -l

Start fdisk to partition the SD card: (Don't forget to replace the sdX with your sd-card drive letter)

$ fdisk /dev/sdX

Type o
Type p
Type n, then p, then 1, then ENTER, then type +200M
Type t, then c
Type n, then p, then 2, then ENTER twice
Exit by typing w

Execute the following script to mount the newly created partitions, download and copy the image. (Don't forget to replace the sdX with your sd-card drive letter)

mkfs.vfat /dev/sdX1 &&
mkdir boot &&
mount /dev/sdX1 boot &&
mkfs.ext4 /dev/sdX2 &&
mkdir root &&
mount /dev/sdX2 root &&
wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-4-latest.tar.gz &&
bsdtar -xpf ArchLinuxARM-rpi-4-latest.tar.gz -C root &&
sync &&
mv root/boot/* boot &&
umount boot root

Boot your raspberry pi and login with alarm/alarm (root user pwd is root)

Change your hostname

$ nano /etc/hostname
# /etc/hostname
noxbox-me
$ nano /etc/hosts
# /etc/hosts
127.0.1.1   noxbox-me
$ ip link show
$ ip link set wlan0 up
$ nano /etc/wpa_supplication/wpa_supplicant-wlan0.conf
# /etc/wpa_supplication/wpa_supplicant-wlan0.conf
ctrl_interface=/run/wpa_supplicant
update_config=1

Enable WiFi

$ wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
$ wpa_cli
> interface wlan0
> add_network
> set_network 0 ssid "my-network"
> set_network 0 psk "my-password"
> enable_network 0
> save_config
> quit
$ systemctl enable wpa_supplicant@wlan0.service
$ systemctl start wpa_supplicant@wlan0.service
$ systemctl enable dhcpcd
$ systemctl start dhcpcd
$ nano /boot/config.txt
# /boot/config.txt
dtparam=audio=on

dtoverlay=vc4-kms-v3d
dtparam=krnbt=on

initramfs initramfs-linux.img followkernel
$ reboot
$ su root
$ pacman-key --init
$ pacman-key --populate archlinuxarm
$ pacman -Syu
$ pacman -S sudo
$ visudo
alarm ALL=(ALL) NOPASSWD: ALL

[Optional]

$ ln -s /usr/share/zoneinfo/Europe/Brussels /etc/localtime
$ pacman -S bluez bluez-utils pulseaudio-bluetooth
$ groupadd --system pulse
$ useradd --system -g pulse -G audio,lp --home-dir /var/run/pulse pulse
$ groupadd --system pulse-access
$ nano /etc/systemd/system/pulseaudio.service
# /etc/systemd/system/pulseaudio.service

[Unit]
Description=PulseAudio Daemon

[Install]
WantedBy=multi-user.target

[Service]
Type=notify
PrivateTmp=true
ExecStart=/usr/bin/pulseaudio --system --realtime --disallow-exit --log-target=journal
$ nano /etc/pulse/daemon.conf
# /etc/pulse/daemon.conf

; system-instance = no
system-instance = yes
$ nano /etc/pulse/system.pa
# /etc/pulse/system.pa

# existing config change:
load-module module-udev-detect tsched=0

# new config entries
load-module module-bluetooth-discover
load-module module-bluetooth-policy
$ systemctl enable pulseaudio
$ systemctl start pulseaudio
$ systemctl --global mask pulseaudio.socket
$ pacman -S alsa-utils
$ 

[Optional]

$ pacman -S alsa-utils
$ aplay /usr/share/sounds/alsa/Side_Left.wav
$ nano /etc/bluetooth/main.conf
# /etc/bluetooth/main.conf

[Policy]
AutoEnable=true
$ nano /etc/bluetooth/audio.conf
# /etc/bluetooth/audio.conf

[General]
Enable=Source,Sink,Media
$ systemctl enable bluetooth
$ systemctl start bluetooth
$ bluetoothctl
> discoverable on
> pairable on

Now connect your device with the noxbox raspberry pi. Don't forget to confirm in bluetoothctl twice.

Now you can stream some songs on your noxbox.

Install services

First run the deploy script to upload the services to your raspberry pi:

chmod +x ./deploy.sh
./deploy.sh -u USERNAME -h HOST_IP

Now login to your raspberry pi and execute the following as sudo:

~/audio-box/install.sh

Check the following to see if the services are running correctly

ls -la /data/services/i2c-amp-control # Should contain node_modules and index.js
ls -la /etc/systemd/system/i2c-amp-control.service # Should exist
journalctl -fu i2c-amp-control # Should show log messages when volume buttons are pressed