openWRT编译初体验:
sudo apt-get update
sudo apt-get install gcc g++ binutils patch bzip2 flex bison make autoconf gettext texinfo unzip sharutils subversion libncurses5-dev ncurses-term zlib1g-dev
svn co svn://svn.openwrt.org/openwrt/branches/backfire
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig
make V=s(若想清除重新编译则make distclean)
openWRT添加最小驱动模块、最小应用模块:
1.添加内核模块
进入openWRT/package目录下,新建模块目录mkdir example----->
cd example; touch Makefile;touch config.in ;mkdir src(makefile中PKG_NAME:=example;define KernelPackage/example;
$(eval $(call KernelPackage,example))语句是将该内核模块编译进系统的,必加)----->
cd src; touch makefile----->
在openWRT/tmp/.config-package.in中添加一个一级菜单并在菜单中包source "package/example/config.in"
make package/example/compile编译该模块即可。
如:
menu "Ralink Properties"
menu "Applications"
config PACKAGE_ated
tristate "ated.......................................................... ATE Daemon"
default y if DEFAULT_ated
default m if ALL
select PACKAGE_libc
select PACKAGE_librt if USE_EGLIBC
select PACKAGE_libpthread if USE_EGLIBC
help
ATE Daemon
endmenu
menu "Drivers"
menuconfig PACKAGE_kmod-rt2860v2
tristate "kmod-rt2860v2............................... Ralink MT7620 wifi AP driver"
default y if DEFAULT_kmod-rt2860v2
default y if (CONFIG_TARGET_ramips_mt7620n || CONFIG_TARGET_ramips_mt7620a)
select PACKAGE_maccalc
select PACKAGE_wireless-tools
depends on TARGET_ramips_mt7620a
help
This package contains a driver for MT7620
source "package/ralink/drivers/mt7620/config.in"
endmenu
endmenu
2.添加用户态工具或最小应用模块
进入openWRT/package目录下,新建模块目录mkdir example2----->
cd example2; touch Makefile;touch config.in ;mkdir src(makefile中PKG_NAME:=example2;define Package/example2;
$(eval $(call Package,example2))语句是将该内核模块编译进系统的,必加)----->
cd src; touch makefile----->
在openWRT/tmp/.config-package.in中添加一个一级菜单并在菜单中包source "package/example/config.in"
make package/example/compile编译该模块即可。
注:应用模块的新加菜单一般放在一级菜单Base system下,应用菜单作为二级或三级菜单。
openWRT各Kconfig或config.in的调用顺序:
顶层config.in:mainmenu "OpenWrt Configuration"
source "target/Config.in"
source "config/Config-images.in"
source "config/Config-build.in"
source "config/Config-devel.in"
source "toolchain/Config.in"
source "target/imagebuilder/Config.in"
source "target/sdk/Config.in"
source "target/toolchain/Config.in"
source "tmp/.config-package.in"
1.1source "target/Config.in":实现了类似内核中ARCH=arm及make SMDKxxx_defconfig的功能。
source "tmp/.config-target.in"
# Kernel/Hardware features
config GPIO_SUPPORT
config