首页 > 代码库 > openwrt学习笔记

openwrt学习笔记

http://blog.csdn.net/openme_openwrt/article/details/7348452  编译OpenWrt - 索引


Wiki导航:http://wiki.openwrt.org/doc/start


编译OpenWRT
0早期的openwrt编译文档:http://downloads.openwrt.org/docs/buildroot-documentation.html#about


1工具链:http://wiki.openwrt.org/about/toolchain

2编译准备:http://wiki.openwrt.org/doc/howto/buildroot.exigence

3编译:http://wiki.openwrt.org/doc/howto/build

4添加feeds:http://wiki.openwrt.org/doc/devel/feeds

5Image Builder:http://wiki.openwrt.org/doc/howto/obtain.firmware.generate

6 SDK:http://wiki.openwrt.org/doc/howto/obtain.firmware.sdk

7 Rootfs on External Storage (extroot):

    http://wiki.openwrt.org/doc/howtobuild/extroot.howtobuild

    http://wiki.openwrt.org/doc/howto/extroot

8 wireless router which is connected to either a wired, a wireless or a 3G wireless connection:

    http://wiki.openwrt.org/doc/howtobuild/wireless-router-with-a-3g-dongle

9 How to Build a Single Package

    http://wiki.openwrt.org/doc/howtobuild/single.package


Developing开发


1 Cross Compile:http://wiki.openwrt.org/doc/devel/crosscompile


            外部编译器设置

                 https://forum.openwrt.org/viewtopic.php?id=32330

                 https://forum.openwrt.org/viewtopic.php?id=29804

                 https://forum.openwrt.org/viewtopic.php?id=12436

           内部编译器设置

2 Creating packages:http://wiki.openwrt.org/doc/devel/packages

3 Feeds:http://wiki.openwrt.org/doc/devel/feeds

4 Using Dependencies:http://wiki.openwrt.org/doc/devel/dependencies

5 How To Submit Patches to OpenWrt:

    https://dev.openwrt.org/wiki/SubmittingPatches

6 External Toolchain - Use OpenWrt as External Toolchain

    http://wiki.openwrt.org/doc/howto/external_toolchain

    https://lists.openwrt.org/pipermail/openwrt-devel/2009-February/003774.html

http://blog.csdn.net/openme_openwrt/article/details/8299215  OpenWrt取消strip或者重新设置strip参数的方法

http://andelf.diandian.com/post/2013-05-22/40050677370 添加新设备


http://wiki.openwrt.org/doc/devel/packages  制作包参考文档

 SECTION:=base  在opkg中的段
CATEGORY:=Network  在menuconfig中的分类
DEFAULT := y 在menuconfig中变成默认选中
PKG_RELEASE 类似arch包的尾部子版本, 参考 i2c-gpio-custom , kernel.mk  package-default.mk


PKG_CAT - How to decompress the sources (zcat, bzcat, unzip)

  • PKG_NAME - The name of the package, as seen via menuconfig and ipkg

  • PKG_VERSION - The upstream version number that we‘re downloading

  • PKG_RELEASE - The version of this package Makefile

  • PKG_LICENSE - The license(s) the package is available under, SPDX form.

  • PKG_LICENSE_FILE- file containing the license text

  • PKG_BUILD_DIR - Where to compile the package

  • PKG_SOURCE - The filename of the original sources

  • PKG_SOURCE_URL - Where to download the sources from (directory)

  • PKG_MD5SUM - A checksum to validate the download

  • PKG_CAT - How to decompress the sources (zcat, bzcat, unzip)

  • PKG_BUILD_DEPENDS - Packages that need to be built before this package, but are not required at runtime. Uses the same syntax as DEPENDS below.

  • PKG_INSTALL - Setting it to "1" will call the package‘s original "make install" with prefix set to PKG_INSTALL_DIR

  • PKG_INSTALL_DIR - Where "make install" copies the compiled files

  • PKG_FIXUP - ???


Adding configuration options

If you would like configure your package installation/compilation in the menuconfig you can do the following: Add MENU:=1 to your package definition like this:

define Package/mjpg-streamer
  SECTION:=multimedia
  CATEGORY:=Multimedia
  TITLE:=MJPG-streamer
  DEPENDS:=@!LINUX_2_4 +libpthread-stubs +jpeg
  URL:=http://mjpg-streamer.wiki.sourceforge.net/
  MENU:=1
endef

Create a config key in the Makefile:

define Package/mjpg-streamer/config
	source "$(SOURCE)/Config.in"
endef


And finally you can check your configuration parameters in your Makefile in the following way: (Note that you can reference to the parameters value with it name prefixed with CONFIG_)

ifeq ($(CONFIG_MJPEG_STREAMER_INPUT_UVC),y)
	$(CP) $(PKG_BUILD_DIR)/input_uvc.so $(1)/usr/lib
endif

内核模块 autoload

  AUTOLOAD:=$(call AutoLoad,30,loop)


define Build/InstallDev
	$(INSTALL_DIR) $(STAGING_DIR)/usr/include/madwifi
endef

http://wiki.openwrt.org/doc/devel/dependencies 依赖关系,关看

DEPENDS 中 @GPIO_SUPPORT 会在menuconfig中的depends中出现, 而其他子包+kmod-i2c-core则不会出现在里面,将会被opkg的包依赖引用


EXTRA_KCONFIG := CONFIG_SPI_GPIO_CUSTOM=m  (spi-gpio-custom 包)

EXTRA_CFLAGS

AUTOLOAD表示会自动加载,放入 /etc/modules.d/

FILES 指定模块名

PKG_BUILD_PARALLEL 并行编译

http://wiki.openwrt.org/doc/devel/feeds 添加自定义的feed的方法使用 src-link 本地link方式

src-link customfeed /home/user/openwrt/project/packages

PKG_FILE_DEPENDS 和 PKG_BUILD_DEPNEDS:=opkg/host

参考 base-files示例

本文出自 “枪炮与玫瑰的BLOG” 博客,请务必保留此出处http://axlrose.blog.51cto.com/434566/1530954