当前位置:网站首页>Openwrt (VIII) application layer development
Openwrt (VIII) application layer development
2022-06-25 22:29:00 【Embedded software development communication】
One 、 The application and kernel layer
Many people begin to learn embedded system only after learning MCU Linux Of , At the beginning, I couldn't understand why writing two programs can light up LED, In the past, a single-chip computer only needed to write a program to go in LED You can control it ? This is the idea of layering brought about by the operating system . In fact, we can also directly control in the drive , But this loses the meaning of the operating system .
The driver is in the kernel layer , The application is in the application layer . Relationship between them :
application ——》 drive ( Call the driver to operate the underlying hardware )
Two 、 Application instance
Examples can best explain knowledge , Our application program calls the character driver in the previous section . The following content can be used as a template in the future .
1、 stay package Create a new folder chardrv_app Folder
2、 stay chardrv_app Create a new folder Makefile file , The contents are as follows :
#
# Copyright (C) 2009-2010 Jo-Philipp Wich <[email protected]>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=chardrv_app
PKG_RELEASE:=9
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/chardrv_app
SECTION:=utils
CATEGORY:=Utilities
TITLE:=CharDrv_app
DEPENDS:=+libncurses
endef
define Package/chardrv_app/description
This package contains an character driver.
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Build/Configure
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
CC="$(TARGET_CC)" \
CFLAGS="$(TARGET_CFLAGS) -Wall" \
LDFLAGS="$(TARGET_LDFLAGS)"
endef
define Package/chardrv_app/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/chardrv_app $(1)/usr/sbin/
endef
$(eval $(call BuildPackage,chardrv_app))
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
above Makefile And driven Makefile Basically similar , It can be downloaded from package For other modules Makefile To make changes , I use the above nvram Of Makefile To modify .
3、 stay chardrv_app Create a new folder src Folder , stay src So let's make a new one Makefile file , The content is :
all: chardrv_app
OBJS = chardrv_app.o
CC = gcc
CCFLAGS = -Wall -c -o
%.o: %.c
$(CC) $(CCFLAGS) [email protected] $< $(LDFLAGS)
chardrv_app: $(OBJS)
$(CC) -o [email protected] $(OBJS) $(LDFLAGS)
clean:
rm -f rbcfg *.o
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
4、 stay src Under the new chardrv_app.c file . The contents are as follows :
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
int main(int argc , char** argv)
{
// device handle
int fd;
int num = 1;
// Open the driver module
fd = open("/dev/chardrv" , O_RDWR|O_NONBLOCK);
if(fd < 0)
{
printf("can't open /dev/chardrv\n");
return -1;
}
// Function test
write(fd,&num,1);
read(fd,&num,1);
ioctl(fd,1,1);
close(fd);
return 0;
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
5、make menuconfig Select module


6、 Execute the following statements in turn to compile
make package/chardrv_app/compile V=99
make package/chardrv_app/install V=99
make package/index V=99
The compiled file is in openwrt/bin/ramips/packages/base/ Next , file name
chardrv_app_9_ramips_24kec.ipk
7、 Put the compiled firmware on the development board , Then test according to the following picture .

3、 ... and 、 Problems and solutions
The following problems occurred while installing the app :

resolvent : Reuse make V=99 compile openwrt The firmware , Then download to the development board . The above problem is that the firmware is the previous one , It's not the latest . The drivers and applications should be compiled before the routing firmware is recompiled , Otherwise, there will be this problem .
* When compiling, if the permission is insufficient , To add sudo, So you can compile and pass .
边栏推荐
- MySQL modifies multiple tables and adds multiple fields through SQL
- 实验三的各种特效案例
- Beyond natural motion: exploring the discontinuity of video interpolation
- Dio encapsulated by the flutter network request (cookie management, adding interceptors, downloading files, exception handling, canceling requests, etc.)
- Online crudhasone Association query reports an error unabletouseinternalvariable:list
- About the version mismatch of unity resource package after importing the project
- Talk about adapter mode
- GridView component of swiftui 4 new features (tutorial includes source code)
- MySQL Chapter 15 lock
- How does idea package its own projects into jar packages
猜你喜欢

HNU计网实验:实验一 应用协议与数据包分析实验(使用Wireshark)

圖解棧幀運行過程

ASP. Net core uses function switches to control Route Access (Continued) yyds dry inventory

Win11录屏数据保存在哪里?Win11录屏数据保存的位置

Understand two major web development patterns

Obsidian basic tutorial
Pycharm 2022.1 EAP 2 release
. Thoughts on software trends in the 20th anniversary of net
Youku IPv6 evolution and Practice Guide

NARI radar's IPO meeting: it plans to raise nearly 1billion yuan. Bao Xiaojun and his wife are Canadians
随机推荐
【WPF】CAD工程图纸转WPF可直接使用的xaml代码技巧
Research Report on China's new energy technology and equipment market competition analysis and marketing strategy suggestions 2022-2028
How does idea package its own projects into jar packages
What are the debugging methods for nodejs
China soft magnetic material market demand status and prospect scale forecast report 2022-2028
Facing the "industry, University and research" gap in AI talent training, how can shengteng AI enrich the black land of industrial talents?
mysql 通过sql 修改多表增加多个字段
SwiftUI 4 新功能 之 网格视图Gridview组件 (教程含源码)
HLS. JS: past, present and future
Fujilai pharmaceutical has passed the registration: the annual revenue is nearly 500million yuan. Xiangyun once illegally traded foreign exchange
Some websites used by Beijing University of technology when graduating
What if win11 cannot delete the folder? Win11 cannot delete folder
HotSpot JVM 「01」类加载、链接和初始化
Mathematical analysis_ Notes_ Chapter 4: continuous function classes and other function classes
目前期货怎么开户安全些?哪些期货公司靠谱些?
在线CRUDhasone关联查询报错Unabletouseinternalvariable:List
[动态规划]最长回文子串-对于动态转移循环顺序的思考
How to use Matplotlib library to realize enlarged display of graphic local data
No nonsense, code practice will help you master strong caching and negotiation caching!
When we talk about the metauniverse, what are we talking about?