OpenWrt Forum Archive

Topic: How to enable USB storage support in kernel?

The content of this topic has been archived on 21 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello!

I want to exclude kernel modules (kmod-*) from the firmware, and to include support of usb of a flash card directly in a kernel.
How to do it? What items to select in a kernel configurator?

Use make kernel_menuconfig instead of make menuconfig to directly configure your Linux kernel. This will directly modify the target/linux/<platform>/config-<version> file. Any changes to this file may give you some problems in any future updates. So, I strongly suggest you learn how to use quilt and use it to modify the file.

Whenever I use quilt to modify a file, I stick to the following rules in naming the new patched file based on the original file full name (name with directory path):

  1. Replace the / with a -.

  2. Replace the . with a _.

For instance, for the scripts/download.pl file, I will use scripts-downloads_pl.patch as the patched file name. Obivously, I will use target-linux-<platform>-config-<version>.patch as the patched file name for the target/linux/<platform>/config-<version> file. You can use any patched file name as you wish. One more thing about quilt before I proceed, always do it at the OpenWRT root directory and NOT any sub-directories since quilt will create a patches and a .pc sub-directories in the same directory it gets invoked to store all of its house keeping files for maintenance purposes. Otherwise, this may give you some headaches to maintain all patched files in the long run.

This is how I would do to maintain my local files using quilt:

  1. Run quilt refresh to update any last patches maintained by quilt.

  2. Run quilt new target-linux-<platform>-config-<version>.patch to create a patches/target-linux-<platform>-config-<version>.patch file.

  3. Run quilt edit target/linux/<platform>/config-<version> to edit the file needed to modify and maintained by quilt. quilt will launch its default text editor, i.e. vi.

  4. Once in the edit mode, go to the beginning of the file or any place you will remember and insert any character to temporarily modify the file. Then, save and exit the file.

  5. Run quilt refresh to refresh the patches/target-linux-<platform>-config-<version>.patch file.

  6. Go back to step #3 above to remove the character you just inserted in the file, save, and exit the file. This step is necessary to restore your target/linux/<platform>/config-<version> file to its original state in order for the following step to succeed.

  7. Now, go ahead to run make kernel_menuconfig to add / remove any modules as you wish.

  8. After you are done with the make kernel_menuconfig, you will see your target/linux/<platform>/config-<version> file gets updated. Now, run quilt refresh to update your patches/target-linux-<platform>-config-<version>.patch file.

The above steps take care of maintaining your target/linux/<platform>/config-<version> file with quilt. Now, whenever you want to perform the usual task to to update your OpenWRT root repository, i.e. svn up (for SVN trunk) or git pull (for GIT trunk), etc., you can use the following steps to perform the update:

  1. Restore your modified target/linux/<platform>/config-<version> file to its original state by doing a quilt pop.

  2. Then, go ahead to perform the updates as usual.

  3. Once you have the updates, then run a quilt push to update your target/linux/<platform>/config-<version> file with your mods.

If the OpenWRT update has made any changes to the target/linux/<platform>/config-<version> file, there is a chance the above last step (quilt push) will fail. In this case, you will need to manually modify your patches/target-linux-<platform>-config-<version>.patch file. This will become a nightmare, AFAICT. To remedy this issue, I will do the following and use the target/linux/<platform>/config-<version> and its respective patche file patches/target-linux-<platform>-config-<version>.patch to illustrate:

  1. Save and/or backup a copy of your patches/target-linux-<platform>-config-<version>.patch file. Usually, I just copy my patches/target-linux-<platform>-config-<version>.patch to my /tmp/patches sub-directory.

  2. Then, do a diff -uNr target/linux/<platform>/config-<version> /tmp/patches/target-linux-<platform>-config-<version>.patch > patches/target-linux-<platform>-config-<version>.patch to update my patches/target-linux-<platform>-config-<version>.patch file.

  3. Use any text editor, i.e. vi, etc., to edit the newly updated patches/target-linux-<platform>-config-<version>.patch file to remove any occurrence of /tmp from the /tmp/patches/target-linux-<platform>-config-<version>.patch strings. Then, save and exit the file.

  4. Now, run quilt push to update the target/linux/<platform>/config-<version> file.

  5. If no error, then run quilt refresh to update the patches/target-linux-<platform>-config-<version>.patch file.

  6. If error does occur, then your best approach is to completely delete the patched file, i.e. quilt del target-linux-<platform>-config-<version>.patch, and do it all over again or waste more time to investigate / fix the patched file if you know how.

There is all there to it, Good luck.

The discussion might have continued from here.