Compiled OpenCL kernel driver for FPGA segfaults during `insmod aclsoc_drv.ko`
nocduro opened this issue · 4 comments
May need to be based off of the exact same linux header files, might try the linux image from: https://downloadcenter.intel.com/download/26687/Downloads-for-the-Terasic-DE10-Nano-Kit-Featuring-an-Intel-Cyclone-V-FPGA-SoC?v=t
Tried the intel image from that page, and it doesn't get past u-boot:
Error: ethernet@ff702000 address not set.
Trying the DE10_Nano_Xfce from terasic next
When segfaulting the error showed something like address 0, which doesn't make sense for a properly compiled driver. I tried recompiling, and got some warnings that I fixed by compiling the Linux kernel to generate header files and the required module support.
In the folder with linux, run
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- KERNEL=kernel7
I think this will run the configurator, where we need to enable support for modules:
*
* Enable loadable module support
*
Enable loadable module support (MODULES) [Y/n/?] y
Forced module loading (MODULE_FORCE_LOAD) [N/y/?] (NEW) y
Module unloading (MODULE_UNLOAD) [N/y/?] (NEW) y
Forced module unloading (MODULE_FORCE_UNLOAD) [N/y/?] (NEW) y
Module versioning support (MODVERSIONS) [N/y/?] (NEW) y
Source checksum for all modules (MODULE_SRCVERSION_ALL) [N/y/?] (NEW)
Module signature verification (MODULE_SIG) [N/y/?] (NEW)
Compress modules on installation (MODULE_COMPRESS) [N/y/?] (NEW)
*
Earlier on in the first build I enabled support for Altera CPUs, and other things related to our board, but I'm not sure if they influence the driver compilation. Since we are just compiling a kernel module, we might just need the above kernel module support.
After modifying the config, and building linux, I compiled the driver and it completed without errors. Still need to test it on the DE10-nano board.
edit: modified driver available in commit 8d5df10
edit: new driver did not work, complains about vermagic error:
root@de10-nano:~/opencl# insmod aclsoc_drv.ko
[ 125.640694] aclsoc_drv: version magic '4.1.33-ltsialtera-gb84195c mod_unload modversions ARMv7 thumb2 p2v8 ' should be '4.1.33-ltsi-altera SMP mod_unload ARMv7 p2v8 '
insmod: ERROR: could not insert module aclsoc_drv.ko: Invalid module format
Trying to force with modprobe aclsoc_drv --force
gives:
root@de10-nano:~/opencl# modprobe --force -a aclsoc_drv
modprobe: ERROR: could not insert 'aclsoc_drv': Exec format error
root@de10-nano:~/opencl# /sbin/modinfo aclsoc_drv.ko
filename: /home/root/opencl/aclsoc_drv.ko
description: Driver for Intel(R) OpenCL SoC Acceleration Devices
license: Dual BSD/GPL
author: Dmitry Denisenko
depends:
vermagic: 4.1.33-ltsialtera-gb84195c mod_unload modversions ARMv7 thumb2 p2v8
Compiled version available here: https://github.com/thinkoco/c5soc_opencl
Instructions on compiling kernel: https://github.com/thinkoco/c5soc_opencl/blob/master/HowToDo.md