OpenWrt Forum Archive

Topic: HOW TO: Configure toolchain for WRT54G-V4

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

I'm working on running a Hello World program on the Linksys WRT54G-V4.

Right now this router is running dd-wrt for reasons I'll explain below. 

Following the instructions I've been able to build OpenWRT and produce images for brcm47xx and brcm63xx.  I was never able to build dd-wrt firmware, or figure out its toolchain.

I'm able use the very nice 'make menuconfig' utility to build a toolchain that will cross compile from my x86 Ubuntu box to a MIPS target.

For example, here is a successful compile of my little Hello World program:

jim@ubuntu:~/Desktop/tests$ cat helloC.c
#include <stdio.h>
int main (int argc, char **argv)
{
  printf("Hello World\n");
  return 0;
}
jim@ubuntu:~/Desktop/tests$
jim@ubuntu:~/Desktop/tests$ mipsel-openwrt-linux-gcc -o HelloWorld helloC.c
jim@ubuntu:~/Desktop/tests$
jim@ubuntu:~/Desktop/tests$ file HelloWorld
HelloWorld: ELF 32-bit LSB executable, MIPS, MIPS32 version 1, dynamically linked (uses shared libs), with unknown capability 0xf41 = 0x756e6700, with unknown capability 0x70100 = 0x3040000, not stripped
jim@ubuntu:~/Desktop/tests$

Sadly, when I try to run HelloWorld on my WRT54G-V4 running dd-wrt I get a seg fault.

Looking at Wikipedia, I see that this router uses the Broadcom BCM5352. 

When I run make menuconfig in by OpenWRT/trunk directory I don't see an option for the BCM5352, which is why I'm reluctant to flash my router with one of the images I've created in the brcm47xx or brcm63xx directories. I don't want to guess wrong and brick the router.

Question 1 - Which Broadcom configuration should I select using make menuconfig to target my WRT54G-V4 with its BCM5352 chipset?

Question 2 - Should my 'HelloWorld' executable file I generated above run directly from the command line on the 54G, or must I make it a package per http://www.gargoyle-router.com/wiki/dok … wrt_coding ?

TIA

(Last edited by JimNtexas on 6 Sep 2012, 19:17)

Current OpenWrt uses a way newer uClibc than DD-Wrt. Try an 8.09 release of OpenWrt and build the toolchain with that. Also pick the brcm-2.4 target there.

Thanks jow,

My initial attempt to flash your recommended version of OpenWRT on this WRT54Gv2.2 box failed, but I was able to get connected to what I believe to be the fail safe system.

I can access the Attitude Adjustment gui via putty.

BusyBox v1.19.4 (2012-08-29 13:09:40 PDT) built-in shell (ash)
Enter 'help' for a list of built-in commands.

  _______                     ________        __
|       |.-----.-----.-----.|  |  |  |.----.|  |_
|   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
|_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
-----------------------------------------------------
ATTITUDE ADJUSTMENT (Bleeding Edge, r33311)
-----------------------------------------------------
  * 1/4 oz Vodka      Pour all ingredients into mixing
  * 1/4 oz Gin        tin with ice, strain into glass.
  * 1/4 oz Amaretto
  * 1/4 oz Triple sec
  * 1/4 oz Peach schnapps
  * 1/4 oz Sour mix
  * 1 splash Cranberry juice
-----------------------------------------------------
root@OpenWrt:~# help
Built-in commands:
------------------
        . : [ [[ alias bg break cd chdir command continue echo eval exec
        exit export false fg getopts hash help jobs kill let local printf
        pwd read readonly return set shift source test times trap true
        type ulimit umask unalias unset wait

root@OpenWrt:~#

The router does work, and one can connect to the internet with it. 

My problem is that I can't seem to re-flash a openwrt-brcm-2.4-squashfs.trx on it.  I've tried using tftpw.exe right after power-on with no luck.

I don't have an httpd daemon running, and opkg won't install luci .

I've set nvram boot_time to 10, and nvram boot_wait is on

The good news is that I can write C programs on my Linux box and can successfully compile and run them on this system smile smile . WinSCP can manipulate the file system. 

I just need to get a full router with web gui, either by reflashing  or getting a web interface working on it.

Thanks again.

(Last edited by JimNtexas on 7 Sep 2012, 23:02)

I'm back in business! 

To summarize, here how I was able to unbrick my Linksys WRT54G-V2.2

I was able to connect to and log in to the failsafe system using the documented procedures.

I downloaded and installed the correct firmware image using the instructions at http://wiki.openwrt.org/toh/linksys/wrt54g , 'Update the OpenWrt Image from Failsafe'. 

Specifically,

cd /tmp
wget http://downloads.openwrt.org/whiterussi … uashfs.trx

mtd -r write openwrt-brcm-2.4-squashfs.trx linux


The system rebooted, and now I have the basic OpenWRT web gui. 

I can compile and run C programs on this box thanks to the hints above from @jow.

Thanks!

The discussion might have continued from here.