x210项目重新回顾之九led驱动程序

1.)menuconfig 添加led支持,这里我编译成模块,后面手工加载该内核模块

x210项目重新回顾之九led驱动程序

 >make 

>make modules ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-

> make modules_install ARCH=arm  CROSS_COMPILE=arm-none-linux-gnueabi-  INSTALL_MOD_PATH=/tftpboot/nfs

安装到开发板上/lib/modules/2.6.35.7+/kernel/drivers/leds

 

开发板上>cd /lib/modules/2.6.35.7+/kernel/drivers/leds
/lib/modules/2.6.35.7+/kernel/drivers/leds # ls
led-class.ko  leds-gpio.ko(安装模块得来)
 

>insmod led-class.ko      (注意不要insmod leds-gpio.ko,否则运行应用程序会报端口冲突)

2.)去/sys/class/查看安装的模块类

/sys/class/leds # ls
led1  led2  led3

 

3)编译安装led设备驱动leds-s5pv210

~/news5pv210/study/zhulaoshi/code/linux_driver/4.LEDDriver/5.4.16$  make

>sudo cp leds-s5pv210.ko /tftpboot/nfs/driver_test

开发板上driver_test>insmod leds-s5pv210.ko   

 >lsmod
leds_s5pv210 1221 0 - Live 0xbf01e000
led_class 2494 1 leds_s5pv210, Live 0xbf000000
 

4) 测试

/sys/class/leds # cd led1


/sys/devices/virtual/leds/led1 # ls
brightness      max_brightness  power           subsystem       uevent


/sys/devices/virtual/leds/led1 # echo  1 > brightness
[ 2800.294451] s5pv210_led1_set

 

注意:如果不添加led内核框架模块支持,直接运行朱老师的insmod leds-s5pv210.ko,汇报没找到led_class_*相关注册类