1. 板子f403tech的RT5350的板子和
(1)openWRT系统的定义和特点
OpenWrt是一个高度模块化、高度自动化的嵌入式Linux系统,拥有强大的网络组件,常常被
用于工控设备、电话、小型机器人、智能家居、路由器以及VOIP设备中。
OpenWrt支持各种处理器架构,无论是对ARM,X86,PowerPC或者MIPS都有很好的支持。
其多达3000多种软件包,囊括从工具链(toolchain),到内核(linux kernel),到软件包
(packages),再到根文件系统(rootfs)整个体系,使得用户只需简单的一个make命令即可方便快
速地定制一个具有特定功能的嵌入式系统来制作固件。 其模块化设计也可以方便的移植各类功能
到OpenWrt下,加快开发速度。
2 实验mjpeg-streamer、uvc视频监控
3 openwrt的下载安装
<pre name="code" class="cpp">sudo apt-get install subversion
sudo apt-get install git-core
sudo apt-get install gcc g++ binutils patch bzip2 flex bison make autoconf gettext texinfo unzip sharutils zlib1g-dev libncurses5-dev gawk
mkdir openwrt
cd openwrt/
svn co svn://svn.openwrt.org/openwrt/trunk
cd trunk/
./scripts/feeds update -a
./scripts/feeds install -a
(4) 配置编译openWRT系统
a、选择CPU型号
TargetSystem —> RalinkRT288x/RT3xxx
b、选择CPU子型号
Subtarget —> RT3x5x/RT5350basedboards
c、选择具体路由器型号
Targetprofile—>HAME-MPR-A2
(5) 编译
make V=99
至此,完成内核和文件系统镜像编译
4 驱动开发流程
进入/home/openwrt/trunk/package/kernel驱动目录,仿照参考其他的驱动。
新建example文件夹,进入example文件夹。
创建Makefile:
#
# Copyright (C) 2008-2012 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
# modify by 2014-10-23
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=example
PKG_RELEASE:=1
include $(INCLUDE_DIR)/package.mk
define KernelPackage/example
SUBMENU:=Other modules
# DEPENDS:=@!LINUX_3_3
TITLE:=Simple example driver
FILES:=$(PKG_BUILD_DIR)/example.ko
# AUTOLOAD:=$(call AutoLoad,30,gpio-button-hotplug,1)
KCONFIG:=
endef
define KernelPackage/example/description
This is a example for the following in-kernel drivers:
1) example one
2) example two
endef
MAKE_OPTS:= \
ARCH="$(LINUX_KARCH)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
SUBDIRS="$(PKG_BUILD_DIR)"
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Build/Compile
$(MAKE) -C "$(LINUX_DIR)" \
$(MAKE_OPTS) \
modules
endef
$(eval $(call KernelPackage,example))
新建srce文件夹,进入src文件夹。
创建Makefile:
obj-m += example.o
创建example.c源文件
#include <linux/module.h>
#include <linux/version.h>
#include <linux/kmod.h>
static int __init example_init(void)
{
printk("hello example openwrt\n");
return 0;
}
static void __exit example_exit(void)
{
printk("hello example openwrt exit\n");
}
module_init(example_init);
module_exit(example_exit);
MODULE_AUTHOR("zhaochuang8888@126.com");
MODULE_DESCRIPTION("example driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:" DRV_NAME);
c.编译驱动的命令
make package/kernel/example/compile V=99
<pre name="code" class="cpp"><pre name="code" class="cpp">在/home/openwrt/trunk/bin/ramips/packages/base目录生成:kmod-example_3.14.18-1_ramips_24kec.ipk
5 应用开发流程
进入/home/openwrt/trunk/package应用目录。参考其他的应用文件。
创建helloworld文件夹,并进入。
创建Makefile:
##############################################
# OpenWrt Makefile for helloworld program
#
#
# Most of the variables used here are defined in
# the include directives below. We just need to
# specify a basic description of the package,
# where to build our prog