Porting ART Driver to OpenWRT

OpenWRT is a popular wireless router OS, and ART (Atheros Radio Test) is a radio test tool provided by Qualcomm Atheros. If anyone want to test radio performance in OpenWRT OS, one thing has to to be done is that porting ART driver to OpenWRT. A friend of mine was looking for OpenWRT ART driver and I spent a lot of time on porting it. Fortunately, I finally succeeded and I like to share it with the readers of my blog in this post.

By the way, my English is not very good, if there is any mistake, please correct me.

Step 1, modify makefile.artmod to match with the specified kernel path and toolchain path.

KDIR := /home/tom/openwrt/trunk/build_dir/target-mips_34kc_uClibc-  
PWD := $(shell pwd)   
ROOTDIR := $(PWD)/modules  
# Default architecture is MIPS  
ARC :=mips  CROSS_CC :=/home/tom/openwrt/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-

Step 2, by not making any code changes, starting compile and I got the error below.

error: unknown field ‘ioctl’ specified in initialize

I have encountered similar problem during porting ART driver for Freescale i.MX6 processor. Change ioctl into compat_ioctl of dk_fops structure located in modules/dk_func.c, compile again and there are no errors about ioctl.

Step 3, a new error as below.

error: ‘SPIN_LOCK_UNLOCKED’ undeclared here (not in a function)

Modify related code from

spinlock_t driver_lock = SPIN_LOCK_UNLOCKED;



Step 4, compile the source code once again and art.ko kernel module is avilable in modules directory.

Step 5, upload art.ko to a web server and download it into DUT by wget command.

Step 6, load DUT by artgui, error is reported in console window as below.

deviceInit devIndex=0 device_fn=0 pdkInfo=0  
Opening device /dev/dk0  
Error: get version ioctl failed !  
< 6006 ERROR Anwi driver load error.  
< 7502 CONTROL OFF  
< 7504 INFO |set|devid||  
< 7504 INFO |set|mac||  
< 7504 INFO |set|customer||  
< 7506 CONTROL DONE load devid=-1; caldata=auto;

the screenshot is attached below


Step 7, dk_fop structure is defined as below in higher ART version.

static long dk_ioctl_new(struct file *file, unsigned int cmd, unsigned long arg) 
{ struct inode *inode = file->f_path.dentry->d_inode; 
long ret; 
ret = dk_ioctl(inode, file, cmd, arg); return ret; } 

A new ioctl is defined and it takes effect when kernel version is above 2.6.31.

Step 8, modify dk_fops structure defined in lower ART version as below.

static long dk_ioctl_new(struct file *file, unsigned int cmd, unsigned long arg) { 
struct inode *inode = file->f_path.dentry->d_inode; 
long ret; 
ret = dk_ioctl(inode, file, cmd, arg); return ret; 

static struct file_operations dk_fops = { 
owner: THIS_MODULE, 
open: dk_open, 
release: dk_release, 
mmap: dk_mmap, 
unlocked_ioctl: dk_ioctl_new };

Step 9, compile again and download art.ko into DUT, using artgui to load DUT and thers is no error in console window as below.


本文章由作者:佐须之男 整理编辑,原文地址: Porting ART Driver to OpenWRT
本站的文章和资源来自互联网或者站长的原创,按照 CC BY -NC -SA 3.0 CN协议发布和共享,转载或引用本站文章应遵循相同协议。如果有侵犯版权的资 源请尽快联系站长,我们会在24h内删除有争议的资源。欢迎大家多多交流,期待共同学习进步。