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 PCI_SUPPORT
config USB_SUPPORT。。。----既无menu又无choice故非配置菜单。
# Architecture selection
config arm_v7
config mips。。。
1.2source "tmp/.config-target.in"
choice----------------------一级菜单
prompt "Target System"
default TARGET_ar71xx
config TARGET_ppc44x
config TARGET_bcm53xx
config TARGET_octeon
config TARGET_ramips
bool "Ralink RT288x/RT3xxx"
end choice--------------------一级菜单结束
choice
prompt "Subtarget" if HAS_SUBTARGETS------一级菜单
config TARGET_ramips_mt7620a
bool "MT7620a based boards"
select LINUX_3_10
depends on TARGET_ramips
select USES_DEVICETREE
select GPIO_SUPPORT----选中TARGET_ramips_mt7620a后会连带选中以下select各项
select PCI_SUPPORT
select USES_SQUASHFS
select USB_SUPPORT
select mipsel
。。。。。。
end choice-----------------------一级菜单结束
choice
prompt "Target Profile"--------------------一级菜单,配置菜单中只有一个选项但选中后会连带选中如下一系列select项。
config TARGET_ramips_mt7620a_Default
bool "Default Profile"
depends on TARGET_ramips_mt7620a
select DEFAULT_base-files
select DEFAULT_busybox
select DEFAULT_dnsmasq
select DEFAULT_dropbear
select DEFAULT_firewall
select DEFAULT_fstools
select DEFAULT_ip6tables
select DEFAULT_iptables-----------Default package set compatible with most boards.
select DEFAULT_iwinfo
select DEFAULT_kmod-gpio-button-hotplug
select DEFAULT_kmod-ipt-nathelper
select DEFAULT_kmod-leds-gpio
select DEFAULT_kmod-ledtrig-usbdev
select DEFAULT_kmod-rt2800-pci
select DEFAULT_kmod-rt2800-soc
select DEFAULT_kmod-usb-core
select DEFAULT_kmod-usb-dwc2
select DEFAULT_libc
select DEFAULT_libgcc
select DEFAULT_mtd
select DEFAULT_netifd
select DEFAULT_odhcp6c
select DEFAULT_odhcpd
select DEFAULT_opkg
select DEFAULT_ppp
select DEFAULT_ppp-mod-pppoe
select DEFAULT_swconfig
select DEFAULT_uci
select DEFAULT_wpad-mini
end choice---------------------------一级菜单结束
================================================================================================================================================
squashfs-lzma:制作squashfs文件系统,并用lzma压缩算法压缩(若硬件平台选Ralink则root filesystem默认用squashfs-lzma压缩,
最终用脚本将uImage和压缩的root filesystem压成一个固件包)。
--------------->固件就是内核+根文件系统放在一个分区,类似硬盘的分区系统可按需读取该分区上的任一个文件。
2.1 source "config/Config-images.in"
menu "Target Images"----------------一级菜单
choice-----------------------------二级菜单
config TARGET_INITRAMFS_COMPRESSION_LZMA-------若使用内核的Initramfs则需选择Initramfs的压缩方式。
config TARGET_ROOTFS_TARGZ---------------------若root filesystem直接打包,则需选择打包所用压缩格式(tar.gz或cpio.gz)。
config TARGET_ROOTFS_JFFS2--------------------文件系统的映像(images)类型,一般为squashfs或yaffs2。
endchoice------------------------二级菜单结束
source "target/linux/*/image/Config.in"-----二级菜单,不过该菜单只有X86\at91\avr32及博通等几个硬件平台有,其他平台不需要。
endmenu-------------------一级菜单结束
=================================================================================================================================================
3.1 source "config/Config-build.in"
menu "Global build settings"-----------------一级菜单
config COLLECT_KERNEL_DEBUG---收集内核编译符号表及其他模块的编译符号表,调试用。
comment "Kernel build options"
source "config/Config-kernel.in"
comment "Package build options"
config DEBUG-------将package的符号表等信息编到package中
3.2 comment "Kernel build options"
config KERNEL_EARLY_PRINTK
config KERNEL_PRINTK_TIME----选中后内核Printk会打印时间信息(内核本身的编译选项)。
config KERNEL_NAMESPACES
config KERNEL_KALLSYMS------使能内核编译符号表编译到内核(内核本身的编译选项)。
==================================================================================================================================================
4.1 source "config/Config-devel.in"和source "toolchain/Config.in"
menuconfig DEVEL------------------一级菜单
bool "Advanced configuration options (for developers)"
config DOWNLOAD_FOLDER---------可设置make时下载文件的存放目录
config TARGET_ROOTFS_DIR--------修改根文件系统所在的目录
config KERNEL_GIT_CLONE_URI-----配置所需内核版本的git下载链接
config KERNEL_GIT_LOCAL_REPOSITORY
config BUILD_LOG--------------配置编译时是否记录错误日志
config SRC_TREE_OVERRIDE----自定义package目录源码的位置
config EXTERNAL_KERNEL_TREE----自定义内核源码目录(使用自己的内核源码)
menuconfig TARGET_OPTIONS---------二级菜单
bool "Target Options" if DEVEL
config TARGET_OPTIMIZATION----开启编译器优化
endmenu
menuconfig EXTERNAL_TOOLCHAIN-----二级菜单
config NATIVE_TOOLCHAIN---配置使用host及toolchain目录中编译出来的工具及编译器,否则需要自定义工具的名称、安装路径、及工具链头文件和依赖库路径。
source "toolchain/eglibc/Config.in"
source "toolchain/uClibc/Config.in"
source "toolchain/musl/Config.in"
source "toolchain/gcc/Config.version"
source "toolchain/eglibc/Config.version"
source "toolchain/uClibc/Config.version"
source "toolchain/musl/Config.version"
========================================================================================================================
5 下面这三项包含的内容极少:
source "target/imagebuilder/Config.in"
source "target/sdk/Config.in"
source "target/toolchain/Config.in"
bool "Build the OpenWrt Image Builder"---若不用外部工具链且不用Initramfs,openWRT就编译生成Image构建工具。
depends on !TARGET_ROOTFS_INITRAMFS
depends on !PROFILE_KCONFIG
depends on !EXTERNAL_TOOLCHAIN
config SDK
bool "Build the OpenWrt SDK"---------只要不用外部工具链,openWRT就编译SDK。
depends on !EXTERNAL_TOOLCHAIN
config MAKE_TOOLCHAIN
bool "Build the OpenWrt based Toolchain"
depends on !EXTERNAL_TOOLCHAIN-----------只要不用外部工具链,openWRT就选中该配置项进而自行编译安装所有工具和工具链。
====================================================================================================================
6.1 source "tmp/.config-package.in"
menuconfig IMAGEOPT--------------一级菜单
bool "Image configuration"
source "package/*/image-config.in"------类似Uboot传递的bootargs参数(如init=/bin ipaddr等环境变量)
endmenu
menu "Base system"--------------------------------一级菜单
config PACKAGE_Smartroom--------------------------自定义的模块
tristate "Smartroom............................................ wulian MT7620 tools"
default y if DEFAULT_Smartroom
default m if ALL
select PACKAGE_libc
select PACKAGE_librt
select PACKAGE_libsqlite3
select PACKAGE_libstdcpp
select PACKAGE_libpthread
select PACKAGE_librt if USE_EGLIBC
select PACKAGE_libpthread if USE_EGLIBC---优化场景执行功能;优化设备管理(网关重启后生效)。
config PACKAGE_base-files---------该配置项用于选中openWRT系统启动脚本
tristate "base-files................................... Base filesystem for OpenWrt"
default y if DEFAULT_base-files
default m if ALL
select PACKAGE_libc
select PACKAGE_procd-----------若配置了openWRT的系统启动脚本,那这些select选项必选。
select PACKAGE_netifd
select PACKAGE_librt if USE_EGLIBC
select PACKAGE_libpthread if USE_EGLIBC
source "package/utils/busybox/Config.in"---------二级菜单,busybox的配置菜单
source "package/system/udev/Config.in"-----------二级菜单,udev的配置菜单(udev替代devfs及hotplug,管理/dev目录设备文件)
config PACKAGE_wulian-tools
tristate "wulian-tools......................................... wulian MT7620 tools"
default y if DEFAULT_wulian-tools
default m if ALL
select PACKAGE_lua
select PACKAGE_zlib
select PACKAGE_libopenssl
select PACKAGE_libpcre
select PACKAGE_libstdcpp
select PACKAGE_libpthread
select PACKAGE_libpthread if USE_EGLIBC
select PACKAGE_libc
select PACKAGE_librt
select PACKAGE_librt if USE_EGLIBC
select PACKAGE_libsqlite3
endmenu
menu "Boot Loaders"---------------部分硬件平台支持Uboot配置选项,选中后便可使用openWRT工程中的Uboot?
config PACKAGE_uboot-sunxi-pcDuino--------一级菜单
endmenu----------------------------------一级菜单结束
menu "Kernel modules"-----------一级菜单
menu "Block Devices"--------二级菜单
config PACKAGE_kmod-ata-core
config PACKAGE_kmod-mvsas-----Kernel support for the Marvell SAS SCSI adapters。
endmenu--------------------二级菜单结束
menu "Wireless Drivers"--------二级菜单
config PACKAGE_kmod-rt2800-pci-----雷凌pci接口的网卡驱动,不是片上的WiFi驱动。
config PACKAGE_kmod-rt2800-usb-----雷凌USB接口的网卡驱动,不是片上的WiFi驱动。
endmenu--------------------二级菜单结束
。
。
。
endmenu--------------------一级菜单结束
menu "JavaScript"---------一级菜单,如下这些一级菜单均是可选择的,一般只选menu "Lua" ?
menu "Java"
menu "Lua"
menu "PHP"
menu "Perl"
menu "Ruby"
menu "Libraries"------------一级菜单
menu "Filesystem"-------二级菜单
config PACKAGE_libattr----libattr库,为文件系统提供libattr库?
config PACKAGE_libext2fs---libext2fs is a library which can access ext2, ext3 and ext4 filesystems.
endmenu----------------二级菜单结束
menu "Firewall"-------二级菜单
PACKAGE_libip4tc-----IPv4防火墙必需的libiptc开源库
endmenu------------二级菜单结束
source "package/libs/openssl/Config.in"
source "feeds/packages/libs/gnutls/Config.in"
source "package/libs/openssl/Config.in"
menu "Sound"---------二级菜单
config PACKAGE_liblo------轻量级开源声音控制库
endmenu
menu "Database"---------二级菜单
config PACKAGE_libsqlite2------开源数据库
config PACKAGE_pgsqlodbc----Postgresql driver for ODBC.
endmenu