从 x86 交叉编译 MIPS 路由器
我的最终目标是为我的旧 Actiontec 调制解调器/路由器编译无线工具,以便我可以将其配置为无线以太网桥。目前,它的无线功能(似乎)由管理大部分 Web 界面的相同二进制文件控制,但似乎它们使用了内部使用的无线工具库,至少实现了某些功能。
我以前从未针对不同的 CPU 架构进行过交叉编译,并且不确定如何完全识别我需要做什么。我正在尝试使用 uClibc,因为它似乎已在系统的其余部分中使用,但我不确定如何为调制解调器环境配置 buildroot。我根据下面的过程中的信息对配置应该是什么进行了最佳猜测,但是自从a用它编译的简单 C 应用程序仅返回 0,无法正常运行。
# cat /proc/version
Linux version 2.4.17_mvl21-malta-mips_fp_le ([email protected]) (gcc version 2.95.3 20010315 (release/MontaVista)) #1 Thu Apr 21 18:04:37 PDT 2005
# cat /proc/cpuinfo
processor : 0
cpu model : MIPS 4KEc V4.8
BogoMIPS : 149.91
wait instruction : no
microsecond timers : yes
extra interrupt vector : yes
hardware watchpoint : yes
VCED exceptions : not available
VCEI exceptions : not available
My end goal is to compile wireless tools for my old Actiontec modem/router so I can configure it as a wireless to ethernet bridge. Currently it's wireless features are (seemingly) controlled by the same binary that manages most of the web interface, but it appears that they used the library wireless tools uses internally for at least some of the functionality.
I've never cross compiled for a different CPU architecture before and not sure how to fully identity what I need to do. I'm trying to use uClibc since it appears to be used in the rest of the system, but I'm not sure how to configure buildroot for the modems environment. I made a best guess at what the configuration should be based on the information from proc below, but somethings wrong since a simple C application that only returns 0 compiled with it fails to run properly.
# cat /proc/version
Linux version 2.4.17_mvl21-malta-mips_fp_le ([email protected]) (gcc version 2.95.3 20010315 (release/MontaVista)) #1 Thu Apr 21 18:04:37 PDT 2005
# cat /proc/cpuinfo
processor : 0
cpu model : MIPS 4KEc V4.8
BogoMIPS : 149.91
wait instruction : no
microsecond timers : yes
extra interrupt vector : yes
hardware watchpoint : yes
VCED exceptions : not available
VCEI exceptions : not available
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你是对的,你需要一个合适的mips工具链来交叉编译你的应用程序和Buildroot 可以做到这一点。但您可能需要调整 buildroot 的 menuconfig 选项。
根据
文件
的输出,您的选项可能会发生变化。在我的系统上,二进制应用程序通知以下信息:ELF 32 位 MSB 可执行文件、MIPS、MIPS32 rel2 版本 1 (SYSV)
这些是我为 Buildroot 的菜单配置启用的选项:
工具链本身已安装在/opt/cross-mips-buildroot。您可以在 /opt/cross-mips-buildroot/usr/bin/ 上找到编译器和其他工具。
尝试编译一个简单的 hello world 应用程序,看看是否可以运行它在 mips 系统内部。
注意:此配置不会构建 C++ 编译器。如果您需要它,您可以
grep LIBSTDCPP .config
并检查它是否启用,并将其更改为您喜欢的。然后make menuconfig
来实现它。You are right, you need a proper mips toolchain to cross-compile your application and Buildroot can do that. But you may need to tweak buildroot's menuconfig options.
Depending on the output of
file
, your options may change. On my system, binary apps inform the following:ELF 32-bit MSB executable, MIPS, MIPS32 rel2 version 1 (SYSV)
These are the options I have enabled for my Buildroot's menuconfig:
The toolchain itself is installed at /opt/cross-mips-buildroot. You can find the compiler and other tools on /opt/cross-mips-buildroot/usr/bin/
Try to compile a simple hello world application and see if you can run it inside the mips system.
Note: this configuration will not build a C++ compiler. If you need it, you can
grep LIBSTDCPP .config
and check if it's enable or not and change it to your likes. Thenmake menuconfig
to make it happen.查看:
http://www.kegel.com/crosstool/
这是跨领域的权威网站在 GCC 下编译。
Check out:
http://www.kegel.com/crosstool/
It's the authoritative site on cross-compiling under GCC.
请随意查看 dockcross 项目。他们提供跨工具链作为各种架构的 docker 容器。
就我个人而言,我更喜欢保持我的主机系统尽可能干净,所以这对我来说是完美的匹配。
要启动并运行一个简单的 hello world 示例,请按照 README 中的步骤操作.首先。
MIPS 上的 HelloWorld.c
不过,请查看我的 hello world 编译,了解正在运行的 Netgear N600 wndr3700v2 路由器DD-WRT。 (我链接了 openWRT wiki 页面而不是 dd-wrt,更喜欢这个)。
检查路由器上使用的架构,请信任 wiki 页面或仅通过 ssh/telnet 连接并运行 uname -a 命令。
因此,我们可以从 dockerhub 中提取 mips 容器:
让我们创建一个名为
helloWorld
的简单项目文件夹,并在其中添加一些代码。现在我们可以使用
dockcross
来编译它。现在我们已准备好传输并运行您的
helloWorld
可执行文件。如果您不知道加载程序位于何处,请使用 file 命令。如果该命令不可用,请查看 entware 项目。
这是官方的 dd-wrt 安装图这里
please feel free to look into dockcross project. They offer cross tool-chains as docker containers for various architectures.
Personally, I prefer to keep my host system as clean as possible, so this is a perfect match for me.
To get a simple hello world example up and running please just follow the steps from the README.rst.
HelloWorld.c on MIPS
However, please checkout my hello world compilation for a Netgear N600 wndr3700v2 router running DD-WRT. (I have linked the openWRT wiki page instead of the dd-wrt, prefer this one).
Check which arch is used on the router, please trust the wiki pages or just connect via ssh/telnet and run uname -a command.
So we can pull the mips container from dockerhub:
Let's create a simple project folder called
helloWorld
and but some code into it.Now we can compile it with
dockcross
.Now we are ready to transfer and run your
helloWorld
executable.In case you do not know where your loader is located, please use file command. In case the command is not available, please checkout entware project.
Here would be the official dd-wrt install tut here