Mycroft-gui on my Mark-II - first light

@guhl While waiting for my compile run to compile the KF5 framework for my project, I was reading through your sound section on your wiki.

I see you are installing some python packages, create a python script and using systemd to run that script, just to set the hardware volume to max 30 and let pulseaudio control the 0 - 30 section by pushing all alsa to pulseaudio similar as I do in my project.

Looking at the skill-mark-2 repo, you can just set that volume by a linux command;
https://github.com/MycroftAI/skill-mark-2/blob/master/init.py#L266

So you do not need that whole python script and associated libraries if you use this command;

i2cset -y 1 0x4b 30

If you combine this with a udev rule that runs a command as soon as it sees the usb respeaker device, you do not need systemd as well. Just create a “10-usb-sound.rules” within “/etc/udev/rules.d” with the following content;

SUBSYSTEM=="usb", ATTR{idVendor}=="2886", ATTR{idProduct}=="0018", RUN+="i2cset -y 1 0x4b 30"

I don’t have a respeaker device so can’t test it for you, but if you could please be so kind to test and report back to me. We both benefit from it as it would allow me to support that device within my project without the whole hardware set/get stuff that the Mycroft dev’s are doing within that mark 2 skill.

EDIT: Oh, hang on. that hardware volume is for the Adafruit. Oh well, the principle is the same. You just need to change the SUBSYSTEM and the ATTR vendor/product variables to the adafruit ones. Will see if I can dig them up from google, otherwise just dump that command straight into your systemd service :wink:

@j1nx thanks for the tip with i2cset I tested this and it works.

But I do not see how the udev rule should be set up / working on Subsystem USB.
The Adafruit is not connected to USB but only to I2C .
But what I did is:
Create a /etc/udev/rules.d/10-i2c-sound.rules with the content:

SUBSYSTEM==“i2c”, ATTR{name}==“bcm2835 I2C adapter”, RUN+=“/usr/sbin/i2cset -y 1 0x4b 30”

This is kind of blindly executing the command as soon as the I2C controller is seen but I do not see how I could use udev to checked if the AdaFruit is really there. The only thing I can get by running:

udevadm info -a -p /sys/bus/i2c/devices/i2c-1

is

looking at device ‘/devices/platform/soc/3f804000.i2c/i2c-1’:
KERNEL==“i2c-1”
SUBSYSTEM==“i2c”
DRIVER==“”
ATTR{name}==“bcm2835 I2C adapter”
looking at parent device ‘/devices/platform/soc/3f804000.i2c’:
KERNELS==“3f804000.i2c”
SUBSYSTEMS==“platform”
DRIVERS==“i2c-bcm2835”
ATTRS{driver_override}==“(null)”
looking at parent device ‘/devices/platform/soc’:
KERNELS==“soc”
SUBSYSTEMS==“platform”
DRIVERS==“”
ATTRS{driver_override}==“(null)”
looking at parent device ‘/devices/platform’:
KERNELS==“platform”
SUBSYSTEMS==“”
DRIVERS==“”

but the good think is: I works! So I think this is definitely a better solution as it kicks in a lot earlier than the systemd user service and the cracking sounds are not really disturbing during boot.

I will add that to the trac wiki

btw: trying to build the KDE plasma-workspace is driving my crazy. I did successfully build plasma-nano but I think I actually need to build plasma-workspace to start a plasma-shell.
But to be totally true I have very little knowledge of KDE. Maybe we find a way to work together on that before I loose my nerves.
I am not really sure why it is necessary to run this on plasma in the first place. In Sailfish OS where also everything is QML, Wayland and QT based we don’t use KDE as far as I see.

Thanks and have fun - Guhl

Yeah, sorry about the USB confusion I wasn’t reading properly, hence my edit, but guess was still unclear. :wink:

Anyhow…

Nice that you at least can run the command when it sees and loads the broadcom I2C adaptor. That is fine for you as you know for sure your ADA is there, but might be a bit more problematic for my supporting it in MycroftOS like that. If something else is connected to the I2S I expect monkey business.

Perhaps something is shown in “dmesg” as that is low level kernel stuff. Just run the command; dmesg and scroll through the message in search for I2S stuff. Perhaps you can get the IdVendor and IdProduct from there. If there is any offcourse…

About Plasma-Workspace: Reading through the code, it is only needed for the config headers and is used for Reboot and Shutdown code. So you can enable halt or reboot the device from the GUI.

If you strip that out and just use some enclosure Python code to handle the reboot and halt voice command, I guess you don’t need it.

Have a look at this commit;

Am posting my complete step by step guide to building a custom image I experimented with for the raspberry pi4 using ubuntu 18.04 minimal server and KDE Neon as base which includes all the required development packages to build Mycroft-GUI, Plasma-Nano, Mycroft-Gui-Mark-2 and other dependencies all from master branch without having to rebuild Qt or any other major KDE framework, or having to modify any repository . Link To Step By Step Guide: https://github.com/AIIX/Documentation/blob/master/Custom-RPI4-MycroftImage.md

This should also help anyone who’s building a custom OS/Image for the RPI4 to get an overview of the structure of the image and config files required.

5 Likes

@AIIX
Wow, this is super helpful!

If I would have had this earlier it would have saved me a probably a week of time but I am very thankful that you did not post it earlier because it also would have cost me a week of learning and experience!

Thanks for your support - have fun - Guhl

2 Likes

Hi,

I know, the pictures are not good, but this is the mycroft-gui running on plasma-nano on my PI3 based mark2 build:
gui_on_plasma_1 gui_on_plasma_2

This based on the build log of @AIIX and I re-documented it here Trac-Wiki mycroft-gui-mark-2_sys This is still work in progress but I will document my progress there.

I first tried to do this with Ubuntu server 20.04 but I could by no means get the SDDM up. So I used the same 18.04 image as AIIX.

Still a lot to polish but this is a by far easier way to get the GUI up than building all QT and KDE from sources.

Thanks again @AIIX !

Have fun - Guhl

3 Likes

@guhl Looking gooooooooood!

I think I speak for more if I say; We are all awaiting the video showcase of your Mark-2 patiently :wink:

@j1nx would you have an idea how to manage screen rotation with plasma/wayland/X11?
If I do the screen rotation in config.txt as shown above the screen is rotated until SDDM kicks in but then the PI crashes (did not investigate logs yet).
Is there a standard way on how to do screen rotation in X11/xrandr,… on the PI3?
Have fun - Guhl

xrandr --rotate left
Maybe?!

No, not by hard. Digging (deep) into memory, you most likely need to readout your modeline of your screen and setup a X11 configuration files with it.

I guess, the google words could be; “linux desktop portrait mode” (or something similar)

try setting the software rotation in mycroft-gui-mark-2 file to ‘Normal’ and rebuild and install: https://github.com/MycroftAI/mycroft-gui-mark-2/blob/cb5cf4da122b0fdfa023687ab8272a15558d3ae5/lookandfeel/contents/plasmoidsetupscripts/org.kde.mycroft.mark2.js#L2 additionally it seems you are still running the mycroft gui application and not the embed skill view in plasma-nano so it wont have affect on mycroft-gui application but on the shell itself

The possible rotation config values are defined here https://github.com/MycroftAI/mycroft-gui-mark-2/blob/2e50c204cf0911c400a4c0127d7ca1a20217269c/containments/mark2/package/contents/config/main.xml

Thank @AIIX
this might be a stupid question, but how do I run the embed skill view in plasma-nano?
I am still a little be lost here.
Have fun - Guhl

If you have copied over all the files from “7. Download Scripts/Overlays from RPI4 for Mycroft” part to the image and are booting into plasma nano it should already be running mycroft embedded.

Well then I might have missed something, I will check this again, …

@AIIX i double checked that I did copy everything.
Can you point out what exactly should bring up mycroft embedded?

Looking at your last addition on your wiki, you are installing both mycroft-gui and mycroft-gui-mark2 while it is actually either / or.

mycroft-gui == Desktop
mycroft-gui-mark-2 == Embedded

Perhaps we should opt for a reposiory rename of both;

mycroft-gui -> mycroft-gui-desktop
mycroft-gui-mark-2 -> mycroft-gui-embedded

The desktop variant is for “full blown” desktop evironments, where as the embedded variant is running directly onto the plasma shell and therefor integrated things as a onscreen keyboard, quick access to certain settings via sliding panel etc.

OK that clarifies something but I still don’t get what exactly is supposed to start the mycroft-gui-mark-2?

If I read all the files correctly from the devices overlay directories, it should autologin, auto start the mark2 plasma containment at boot.

If not, you could try to logouot of your X session and see if there is some sort of Mark2 session to log into?

But perhaps, indeed @AIIX could better explain it as above could be very wrong as it is all based on my own assumptions

sorry but in what file exactly do you see that it should auto start the mark2 plasma containment?
I have it autologin and it has a network connection but it just does not start anything and I just don’t see what file should start the plasma containment.
I just don’t have any KDE experience that’s why I am so lost here. 20 years of Gnome and GTK leave a trace :frowning:

I am sorry, going to leave that to AIIX as I have no experience with it either (yet).

It looks like all the overlay files configure to autologin with the mycroft user, with plasma-nano as default desktop (which look to be very minimal and only a shell) , whereas plasma-nano appears to be configured with the whole mark-2 look and feel stuff.

But how to get there if it doesn’t auto start at boot ? Sorry, no clue as well. In the end those thing always appear to be a missed file, a wong comma somewhere etc. :slight_smile: