openwrt-安装-驱动-应用-lcd2004a实验

本文介绍了OpenWrt系统,它是一个高度模块化、自动化的嵌入式Linux系统,常用于工控设备和路由器等。内容包括RT5350板子的OpenWrt安装,以及使用mjpeg-streamer进行UVC视频监控的实验。此外,还涵盖了OpenWrt的下载和安装过程。
摘要由CSDN通过智能技术生成

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值