title: How to write Hello World for OpenWRT and/or dd-wrt
body: <p>I'm working on running a Hello World program on the Linksys WRT54G-V4 running either dd-wrt or OpenWRT.</p>
  
  <p>Right now this router is running dd-wrt for reasons I'll explain below. I'd like to switch this router to OpenWRT, because I've not been able to build dd-wrt or its toolchain.  I 'assume' that the OpenWRT toolchain should produce executable binaries that will run on dd-wrt also.</p>
  
  <p>OpenWRT was pretty straightforward to build, since it has a nice menu driven make system. Using this handy tool I built a toolchain that will cross compile from my x86 Ubuntu box to a MIPS target.</p>
  
  <p>Following the instructions I've been able to build OpenWRT and produce images for brcm47xx and brcm63xx.   </p>
  
  <p>For example, here is a successful compile of my little Hello World program:</p>
  
  <pre><code>jim@ubuntu:~/Desktop/tests$ cat helloC.c
  #include &lt;stdio.h&gt;
  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$
  </code></pre>
  
  <p>Sadly, when I try to run HelloWorld on my WRT54G-V4 running dd-wrt I get a seg fault.</p>
  
  <p>Looking at Wikipedia, I see that this router uses the Broadcom BCM5352. </p>
  
  <p>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.</p>
  
  <p><strong>Question 1</strong> - Which Broadcom configuration should I select using make menuconfig to target my WRT54G-V4 with its BCM5352 chipset?</p>
  
  <p><strong>Question 2</strong> - 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 <a href="http://www.gargoyle-router.com/wiki/doku.php?id=openwrt_coding" rel="nofollow">http://www.gargoyle-router.com/wiki/doku.php?id=openwrt_coding</a> ?</p>
  
  <p>TIA</p>