# "can't send spi message" error when running Matrix Creator examples on resinOS

**URL:** <https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267>\
**Category:** Product support\
**Tags:** raspberrypi3\
**Created:** [June 2, 2018, 6:52am UTC](https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267 "2018-06-02T06:52:30Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![pcg108](https://avatars.discourse-cdn.com/v4/letter/p/a183cd/32.png) [@pcg108](https://forums.balena.io/u/pcg108)\
**Post date:** [June 2, 2018, 6:52am UTC](https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267/1 "2018-06-02T06:52:30Z")

</div>

Hello,

I am using a Raspberry Pi 3 with a Matrix Creator board. Using the Matrix documentation [here](https://github.com/matrix-io/matrix-creator-hal) I installed the necessary dependencies for the board through the dockerfile and tried to run the “mic\_energy\_direct” demo [here](https://github.com/matrix-io/matrix-creator-hal/blob/master/demos/mic_energy_direct.cpp).

However, I get the following output when running any of the matrix examples that involve the microphones:  
“can’t send spi message”

Any help would be greatly appreciated. Thank you!

---

<div class="post-metadata">

**Author:** ![pcg108](https://avatars.discourse-cdn.com/v4/letter/p/a183cd/32.png) [@pcg108](https://forums.balena.io/u/pcg108)\
**Post date:** [June 9, 2018, 11:42pm UTC](https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267/4 "2018-06-09T23:42:43Z")

</div>

Also, here is my full dockerfile installing matrix dependencies, for reference. The forum does not seem to allow me to post it in text due to it having more than two links in it:

 ![17%20PM](https://global.discourse-cdn.com/balena/original/2X/7/702f4a71f0e6f64025ed4b9cc32a17572d2c8ca0.png)

---

<div class="post-metadata">

**Author:** ![pcarranzav](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pcarranzav/32/94_2.png) [@pcarranzav](https://forums.balena.io/u/pcarranzav)\
**Post date:** [June 11, 2018, 12:20am UTC](https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267/5 "2018-06-11T00:20:04Z")

</div>

Hi @pcg108 - I can think of two things to try, judging from this: [https://github.com/matrix-io/matrix-creator-quickstart/wiki/enable-spi](https://github.com/matrix-io/matrix-creator-quickstart/wiki/enable-spi) and looking at how raspi-config works:

1. Ensure that SPI is enabled. This is true by default in recent resinOS versions (what version are you using?). In the resin dashboard’s “Device configuration” page, check that “Define DT parameters / RESIN\_HOST\_CONFIG\_dtparam” includes “spi=on” - default is `"i2c_arm=on","spi=on","audio=on"` and if that is set then it should be fine.

2. Ensure that the SPI kernel module is loaded, by changing your CMD line in the Dockerfile to:

```auto
CMD modprobe spi-bcm2708 && python3 src/loop.py

```

(I’m not sure if it’s `spi-bcm2708` or `spi_bcm2708` so maybe try the second one if the first one doesn’t work)

---

<div class="post-metadata">

**Author:** ![pcg108](https://avatars.discourse-cdn.com/v4/letter/p/a183cd/32.png) [@pcg108](https://forums.balena.io/u/pcg108)\
**Post date:** [June 11, 2018, 1:44am UTC](https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267/6 "2018-06-11T01:44:15Z")

</div>

Hi @pcarranzav thank you for your reply! I double checked the device configuration and spi is indeed on, and I did step 2 as well (I had to change it to spi-bcm2835 since apparently the kernel module has been updated from spi-bcm2708 according to [this](https://raspberrypi.stackexchange.com/questions/46172/rpi3-missing-spi-bcm2708-module))

---

<div class="post-metadata">

**Author:** ![pcarranzav](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pcarranzav/32/94_2.png) [@pcarranzav](https://forums.balena.io/u/pcarranzav)\
**Post date:** [June 11, 2018, 10:19pm UTC](https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267/7 "2018-06-11T22:19:59Z")

</div>

Hi @pcg108 - another idea. It seems like you need to program the FPGA on the Matrix on every boot, and this is handled by the matrixio-creator-init package [https://github.com/cmetz/matrix-creator-init](https://github.com/cmetz/matrix-creator-init) - but this works by starting a systemd service, and you don’t have systemd enabled in your container.

So I think what you could try is to start the script from that package manually:

```auto
CMD /usr/share/matrixlabs/matrixio-devices/matrix-init.bash && python3 src/loop.py

```

(Alternatively, you could enable systemd in your container by setting `ENV INITSYSTEM on`, and I think that would automatically start the service for you, but dunno if it would have other side effects in this case)

---

<div class="post-metadata">

**Author:** ![pcg108](https://avatars.discourse-cdn.com/v4/letter/p/a183cd/32.png) [@pcg108](https://forums.balena.io/u/pcg108)\
**Post date:** [June 12, 2018, 5:02am UTC](https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267/8 "2018-06-12T05:02:36Z")

</div>

Interesting, I tried this and I get the following:

INFO: [/dev/spidev0.0] was opened  
MATRIX device has not been detected

Then when I try running even the LED demos which used to work, they no longer work since the Matrix Creator is not detected. Also in my dockerfile there was an

ENV INITSYSTEM on

already, and when I removed it the FPGA was reprogrammed but the same error (can’t send spi message) appears to be there

---

<div class="post-metadata">

**Author:** ![pcarranzav](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pcarranzav/32/94_2.png) [@pcarranzav](https://forums.balena.io/u/pcarranzav)\
**Post date:** [June 12, 2018, 11:16pm UTC](https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267/10 "2018-06-12T23:16:48Z")

</div>

@pcg108 that sounds odd.  
Maybe try running it all after a reboot? Just to make sure it’s all starting from a clean state, I don’t know how the Creator works in that sense.

There’s also this: [https://github.com/cmetz/matrix-creator-init/blob/master/matrix-mics.conf](https://github.com/cmetz/matrix-creator-init/blob/master/matrix-mics.conf) so another thing to try would be to modprobe those two modules too (though I can’t quite see how that would relate with an SPI message failing)

---

<div class="post-metadata">

**Author:** ![sqweelygig](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/sqweelygig/32/150_2.png) [@sqweelygig](https://forums.balena.io/u/sqweelygig)\
**Post date:** [June 25, 2018, 4:57pm UTC](https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267/20 "2018-06-25T16:57:05Z")

</div>

Hi there!  
Did you get a chance to dig into the suggestions from Pablo, we’re keen to get to this worked out, but need some help from your end.

---

<div class="post-metadata">

**Author:** ![airfield20](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@airfield20](https://forums.balena.io/u/airfield20)\
**Post date:** [May 28, 2020, 2:37am UTC](https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267/23 "2020-05-28T02:37:15Z")

</div>

> [@sqweelygig](#):
>
> dig into the suggestions fr

Hi was this ever solved? I am trying to also use matrix-hal with balena.

---

<div class="post-metadata">

**Author:** ![CameronDiver](https://avatars.discourse-cdn.com/v4/letter/c/2acd7d/32.png) [@CameronDiver](https://forums.balena.io/u/CameronDiver)\
**Post date:** [May 28, 2020, 8:32am UTC](https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267/24 "2020-05-28T08:32:53Z")

</div>

Hey, are you having the exact same issue as the one presented above? We can try to debug your issues too, but we’ll need some further information. If the issue is sufficiently different it’s probably worth starting a new forum thread.

---

<div class="post-metadata">

**Author:** ![airfield20](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@airfield20](https://forums.balena.io/u/airfield20)\
**Post date:** [May 29, 2020, 12:14am UTC](https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267/26 "2020-05-29T00:14:45Z")

</div>

> [@pcg108](#):
>
> However, I get the following output when running any of the matrix examples that involve the microphones:  
> “can’t send spi message”

This was the original issue, so yes I am having the exact same issue when trying to read microphone data. I’ve created a slightly modified version of the above dockerfile based on balenas official systemd based image, which allowed my to install matrixio-creator-init. I also have privileged mode enabled in my docker compose file.

These modifications allow me to control the led lights and read from the other sensors, but it doesn’t allow me to read any data from the microphones. It just says cannot send spi message.

---

<div class="post-metadata">

**Author:** ![airfield20](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@airfield20](https://forums.balena.io/u/airfield20)\
**Post date:** [May 29, 2020, 12:27am UTC](https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267/27 "2020-05-29T00:27:10Z")

</div>

Here is the exact setup I am using. [https://github.com/airfield20/Matrix-Creator-BalenaOS](https://github.com/airfield20/Matrix-Creator-BalenaOS)  
I would also like to be able to install the matrixio-kernel-modules package, but im not sure how exactly.

The repo for the kernel modules is here [https://github.com/matrix-io/matrixio-kernel-modules](https://github.com/matrix-io/matrixio-kernel-modules) . The repo states “This drivers **only** works with current stock raspbian kernel.”. How similar is this kernel to the stock raspberry kernel? If it is too dissimilar then is there any way to use the stock raspbian kernel or maybe even emulate it to get this device working?

Thank you for any help you may be able to provide.

---

<div class="post-metadata">

**Author:** ![gelbal](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/gelbal/32/1109_2.png) [@gelbal](https://forums.balena.io/u/gelbal)\
**Post date:** [May 29, 2020, 12:17pm UTC](https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267/30 "2020-05-29T12:17:19Z")

</div>

Hi @airfield20, sounds like you need to install out-of-tree kernel modules to get the microphone working. We have an example project to help you on that front: [GitHub - balena-os/kernel-module-build: Example project for building an OOT kernel module in balena](https://github.com/balena-os/kernel-module-build/)

Then this topic of building out-of-tree kernel modules is coming up quite frequently lately. I asked my teammates to write a blog post about it.

> "This drivers only works with current stock raspbian kernel.”. How similar is this kernel to the stock raspberry kernel?

We are using the Raspberry Pi Foundation kernel at [GitHub - raspberrypi/linux: Kernel source tree for Raspberry Pi-provided kernel builds. Issues unrelated to the linux kernel should be posted on the community forum at https://forums.raspberrypi.com/](https://github.com/raspberrypi/linux)

As far as we know, raspbian packages this kernel but it may lag behind.

So I suggest trying out building the kernel module yourself. Let us know how it goes and if you run into a specific issue.

---

<div class="post-metadata">

**Author:** ![airfield20](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@airfield20](https://forums.balena.io/u/airfield20)\
**Post date:** [May 29, 2020, 12:40pm UTC](https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267/32 "2020-05-29T12:40:28Z")

</div>

Thanks, I have been working on this manual installation for some time. I will let you know how it goes. The original issue still remains though, issues using SPI. Even though lights and sensors are working, any attempt to read microphone data using matrix hal returns “can’t send spi message”. Do you have any advice for this issue?

---

<div class="post-metadata">

**Author:** ![zvin](https://avatars.discourse-cdn.com/v4/letter/z/a5b964/32.png) [@zvin](https://forums.balena.io/u/zvin)\
**Post date:** [May 29, 2020, 1:36pm UTC](https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267/33 "2020-05-29T13:36:55Z")

</div>

@airfield20 have you enabled spi in the `config.txt` file like described here [https://www.balena.io/docs/learn/develop/hardware/i2c-and-spi/#spi](https://www.balena.io/docs/learn/develop/hardware/i2c-and-spi/#spi) ?

---

<div class="post-metadata">

**Author:** ![airfield20](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@airfield20](https://forums.balena.io/u/airfield20)\
**Post date:** [May 29, 2020, 1:52pm UTC](https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267/35 "2020-05-29T13:52:18Z")

</div>

That documentation states that it is enabled by default. I did check the device parameter through balenaos and it is at the default setting. Also in an earlier attempt i installed raspi-config in the container and enabled spi but to no avail. The issue was still present.

---

<div class="post-metadata">

**Author:** ![zvin](https://avatars.discourse-cdn.com/v4/letter/z/a5b964/32.png) [@zvin](https://forums.balena.io/u/zvin)\
**Post date:** [May 29, 2020, 2:11pm UTC](https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267/36 "2020-05-29T14:11:13Z")

</div>

You’ll need to build [https://github.com/matrix-io/matrixio-kernel-modules](https://github.com/matrix-io/matrixio-kernel-modules) like in this example [https://github.com/balena-os/kernel-module-build/](https://github.com/balena-os/kernel-module-build/) .  
Once you have a kernel module built, you’ll need to `insmod` it from a privileged container.  
The build should also create a `matrixio.dtbo` file that you will need to place in the `overlays` folder of the boot partition of your SD card.  
You will also need to update the `config.txt` file in the boot partition of the sd card to add `dtoverlay=matrixio`.

---

<div class="post-metadata">

**Author:** ![zvin](https://avatars.discourse-cdn.com/v4/letter/z/a5b964/32.png) [@zvin](https://forums.balena.io/u/zvin)\
**Post date:** [May 29, 2020, 2:15pm UTC](https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267/37 "2020-05-29T14:15:45Z")

</div>

I don’t think you need to run `systemd` in your container.

---

<div class="post-metadata">

**Author:** ![airfield20](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@airfield20](https://forums.balena.io/u/airfield20)\
**Post date:** [June 1, 2020, 8:19pm UTC](https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267/39 "2020-06-01T20:19:25Z")

</div>

![image](https://global.discourse-cdn.com/balena/original/2X/4/4d30f8bb76d80f7ab9175eb2d8d4fdc1db437af5.png)

Sorry for the late response, it took me a minute to figure out the correct Balena\_machine\_name and version string to use. The image is showing the results of build.sh using  
`ENV VERSION '2.50.1+rev1.prod' `  
`RUN ./build.sh raspberrypi4-64 $VERSION matrixio-kernel-modules/src`  
in the Dockerfile.

The list of errors are:

```auto
[main] make: Entering directory '/tmp/tmp.d6J9bceBy8'
[main] arch/arm64/Makefile:27: ld does not support --fix-cortex-a53-843419; kernel may be susceptible to erratum
[main]     
[main] arch/arm64/Makefile:40: LSE atomics not supported by binutils
[main]     
[main] CC [M] /usr/src/app/matrixio-kernel-modules/src_raspberrypi4-64_2.50.1+rev1.prod/matrixio-core.o
[main] gcc: error: unrecognized command line option '-mgeneral-regs-only'

```

I haven’t found much info on those errors so far. Could you point me in the right direction? Thanks

---

<div class="post-metadata">

**Author:** ![jimsynz](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/jimsynz/32/4663_2.png) [@jimsynz](https://forums.balena.io/u/jimsynz)\
**Post date:** [June 1, 2020, 9:06pm UTC](https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267/40 "2020-06-01T21:06:59Z")

</div>

Hi @airfield20,

Boy, there’s a lot of history for me to read on this one. Specifically about the `LSE atomics not supported by binutils` error; is the build environment based on Alpine? That’s my first guess. My googling for this error seems to be related to building kernels for NVIDIA machines which I am not sure are relevant.

If it is alpine can you try building in a Debian-based container instead?

Cheers,  
James.

[Next page](https://forums.balena.io/t/cant-send-spi-message-error-when-running-matrix-creator-examples-on-resinos/3267.md?page=2)
