I have been getting some question and will try to write this up in order for other to get a successful build from svn. I will focus on compiling for broadcom based hardware using the linux.v24_2 branch.
I HOLD NO REPONSIBILITY FOR ANY ACTIONS IF ANYONE BRICKS THEIR ROUTER FOLLOWING THIS GUIDE. I HAD TO USE JTAG TO RECOVER MULTIPLE TIMES WHILE TRYING TO GET THE SOURCE TO COMPILE CORRECTLY. BY ATTEMPTING ANYTHING IN THIS GUIDE, YOU ARE DOING SO AT YOUR OWN RISK
Last edited by rkozola on Sat Mar 01, 2008 17:45; edited 2 times in total
Posted: Sat Mar 01, 2008 16:32 Post subject: Setup up a build environment using MS VitualPC 2007
In order to set up a build environment, I went with VirtualPC 2007 from MS. This is a free download from MS and is easy to use, it will require a pc with windows. I chose this as it has a lot of useful features for development such as differencing disks and well as undo disks. I chose to use the TinyCD method to install the latest stable version of Debian.
First create a new virtual machine in VPC. I created a 10GB virtual hard disk and set the vm to use 512MB for ram.
Next I used the Tiny CD of current stable version of Debian (http://www.debian.com/distrib/netinst) to install a basic console based linux install for use in compiling DD-WRT from svn. Set the vm to boot from the iso image for the debian install and follow the directions below to get a working linux system.
-Choose language and click continue
-Choose language and click continue
-Select a keyboard layout and click continue
-set Hostname: to dd-wrt and click continue
-Leave Domain name: blank and click continue
-Choose a mirror county location and click continue
-Choose a mirror sight and click continue
-Enter HTTP proxy info if needed and click continue
-Choose Guided - use entire disk and click continue
-Select partition and click continue
-Select Separate /home partition and click continue (makes it easy to backup/restore src if needed)
-Select Finish partitioning and write changes to disk and click continue
-Select Yes to write changes and click continue
-Configure time zone and click continue
-Enter a root password and verfiy and click continue
-Enter dd-wrt and Full name for new user and click continue
-Enter dd-wrt for your account and click continue
-Enter a password and verify and click continue
-Select No to the Configuring popularity-contest and click continue
-For Software selection uncheck all boxes except for Standard System, Standard System should be the only one checked and click continue
-Select Yes and click continue to install the GRUB boot loader to mbr
-Install is finished, click continue to reboot
Last edited by rkozola on Sat Mar 01, 2008 17:58; edited 3 times in total
Posted: Sat Mar 01, 2008 16:33 Post subject: Installing required tools to compile and retreiving svn src
I use the following script to install the required programs needed to compile as well as grab the source from svn. Again this is focusing on the src/linux/brmc/linux/v24_2 kernel.
After the system has rebooted, login using the dd-wrt user and the password set during setup. Save the following as get_src_svn.sh and chmod to add permissions to execute. This script will install all requirements and get source from svn.
svn co -N svn://svn.dd-wrt.com/DD-WRT .
svn co svn://svn.dd-wrt.com/DD-WRT/tools
svn co svn://svn.dd-wrt.com/DD-WRT/opt
svn co -N svn://svn.dd-wrt.com/DD-WRT/src
svn co svn://svn.dd-wrt.com/DD-WRT/src/include.bcm
svn co svn://svn.dd-wrt.com/DD-WRT/src/include.v23
svn co svn://svn.dd-wrt.com/DD-WRT/src/include.v24
svn co svn://svn.dd-wrt.com/DD-WRT/src/led
svn co svn://svn.dd-wrt.com/DD-WRT/src/ses
svn co svn://svn.dd-wrt.com/DD-WRT/src/shared
svn co svn://svn.dd-wrt.com/DD-WRT/src/router
svn co svn://svn.dd-wrt.com/DD-WRT/src/squashfs-tools
svn co svn://svn.dd-wrt.com/DD-WRT/src/switch
svn co svn://svn.dd-wrt.com/DD-WRT/src/tools
svn co svn://svn.dd-wrt.com/DD-WRT/src/wl
svn co svn://svn.dd-wrt.com/DD-WRT/src/linux/brcm/linux.v24_2
ln -s /home/dd-wrt/DD-WRT/src/linux/brcm/linux.v24_2 /home/dd-wrt/DD-WRT/src/linux/linux
Last edited by rkozola on Tue Jan 06, 2009 1:35; edited 11 times in total
Now is a good time to shutdown the virtual machine and save change to the virtual hard disk from the undo disk. This step will save everything we have done to this point to the virtual hard disk. By using undo disks, we can save a clean environment and source, if we make any mistakes and mess things up in the future we can just discard the changes and go back to a point where we have this clean system. I normally only save changes to the virtual hard disk when updating source from svn or after I have modified any of the source files. I never save changes after attempting a build or successfully completing a build, I like a clean source tree. I will even go as far as setting up a differencing disk after installing the required program and my initial src grab from svn. This way in case I accidently save changes to the virtual hard disk at some point, I can just create a new differencing disk instead of having to start from scratch.
Last edited by rkozola on Sat Mar 01, 2008 17:03; edited 2 times in total
Posted: Sat Mar 01, 2008 16:34 Post subject: Required modifications for dependencies before building
(ALL ISSUES NOW FIXED, SECTION CAN BE IGNORED)There are a few files that need to be modified in order for the 'make configure' step to procede without errors.
3 files under DD-WRT/src/router/rules will need to be modified so that their dependencies are made prior to the make configure step for these application.
(FIXED)edit DD-WRT/src/router/rules/dropbear.mk and insert the following between lines 1 and 2:
cd zlib && make
(FIXED)edit DD-WRT/src/router/rules/openvpn.mk and insert the following between lines 1 and 2:
cd openssl && make
(FIXED)edit DD-WRT/src/router/rules/tcpdump.mk and insert the following between lines 1 and 2:
cd libpcap && make
(FIXED)Also noticed that the Makefile for libpcap_noring has a hardcoded reference to the linux.v23 branch. It might be a good idea to change line 53 of DD-WRT/src/router/libpcap_noring/Makefile to the following
Posted: Sat Mar 01, 2008 17:16 Post subject: Additions to DD-WRT/opt and install_*.sh scripts
This is where things start to get a little dirty. The DD-WRT/opt directory appears to be a little outdated and scripts will have to be created to build of the linux.v24_2 branch.
The first thing is to create a new script named make_kernel.v24_2.sh and use chmod to mark as executable. This script should look like the following.
./loader-0.02/lzma e ../src/linux/brcm/linux.v24_2/arch/mips/bcm947xx/compressed/piggy vmlinuz
./loader-0.02/lzma e ../src/linux/brcm/linux.v24_2/arch/mips/bcm947xx/compressed/piggy vmlinuzmicro
Next is to create the install_*.sh scripts to create the firmware versions you are trying to build. For the most part you can use the existing install_*.sh scripts as a base to create new scripts for using the linux.v24_2 branch. This will require you to change the .config_* and the references to the linux branch you are compiling for. Below is an example of the install_mini.v24_2.sh that I use.
cp .config_mini.v24 .config
rm -rf mipsel-uclibc/install
Posted: Sat Mar 01, 2008 17:16 Post subject: Building from source
After creating all the install scripts that you will be using, it is probably a good time to shutdown the vm and save the undo disk changes to the virtual hard disk. The next step will be attempting to build.
Issuing the following commands under /home/dd-wrt should successfully build a dd-wrt.v24_generic_mini.bin under the DD-WRT/image directory.
cd DD-WRT/src/router;cp .config_mini.v24 .config;cp ../linux/linux/.config_std ../linux/linux/.config;export MYPATH=$PATH;export PATH=/opt/4.1.0/bin:$MYPATH;make configure;cd ../../opt;./install_mini.v24_2.sh;
Last edited by rkozola on Sat Mar 01, 2008 22:11; edited 4 times in total
Posted: Sat Mar 01, 2008 17:17 Post subject: Native USB Support
USB support has been added by the devs, the below is no longer be needed.
It is possible to make a few modifications to some files and have usb support included in the build. This will use the native 2.4.35 modules compiled during the kernel. I have noticed that the read/write speeds are at least double that using this method over using the ipks and firmware modification toolkit. This will also use the sysinit-broadcom.c to load the base usb support. This will also activate the USB light on wrt350n (maybe other models). Loading modules for specific filesystems or device can be handled in a startup script either compiled into the firmware or add to jffs. NVRAM variables will be used to control what is loaded. On average, this all will add around 500kb to a firmware's size.
The following needs to be added/changed in DD-WRT/src/router/services/sysinit-broadcom.c to allow for the sysinit to load the usb core modules at boot. Search for the line '#ifdef HAVE_USB' in this file and change that section to look like the following.
//load usb driver. we will add samba server, ftp server and ctorrent support in future
"usbcore usb-ohci usb-uhci ehci-hcd scsi_mod usb-storage ide-core ide-detect ide-disk ide-scsi cdrom ide-cd printer sd_mod sr_mod";
foreach (module, modules, next)
cprintf ("loading %s\n", module);
eval ("insmod", module);
if(nvram_match ("usb_core", "1"))
cprintf ("loading usbcore\n");
eval ("insmod", "usbcore");
The following needs to be added/changed in DD-WRT/src/router/Makefile to include the modules into the /lib/modules/2.4.35 during building. Search for the line 'ifeq ($(CONFIG_USB),y)' in this file and change that section to look like the following.
Below is an example of usb.startup that I use for my wrt350n and an external drive with optware and some additional programs. The usb.startup file is saved in DD-WRT/src/router and is copied over with changes from the Makefile above.
if [ -z "$(nvram get usb_core)" ]; then
nvram set usb_core=0
nvram set usb_ohci=0
nvram set usb_uhci=0
nvram set usb_ehci=0
nvram set usb_printer=0
nvram set usb_storage=0
nvram set usb_fs_fat=0
nvram set usb_fs_ext2=0
nvram set usb_fs_ext3=0
if [ "$(nvram get usb_core)" = "1" ]; then
if [ "$(nvram get usb_fs_fat)" = "1" ]; then
if [ "$(nvram get usb_fs_ext2)" = "1" ]; then
if [ "$(nvram get usb_fs_ext3)" = "1" ]; then
until [ `dmesg | tail | grep -c 'USB Mass Storage device found at ' ` -ne 0 ] ; do
gpio disable 4
gpio enable 4
echo `dmesg | tail | grep -c 'USB Mass Storage device found at ' `
mount /dev/scsi/host0/bus0/target0/lun0/part1 /mnt/usb
mount /dev/scsi/host0/bus0/target0/lun0/part2 /mnt/swap
mount /dev/scsi/host0/bus0/target0/lun0/part3 /mnt/opt
mount -o bind /mnt/opt /jffs/opt
mount -o bind /jffs/opt /opt
echo "export PATH=$PATH:/opt/bin:/opt/sbin" > /tmp/root/.profile
[ -e /opt/etc/profile ]
grep -q nobody /etc/passwd || echo "nobody:*:65534:65534:nobody:/var:/bin/false" >> /etc/passwd
I had to modify DD-WRT DD-WRT/src/router/misc/rootprep.sh in order to create usb,swap, and opt under /mnt. The following lines were added under the '# miscellaneous' after the 'mkdir -p mnt' line
Joined: 19 Jan 2008 Posts: 46 Location: Florida, US
Posted: Wed Mar 05, 2008 5:15 Post subject: Error !!
Thanks for your explanations.
I have did everything you mentioned here and I stuck here
cp .config_mini.v24 .config
rm -rf mipsel-uclibc/install
I got an error in the last line of the code that I copied above. There was no folders created. All folders under the src/router/mipsel-uclibc ( I have created target and bin directories) are created by me. Should the folder be created automatically? I am getting error when I type