This is an old revision of the document!


Lab 04 - Linux kernel development

Objectives

  • Learn Linux kernel development basics;
  • Build your own Linux kernel module;
  • Understand userspace device types;
  • Use MMIO to communicate with the IMX UART peripheral!

Contents

Lecture

No lecture available :(

Tasks

Let's build a Linux kernel module and load in onto our board!

00. Preparation

First, you need to have the Linux source code for the same version of the kernel you're running your board on.

You can check the version by running uname -a on the imx8 device (we will use v6.4 in our example).

Check your linux source code using git status to see if you're running the same one:

# git status
HEAD detached at v6.4

If you need to recompile the kernel, check out the desired tag.

Next (optional), it's going to be useful to have ssh installed inside the rootfs.

Use buildroot's menuconfig to install PACKAGE_OPENSSH (all of them).

In either case (kernel / buildroot recompilation), you will need to regenerate the linux.itb image with your new binaries.

01. Your first kernel module?

Read some of this and create your external module's makefile.

DO NOT FORGET TO ADD ARCH=arm64 to the kbuild make invocation!

If you don't do so, the kernel's .config will be reset and you'll probably need to recompile the kernel if you do anything more on the kernel tree.

TODO

02. Making a simple character device

Google for some inspiration on Linux kernel sample character device modules.

Next: build it!

Upload it onto your board and test it using insmod!

TODO

03. Writing to a serial device (UART)

Download & read the i.MX8M's Reference Manual, chapter 16.2. Ahem not all of it, check the memory map / register definition for UTXD and UTS.

Next, we will enhance our character device to print the using IMX UART peripheral using a simple MMIO interface. Useful resources for mapping, reading & writing IO memory: https://www.kernel.org/doc/html/latest/driver-api/device-io.html

TODO

ass/laboratoare/04.1689974641.txt.gz ยท Last modified: 2023/07/22 00:24 by florin.stancu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0