Following the Linux Kernel Module Programming Guide with RISC-V Milkv Duo embedded board
We saw in this post that The Linux Kernel Module Programming Guide is a great resource when learning Linux Device Drivers. It however takes a self-compiled route with the modules developed and run directly on the host system. For GPIO examples the Raspberry PI is used.
In this article we shall see how to adopt the guide to learn with the Milk-V Duo board. Here we assume you use the vanilla Buildroot repo for building the system image.
Adapting the Makefile#
As mentioned above, the modules are selfcompiled to run locally on the host system. To make them run on our dev board we need to modify the Makefile. The C source file is left untouched.
CC = obj-m :=
KDIR :=
:
:
Be sure to adapt the KDIR
path to suite your system's location. Also make note to change hello.o
to whatever you named your C source file.
Remember to execute the following environment variables before running make:
export PATH="$PATH:/home/ajit/work/ldd/milkv/milkv-duo-buildroot/output/host/bin"
export ARCH=riscv
export CROSS_COMPILE=riscv64-linux-
Changing the GPIO directives#
In the chapter #detecting-button-presses, they use the Raspberry PI which is based on Cortex-A architecture. Our RISC-V board uses different GPIO naming scheme, and we need to adapt accordingly...
TODO