I have a Freescale i.MX board on which I run the Linux 3.0.35 kernel.
I want to test if the Kernel Crypto API of my Linux system works. I just found out the test program is called tcrypt. I see that under /lib/modules/ there is a tcrypt.ko in the drivers directory. This being the case, is there anyway I can test run this library? How do I call it? Do I need to reconfigure my kernel to "enable" something to call it?
Please keep in mind that I am new to kernel API's.
I had to compile the kernel modules. This built the "tcrypt.ko" module too. Then I used "insmod" command to load the module. Once loaded, the module was started with :
modprobe tcrypt sec=1 mode=200
(where mode is the algorithm to test)
Related
Suppose I have x86-64 machine with some version of Linux kernel. And I have directory with kernel sources of another version. The kernel was built for arm arch and loaded to the appropriate device.
Now I need to rebuild just one kernel module in this big directory.
I read this post and tried something like
make path/to/the/module/itself.ko
, but it build module for amd64.
When I try
make M=path/to/the/module/
it gives a bunch of arch-related C-errors.
Could someone explain how can easy use this ARM-ready environment to rebuild some kernel module?
You could try:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- M=path/to/the/module/
Also read:
Cross compiling a kernel module
gcc-arm-linux-gnueabi command not found
I'm new in kernel development driver and I'm trying to develop a Linux kernel module, using the this module information:
http://lxr.free-electrons.com/source/drivers/pwm/pwm-tiehrpwm.c
But I didn't understand how to use it. How could adapt this module or better, how to create a new module using functions contained in this file like ehrpwm_pwm_config, ehrpwm_pwm_enable?
PS:I don't want to use sysfs, I would configure the pwm signal programmatically. I'm using a Beaglebone Black board running a Debian distribution , and cape-universaln.
Thanks
You need to enable CONFIG_PWM_TIEHRPWM in your .config file of your linux-kernel. By default, CONFIG_PWM_TIEHRPWM is not set and you need to enable it as CONFIG_PWM_TIEHRPWM=y, if you want to build it as a part of kernel image, or as CONFIG_PWM_TIEHRPWM=m, if you want to build it as a LKM.
Then, build your kernel as make -j12 and insmod your module as:
#insmod /lib/modules/$uname -r/drivers/pwm/pwm_tiehrpwm.ko if you have built it as a LKM. Check Linux kernel documentation on how to configure pwm!
I've an I2C storage CHIP attached with system, A kernel space driver program of that CHIP is functioning with insmod / rmmod from running system.
But I would like to add this program with kernel source, so that on Kernel booting (from zImage) it will read from I2C CHIP, and Print something (e.g. Serial #) from it.
My question is, is it enough to add the driver object with kernel/Makefile
as obj-y += ?
while searching for Kernel module writing and so on, you'll find a hundreds of thousands "hello_world.c" program, that will describe how you can print
hello_world at kernel log, when your kernel and system all working and up. Which are called loadable kernel module, using program like insmod to load and rmmod to unload.
But, I was searching how to load my own script (i.e. that hello_world.c) when kernel is booting, and wanna see something on console that exactly coming from kernel at booting time, then google is almost silent.
Well, its just not difficult, and quite easy. What I've done by myself to get the printk() message at kernel booting is -
Kept the hello_world.c program inside ./kernel/driver (You can keep it almost anywhere inside Kernel source folder also can make your own folder, but that will require your own Makefile).
And edit the ./kernel/driver/Makefile to add obj-y += hello_world.o
at the end of the Makefile.
Then compile the full kernel and generated zImage transferred to sd-card.
While booting, just after USB HID core driver, I am able to see my custom message from hello_world printk().
[ 3.652944] usbcore: registered new interface driver usbhid
[ 3.657253] usbhid: USB HID core driver
[ 3.660152] HELLO: HELLOING WORLD from KERNEL BINARY
NOTE:- Unlike, loadable module, function maked with __exit would never called by compile when subjected code is in-built with kernel source.
i.e. in Such case hello_world.c is "Programmed to received (read include) but can't never leave"
I would ultimately like to modify and compile the existing Linux USB storage driver and test it. For the first step, I wanted to compile the module as is.
I downloaded the latest Linux kernel (version 3.12) and extracted it to ~/linux-3.12.
I found the driver I wanted to compile: drivers/usb/storage, but when I ran make, I got the following error:
make: *** No targets. Stop.
I found many guides online, but none of them worked for the USB storage driver. All I want is to compile this one module and get the .ko so I can test it out.
NOTE: I'm running Ubuntu 13.04 64-bit, and uname -r outputs 3.8.0-30-generic - I'm not sure if that's the problem, but I managed to compile the whole Kernel before. I don't want to do that now because it takes an eon.
If you wanted to build the drivers/usb/storage module you would do this:
make M=drivers/usb/storage
from the root directory of the kernel tree. Before doing so, you will need to make sure that your configuration is the same as the config of the running kernel.
You can't simply take the source code for one kernel and use it to build modules for another one. The module needs to be built from the same source and with the same configuration as the kernel itself.
Basically, you need to find the source code for the Ubuntu kernel you're running. In Ubuntu, as in Debian, that can be done with 'apt-get source '. The package name is probably something like 'linux-image-3.8-2-amd64'.
Once you have the source code you need to find the configuration of your running kernel. Fortunately Ubuntu keeps that in /boot/config-3.8-....
Copy that config to your kernel source tree as .config and run 'make oldconfig'. Now you should be able to build the module (assuming it's not already built into your kernel!).
Hey there,
following problem:
I'm using a rather weird linux distro here at work (Centos 5) which seems to have an older kernel (or at least some differences in the kernel) and you can't simply update it.
The program I need to install needs a function crypto_destro_tfm (and prob some more, but this is the only error at this point) which is included in the file linux/crypto/api.c - so I assume its in the kernel module crypto_api. Problem is: On my distro, I don't even have an crypto/api.c and even though I do have a module crypto_api.ko it seems that this function isn't in there.
My plan is the following: Take the crypto_api from a newer linux distro and then compile it and load the module into my centos.
Now I hope that some of you can tell me what I need to do to rebuild and replace that module. Of course I do have all the source files from a newer kernel. (Just to remind you: I can't simply recompile and use a newer kernel, b/c centos sucks in this way)
Thank you
FWIW: Here's the exact error
WARNING: "crypto_destroy_tfm" [/home/Chris/digsig-patched/digsig_verif.ko] undefined!
There is a good chance backporting API change in an older kernel will lead to a cascade of problem. Let's suppose you backport crypto api of version 2.6.Y to your local version, 2.6.X
Now you have the following situation :
module crypto api export 2.6.Y functions
your external module might be Happy with that situation
all other module that depends on version 2.6.X of the crypto API will complain.
But wait, I can backport recent kernel code into all the modules that complain, and here we go... Oops, but then we have the former situation, but now each backported module might trigger a similar situation.
If you can't update the CentOS kernel, because the CentOS kernel has a lot of custom code you are afraid to loose when going with a "vanilla" kernel, then you may find that it is an easier task to "downgrade" your external module :
Look at the current crypto API (for example using lxr.linux.no)
Look at your kernel version of this API
Try to see how the new API could be replaced with call to the old API to provide a similar function.
Modify your external module to use the old API instead of the new one.
In any case, you may not be able to replace your kernel with a vanilla one, but you should at least be able to rebuild it, and then to patch it and rebuild it etc... If you can't do this simple task, then I don't think backporting anything will be successful.
Try downloading the SRC RPM from a newer version of CentOS which has the module and recompile the RPM on your CentOS 5:
rpmbuild --rebuild kernel-X.XX-X.src.rpm
I don't have a copy of CentOS to compare with so you will want to read the man page on rpm/rpmbuild, but I've found recompiling the whole package which includes the kernel and all it's modules to be safer than trying to just porting one module from a newer kernel. I do this occasionally on Debian/Ubuntu when I need a newer package for something.