(ES) 3.3.2 Aplicaciones de espacio de kernel (Kernel space) - coffeebrain/Codesign_HW_SW GitHub Wiki

Key concepts used in this section

For this section it is important to know the following key concepts:

To be able to communicate with the IP components created in Platform Designer from the software is necessary to know how to "speak" with them in an appropiate way, there is where drivers come to scene, the software pieces are the ones responsible for making the translations between software and hardware, for that reason these need special attention in the design process.


Kernel space app creation

When creating a driver (kernel module) many important rules must be followed. This process differs from the creation of apps in the user space. Creating a bad kernel file can result in system corruption, in most of the cases a problem in kernel requires that the system has to be reseted when executing.

The following are the files that must be created to cross compilate a kernel module

  • Makefile
  • Kbuild
  • Driver code (C file)

Makefile

KDIR ?= <linux-kernel-path>/socfpga-kernel-dev/KERNEL

default:
	$(MAKE) -C $(KDIR) ARCH=arm M=$(CURDIR)

clean:
	$(MAKE) -C $(KDIR) ARCH=arm M=$(CURDIR) clean

help:
	$(MAKE) -C $(KDIR) ARCH=arm M=$(CURDIR) help

Kbuild

obj-m := custom_leds.o

Driver file (C code)

Your driver.

// Linux imports
// Prototypes
// Structs
// Module device table
// Functions
// module_init and module_exit calls
// Information about kernel module

Cross compile

Binary Toolchain

export CROSS_COMPILE=<Linaro-binary-toolchain-path>/gcc-linaro-6.5.0-2018.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
make
make clean
make install