Skip to content

Commit

Permalink
add post: lkmpg
Browse files Browse the repository at this point in the history
  • Loading branch information
ntn888 committed Jan 6, 2024
1 parent 1a784fb commit 923b976
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions content/blog/linux-lkmpg-milkv.md
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

0 comments on commit 923b976

Please sign in to comment.