1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Compiling Linksys WRT160N v1 firmware

Discussion in 'Linksys Official Firmware' started by Alberto Castillo, Jul 24, 2017.

  1. Alberto Castillo

    Alberto Castillo Network Newbie Member

    Hello

    I have made a small modification (which I believe to be a bug in the latest Linksys firmware for this model where only 11 channels for the WiFi are being shown instead of 13 on an European model).

    However I am unable to compile it. It also seems that the readme instructions are too old. I also have not enough experience when compiling on Linux. So I wonder, if anyone with the enough time or has already setup an environment can compile it.

    The sources can be downloaded here: http://www.mediafire.com/file/47a3y9i1blwrm0u/wrt160n_v1.2.11_001.tar.gz

    The file to be replaced can be found here: http://www.mediafire.com/file/qfi75a3f69on255/Wireless_Manual.asp

    The content changed on that file was:
    Code:
        if(locale == "ETSI") {
            max_channel = 11;
        }
    To:
    Code:
        if(locale == "ETSI") {
            max_channel = 13;
        }
    This file is located on "wrt160n_v1.2.11_001\release\src\router\www\cisco_wrt54g_m"

    Could someone compile it? I think this would solve the issue. Althought I would preffer to compile it myself if I had the enough experience.

    Thanks
     
  2. Alberto Castillo

    Alberto Castillo Network Newbie Member

    I have setup a centOS 6 machine on 32 bit using a VPS I have, I have installed the packages mentioned in the readme, althought not those versions.

    I also had to install ncurses-devel as it prompted for ncurses

    When I run make.sh I end up getting things in the log that don't seem to appear on the original log that is included with the sources when building the original code.bin that is included with the source. Due to this iut starts asking me questions that are already on a config file

    here's an example:
    Code:
    #
    # Using defaults found in .config
    #
    scripts/Configure: line 556: .: .config: file not found
    scripts/Configure: line 558: .: .config-is-not.2278: file not found
    There also seems to be issues with paths as it seems it tries to read or copy files that do not exist.

    Any idea? Thanks

    This is the readme:
    Code:
    README:
    
    1. 1. To Build both Tool chain and Firmware image:
       1.1 Host Redhat-9 (Linux kernel 2.4.20) on x86 machine
       1.2 Compiling tool version: gcc 3.2.3, binutils 2.13.90.0.18-9, glibc 2.3.2-11.9, GNU Make version 3.79.1
    
    2.  Put wrt160n_v1.2.11_001.tgz
     to a directory such as /home/WRT160N, then extract the wrt160n_v1.2.11_001.tgz file.
    
       # cd /home/WRT160N
       # tar xzvf wrt160n_v1.2.11_001.tgz
    
    
    To Install Toolchain and Build Firmware image:
    
    METHOD 1:
    
          1) if you have root permission you can copy toolchain binary code to /opt/ directly
    
       # cd /home/WRT160N
       # cp wrt160n_v1.2.11_001/tools/brcm /opt/ -a
    
        2) Set the toolchain PATH. (Assume the toolchain is installed in /opt/brcm)
     
       # vim ~/.bash_profile
       Add "PATH=$PATH:/opt/brcm/hndtools-mipsel-linux/bin:/opt/brcm/hndtools-mipsel-uclibc/bin" to ~/.bash_profile
        if your PATH  in ~/.bash_profile includes some other or older toolchain path, please modify your .bash_profile to make sure that /opt/brcm/hndtools-mipsel-linux/bin:/opt/brcm/hndtools-mipsel-uclibc/bin locates in front of the older so that compiler finds correct toolchain.
       # source ~/.bash_profile
     
        3)  Go to wrt160n_v1.2.11_001 folder and execute make.sh.
     
       # cd /home/WRT160N
       # cd wrt160n_v1.2.11_001
       # ./make.sh
     will generate the code.bin under release/image/ folder.
    
    
    
    or METHOD 2: build mips toolchain from source code on REDHAT9.
    
       
        1. BUILDING GNU Toolchian(You must have root permission to install toolchain binaries to /opt/brcm directory):
    
       1.1 Building mipsel-linux-3.2.3
               o cd to release/src/router
               o make menuconfig
                 save defaults and return
               o Get to the ../tools-src directory and run ./build_tools.sh.
    
             This action will generate hndtools-mipsel-linux-3.2.3 under /opt/brcm. please note build_tools.sh will install toolchain to /opt/brcm by default,
       you can pass "-i xxx-directory" to change the installation directory if you
       have no root permission
    
       Usage: build_tools.sh [-d base_dir] [-k kernel_dir] [-i install_base]
        -d base_dir
                  The base directory where the source will be extracted to and
                  the release will be built.  If no -d option is provided,
                  the default base_dir is the current pwd.
     
        -k kernel_dir
                  The base directory where a copy of the kernel sources,
                  already configured; can be found. If no -k option is
                  provided, the default kernel_dir is
                  $base_dir/../release/src/linux/linux.
     
        -i install_base
                  The base directory where the resulting binaries will be
                  installed and run from.  If no -i option is provided, the
                  default install_base is /opt/brcm.
                 
        (Note: arguments specified must be absolute paths.)
    
           o Set up a symbolic link in the /opt/brcm directory
             ln -s hndtools-mipsel-linux-3.2.3 hndtools-mipsel-linux
           o Add the directory to your system path:
             export PATH=$PATH:/opt/brcm/hndtools-mipsel-linux/bin/
    
        1.2 Building mipsel-uClibc-0.9.19:
           o cd ../tools-src/uClibc
           o [make menuconfig]or [make config] to change configuration
             (or [make oldconfig] to rebuild existing configuration)
             o make
             o make install
    
                 This action will generate hndtools-mipsel-uclibc-0.9.19 under /opt/brcm.
    
           o Set up a symbolic link in the /opt/brcm directory:
             ln -s hndtools-mipsel-uclibc-0.9.19 hndtools-mipsel-uclibc
           o Add the directory to your system path:
                 export PATH=$PATH:/opt/brcm/hndtools-mipsel-uclibc/bin/
    
                 Now, the system PATH,for example, should be like:
                 /usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:
             /opt/brcm/hndtools-mipsel-linux/bin/:/opt/brcm/hndtools-mipsel-uclibc/bin/
    
                To see whether toolchain is set up appropriately, you can execute shell command:
                which mipsel-linux-gcc
                if echo "/opt/brcm/hndtools-mipsel-linux/bin/",it is ok, otherwise,set up again.
    
         2. Building Firmware Image:
         o cd release/src
         o make
         o will generate the code.bin under release/image/ folder.
    
     
  3. Sean B.

    Sean B. LI Guru Member

    While I haven't compiled any Linksys builds, I've ran countless builds of Toastman and Shibby's sources. I can tell you that the package versions are critical. If the exact versions are not available in a package repo for your OS, you will have to find the sources online and build the versions yourself.
     
  4. Alberto Castillo

    Alberto Castillo Network Newbie Member

    Thank you, I am trying to download Redhat 9 and see if in their repos the same versions are available. even if it has discontinued I wonder if the repos are still up. Redhat 9 is available on Redhat's archive FTP server
     
  5. Sean B.

    Sean B. LI Guru Member

    Are these the only build packages/versions the Linksys firmware calls for?

    Code:
    gcc 3.2.3, binutils 2.13.90.0.18-9, glibc 2.3.2-11.9, GNU Make version 3.79.1
     
  6. Alberto Castillo

    Alberto Castillo Network Newbie Member

    Hello Sean

    They are in the readme and seem to be these ones:
    Code:
    1. To Build both Tool chain and Firmware image:
       1.1 Host Redhat-9 (Linux kernel 2.4.20) on x86 machine
       1.2 Compiling tool version: gcc 3.2.3, binutils 2.13.90.0.18-9, glibc 2.3.2-11.9, GNU Make version 3.79.1
    It also seems to need ncurses-devel as I have installed on my CentOS 6 VPS test, plus you can also see that on the log that the sources include when the original firmware was compiled, but I don't know which version since it's not included in the Readme:
    Code:
    gcc  -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>" -I. -c mconf.c -o mconf.o
    gcc  -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>" -I. -c checklist.c -o checklist.o
    gcc  -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>" -I. -c menubox.c -o menubox.o
    gcc  -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>" -I. -c textbox.c -o textbox.o
    gcc  -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>" -I. -c yesno.c -o yesno.o
    gcc  -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>" -I. -c inputbox.c -o inputbox.o
    gcc  -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>" -I. -c util.c -o util.o
    gcc  -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>" -I. -c msgbox.c -o msgbox.o
    I am still downloading Redhat 9 from archive.download.redhat.com/pub/redhat/linux/9/en/iso/i386
    My connection is slow and will take some time to complete.

    I also attached the full log of the original firmware that is included in the sources as a zip file (as the .txt file is too large to upload)

    Thanks
     

    Attached Files:

  7. Alberto Castillo

    Alberto Castillo Network Newbie Member

    I am installing Redhat 9 now, seems like it has the right versions included, so I might just need to compile and that's it. It's still installing.
     
  8. Sean B.

    Sean B. LI Guru Member

    I've found the source packages for all the versions you need, if you wish to build them rather than install redhat 9. Whichever you prefer.
     
  9. Alberto Castillo

    Alberto Castillo Network Newbie Member

    Thank you very much, install is almost done
     
  10. Alberto Castillo

    Alberto Castillo Network Newbie Member

    I had to solve a few issues like following a kb article from vmware to be able to connect to the internet and disable iptables to be able to ssh on the virtual machine to be able to transfer the sources from my host machine.

    It compiled perfectly, however some weird things is that the Status page of the firmware doesn't match the MD5 of the firmware file I have uploaded, which is weird

    Besides that, it still shows 11 channels instead of 11..
     
  11. Sean B.

    Sean B. LI Guru Member

    I'm pretty sure the regional channel specifications are read by the wireless driver directly from the CFE, and changes to them in nvram or the firmware will be ignored. As the channel specs and transmit power are legally regulated in most demographics, allowing them to be changed as easily as setting some nvram variables or quick mods to firmware source would not be acceptable to any governing body.
     
  12. Alberto Castillo

    Alberto Castillo Network Newbie Member

    Hi

    True, I would agree with that. But my router is European. The original firmware that came with it had 13 channels instead of 11, upgrading (or more likely downgrading since they made a mess of my router's firmware) to the firmware makes the last 2 channels dissapear.

    The reason I say Linksys did a mess with my model is because originally my router had firmware 1.53. Then they posted updates on the website with firmware numbers like 1.02. That would be understood as a downgrade, but the build dates are later than the build date of 1.53.

    As far as I know, I remember someone mentioning on a forum that Linksys ported the WRT150N 1.52 firmware to the WRT160N and shipped it as 1.53. Then they published updates as 1.02 and so on..
     
    Last edited: Jul 26, 2017
  13. Sean B.

    Sean B. LI Guru Member

    May be a good idea to skip the firmware and go directly to the driver to see what settings its pulled. I think the stock firmware either has a "system commands" type option in the GUI, or allows for a telnet/ssh connection for a shell ( it's been so long sense I've run stock firmware ). Run:

    Code:
    wl country
    This will return the country the driver is configured with.

    Code:
    wl channels b
    This will return what the driver has allowed for available channels.

    Code:
    wl channels_in_country EU b
    This will return what the driver has listed as the available channels in Europe. Whether the outputs from those commands match or are different will be interesting to see.
     
    Last edited: Jul 26, 2017
  14. Alberto Castillo

    Alberto Castillo Network Newbie Member

    I can try when I get at home. There's no system commands option in the web GUI. I will try to connect using SSH or Telnet
     
  15. Sean B.

    Sean B. LI Guru Member

    Is there any chance there are firmware builds specific to regions? Such as filenames including EU,US,DE etc? If firmware for an incorrect region was flashed, and Linksys had made changes to the CFE in that firmware change, it could have changed your router to have originated elsewhere.
     
  16. Alberto Castillo

    Alberto Castillo Network Newbie Member

    Hi

    It could be, the firmware updates had "_US" added at the end. However they were downloaded from the european webpage. In fact, that's what I initially thought

    I can also confirm this with another router I have, the Cisco Linksys E3000. The firmware update for 1.0.0.6 (Can't remember the exact version numbering) had "_US" added at the end. It has the 13 channels.

    The device originally came with 1.0.0.4 (Can't remember the exact version numbering). I compared the MD5 on the status page to the original 1.0.0.4 firmware posted on the website that also had the "_US" applied to the filename. The MD5 matched and it had 13 channels.
    Both versions were downloaded from the european websites (Spanish)
     
  17. Sean B.

    Sean B. LI Guru Member

    Very strange. I'm rather curious as to what's going on here. Hopefully we can twist wl's arm so to speak and get the proper channels reinstated. If not, then to my knowledge the only other source of issue would be an erroneous configuration in the CFE. And fixing that would be... tricky.. at best.
     
  18. Alberto Castillo

    Alberto Castillo Network Newbie Member

    I agree.
    I have tried to load the original 1.53 firmware I had and that one shows the 13 channels perfectly, so I am unsure if it's really an issue on the CFE.

    Other aftermarket firmwares such as Tomato and DD-WRT show the 13 channels as well.
     
  19. Sean B.

    Sean B. LI Guru Member

    Do you have the Linksys firmware source for both versions? The one that was showing the channel 13 previously, and the one that now does not? If so, I'd suggest using diff or meld to compare and search for code changes between the two.
     
  20. Alberto Castillo

    Alberto Castillo Network Newbie Member

    Hi, I already tried to, the sources for the 1.53 firmware were published on the GPL Linksys webpage at some point many years ago.

    I also asked Vicktek, a known modder of Linksys firmwares as he had them in the past, but he no longer has them.

    I only keep the 1.2 sources that I published and these are easy to find on the internet on a Sourceforge page, as Linksys has already removed them.

    This is why I suspected the restriction could have been put on the Wireless Manual webpage where you can select the channels. I found that line I indicated above:
    Code:
       if(locale == "ETSI") {
            max_channel = 11;
        }
    It actually makes a lot of sense to change that line to 13 instead of 11. But didn't seem to work.
    This is indeed a mistery and I really would like to know what Linksys messed up with the european variants of this model.
    I remember calling their support many years ago asking about this and the firmware releases in their webpages promoting versions with a lower number than the one I previously had.
    They only were able to tell me that those were the right versions for the device. Never knew how to give me an answer to the 11 channel issue.
     
  21. Sean B.

    Sean B. LI Guru Member

    I'll download the sources and take a look this evening, maybe I can spot something else as I just don't have much for memory of them. Sorry I don't have more for suggestions, hopefully wl will give us a lead.
     
  22. Alberto Castillo

    Alberto Castillo Network Newbie Member

    Hello

    Thank you. This is mere curiosity, so feel free when you have sometime. I have tried to get into the router using telnet and SSH (using Putty) and it rejects any connection I attempt to make at it.

    My main issue is that I wished Linksys supported VLANs or that the Tomato firmware supported it for this model, as I will need it for a ISP I plan to sign a contract with. Requires 802.1q VLAN 20. So I assume it's a tag to VLAN20
     
  23. Sean B.

    Sean B. LI Guru Member

    I would think there would be an option in the GUI somewhere to enable ssh or telnet connections, I take it you didn't see one though? I'll see what I can find on how to enable it.
     
  24. Sean B.

    Sean B. LI Guru Member

    Downloaded the user manual for your router, unfortunately it does not appear to support a telnet or ssh connection nor have any command line ability at all with the stock firmware. That pretty well ties our hands on being able to do anything for diagnostics.
     
  25. Alberto Castillo

    Alberto Castillo Network Newbie Member

    Hello

    Sorry for not replying back to you yesterday.I have had this router for many years and I never saw any SSH/Telnet connection option on the stock firmware. However I must say it spent the vast most of it's life running DD-WRT

    My guess is that Linksys just messed up this model publishing their firmware as I see some other models from the era did have an ETSI firmware. It's probably fixable on the sources but haven't had the luck. I would say there might be a global variable that sets the model's region.
     
  26. Sean B.

    Sean B. LI Guru Member

    It may be worthwhile looking through the source for the variables named "wl_ccode" and "wl_country". There would also be alternate variables using "wl0" and "wl1" instead of just "wl" which are for the individual radios. Considering these variables are used for the wl driver and are also in the CFE they may very well exist in stock firmware as well. These are the ones I modified in the CFE and nvram of my router to "adjust" wl's options.
     
  27. Alberto Castillo

    Alberto Castillo Network Newbie Member

    will try to look for that
     
  28. Alberto Castillo

    Alberto Castillo Network Newbie Member

    I did find some, althought nothing related to the location of the router (althought I was probably not meant to find that there) but nothing which indicates the channels. I wouldn't be surprised if there was a whole locale or location value that held the location of the router itself.. The ammount of files is huge..
    Wished there was documentation that explained the enviroment itself
     
  29. Sean B.

    Sean B. LI Guru Member

    What did you find? Some of those variables I mentioned? If so, they completely control what region wl uses for it's allowed channel an tx power settings. If they're properly setup to use the country code for Europe a long with its full name then it's of no help. However if they're set to something else, that would be an issue.
     
  30. Sean B.

    Sean B. LI Guru Member

    And just in case, you may consider seeing if linksys has an option somewhere on their website to run your routers serial # and retrieve its build info. Just to confirm it was, in fact, built as an EU model router.
     
  31. Sean B.

    Sean B. LI Guru Member

    Nevermind that last post, I forgot you said other firmware allows channel 13. That firmware must be meant for a different region.. I'll try an get a look at the source.
     
  32. Sean B.

    Sean B. LI Guru Member

    Found It!!!! In /release/src/include/code_pattern.h

    Code:
    /***************************************
     * define country                      *
     * LOCALE=COUNTRY =                    *
     ***************************************/
    #define COUNTRY        LOCALE    <===HERE==== DEFINES COUNTRY WITH THE VALUE DEFINED BY LOCALE
    #define LOCALE USA   <===HERE==== LOCALE IS DEFINED AS USA. TO CHANGE TO EUROPE, PUT // AT THE BEGINNING OF THIS LINE
    //#define LOCALE JAPAN
    //#define LOCALE EUROPE   <===HERE==== AND REMOVE THE // FROM THIS LINE
    //#define LOCALE WW
    //#define LOCALE GERMANY
    //#define LOCALE FRANCE
    //#define LOCALE KOREA
    //#define LOCALE UK
    
    SEVERAL SECTIONS BELOW
    
    /***************************************
     * define wireless max channel         *
     * WL_MAX_CHANNEL =                    *
     ***************************************/
    #if LOCALE == JAPAN || LOCALE == EUROPE || LOCALE == GERMANY || LOCALE == FRANCE
        #define    WL_MAX_CHANNEL    "13"   <===HERE==== IF LOCALE IS DEFINED AS EUROPE, THIS VALUE WILL BE USED FOR MAX CHANNEL
    #elif OEM == KOREA
    //    #define    WL_MAX_CHANNEL    "13"    // 11g
        #define    WL_MAX_CHANNEL    "11"    // 11n
    #else
        #define WL_MAX_CHANNEL    "11"  <===HERE==== WITH LOCALE DEFINED AS USA, THIS VALUE IS BEING USED
    #endif
    It is defined as USA, with the max channel as 11. There may be other places that need to be changed still as well, but this confirms the firmware is for a US model. Forgive me if you already stated, but what was the reason you want to run this specific version? Rather than running one of the other versions you said allows channel 13 that is.
     
    Last edited: Jul 28, 2017
  33. Alberto Castillo

    Alberto Castillo Network Newbie Member

    Hello

    Sorry for my lack of answer, had an extremely busy day
    Yes, my model is completely european, first because it had an European firmware that was nowhere to be found on their website, and second because if you look below the router, it has the CE logo.

    I am surprised. I was going to take a look at it today again but I noticed you have found it earlier.
    Actually there was no reason. Just curiosity as I mentioned as I would like to know what the heck they did. I am also hesitant about buying a Linksys router again as I have a Linksys E3000 model that has wifi issues sometimes. (Haven't tracked the reasons of it but I doubt it's interferences even if my whole environment is full of 2,4Ghz wifis)

    I will give a try to reverting the Wireless_Manual.asp file and modifying the code_pattern.h file as you indicated. That should solve it

    Definetly the code makes sense there and they some how built this firmware only for USA and posted it on the european website

    Did it take you a long time to find it? how did you find it? I have no IDE in Linux. And there are so many files there
     
  34. Alberto Castillo

    Alberto Castillo Network Newbie Member

    Reverted previous Wireless_Manual.asp change and applied code_pattern.h change
    Compiling now.
     
  35. Alberto Castillo

    Alberto Castillo Network Newbie Member

    Still 11 channels
    I changed the Wireless manual.asp code back to 13 as well and no go
    I also did a 30/30/30/ reset on all the attempts
     
  36. Sean B.

    Sean B. LI Guru Member

    More than likely there's more references to USA in the source. Look around and see if there's any directories or files that reference "cfe" . If the firmware included changes to it, those would be the "master switches" so to speak. The only thing tho, we likely can't modify them.. as it's probably an included pre-med binary for security.
     
  37. Alberto Castillo

    Alberto Castillo Network Newbie Member

    Thank you, but I am surprised there's no documentation provided. Guessing makes it harder.
     
  38. Sean B.

    Sean B. LI Guru Member

    Found another one. /release/src/cy_conf.mak

    Code:
    WEB_PAGE=cisco_wrt54g_m
    LOCALE=USA        <======
    DNSMASQ_SUPPORT=1
    CONFIG_DNSMASQ=y
    UDHCPD_SUPPORT=1
    CONFIG_UDHCPD=y
    UDHCPC_SUPPORT=1
    CONFIG_UDHCPC=y
    PPPOE_SUPPORT=1
     
  39. Sean B.

    Sean B. LI Guru Member

    That's the only other one I can find, if there's more then they're in the binaries and out of our reach. If you decide to run a build with this one changed to EU a long with the other one we found, don't forget after flashing to "restore router defaults" to be sure the changes get loaded into nvram.
     
  40. Alberto Castillo

    Alberto Castillo Network Newbie Member

    That must be it as it seems to be part of the webpage. I assume the word I have to replace it with is ETSI, I will compile it tomorrow. How did you locate them?

    Yea, I always did factory defaults and 30/30/30
     
  41. Sean B.

    Sean B. LI Guru Member

    I believe you'd just change USA to EU . And make sure to change the other file as we discussed in the prior posts as well.
     
  42. Alberto Castillo

    Alberto Castillo Network Newbie Member

    I haven't had time yet, hopefully I can try this tomorrow!
     

Share This Page