其他分享
首页 > 其他分享> > 学会使用main函数对驱动进行测试

学会使用main函数对驱动进行测试

作者:互联网

以rk3288 spi设备为例对其驱动进行测试
对kernel\drivers\spi\spidev.c文件进行测试需要用到kernel\Documentation\spi\spidev_test.c
config文件配置
CONFIG_SPI_ROCKCHIP=y
CONFIG_SPI_SPIDEV=y
添加Android.mk文件

LOCAL_PATH:=$(call my-dir)

include $(CLEAR_VARS)
LOCAL_SRC_FILES+=spidev_test.c
LOCAL_MODULE := spidev_test

include $(BUILD_EXECUTABLE)

Makefile

# kbuild trick to avoid linker error. Can be omitted if a module is built.
obj- := dummy.o

# List of programs to build
hostprogs-y := spidev_test

# Tell kbuild to always build the programs
always := $(hostprogs-y)

HOSTCFLAGS_spidev_test.o += -I$(objtree)/usr/include


mmm kernel/Document/spi/即可

int main(int argc, char *argv[])    //argc输入字符串个数  argv[] 记录输入的字符串,以空格隔开
{
                                    //argv[0] should be the module name
    sscanf(argv[1], "%x", &val);    //transform hex string to dec int
    ...
}

标签:kernel,函数,int,spidev,argv,spi,测试,test,main
来源: https://blog.csdn.net/wu472269100/article/details/121457000