Skip to content

LINUX DEVICE DRIVERS


Introduction

  • Driver’s goal is map user calls to hardware or protocol related procedure
  • When writing driver as a programmer, we should tell the difference between mechanism and strategy, we should not add special strategy without needed, let user use their strategy as their need.

Build kernel

  • check kernel message the message by module of linux system will be at system log directory, default: /var/log/messages, for Ubnuntu, the location of it changes to /var/log/syslog

    dmsg | tail can perform the same work too !!!

  • the module need to be signed when SECURE BOOT is enabled on UEFI/BIOS setting
  • remove/rebuild kernel may solve insmod error
    insmod: ERROR: could not insert module ./hello_world.ko: Invalid module format
    $ sudo apt update && sudo apt upgrade
    $ sudo apt remove --purge linux-headers-*
    $ sudo apt autoremove && sudo apt autoclean
    $ sudo apt install linux-headers-generic