Start Mycroft on boot, enclosure start timing - Raspberry Pi OS (Buster)

Hi there,

I’ve successfully installed Mycroft on the latest version of Raspberry Pi OS (not picroft) following this excellent guide (Thank you @Dominik ).

I’m having a few teething issues getting Mycroft to start at boot, but they seem different to those mentioned here.

There are two issues I would be grateful to have some advice on:

#1 - I’ve made a systemd service (shown below), and Mycroft starts at boot, but there’s no sound - it appears to be a permissions issue accessing ALSA?

The error that shows up is the below, but the other symptom is that there’s no mic level shown in mycroft-cli-client.

2022-03-18 20:45:54.753 | ERROR    |   969 | VolumeSkill | Couldn't allocate mixer, ALSAAudioError('Unable to find mixer control Master,0 [default]')

My systemd service is pasted below:

[Unit]
Description=Mycroft AI
After=alsa-restore.service network-online.target
Wants=network-online.target

[Service]
User=pi
Group=pi
WorkingDirectory=/home/pi/
ExecStart=/home/pi/mycroft-core/bin/mycroft-start all
ExecStop=/home/pi/mycroft-core/bin/mycroft-stop
Type=forking
Restart=no

[Install]
WantedBy=multi-user.target

If I run mycroft-start from the command line, I have no issues… (outside #2 below, which I don’t think is related to this) I’m guessing permissions for audio, but I’m not really sure how to start troubleshooting this?

#2 - The Mark 1 enclosure will not work right unless I launch it after the bus is booted. If I use:

mycroft-start all

Then the eyes / mouth / etc don’t work - I get an ‘Attempting to use a port that is not open’ error in the 'enclosure.log file. Simply starting the bus first, allowing some time, then starting everything, works fine:

mycroft-start bus
sleep 10
mycroft-start all

The above workaround is totally fine for me - I can write a wrapper script for the 3 lines above, and use that as the start script for Mycroft, but I figured perhaps someone else has come across this issue and may have some advice on a better way to tackle it?

Thanks in advance for any help - I’ve had a lot of fun dusting off my Mark 1 and seeing the general improvements in the Mycroft ecosystem!

For the systemd service I use, the first three lines of mycroft.service are:

[Unit]
Description=Mycroft AI
After=pulseaudio.service

Maybe worth a try ?

-Mike M

Hi @mike99mac , thank you for the suggestion! Unfortunately I don’t have the pulseaudio service running, my sound seems to be handled by the alsa-restore service.

Also, the audio issue occurs even if I boot the pi, and then start the service manually, so I don’t think it’s a timing thing for the service, it seems more related to audio permissions in general.

I’m able to replicate the issue if I attempt to start Mycroft as root, rather than pi, e.g.

mycroft-start all

Loads the sound correctly, while:

sudo mycroft-start all

Does not…

I figured the User=pi and Group=pi in the systemd file would fix this, but evidently not!

Is it then? Maybe with pulseaudio sharing audio resources would work better?

-Mike M

Hi, [S13_Mills]. First to note is that you setup the mycroft-core as pi, not root. So yest mycroft-start all as pi will succeed, bit as root as it dose not have the benefit of all the files install in .config/mycroft, .local/share/mycroft and .mycroft. Trying to go the ALSA only route, is fair, my latest install if on a Pi4B and is not based on the picroft image, it’s on Debian Bullseye 64bit, and I only have ALSA, but the for systemd make the service a user service, not a system level service, that way you can have it run a the user pi. As for the mic issue make sure that in you mycroft-config edit user under the listener section don’t have a statement like //“device_name”: //.