No description
  • C 63.1%
  • Rust 17.2%
  • Just 13.2%
  • Nix 4%
  • Makefile 2.5%
Find a file
2026-03-24 11:13:50 +01:00
.helix helix: Add LSP configuration 2026-03-20 17:07:34 +01:00
.vscode vscode: Cleanup 2025-08-08 13:40:01 +02:00
01_basic_module fix: renommer MODULE_LICENSE vers Dual MIT/GPL sur modules 01-05 2026-03-21 18:57:27 +01:00
02_module_params fix: renommer MODULE_LICENSE vers Dual MIT/GPL sur modules 01-05 2026-03-21 18:57:27 +01:00
03_character_device 03_character_device: Unify logic with C version 2026-03-24 11:13:50 +01:00
04_process_monitor fix: renommer MODULE_LICENSE vers Dual MIT/GPL sur modules 01-05 2026-03-21 18:57:27 +01:00
05_packet_filter feat: ajouter le paramètre module filter_port dans packet_filter 2026-03-21 19:34:52 +01:00
06_virtual_led_basic modules(all): Use raw string instead $(VAR) 2026-03-20 17:07:11 +01:00
07_virtual_leds_more_complex refactor: utiliser devm_* allocations dans virtual_leds_more_complex 2026-03-21 19:51:46 +01:00
08_gpio_pin_rpi3 modules(all): Use raw string instead $(VAR) 2026-03-20 17:07:11 +01:00
09_gpio_led_rpi3 fix: déplacer la déclaration de int ret en début de bloc dans register_rpi3_led 2026-03-21 19:26:56 +01:00
10_lightning_node_pro_led fix: initialiser le device HID avec hid_parse + hid_hw_start dans probe 2026-03-21 19:28:50 +01:00
.clang-format Run clang-format 2025-02-25 13:32:53 +01:00
.envrc env: Migrate to shell.nix to use nixpkgs of the system 2026-01-22 19:31:54 +01:00
.gitignore just: Add clangd and lsp to configure lsp 2026-01-22 20:15:23 +01:00
Justfile fix: bad shebang for NixOS 2026-03-21 19:14:35 +01:00
README.md README: Add step to build patched env 2026-03-20 17:07:31 +01:00
shell.nix Fix source is not always a Git repo need to be processed before 2026-03-21 00:33:22 +01:00

Setup env

Patch to follow

Custom nixpkgs override

If a required fix is not yet in nixpkgs, you can override it from a custom fork using the commit SHA:

nix-shell -I nixpkgs=https://github.com/mrdev023/nixpkgs/archive/<commit-sha>.tar.gz

Replace <commit-sha> with the exact commit from the fork branch (e.g. fix-rust-makefile-kernel). Using the commit SHA ensures reproducibility and avoids stale cache issues from branch-based URLs.

Automatic

Direnv configuration is available so you can use direnv allow to setup shell.

Manual

On NixOS:

You just need to start you shell with nix-shell.

On other distros:

You need to install kernel-devel to compile C code, rust rust-src bindgen-cli rustfmt clippy to compile rust code and just. You also need to setup LINUX_MODULES_FOLDER to linux modules folder of your distro (ex: /lib/modules/$(uname -r)) in your shell (ex: .bashrc)

Note for Rust

Check required kernel conf CONFIG_RUST=y

cat /boot/config-$(uname -r) | grep CONFIG_RUST

Generate rust-analyzer conf

make LLVM=1 -C $LINUX_MODULES_FOLDER/build M=$(pwd) rust-analyzer

make : targets list

  • all : Compiling kernel (by default)
  • clean : Cleaning build folder

All subfolder is configured to use LINUX_MODULES_FOLDER env variable set by flake develop

How test module

Step 1: Load module

sudo insmod [module_name].ko

Warning: Can fail if secure boot is enabled (see notes about secure boot in below)

Step 2: Check logs

sudo dmesg | tail

Step 3: Unload module

sudo rmmod [module_name].ko

Notes

Find required headers files

nix shell nixpkgs#bear
cd 01_basic_module/
bear --append --output ../.vscode/compile_commands.json -- make -C $LINUX_MODULES_FOLDER/build M=$PWD modules

Search -I args and -D args

Sign kernel module for testing with secure boot enabled

Prerequisites: Own secure boot keys configured.

Secure boot keys can be found in :

  • Fedora : /etc/pki/akmods
  • With sbctl : /var/lib/sbctl
sign-file sha256 $SECUREBOOT_KEYS_PATH/private_key.priv $SECUREBOOT_KEYS_PATH/public_key.der <module_file>.ko

sign-file executable is in /usr/src/kernels/$(uname -r)/scripts

Full example (run as root):

  1. Fedora
/usr/src/kernels/$(uname -r)/scripts/sign-file sha256 /etc/pki/akmods/private/private_key.priv /etc/pki/akmods/certs/public_key.der <module_file>.ko

Format

  1. .clang-format

How update .clang-format

curl https://raw.githubusercontent.com/torvalds/linux/refs/heads/master/.clang-format -o .clang-format

Format files

clang-format -i **/*.c

Checkpatch

./<linux-source>/scripts/checkpatch.pl --no-tree -f <file>

For example from NixOS development environment

$LINUX_MODULES_FOLDER/source/scripts/checkpatch.pl --no-tree -f 01_basic_module/basic_module_in_c.c