Device Driver Development in Linux - linux

I plan to learn embedded linux and writing linux device drivers.
After reading about device drivers and walking through some tutorials, I'm a little confused about the kernel-source that to be used for compilation.
I am using ubuntu 11.04 and in my /usr/src/ me find the following:
tijin#tijin-Vostro-460:/usr/src$ ls
gcc-4.4 linux-headers-2.6.38-10-generic-pae
linux-headers-2.6.38-10 linux-headers-2.6.38-8
my questions:
1)do I need a kernel-source to compile the driver code or the headers are enough?
2)where can I get the kernel source code and what is the procedure to install the source code. Please let me know the details.

Headers is enough
from kernel.org - or for Ubuntu specific kernels, follow the documentation
For module compilation instructions, see this question

Yes. You need not only the source but a "make"d source (a compiled kernel source).
The main location to get the kernel source is: http://www.kernel.org
As you're using Ubuntu you can just download the source from the repositories.
Here's the page indicated at Ubuntu's help as a guide for compiling a kernel from source on Natty (11.04):
http://blog.avirtualhome.com/2011/08/03/how-to-compile-a-new-ubuntu-11-04-natty-kernel/

For a fresher to device driver coding the "hello world" driver code reference is here :
http://www.linuxquestions.org/questions/linux-kernel-70/simple-makefile-error-all-nothing-need-to-be-done-600403/ .
This link also discussing the issues related to the Makefile. Important idea that i got from the reference is: Never ever copy-paste the content of a document for creating Makefile.
If you are getting trouble with seeing logs then please refer the link :
http://www.cyberciti.biz/faq/linux-log-files-location-and-how-do-i-view-logs-files/
thanks.

Related

Using Eclipse (with Debian) to modify applications from the official repository

For a university project, I am trying to find a not so cumbersome way to effectively modify certain applications from the official Debian repository, such as eog. I want to clarify that I am unfamiliar with Linux and GTK. My idea was to be able to work comfortably in terms of finding variable and function definitions, trying step by step debugging while getting used to gtk+ and the application's source code. I tried to understand the code while working from the terminal, but in my opinion, it was a pain i* t** a**.
So far, I managed to install the application's build dependencies with
sudo apt build-dep eog
and I received the source-code with
apt-get source eog
After I installed eclipse, I tried to get gtk+ running with the minimum example from the gtk+ reference manual. I found a very useful easy explanation here. It's the answer from Wed, 04 November 2015 12:51.No problem so far. So in theory, I should be able to write GTK+ applications in Eclipse. But when I am trying to make a new project and include eog's .src and .h files, I am running into a mass of unresolved inclusions, missing header files, undefined references etc...
So I wanted to ask: Did anybody work on similar tasks and can provide some help? Or: Does anyone have a better idea maybe?
If anybody should come across this ever again: I found an alternative solution: When you download the source-files of eog, you will come across the meson-build system. Eclipse supports C meson-build projects. I just copied all downloaded source files into the meson-build project in eclipse in could compile it right away.

Header files not found when porting from AIX to linux

I am got source files from an application on IBM AIX and I am trying to build them on Linux. However I am getting compilation errors header file not found.
When compiled source from AIX on Linux got error these headers not found:
usersec.h
userpw.h
sys/mode.h
standards.h
After I Googled I realized they are headers (/usr/include/usersec.h) for user management (user authentication and pwd verification etc) funtions on AIX.
As there is no equivalent header on Linux, I like to know what is best practice to port these functions? What are there equivalent headers/functions on Linux.
As there is not much information I found on net hence posting it here as I am badly stuck. Thank you.
Update: Details of functions being migrated are mentioned in another question

Building Yocto Linux Image with my own program inside of Image

I've successfully built Yocto and can run the Linux enviroment on my embedded hardware. However, I am stuck on where how to place my program into the Image so that when I run the Linux environment on the embedded hardware, I can run my program. I've been trying to find the answer at https://www.yoctoproject.org/docs/current/mega-manual/mega-manual.html , but so far I am either missing something or not fully understanding the documentation. Does anyone have any ideas or examples to guide me to the correct path?
You need to write your own bitbake recipe for building and including the application in the image. See a hello world example here.
Yeah to install your own program binary into the OS image you need to write your own recipe and helloworld is best example to refer.
You can get more additional info like create own layer, create own image and install own code binary into OS image please have a look at https://github.com/prashantdivate/meta-sirius

How to use SCARD_CTL_CODE under linux?

I'm trying on some code to use ACR83 reader under Linux. I have successfully installed and tested pcsc and ccid drivers on my Ubuntu and also I can send/receive APDUs to my smart card. I was trying to use reader's LCD and Pinpad by a piece of code I have previousely tested on MS Windows successfully but each time I use a definition using IOCTL_SMARTCARD_READ_KEY I get an error on make saying: undefined reference to SCARD_CTL_CODE!!!
what is the diference between these definitions on Windows and Linux?
Should I change any thing?
Thanks for your replies.
I found the answer here.
If you define #define SCARD_CTL_CODE(code) (0x42000000 + (code)) your source will be compatible for different platforms, as mentioned in the link above.

Linux application project for zynq7000 in the Xilinx SDK

I'm trying to create a Linux application to run on my Zynq7020. However I don't understand how the Xilinx SDK generate the executable file.
When I create a hello world, for instance, it creates one .elf file and under the debug it creates one object (.o) and one dependency (.d). I want to run it under the Linux that is running on my board, how do I do it?
Thank you very much.
I want to run it under the Linux that is running on my board, how do I do it?
Most likely, you just need to copy/download the .elf file to your target board and run it.
If that doesn't work, try editing your question to supply more info. In particular, what commands "create a hello world" actually executes?
When creating the project in the Xilinx SDK, select that it runs on linux rather than standalone. See this official tutorial for an in-depth explanation.

Resources