Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time

Recipe for creating the Mark-2.pi Image

This image is built on top of the original Mycroft Mark 1, modified appropriately to allow a Github-style installation of mycroft-core. Essential differences between this image and the Mark 1 are:

  • Removed the mycroft-core and Mycorft-mark-1 packages
  • Cloned mycroft-core under the pi user
  • Added an auto_run.sh script for the pi user in .bashrc

Importantly, the mycroft-admin-service is still installed on this image and continues to run as the root user to provide wifi setup. This also requires the specific version of Jessie used here, as the newer kernel does not allow the wifi splitting used in the captive portal approach.

Table of contents


Mark 1 Recipe

Install and Configure Base Raspbian Image

  • Burn jessie to SD card. Use:
    2016-09-23-raspbian-jessie-lite.img
  • Boot Raspberry Pi and login as pi/raspberry
  • sudo passwd pi and change to 'mycroft'
  • sudo raspi-config then select
    • '1 Expand Filesystem'
    • '3 Boot Options'
      • --> 'B2 Console Autologin'
    • '4 Wait for network at boot'
      • --> 'No'
    • '5 Internationalization Options'
      • --> 'I3 Change Keyboard Layout'
      • --> 'Generic 101-key PC'
      • --> 'Other'
      • --> 'English (US)'
      • --> 'English (US)'
      • --> 'The default for the keyboard layout'
      • --> 'No compose key'
    • '9 Advanced Options'
      • --> 'A2 Hostname'
      • --> Enter: 'mark_1'
    • Finish and allow the reboot

Connect to Mycroft repos and pull down current image

  • Plug in network cable (if not already)
  • (Optional) Connect via SSH so you can copy/paste all of the following.
  • sudo apt-get update
  • sudo apt-get install apt-transport-https -y
  • sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F3B1AA8B
  • sudo bash -c 'echo "deb http://repo.mycroft.ai/repos/apt/debian debian main" > /etc/apt/sources.list.d/repo.mycroft.ai.list'
  • sudo apt-get update
  • sudo apt-get install mycroft-core -y

Install vim (for Arron's general health and well being)

sudo apt-get install vim -y

Install ufw for a simple firewall setup

sudo apt-get install ufw -y

Set 'll' alias (for Steve's general health and well being)

nano .bashrc and uncomment 'alias ll='ls -l' (about 25 lines from the bottom)

Add initial config for platform detection

  • sudo mkdir /etc/mycroft
  • sudo nano /etc/mycroft/mycroft.conf and add the following:
{
    "enclosure": {
        "platform": "mycroft_mark_1",
        "platform_build": 3,
        "port": "/dev/ttyAMA0",
        "rate": 9600,
        "timeout": 5.0,
        "update": true,
        "test": false
    },
    "VolumeSkill": {
    "default_level": 6,
    "min_volume": 0,
    "max_volume": 83
    }
}

Platform build should be updated with each new image.

Set default sample rate for better sound quality

sudo nano /etc/pulse/daemon.conf and uncomment (9 lines from the bottom)

 default-sample-rate = 44100

Disable kernel boot TTY on GPIO UART

Enable systemd-timesyncd

  • sudo timedatectl set-ntp true

Edit boot configuration settings

sudo nano /boot/config.txt

  • Uncomment all of these to enable the optional hardware interfaces (about 10 lines from bottom)

    • dtparam=i2c_arm=on
    • dtparam=i2s=on
    • dtparam=spi=on
  • Comment out the following to disable audio (loads snd_bcm2835)

     #dtparam=audio=on
    
  • Add the following lines at the bottom:

     # Disable Bluetooth, it interferes with serial port
     dtoverlay=pi3-disable-bt
     dtoverlay=pi3-miniuart-bt
     # Enable Mark 1 soundcard drivers
     dtoverlay=rpi-proto
    
  • sudo nano /boot/cmdline.txt

    • Make sure it contains no mention of ttyAMA0, as this is where the boot logging to serial would be enabled in the past.
    • Delete this option: 'console=serial0,115200'
  • Reboot sudo reboot now

Setup soundcard

Set correct volume and sound card settings

  • alsamixer
  • Press F6 and select 'snd_rpi_proto'
  • Press F5 to show all settings
  • Adjust settings to match as shown below. User right-arrow to change selection, Up to change numbers, 'M' to change between options
  • Raise 'Master' volume to 46 with up arrow presses
  • Press right and enable 'Master Playback' with press of 'M'
  • Press right three times and enable 'Mic' 'Capture' with press of spacebar
  • Press right three times and enable 'Playback Deemp' with press of 'M'
  • Press right three times and set 'Input Mux' to 'Mic' with press of up arrow
  • Press right and enable 'Output Mixer HiFi' with press of 'M'
  • Press right three times and enable 'Store DC Offset' with press of 'M'
  • ESC to save and exit

Enable ufw for a simple firewall allowing only port 22 incoming as well as dns, dhcp, and the Mycroft web socket

Block all incoming by default

  • sudo ufw default deny incoming

Allow ssh on port 22 when enabled

  • sudo ufw allow 22

WiFi setup client: Allow tcp connection to websocket

  • sudo ufw allow in from 172.24.1.0/24 to any port 8181 proto tcp

Allow tcp to web server

  • sudo ufw allow in from 172.24.1.0/24 to any port 80 proto tcp

Allow udp for dns

  • sudo ufw allow in from 172.24.1.0/24 to any port 53 proto udp

Allow udp for dhcp

  • sudo ufw allow in from 0.0.0.0 port 68 to 255.255.255.255 port 67 proto udp

Turn on the firewall

  • sudo ufw enable

Create RAM disk for IPC

sudo mkdir /ramdisk

edit /etc/fstab and add the following line:

tmpfs /ramdisk tmpfs rw,nodev,nosuid,size=20M 0 0

Edit /etc/mycroft/mycroft.conf and add the line

"ipc_path": "/ramdisk/mycroft/ipc/"

at the end. (remember the comma on the line before)

Upgrade packages

Upgrade all packages except raspberrypi-kernel

sudo apt-get update

echo "raspberrypi-kernel hold" | sudo dpkg --set-selections

sudo apt-get upgrade

Setup packagekit

Install the packagekit package.

apt-get install packagekit

Set a policy allowing the mycroft user to install packages using this by creating the file /etc/polkit-1/localauthority/50-local.d/allow_mycroft_to_install_package.pkla

and enter the following

 [Allow mycroft to install packages using packagekit]
 
 Identity=unix-user:mycroft
 
 Action=org.freedesktop.packagekit.package-eula-accept;org.freedesktop.packagekit.package-install
 ResultAny=yes

Allow mycroft user to install with pip

Pip doesn't interact with policy kit so a sudoer rule is needed to allow pip install from mycroft without password. Edit /etc/sudoers.d/011_mycroft-nopasswd and add:

mycroft ALL=(ALL) NOPASSWD: /usr/local/bin/pip install *

Afterwards remove write flag of the file

chmod -w /etc/sudoers.d/011_mycroft-nopasswd

Install librespot

curl -sL https://dtcooper.github.io/raspotify/install.sh | sh

Then disable the raspotify service:

sudo systemctl stop raspotify sudo systemctl disable raspotify

The spotify connect client can now be started from a skill by executing librespot --user USER --password PASS --name Mycroft

Clear the Bash History

  • history -c
  • history -w

Mark 2 Remix Recipe

On top of the Mark 1 image (Raspbian Jessie, etc):

Install I2C for the audio output

sudo raspi-config, turn on i2c

Download and run update script

cd ~
wget -N https://rawgit.com/MycroftAI/enclosure-mark2/master/home/pi/update.sh
bash update.sh

Disable the auto-update of Debian

sudo nano /etc/cron.hourly/mycroft-core comment out "apt-get install..." for now TODO: Replace with an hourly(?) update of the Picroft packages

Temporary: Fix skills/main.py

Disable the code that reinstalls the mycroft-core package.