-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
+++ | ||
title = "Following the Linux Kernel Module Programming Guide with RISC-V Milkv Duo embedded board" | ||
date = 2024-01-06 13:27:00 | ||
draft = false | ||
|
||
[taxonomies] | ||
categories = ["embedded-linux"] | ||
tags = ["embedded-linux", "linux", "linux drivers", "milkv-duo"] | ||
|
||
[extra] | ||
lang = "en" | ||
toc = true | ||
comment = false | ||
copy = true | ||
math = false | ||
mermaid = false | ||
outdate_alert = false | ||
outdate_alert_days = 120 | ||
display_tags = true | ||
truncate_summary = false | ||
+++ | ||
|
||
We saw in [this post](@/blog/linux-embedded-howto.md) that [The Linux Kernel Module Programming Guide](https://sysprog21.github.io/lkmpg/) 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](https://milkv.io/duo) board. Here we assume you use the vanilla Buildroot [repo](https://github.com/milkv-duo/milkv-duo-buildroot) 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. | ||
|
||
```Makefile | ||
CC = $(CROSS_COMPILE)gcc | ||
|
||
obj-m := hello.o | ||
KDIR := /home/<user>/milkv/milkv-duo-buildroot/output/build/linux-duo-linux-5.10.4 | ||
|
||
all: | ||
$(MAKE) -C $(KDIR) M=$(PWD) | ||
|
||
clean: | ||
$(MAKE) -C $(KDIR) M=$$PWD clean | ||
|
||
``` | ||
|
||
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. | ||
|
||
## Changing the GPIO directives | ||
|
||
In the chapter [#detecting-button-presses](https://sysprog21.github.io/lkmpg/#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 | ||
|