记录Openwrt产品定制开发过程,(三) 开发定制(openwrt 界面定制)

前置章节:

(一)环境配置和目录结构

(二) Make过程

===========================

make过程是Openwrt开发中比较磨人的阶段,一旦编译通过调顺畅了,整个系统用起来就爽了。:)

===========================

1 开发定制

OpenWrt提供定制独立APP(即:ipk)以及定制内建于firmware APP的机制。

同时,OpenWrt自己也集成了大量的应用,可以通过简单的menuconfig方式集成进firmware中。

1.1 使用系统配置

对于OpenWrt系统已经完成集成的各个应用,可以通过Make menuconfig来定制加入firmware中。对此方法我们在“1.4.3定制编译”章节中有说明。

1.2 定制支持3G数据卡配置

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

1.2.1 usb networking support

Go to Kernel Modules → USB Support.Select the following modules by pressing y to include the modules within the compiled image.Kernel Modules -> USB Support<*> kmod-usb2<*> kmod-usb-ohci<*> kmod-usb-uhci<*> kmod-usb-acm # For ACM based modem, such as Nokia Phones<*> kmod-usb-net # For tethering and rndis supportkmod-usb-net –> to support usb networking interface. Select all subsets if you want perfect support for usb network interfaces, including Android and iPhone tethering. Some newer 4g dongles use usb network interface (rndis) instead of legacy serial protocol.<*> kmod-usb-net…………… Kernel modules for USB-to-Ethernet convertors <*> kmod-usb-net-asix…… Kernel module for USB-to-Ethernet Asix convertors <*> kmod-usb-net-cdc-eem………………… Support for CDC EEM connections -*- kmod-usb-net-cdc-ether………….. Support for cdc ethernet connections <*> kmod-usb-net-cdc-mbim………………… Kernel module for MBIM Devices -*- kmod-usb-net-cdc-ncm………………… Support for CDC NCM connections <*> kmod-usb-net-cdc-subset…… Support for CDC Ethernet subset connections <*> kmod-usb-net-dm9601-ether…….. Support for DM9601 ethernet connections <*> kmod-usb-net-hso.. Kernel module for Option USB High Speed Mobile Devices <*> kmod-usb-net-ipheth………………… Apple iPhone USB Ethernet driver <*> kmod-usb-net-kalmia………………. Samsung Kalmia based LTE USB modem <*> kmod-usb-net-kaweth.. Kernel module for USB-to-Ethernet Kaweth convertors <*> kmod-usb-net-mcs7830 <*> kmod-usb-net-pegasus <*> kmod-usb-net-qmi-wwan……………………………… QMI WWAN driver <*> kmod-usb-net-rndis……………………. Support for RNDIS connections <*> kmod-usb-net-sierrawireless………. Support for Sierra Wireless devices <*> kmod-usb-net-smsc95xx. SMSC LAN95XX based USB 2.0 10/100 ethernet devices kmod-usb-serial → to support legacy 3g dongles. Select all subsets to ensure that your dongle works. Most 3g dongles use the option driver or generic serial driver to work. Note that option driver has better capability of distinguishing between modem serial interfaces and storage interface than generic usb serial driver.<*> kmod-usb-serial………………… Support for USB-to-Serial converters <*> kmod-usb-serial-ark3116…….. Support for ArkMicroChips ARK3116 devices <*> kmod-usb-serial-belkin…………………… Support for Belkin devices <*> kmod-usb-serial-ch341…………………….. Support for CH341 devices <*> kmod-usb-serial-cp210x……….. Support for Silicon Labs cp210x devices <*> kmod-usb-serial-cypress-m8………….. Support for CypressM8 USB-Serial <*> kmod-usb-serial-ftdi………………………. Support for FTDI devices <*> kmod-usb-serial-ipw……………….. Support for IPWireless 3G devices <*> kmod-usb-serial-keyspan…….. Support for Keyspan USB-to-Serial devices <*> kmod-usb-serial-mct………….. Support for Magic Control Tech. devices <*> kmod-usb-serial-mos7720………….. Support for Moschip MOS7720 devices <*> kmod-usb-serial-motorola-phone………… Support for Motorola usb phone <*> kmod-usb-serial-option………………. Support for Option HSDPA modems <*> kmod-usb-serial-oti6858…… Support for Ours Technology OTI6858 devices <*> kmod-usb-serial-pl2303…………… Support for Prolific PL2303 devices <*> kmod-usb-serial-qualcomm…………….. Support for Qualcomm USB serial <*> kmod-usb-serial-sierrawireless……. Support for Sierra Wireless devices <*> kmod-usb-serial-ti-usb…………………. Support for TI USB 3410/5052 <*> kmod-usb-serial-visor…………… Support for Handspring Visor devices -*- kmod-usb-serial-wwan………………… Support for GSM and CDMA modems

1.2.2 Additional packages required for 3g functionality

Go to Network section. Select `uqmi` to support qmi interface and `ppp` to support standard point-to-point protocol.

Network

<*>chat <*>ppp <*>uqmi有一些数据卡支持<*>umbim,需要添加。

Go to Utilities section. Select comgt to provide control over 3g interface and usb-modeswitch to provide mode switching between virtual cd-rom interface to serial interface.

Utilities <*>comgt <*>usb-modeswitch

1.2.3 Web Interface Support

LuC接口是可选的,如果要想使用,同时又有足够的空间可以打开配置开关。

Luci1. Collections <*> luci3. Applications <*> luci-app-multiwan (optional to support multiple 3g dongles)6. Protocols <*> luci-proto-3g -*- luci-proto-ppp

1.3 定制系统配置进行开发

在已有系统的基础上定制组件,以为nginx添加rtmp-module为例。

1.3.1 查找feed配置

$./script/feed update -a$./script/feed install –a$cd ./openwrt/feeds/

Packages.index中定义了各个预置的包和它们的配置信息。找到你想要定制的nginx。从以下行可以得到配置文件位置:

Config: source \”feeds/packages/net/nginx/Config.in\”

1.3.2 修改feedàConfig.in配置

然后找到配置文件Config.in。该配置文件直接被menuconfig使用,配置以后就可以直接在make menuconfig中进行配置了。

$cd ./openwrt/feeds/packages/net/nginx$vi Config.in

在配置项的最后一行添加nginx_rtmp入口:

config NGINX_RTMP bool prompt \”Enable RTMP module\” default n

1.3.3 修改feedàMakefile配置

$vi Makefile

在以下节中添加内容:

1.3.3.1 添加包依赖

PKG_CONFIG_DEPENDS := 中添加 CONFIG_NGINX_RTMP

1.3.3.2 添加模块make选项

ADDITIONAL_MODULES:= 中添加

ifneq ($(CONFIG_NGINX_RTMP),y) ADDITIONAL_MODULES = –add-module=$(PKG_BUILD_DIR)/nginx-rtmp/Endif

1.3.3.3 添加主模块编译/准备/下载选项

define Package/nginx/install。。。。define Build/Prepare $(call Build/Prepare/Default) $(if $(CONFIG_NGINX_NAXSI),$(call Prepare/nginx-naxsi)) $(if $(CONFIG_NGINX_LUA),$(call Prepare/lua-nginx)) $(if $(CONFIG_NGINX_RTMP),$(call Prepare/nginx-rtmp))endef

1.3.3.4 添加子模块编译/准备/下载选项

最后添加下载、包解压配置项:

define Download/nginx-rtmp VERSION:=e08959247dc840bb42cdf3389b1f5edb5686825f SUBDIR:=nginx-rtmp FILE:=nginx-rtmp-module-$(PKG_VERSION)-$$(VERSION).tar.gz URL:=https://github.com/arut/nginx-rtmp-module.git PROTO:=gitendef define Prepare/nginx-rtmp $(eval $(call Download,nginx-rtmp)) gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)endef

1.3.4 修改ROM配置

如果修改了配置导致ROM太大无法生成最终bin文件,可以修改ROM大小。

$ cd target/linux/

找到自己的路由器入口,以我的RT3x5x/RT5350为例,这个入口是 ramips/image。

修改其中的Makefile文件:

ralink_default_fw_size_8M=8060928

将其中的8M改到合适的尺寸。

1.3.5 编译

$make V=99 –j5

1.4 SDK开发环境

对于自己定制的package(应用),而这个package又不需要随固件一起安装,也就是当做一个可选软件包来使用。这可以利用SDK环境来单独编译(避免每次都重新编译系统),编译后会在bin/[yourtarget]/package目录中生成一个ipk的文件包。然后利用 opkg install xxx.ipk 来安装这个软件。

打开SDK开发环境,可以通过make menuconfig添加编译选项SDK,在bin目录中会生成当前配置的SDK.bz2压缩文件,解压这个文件就可以得到个人定制开发的环境。

OpenWrt对此的说明如下:This is the OpenWrt SDK. It contains a stripped-down version of the buildroot. You can use it to test/develop packages without having to compile your own toolchain or any of the libraries included with OpenWrt.

To use it, just put your buildroot-compatible package directory in the subdir \’package/\’ and run \’make\’ from this directory.

1.4.1 解压SDK

$ tar xvf OpenWrt-SDK-ramips-rt305x_64.tar.bz2$ cd OpenWrt-SDK-ramips-rt305x_64

目录结构如下。

记录Openwrt产品定制开发过程,(三) 开发定制(openwrt 界面定制)

1.4.2 建立定制工作目录

按照规则在package目录下建立自己的定制模块的工作目录。

$ cd package$ mkdir myhello$ cd myhello$ mkdir src

1.4.3 准备Makefile文件

需要准备两个Makfile文件,一个在package/myapp/目录下;一个在package/myapp/src/目录下。

  1. package/myapp/Makefile
  2. package/myapp/src/Makefile

# build helloworld executable when user executes “make” SRC:=myhello.c myhello: $(SRC) $(CC) $(SRC) -o myhello # remove object files and executable when user executes \”make clean\” clean: rm *.o

1.4.4 编译代码

  1. 返回到SDK的根目录
  2. 执行make进行编译

编译过程会在build_dir目录下完成,在目录build_dirtarget-mips_34kc_uClibc-0.9.33.2testipkg-ar71xx中生成可执行文件编译结果*.ipk会放在 bin/[yourtarget]/package目录下。

1.4.5 应用myAppxx.ipk

上传myAppxx.ipk至路由器,执行 opkg install myAppxx.ipk.

输入myhello可执行命令,并查看程序结果。

=====结束======

Openwrt是组织的很好的一套系统,社区也很成熟,玩熟了可以节省你很多做板的时间!

下面show一下,我的另一块开发板。 :)

记录Openwrt产品定制开发过程,(三) 开发定制(openwrt 界面定制)

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

(0)
上一篇 2023年5月5日 上午8:43
下一篇 2023年5月5日 上午8:53

相关推荐