我在LinksysWRT54G-V4上运行一个Hello程序,运行dd或OpenWRT。
现在这个路由器正在运行dd,原因我将在下面解释。我想把这个路由器切换到OpenWRT,因为我还不能构建dd或它的工具链。我“假设”OpenWRT工具链应该生成可执行的二进制文件,这些二进制文件也将在dd上运行。
OpenWRT的构建非常简单,因为它有一个很好的菜单驱动的make。使用这个方便的工具,我构建了一个工具链,它将交叉编译从我的x86 Ubuntu到一个MIPS目标。
按照指示,我能够构建OpenWRT并为brcm47xx和brcm63xx生成图像。
例如,下面是我的小Hello程序的成功编译:
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$可悲的是,当我试图在运行dd的WRT54G-V4上运行HelloWorld时,我会遇到一个seg错误。
看看维基百科,我看到这个路由器使用的是Broadcom BCM5352。
当我通过OpenWRT/主干目录运行menuconfig时,我没有看到BCM5352的选项,这就是为什么我不愿意用我在brcm47xx或brcm63xx目录中创建的映像来刷新路由器的原因。我不想猜错了,把路由器砌成砖块。
问题1 -我应该选择使用menuconfig来针对WRT54G-V4和它的BCM5352芯片组的哪个Broadcom配置?
问题2 -我上面生成的'HelloWorld‘可执行文件是直接从54G上的命令行运行,还是必须使其成为每个coding的包?
提亚
发布于 2016-07-23 12:18:15
您可以按照官方的方法操作(来自:http://www.dd-wrt.com/forum/viewtopic.php?p=21499&sid=de90601a8d51747d1c8ccec29284127d)
1. The helloworld.c source
Code:
#include <stdio.h>
int main ( void ) {
printf( "Hello world!\n" );
}
2. Get and unpack the toolchain in your homedir
Code:
cd ~
wget ftp://ftp.dd-wrt.com/sourcecode/toolchains.x86.debian.sp1.tar.bz2
tar -jxf toolchains.x86.debian.sp1.tar.bz2
3. Add the path to your cross-compiler executable to your path environment variable and compile helloworld.c
Code:
PATH=~/toolchains/4.1.0-uclibc-0.9.28/bin:$PATH mipsel-linux-uclibc-gcc helloworld.c -o helloworld
4. Check if its correctly compiled with the cross-compiler
Code:
file helloworld
helloworld: ELF 32-bit LSB executable, MIPS, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
5. Finally, transfer the helloworld binary file to your router, set the executable bit and run it.用Ubuntu6.06.1LTS测试。
https://stackoverflow.com/questions/12306165
复制相似问题