Disabling Linux driver for Arduino issue - c

I'm writing a kernel module which will be kind of a driver for my Chinese Arduino.
At one moment I had to disable existing arduino driver and make sure that arduino is not determined by system. I did it with rmmod command. Unplugged and plugged in my arduino. But it still determined in /dev/ as ttyUSB0, same as it was before.
Does it mean that I have more drivers on my system which I don't know about? Or every hardware plugged in usb port will be determined as a file regardless of driver existence? 0_0
Also, of course I have an arduino ide installed on my machine. Maybe there is a built-in driver? If so, how can I disable it without removing ide?
Thank you for the answers.

Does it mean that I have more drivers on my system which I don't know
about?
Kernel may be configured to use a particular driver while user space still might change that.
The manual way: rmmod your driver, unplug Arduino, check system log with dmesg. Plug in Arduino, check dmesg again. Automated way: use usb-devices script from usbutils package (apt-get install usbutils) to list usb devices and the drivers associated with them.
After you find the associated driver, most likely ch341, rmmod it, or add to /etc/modprobe.d/blacklist to disable loading of this module permanently.

Related

Socketcan Driver implementation

I am new to creating a driver implementing.
My Application is using socketcan interface and apparently socketcan is not supported by the SOC.
I am planning to write my own driver. The issue I know how simple module for kernel I am not pretty sure where to start for socketcan driver .
If someone can please tell me where can I take reference for building the CAN driver or some git repo where can I use it and any specifics while writing the driver
SocketCan is the name of a Linux subsystem. It can be enabled in the kernel config via CONFIG_CAN. In turn, this subsystem will make use of platform-specific drivers to control the SOC's CAN adapters (if any).
If Linux's CAN subsystem is not enabled, make sure to enable CONFIG_CAN. If it is enabled, and no "can" device show up, the best would likely be to contact the SOC vendor for further guidance / drivers / devicetree / ... In any case, writing a custom driver is probably not necessary here.

Do real software have kernel modules inside them on Linux and other OSes

I like to ask: do applications like Apache Webserver on Linux, Wireshark, and software like network tools and other real world applications that have to do work with network connection, do they need kernel module, If no then is it to what extent a normal practice that applications do have kernel module. Like when I install some application then kernel module installs with it. I know when I enable IIS server from windows, specific kernel module do get enabled that does IIS work. (don't know why that OS does not implement raw sockets api so developer can use)
My question: Some time ago I was trying to make tcp server using raw socket and found that it was something not that easy since kernel does all sorts of things like (correct me if I am wrong)
Checking for spoofed packets
adding its own headers info inside packets
So I am about to Make an application that does following things in kernel
Configuring NIC card like reading card registers and reporting back
shutting down Network Interface
Starting Network interface
Reading packets from DMA RX and reporting average number of packets received to detect DOS attacks and if detects DOS then shutting down specific Interface/ like reporting counter for packets
And the Application will just act as a command controller. Like a user can use the application to make changes specified in above 4 points.
So I like to ask you is it common practice for applications to have a kernel module and why this is a resorted option if someone like to choose embedded kernel module in applications,
Above things are for learning purposes.
No. Linux programs very rarely have kernel modules. Kernel modules are normally for hardware device drivers.
If a program does need a certain kernel module, it will tell you to install the module yourself. It won't include a copy of the module.
It sounds like you want to make your own driver that replaces the normal driver for your network card. It's possible, but nobody does it. If you want to shut down or start up a network interface, there is already a way to do that without writing your own kernel module. If you want to count the packets, there's already a way to do that. If you want to see all the packets, there's already a way to do that.
There's no way to read card registers already - that's because every card has different registers. But whatever you want to do with those registers, there's probably a way to do it already.

How to reset system in wireless driver?

Can I use emergency_restart() ?
or If I use kill(1, SIGTERM);
I need to include "signal.h", but it seems not work in wireless driver
embedded linux system
device: wireless AP
code section: wireless driver
As Basile says, kill() is a user space syscall, so you can't use it from a kernel module. It's a crude way to accomplish what you are trying to do anyways. Unless you have a reason to use emergency_restart() over kernel_restart() I would use the latter. The options you have can be found in reboot.h.
BTW, this is opening a security hole in your system. Since the driver is interpreting the data packet to determine if it is time to restart, there the OS cannot help to determine if that source has authority to perform such an action on your system. You may be better off with a user-space daemon which is run with the appropriate permissions to reboot the computer, and can act as an authentication agent and a reboot agent rather than doing it in your driver.

Raspberry Pi usb redirect issue

Okay I am going to try and be as discriptive as possible here to get this problem solved. I work at a company that makes BIG gear boxes and we have computers that run our Mills/Laths. These computers are currently FIT-PCs running XP. These computers are used to control the laths/mills via a usb to serial converter (PL2303_Prolific usb to serial converter). When it is plugged into an xp machine it is recognized as a com port. SO these machines are very old and are fail left and right, I intend to replace them with a raspberry pi running xfreerdp but I can't seem to get the usb serial device to be redirected to the virtual machine it is remoting into. Has anyone ran into this/know a fix for it? Please ask me questions if you are unsure of something because I am completely stuck here. TLDR Using raspberry pis as thin clients need to push a usb 2 serial cable through to the virtual xp machine
Unfortunately there are known issues with USB on Raspberry Pi. They're aware of the issue and working on it, but it is as of yet unresolved.
The USB Redux thread was created to capture the state of the work as well as the current list of work-arounds. The USB/serial converters are broken is a related thread.
There is hope, however. First, they are working actively to fix it, so I suspect it's just a matter of time. Second, there are a few things you can try.
There's a config file in
/boot/cmdline.txt where you can try adding a few entries. One that appears quite effective is dwc_otg.speed=1 and dwc_otg.fiq_fix_enable=1 (but they didn't help me). See this page for some examples.
Update the kernel (search for rpi-update) to at least #348 (use uname -a to determine the kernel level)
Good luck.
Update (Mar 13 2013). There appears to be a fix for the majority of USB issues as of kernel #389. Use rpi-update to update.

Communicating to USB Device

I bought a usb otoscope from the internet and I want to create an application that uses it. When I plug it into the computer, it reads the device as a USB Camera, and I can use the very barebones software supplied to communicate with it. I'm very new to the idea of communicating with usb all together. I've tried to look at some sites like this: http://www.jespersaur.com/drupal/book/export/html/21, that tell me how to reverse engineer a device. I don't know if I'm going down the right path with this...
I've downloaded USB Snoopy and I can't seem to get it to sniff the packets correctly. I also have Crunchbang linux installed on a different computer but I don't know how to sniff it on that either (especially because the drivers are native to windows). All I want is some sort of API/Interfacing functions for me to call and use. How do I go about doing such a thing? I'm able to locate the device on the device manager in windows, and it tells me hardware ID's and such. I can supply any information if necessary. Thank you.
EDIT - Small description I found of the otoscope: http://microscopesimgv.blogspot.com/2012/08/oasis-ehev2-usbplus-20mp-handheld-usb.html
would this tool help you any?libusbx is a cross-platform user mode library that provides generic access to USB devices
CHEERS!

Resources