1
0

feat(lab02): add exercice 3

This commit is contained in:
2026-03-27 15:14:41 +01:00
parent cc67357fc3
commit a4bef25652
2 changed files with 34 additions and 14 deletions

View File

@@ -48,7 +48,7 @@
//------------------------------------- //-------------------------------------
// Content // Content
// //
= Embedded Linux Environment = Embedded Linux Environment
@@ -73,7 +73,7 @@ Or only uboot with `make uboot` command.
In buildroot, with `make menuconfig`, we can select the package we want in `Target packages` section. We can specifically build it with `make <package-name>` command. Otherwise, it will be built with the whole system when we run `make` command. In buildroot, with `make menuconfig`, we can select the package we want in `Target packages` section. We can specifically build it with `make <package-name>` command. Otherwise, it will be built with the whole system when we run `make` command.
=== How to modify the Linux kernel configuration? === How to modify the Linux kernel configuration?
Like all package, with `make <package-name>-menuconfig` command. So, for Linux kernel: Like all package, with `make <package-name>-menuconfig` command. So, for Linux kernel:
```bash ```bash
|> make linux-menuconfig |> make linux-menuconfig
``` ```
@@ -84,7 +84,7 @@ The overlay is a directory (inin the board folder) with the same structure as ro
=== How to use the eMMC card instead of the SD card? === How to use the eMMC card instead of the SD card?
We need to change the boot script `(boot*.cmd)` to load from eMMC by changing the `fatload` command with the correct number. Probably 1 instead of 0. We need to change the boot script `(boot*.cmd)` to load from eMMC by changing the `fatload` command with the correct number. Probably 1 instead of 0.
``` ```
fatload mmc 1 $kernel_addr_r Image fatload mmc 1 $kernel_addr_r Image
``` ```
@@ -114,7 +114,7 @@ If we develop only user space program, we don't need to load kernel by tftp. But
Create the skeleton of a kernel module and generate it outside the kernel sources using a Makefile. The module should display a message when it is registered and when it is uninstalled. Create the skeleton of a kernel module and generate it outside the kernel sources using a Makefile. The module should display a message when it is registered and when it is uninstalled.
] ]
We already have a skeleton in `src/02-modules/exercice01`. We see on the Makefile that the module is generated outside the kernel sources with the `KDIR` variable imported from `src/kernel_settings`. This variable point to the kernel sources. We already have a skeleton in `src/02-modules/exercice01`. We see on the Makefile that the module is generated outside the kernel sources with the `KDIR` variable imported from `src/kernel_settings`. This variable point to the kernel sources.
The Makefile also use the `PWD` variable to the current directory. The Makefile also use the `PWD` variable to the current directory.
The `make` command will use these variables to generate the module in the current directory. The `make` command will use these variables to generate the module in the current directory.
@@ -133,7 +133,7 @@ filename: /workspace/src/02_modules/exercice01/mymodule.ko
license: GPL license: GPL
description: Module skeleton description: Module skeleton
author: Daniel Gachet <daniel.gachet@hefr.ch> author: Daniel Gachet <daniel.gachet@hefr.ch>
depends: depends:
name: mymodule name: mymodule
vermagic: 5.15.148 SMP preempt mod_unload aarch64 vermagic: 5.15.148 SMP preempt mod_unload aarch64
parm: text:charp parm: text:charp
@@ -143,13 +143,13 @@ parm: elements:int
#subtask[ #subtask[
Install the module (insmod) and check the kernel log (dmesg) Install the module (insmod) and check the kernel log (dmesg)
] ]
```bash ```bash
|> insmod mymodule.ko |> insmod mymodule.ko
[ 1727.896902] mymodule: loading out-of-tree module taints kernel. [ 1727.896902] mymodule: loading out-of-tree module taints kernel.
[ 1727.903442] Linux module 01 skeleton loaded [ 1727.903442] Linux module 01 skeleton loaded
``` ```
We can see the module is indead out-of-tree and correctly loaded. We can see the module is indead out-of-tree and correctly loaded.
```bash ```bash
|> dmesg | tail -5 |> dmesg | tail -5
[ 1381.694764] CIFS: Attempting to mount \\192.168.53.4\workspace [ 1381.694764] CIFS: Attempting to mount \\192.168.53.4\workspace
@@ -166,8 +166,8 @@ We can see the module is indead out-of-tree and correctly loaded.
```bash ```bash
|> lsmod |> lsmod
Module Size Used by Tainted: G Module Size Used by Tainted: G
mymodule 16384 0 mymodule 16384 0
··· ···
|> cat /proc/modules |> cat /proc/modules
@@ -181,20 +181,20 @@ mymodule 16384 0 - Live 0xffff8000011bf000 (O)
] ]
```bash ```bash
|> rmmod mymodule.ko |> rmmod mymodule.ko
[ 2989.535793] Linux module skeleton unloaded [ 2989.535793] Linux module skeleton unloaded
``` ```
//-------------- //--------------
#subtask[ #subtask[
Adapt the Makefile of the module to allow the installation of the module with other kernel modules allowing the use of the modprobe command. The module should be installed in the root filesystem used in cifs by the target. Adapt the Makefile of the module to allow the installation of the module with other kernel modules allowing the use of the modprobe command. The module should be installed in the root filesystem used in cifs by the target.
] ]
```bash ```bash
# On host: # On host:
|> make install |> make install
# On target: # On target:
|> modprobe mymodule |> modprobe mymodule
[ 3359.811183] Linux module 01 skeleton loaded [ 3359.811183] Linux module 01 skeleton loaded
``` ```
@@ -209,8 +209,28 @@ mymodule 16384 0 - Live 0xffff8000011bf000 (O)
], ],
) )
//-------------------
// Exercise 3: What does it mean the 4 values in ```/proc/sys/kernel/printk``` ?
//-------------------
#task(
[What does it mean the 4 values in ```/proc/sys/kernel/printk``` ?],
[
```bash
|> cat /proc/sys/kernel/printk
7 4 1 7
```
The number specified the level of output in a console.
This file specifies the log level for:
- current: 7
- default: 4
- minimum: 1
- boot-time-default: 7
This number matches with this table (#link("https://www.kernel.org/doc/html/latest/core-api/printk-basics.html", [printk documentation])):
#image("resources/img/printk-log-levels.png")
]
)
//------------------------------------- //-------------------------------------

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 KiB