This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Run script on startup as late as possible

Hi,

I created a simple module that controls wheter a USB supplies power for a device when in host mode or not. When loaded, this module cuts off the power to any device connected until told otherwise.

It is also desired that when booted, the system comes with both my module loaded, and the USB supply cut off. To this end, so far I've tried:

  1.  Setting my module as a kernel built-in: had no effect, modules that are loaded later overrun my configuration;
  2.  Creating an init.d script: Created the script, and set it up to run on rc5. No luck as well, I run into multiple problems with USB devices (such as `usb 2-1: device descriptor read/64, error -110`);


I'm running Kernel 3.12 on a custom AM335x board, and I've tested that the module works as intended if I load it manually (via `modprobe`) into the system, after logging in.

Ideally, I want to keep these configurations to be done during boot, without any need of logins and such.

So, my question is: how can I postpone the module loading until the last possible minute, assuring that any other configuration is already finished? Also, is udev a good solution for this sort of thing? From what I read, I had the impression it wouldn't be the best fit...

Regards,

Guilherme