General TC > General TC Talk
loading driver with modeprobe or insmod with parameters
gharig:
Hello,
So I'm trying to figure out why parameters being passed while loading a kernel module using modprobe or insmod are not working as to the way I believe they should work.
--- Code: --- sudo modprobe someDriver Param1=123 Param2=456
--- End code ---
OR
--- Code: --- sudo insmod ./someDriver.ko Param1=123 Param2=456
--- End code ---
The driver assigns default value for Param1 = 0 and Param2 = 1
The driver prints out the values Param1 = 0 and Param2 = 1 in dmesg
What I expect is that Param1 = 123 and Param2 = 456
Is the busybox version of modprobe the issue?
Maybe there is some small detail that I'm overlooking.
Thanks
gharig
I mentioned this earlier in another post too.
http://forum.tinycorelinux.net/index.php/topic,24005.msg151255.html#msg151255
Rich:
Hi gharig
Based on your other post, it sounds like like you are not reading the values being passed to your module.
gharig:
Hi Rich,
My understanding is that the macro module_param( variable_name, type, permission ) handles this when the kernel module is loaded.
this is for a very simple kernel module
--- Code: ---
//.......
static int Param1= 0;
static int Param2 = 1;
module_param( Param1, int, 0 );
module_param( Param2, int, 0 );
//.........
static int __init test_init(void)
{
printk(KERN_INFO "Param1 = %d \n", Param1);
printk(KERN_INFO "Param2 = %d \n", Param2);
printk(KERN_INFO "Kernel Module Loaded Successfully...\n");
return 0;
}
static void __exit test_exit(void)
{
printk(KERN_INFO "Kernel Module Removed Successfully...\n");
}
module_init(test_init);
module_exit(test_exit);
--- End code ---
So after I make and install the module I can call modprobe with the values I pass in with the parameters.
--- Code: ---sudo modprobe someDriver Param1=123 Param2=456
--- End code ---
So that when I look at dmesg I should see the following
--- Code: ---Param1=123
Param2=456
Kernel Module Loaded Successfully...
--- End code ---
So when you say that I'm not reading the values I'm a bit confused.
Any light you could shed on me would be greatly appreciated.
Thanks
gharig
Rich:
Hi gharig
--- Quote from: gharig on April 28, 2022, 06:27:21 PM ---My understanding is that the macro module_param( variable_name, type, permission ) handles this ...
--- End quote ---
Here you set the variable name and type.
--- Quote ---
--- Code: ---module_param( Param1, int, 0 );
module_param( Param2, int, 0 );
--- End code ---
--- End quote ---
For permission you used 0. I think that's your problem. Try it like this:
--- Code: ---module_param( Param1, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
module_param( Param2, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
--- End code ---
gharig:
Hi Rich,
Sorry to be a pest, but I tried your suggestion for setting the permissions in module_param().
The results are the same. So I have attached the test.c and the makefile. Maybe when you get a chance you can see what is wrong.
If you are to see the parameters change on your system then maybe it might be something with my card.
I'm running Tinycore 13 32bit on a Winsystems C412 that has the following:
1 GHz DMP Vortex86DX3 Processor (Dual core) CPU2 GB DDR3-LV System RAMLow Power10 Year AvailabilityRugged Design for Demanding Environments-40°C to +85°C Operating Temperature RangePC/104-Plus Small Form Factor Shock and Vibration Tested Connectivity and I/O for Embedded SystemsDual Ethernet (1x Fast Ethernet, 1x Gigabit) 4x USB 2.024x GPIO 5V with Event Sense 4x Serial Ports (2x RS-232, 2x RS-232/422/485) Parallel Port LPTAudio Graphics Support Dual video output (VGA, LVDS with digital backlight dimmer)
I haven't tried this on my Hyper-V, but I will tonight when I get home, and let you know the results from that system.
As always thanks for your help.
gharig
Navigation
[0] Message Index
[#] Next page
Go to full version