driver not working when built as built in driver - linux

I wrote a basic character driver for beagle-bone which prints two message in 1 second interval via a workqueue and a tasklet using printk.
At first i build it as module driver, generated .ko file, load it using insmod command and the print is coming when viewed via dmesg.
Then i built as inbuilt driver and load the uImage and after bootup i checked the dmesg prints. But there is no prints.
In the .config file
CONFIG_MY_DRIVER=y
So its taken as built in driver i think.
How can i confirm whether its actually built in the final image. No error was reported while building.
Is there any additional steps to be done for loading the build in driver.
Please pardon me if i went wrong on any basics. I am really new to linux.

This means that you added it probably somewhere to Kconfig file:
"CONFIG_MY_DRIVER=y"
but, Have you added it to Makefile? It works like that, then kernel during a building an Image, takes all of this directives "CONFIG_*" and use it to build particular source files from Makefile.
Example:
cat fs/ext2/Makefile
ext2-$(CONFIG_EXT2_FS_SECURITY) += xattr_security.o
cat fs/ext2/Kconfig
config EXT2_FS_SECURITY
bool "Ext2 Security Labels"
depends on EXT2_FS_XATTR
so in this example above if your source file is xattr_security.c then you should get xattr_security.o file in fs/ext2 dir, when this is build. You should also see it if your file is build, during a compilation process.

Related

Can't add a directory with code to u-boot project

I wanted to call a C function defined in arm-tf (arm trusted firmware) from a u-boot assembly code. That assembly code of u-boot is arch/arm/lib/gic_64.S. The build process for this doesn't work out as I wanted so I ask it here with simple example.
In u-boot build tree, there is the directory arch/arm/lib. I added a directory arch/arm/lib/testd and put testf.c there. testf.c is just printing a string. In arch/arm/lib/Makefile, I added
libs-y += arch/arm/lib/testd
and in arch/arm/lib/testd/Makefile, I added
obj-y += testf.o
When I do make in u-boot root directory, I find nothing is made under arch/arm/lib/testd. But if I do make arch/arm/lib/testd/testf.o, that file is made. I saw this question but it doesn't help. Actually I guess I should see spl/arch/arm/lib/testd/{built-in.o, testf.o} if it was successful(because I'm building u-boot-spl).
I will be very grateful if anyone could tell me how I should do it. Thanks!
It looks like, if I add in arch/arm/lib/Makefile only
obj-y += testd/
Then by doing make I see arch/arm/lib/testd/testf.o and spl/arch/arm/lib/testd/{build-in.o,testf.o} generated.
The key part was the testd/ not testd.

Does llsubmit take into consideration the LD_LIBRARY_PATH?

I'm having a bit of a trouble running a job on a nVidia cluster. My code is divided into a shared library containing the cuda code and a .cpp file which calls functions from that lib.
The thing is that when I submit the job (llsubmit) I get an error message telling me that ".. cannot open shared object file: No such file or directory"
I've tried adding the path where my .so file is located using the LD_LIBRARY_PATH variable but it still doesn't work.
Could I specify this by adding an entry in my .cmd file?

How to compile the linux kernel with an obsolete option?

OK, so I have this embedded kernel whose network card used to work fine with the LLTEMAC option. The new one with LL_TEMAC doesn't. I still see the code with LLTEMAC in the source, but not in the available option in the .config file:
$ ack-grep LLTEMAC
drivers/net/ethernet/xilinx/xilinx_lltemac/Makefile:10:obj-$(CONFIG_XILINX_LLTEMAC) := xilinx_temac.o
drivers/net/ethernet/xilinx/xilinx_lltemac/xlltemac_main.c:2: * Xilinx Ethernet: Linux driver for the XPS_LLTEMAC core.
drivers/net/ethernet/xilinx/xilinx_lltemac/xlltemac_main.c:452:#ifdef CONFIG_XILINX_LLTEMAC_MARVELL_88E1111_RGMII
...
include/linux/xilinx_devices.h:83:/* LLTEMAC platform data */
Is there a way to compile the kernel with this removed option ?
Simply adding CONFIG_XILINX_LLTEMAC=y CONFIG_XILINX_LLTEMAC_MARVELL_88E1111_GMII=y to the .config file does not do anything as the dislaimer states: # Automatically generated file; DO NOT EDIT.
Thanks.
Why not just update this individual driver to understand the new configuration option?

Embedded linux driver load-up

I'm developing a device driver for embedded linux(ARM).
How can I compile the KO file generated as a part of the kernel,
in a way that the module will be loaded in boot ?
this is the first time I need to compile the driver into the kernel and not as a loadable module. so I'm not sure how to do it.
Thanks,
Ramon.
For your first question, I assume that you want to build your driver statically into the kernel image(not as a module). First, you select a directory in drivers directory where you want to put your driver files. Assume you want to put your files in drivers/char/. Copy your files into this directory. There will be a Kconfig file in the drivers/char/ directory, open it and add an entry like this in the before the endmenu.
config MYDRIVER
bool "This is a driver for something"
default n
help
This is a test driver.
Save the file and open Makefile in the same directory. Goto end of the file and add the following entry.
obj-$(CONFIG_MYDRIVER) += mydriver.o
That's it you have added the file to the kernel tree. Now, as usual, do make menuconfig and select MYDRIVER.
See this Kernel Compilation article for more info.
You need to build your device driver as a built-in. You can either edit your kernel .config file manually and change "=m" to "=y" for the CONFIG option that belongs to your module, or use make menuconfig to change <M> to <*> for your device driver.
before -> <M> Your Device Driver Name Here
after -> <*> Your Device Driver Name Here

Capturing code generated by Qemu in a file

In qemu, when we are giving instructions it gets converted to the machine code for the particular architecture. I would like to write this code to a file. For that I think in cpu-exec.c the generated code is obtained (it is returned for execution). How will i copy it to a file?
/qemu-0.14.0/cpu-exec.c
find cpu_gen_code() # translate-all.c:57,
-to->
# line104: log_disas(tb->tc_ptr, *gen_code_size_ptr);
try to hack it.

Resources