Skip to content

Linux kernel char device driver for controlling the LEDs with requred commands

Notifications You must be signed in to change notification settings

Mukhin22/char_device_task

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Char device task project

Description

This is Linux Kernel character device driver to control the gpio connected LEDs.

Possible commands:

1 - enable led

0 - disable led (disable blinking, if it's active now)

2 <blinks_number> <blinks_interval_ms> - blinking the LEDs with interval in miliseconds and number of blinks used in parameters.

Each of the command can be used for both leds:

echo 1 > /dev/LED_CTRL

echo 2 20 500> /dev/LED_CTRL1

Commands are queued.

Driver Usage

  1. Cross-compile module

make -j$(nproc) ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules

  • This operation should be performed with preinstalled rapbpios kernel build tools.

  • To get and build your own kernel follow the link

  • Kernel sources should be downloaded and build. After your kernel will be stored in linux/ directory.

  • Module directory should be linux/drivers/char_led/

  • Before building add line to Kconfig file in linux/drivers

source "drivers/char_led/Kconfig"

  • Before building add line to Makefile in linux/drivers

obj-$(CONFIG_CHAR_LED) += char_led/

  1. Copy char_led.ko file to the raspberry pi device using ssh.

Example of such copy:

scp /home/strngr/linux/drivers/char_led/char_led.ko [email protected]:/home/pi/

  1. Perform: sudo insmod char_led.ko

Note: If module can not be installed because of it's build on a newer kernel version. (It could be checked with modinfo module_name command). The kernel could be updated using sudo rpi_update. After the job is done use sudo reboot

  1. When the module is installed it could be checked using lsmod command

  2. Load module using the load.sh script from current directory:

sudo chmod +x ./load.sh

sudo ./load.sh

  1. Next module should be seen in /dev/ directory. Check it with

    ls /dev/* | grep 'LED_CTRL'

  2. Check the module is working with commands

  • For red led:

    sudo bash ./test.sh 0 10 200

  • For blue led:

    sudo bash ./test.sh 1 10 200

  1. Now it can be used for your needs.

About

Linux kernel char device driver for controlling the LEDs with requred commands

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published