调试一个usb驱动,发现在android下无法自动创建设备节点,手动创建设备节点可以正常访问硬件。后来发现是在init进程里面对一些usb设备进行了过滤。
在system/core/init/devices.c 中的下面函数中。
static void handle_generic_device_event(struct uevent *uevent)
{
char *base;
const char *name;
char devpath[96] = {0};
char **links = NULL;
name = parse_device_name(uevent, 64);
if (!name)
return;
if (!strncmp(uevent->subsystem, "usb", 3)) {
if (!strcmp(uevent->subsystem, "usb")) {
/* This imitates the file system that would be created
* if we were using devfs instead.
* Minors are broken up into groups of 128, starting at "001"
*/
int bus_id = uevent->minor / 128 + 1;
int device_id = uevent->minor % 128 + 1;
/* build directories */
mkdir("/dev/bus", 0755);
mkdir("/dev/bus/usb", 0755);
Android USB驱动设备节点创建问题

在调试Android USB驱动时遇到问题,设备节点无法自动创建,导致硬件访问受阻。手动创建设备节点后能正常工作。问题源在于init进程中的设备过滤机制,具体涉及system/core/init/devices.c文件的相关函数。解决方法是添加代码来创建指定名称的设备节点。
最低0.47元/天 解锁文章
1753

被折叠的 条评论
为什么被折叠?



