主题 : 新手led 复制链接 | 浏览器收藏 | 打印
级别: 侠客
UID: 59279
精华: 0
发帖: 84
金钱: 430 两
威望: 86 点
综合积分: 168 分
注册时间: 2011-11-22
最后登录: 2012-12-04
楼主  发表于: 2012-07-19 08:54

 新手led

android-kernel-2.6.36-20110325\linux-2.6.36-android\Documentation\leds-class.txt中显示
LEDs appear in /sys/class/leds/.

但超级终端中显示
/sys/class/leds # ls
mmc0::
mmc1::
请问最后这两行表示什么意思?

我想操作led,从源程序开始操作,而不是使用友善提供的小软件,请问接下来我该怎么做?
^很多问题的背后都是简单的原因......
级别: 荣誉会员
UID: 34780
精华: 0
发帖: 1219
金钱: 6230 两
威望: 1246 点
综合积分: 2438 分
注册时间: 2010-12-21
最后登录: 2017-09-18
1楼  发表于: 2012-07-19 11:23
mini6410的led驱动是一个简单的misc设备,源文件是drivers/char/mini6410_leds.c
印象中是有实例程序的
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
2楼  发表于: 2012-07-19 13:01
但超级终端中显示
/sys/class/leds # ls
mmc0::
mmc1::
请问最后这两行表示什么意思?

这应该表示有内核里注册了两个名字分别是"mmc0::"和"mmc1::"的led class设备

友善之臂提供的Mini6410/Tiny6410/Tiny210上的led驱动都不是led class架构的,驱动源代码在内核目录下的drivers\char\mini6410_leds.c和drivers\char\mini210_leds.c, 其对应的操作方法可以参考光盘Linux目录下example包里的leds\led.c。
如果你希望做一点更有意义的事情, 我想你可以把友善之臂提供的驱动按照led class的架构重写一下。
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 侠客
UID: 59279
精华: 0
发帖: 84
金钱: 430 两
威望: 86 点
综合积分: 168 分
注册时间: 2011-11-22
最后登录: 2012-12-04
3楼  发表于: 2012-07-20 08:58

 回 1楼(911gt3) 的帖子

     谢谢哈,源程序我找到了,并编译为了 .ko 文件,但是拷到开发板上加载mini6410_leds.ko 模块时失败了,提示如下:
/ #  
/ # insmod mini6410_leds.ko                          
------------[ cut here ]------------                                    
WARNING: at fs/sysfs/dir.c:451 sysfs_add_one+0x64/0x8c()                                                        
sysfs: cannot create duplicate filename '/devices/virtual/misc/leds'                                                                    
Modules linked in: mini6410_leds(+) zd1211rw rt2800usb rt2800lib rt73usb rt2x00u                                                                                
sb rt2x00lib ath9k_htc ath9k_common mac80211 ath9k_hw ath libertas_sdio libertas                                                                                
cfg80211 compat                
[<c016a9a4>] (unwind_backtrace+0x0/0xe4) from [<c017f51c>] (warn_slowpath_common                                                                                
+0x4c/0x64)          
one_wire_status: 3                  
[<c017f51c>] (warn_slowpath_common+0x4c/0x64) from [<c017f5b4>] (warn_slowpath_f                                                                                
mt+0x2c/0x3c)            
[<c017f5b4>] (warn_slowpath_fmt+0x2c/0x3c) from [<c023148c>] (sysfs_add_one+0x64                                                                                
/0x8c)      
one_wire_status: 4                  
[<c023148c>] (sysfs_add_one+0x64/0x8c) from [<c0231510>] (create_dir+0x5c/0xac)                                                                              
[<c0231510>] (create_dir+0x5c/0xac) from [<c0231638>] (sysfs_create_dir+0xb8/0xe                                                                                
0)  
[<c0231638>] (sysfs_create_dir+0xb8/0xe0) from [<c02d73fc>] (kobject_add_interna                                                                                
l+0xec/0x1c8)            
one_wire_status: 4                  
[<c02d73fc>] (kobject_add_internal+0xec/0x1c8) from [<c02d77ac>] (kobject_add+0x                                                                                
68/0x8c)        
[<c02d77ac>] (kobject_add+0x68/0x8c) from [                                        
one_wire_status: 4                  
[<c03196e4>] (device_add+0xac/0x4a4) from [<c0319b64>] (device_create_vargs+0x70                                                                                
/0xb8)      
[<c0319b64>] (device_create_vargs+0x70/0xb8) from [<c0319bc8>] (device_create+0x                                                                                
1c/0x24)        
one_wire_status: 4                  
[<c0319bc8>] (device_create+0x1c/0x24) from [<c030711c>] (misc_register+0xbc/0x1                                                                                
28)  
[<c030711c>] (misc_register+0xbc/0x128) from [<bf16b044>] (dev_init+0x44/0x64 [m                                                                                
ini6410_leds])              
[<bf16b044>] (dev_init+0x44/0x64 [mini6410_leds]) from [<c01654fc>] (do_one_init                                                                                
call+0xbc/0x190)                
one_wire_status: 4                  
[<c01654fc>] (do_one_initcall+0xbc/0x190) from [<c01acfe8>] (sys_init_module+0x1                                                                                
598/0x1760)          
[<c01acfe8>] (sys_init_module+0x1598/0x1760) from [<c0165e60>] (ret_fast_syscall                                                                                
+0x0/0x30)          
one_wire_status: 4                  
---[ end trace 5273fb0808d6e10c ]---                                    
kobject_add_internal failed for leds with -EEXIST, don't try to register things                                                                              
with the same name in the same directory.                                        
one_wire_status: 4                  
[<c016a9a4>] (unwind_backtrace+0x0/0xe4) from [<c02d7498>] (kobject_add_internal                                                                                
+0x188/0x1c8)            
[<c02d7498>] (kobject_add_internal+0x188/                                      
x68/0x8c)
[<c02d77ac>] (kobject_add+0x68/0x8c) from [<c03196e4>] (device_add+0xac/0x4a4)
one_wire_status: 4
[<c03196e4>] (device_add+0xac/0x4a4) from [<c0319b64>] (device_create_vargs+0x70
/0xb8)
[<c0319b64>] (device_create_vargs+0x70/0xb8) from [<c0319bc8>] (device_create+0x
1c/0x24)
one_wire_status: 4
[<c0319bc8>] (device_create+0x1c/0x24) from [<c030711c>] (misc_register+0xbc/0x1
28)
[<c030711c>] (misc_register+0xbc/0x128) from [<bf16b044>] (dev_init+0x44/0x64 [m
ini6410_leds])
one_wire_status: 4
[<bf16b044>] (dev_init+0x44/0x64 [mini6410_leds]) from [<c01654fc>] (do_one_init
call+0xbc/0x190)
[<c01654fc>] (do_one_initcall+0xbc/0x190) from [<c01acfe8>] (sys_init_module+0x1
598/0x1760)
[<c01acfe8>] (sys_init_module+0x1598/0x1760) from [<c0165e60>] (ret_fast_syscall
+0x0/0x30)
one_wire_status: 4
leds    initialized
insmod: init_module 'mini6410_leds.ko' failed (File exists)
/ #

请问这是怎么回事?感觉前面一直好好的,是哪里出错了??谢谢哈~~
级别: 侠客
UID: 59279
精华: 0
发帖: 84
金钱: 430 两
威望: 86 点
综合积分: 168 分
注册时间: 2011-11-22
最后登录: 2012-12-04
4楼  发表于: 2012-07-20 09:12

 回 2楼(kasim) 的帖子

    谢谢哈
    嗯,努力学习,争取早日实现
    我把友善提供的源程序编译为了 .ko 文件,但是拷到开发板上加载mini6410_leds.ko 模块时失败了,提示如下:
/ #  
/ # insmod mini6410_leds.ko                          
------------[ cut here ]------------                                    
WARNING: at fs/sysfs/dir.c:451 sysfs_add_one+0x64/0x8c()                                                        
sysfs: cannot create duplicate filename '/devices/virtual/misc/leds'                                                                    
Modules linked in: mini6410_leds(+) zd1211rw rt2800usb rt2800lib rt73usb rt2x00u                                                                                
sb rt2x00lib ath9k_htc ath9k_common mac80211 ath9k_hw ath libertas_sdio libertas                                                                                
cfg80211 compat                
[<c016a9a4>] (unwind_backtrace+0x0/0xe4) from [<c017f51c>] (warn_slowpath_common                                                                                
+0x4c/0x64)          
one_wire_status: 3                  
[<c017f51c>] (warn_slowpath_common+0x4c/0x64) from [<c017f5b4>] (warn_slowpath_f                                                                                
mt+0x2c/0x3c)            
[<c017f5b4>] (warn_slowpath_fmt+0x2c/0x3c) from [<c023148c>] (sysfs_add_one+0x64                                                                                
/0x8c)      
one_wire_status: 4                  
[<c023148c>] (sysfs_add_one+0x64/0x8c) from [<c0231510>] (create_dir+0x5c/0xac)                                                                              
[<c0231510>] (create_dir+0x5c/0xac) from [<c0231638>] (sysfs_create_dir+0xb8/0xe                                                                                
0)  
[<c0231638>] (sysfs_create_dir+0xb8/0xe0) from [<c02d73fc>] (kobject_add_interna                                                                                
l+0xec/0x1c8)            
one_wire_status: 4                  
[<c02d73fc>] (kobject_add_internal+0xec/0x1c8) from [<c02d77ac>] (kobject_add+0x                                                                                
68/0x8c)        
[<c02d77ac>] (kobject_add+0x68/0x8c) from [                                        
one_wire_status: 4                  
[<c03196e4>] (device_add+0xac/0x4a4) from [<c0319b64>] (device_create_vargs+0x70                                                                                
/0xb8)      
[<c0319b64>] (device_create_vargs+0x70/0xb8) from [<c0319bc8>] (device_create+0x                                                                                
1c/0x24)        
one_wire_status: 4                  
[<c0319bc8>] (device_create+0x1c/0x24) from [<c030711c>] (misc_register+0xbc/0x1                                                                                
28)  
[<c030711c>] (misc_register+0xbc/0x128) from [<bf16b044>] (dev_init+0x44/0x64 [m                                                                                
ini6410_leds])              
[<bf16b044>] (dev_init+0x44/0x64 [mini6410_leds]) from [<c01654fc>] (do_one_init                                                                                
call+0xbc/0x190)                
one_wire_status: 4                  
[<c01654fc>] (do_one_initcall+0xbc/0x190) from [<c01acfe8>] (sys_init_module+0x1                                                                                
598/0x1760)          
[<c01acfe8>] (sys_init_module+0x1598/0x1760) from [<c0165e60>] (ret_fast_syscall                                                                                
+0x0/0x30)          
one_wire_status: 4                  
---[ end trace 5273fb0808d6e10c ]---                                    
kobject_add_internal failed for leds with -EEXIST, don't try to register things                                                                              
with the same name in the same directory.                                        
one_wire_status: 4                  
[<c016a9a4>] (unwind_backtrace+0x0/0xe4) from [<c02d7498>] (kobject_add_internal                                                                                
+0x188/0x1c8)            
[<c02d7498>] (kobject_add_internal+0x188/                                      
x68/0x8c)
[<c02d77ac>] (kobject_add+0x68/0x8c) from [<c03196e4>] (device_add+0xac/0x4a4)
one_wire_status: 4
[<c03196e4>] (device_add+0xac/0x4a4) from [<c0319b64>] (device_create_vargs+0x70
/0xb8)
[<c0319b64>] (device_create_vargs+0x70/0xb8) from [<c0319bc8>] (device_create+0x
1c/0x24)
one_wire_status: 4
[<c0319bc8>] (device_create+0x1c/0x24) from [<c030711c>] (misc_register+0xbc/0x1
28)
[<c030711c>] (misc_register+0xbc/0x128) from [<bf16b044>] (dev_init+0x44/0x64 [m
ini6410_leds])
one_wire_status: 4
[<bf16b044>] (dev_init+0x44/0x64 [mini6410_leds]) from [<c01654fc>] (do_one_init
call+0xbc/0x190)
[<c01654fc>] (do_one_initcall+0xbc/0x190) from [<c01acfe8>] (sys_init_module+0x1
598/0x1760)
[<c01acfe8>] (sys_init_module+0x1598/0x1760) from [<c0165e60>] (ret_fast_syscall
+0x0/0x30)
one_wire_status: 4
leds    initialized
insmod: init_module 'mini6410_leds.ko' failed (File exists)
/ #

请问这是怎么回事?感觉前面一直好好的,是哪里出错了??谢谢哈~~
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
5楼  发表于: 2012-07-20 10:43

 回 4楼(蔚蓝梦想) 的帖子

"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."