gnumpi/esphome_matrixio

Compile Error

Closed this issue · 10 comments

Hello, this is an amazing project that I wanted to try immediately. I did the steps on the raspberry pi which the matrix voice is connected to.

Unfortunately, I get the following error:

It seems that the matrixio componen is not in the .venv folder. I am not familiar with the venv at all unfortunately.

This raspberry pi still runs under Buster: Linux matrixpi 5.10.63-v7l+ #1459 SMP Wed Oct 6 16:41:57 BST 2021 armv7l GNU/Linux

(.venv) pi@matrixpi:~/esphome_matrixio$ esphome compile matrix_voice.yaml
INFO Reading configuration matrix_voice.yaml...
ERROR Unable to load component matrixio:
Traceback (most recent call last):
  File "/home/pi/esphome_matrixio/.venv/lib/python3.7/site-packages/esphome/loader.py", line 162, in _lookup_module
    module = importlib.import_module(f"esphome.components.{domain}")
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "esphome/components/matrixio/__init__.py", line 16, in <module>
    CONFIG_SCHEMA = spi.spi_device_schema(True, "8MHz").extend(
TypeError: spi_device_schema() takes from 0 to 1 positional arguments but 2 were given
ERROR Unable to load component matrixio.light:
Traceback (most recent call last):
  File "/home/pi/esphome_matrixio/.venv/lib/python3.7/site-packages/esphome/loader.py", line 162, in _lookup_module
    module = importlib.import_module(f"esphome.components.{domain}")
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "esphome/components/matrixio/__init__.py", line 16, in <module>
    CONFIG_SCHEMA = spi.spi_device_schema(True, "8MHz").extend(
TypeError: spi_device_schema() takes from 0 to 1 positional arguments but 2 were given
Failed config

matrixio: [source matrix_voice.yaml:36]

  Component not found: matrixio.
  id: matrixio_dev
  cs_pin: GPIO23
light.matrixio: [source matrix_voice.yaml:40]

  Platform not found: 'light.matrixio'.
  platform: matrixio
  name: everloop
  id: everloop
  on_turn_on:
    - light.turn_on:
        id: everloop
        red: 20%
        green: 0%
        blue: 0%
        white: 0%
    - voice_assistant.start:
        silence_detection: False
  on_turn_off:
    - voice_assistant.stop:
microphone: [source matrix_voice.yaml:57]

  Component not found: microphone.
  - platform: matrixio
    id: matrixio_mic
speaker: [source matrix_voice.yaml:61]

  Component not found: speaker.
  - platform: matrixio
    id: matrixio_speaker_hp
voice_assistant: [source matrix_voice.yaml:65]

  Component not found: voice_assistant.
  microphone: matrixio_mic
  speaker: matrixio_speaker_hp
  on_listening:
    - light.turn_on:
        id: everloop
        blue: 100%
        red: 0%
        green: 0%
        brightness: 60%
(.venv) pi@matrixpi:~/esphome_matrixio$
gnumpi commented

It seems you got an older version of ESPHome as the current version requires Python >= 3.9. Please verify:

esphome version
python --version

You could try installing a newer version of python on your system or build the esp firmware within a Docker container. Let me know if you need help with that.

I guess I do need the help...

I tried to install a newer version of python but ran into a multitude of other problems. I decided to start from scratch and installed a fresh Raspberry Pi OS (Bookworm). I was able to build the esphome firmware. But I am struggling to install the MatrixIO stuff (https://github.com/qnlbnsl/Matrix-IO/). I did not even try to install the "official" MATRIX repository (as I assume it is broken anyway).

Can you give a step-by-step instructions?

I've copied the git folder and executed install.sh / build.sh / prereqs.sh / build-prereqs.sh in different orders. install.sh always fails to install:

dpkg: dependency problems prevent configuration of matrixio-creator-init:
 matrixio-creator-init depends on esptool; however:
  Package esptool is not installed.

But I have verified that esptool is indeed installed?

gnumpi commented

I see, @qnlbnsl changed the configuration of the matrix-creator-init package to be dependent on the esptool debian package, which is not part of the default apt repository. You can ask him which repository you should add for installing the esptool package. As an alternative, you can remove the dependency in matrix-creator-init. You mentioned that you already installed esptool manually. If 'which esptool.py' gives your correct path, you can remove 'esptool' from ../src/matrix-creator-init/debian/control and rebuild and reinstall the packages.

Thank you for your help. I am struggling with this a lot, my knowledge is a little sub-par.

When I try to do build.sh there is an error

pi@matrixpi:~/Matrix-IO $ sh build.sh
starting builds
Building JimTCL...
build.sh: 8: cd: can't cd to /home/pi/Matrix-IO/src/jimtcl

Now it seems that init.sh is downloading some sources.

But when I do init.sh:

pi@matrixpi:~/Matrix-IO $ sh init.sh
Downloading source code...
Cloning into 'matrix-creator-hal'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Cloning into 'matrix-creator-init'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Cloning into 'matrixio-kernel-modules'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Cloning into 'matrix-lite-py'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Cloning into 'matrix-creator-openocd'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Cloning into 'xc3sprog'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Is there a way to install esptool as a debian package? Google is not helpful on this one unfortunately.

Thanks again!!

that is weird... so the shell scripts in the repo. I have not documented it yet but they are meant to setup the build env. install.sh should install all packages, schedule the reboot, etc.... @chiefymuc I would recommend not using the scripts unless you are planning to build things yourself.
Also, this is important. possibly the one thing that kept breaking things for me.
change the /boot/config.txt to have
arm_64bit=0
This will set rasbian to load up kernel7l which has the sources. The kernel v8 does not have the sources available as such the kernel modules fail to install

gnumpi commented

If I remember correctly I managed to install the kernel modules with arm_64bit=1 and kernel v8. I will check that later. But if you want to flash the ESP32 only, you don't even need the kernel modules. The package matrix-creator-init is all you need.
I have to leave now, I might find some time on the weekend to look into it.

Ok so when I simply do 'sh install.sh" I get the following:

(still with arm_64bit=1)

pi@matrixpi:~/Matrix-IO $ sh install.sh
install.sh: 4: Bad substitution
Usage: install.sh [arm64|armhf]

As I am on Raspberry Pi 4 I believe that arm64 is the correct choice, right?

So then I get:

pi@matrixpi:~/Matrix-IO $ sh install.sh arm64
install.sh: 4: Bad substitution
Installing dependencies...
Installing /home/pi/Matrix-IO/deps/arm64/libreadline6_6.3-8ubuntu2_arm64.deb...
(Reading database ... 200018 files and directories currently installed.)
Preparing to unpack .../libreadline6_6.3-8ubuntu2_arm64.deb ...
Unpacking libreadline6:arm64 (6.3-8ubuntu2) over (6.3-8ubuntu2) ...
Setting up libreadline6:arm64 (6.3-8ubuntu2) ...
Processing triggers for libc-bin (2.36-9+rpt2+deb12u3) ...
Installing /home/pi/Matrix-IO/deps/arm64/wiringpi-2.61-1-arm64.deb...
(Reading database ... 200018 files and directories currently installed.)
Preparing to unpack .../wiringpi-2.61-1-arm64.deb ...
Unpacking wiringpi (2.61) over (2.61) ...
Setting up wiringpi (2.61) ...
/bin/chown: warning: '.' should be ':': ‘root.root’
Processing triggers for man-db (2.11.2-2) ...
Installing packages from build folder...
Installing /home/pi/Matrix-IO/build/matrix-creator-hal/arm64/libmatrixio-creator-hal-dev_0.3.8_arm64.deb...
(Reading database ... 200018 files and directories currently installed.)
Preparing to unpack .../libmatrixio-creator-hal-dev_0.3.8_arm64.deb ...
Unpacking libmatrixio-creator-hal-dev (0.3.8) over (0.3.8) ...
Setting up libmatrixio-creator-hal-dev (0.3.8) ...
Installing /home/pi/Matrix-IO/build/matrix-creator-hal/arm64/libmatrixio-creator-hal_0.3.8_arm64.deb...
(Reading database ... 200018 files and directories currently installed.)
Preparing to unpack .../libmatrixio-creator-hal_0.3.8_arm64.deb ...
Unpacking libmatrixio-creator-hal:arm64 (0.3.8) over (0.3.8) ...
Setting up libmatrixio-creator-hal:arm64 (0.3.8) ...
Installing /home/pi/Matrix-IO/build/matrix-creator-openocd/arm64/matrixio-openocd_1.0.1.002_arm64.deb...
(Reading database ... 200018 files and directories currently installed.)
Preparing to unpack .../matrixio-openocd_1.0.1.002_arm64.deb ...
Unpacking matrixio-openocd (1.0.1.002) over (1.0.1.002) ...
Setting up matrixio-openocd (1.0.1.002) ...
Processing triggers for man-db (2.11.2-2) ...
Installing /home/pi/Matrix-IO/build/xc3sprog/arm64/matrixio-xc3sprog_1.1.1.003_arm64.deb...
(Reading database ... 200018 files and directories currently installed.)
Preparing to unpack .../matrixio-xc3sprog_1.1.1.003_arm64.deb ...
Unpacking matrixio-xc3sprog (1.1.1.003) over (1.1.1.003) ...
Setting up matrixio-xc3sprog (1.1.1.003) ...
Installing /home/pi/Matrix-IO/build/matrix-creator-init/arm64/matrixio-creator-init_0.4.17_arm64.deb...
Selecting previously unselected package matrixio-creator-init.
(Reading database ... 200018 files and directories currently installed.)
Preparing to unpack .../matrixio-creator-init_0.4.17_arm64.deb ...
Unpacking matrixio-creator-init (0.4.17) ...
dpkg: dependency problems prevent configuration of matrixio-creator-init:
 matrixio-creator-init depends on esptool; however:
  Package esptool is not installed.

dpkg: error processing package matrixio-creator-init (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 matrixio-creator-init
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... Done
The following packages will be REMOVED:
  matrixio-creator-init
0 upgraded, 0 newly installed, 1 to remove and 13 not upgraded.
1 not fully installed or removed.
After this operation, 1,997 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 200052 files and directories currently installed.)
Removing matrixio-creator-init (0.4.17) ...
@reboot pi /home/pi/Matrix-IO/install_kernel_modules.sh arm64
Rebooting the system...

Broadcast message from root@matrixpi on pts/1 (Fri 2023-11-17 18:55:39 CET):

The system will reboot now!

Thanks again for all your help. I will pay back by writing a Step-by-step setup guide once this is figured out :)

@chiefymuc not necessarily. The confusion stems from the fact that rpi4 still calls itself 64bit even if you were to install a 32bit system. the selection is dependent on what OS you installed. If you installed regular rasbian then you would want to select arm64. I have not tested much with that right now and am using the 32 bit rasbian lite.
as far as esptool goes. Try running:
sudo apt-get install esptool OR sudo apt-get install python-esptool. Also, let's move the conversation to my repository such as to not hijack this issue.

Continued here: qnlbnsl/Matrix-IO#1

I'm closing this issue as I was helped over at @qnlbnsl repository.