Driver compilation failed for Fusion Hat

I’ve recently bought the Fusion Hat and am trying to use it with my Raspberry Pi 3.

I’ve tried installing under Raspian Bullseye (Debian 11) and Raspian Bookworm (Debian 12) and keep getting the following errors in the install log and the installation script shows failure for compiling the driver:

✗ Compile driver

Building Fusion Hat driver and device tree overlay…
make -C /lib/modules/5.10.103-v7+/build M=/home/pi/fusion-hat/driver modules
make[1]: Entering directory ‘/usr/src/linux-headers-5.10.103-v7+’
CC [M] /home/pi/fusion-hat/driver/i2c.o
CC [M] /home/pi/fusion-hat/driver/adc.o
CC [M] /home/pi/fusion-hat/driver/battery.o
/home/pi/fusion-hat/driver/battery.c: In function ‘fusion_hat_battery_init’:
/home/pi/fusion-hat/driver/battery.c:192:5: warning: ISO C90 forbids mixed decl>
192 | struct power_supply_config psy_cfg = {};
| ^~~~~~
CC [M] /home/pi/fusion-hat/driver/shutdown.o
CC [M] /home/pi/fusion-hat/driver/pwm.o
/home/pi/fusion-hat/driver/pwm.c: In function ‘period_store’:
/home/pi/fusion-hat/driver/pwm.c:155:3: warning: ISO C90 forbids mixed declarat>
155 | uint32_t frequency = 1000000 / period;
| ^~~~~~~~
/home/pi/fusion-hat/driver/pwm.c: In function ‘fusion_hat_pwm_probe’:
/home/pi/fusion-hat/driver/pwm.c:374:55: warning: passing argument 2 of ‘kobjec>
374 | ret = kobject_init_and_add(&pwm_channels[i].kobj, &pwm_channel_ktyp>
| ^~~~~~~~~~~~~~~~~~
In file included from ./include/linux/energy_model.h:7,
from ./include/linux/device.h:16,
from /home/pi/fusion-hat/driver/main.h:12,
from /home/pi/fusion-hat/driver/pwm.c:10:
./include/linux/kobject.h:99:44: note: expected ‘struct kobj_type *’ but argume>
99 | struct kobj_type *ktype, struct kobject *paren>
| ~~~~~~~~~~^
CC [M] /home/pi/fusion-hat/driver/button.o
/home/pi/fusion-hat/driver/button.c: In function ‘fusion_hat_button_poll_work’:
/home/pi/fusion-hat/driver/button.c:35:5: warning: ISO C90 forbids mixed declar>
35 | int ret = fusion_hat_i2c_read_byte(dev->client, CMD_READ_BUTTON_STA>
| ^
/home/pi/fusion-hat/driver/button.c:45:5: warning: ISO C90 forbids mixed declar>
45 | bool current_state = (button_status & 0x01);
| ^~
CC [M] /home/pi/fusion-hat/driver/led.o
CC [M] /home/pi/fusion-hat/driver/speaker.o
CC [M] /home/pi/fusion-hat/driver/main.o
/home/pi/fusion-hat/driver/main.c: In function ‘fusion_hat_probe’:
/home/pi/fusion-hat/driver/main.c:178:53: error: macro “class_create” requires >
178 | fusion_dev->class = class_create(FUSION_HAT_NAME);
| ^
In file included from ./include/linux/device.h:31,
from ./include/linux/acpi.h:15,
from ./include/linux/i2c.h:13,
from /home/pi/fusion-hat/driver/main.c:2:

./include/linux/device/class.h:259: note: macro “class_create” defined here

259 | #define class_create(owner, name)
|
/home/pi/fusion-hat/driver/main.c:178:25: error: ‘class_create’ undeclared (fir>
178 | fusion_dev->class = class_create(FUSION_HAT_NAME);
| ^~~~~~~~~~~~
| vfs_create
/home/pi/fusion-hat/driver/main.c:178:25: note: each undeclared identifier is r>
/home/pi/fusion-hat/driver/main.c: At top level:
/home/pi/fusion-hat/driver/main.c:338:14: error: initialization of ‘int ()(str>
338 | .probe = fusion_hat_probe,
| ^~~~~~~~~~~~~~~~
/home/pi/fusion-hat/driver/main.c:338:14: note: (near initialization for ‘fusio>
/home/pi/fusion-hat/driver/main.c:339:15: error: initialization of ‘int (
)(str>
339 | .remove = fusion_hat_remove,
| ^~~~~~~~~~~~~~~~~
/home/pi/fusion-hat/driver/main.c:339:15: note: (near initialization for ‘fusio>
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:280: /home/pi/fusion-hat/driver/main.o] Er>
make[1]: *** [Makefile:1825: /home/pi/fusion-hat/driver] Error 2
make[1]: Leaving directory ‘/usr/src/linux-headers-5.10.103-v7+’
make: *** [Makefile:43: all] Error 2
✗ Install driver
Installing Fusion Hat driver and device tree overlay…
rmmod fusion_hat || echo "Warning: Failed to unload fusion_hat module. It may b>
rmmod: ERROR: Module fusion_hat is not currently loaded
Warning: Failed to unload fusion_hat module. It may be in use or require additi>
make[1]: Entering directory ‘/home/pi/fusion-hat/driver’
Installing kernel module…
make -C /lib/modules/5.10.103-v7+/build M=/home/pi/fusion-hat/driver modules_in>
make[2]: Entering directory ‘/usr/src/linux-headers-5.10.103-v7+’
cat: /home/pi/fusion-hat/driver/modules.order: No such file or directory
DEPMOD 5.10.103-v7+
Warning: modules_install: missing ‘System.map’ file. Skipping depmod.
make[2]: Leaving directory ‘/usr/src/linux-headers-5.10.103-v7+’
Loading required IIO subsystem module…
Updating module dependencies…
depmod -a
Module installation completed.

I’m not that adept with Linux but am doing the install as per the instructions:

curl -sSL https://raw.githubusercontent.com/sunfounder/sunfounder-installer-scripts/main/install-fusion-hat.sh | sudo bash

Can someone advise how to resolve this please?

Thanks

Hi Kevin,

I can see you have a Makefile Error 2 which could mean you are missing the Linux kernel headers required to build the fusion-hat library module. I had a similar issue building the library for Ubuntu 24.04 on a Pi5.

I posted the solution here Cannot compile driver for Fusion-HAT+ on Pi5 running Ubuntu 24.04 with install script

After re-installing the missing Linux headers the install script and module build worked fine.

The install command will install the correct headers for the OS and version you have installed.

let me know if this works!

Mike

Hi Mike,

I tried that command earlier as I spotted your previous post, unfortunately it reported it couldn’t find the relevant Linux Headers file.

I’m getting a weird error with make, it’s reporting ISO C90 forbids mixed declarations for a number of the files and then bad arguments or invalid pointers in the main.h file.

I’ve been going round in circles trying to force make to use C99 using CFLAGS but I’m more a Windows person, my Unix history was Xenix, Solaris, SCO OpenServer, Novell UnixWare and some Red Hat when VMWare was using that as its core underlying OS, I haven’t really done Unix in quite some time.

Thanks

Kevin

Bugger. It looked like your log threw more errors than my attempt. I doubt I can help. Consider getting a pi5? Or a pi4?

Yeah, it threw up a load of errors. I might re-image the USB stick with an older OS and try again since going newer didn’t work. If I got it working then I was considering getting a newer pi, but wanted to try it out with the 3B to start.

Well after re flashing the OS, the driver compiled. Having a different issue now but will create a new post for it.

1 Like

We have not been able to reproduce your issue so far. We tested with a Raspberry Pi 3 Model B Rev 1.2 running the Bookworm 64-bit desktop system, and the installation worked without any problems.

Could you please let us know which Raspberry Pi model and operating system version you are using? We will test again based on your setup.