bernmc / flashstor-trueNAS-fancontrol

Asustor Flashstor temperature monitoring and fan control for TrueNAS-Scale
GNU General Public License v3.0
32 stars 4 forks source link

make step fails in ElectricEel #6

Open sb10 opened 1 month ago

sb10 commented 1 month ago

As already known, the make step fails in ElectricEel, which is now officially released.

I get:

sudo su
install-dev-tools
apt install dkms
git clone https://github.com/mafredri/asustor-platform-driver
cd asustor-platform-driver
make
[...]
make[3]: *** [scripts/Makefile.build:243: /home/admin/asustor-platform-driver/asustor.o] Killed
make[2]: *** [/usr/src/linux-headers-6.6.44-production+truenas/Makefile:1924: /home/admin/asustor-platform-driver] Error 2
make[1]: *** [Makefile:237: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.6.44-production+truenas'
make: *** [Makefile:24: modules] Error 2

I've no idea why that happens.

bernmc commented 1 month ago

@sb10 Sendu could you use make V=1 instead of make, and post the verbose output here - might give us a bit more info on why the process is being killed

sb10 commented 1 month ago

@sb10 Sendu could you use make V=1 instead of make, and post the verbose output here - might give us a bit more info on why the process is being killed

make V=1 &> make.out
[still manages to output a load of stuff to terminal]
cat make.out
make[1]: Entering directory '/usr/src/linux-headers-6.6.44-production+truenas'
make --no-print-directory -C /usr/src/linux-headers-6.6.44-production+truenas \
-f /usr/src/linux-headers-6.6.44-production+truenas/Makefile modules
make -f ./scripts/Makefile.build obj=/home/admin/asustor-platform-driver need-builtin=1 need-modorder=1 
make[3]: *** [scripts/Makefile.build:243: /home/admin/asustor-platform-driver/asustor.o] Killed
make[2]: *** [/usr/src/linux-headers-6.6.44-production+truenas/Makefile:1924: /home/admin/asustor-platform-driver] Error 2
make[1]: *** [Makefile:237: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.6.44-production+truenas'
make: *** [Makefile:24: modules] Error 2
bernmc commented 1 month ago

I've tried a few different things with Electric Eel, without success so far.

rcursaru commented 3 weeks ago

can we provide more output/testing/help towards this? If I can help, I am glad to test on a AS6702T.

c0d3-ngn commented 2 weeks ago

Same here, I have the issue on a AS6602T. I can provide whatever debug info needed for this case.

tterava commented 2 weeks ago

I'm also able to help, on AS5304T. Without this driver the CPU reaches over 100C on heavy load. Surprisingly it has stayed completely stable, but it's obviously not a good long term solution to just let it do its thing.

bernmc commented 2 weeks ago

Happy to have any help available. What we really need is someone with a bit of linux knowledge that may have a workaround for iX's restrictions.

My entirely ignorant thoughts on things to try are currently along the lines of:

Remember that the script still works on the previous versions of TrueNAS which are probably going to be more stable than Eel for a while yet.

st-mediola commented 2 weeks ago

I doubt docker could do much, the kernel module is probably required to expose the hardware as a usable device in the system, once you have it, you could control the fan from docker by mounting some /device/ (probably /sys/devices/platform/asustor_it87) into the container. But raw access to hardware I/O usually isn't available in userspace and therefore docker. Docker also loads no kernel of it's own (try cat /proc/sys/kernel/version in a container, you'll see your host's kernel).

Whatever dies during compilation seems to be triggered at scripts/Makefile.build:243 which looks like it's not c/c++ compiling some .c file to some .o file. Idk, maybe that build script part can be executed manually or with some debug flags to get more details.

This is just guessing based on the logs, I don't own a flashstor, came across this because I'm researching options :)

c0d3-ngn commented 2 weeks ago

Following a little bit the code traces and together with what @st-mediola commented I have tried to compile by myself the asustor.c file by means of gcc with the following flags:

gcc -Wall -Wextra -D__KERNEL__ -DMODULE -I/lib/modules/6.6.44-production+truenas/build/include -I/lib/modules/6.6.44-production+truenas/build/arch/x86/include -fno-pic -fno-common -O2 -o asustor.o -c asustor.c

The result I got back is this:

In file included from /lib/modules/6.6.44-production+truenas/build/include/linux/build_bug.h:5,
                 from /lib/modules/6.6.44-production+truenas/build/include/linux/container_of.h:5,
                 from /lib/modules/6.6.44-production+truenas/build/include/linux/list.h:5,
                 from /lib/modules/6.6.44-production+truenas/build/include/linux/dmi.h:5,
                 from asustor.c:10:
/lib/modules/6.6.44-production+truenas/build/include/linux/compiler.h:246:10: fatal error: asm/rwonce.h: No such file or directory
  246 | #include <asm/rwonce.h>
      |          ^~~~~~~~~~~~~~
compilation terminated

I am not an expert on kernel modules, but maybe this sheds some light on the current problem. It seems like it is not getting the reference of the asm modules, nevertheless they are located inside the /lib/modules/6.6.44-production+truenas/build/arch/x86/include path:


 ls -l /lib/modules/6.6.44-production+truenas/build/arch/x86/include    
total 18
drwxr-xr-x 10 root root 347 Nov  8 20:33 asm
drwxr-xr-x  4 root root   4 Nov  8 20:33 generated
drwxr-xr-x  3 root root   3 Nov  8 20:33 uapi
st-mediola commented 2 weeks ago

That directory does not seem to contain rwonce.h. There one in asm-generic/rwonce.h since this upstream commit, https://github.com/truenas/linux/commit/e506ea451254ab17e0bf918ca36232fec2a9b10c so I think something isn't right with that simple gcc command. Some architectures have their own asm/rwonce.h but for x86 seems to make it come from asm-generic.

You can find several complaints regarding compiling modules and about not finding asm/rwonce.h. Also https://github.com/truenas/linux/commit/1d351f1894342c378b96bb9ed89f8debb1e24e9f is adressing something similar.

https://forums.raspberrypi.com/viewtopic.php?t=350381 looks interesting, maybe you do need to run make with ARCH=x86 for the buildsystem to "generate" an x86 version for all the files that should be used from generic. The generated files would simply redirect via e.g. #include <asm-generic/rwonce.h> if I understand correctly. So even copying the original file there would likely work.

I've otherwise found that some people simply edited places that include /asm to use asm-generic. It's a hack but if you simply edit include/linux/compiler.h and change the include at the end to asm-generic/rwonce.h?

c0d3-ngn commented 2 weeks ago

Thanks for the suggestion. I have tried following your steps changing the include at the end of the include/linux/compiler.h but there is another error missing asm library:

In file included from /lib/modules/6.6.44-production+truenas/build/arch/x86/include/asm/barrier.h:85:
/lib/modules/6.6.44-production+truenas/build/include/asm-generic/barrier.h: At top level:
/lib/modules/6.6.44-production+truenas/build/include/asm-generic/barrier.h:18:10: fatal error: asm/rwonce.h: No such file or directory
   18 | #include <asm/rwonce.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.

I made a bit of research and I found that some people just create a symlink to the asm-generic folder with asm since in that directory where the error is complaining there is no asm folder. After adding the symlink it starts compiling but then another error is shown:

In file included from /usr/include/linux/unistd.h:8,
                 from /lib/modules/6.6.44-production+truenas/build/include/asm/seccomp.h:11,
                 from /lib/modules/6.6.44-production+truenas/build/include/linux/seccomp.h:22,
                 from /lib/modules/6.6.44-production+truenas/build/include/linux/sched.h:22:
/lib/modules/6.6.44-production+truenas/build/arch/x86/include/asm/unistd.h: At top level:
/lib/modules/6.6.44-production+truenas/build/arch/x86/include/asm/unistd.h:21:12: fatal error: asm/unistd_64_x32.h: No such file or directory
   21 | #  include <asm/unistd_64_x32.h>
      |            ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
tterava commented 2 weeks ago

Adding another include directory to the command seems to allow the build process to go further: gcc -Wall -Wextra -D__KERNEL__ -DMODULE -I/lib/modules/6.6.44-production+truenas/build/include -I/lib/modules/6.6.44-production+truenas/build/arch/x86/include -I/lib/modules/6.6.44-production+truenas/build/arch/x86/include/generated -fno-pic -fno-common -O2 -o asustor.o -c asustor.c

Both rwonce.h and uninstd_64_x32.h are found under /lib/modules/6.6.44-production+truenas/build/arch/x86/include/generated/asm