(EN) 3.3.2 Kernel space application - coffeebrain/Codesign_HW_SW GitHub Wiki

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.


Commands to work with kernel modules

  • Go to your module's folder in root:

    cd /root/<your-module-path>
    
  • Insert your module:

    insmod <module>.ko
    
  • Check if your module was inserted:

    lsmod
    
  • Write (in this example a 0) to your running module:

    echo -n -e '\x0' > /dev/<dev-module-name>
    
  • Check your modules printk log:

    tail -30 /var/log/kern.log
    

Kernel space app creation

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
⚠️ **GitHub.com Fallback** ⚠️