Adding kernel modules (1-wire sensors) - also compiling coreelec

I want to connect a DS18B20 thermal sensor to my odroid-c2 running CoreELEC. It’s supported via the w1_gpio and w1_therm kernel modules, but CoreELEC does not include them in the distribution. For the record, in raspbian these kernel modules take about 256k of disk space.

My first attempt was to try to rebuild a CoreELEC image, and then just copy the kernel modules over to see if that would work. I cloned the github repo, checked out tag 9.0.2 (current release), and ran “make” in the repo. It started building, and many things built correctly include the linux kernel, but runs into trouble when compiling u-boot-LePotato. I’ve put a log file up at but it seems to be related to libfdt.h, it’s somehow apparently pulling in my local copy of header files instead of the dev environment ones.

So that’s problem number 1.

I figured that even though u-boot-LePotato doesn’t build, the kernel does, so I can just modify the kernel configuration and recompile that. However, when I try to run “make menuconfig” within the linux-${SHA256SUM} folder, I get
make: *** No rule to make target linux-${SHA256SUM}//arch/Makefile. Stop.

I’m guessing this is because the kernel is being cross-compiled, and I’m not specifying that, but I don’t know how to specify the cross-compilation details for the linux kernel. Is there an easy way to adjust the kernel configuration within CoreELEC?

Okay, I worked out the command for menuconfig, it is
make menuconfig ARCH=arm64 HOSTCC=…/toolchain/bin/host-gcc HOSTCXX=…/toolchain/bin/host-g++

With that, I was then able to build the linux kernel (and modules) with w1_gpio and w1_therm modules. Since the system is read-only on CoreELEC, I copied the module files to flash, and used insmod ./w1-gpio.ko to load them, and they loaded fine. I have not yet tested them, as I did this remotely and still need to connect an actual thermal sensor, but this part appears to be working.

Slow progress recently. The w1-gpio master is not being detected, probably because the device tree doesn’t have a onewire section. I’m fiddling around with adding the onewire section from Armbian, or from the hardkernel sources, but I’m not as yet having any luck with getting it noticed.

Have you read this: ?

Yup, but the problem is that those instructions expect you to already have a onewire section in your FDT, which is not true in CoreELEC (fdtget /flash/dtb.img /onewire gpios gives FDT_ERR_NOTFOUND). I’ve tried modifying boot.ini to load the overlay (meson-w1-gpio.dtbo) but all attempts to do that resulted in a non-booting C2. I’ve also tried adding “fdt put” commands in boot.ini, this results in a booting system that has some /onewire parts in the FDT, but the kernel complains about not being able to find the phandle, which seems to be a result of not properly loading the overlay but manually inserting only bits and pieces of the fdt. I’m not that hugely fussed about this, so I’m tempted to just fast-forward my plans to get an rpi zero to control the lighting, and use that for the temp sensor as well, as at this point I think it’s a simpler way forward.

Core922:~ # fdtget /flash/dtb.img /onewire gpios
25 63 0

CoreELEC:/flash # fdtget /flash/dtb.img /onewire gpios
Error at ‘/onewire’: FDT_ERR_NOTFOUND

That’s the message I get on my C2.

Have you tried modprobe w1-gpio && modprobe w1-therm?
It should work.
Which build you use?
I tried in latest nightly on my N2.

With the CoreELEC image, neither of those modules exist. If I build them manually and copy them over, I can insmod them, and dmesg shows “Driver for 1-wire Dallas network protocol.”, but the master is not detected (nor any slave devices).

This is all with the latest stable, on a C2, not N2.

That’s right, there is no onewire entry in the 3.14 kernel DTBs.