ARM Linux驱动开发环境

目的:梳理ARM Linux驱动开发所需的环境和流程,记录遇到的问题。

 

环境介绍:

pc机:编写驱动程序和测试代码

服务器:编译驱动程序生成.ko文件,编译测试代码生成执行程序

单板:jz2440

 

准备工作:

linux内核:linux-2.6.22.6以及对应的补丁文件

工具链:gcc version 3.4.5

uboot:引导内核

uImage:引导根文件系统

根文件系统:运行应用程序

在进行驱动开发之前,单板上已经可以运行Linux系统,在搭建开发环境以及驱动开发的过程中,工具链的版本要保持一致。

 

为了方便将.ko文件和测试程序上传到单板的上,笔者采用NFS挂载目录的方式,简要总结一下步骤和遇到的问题。

1.服务器需要支持NFS挂载功能,如果不支持,需要手动下载:sudo apt install nfs-kernel-server

2.确定服务器支持NFS功能后,在/etc/exports中添加被挂载目录的路径:

/home/fitz/mount_bd *(rw,sync,no_subtree_check,no_root_squash)

3.重启nfs服务:sudo /etc/init.d/nfs-kernel-server restart

4.先尝试在服务器上挂载自身目录,测试nfs功能是否正常

mount -t nfs -o nolock ServerIP:目录 挂载的目录

5.在挂载服务器目录到单板linux系统之前,需要保证服务器和单板系统可以互相ping通。单板、主机、服务器有多种互联方式,强烈建议通过路由器或者交换机互联,最好不要pc通过无线上网,单板和pc通过网线直连。具体操作可参考韦东山老师视频。一句话总结:服务器上桥接的网卡与单板连接pc机的网卡要是同一网卡。

6.在单板的Linux上mount -t nfs -o nolock ServerIP:目录 挂载的目录即可挂载对应目录,以后将服务器上生成.ko和测试代码拷贝到该目录,就可以直接在单板系统上使用。

 

在实际使用的过程中会出现如下问题:

nfs: server 192.168.xx.xx not responding, still trying在加载驱动尤其是驱动比较大的时候会出现该问题。

原因:NFS默认的传输协议是UDP,而服务器和单板系统通过UDP交互时就会出现严重的网卡丢包现象。尤其是通过NFS复制较大文件的时候。

解决方案:

更改挂载命令

mount -t nfs -o nolock,rsize=4096,wsize=4096 ServerIP:目录 挂载的目录

至于背后更深层次的含义暂不作深究,问题得以解决即可。

 

至此,就可以开展ARM Linux驱动的开发工作了。

Linux Driver Development for Embedded Processors – Second Edition 版本: Learn to develop Linux embedded drivers with kernel 4.9 LTS The flexibility of Linux embedded, the availability of powerful, energy efficient processors designed for embedded computing and the low cost of new processors are encouraging many industrial companies to come up with new developments based on embedded processors. Current engineers have in their hands powerful tools for developing applications previously unimagined, but they need to understand the countless features that Linux offers today. This book will teach you how to develop device drivers for Device Tree Linux embedded systems. You will learn how to write different types of Linux drivers, as well as the appropriate APIs (Application Program Interfaces) and methods to interface with kernel and user spaces. This is a book is meant to be practical, but also provides an important theoretical base. More than twenty drivers are written and ported to three different processors. You can choose between NXP i.MX7D, Microchip SAMA5D2 and Broadcom BCM2837 processors to develop and test the drivers, whose implementation is described in detail in the practical lab sections of the book. Before you start reading, I encourage you to acquire any of these processor boards whenever you have access to some GPIOs, and at least one SPI and I2C controllers. One of the boards used to implement the drivers is the famous Raspberry PI 3 Model B board. You will learn how to develop drivers, from the simplest ones that do not interact with any external hardware, to drivers that manage different kind of devices: accelerometers, DACs, ADCs, RGB LEDs, Multi-Display LED controllers, I/O expanders, and Buttons. You will also develop DMA drivers, drivers that manage interrupts, and drivers that write/read on the internal registers of the processor to control external devices. To easy the development of some of these drivers, you will use different types of Frameworks: Miscellaneous framework, LED framework, UIO framework, Input framework and the IIO industrial one. This second edition has been updated to the v4.9 LTS kernel.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值