Writing Built in Driver for Linux - linux-device-driver

What are the steps in developing a built in Linux driver?
I mean which files must I modify in order to make driver installed when the kernel boots up?
Thanks
Gest

cd /path/to/Kernel
make menuconfig
Highlight Device Drivers, using arrow keys, and press Enter
Now highlight the driver that you want as built-in and press y
Note: Only the drivers prefixed with < >can be built as a module. Pressing Y includes, N excludes, M modularizes features.
Also note that there are some drivers which have two states, i.e built-in or not-included, and these drivers cannot be modularized.
Legend: [*] built-in [ ] excluded module < > module capable
e.g If a user wants I2C drivers to be built in then
cd /path/to/Kernel
make menuconfig
Device Drivers----> (Highlight and Press Enter)
I2C support (Highlight and press 'Y')
Now M will be replaced by * i.e the I2C driver is now built-in.
Build the kernel now and have fun.

If you know the right defconfig file for your target and config name for your driver or subsystem, you can directly add it into /arch/xxxx(arm/sparc/..)/config/***_defconfig as CONFIG_I2C=y.

Related

Creating an X11 frame in mit-scheme + scmutils

I am working through the book Structure and Interpretation of Classical Mechanics, which requires writing scheme code in mit-scheme for its exercises. I've installed scmutils, the scheme library provided with the book, and when I launch mit-scheme, the following items are listed:
Release 10.1.10
Microcode 15.3
Runtime 15.7
SF 4.41
LIAR/x86-64 4.118
SOS 1.8
XML 1.0
Edwin 3.117
X11 1.3
X11-Screen 1.0
ScmUtils Mechanics.Summer 2019
This seems to suggest that X11 support is enabled. However when I use the frame command to try and create a window for a plot,
(frame 0 :pi/2 0 5)
I get the error:
;Could not find plugin: "x11"
;To continue, call RESTART with an option number:
; (RESTART 1) => Return to read-eval-print level 1
This is on Linux with X11, with mit-scheme installed through the package manager (pacman) and scmutils downloaded from the book/course website.
Moreover, some other commands from scmutils that involve invoking X-windows, like show-expression (that generates DVI output from an input math expression and launches XDVI) work fine.
The install guide for mit-scheme says I need libx11-dev (or equivalent) installed if I want support for X11 graphics, but I downloaded the binary package from the repositories and I can't tell if it comes with X11 support.
Figured it out. The version of mit-scheme available in the Arch Linux repositories does not come bundled with the plugin x11 for X11 support, and it wasn't straightforward to add it manually.
Instead I downloaded the source from gnu.org and compiled it manually, then reinstalled scmutils on top for the SICM-specific features.

How do I get GTK based GUI in a Yocto project?

I am developing a kiosk type application using Yocto and a raspberry pi3. I have an hdmi touchscreen attached and have a USB keyboard attached for development only. My problem starts when I try to start GTK in one of my processes.
My project involves creating the kernel, has several processes running for various tasks, and will have a touchscreen GUI based on GTK+3 (using Glade).
My kernel is working and my processes are running and able to communicate with each other. But, now I'm having problems getting any kind of graphical output on the screen. Right now, all I have is console access as root.
When I start my 'display-mgr' process it tries to start up GTK. When it tries to 'gtk_init()', I get:
Gtk-WARNING ++: ...timeinfo...: cannot open display:
I've tried the usual 'export DISPLAY' stuff, but it looks like I don't even have the Xserver installed on the board.
I have:
DEPENDS = "libconfig pkgconfig-native gtk+ gtk+3 glib-2.0 libxml2 gnome-common glade"
in the recipe for my process. I also have: DISTRO_FEATURES_append = " x11" in my image recipe. Is there some package that I've missed?
I would recommend you start with core-image-sato from poky distro, and gradually replace the pieces. Alternatively, use core-image-weston, which would use that instead of x11.

Is a PREEMPT-ible Linux kernel Real Time?

I was configuring rpi-3.8.y (raspbian kernel on 3.8.y branch) using menuconfig and came across the following,
Will selecting a PREEMPT-ible kernel (choice #3) cross-compile a real-time one ?
No.
The closest thing you'll get to real-time with Linux is PREEMPT_RT, which is an out-of-tree patch set, and clearly not present in whatever kernel sources you're building.

Problems with RASP lemmatizer in GATE (using Mac)

I am analysing novels in English to extract relevant linguistic information from them. To this end, I am using GATE and need a lemmatizer, so I was trying to use the RASP tool with one of the example pipelines that are suggested:
1) RegEx Sentence Splitter
2) RAPS2 Tokenizer
3) RASP2 POS Tagger
4) RASP 2 Morphological Analyser
5) RASP2 Parser.
I am using a desktop Mac (OS X 10.9.4) and the latest version of GATE. When I load the RegEx Sentence Splitter in the "Processing Resources" of GATE, I have no problem. But then, when I try loading the first RAPS tool, RAPS2 Tokenizer, I get an error message saying "gate.creole.ResourceInstantiationException: java.lang.Exception: Executable /Applications/gate-8.0-build4825-ALL/plugins/Parser_RASP/resources/tokenise/token.x86_64_mac os x does not exist
at com.digitalpebble.rasp2.token.RASPTokenizer.init(RASPTokenizer.java:71)
at gate.Factory.createResource(Factory.java:432)
at gate.gui.NewResourceDialog$4.run(NewResourceDialog.java:250)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.Exception: Executable /Applications/gate-8.0-build4825-ALL/plugins/Parser_RASP/resources/tokenise/token.x86_64_mac os x does not exist"
and the RASP2 Tokenizer does not get loaded into GATE.
Can you tell me why this is? What is happening? How can I solve it?
RASP itself is a native (non-Java) program. The GATE plugin includes a selection of different versions of the RASP binary compiled for specific platforms, and tries to select the appropriate one automatically by constructing a file name from the architecture and operating system name of the host platform.
There isn't a .x86_64_mac os x variant, but 64-bit Mac OS can run 32-bit binaries. The .ix86_darwin version works for me on OS X (10.10) so you should be able to make it work by making a copy of or a link to the token.ix86_darwin file named token.x86_64_mac os x (including the spaces). In a Terminal:
cd /Applications/gate-8.0-build4825-ALL/plugins/Parser_RASP/resources/tokenise
ln -s 'token.ix86_darwin' 'token.x86_64_mac os x'

In Debian Linux can I build a single driver to become permanently part of my kernel image and part of my vmlinux file (for debugging)

I've got a custom kernel that I've built locally with gdb and kgdb enabled and installed. I have the vmlinux file for it that I use for source level kgdb. Each time I make a change I've been rebuilding the entire kernel. But I want to become more efficient than rebuilding whole kernels for every code change.
So I made a mod to my ata driver. Then I did a
make M=drivers/ata
It succeeded. Now how do I replace my previous ata driver with this ata driver and get this updated info into my vmlinux file for source debugging this new driver.
I'm not considering doing an insmod. I want to permanently modify my kernel image to replace the previous ata driver with this ata driver.
I think that is not possible to replace a driver in the Linux binary with a new version. You must use insmod, or recompile the entire kernel. I do not see any problem to recompile the whole kernel. If you already compiled it before, it takes few seconds