Is there any way to pass parameters to the kernel module when OpenWrt starts?

For example: I want to pass "quirks=0xab12:0xcd34:u" to the usb-storage module when system starts,
do I have to modify the source code and rebuild the firmware?
How to use the files in /etc/modules.d?

I don't know if you can do that at boot time without modifying the device tree file for your hardware but would be very interested to know if it is possible.

You can specify boot arguments in device tree by using "chosen"

 #include "pxa910.dtsi"
/ {
    compatible = "mrvl,pxa910-dkb", "mrvl,pxa910";

    chosen {
	    bootargs = "<boot args here>";

    memory {
        reg = <0x00000000 0x10000000>;

@biangbiangmian, nice name.
According to the documentation, I have read some source code, and the basic routine should look like this:
kmodloader.c->insert_module()->read files in /etc/modules.d (One module per line, the format is like this: "moudulename parameter1=value parameter2=value").
but "usb-storage quirks=0xab12:0xcd34:u" does not work for me, don't know why :thinking:.
here is the usb-storage module .

Thank you :grin: Just a guess, but have you tried entering the quirks in decimal rather than hexadecimal? see

1 Like

UP for the first question.

Is there any documentation regarding passing parameters to the kernel module on boot?

My problem is: I want to plug my Seagate External drive to OpenWRT router. After some googling I found that UAS feature is broken. If I manually add US_FL_IGNORE_UAS to exlude list in eg:
UNUSUAL_DEV(0x0bc2, 0x3312, 0x0000, 0x9999,
<------><------>"Expansion Desk",
<------><------>US_FL_NO_ATA_1X | US_FL_IGNORE_UAS),

The system starts properly, the Seagate drive is loaded as usb-storage successfully.
But I want to avoid rebuilding and flashing since I'm using another custom build (I don't have access to that repo)

When I write "usb-storage quirks=0bc2:3312:u" into /etc/module.d/usb-storage file and reboot the problem with UAS remains the same.
After debugging I found that quirks are parsed by usb-storage-uas module.
When I write "uas quirks=0bc2:3312:u" into /etc/module.d/usb-storage-uas file and reboot ... the problem wasn't solved.
After that I found that /etc/module-boot.d/usb-storage-uas is linked to /rom/etc/module.d/usb-storage-uas (it consist of only thee chars - "uas", and has read only access) during the boot , and after some time it links to /etc/module.d/usb-storage-uas .

Is there any way to pass parameters to the kernel module when OpenWrt starts?

I'm also facing the same problem.

I've tried all the options suggested, but it feels like the options aren't loaded into the kernel at load time.

If I try changing /sys/module/usb_storage/parameters/quirks manually, then it works well but I need to replug the USB device and the config gets lost in every reboot.

Any news on this? I also can't load parameters at boot by editing /etc/modules.d/usb-storage (tried usb-storage quirks=0bc2:231a:u), it simply get ignored...

The /etc/modules.d documentation linked above tells you why this likely isn't working:

At this point in the boot sequence, '/etc/modules-boot.d' is the one from the rom image (/rom/etc/… when boot is done). The overlay filesystem is mounted later.

So, if you're editing the live overlay filesystem, it won't take effect. If you modify the file in your image build, then it may take effect.


Makes sense.

To guys who facing the same problem:
I don't remember how I solved it at the time, I only remember that I compiled the firmware many times and it took me several hours, even though I had experience in compiling OpenWrt firmware earlier.
I also remember that my USB device is a counterfeit product, and its id does not match the usb id. So you should check (with lsusb command) the device id first.

I recommend editing the firmware directly to get rid of compiling.

At least on my device, /etc/modules-boot.d contains only symlinks to /etc/modules.d. An interesting point is that I'm using the Image Builder to get a customized firmware that already has kmod-usb-storage and related packages installed. I'll give a try with an unmodified snapshot to see if anything changes...

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.