Building custom kernel modules for the BeagleV-Fire

Possibly a duplicate of Rebuilding Ubuntu on BeagleV-Fire,
but I didn’t want to hijack his thread…


Been poking at it for a few hours, trying to replicate @RobertCNelson’s CI, but locally.

The big CI builder is great for getting a complete disk image together,
but it seems incredibly wasteful when one is developing a single LKM.

It feels like I’m getting close, but I’ve hit a snag:

debian@isengard:~/mpfs-tvs$ make
make -j4 ARCH=riscv CROSS_COMPILE=/home/debian/riscv-toolchain/bin/riscv64-linux- -C ../linux M=/home/debian/mpfs-tvs modules
make[1]: Entering directory '/home/debian/linux'
  CC [M]  /home/debian/mpfs-tvs/mpfs-tvs.o
  MODPOST /home/debian/mpfs-tvs/Module.symvers
WARNING: Module.symvers is missing.
         Modules may not have dependencies or modversions.
         You may get many unresolved symbol warnings.
WARNING: modpost: "__platform_driver_register" [/home/debian/mpfs-tvs/mpfs-tvs.ko] undefined!
WARNING: modpost: "_printk" [/home/debian/mpfs-tvs/mpfs-tvs.ko] undefined!
WARNING: modpost: "platform_driver_unregister" [/home/debian/mpfs-tvs/mpfs-tvs.ko] undefined!
WARNING: modpost: "module_layout" [/home/debian/mpfs-tvs/mpfs-tvs.ko] undefined!
  CC [M]  /home/debian/mpfs-tvs/mpfs-tvs.mod.o
  LD [M]  /home/debian/mpfs-tvs/mpfs-tvs.ko
make[1]: Leaving directory '/home/debian/linux'

I’ve been studying the build system, but I can’t quite make out where the missing file
is supposed to come from. Any pointers welcome!

I know it’s not a lot to go on, but I have been replicating almost all of the steps
contained in the build system, although I don’t use the docker image,
but run directly on a “bare-metal” Debian Bookworm.

Google tells me that the missing files are generated once a modules build completes,
but I haven’t been able to get that to work either; does not run to completion.

1 Like

Ok, turns out I was trying to hard; much easier to install docker and pull the robertcnelson/beagle-devscripts-kernel-debian-12-amd64:latest image.

Once attached to it, just do what his .gitlab-ci.yml script does and you’ll have
a build environment in no time. Just make sure you run the steps from ./04_build_linux.sh manually,
or you will have to do it again, as it deletes the ./deploy/tmp folder you’re after.
All the steps after ./04_build_linux.sh are not required for what we’re trying to do.

My Makefile looks like this:

# Makefile for driver: native-compile

obj-m := mpfs-tvs.o

all:
	make -j${CORES} ARCH=riscv CROSS_COMPILE=${CC} -C /BeagleV-Fire-ubuntu/deploy/tmp/lib/modules/6.1.33-linux4microchip+fpga-2023.06-20240531+/build M=$(PWD) modules

clean:
	make -j${CORES} ARCH=riscv CROSS_COMPILE=${CC} -C /BeagleV-Fire-ubuntu/deploy/tmp/lib/modules/6.1.33-linux4microchip+fpga-2023.06-20240531+/build M=$(PWD) clean

and you will need to replace the path to …/build, as it is dynamic.

Happy coding! :smiling_face: