Compiling DD-WRT

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Broadcom SoC based Hardware
Goto page 1, 2, 3 ... 11, 12, 13  Next
Author Message
<Kong>
DD-WRT Guru


Joined: 15 Dec 2010
Posts: 3769
Location: Germany

PostPosted: Mon Oct 13, 2014 9:07    Post subject: Compiling DD-WRT Reply with quote
Obviously compiling dd-wrt is very difficult, thus needs a tutorial:-)

This should work with latest revision currently around 25100, this is basically working the same way for all targets whether it is mipsel or arm.

1. Get the toolchains:

ftp://ftp.dd-wrt.com/toolchains/

and extract them e.g. to ~/Toolchains

2. Checkout Code:

Code:
mkdir ~/DEV
cd DEV
svn co svn://svn.dd-wrt.com/DD-WRT .


3. Create a little script

Code:
#!/bin/bash

#path to bin of extracted toolchain for this target
export GCCMIPS=~/Toolchains/toolchain-mipsel_r2_gcc-4.7-linaro_uClibc-0.9.33.2/bin
export PATH=$GCCMIPS:$PATH

#compile jsformat
cd ~/DEV/src/router/tools
rm jsformat
make jsformat

#.config_ac contains lots of features, strip it down remove features as compiling everything takes a lot of time and requires lots of host tools from your distro, you want to avoid these problems in the beginning

cp -f ~/DEV/src/router/configs/broadcom_K3x/.config_ac  ~/DEV/src/router/.config

#compile trx
cd ~/DEV/opt/tools/
gcc -o trx trx.c

# compile them once to make sure these binaries work on your distro, then comment them as I did
#cd ~/DEV/tools/
#rm ./strip
#gcc strip.c -o ./strip
#rm ./write3
#gcc write3.c -o ./write3
#rm ./write4
#gcc write4.c -o ./write4


cd ~/DEV/src/router
make -f Makefile.brcm3x configure
make -f Makefile.brcm3x clean all install

#copy firmware file and rename it

cp ~/DEV/src/router/mipsel-uclibc/dd-wrt.v24-K3_R6300.trx ~/DEV/image/dd-wrt.v24-K3_AC.bin
....


4. For this target bcm4706 modify a few files, e.g. in kernel dir: drivers/net/wireless/Kconfig

you need comment a few lines as these drivers are not part of the kernel by default:
Code:

#if RALINK_DEVICE
#source "drivers/net/wireless/rt3352/rt2860v2_ap/Kconfig"
#source "drivers/net/wireless/rt3352/rt2860v2_sta/Kconfig"
#endif
#if SOC_MT7620_OPENWRT
#source "drivers/net/wireless/rt7620/rt2860v2_ap/Kconfig"
#source "drivers/net/wireless/rt7620/rt2860v2_sta/Kconfig"
#source "drivers/net/wireless/rt5592/Kconfig"
#endif


In Makefile.brcm3x add two lines to copy igs emf kernel modules
Code:

mv $(TARGETDIR)/usr/lib/services.so $(TARGETDIR)/lib
cp emf_bin/mipsel/igs.ko $(TARGETDIR)/lib/modules/$(LINUXVER)/kernel/drivers/net/wl/
cp emf_bin/mipsel/emf.ko $(TARGETDIR)/lib/modules/$(LINUXVER)/kernel/drivers/net/wl/


and comment out line:

#include rules/emf.mk

in ~/DEV/src/router/rules/all.mk

You have to do this because BrainSlayer has a different directory structure on his server. On previous revisions you don't have to do it as igs/emf was not used.

If using igs/emf you need to comment stripping in Makefile in order to avoid unresolved symbols in wireless driver.

also in Makefile.brcm3x comment:

Code:
#   ../../opt/asus/asustrx-rt66u -p RT-AC66U -v 3.0.0.1 -m 32000000 -o $(ARCH)-uclibc/dd-wrt.v24-K3_RT-AC66U.trx $(ARCH)-uclibc/lzma_vmlinuz -a 1024 $(ARCH)-uclibc/rootfs.squashfs

since I don't need the trx tool for asus as I don't build it I just commented it, you can just compile it if you need it.

#   cd $(ARCH)-uclibc && ../tools/bufenc/makefw.sh dd-wrt.v24-K3-nandboot


same here this is not in svn and only needed to create special buffalo builds

If I did not forget anything you should be able to call the script in order to start compiling.

Note:

As I just copied and pasted the lines from my script it is possible I have done a typo etc. Thus it is possible, that you get an error.

If you hit compile problems, check these things:

-look at the output closely, maybe your are missing, developer packages on your linux install
-if a package doesn't compile it may not be configured properly, thus go into ~/DEV/src/router and configure the package the failing app or dependencies by hand "make -f Makefile.brcm3x <app>-configure"


Beware, there is no guarantee, that a compiled image actually runs without a hitch. I have seen problems such as buggy host tools like ccache mess up the compilation and cause kernel crashes etc..


Last words, if you think it was difficult to findout this out then look at my personal difficulty rating from 1-10:

1. Setting up basic environment for compiling
2. adding new packages
3. adding new settings
4. modify webif
5. finding a simple bug
6. porting a device that is similar to already supported device
7. finding a complex bug
8. add a few patches to the kernel
9. fix kernel bugs
10. add support for a completely new architecture, that is not supported by the kernel

Now if you feel like you want to do this, try it out document any problems ask if you have trouble. Hopefully someone write up a complete guide and add it in the wiki. Again don't hammer us with noobish questions, don't try this if you have no development experience.


Last edited by <Kong> on Sat Nov 29, 2014 22:25; edited 1 time in total
Sponsor
earthmind
DD-WRT User


Joined: 25 May 2008
Posts: 96

PostPosted: Mon Oct 13, 2014 9:11    Post subject: Reply with quote
Kong, in my book you have stepped up to the plate and gone beyond what's normally expected. Thank you once again.
<Kong>
DD-WRT Guru


Joined: 15 Dec 2010
Posts: 3769
Location: Germany

PostPosted: Mon Oct 13, 2014 9:28    Post subject: Reply with quote
And by the way there have been several people that managed to do this all on their own, even port devices with practically no help from us, good example is:

http://sourceforge.net/projects/ddwrtdir860l/files/Firmwares/20140124/

Fractal, Tathagata are other well know examples.

These are the kind of guys we need.
mr.shimpy
DD-WRT User


Joined: 01 Aug 2014
Posts: 70

PostPosted: Mon Oct 13, 2014 10:28    Post subject: Reply with quote
<Kong> wrote:
And by the way there have been several people that managed to do this all on their own, even port devices with practically no help from us, good example is:

http://sourceforge.net/projects/ddwrtdir860l/files/Firmwares/20140124/

Fractal, Tathagata are other well know examples.

These are the kind of guys we need.


Hmmm, what you really need are team players.
MastaG
DD-WRT Novice


Joined: 04 Mar 2014
Posts: 21

PostPosted: Mon Oct 13, 2014 12:30    Post subject: Reply with quote
EDIT: I already figured it out Razz

So how much space do we have for extra things to include in the rootfs? (like kmods, binaries and other funstuff)
Gameman Advanced Kid
DD-WRT Guru


Joined: 18 Nov 2012
Posts: 822

PostPosted: Mon Oct 13, 2014 13:23    Post subject: Reply with quote
can this be done in windows too? or is this something only for linux?
_________________
Is everything okay?

WDS AP - R7800
WDS STATION - R7500V2
_Robb_
DD-WRT User


Joined: 14 Jan 2012
Posts: 324
Location: Wr PL

PostPosted: Mon Oct 13, 2014 13:50    Post subject: Reply with quote
I rather think nobody here would recommend it.

But if You want to try it under Windows - try it with "cygwin".
I think You may be the first.

But better to make a virtual machine with some linux distro.

_________________
http://www.speedtest.net/result/3915993898.png

DO NOT 30-30-30 or erase nvram newer routers! It can brick them.

EA6700: Build 27745 (nvram below 32K, ipv6 - HE 6in4)
E4200: Build 26587
WRT54GL: Retired - waiting in the closet for an emergency.
mr.shimpy
DD-WRT User


Joined: 01 Aug 2014
Posts: 70

PostPosted: Mon Oct 13, 2014 13:52    Post subject: Reply with quote
Gameman Advanced Kid wrote:
can this be done in windows too? or is this something only for linux?


No, you need a linux system, but you could run linux in a virtual machine in your windows. You could install virtualbox as the hypervisor and install ubuntu in a virtual machine.
Anti-Ultimate
DD-WRT User


Joined: 11 Oct 2014
Posts: 51

PostPosted: Mon Oct 13, 2014 14:25    Post subject: Reply with quote
Why is DD-WRT still using SVN ( ̄◇ ̄Wink
MastaG
DD-WRT Novice


Joined: 04 Mar 2014
Posts: 21

PostPosted: Mon Oct 13, 2014 14:29    Post subject: Reply with quote
Alright so far so good,

There are a few workarounds for me when building on Fedora 20 x86_64

EDIT (for the last time Razz )

I've posted my build script on page 3 of this thread Smile


Last edited by MastaG on Wed Oct 15, 2014 13:16; edited 22 times in total
_Robb_
DD-WRT User


Joined: 14 Jan 2012
Posts: 324
Location: Wr PL

PostPosted: Mon Oct 13, 2014 14:43    Post subject: Reply with quote
Anti-Ultimate wrote:
Why is DD-WRT still using SVN ( ̄◇ ̄Wink

Because it's one of those long term project decisions, which is changed only when it's crucial to change it.

_________________
http://www.speedtest.net/result/3915993898.png

DO NOT 30-30-30 or erase nvram newer routers! It can brick them.

EA6700: Build 27745 (nvram below 32K, ipv6 - HE 6in4)
E4200: Build 26587
WRT54GL: Retired - waiting in the closet for an emergency.
<Kong>
DD-WRT Guru


Joined: 15 Dec 2010
Posts: 3769
Location: Germany

PostPosted: Mon Oct 13, 2014 15:09    Post subject: Reply with quote
MastaG wrote:
Alright so far so good,

There are a few workarounds for me when building on Fedora 20 x86_64

Fedora has newer host tools, thus you probably run into a few more problems, whenever I find these I commit them, but suse is a bit behind regarding make/gcc etc.

Quote:

1. I needed to create a few revision.h headers (found the fix in the forums):
Code:
cd ~/DEV/src/router/libutils
echo -n '#define SVN_REVISION "' > revision.h
svnversion -n . >> revision.h
echo '"' >> revision.h

cd ~/DEV/src/router/httpd/visuals
echo -n '#define SVN_REVISION "' > revision.h
svnversion -n . >> revision.h
echo '"' >> revision.h

cd ~/DEV/src/router/httpd
echo -n '#define SVN_REVISION "' > revision.h
svnversion -n . >> revision.h
echo '"' >> revision.h



Good catch almost forgot about it. BS generates this through his scripts, I once committed the fix for this and BrainSlayer removed it as he wants it his way, but this is the proper way to do it:

http://svn.dd-wrt.com/changeset?sfp_email=&sfph_mail=&reponame=&new=22967%40src%2Frouter%2Fshared%2FMakefile&old=21876%40src%2Frouter%2Fshared%2FMakefile&sfp_email=&sfph_mail=

it creates revision.h in router/shared, this include is pulled in by all apps:-)

Quote:

2. Point the kernel to 3.10 instead of 3.11 by doing: make -f Makefile.brcm3x menuconfig (under Environment):
Code:
$(SRCBASE)/linux/universal/linux-3.10


3. Comment out the pcap-pbf.h in ~DEV/src/router/rflow/process.c as it causes things to be redefined:
Code:
/*#include "pcap-bpf.h"*/


4. Remove the condition in ~/DEV/src/router/busybox/modutils/insmod.c it should read:
Code:
int init_module(const char *name, const struct new_module *);
int query_module(const char *name, int which,
                 void *buf, size_t bufsize, size_t * ret)
{
    return -1;
}




For those too check, if you ran configure, I don't need to do this here.
MastaG
DD-WRT Novice


Joined: 04 Mar 2014
Posts: 21

PostPosted: Tue Oct 14, 2014 8:15    Post subject: Reply with quote
Ah, thanks for showing me the commits for REVISION_REWRITE Smile

EDIT: Fixed, my mistake Razz


Last edited by MastaG on Tue Oct 14, 2014 12:16; edited 1 time in total
fkpwolf
DD-WRT Novice


Joined: 02 Jul 2014
Posts: 6

PostPosted: Tue Oct 14, 2014 8:34    Post subject: Reply with quote
good guide. But obviously, it is the simplest part of the whole path to a completely usable firmware.
LOM
DD-WRT Guru


Joined: 28 Dec 2008
Posts: 7614

PostPosted: Tue Oct 14, 2014 9:50    Post subject: Reply with quote
MastaG wrote:
Ah found it Smile
src/router/configs/broadcom_K3x/.config_ac doesn't define: CONFIG_BCMMODERN=y



???

It does as far as I can see.

_________________
Kernel panic: Aiee, killing interrupt handler!
Goto page 1, 2, 3 ... 11, 12, 13  Next Display posts from previous:    Page 1 of 13
Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum