Chinaunix首页 | 论坛 | 博客
  • 博客访问: 279738
  • 博文数量: 102
  • 博客积分: 230
  • 博客等级: 入伍新兵
  • 技术积分: 477
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-13 15:58
文章存档

2014年(23)

2013年(2)

2012年(45)

2011年(32)

分类:

2012-11-26 17:02:46

用的是Gentoo Linux Kernel版本2.6.28.7
~ $ uname -a
Linux linyin 2.6.28.7 #1 Tue Mar 3 17:12:26 CST 2009 i686 VIA Samuel 2 CentaurHauls GNU/Linux
从DD-WRT官方网站下载Toolchains
地址:
 
其中有如下几个版本:
all_toolchains_amd64.tar.bz2                  For AMD64 CPU
gcc-3.3.5-openwrt.tar.bz2                     在OpenWRT环境下
gcc-3.4.4-crossmipsel-AMD64.tar.bz2           For AMD64 CPU
gcc.3.4.4-broadcom-mipsel.tar.bz2             一般的X86 CPU
toolchains.darwin.ppc.sp1.tar.bz2             PPC CPU下Darwin系统
toolchains.x86.debian.sp1.tar.bz2             X86下的Debian系统
 
我使用的路由器是贝尔金7231-4P,MIPS类CPU,BROADCOM芯片
:~# uname -a
Linux DD-WRT 2.4.35 #1955 Tue May 20 06:38:36 CEST 2008 mips unknown
:~# cat /proc/cpuinfo
system type             : Broadcom BCM4712 chip rev 1
processor               : 0
cpu model               : BCM3302 V0.7
BogoMIPS                : 199.47
wait instruction        : no
microsecond timers      : yes
tlb_entries             : 32
extra interrupt vector  : no
hardware watchpoint     : no
VCED exceptions         : not available
VCEI exceptions         : not available
下载toolchains后解压,我放在/home/linyin/.opt/
修改用户.bashrc添加:export PATH=$PATH:/home/linyin/.opt/openwrt/bin
 
写个C程序:
  1 #include
  2 int main()
  3 {
  4         printf("Hello,DD-WRT\n");
  5         return 0;
  6 }
 
交叉编译它:
~ $ mipsel-linux-gcc -o test test.c
查看可执行文件类型:
~ $ file test
test: ELF 32-bit LSB executable, MIPS, MIPS32 version 1 (SYSV), dynamically linked (uses shared libs), not stripped
OK,放到DD-WRT下就可以执行了... =)

阅读(1849) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~