由于本人需要将sd卡作为从设备使得pc能够识别为U盘,即Mass Storage设备,在论坛得到的都是现成的,需要下载,我懒得下载,就查资料得到以下方法:
首先内核需要进行以下设置:
Device Driver ---->
USB support---->
* USB Mass Storage support
Device Driver ---->
USB support---->
USB Gadget Support--->
<M> USB Gadget functions configurable through configfs
* Generic serial bulk in/out
* Mass storage
* Function filesystem
[M] USB Gadget precomposed configurations
[M] Mass storage Gadget
然后编译内核会生成以下三个ko文件:
drivers/usb/gadget/libcomposite.ko,
drivers/usb/gadget/legacy/g_mass_storage.ko,
drivers/usb/gadget/function/usb_f_mass_storage.ko,
需要將此三个文件复制到到rootfs或是系统可以存取到的地方。
rootfs根文件系统设置:
在etc/init.d/rcS 添加以下内容(我将三个文件存到了自己建的目录/ts下):
insmod /ts/libcomposite.ko
insmod /ts/usb_f_mass_storage.ko
insmod /ts/g_mass_storage.ko file=/dev/mmcblk0p1 stall=0 removable=1
启动后打印如下:
[ 5.794850] Mass Storage Function, version: 2009/09/11
[ 5.800062] LUN: removable file: (no medium)
[ 5.804536] LUN: file: /dev/mmcblk0p1
[ 5.808198] Number of LUNs=1
[ 5.812871] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[ 5.819987] g_mass_storage gadget: userspace failed to provide iSerialNumber
[ 5.827029] g_mass_storage gadget: g_mass_storage ready
启动后电脑也识别到了U盘,打开U盘正是我在板子上的SD卡
离线
人山人海中削尖脑壳,钻到前排,感谢楼主热心分享。(数了一下应该够十五个字了)
离线
人山人海中削尖脑壳,钻到前排,感谢楼主热心分享。(我没数,但是肯定够十五个字了)
离线
人山人海中削尖脑壳,钻到前排,感谢楼主热心分享。(我没数,但是肯定够十五个字了,后面的接上)
离线
一直USB有问题,原来Gadget 是模块加载的
离线
楼主,你用的内核版本是多少?
离线
请问是用的那个版本的内核呢,谢谢!
由于本人需要将sd卡作为从设备使得pc能够识别为U盘,即Mass Storage设备,在论坛得到的都是现成的,需要下载,我懒得下载,就查资料得到以下方法:
首先内核需要进行以下设置:
Device Driver ---->
USB support---->
* USB Mass Storage supportDevice Driver ---->
USB support---->
USB Gadget Support--->
<M> USB Gadget functions configurable through configfs
* Generic serial bulk in/out
* Mass storage
* Function filesystem
[M] USB Gadget precomposed configurations
[M] Mass storage Gadget然后编译内核会生成以下三个ko文件:
drivers/usb/gadget/libcomposite.ko,
drivers/usb/gadget/legacy/g_mass_storage.ko,
drivers/usb/gadget/function/usb_f_mass_storage.ko,
需要將此三个文件复制到到rootfs或是系统可以存取到的地方。rootfs根文件系统设置:
在etc/init.d/rcS 添加以下内容(我将三个文件存到了自己建的目录/ts下):
insmod /ts/libcomposite.ko
insmod /ts/usb_f_mass_storage.ko
insmod /ts/g_mass_storage.ko file=/dev/mmcblk0p1 stall=0 removable=1启动后打印如下:
[ 5.794850] Mass Storage Function, version: 2009/09/11
[ 5.800062] LUN: removable file: (no medium)
[ 5.804536] LUN: file: /dev/mmcblk0p1
[ 5.808198] Number of LUNs=1
[ 5.812871] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[ 5.819987] g_mass_storage gadget: userspace failed to provide iSerialNumber
[ 5.827029] g_mass_storage gadget: g_mass_storage ready启动后电脑也识别到了U盘,打开U盘正是我在板子上的SD卡
离线
主线linux 5.2
离线
能否把主线linux5.2传上百度网盘
离线
能否把主线linux5.2传上百度网盘
......上传也挺慢的,你直接在git下吧
离线
......上传也挺慢的,你直接在git下吧
内核版本是"zero-5.2.y"吗?
离线
是的,但是我感觉4.13应该也没问题,相差应该不大
内核版本是"zero-5.2.y"吗?
离线
insmod: can't insert 'usb_f_mass_storage.ko': invalid module for[ 928.535732] g_mass_storage: Unknown symbol fsg_common_set_sysfs (err -2)
mat
[ 928.546607] g_mass_storage: Unknown symbol fsg_common_create_luns (err -2)
[ 928.553866] g_mass_storage: Unknown symbol fsg_common_set_cdev (err -2)
[ 928.560522] g_mass_storage: Unknown symbol fsg_common_free_buffers (err -2)
[ 928.567503] g_mass_storage: Unknown symbol fsg_common_remove_luns (err -2)
[ 928.574417] g_mass_storage: Unknown symbol fsg_common_set_inquiry_string (err -2)
[ 928.581926] g_mass_storage: Unknown symbol fsg_common_set_num_buffers (err -2)
[ 928.589202] g_mass_storage: Unknown symbol fsg_config_from_params (err -2)
[ 928.598633] g_mass_storage: Unknown symbol fsg_common_set_sysfs (err -2)
[ 928.605436] g_mass_storage: Unknown symbol fsg_common_create_luns (err -2)
[ 928.612510] g_mass_storage: Unknown symbol fsg_common_set_cdev (err -2)
[ 928.619187] g_mass_storage: Unknown symbol fsg_common_free_buffers (err -2)
[ 928.626169] g_mass_storage: Unknown symbol fsg_common_remove_luns (err -2)
[ 928.633107] g_mass_storage: Unknown symbol fsg_common_set_inquiry_string (err -2)
[ 928.640619] g_mass_storage: Unknown symbol fsg_common_set_num_buffers (err -2)
[ 928.647871] g_mass_storage: Unknown symbol fsg_config_from_params (err -2)
insmod: can't insert 'g_mass_storage.ko': unknown symbol in module, or unknown parameter
这是什么原因?
离线
是的,但是我感觉4.13应该也没问题,相差应该不大
insmod: can't insert 'usb_f_mass_storage.ko': invalid module for[ 928.535732] g_mass_storage: Unknown symbol fsg_common_set_sysfs (err -2)
mat
[ 928.546607] g_mass_storage: Unknown symbol fsg_common_create_luns (err -2)
[ 928.553866] g_mass_storage: Unknown symbol fsg_common_set_cdev (err -2)
[ 928.560522] g_mass_storage: Unknown symbol fsg_common_free_buffers (err -2)
[ 928.567503] g_mass_storage: Unknown symbol fsg_common_remove_luns (err -2)
[ 928.574417] g_mass_storage: Unknown symbol fsg_common_set_inquiry_string (err -2)
[ 928.581926] g_mass_storage: Unknown symbol fsg_common_set_num_buffers (err -2)
[ 928.589202] g_mass_storage: Unknown symbol fsg_config_from_params (err -2)
[ 928.598633] g_mass_storage: Unknown symbol fsg_common_set_sysfs (err -2)
[ 928.605436] g_mass_storage: Unknown symbol fsg_common_create_luns (err -2)
[ 928.612510] g_mass_storage: Unknown symbol fsg_common_set_cdev (err -2)
[ 928.619187] g_mass_storage: Unknown symbol fsg_common_free_buffers (err -2)
[ 928.626169] g_mass_storage: Unknown symbol fsg_common_remove_luns (err -2)
[ 928.633107] g_mass_storage: Unknown symbol fsg_common_set_inquiry_string (err -2)
[ 928.640619] g_mass_storage: Unknown symbol fsg_common_set_num_buffers (err -2)
[ 928.647871] g_mass_storage: Unknown symbol fsg_config_from_params (err -2)
insmod: can't insert 'g_mass_storage.ko': unknown symbol in module, or unknown parameter
这是什么原因?
离线
有没有勾上 CONFIG_USB_F_MASS_STORAGE ?
分析过程:
$ cd A33/mainline/linux
linux $ grep fsg_common_create_luns -r .
./drivers/usb/gadget/legacy/acm_ms.c: status = fsg_common_create_luns(opts->common, &config);
./drivers/usb/gadget/legacy/mass_storage.c: status = fsg_common_create_luns(opts->common, &config);
./drivers/usb/gadget/legacy/multi.c: status = fsg_common_create_luns(fsg_opts->common, &config);
./drivers/usb/gadget/legacy/nokia.c: status = fsg_common_create_luns(fsg_opts->common, &fsg_config);
./drivers/usb/gadget/function/f_mass_storage.h:int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg);
./drivers/usb/gadget/function/f_mass_storage.c:int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg)
./drivers/usb/gadget/function/f_mass_storage.c:EXPORT_SYMBOL_GPL(fsg_common_create_luns);
linux$ cat ./drivers/usb/gadget/function/Makefile |grep f_mass_storage
usb_f_mass_storage-y := f_mass_storage.o storage_common.o
obj-$(CONFIG_USB_F_MASS_STORAGE)+= usb_f_mass_storage.o
离线
有没有勾上 CONFIG_USB_F_MASS_STORAGE ?
分析过程:
$ cd A33/mainline/linux
linux $ grep fsg_common_create_luns -r .
./drivers/usb/gadget/legacy/acm_ms.c: status = fsg_common_create_luns(opts->common, &config);
./drivers/usb/gadget/legacy/mass_storage.c: status = fsg_common_create_luns(opts->common, &config);
./drivers/usb/gadget/legacy/multi.c: status = fsg_common_create_luns(fsg_opts->common, &config);
./drivers/usb/gadget/legacy/nokia.c: status = fsg_common_create_luns(fsg_opts->common, &fsg_config);
./drivers/usb/gadget/function/f_mass_storage.h:int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg);
./drivers/usb/gadget/function/f_mass_storage.c:int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg)
./drivers/usb/gadget/function/f_mass_storage.c:EXPORT_SYMBOL_GPL(fsg_common_create_luns);linux$ cat ./drivers/usb/gadget/function/Makefile |grep f_mass_storage
usb_f_mass_storage-y := f_mass_storage.o storage_common.o
obj-$(CONFIG_USB_F_MASS_STORAGE)+= usb_f_mass_storage.o
root@guang-virtual-machine:/home/guang/licheepi/linux-zero-5.2.y# grep fsg_common_create_luns -r
Module.symvers:0x00000000 fsg_common_create_luns drivers/usb/gadget/function/usb_f_mass_storage EXPORT_SYMBOL_GPL
drivers/usb/gadget/function/f_mass_storage.c:int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg)
drivers/usb/gadget/function/f_mass_storage.c:EXPORT_SYMBOL_GPL(fsg_common_create_luns);
Binary file drivers/usb/gadget/function/usb_f_mass_storage.ko matches
Binary file drivers/usb/gadget/function/usb_f_mass_storage.o matches
drivers/usb/gadget/function/f_mass_storage.h:int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg);
Binary file drivers/usb/gadget/function/f_mass_storage.o matches
Binary file drivers/usb/gadget/legacy/mass_storage.o matches
Binary file drivers/usb/gadget/legacy/g_mass_storage.o matches
drivers/usb/gadget/legacy/mass_storage.c: status = fsg_common_create_luns(opts->common, &config);
Binary file drivers/usb/gadget/legacy/g_mass_storage.ko matches
drivers/usb/gadget/legacy/multi.c: status = fsg_common_create_luns(fsg_opts->common, &config);
drivers/usb/gadget/legacy/nokia.c: status = fsg_common_create_luns(fsg_opts->common, &fsg_config);
drivers/usb/gadget/legacy/acm_ms.c: status = fsg_common_create_luns(opts->common, &config);
root@guang-virtual-machine:/home/guang/licheepi/linux-zero-5.2.y# cat ./drivers/usb/gadget/function/Makefile |grep f_mass_storage
usb_f_mass_storage-y := f_mass_storage.o storage_common.o
obj-$(CONFIG_USB_F_MASS_STORAGE)+= usb_f_mass_storage.o
root@guang-virtual-machine:/home/guang/licheepi/linux-zero-5.2.y#
有勾选的
但是加载的时候提示这个insmod: can't insert 'usb_f_mass_storage.ko': invalid module
离线
你的ko安装和加载操作可能有问题。
你是怎么做的?
加载驱动如下:
# ls
g_mass_storage.ko libcomposite.ko usb_f_mass_storage.ko
# insmod libcomposite.ko
# insmod usb_f_mass_storage.ko
insmod: can't insert 'usb_f_mass_storage.ko': invalid module format
# insmod g_mass_storage.ko file=/dev/mmcblk0p1 stall=0 removable=1
[ 2108.120204] g_mass_storage: Unknown symbol fsg_common_set_sysfs (err -2)
[ 2108.127009] g_mass_storage: Unknown symbol fsg_common_create_luns (err -2)
[ 2108.134083] g_mass_storage: Unknown symbol fsg_common_set_cdev (err -2)
[ 2108.140753] g_mass_storage: Unknown symbol fsg_common_free_buffers (err -2)
[ 2108.147735] g_mass_storage: Unknown symbol fsg_common_remove_luns (err -2)
[ 2108.154655] g_mass_storage: Unknown symbol fsg_common_set_inquiry_string (err -2)
[ 2108.162164] g_mass_storage: Unknown symbol fsg_common_set_num_buffers (err -2)
[ 2108.169434] g_mass_storage: Unknown symbol fsg_config_from_params (err -2)
[ 2108.179749] g_mass_storage: Unknown symbol fsg_common_set_sysfs (err -2)
[ 2108.186554] g_mass_storage: Unknown symbol fsg_common_create_luns (err -2)
[ 2108.193649] g_mass_storage: Unknown symbol fsg_common_set_cdev (err -2)
[ 2108.200315] g_mass_storage: Unknown symbol fsg_common_free_buffers (err -2)
[ 2108.207296] g_mass_storage: Unknown symbol fsg_common_remove_luns (err -2)
[ 2108.214218] g_mass_storage: Unknown symbol fsg_common_set_inquiry_string (err -2)
[ 2108.221726] g_mass_storage: Unknown symbol fsg_common_set_num_buffers (err -2)
[ 2108.228974] g_mass_storage: Unknown symbol fsg_config_from_params (err -2)
insmod: can't insert 'g_mass_storage.ko': unknown symbol in module, or unknown parameter
离线
先把原来的 ko 文件夹删了, 重新安装: https://whycan.cn/t_2701.html#p21651
类似这个命令:
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make modules_install INSTALL_MOD_PATH=/opt/buildroot-2018.08.2/output/target/
然后用 modprobe 安装驱动, 不要用 insmod
离线
先把原来的 ko 文件夹删了, 重新安装: https://whycan.cn/t_2701.html#p21651
类似这个命令:
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make modules_install INSTALL_MOD_PATH=/opt/buildroot-2018.08.2/output/target/
然后用 modprobe 安装驱动, 不要用 insmod
# insmod g_mass_storage.ko file=/dev/mmcblk0p1 stall=0 removable=1
[ 95.097028] Mass Storage Function, version: 2009/09/11
[ 95.102354] LUN: removable file: (no medium)
[ 95.106983] LUN: removable file: /dev/mmcblk0p1
[ 95.111605] Number of LUNs=1
[ 95.115709] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[ 95.122829] g_mass_storage gadget: userspace failed to provide iSerialNumber
[ 95.129946] g_mass_storage gadget: g_mass_storage ready
# [ 111.714089] g_mass_storage gadget: high-speed config #1: Linux File-Backed Storage
#
#
# fdisk
BusyBox v1.27.2 (2017-11-16 08:24:23 CST) multi-call binary.
Usage: fdisk [-ul] [-C CYLINDERS] [-H HEADS] [-S SECTORS] [-b SSZ] DISK
Change partition table
-u Start and End are in sectors (instead of cylinders)
-l Show partition table for each DISK, then exit
-b 2048 (for certain MO disks) use 2048-byte sectors
-C CYLINDERS Set number of cylinders/heads/sectors
-H HEADS Typically 255
-S SECTORS Typically 63
# fdisk -l
Disk /dev/mmcblk0: 120 MB, 125960192 bytes, 246016 sectors
3844 cylinders, 4 heads, 16 sectors/track
Units: cylinders of 64 * 512 = 32768 bytes
Device Boot StartCHS EndCHS StartLBA EndLBA Sectors Size Id Type
/dev/mmcblk0p1 0,32,33 4,52,48 2048 67583 65536 32.0M 6 FAT16
Partition 1 does not end on cylinder boundary
/dev/mmcblk0p2 4,52,49 15,75,60 67584 245759 178176 87.0M 83 Linux
Partition 2 does not end on cylinder boundary
# ls
g_mass_storage.ko
# cd /
# ls
bin lib32 mnt run ts
dev linuxrc opt sbin usr
etc lost+found proc sys v3s-key-test
lib media root tmp var
# mount /dev/mmcblk0p1 mnt
[ 222.320193] FAT-fs (mmcblk0p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
# cd mnt/
# ls
System Volume Information sun8i-v3s-licheepi-zero.dtb
sun8i-v3s-licheepi-zero-dock.dtb zImage
可以了,感谢大佬。稍后我把细节问题发出来分享给大家!!!
离线
insmod: can't insert 'usb_f_mass_storage.ko': invalid module for[ 928.535732] g_mass_storage: Unknown symbol fsg_common_set_sysfs (err -2)
mat
[ 928.546607] g_mass_storage: Unknown symbol fsg_common_create_luns (err -2)
[ 928.553866] g_mass_storage: Unknown symbol fsg_common_set_cdev (err -2)
[ 928.560522] g_mass_storage: Unknown symbol fsg_common_free_buffers (err -2)
[ 928.567503] g_mass_storage: Unknown symbol fsg_common_remove_luns (err -2)
[ 928.574417] g_mass_storage: Unknown symbol fsg_common_set_inquiry_string (err -2)
[ 928.581926] g_mass_storage: Unknown symbol fsg_common_set_num_buffers (err -2)
[ 928.589202] g_mass_storage: Unknown symbol fsg_config_from_params (err -2)
[ 928.598633] g_mass_storage: Unknown symbol fsg_common_set_sysfs (err -2)
[ 928.605436] g_mass_storage: Unknown symbol fsg_common_create_luns (err -2)
[ 928.612510] g_mass_storage: Unknown symbol fsg_common_set_cdev (err -2)
[ 928.619187] g_mass_storage: Unknown symbol fsg_common_free_buffers (err -2)
[ 928.626169] g_mass_storage: Unknown symbol fsg_common_remove_luns (err -2)
[ 928.633107] g_mass_storage: Unknown symbol fsg_common_set_inquiry_string (err -2)
[ 928.640619] g_mass_storage: Unknown symbol fsg_common_set_num_buffers (err -2)
[ 928.647871] g_mass_storage: Unknown symbol fsg_config_from_params (err -2)
insmod: can't insert 'g_mass_storage.ko': unknown symbol in module, or unknown parameter这是什么原因?
依赖关系不对
insmod libcomposite.ko
insmod usb_f_mass_storage.ko
insmod g_mass_storage.ko file=/dev/mmcblk0p1 stall=0 removable=1
离线
我也照着做了一遍,
我的内核是:
Linux (none) 4.13.16-licheepi-zero+ #7 SMP Fri Sep 11 09:58:04 CST 2020 armv7l GNU/Linux
我的系统是spi flash启动的。
我的步骤是:我没有libcomposite.ko,CONFIG_USB_LIBCOMPOSITE=y。
insmod usb_f_mass_storage.ko
insmod g_mass_storage.ko file=/dev/mtdblock0 removable=1
此时pc发现新盘符。
然后我插入tf卡,U盘盘符就会消失,弹出tf卡,U盘盘符又回来了。所以我file=/dev/mmcblk0p1也是没有盘符的。请问有没有小伙伴知道是什么原因吗?
离线
我插入tf卡的时候,甚至网卡都能down/up一下,我在想这个莫非是一个硬件设计的原因?
[ 2037.365794] dwmac-sun8i 1c30000.ethernet eth0: Link is Down
[ 2038.405897] dwmac-sun8i 1c30000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx
离线
学习学习,正好要搞这个。
离线
由于本人需要将sd卡作为从设备使得pc能够识别为U盘,即Mass Storage设备,在论坛得到的都是现成的,需要下载,我懒得下载,就查资料得到以下方法:
首先内核需要进行以下设置:
Device Driver ---->
USB support---->
* USB Mass Storage supportDevice Driver ---->
USB support---->
USB Gadget Support--->
<M> USB Gadget functions configurable through configfs
* Generic serial bulk in/out
* Mass storage
* Function filesystem
[M] USB Gadget precomposed configurations
[M] Mass storage Gadget然后编译内核会生成以下三个ko文件:
drivers/usb/gadget/libcomposite.ko,
drivers/usb/gadget/legacy/g_mass_storage.ko,
drivers/usb/gadget/function/usb_f_mass_storage.ko,
需要將此三个文件复制到到rootfs或是系统可以存取到的地方。rootfs根文件系统设置:
在etc/init.d/rcS 添加以下内容(我将三个文件存到了自己建的目录/ts下):
insmod /ts/libcomposite.ko
insmod /ts/usb_f_mass_storage.ko
insmod /ts/g_mass_storage.ko file=/dev/mmcblk0p1 stall=0 removable=1启动后打印如下:
[ 5.794850] Mass Storage Function, version: 2009/09/11
[ 5.800062] LUN: removable file: (no medium)
[ 5.804536] LUN: file: /dev/mmcblk0p1
[ 5.808198] Number of LUNs=1
[ 5.812871] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[ 5.819987] g_mass_storage gadget: userspace failed to provide iSerialNumber
[ 5.827029] g_mass_storage gadget: g_mass_storage ready启动后电脑也识别到了U盘,打开U盘正是我在板子上的SD卡
能实现挂载分区下的目录吗 就是挂载目录
离线
离线
离线
请问系统可以使TF启动吗,而且虚拟U盘是TF的分区,可以吗?我使用的是nano
离线
这里插拔USB的时候,nano主板是不是要一直供电5V,即外接电源
离线