This is an old revision of the document!

Raspberry Pi - Novation LaunchPad at Console

Part 1: General setup

  • run raspberrypi-ua-netinst on SD card (default install - server packages of debian jessie)
  • SSH in as root…
> /etc/motd
echo rpi-ds-remote > /etc/hostname
sed -i s/pi/rpi-ds-remote/g /etc/hosts
echo "America/Chicago" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
sed -i -e 's/^# en_US.UTF-8/en_US.UTF-8/' /etc/locale.gen
dpkg-reconfigure -f noninteractive locales
apt-get --no-install-recommends install aptitude
aptitude install fbset screen rsync psmisc file patch ethtool strace tcpdump vim bzip2 xz-utils netcat-traditional
aptitude --without-recommends install dnsutils

aptitude install watchdog
sed -i -e 's/^#watchdog-device/watchdog-device/g' /etc/watchdog.conf
sed -i -e 's/^#max-load-1\t/max-load-1\t/g' /etc/watchdog.conf
echo "# Raspberry Pi doesn't work with the default timeout of 60; set it to 10 instead" >> /etc/watchdog.conf
echo $'watchdog-timeout\t= 10' >> /etc/watchdog.conf
systemctl enable watchdog.service
ln -sf /lib/systemd/system/watchdog.service /etc/systemd/system/ # nothing in the [Install] section for this unit file, so we symlink manually

adduser tdobes
adduser tdobes adm
adduser tdobes systemd-journal

# don't erase boot messages from console
mkdir -p /etc/systemd/system/getty\@tty1.service.d
echo '[Service]' > /etc/systemd/system/getty\@tty1.service.d/noclear.conf
echo 'TTYVTDisallocate=no' >> /etc/systemd/system/getty\@tty1.service.d/noclear.conf

# improve boot speed
systemctl mask keyboard-setup.service
systemctl mask console-setup.service
systemctl mask rc-local.service
systemctl mask kbd.service

systemctl disable rsyslog.service # disable to reduce writes to sd card
systemctl stop rsyslog.service
rm /var/log/auth.log* /var/log/daemon.log* /var/log/debug /var/log/kern.log* /var/log/messages /var/log/syslog

systemctl disable hwclock-save.service # avoids error on shutdown/reboot

Part 2: Network

aptitude install ifplugd
sed -i -e 's/^INTERFACES=""/INTERFACES="eth0"/g' /etc/default/ifplugd
sed -i -e 's/^allow-hotplug eth0/#allow-hotplug eth0/g' /etc/network/interfaces

# it looks like this uses systemd-timesyncd, so we won't use NTP

mkdir -p /etc/systemd/system/ssh.socket.d
echo '[Socket]' > /etc/systemd/system/ssh.socket.d/port-2222.conf
echo 'ListenStream=2222' >> /etc/systemd/system/ssh.socket.d/port-2222.conf
systemctl disable ssh.service && systemctl enable ssh.socket

systemctl mask networking.service # we use ifplugd instead
echo 'D /run/network 0755 root root' > /etc/tmpfiles.d/debian-networking.conf
echo 'F /run/network/ifstate 0644 root root - lo=lo' >> /etc/tmpfiles.d/debian-networking.conf

Part 3: LaunchPad

aptitude install python2.7 usbutils alsa-utils
aptitude --without-recommends install python-pygame

mkdir /opt/launchpad
pushd /opt/launchpad
chown tdobes /opt/launchpad # for development

adduser tdobes audio

Part 4: MQTT

aptitude install mosquitto-clients python-mosquitto

Part 5: Autostart on USB hotplug

adduser --system --home /nonexistent --shell /bin/false --no-create-home --disabled-login launchpad
adduser launchpad audio

echo '[Unit]' > /etc/systemd/system/launchpad\@.service
echo 'Description=MCP LaunchPad Control for %I' >> /etc/systemd/system/launchpad\@.service
echo '' >> /etc/systemd/system/launchpad\@.service
echo 'BindTo=%i.device' >> /etc/systemd/system/launchpad\@.service
echo 'After=%i.device' >> /etc/systemd/system/launchpad\@.service
echo >> /etc/systemd/system/launchpad\@.service
echo '[Service]' >> /etc/systemd/system/launchpad\@.service
echo 'ExecStart=/opt/launchpad/' >> /etc/systemd/system/launchpad\@.service
echo 'WorkingDirectory=/opt/launchpad' >> /etc/systemd/system/launchpad\@.service
echo 'User=launchpad' >> /etc/systemd/system/launchpad\@.service
echo 'Environment=PYTHONUNBUFFERED=1' >> /etc/systemd/system/launchpad\@.service
echo >> /etc/systemd/system/launchpad\@.service
echo 'Restart=always' >> /etc/systemd/system/launchpad\@.service
echo 'RestartSec=1' >> /etc/systemd/system/launchpad\@.service
echo 'StartLimitInterval=10s' >> /etc/systemd/system/launchpad\@.service
echo 'StartLimitBurst=10' >> /etc/systemd/system/launchpad\@.service

echo 'SUBSYSTEM=="sound", KERNEL=="card*", SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="1235", ATTRS{idProduct}=="0069", TAG+="systemd", ENV{SYSTEMD_WANTS}="launchpad@$env{DEVNAME}.service"' > /etc/udev/rules.d/mcp-launchpad.rules
computer/raspberry_pi_launchpad.1489263161.txt.gz · Last modified: 2017/03/11 14:12 by tdobes
Recent changes RSS feed Driven by DokuWiki Valid XHTML 1.0 Valid CSS