I'm hoping to find a generic mechanism in Linux to toggle LEDs that are wired up to a GPIO controller in an embedded application.
I'm able to use either JTAG or my bootloader (setting the registers directly). However it'd be awesome to toggle some lights from usermode
I'm not well versed in this on Linux, is there a standard kernel driver that I can call from my usermode application? or do I need to write a driver for my application?
I've done a websearch and found ideas ranging from writing my own driver, to libraries that feel adhoc. I'm hoping to find the most 'standard' way, thought the stackoverflow crowd would have a good opinion
any tips would be great
You want to use the sysfs interface to GPIOs
http://www.kernel.org/doc/Documentation/gpio.txt
In that link search for "Sysfs Interface for Userspace"
I have no idea what type of system you are on, or if support for this is already enabled in your kernel or not, but that is where you want to look.
Related
I am looking into persona devices as described in Appendix G of the Redhawk manual.
Is there a detailed "how to" for this anywhere?
In my scenario my 'Programmable Device' would be a Redhawk FEI device that interfaces with a kernel API that controls tuners, fans, gps, buttons and LCD displays. I would like to break this out into three or four persona devices that interface with the main FEI Device.
Thought I'd ask.
If you head to Geon's github and look at the RFNoC_ProgrammableDevice and RFNoC_DefaultPersona, you can get an idea of how these Devices interact with one another. It should be noted that these Devices are still under development. Unfortunately, the manual appendix you mentioned and these examples are really the closest thing to a "how to" there is right now.
That being said, this pattern is generally reserved for FPGAs, with the programmable Device controlling access to the programmable hardware (and FEI functionality, if present) and the persona(s) controlling access to specific bit file capabilities. If you're not interacting with an FPGA, then the pattern will most likely be more trouble than it's worth to obtain modularity.
I remember reading some books about Linux Device drivers around the end of my university education for Comp. Science. Soon there-after I got a job and haven't really worked much with Linux/Embedded (I do mostly java stuff now). However it's something I want to look into.
Anyways I recall reading an online article (ill edit post if I can find it) about writing a USB Driver for Linux for a Little "USB Missile Turret" similar to this:
http://www.thinkgeek.com/geektoys/warfare/8a0f/
Anyways it went into detail about how to write the driver without a driver being provided (the guy just found a generic one on ebay....and figured out how to like...write the driver just by looking at the components and such). ANYWAYS it was pretty amazing.
I have a pretty good clue about how low level embedded stuff works, but thats for stuff like AVR's/PIC Microcontrollers, I have no idea how something like this would be written for like a Normal processor in a PC.
Anyways I guess what Im asking is.....how do you figure out this kinda stuff, where would I find such information.
edit: found the link
http://matthias.vallentin.net/blog/2007/04/writing-a-linux-kernel-driver-for-an-unknown-usb-device/
(It's way more confusing then I thought, I didn't realize he reverse engineered a Windows USB driver..im guessing it'd be impossible to figure out without snooping through a windows driver?)
The Linux kernel and drivers are GDFL source. You can read the code, change them, compile them, and experiment to your heart's delight with them. That is a pretty good way to learn.
Currently Roland does not make drivers for Linux, so I am starting a project to write a driver for the Roland GR-55 Guitar Synthesizer, but after looking around, I find I have several options and not sure which is the best or most current method, so I thought I'd ask before waisting a lot of time on this.
This device uses USB, it controls the MIDI and Audio devices in the GR-55.
ALSA or libusb api are two choices; both are new to me; its been years since I wrote a device driver and it was for Unix back in the 80's, but I do know I can figure out how, once I know what tools to use, which I'm guessing both use C still; I have looked at the libusb api; very nice; but I have no idea about ALSA project; seems they are geared into getting modules into the kernel to achieve this.
I would like to find programmers that have worked with Roland like Device Drivers dealing with MIDI and Audio that might be able to help point me in the right direction; I have asked Roland for help; will be waiting for a reply, but not wanting to hold my breath, I think getting started would be my best option; even if they do help, they will only be suppling technical specs, which would be great.
I hope I gave enough details; not much else to say when asking a question about Device drivers.
We are considering using the vendor and product ID of a USB device (obtained via IOKit) to unlock certain features of an application. I'm aware that these values can be spoofed, but I'm not sure how easily it can be done on OSX. What is involved in spoofing the vendor and product ID? Is it something that a non-programmer can do fairly easily?
I suspect it would be fairly easy (for a programmer) to create a kext that creates a reasonably realistic IOUSBDevice object in kernel space. However, once done anyone would be able to load it.
It may also be possible to build a codeless kext using AppleUSBMergeNub to masquerade a device as another (though I haven't tested this, it looks like it might work, assuming you only try to match the IOUSBDevice without actually using it).
It would probably be easier to just hijack your API calls in userspace and give your software the answers it expects.
A non-programmer cannot do that. What you can do is writing a kernel extension (an IOKit driver) for the device, that has a matching dictionary matching the real vendor-/product-ID of the device, which causes the system to automatically load the kernel extension when this device is connected and pass a reference to the device object. The driver is now responsible for initializing the device and create all necessary user space information that is necessary for the IOKit framework (the user space library) to communicate with the device. Usually Apple has default IOKit drivers for most USB device classes (that's why you don't need an extra driver for every USB mouse or keyboard for example), but if there is a more specific driver found, then this driver will be used instead. And when creating the user space data, of course the driver may lie about the vendor-/product-ID, causing the user space program to see false values. Since IOKit is written in C++ and heavily depends upon objects and object inheritance, it is not even necessary to write the driver from scratch, but instead it can inherit from Apple's default driver and just override some methods and otherwise rely upon the super implementation. However, writing IOKit kernel drivers is not that easy and even people developing Mac software for years may have no idea how to do that and the IOKit documentation is one of the worst ones Apple is offering.
So to answer your question: Is it possible? Yes. Is it fairly easy? No. Can non-programmers do it? Certainly not, unless someone else has written a ready to use extension for them, that they only need to install.
It's actually rather EASY, and I'm definitely not a programmer!
Found the guide here
http://rolande.wordpress.com/2012/10/25/getting-the-aten-usb-serial-adapter-working-with-mac-osx-lion
Thanks, Rolande!
I was able to change the IDs of a USB Ethernet adaptor I bought on eBay to use another driver with Mac OS X 10.8.
Since nobody has answered so far, I've stumbled across a page which basically says that you can get an Arduino and program it to return any VID/PID/serial that you want. I still can't find any software-only way to do this.
I can create A OCX in Delphi code to do that
And supply infomation to send/receive data to the USB with other states like:- is it still connected.
Natraly I need a little more detail than that in case that same chip is connected from another product.
example frendly name, device desription.............
Recently, i began developing a driver of an embedded device running linux.
Until now i have only read about linux internals.
Having no prior experience in driver devlopment, i am finding it a tad difficult to land my first step.
I have downloaded the kernel source-code (v2.6.32).
I have read (skimped) Linux Device Drivers (3e)
I read a few related posts here on StackOverflow.
I understand that linux has a "monolithic" approach.
I have built kernel (included existing driver in menuconfig etc.)
I know the basics of kconfig and makefile files so that should not be a problem.
Can someone describe the structure (i.e. the inter-links)
of the various directories in the kernel-source code.
In other words, given a source-code file,
which other files would it refer to for related code
(The "#include"-s provide a partial idea)
Could someone please help me in getting a better idea?
Any help will be greatly appreciated
Thank You.
Given a C file, you have to look at the functions it calls and data structures it uses, rather than worrying about particular files.
There are two basic routes to developing your own device driver:
Take a driver that is similar to yours; strip out the code that isn't applicable to your device, and fill in new code for your device.
Start with the very basic pieces of a device driver, and add pieces a little at a time until your device begins to function.
The files that compose your driver will make more sense as you complete this process. Do consider what belongs in each file, but to some extent, dividing a driver among files is more an art than a science. Smaller drivers often fit into just one or two files.
A bit of design may also be good. Consider what you device does, and what your driver will need to do. Based on that, you should be able to map out what functions a device driver will need to have.
I also believe Linux Device Drivers, Third Edition may help you get on your way to driver development.
Linux files themselves include files based on what they do, what layer they are in, and what layer they access of the call stack. The Big Picture truly informs how each file is related to the next.
I had to fix a kernel driver once. My biggest tip (if you use vim) is to set it up with ctags so you can jump around the kernel source with ctrl-] every time you see a function you don't understand.