当前位置: 首页 > 技术文章 > 正文

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-0.9.33.2/linux-ar71xx_generic/linux-3.18.7
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-0.9.33.2/bin/mips-openwrt-linux-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;

to


DEFINE_SPINLOCK(driver_lock);

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.


#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31)
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; }
#endif

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.

报歉!评论已关闭.