DD-WRT provides a lot of builds for different flash chip sizes. Sometimes though, you might need a module or two that isn’t included in the compiled firmware. Fortunately because of the way DD-WRT is developed (open source) you are able to grab the DD-WRT kernel sources from SVN and do a bit of DIY kernel module compiling. Though its not as simple as it sounds, but hopefully this general guide you get you on your way in compiling kernel modules. For this specific guide I am demonstrating how to compile IPv6 modules.

My setup:

Ubuntu 12.10 (Virtual Machine)

Compiling for ASUS RT N66U, 3.10.2 kernel and revision 22118

Acknowledgements:

This guide wouldn’t of been possible without the following websites that allowed me to learn how to do this myself:

Apart from the kernel source, its also important to get the matching SVN revision that your currently running. In my case the revision number is 22118. It will take a bit of time to download everything.

Getting the DD-WRT toolchain(s) for compiling

The toolchain tar.bz2 package is about 1.3 GB in size, so grab a drink, do something else for while as it might take a while depending on your internet connection. Once the download is complete it will also take some time to extract as well. Once that’s completed its time to setup the make file.

Adding toolchain to $PATH

Before compiling you’ll need to use the correct toolchain, in my case I used the following:

PATH=$PATH:/opt/toolchain-mipsel_gcc4.1.2/bin

Creating a .config file

Now you need to create a .config file in order to specify the modules you want to compile. The kernel source actually contains a lot of default config files for different builds. In my case there is a .config_bcmmips config in there that is perfect for my router. Switch into your kernel source directory:

cd ~/DD-WRT/linux-3.10

Change the kernel version to the one you actually downloaded from SVN.

The .config files are on the root of the kernel source, but take note, they are dot files. You simply need to copy the config that matches your router, in my case this config will be fine:

cp .config_bcmmips .config

Regarding what IPv6 modules to compile, its really up to you, but here is a good set below, it provides the IPv6 modules and various modules for ip6tables to work effectively:

Older guides on compiling don’t mention the ARCH parameter, but it is now required, otherwise the modules cannot be built. “mips” is likely the arch you want to compile for, but adjust this by all means if mips is not what you want.

You might receive the following error when you do this for the first time:

The error is referring to Ralink drivers that don’t appear to exist in SVN. I have no need for them, hence I did the most basic of fixes and simply edited the drivers/net/wireless/Kconfig file and commented out the following lines:

Now re-run the same make command, it should now build the request modules, plus others listed in the default bcmmips config. You may get asked a couple more prompts regarding IPv6 modules, just press enter to advance through the config and continue to the compiling. Compiling will take a bit of time, so be patient.

Finding the compiled IPv6 modules

So everything compiled successfully, now what? Well you need to grab the modules! An easy way to do this is to run a couple of simple find commands such as:

find . -name '6*.ko'
find . -name 'ip6*.ko'
find . -name 'nf*.ko'

You should now copy these out of the kernel source and onto your router on jffs and then insmod the modules one by one. Be careful of dependencies, the order of loading modules can be very important, a good order to use would be:

Share This:

Thanks for this useful write-up. I’ve been using it to compile some other modules for the same DD-WRT built, specifically to mod switch-robo.ko to enable higher vlan ids. It might be helpful for others to specify that you are using the 64-bit version of Ubuntu 12.10. I was scratching my head out when I started with 32-bit and was trying to debug the makefile errors before finally giving 64-bit a shot which worked perfectly.

I also want to confirm with you whether the modules that you compiled using this linux distro turn out to be unloadable, characterized by the “[permanent]” indicator beside the module when you perform a lsmod check as these modules are not rmmod capable. In all other regard, the complied module works great. It just bugs me that they are not rmmod-able and a reboot is in order every time I need to change them.

Thanks,
Kodi

WolfKodi

Okay, so I needed the ip6t_rt module for my n66u as well and went ahead to compile them in a different distribution of linux, namely Debian 7.2 Wheezy. The modules compiled are once again permanent and unloadable upon ismod. This means that it must be compile configuration issue. If someone has came across this and solved this problem, do share.