tag 标签: gadget

相关博文
  • 热度 5
    2023-9-15 15:40
    1283 次阅读|
    0 个评论
    本文将借助飞凌嵌入式OK3568-C开发板为大家介绍实现USBNET模式的方法,在这之前需要先知道什么是USB Gadget——USB Gadget是指所开发的电子设备以USB从设备的模式通过USB连接到主机。举个例子:将手机通过USB线插入PC后,手机就是USB Gadget。同理,在本文的操作中就是将手机替换成了OK3568-C开发板。 Gadget框架提出了一套标准API,在底层,USB设备控制器(UDC) 驱动则实现这一套API,不同的UDC(通常是SoC的一部分) 需要不同的驱动, 甚至基于同样的UDC的不同板卡也需要对代码进行修改。我们想要实现USBNET也需要驱动,它的名字叫做RNDIS。RNDIS驱动在内核中是存在的,只需要找到配置项并编译进内核即可。 首先进入源码kernel目录,进入menuconfig图形配置界面: 进入menuconfig时需要指定环境,不然直接执行make menuconfig进入的图形配置界面为X86架构。如下图进入的为ARM架构是正确的图形配置界面: 按 /,可以进入搜索界面: 直接搜索rndis,找到写有USB Gadget字样的目录,可以看到有多个路径,可以直接进入USB Gadget目录下去看,那个就是配置RNDIS的选项。 经过寻找最终路径如下图所示: 将RNDIS驱动开启,并选中一些网络协议配置,如下图圈中所示: 找到USB Gadget precomposed configurations,将RNDIS编译进内核(如果选择编译成模块,单独编译内核不会生成 .ko文件,为了省去繁琐挂载步骤,本篇就将RNDIS编译进内核)。 配置完成,选择Exit按键直到退出,“是否保存”选择yes即可: 返回源码目录进入build.sh脚本,注释掉defconfig生成.config文件的命令,使menuconfig配置生效,注释位置如下: 保存退出,单独编译内核,在源码目录下执行./build.sh kernel。编译完成之后会在kernel目录下生成boot.img文件。 单步更新镜像使用瑞芯微官方提供的烧写工具—— RKDevTool 。按住Recovery键按Reset,直到烧写工具显示发现一个LOADER设备后松开Recovery键。 替换图中位置,点击设备分区表,完成后,点击执行,设备重启后,即为烧录完成,右侧也会有烧录进度。开发板重启后,ifconfig -a查看可以看到生成usb0节点。 利用Linux USB Gadget设备驱动可以实现一些比较有意思的功能: 1. 一个嵌入式产品中的某个存储设备,或是一个存储设备的某个分区,可以作为一个U盘被PC识别; 2. 一个嵌入式设备通过USB连接到PC后,在PC端会出现一个新的网络连接,在嵌入式设备上也会有一个网卡设备,你可以配置它们的IP地址,并进行网络通讯,俗称USBNET。 此次使用的是USB3.0接口,因此需要detect激活Type-C 5V转3.3V Type-A,硬件改动为p40的pin1连接c23的正极。将播码开关拨至ON,插入双公头USB线; 强制使USB输出为device /sys/devices/platform/fe8a0000.usb2-phy/otg_mode 打印信息如图所示: 可以在设备管理器网络适配器上看到这个节点,配置一个IP 查看网络连接可以看到一个未识别网络,将这个也配置上IP,注意需要跟OK3568-C开发板配置的IP在同一网段: 使用OK3568-C开发板去ping刚才电脑配置的IP,发现可以ping通。 通过以上信息可以看出,OK3568-C开发板已实现USBNET功能,实现网络共享。
  • 热度 11
    2011-11-24 23:31
    1801 次阅读|
    1 个评论
    I don't know about you, but I'm always watching out for the "thing" (the "gadget" or "gizmo" or software application) that will make me rich beyond my wildest dreams and allow me to retire. When I was younger (and MUCH more foolish), I used to tell myself that even if I somehow became extraordinarily wealthy – like winning the lottery, for example – I would continue working because I enjoyed what I was doing so much. Now... well, let's just say that all you would see would be the dust left behind as I raced away into the sunset. It's not that I don't enjoy what I do work-wise, you understand, it's just that there are so many other fun things I would prefer to be doing with my time, such as working on my hobby projects, writing interesting technology books for kids, and going back to college. And when I say "going back to college," I don't mean to get another degree; instead, I would "cherry-pick" the classes I wanted like "Java Programming" on Tuesday mornings and "Ancient History" on Thursday afternoons, leaving Mondays, Wednesdays, and Fridays to gather my strength for the parties at the weekend ). Of course, I first need to make some serious money. This is why I'm constantly on the look-out for something I could design and build that lots and lots and LOTS of people would want to buy. But how do people come up with these inventions? Well, "Necessity is the mother of invention," as they say. What this means is that one way to invent something useful is to think about what you need yourself and then decide (a) whether other people would want it too and (b) has anyone else done this already. The reason I'm waffling on about this is that I thought I'd got a really good idea. Some time ago (we don't know when) a water pipe started to leak behind the fridge-freezer in our kitchen (this has a water/ice dispenser, which is why it was connected to the water supply). The first we knew about this was a few days ago when the wooden floor started to buckle up, by which time it had absorbed lots and lots of water. Suffice it to say that fixing this is going to take a lot of time and money and is going to be a major pain. Anyway, I was standing in the kitchen glaring at the offending pipe/connection when I thought that it would be a really good idea to have a little electronic "gizmo" that you could put on the floor under or behind the fridge – something like a battery-operated smoke detector (but for water) that would sound an alarm if it detected any dampness. Furthermore, it would have to be cheap enough that anyone could afford to buy a bunch of them and put one anywhere where water might be a problem, like under the kitchen and bathroom sinks, under dishwashers and fridges, and so on and so forth. The thing is that if we had had one under our fridge, we would have had a warning as soon as the leak started and we could have quickly sorted everything out and saved ourselves a lot of tears (metaphorically speaking). I was so enthused about this idea that I immediately emailed my inventor friend Brian LaGrave, one of the founders and vice president of BDH Consulting , because this is the sort of project we like to work on together. Within a few minutes, Brian responded by pointing me at Zircon 63931 Leak Alert Electronic Water Detector – a pack of three costs around $22 (less than $8 each) on Amazon.com (I can't believe I didn't think of looking here myself – I think I was just carried away with enthusiasm). With a rating of 4 out of 5 stars from 143 reviews, this looks to be a really good deal.       Bummer! This is just what I was envisaging (except that I wanted to be the one selling the little beauties). On the bright side, I just order a bunch of these little rascals so I can deploy them throughout the house wherever a leak might occur in the future. Oh well, back to the drawing board...