fl2440添加USB驱动,并添加ntfs的写入
来源:互联网 发布:labview编程详解书 编辑:程序博客网 时间:2024/06/05 16:07
//内核:linux-3.0
内核添加USB支持
[luminqi@localhost linux-3.0]$ make menuconfig
Device Drivers --->
Generic Driver Options --->
(/sbin/hotplug) path to uevent helper //配置u盘的热插拔
[*] Block devices --->
<*> Low Performance USB Block driver //低性能USB块设备驱动
SCSI device support --->
<*> SCSI device support //SCSI设备的支持
<*> SCSI generic support //SCSI通用的支持
[*] Probe all LUNs on each SCSI device
//所有在每个SCSI LUN探针装置
[*] USB support --->
<*> Support for Host-side USB //主机端USB支持
[*] USB device filesystem (DEPRECATED) //
[*] USB device class-devices (DEPRECATED) / /USB设备类设备
<*> USB Monitor //USB监控
<*> OHCI HCD support //支持OHCI标准
<*> USB Mass Storage support //支持USB海量存储
File systems ---> //配置u盘的文件系统
DOS/FAT/NT Filesystems --->
<*> MSDOS fs support
<*> VFAT (Windows-95) fs support
(437) Default codepage for FAT //默认代码页,在下面的语言支持可以找到对应编号
(iso8859-1) Default iocharset for FAT //默认字符集,同理
<*> NTFS file system support //添加NTFS支持
[*] NTFS write support
-*- Native language support ---> //配置u盘的语言格式支持
<*> Simplified Chinese charset (CP936, GB2312)
<*> ASCII (United States)
<*> NLS UTF-8
添加USB结构体变量,加厂商ID和设备ID
[luminqi@localhost linux-3.0]$ vim drivers/usb/serial/option.c
101 @@ -51,6 +51,13 @@102 static void option_instat_callback(struct urb *urb);103 104 /* Vendor and product IDs */105 +static int vendor = 0; /* Add by luminqi */106 +static int product = 0; /* Add by luminqi */107 +108 +/* Vendor and product IDs */109 +#define OPTION_VENDOR_RESERVED 0xFFFF /* Add by luminqi */110 +#define OPTION_RESERVED_DEVICE 0xFFFF /* Add by luminqi */111 +112 #define OPTION_VENDOR_ID 0x0AF0113 #define OPTION_PRODUCT_COLT 0x5000114 #define OPTION_PRODUCT_RICOLA 0x6000115 @@ -446,7 +453,8 @@116 .reason = OPTION_BLACKLIST_SENDSETUP117 };118 119 -static const struct usb_device_id option_ids[] = {120 +static struct usb_device_id option_ids[] = {121 + { USB_DEVICE(OPTION_VENDOR_RESERVED, OPTION_RESERVED_DEVICE) }, /* Add by luminqi */122 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },123 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },124 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) },125 @@ -1079,6 +1087,14 @@125 @@ -1079,6 +1087,14 @@126 static int __init option_init(void)127 {128 int retval;129 + if ((vendor>0) && (product>0))130 + {131 + option_ids[0].match_flags = USB_DEVICE_ID_MATCH_DEVICE;132 + option_ids[0].idVendor = vendor;133 + option_ids[0].idProduct = product;134 + printk("Register option drvier for modem vendor=0x%04x product=0x%04x\n", vendor, product);135 + } 136 +137 retval = usb_serial_register(&option_1port_device);138 if (retval)139 goto failed_1port_device_register;
[luminqi@localhost linux-3.0]$ vim arch/arm/mach-s3c2440/mach-smdk2440.c 11 +#include <linux/gpio_keys.h> 12 +#include <linux/input.h> 13 +#include <linux/mtd/physmap.h> 14 +#include <linux/mtd/mtd.h> 15 +#include <linux/mtd/partitions.h> 16 17 #include <asm/mach/arch.h> 18 #include <asm/mach/map.h> 19 @@ -44,9 +52,48 @@ 20 #include <plat/clock.h> 21 #include <plat/devs.h> 22 #include <plat/cpu.h> 23 +#include <plat/ts.h> /* support Touch screen, */ 24 +#include <mach/regs-clock.h> /* for usb_s3c2440_init() */ 25 +#include <linux/i2c.h> /* for AT24C512 driver */ 26 +#include <linux/i2c/at24.h> /* for AT24C512 driver */ 27 +#include <linux/delay.h>68 @@ -155,13 +202,28 @@ 69 &s3c_device_wdt, 70 &s3c_device_i2c0, 71 &s3c_device_iis, 72 + &s3c_device_dm9000, 73 }; 74 75 +/* fix device descriptor read/64, error -62 bug, value refer to datasheet P255 */ 76 +int usb_s3c2440_init(void) 77 +{ 78 + /* Input Frequency is 12.0000MHz, and MDEV=0x38 PDIV=2 SDIV=2, so output frequency 48.00MHz */ 79 + unsigned long upllvalue = (0x38<<12)|(0x02<<4)|(0x02); 80 + while (upllvalue != __raw_readl(S3C2410_UPLLCON)) 81 + { 82 + __raw_writel(upllvalue, S3C2410_UPLLCON); 83 + mdelay(1); 84 + } 85 + return 0; 86 +} 87 + 88 static void __init smdk2440_map_io(void) 89 { 90 s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc)); 91 - s3c24xx_init_clocks(16934400); 92 + s3c24xx_init_clocks(12000000); 93 s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs)); 94 + usb_s3c2440_init();
编译内核,加载到开发板上,插入U盘后结果如下:
//这个U盘格式为NTFS
>: usb 1-1.1: new full speed USB device number 3 using s3c2410-ohciscsi0 : usb-storage 1-1.1:1.0scsi 0:0:0:0: Direct-Access Teclast CoolFlash 8.07 PQ: 0 ANSI: 4sd 0:0:0:0: Attached scsi generic sg0 type 0sd 0:0:0:0: [sda] 30720000 512-byte logical blocks: (15.7 GB/14.6 GiB)sd 0:0:0:0: [sda] Write Protect is offsd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA sda: sda1sd 0:0:0:0: [sda] Attached SCSI removable diskNTFS volume version 3.1.>: mountrootfs on / type rootfs (rw)/dev/root on / type jffs2 (rw,relatime)proc on /proc type proc (rw,relatime)tmpfs on /tmp type tmpfs (rw,relatime)tmpfs on /dev type tmpfs (rw,relatime)sysfs on /sys type sysfs (rw,relatime)devpts on /dev/pts type devpts (rw,relatime,mode=600)/dev/sda1 on /mnt/usb type ntfs (rw,relatime,uid=0,gid=0,fmask=0177,dmask=077,nls=default,errors=continue,mft_zone_multiplier=1)>: ls mnt/usb/NTFS-fs error (device sda1): ntfs_ucstonls(): Unicode name contains characters that cannot be converted to character set default. You might want to try to use the mount option nls=utf8.NTFS-fs warning (device sda1): ntfs_filldir(): Skipping unrepresentable inode 0x1f6c.NTFS-fs error (device sda1): ntfs_ucstonls(): Unicode name contains characters that cannot be converted to character set default. You might want to try to use the mount option nls=utf8.NTFS-fs warning (device sda1): ntfs_filldir(): Skipping unrepresentable inode 0x1f6b.NTFS-fs error (device sda1): ntfs_ucstonls(): Unicode name contains characters that cannot be converted to character set default. You might want to try to use the mount option nls=utf8.NTFS-fs warning (device sda1): ntfs_filldir(): Skipping unrepresentable inode 0x26.NTFS-fs error (device sda1): ntfs_ucstonls(): Unicode name contains characters that cannot be converted to character set default. You might want to try to use the mount option nls=utf8.NTFS-fs warning (device sda1): ntfs_filldir(): Skipping unrepresentable inode 0x25.2.txt chapter6_key_progressbar_handler3.txt chapter6_prj_qq_handlerLAD1.asm linux-3.0System Volume Information startActivitychapter5_prj_qq_activity u-boot-2010.09>: usb 1-1.1: USB disconnect, device number 3NTFS-fs error (device sda1): write_mft_record_nolock(): I/O error while writing mft record 0x5! Marking base inode as bad. You should unmount the volume and run chkdsk.NTFS-fs error (device sda1): __ntfs_write_inode(): Failed (error 5): Run chkdsk.NTFS-fs warning (device sda1): ntfs_put_super(): Volume has errors. Leaving volume marked dirty. Run chkdsk.>: ls mnt/usb/>:
usb 1-1.1: new full speed USB device number 5 using s3c2410-ohciscsi2 : usb-storage 1-1.1:1.0scsi 2:0:0:0: Direct-Access Lenovo USB Flash Drive 1100 PQ: 0 ANSI: 0 CCSsd 2:0:0:0: Attached scsi generic sg0 type 0sd 2:0:0:0: [sda] 3963904 512-byte logical blocks: (2.02 GB/1.88 GiB)sd 2:0:0:0: [sda] Write Protect is offsd 2:0:0:0: [sda] No Caching mode page presentsd 2:0:0:0: [sda] Assuming drive cache: write throughsd 2:0:0:0: [sda] No Caching mode page presentsd 2:0:0:0: [sda] Assuming drive cache: write through sda: sda1sd 2:0:0:0: [sda] No Caching mode page presentsd 2:0:0:0: [sda] Assuming drive cache: write throughsd 2:0:0:0: [sda] Attached SCSI removable disk>: ls mnt/usb/$RECYCLE.BIN ?????????.ppt1.docx ??????????.doc15????????????A???.doc ??????????.docx201421112103 ???.doc ????????????.doc2016???????????.pdf ?????????????.doc2017?????(1).docx ?????????????????--??.doc?? ?????????????????201421112104.doc??.doc ???????????????????.docx??.mp3 ????????????????????.docx
mdev会在/etc目录下找mdev的配置文件: mdev.conf. 如果该文件不存在,那么在执行mdev –s这个命令时,
会提示找不到mdev.conf,这时我们可以建一个空的mdev.conf文件解决这个问题。下面创建使用mdev自动挂载u盘和SD卡的配置etc/mdev.conf
vim etc/mdev.conf
sd[a-z][0-9] 0:0 0777 @(mount /dev/$MDEV /mnt/usb)sd[a-z] 0:0 0777 $(umount /mnt/usb)ub[a-z][0-9] 0:0 0777 @(mount /dev/$MDEV /mnt/usb)ub[a-z] 0:0 0777 $(umount /mnt/usb)mmcblk[0-9]p[0-9] 0:0 0777 @(mount /dev/$MDEV /mnt/sdc)mmcblk[0-9] 0:0 0777 $(umount /mnt/sdc)
#ub[a-z][0-9] 0:0 0777 @(mount /dev/$MDEV /mnt/usb)#ub[a-z] 0:0 0777 $(umount /mnt/usb)
在这里最好取消掉注释,因为有些U盘识别为UB开头,如果没取消可能会识别不了U盘还有一个问题就是某些牌子的U盘会识别不了,就算是FAT32也识别不了,估计是内核
的问题,但总的来说大多都可以识别挂载
下面说说怎么添加对NTFS写的支持
make menuconfig
File systems --->
<*>FUSE (Filesystem in Userspace) support //支持用户空间文件系统,这样就可以使用ntfs-3g挂载
<*> Character device in Userspace support
先安装ntfs-3g,使用源码安装,因为ntfs是给ARM使用的,所以先配置,要用到交叉编译器
[luminqi@localhost 3rdparty]$ wget https://tuxera.com/opensource/ntfs-3g_ntfsprogs-2017.3.23.tgz
[luminqi@localhost 3rdparty]$ tar zxvf ntfs-3g_ntfsprogs-2017.3.23.tgz
[luminqi@localhost 3rdparty]$ cd fl2440/3rdparty/ntfs-3g_ntfsprogs-2017.3.23
[luminqi@localhostntfs-3g_ntfsprogs-2017.3.23]$ ./configure CC=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc RANLIB=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-ranlib LD=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-ld --build=i686 --host=arm-linux --prefix=/home/luminqi/ntfs
关于上面这个命名就是为了配置,为了给ARM使用
CC对应arm-linux-gcc,这个一般都要有
RANLIB对应arm-linux-ranlib
LD对应arm-linux-ld
//对于RANLIB和LD,因为之前没添加上就make,报错说要添加上这两个参数,说明要编译ARM版本的话这两个参数不可缺少,注意要大写,不要小写
--build 指定软件包安装的系统平台.如果没有指定,默认值将是'--host'选项的值.
--host 指定软件运行的系统平台.如果没有指定,将会运行`config.guess'来检测.
--prefix 安装路径,是最常用的选项.制作出的'Makefile'会查看随此选项传递的参数,当一个包在安装时可以彻底的重新安置他的结构独立部分,最好添加.
[luminqi@localhost ntfs-3g_ntfsprogs-2017.3.23]$ make
[luminqi@localhost ntfs-3g_ntfsprogs-2017.3.23]$ make install
[luminqi@localhost ntfs-3g_ntfsprogs-2017.3.23]$ find -iname "ntfs-3g"
./include/ntfs-3g
./src/.libs/ntfs-3g
./src/ntfs-3g
[luminqi@localhost ntfs-3g_ntfsprogs-2017.3.23]$ cd src/.libs/
[luminqi@localhost .libs]$ file ntfs-3g
ntfs-3g: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
[luminqi@localhost .libs]$ cd /home/luminqi/ntfs/
[luminqi@localhost ntfs]$ mv lib/libntfs-3g.so.88.0.0 lib/libntfs-3g.so.88
使用命令file libntfs-3g.so.88
发现是arm支持的
先make下内核,重新烧到开发板
接下来将ntfs-3g和libntfs-3g.so.88传到开发板
依次放在/usr/bin 和/usr/lib
bin 目录下 tftp -gr ntfs-3g 192.168.1.2
lib 目录下 tftp -gr libntfs-3g.so.88 192.168.1.2
主目录下 chmod a+x /usr/bin/ntfs-3g
在/mnt/下新建文件夹ntfs
接上NTFS格式的U盘,这时会自动挂载
/dev/sda1 on /mnt/usb type ntfs 但是挂载在这里还是不支持写
先手动卸载
umount /mnt/usb
再手动挂载,用到ntfs-3g这个工具
/usr/bin/ntfs-3g /dev/sda1 /mnt/ntfs -o silent,umask=0
这样总算支持了NTFS的写!
当然如果要自动挂载到 /mnt/ntfs,就要修改根文件系统里的etc/mdev.conf,重新制作jffs2文件系统
- fl2440添加USB驱动,并添加ntfs的写入
- fl2440添加USB驱动
- fl2440添加内核usb驱动时的问题
- fl2440添加内核usb驱动时的问题
- fl2440 添加 eeprom驱动,并测试
- FL2440添加DS18B20驱动
- FL2440添加DS18B20驱动
- FL2440开发板Linux内核添加USB驱动
- 关于fl2440开发板Linux内核添加USB驱动的问题
- fl2440添加SD卡驱动
- fl2440——移植USB驱动、内核添加USB支持、U盘挂载
- ARM9开发板FL2440移植Linux-3.0内核————添加USB驱动
- FL2440驱动添加(1):hello world 驱动模块添加
- FL2440驱动添加(3)LCD驱动添加学习笔记
- Fl2440内核添加DM9000网卡驱动
- FL2440添加自带led驱动
- 添加USB驱动
- 内核添加USB驱动
- 巧用模板,不仅能提升AS开发效率,还能装逼
- Linux Kernel 学习笔记4:自动创建设备节点
- MongoDB的安装和配置
- 系统延迟及定时机制
- C#中using用法
- fl2440添加USB驱动,并添加ntfs的写入
- 机器学习笔记(三) 朴素贝叶斯分类
- 拍卖(京东2017实习生招聘真题)
- url中文乱码
- c# 设计模式-单例模式
- python学习笔记(四)模块、面向对象
- 递推求解专题训练
- Pyhon 网络爬虫--简单的爬取功能
- 判断元素在数组中出现的次数