Wait, more reading suggests that the error you’re getting may be because you’re trying to build a 64 bit kernel module in a 32 bit runtime. So, one option is setting the CROSS_COMPILE=aarch64-linux-gnu environment variable, and the other is basing your build environment around a 64 bit userspace.
FROM balenalib/raspberry-pi-debian-node:latest
RUN apt-get update && apt-get install -y curl wget build-essential libelf-dev awscli bc flex libssl-dev python bison
COPY . /usr/src/app
WORKDIR /usr/src/app
ENV CROSS_COMPILE aarch64-linux-gnu
ENV VERSION '2.50.1+rev1.prod'
#ENV VERSION '2.29.0+rev1.prod'
RUN ./build.sh raspberrypi4-64 $VERSION matrixio-kernel-modules/src
#RUN ./build.sh --list
CMD ./run.sh
I added that environment variable and these are the error messages
2020-06-01 22:01:31 (30.9 MB/s) - ‘kernel_modules_headers.tar.gz’ saved [11436144/11436144]
[main]
[main] make: Entering directory '/tmp/tmp.ZaKgB0TJGm'
[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] arch/arm64/Makefile:48: Detected assembler with broken .inst; disassembly will be unreliable
[main]
[main] ./scripts/gcc-version.sh: line 26: aarch64-linux-gnugcc: command not found
[main]
[main] ./scripts/gcc-version.sh: line 27: aarch64-linux-gnugcc: command not found
[main]
[main] make: aarch64-linux-gnugcc: Command not found
[main]
[main] make: aarch64-linux-gnugcc: Command not found
[main]
[main] make: aarch64-linux-gnugcc: Command not found
[main]
[main] make: aarch64-linux-gnugcc: Command not found
[main]
[main] CC [M] /usr/src/app/matrixio-kernel-modules/src_raspberrypi4-64_2.50.1+rev1.prod/matrixio-core.o
[main] /bin/sh: 1: aarch64-linux-gnugcc: not found
[main]
[main] make[1]: *** [scripts/Makefile.build:310: /usr/src/app/matrixio-kernel-modules/src_raspberrypi4-64_2.50.1+rev1.prod/matrixio-core.o] Error 127
[main]
[main] make: *** [Makefile:1519: _module_/usr/src/app/matrixio-kernel-modules/src_raspberrypi4-64_2.50.1+rev1.prod] Error 2
[main]
[main] make: Leaving directory '/tmp/tmp.ZaKgB0TJGm'
[main] Removing intermediate container 69fb096a29f2
[main] The command '/bin/sh -c ./build.sh raspberrypi4-64 $VERSION matrixio-kernel-modules/src' returned a non-zero code: 2
[Info] Uploading images
I have a raspberry pi 3 I can test this setup on. Ill try compiling it on there but hopefully I can get the pi 4 working.
Ahh yes, I see. We’d need to put all the cross-compilation tools in the build image too. Taking a step back (and I may have missed this in the history of this thread) why aren’t you building it in a 64-bit container? (ie replace FROM balenalib/raspberry-pi-debian-node:latest with FROM balenalib/rraspberrypi4-64-debian-node:latest)
Typo warning: I meant FROM balenalib/raspberrypi4-64-debian-node:latest. Also, if you rename your Dockerfile to Dockerfile.template you can just do FROM balenalib/%%BALENA_MACHINE_NAME%%-debian-node:latest and it’ll use the right one for the app arch.
That’s great news. You should also be able to replace the instance of raspberrypi4-64 in your build.sh line with %%BALENA_MACHINE_NAME%% too, as it just does a simple search and replace. I look forward to hearing how it went.
I get this error message: N: Skipping acquire of configured file 'main/binary-arm64/Packages' as repository 'https://apt.matrix.one/raspbian buster InRelease' doesn't support architecture 'arm64'
So I think I need a 32 bit system running in either the container or a 32bit balenaOS installation. Im not sure which. Or if these packages are open source I think I will need to compile them myself.
Hi,
Thanks for the update. You could certainly try a 32-bit container (on the x86_64 hardware with a 64-bit balenaOS foundation) first since that’s likely faster than re-imaging the device. An example can be found here.
jimsynz had pointed out earlier in the thread that compiling kernel modules for a 64 bit OS must be done in a 64 bit container. I clicked add device in the balenaCloud dashboard and there weren’t any options for downloading a 32bit OS for the raspberry pi. Do you have any 32 bit images?
Hi, if you want to use a 32 bit OS image then you need to create another app. There is a different device type for the 32 bits os image for the rpi3. Let us know if that works for you
I’ve switched to a 32 bit OS per floion’s suggestion, which allowed me to install the apt packages as normal. Also, I’ve done the steps @zvin recommended. The kernel modules build and the sound device shows up in alsa now, but none of the mic examples work now and I get errors when I try recording through arecord. Is it possible that I am missing some other kernel module related to sound?
root@5a54ff0:/usr/src/app# rec test.wav
rec WARN alsa: can't encode 0-bit Unknown or not applicable
rec FAIL formats: can't open input `default': snd_pcm_open error: Invalid argument
Matrix-hal-examples mic demos:
root@5a54ff0:/usr/src/app/matrix-creator-hal/build/demos# ./direction_of_arrival_demo_direct
INFO: [/dev/matrixio_regmap] was opened
Kernel Modules has been loaded. Use ALSA examples
Segmentation fault (core dumped)
root@5a54ff0:/usr/src/app/matrix-creator-hal/build/demos# ./micarray_recorder_direct
INFO: [/dev/matrixio_regmap] was opened
Kernel Modules has been loaded. Use ALSA implementation
In the demos, while its not longer saying can’t send spi message, its still not receiving any audio data.
Hi @airfield20 – thanks for the additional info. There are a couple of things I would suggest checking:
How are you checking that the modules are being loaded successfully? Are you able to share the output from that check?
I might suggest that you append lsmod at the end of your run.sh script; that way, it will be logged at container startup, and you’ll be able to check it on the device dashboard.
I’d also suggest changing the shebang at the top to #!/bin/bash -x so that it will log the commands it’s running; if one particular module is failing, you’ll be able to easily see what’s going on.
I might suggest also including the modprobe commands in that script as well, just to simplify things a bit.
Can you give that those things a try and let us know how it goes?