-
如果想在OpenWRT上运行自己的程序,就得准备一个开发环境,OpenWRT的开发环境是基于Linux的,所以得先安装一个Linux
- 安装VMWare;
- 下载Ubuntu Server最新版,有32位和64位,应该都可以,但我下载的是32位;
- 通过下载到的Ubuntu ISO文件在VMWare里安装;
- 准备必要的包:
sudo apt-get update
sudo apt-get install subversion git openssh-server gcc g++ binutils patch bzip2 flex bison make autoconf gettext texinfo unzip sharutils subversion libncurses5-dev ncurses-term zlib1g-dev
- 获取OpenWRT源代码: svn checkout svn://svn.openwrt.org/openwrt/trunk
- cd trunk
- ./scripts/feeds update -a
- ./scripts/feeds install -a
- 配置编译选项 make menuconfig
- 最后一步,编译生成固件 make V=99 这一步会比较耗时,慢慢等
- 编译成功后,bin下会生成各种固件,这也说明你的环境已经准备好了,
- 写一个helloworld.c程序, 内容如下:
#includeint main(void)
{
printf("Hello world!\n");
return 0;
}
- staging_dir/toolchain-mips_r2_gcc-linaro_uClibc-0.9.32/bin/mips-openwrt-linux-uclibc-gcc -o helloworld helloworld.c
- 把生成的helloworld程序上传到路由器上就可以跑起来了
-
Targets for ‘make’
download
download all source tarballs (from the selected packages and it’s dependencies) at once before starting the build
prereq
checks if you have all prerequisites installed on the host-system for building the selected packages
world
build everything
tools/install toolchain/install
only build the tools and the toolchain
clean
cleans the packages (NOT the tools and toolchain)
distclean
cleans up everything expect $(TOPDIR)/.config and $(TOPDIR)/dl/
package/-{clean,compile}
rebuild a single package
package/index
updates $(TOPDIR)/bin/packages/Packages
V=99
turns on debugging
make kernel_menuconfig
If you want, you can also modify the kernel config for the selected target system. Simply run “make kernel_menuconfig”
and the build system will unpack the kernel sources (if necessary), run menuconfig inside of the kernel tree, and then
copy the kernel config to target/linux//config so that it is preserved over “make clean” call.
Also look at the OpenWrt Kamikaze documentation at
- http://nbd.name/openwrt.html#x1-250002.1 or
- http://nbd.name/openwrt.pdf
Some more useful URLs:
- Free VMware Player (enough for most users, no need for the VMware Server)
- Download VMDK and VMX files for VMware Player
- Ubuntu (for the Ubuntu ISO image)
- Free VMware Server (also includes the VMware Tools)
My name is Hugo Zhu.



