linux3.13.0内核编译驱动的问题

周靖峰 2015-08-03 10:34:07
我想要在linux3.13.0上编译一个驱动

我先写好源文件,再写好makefile,但是编译的时候出现
  ERROR: Kernel configuration is invalid.
include/generated/autoconf.h or include/config/auto.conf are missing.
Run 'make oldconfig && make prepare' on kernel src to fix it.


WARNING: Symbol version dump /home/zjf/zjf/kernel/linux-source-3.13.0/Module.symvers
is missing; modules will have no dependencies and modversions.


然后我去内核目录执行了make menuconfig和make prepare
但是在执行make prepare的时候却报错了,错误提示如下:
zjf@zjf-ubuntu:~/zjf/kernel/linux-source-3.13.0$ make prepare
HOSTLD scripts/kconfig/conf
scripts/kconfig/conf --silentoldconfig Kconfig
SYSHDR arch/x86/syscalls/../include/generated/uapi/asm/unistd_32.h
SYSHDR arch/x86/syscalls/../include/generated/uapi/asm/unistd_64.h
SYSHDR arch/x86/syscalls/../include/generated/uapi/asm/unistd_x32.h
SYSTBL arch/x86/syscalls/../include/generated/asm/syscalls_32.h
HOSTCC arch/x86/tools/relocs_32.o
HOSTCC arch/x86/tools/relocs_64.o
HOSTCC arch/x86/tools/relocs_common.o
HOSTLD arch/x86/tools/relocs
CHK include/config/kernel.release
UPD include/config/kernel.release
WRAP arch/x86/include/generated/asm/clkdev.h
CHK include/generated/uapi/linux/version.h
UPD include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
UPD include/generated/utsrelease.h
CC kernel/bounds.s
GEN include/generated/bounds.h
CC arch/x86/kernel/asm-offsets.s
In file included from include/linux/suspend.h:8:0,
from arch/x86/kernel/asm-offsets.c:12:
include/linux/mm.h:647:2: error: #error SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > BITS_PER_LONG - NR_PAGEFLAGS
#error SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > BITS_PER_LONG - NR_PAGEFLAGS
^
make[1]: *** [arch/x86/kernel/asm-offsets.s] 错误 1
make: *** [prepare0] 错误 2


请问这是什么错误?应该如何解决这个错误?
...全文
467 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
dirtyrain1990 2015-08-28
  • 打赏
  • 举报
回复
首先应该检查一下是否是你驱动模块的问题,即不添加这个驱动模块是否能够正常编译,所谓的“make oldconfig”等仅仅类似于“按照上一次正常的操作,进行这次操作”,在之前已经报错缺少自动配置文件,所以你在执行此命令也照样会报错。 1.如果是本来编译就缺少autoconf.h\auto.conf的话,建议你去网上这个内核版本里下载一个,因为这个是内核里自带的 2.文件不缺少仍编译失败,使用root权限进行操作,可能是权限问题 3.驱动模块加载后失败,应该是驱动文件配置问题,即与驱动文件关联的Kconfig或者Kconfig.driver等没有进行宏定义
bpi_a64_android初步编译为LCD显示20170309_1442.7z banana pi a64 android6.0.1初步编译为LCD显示。初步设置。 bpi_a64_android的编译配置文件排版.txt 2017/3/9 14:33 0、压缩包的处理: rootroot@cm-System-Product-Name:/home/wwt/a64$ tar zxvf BPI-A64-Android_SourceCode.tar.gz 增加3个编译链 Notice: Please download this file to the correct path https://drive.google.com/open?id=0B_YnvHgh2rwjaVRrc2VoR0xLTlE (1)gcc-linaro-aarch64.tar.xz ==> /lichee/buildroot/dl (2)gcc-linaro-aarch64.tar.xz ==> /lichee/brandy/toolchain (3)gcc-linaro-arm.tar.xz ==> /lichee/brandy/toolchain 重新分块压缩: rootroot@cm-System-Product-Name:/home/wwt/a64$ tar zcvf - bpi_a64_android/ | split -b 3900000000 - bpi_a64_android_wyb_patch1.tar.gz 1、编译lichee内核 rootroot@cm-System-Product-Name:/home/wwt/a64$ rootroot@cm-System-Product-Name:/home/wwt/a64$ cd bpi_a64_android/ rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android$ rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android$ cd lichee/ rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/lichee$ ./build.sh config Welcome to mkscript setup progress All available chips: 0. sun50iw1p1 Choice: 0 All available platforms: 0. android 1. dragonboard 2. linux 3. camdroid 4. secureandroid Choice: 0 All available kernel: 0. linux-3.10 1. linux-3.4 Choice: 0 All available boards: 0. bpi-m64-hdmi 1. bpi-m64-lcd Choice: 1 rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/lichee$ ./build.sh Copy boot.img to output directory ... Copy modules to target ... sun50iw1p1 compile Kernel successful INFO: build kernel OK. INFO: build rootfs ... INFO: skip make rootfs for android INFO: build rootfs OK. INFO: ---------------------------------------- INFO: build lichee OK. INFO: ---------------------------------------- rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/lichee$ rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/lichee$ 2、编译Android rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/lichee$ cd ../android/ rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/android$ source build/envsetup.sh including device/asus/deb/vendorsetup.sh including device/asus/flo/vendorsetup.sh including device/asus/fugu/vendorsetup.sh including device/generic/mini-emulator-arm64/vendorsetup.sh including device/generic/mini-emulator-armv7-a-neon/vendorsetup.sh including device/generic/mini-emulator-mips/vendorsetup.sh including device/generic/mini-emulator-x86_64/vendorsetup.sh including device/generic/mini-emulator-x86/vendorsetup.sh including device/htc/flounder/vendorsetup.sh including device/lge/hammerhead/vendorsetup.sh including device/moto/shamu/vendorsetup.sh including device/softwinner/bpi-m64-hdmi/vendorsetup.sh including device/softwinner/bpi-m64-lcd/vendorsetup.sh including device/softwinner/common/vendorsetup.sh including sdk/bash_completion/adb.bash rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/android$ lunch You're building on Linux Lunch menu... pick a combo: 1. aosp_arm-eng 2. aosp_arm64-eng 3. aosp_mips-eng 4. aosp_mips64-eng 5. aosp_x86-eng 6. aosp_x86_64-eng 7. aosp_deb-userdebug 8. aosp_flo-userdebug 9. full_fugu-userdebug 10. aosp_fugu-userdebug 11. mini_emulator_arm64-userdebug 12. m_e_arm-userdebug 13. mini_emulator_mips-userdebug 14. mini_emulator_x86_64-userdebug 15. mini_emulator_x86-userdebug 16. aosp_flounder-userdebug 17. aosp_hammerhead-userdebug 18. aosp_hammerhead_fp-userdebug 19. aosp_shamu-userdebug 20. bpi_m64_hdmi-eng 21. bpi_m64_hdmi-user 22. bpi_m64_hdmi-userdebug 23. bpi_m64_lcd-eng 24. bpi_m64_lcd-user 25. bpi_m64_lcd-userdebug Which would you like? [aosp_arm-eng] 23 ============================================ PLATFORM_VERSION_CODENAME=REL PLATFORM_VERSION=6.0.1 TARGET_PRODUCT=bpi_m64_lcd TARGET_BUILD_VARIANT=eng TARGET_BUILD_TYPE=release TARGET_BUILD_APPS= TARGET_ARCH=arm64 TARGET_ARCH_VARIANT=armv8-a TARGET_CPU_VARIANT=generic TARGET_2ND_ARCH=arm TARGET_2ND_ARCH_VARIANT=armv7-a-neon TARGET_2ND_CPU_VARIANT=cortex-a15 HOST_ARCH=x86_64 HOST_OS=linux HOST_OS_EXTRA=Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty HOST_BUILD_TYPE=release BUILD_ID=MMB29M OUT_DIR=out ============================================ rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/android$ extract-bsp /home/wwt/a64/bpi_a64_android/android/device/softwinner/bpi-m64-lcd/bImage copied! /home/wwt/a64/bpi_a64_android/android/device/softwinner/bpi-m64-lcd/modules copied! rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/android$ make -j12 Creating filesystem with parameters: Size: 2147483648 Block size: 4096 Blocks per group: 32768 Inodes per group: 8192 Inode size: 256 Journal blocks: 8192 Label: system Blocks: 524288 Block groups: 16 Reserved block group size: 127 Created filesystem with 2422/131072 inodes and 260574/524288 blocks Install system fs image: out/target/product/bpi-m64-lcd/system.img out/target/product/bpi-m64-lcd/system.img+out/target/product/bpi-m64-lcd/obj/PACKAGING/recovery_patch_intermediates/recovery_from_boot.p maxsize=2192446080 blocksize=4224 total=1034077436 reserve=22146432 #### make completed successfully (57:57 (mm:ss)) #### rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/android$ rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/android$ 3、打包img镜像 rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/android$ rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/android$ pack -d /home/wwt/a64/bpi_a64_android/lichee/tools/pack/sun50iw1p1_android_bpi-m64-lcd_card0.img pack finish rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/android$ rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/android$ rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/android$ pack /home/wwt/a64/bpi_a64_android/lichee/tools/pack/sun50iw1p1_android_bpi-m64-lcd_uart0.img pack finish rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/android$ 4、编译uboot(可选) rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/lichee/brandy$ ./build.sh -p sun50iw1p1 CC external/openssl_ext.c ... make -C /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/sunxi_spl/sbrom/spl/ CC /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/arch/arm/cpu/armv7/sun50iw1p1/spl/ss_spl.c ... CC /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/arch/arm/cpu/armv7/sun50iw1p1/spl/spc_spl.c ... CC /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/arch/arm/cpu/armv7/sun50iw1p1/spl/smc_spl.c ... CC /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/arch/arm/cpu/armv7/sun50iw1p1/spl/gic_spl.c ... CC /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/arch/arm/cpu/armv7/sun50iw1p1/spl/debug.c ... CC /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/arch/arm/cpu/armv7/sun50iw1p1/spl/ctype.c ... CC /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/arch/arm/cpu/armv7/sun50iw1p1/spl/eabi_compat.c ... CC /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/arch/arm/cpu/armv7/sun50iw1p1/spl/efuse_spl.c ... make -C /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/sunxi_spl/spl/lib/ make[3]: 没有什么可以做的为 `all'。 /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/../gcc-linaro/bin/arm-linux-gnueabi-gcc -E -include /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/include/u-boot/u-boot.lds.h -DSBROMSWADDR="(0x10480)" -ansi -D__ASSEMBLY__ -P - /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/sunxi_spl/sbrom/sboot.lds /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/../gcc-linaro/bin/arm-linux-gnueabi-ld /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/arch/arm/cpu/armv7/sun50iw1p1/dram/libchipid.o /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/arch/arm/cpu/armv7/sun50iw1p1/dram/libdram.o /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/arch/arm/cpu/armv7/sun50iw1p1/mmc/libmmc.o /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/arch/arm/cpu/armv7/sun50iw1p1/nand/libnand.o /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/sunxi_spl/sbrom/flash/libflash.o /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/sunxi_spl/sbrom/libs/libgeneric.o /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/sunxi_spl/sbrom/load/libload.o /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/sunxi_spl/sbrom/main/libmain.o /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/sunxi_spl/sbrom/openssl/libopenssl.o /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/sunxi_spl/sbrom/spl/libsource_spl.o /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/sunxi_spl/spl/lib/libgeneric.o -L /home/wwt/a64/bpi_a64_android/lichee/brandy/gcc-linaro/bin/../lib/gcc/arm-linux-gnueabi/4.6.3 -lgcc -T/home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/sunxi_spl/sbrom/sboot.lds -o sboot.axf -Map sboot.map /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/../gcc-linaro/bin/arm-linux-gnueabi-objcopy -O binary /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/sunxi_spl/sbrom/sboot.axf /home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/sunxi_spl/sbrom/sboot.bin "sboot_sun50iw1p1.bin" -> "/home/wwt/a64/bpi_a64_android/lichee/brandy/u-boot-2014.07/../../tools/pack/chips/sun50iw1p1/bin/sboot_sun50iw1p1.bin" rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/lichee/brandy$ rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/lichee/brandy$ 5、配置menuconfig(裁剪内核) rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/lichee$ ./build.sh config Welcome to mkscript setup progress All available chips: 0. sun50iw1p1 Choice: 0 All available platforms: 0. android 1. dragonboard 2. linux 3. camdroid 4. secureandroid Choice: 0 All available kernel: 0. linux-3.10 1. linux-3.4 Choice: 0 All available boards: 0. bpi-m64-hdmi 1. bpi-m64-lcd Choice: 1 rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/lichee$ cd linux-3.10/ rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/lichee/linux-3.10$ cp .config bak1_orig.config rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/lichee/linux-3.10$ rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/lichee/linux-3.10$ rootroot@cm-System-Product-Name:/home/wwt/a64/bpi_a64_android/lichee/linux-3.10$ make ARCH=arm64 menuconfig (1)改大打印缓存 General setup ---> (17) Kernel log buffer size (16 => 64KB, 17 => 128KB) 修改为: (18) Kernel log buffer size (16 => 64KB, 17 => 128KB) (2)只保留博通/正基的WIFI/BT:AP6212等 Device Drivers ---> [*] Network device support ---> [*] Wireless LAN ---> Broadcom FullMAC wireless cards support (/system/vendor/modules/fw_bcmdhd.bin) Firmware path (/system/vendor/modules/nvram.txt) NVRAM path Enable Chip Interface (SDIO bus interface support) ---> Interrupt type (Out-of-Band Interrupt) ---> Realtek 8723B SDIO or SPI WiFi Realtek 8723BS_VQ0 WiFi Realtek 8189F SDIO WiFi 修改为: < > Realtek 8723B SDIO or SPI WiFi < > Realtek 8723BS_VQ0 WiFi < > Realtek 8189F SDIO WiFi (3)关闭SELinux安全内核方便调试 Security options ---> [*] NSA SELinux Support [*] NSA SELinux boot parameter (1) NSA SELinux boot parameter default value [ ] NSA SELinux runtime disable [*] NSA SELinux Development Support [*] NSA SELinux AVC Statistics (1) NSA SELinux checkreqprot default value [ ] NSA SELinux maximum supported policy format version 修改为: [ ] NSA SELinux Support (4)在内核中增加USB摄像头/打开UVC的驱动 Device Drivers ---> <*> Multimedia support ---> [ ] Media USB Adapters ---> 修改为: [*] Media USB Adapters ---> --- Media USB Adapters *** Webcam devices *** < > USB Video Class (UVC) 修改为: USB Video Class (UVC) [*] UVC input events device support (NEW)
pcf8563_i2c1_r8_ruoge_ov2640通过给RTC驱动增加设备节点读取秒钟成功+直接读取I2C1获取秒钟值20160626_2201.7z http://blog.csdn.net/21cnbao/article/details/7919055 在Android源码树中添加userspace I2C读写工具(i2c-util) 本文使用的开发板是:杭州若格科技有限公司的全志R8。CPU:CPUARM Cortex-A8 更多芯片资料请参见全志官网: http://www.allwinnertech.com/clq/r/R8.html 通过/dev/i2c-n节点,用户可以在userspace直接访问板上的i2c外设寄存器,主要是透过I2C_RDWR这个IO控制命令将i2c_msg数组传递给kernel去执行。 开发板的/dev/i2c-1总线下挂有一片I2C的RTC:pcf8563。 root@android:/dev # cd /sys/class/i2c-adapter/ root@android:/sys/class/i2c-adapter # ll lrwxrwxrwx root root 1970-01-02 08:31 i2c-0 -> ../../devices/platform/sun5i-i2c.0/i2c-0 lrwxrwxrwx root root 1970-01-02 08:31 i2c-1 -> ../../devices/platform/sun5i-i2c.1/i2c-1 lrwxrwxrwx root root 1970-01-02 08:31 i2c-2 -> ../../devices/platform/sun5i-i2c.2/i2c-2 root@android:/sys/class/i2c-adapter # cd i2c-1 root@android:/sys/class/i2c-adapter/i2c-1 # ll drwxr-xr-x root root 1970-01-02 08:31 1-0051 --w------- root root 4096 1970-01-02 08:31 delete_device lrwxrwxrwx root root 1970-01-02 08:31 device -> ../../sun5i-i2c.1 drwxr-xr-x root root 1970-01-01 08:00 i2c-dev -r--r--r-- root root 4096 1970-01-02 08:31 name --w------- root root 4096 1970-01-02 08:31 new_device drwxr-xr-x root root 1970-01-01 08:00 power lrwxrwxrwx root root 1970-01-02 08:31 subsystem -> ../../../../bus/i2c -rw-r--r-- root root 4096 1970-01-01 08:00 uevent root@android:/sys/class/i2c-adapter/i2c-1 # root@android:/sys/class/i2c-adapter/i2c-1 # cd 1-0051/ root@android:/sys/class/i2c-adapter/i2c-1/1-0051 # ll lrwxrwxrwx root root 1970-01-02 10:18 driver -> ../../../../../bus/i2c/drivers/pcf8563 -r--r--r-- root root 4096 1970-01-02 10:18 modalias -r--r--r-- root root 4096 1970-01-02 10:18 name drwxr-xr-x root root 1970-01-02 10:18 power drwxr-xr-x root root 1970-01-02 10:18 rtc lrwxrwxrwx root root 1970-01-02 10:18 subsystem -> ../../../../../bus/i2c -rw-r--r-- root root 4096 1970-01-02 10:18 uevent root@android:/sys/class/i2c-adapter/i2c-1/1-0051 # cat name pcf8563 root@android:/sys/class/i2c-adapter/i2c-1/1-0051 # 注释:1-0051 1 表示 i2c-1这条I2C1总线上挂载的设备,如果是I2C2总线上挂载的设备,路径就是2-00XX了。 0051 一般的I2C设备的从机地址都是一个字节的,因为前两位为0x00(16进制的),后两位为pcf8563移位自后的I2C从机地址0x51(也是16进制的) 压缩包中的PCF8563-CN.pdf,datasheet告诉我们:I2C总线从地址:读,0A3H;写,0A2H。右移一位之后正好是0x51。 下面的代码可以完成这个功能: #include #include #include #include #include #include #include #include #include #include #include /* This is the structure as used in the I2C_RDWR ioctl call */ struct i2c_rdwr_ioctl_data { struct i2c_msg __user *msgs; /* pointers to i2c_msgs */ __u32 nmsgs; /* number of i2c_msgs */ }; int i2c_read_reg(char *dev, unsigned char *buf, unsigned slave_address, unsigned reg_address, int len) { struct i2c_rdwr_ioctl_data work_queue; unsigned char w_val = reg_address; int ret; int fd = open(dev, O_RDWR); if (!fd) { printf("Error on opening the device file\n"); return 0; } work_queue.nmsgs = 2; work_queue.msgs = (struct i2c_msg*)malloc(work_queue.nmsgs *sizeof(struct i2c_msg)); if (!work_queue.msgs) { printf("Memory alloc error\n"); close(fd); return 0; } ioctl(fd, I2C_TIMEOUT, 2); ioctl(fd, I2C_RETRIES, 1); (work_queue.msgs[0]).len = 1; (work_queue.msgs[0]).addr = slave_address; (work_queue.msgs[0]).buf = &w_val; (work_queue.msgs[1]).len = len; (work_queue.msgs[1]).flags = I2C_M_RD; (work_queue.msgs[1]).addr = slave_address; (work_queue.msgs[1]).buf = buf; ret = ioctl(fd, I2C_RDWR, (unsigned long) &work_queue); if (ret < 0) { printf("Error during I2C_RDWR ioctl with error code: %d\n", ret); close(fd); free(work_queue.msgs); return 0; } else { printf("read salve:x reg:x\n", slave_address, reg_address); close(fd); free(work_queue.msgs); return len; } } int i2c_write_reg(char *dev, unsigned char *buf, unsigned slave_address, unsigned reg_address, int len) { struct i2c_rdwr_ioctl_data work_queue; unsigned char w_val = reg_address; unsigned char w_buf[len+1]; int ret; w_buf[0] = reg_address; int fd = open(dev, O_RDWR); if (!fd) { printf("Error on opening the device file\n"); return 0; } work_queue.nmsgs = 1; work_queue.msgs = (struct i2c_msg*)malloc(work_queue.nmsgs *sizeof(struct i2c_msg)); if (!work_queue.msgs) { printf("Memory alloc error\n"); close(fd); return 0; } ioctl(fd, I2C_TIMEOUT, 2); ioctl(fd, I2C_RETRIES, 1); (work_queue.msgs[0]).len = 1 + len; (work_queue.msgs[0]).addr = slave_address; (work_queue.msgs[0]).buf = w_buf; memcpy(w_buf + 1, buf, len); ret = ioctl(fd, I2C_RDWR, (unsigned long) &work_queue); if (ret < 0) { printf("Error during I2C_RDWR ioctl with error code: %d\n", ret); close(fd); free(work_queue.msgs); return 0; } else { printf("write salve:x reg:x\n", slave_address, reg_address); close(fd); free(work_queue.msgs); return len; } } int main(int argc, char **argv) { unsigned int fd; unsigned int slave_address, reg_address; unsigned r_w; unsigned w_val; unsigned char rw_val; if (argc < 5) { printf("Usage:\n%s /dev/i2c-x start_addr reg_addr rw[0|1] [write_val]\n", argv[0]); return 0; } fd = open(argv[1], O_RDWR); if (!fd) { printf("Error on opening the device file %s\n", argv[1]); return 0; } sscanf(argv[2], "%x", &slave_address); sscanf(argv[3], "%x", ®_address); sscanf(argv[4], "%d", &r_w); if (r_w == 0) { i2c_read_reg(argv[1], &rw_val, slave_address, reg_address, 1); printf("Read %s-%x reg %x, read value:%x\n", argv[1], slave_address, reg_address, rw_val); } else { if (argc < 6) { printf("Usage:\n%s /dev/i2c-x start_addr reg_addr r|w[0|1] [write_val]\n", argv[0]); return 0; } sscanf(argv[5], "%d", &w_val); if ((w_val & ~0xff) != 0) printf("Error on written value %s\n", argv[5]); rw_val = (unsigned char)w_val; i2c_write_reg(argv[1], &rw_val, slave_address, reg_address, 1); } return 0; } 在android/external/新建i2c-util目录,上述源代码存入android/external/i2c-util/i2c-util.c, R:\wyb\pcf8563_i2c1_r8_ruoge_ov2640\android\i2c-util\i2c-util.c 编写对应的Android.mk: LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := optional LOCAL_MODULE = i2c-util # LOCAL_SRC_FILES := $(call all-subdir-c-files) LOCAL_SRC_FILES := i2c-util.c include $(BUILD_EXECUTABLE) 编译Android后,上述工具会位于/system/bin目录。在电路板上使用它: R:\wyb\pcf8563_i2c1_r8_ruoge_ov2640\android\out\target\product\nuclear-evb\system\bin\i2c-util 如果android已经编译了,只需要执行: rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android$ source build/envsetup.sh rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android$ lunch 选择:18. nuclear_evb-eng (注意:不同的ubuntu电脑,序号可能不同,但是只需要选择nuclear_evb-eng编译选项前面的序号既可!!!!) rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android$ rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android$ cd i2c-util/ rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android/i2c-util$ rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android/i2c-util$ rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android/i2c-util$ mm 详细的编译步骤: Connecting to 192.168.1.103:22... Connection established. To escape to local shell, press 'Ctrl+Alt+]'. Welcome to Ubuntu 14.04 LTS (GNU/Linux 3.13.0-24-generic x86_64) * Documentation: https://help.ubuntu.com/ Last login: Sun Jun 26 19:23:30 2016 from 192.168.1.101 rootroot@rootroot-E400:~$ cd wyb/pcf8563_i2c1_r8_ruoge_ov2640/ rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640$ rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640$ rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640$ ll total 8606460 drwxr-xr-x 4 rootroot rootroot 4096 Jun 26 20:46 ./ drwxr-xr-x 19 rootroot rootroot 4096 Jun 25 06:50 ../ drwxrwxr-x 29 rootroot rootroot 4096 Jun 26 19:51 android/ drwxrwxr-x 8 rootroot rootroot 4096 Jun 26 16:35 lichee/ rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640$ cd android/ rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android$ rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android$ rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android$ source build/envsetup.sh including device/asus/grouper/vendorsetup.sh including device/asus/tilapia/vendorsetup.sh including device/generic/armv7-a-neon/vendorsetup.sh including device/generic/armv7-a/vendorsetup.sh including device/generic/mips/vendorsetup.sh including device/generic/x86/vendorsetup.sh including device/samsung/maguro/vendorsetup.sh including device/samsung/manta/vendorsetup.sh including device/samsung/toroplus/vendorsetup.sh including device/samsung/toro/vendorsetup.sh including device/softwinner/common/vendorsetup.sh including device/softwinner/crane-evb/vendorsetup.sh including device/softwinner/nuclear-256m/vendorsetup.sh including device/softwinner/nuclear-evb/vendorsetup.sh including device/softwinner/nuclear-r8m-evb/vendorsetup.sh including device/ti/panda/vendorsetup.sh including sdk/bash_completion/adb.bash rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android$ rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android$ rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android$ lunch You're building on Linux Lunch menu... pick a combo: 1. full-eng 2. full_x86-eng 3. vbox_x86-eng 4. full_mips-eng 5. full_grouper-userdebug 6. full_tilapia-userdebug 7. mini_armv7a_neon-userdebug 8. mini_armv7a-userdebug 9. mini_mips-userdebug 10. mini_x86-userdebug 11. full_maguro-userdebug 12. full_manta-userdebug 13. full_toroplus-userdebug 14. full_toro-userdebug 15. crane_evb-eng 16. nuclear_256m-user 17. nuclear_256m-eng 18. nuclear_evb-eng 19. nuclear_r8m_evb-eng 20. full_panda-userdebug Which would you like? [full-eng] 18 ============================================ PLATFORM_VERSION_CODENAME=REL PLATFORM_VERSION=4.2.2 TARGET_PRODUCT=nuclear_evb TARGET_BUILD_VARIANT=eng TARGET_BUILD_TYPE=release TARGET_BUILD_APPS= TARGET_ARCH=arm TARGET_ARCH_VARIANT=armv7-a-neon HOST_ARCH=x86 HOST_OS=linux HOST_OS_EXTRA=Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty HOST_BUILD_TYPE=release BUILD_ID=JDQ39 OUT_DIR=out ============================================ rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android$ rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android$ rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android$ ll total 156 drwxrwxr-x 29 rootroot rootroot 4096 Jun 26 19:51 ./ drwxr-xr-x 4 rootroot rootroot 4096 Jun 26 20:46 ../ drwxrwxr-x 3 rootroot rootroot 4096 Jun 13 11:38 abi/ drwxrwxr-x 10 rootroot rootroot 4096 Jun 13 11:38 bionic/ drwxrwxr-x 5 rootroot rootroot 4096 Jun 13 11:38 bootable/ drwxrwxr-x 7 rootroot rootroot 4096 Jun 13 11:38 build/ drwxrwxr-x 11 rootroot rootroot 4096 Jun 13 11:38 cts/ drwxrwxr-x 18 rootroot rootroot 4096 Jun 13 11:38 dalvik/ drwxrwxr-x 18 rootroot rootroot 4096 Jun 13 11:38 development/ drwxrwxr-x 10 rootroot rootroot 4096 Jun 13 11:38 device/ drwxrwxr-x 3 rootroot rootroot 4096 Jun 13 11:38 docs/ drwxrwxr-x 159 rootroot rootroot 4096 Jun 13 11:39 external/ drwxrwxr-x 14 rootroot rootroot 4096 Jun 13 11:40 frameworks/ drwxrwxr-x 10 rootroot rootroot 4096 Jun 13 11:40 gdk/ drwxrwxr-x 10 rootroot rootroot 4096 Jun 13 11:40 hardware/ drwxr-xr-x 2 rootroot rootroot 4096 Jun 26 19:37 i2cscan/ drwxr-xr-x 2 rootroot rootroot 4096 Jun 26 19:52 i2c-util/ drwxrwxr-x 11 rootroot rootroot 4096 Jun 13 11:40 libcore/ drwxrwxr-x 4 rootroot rootroot 4096 Jun 13 11:40 libnativehelper/ -r--r--r-- 1 rootroot rootroot 87 Jun 13 11:38 Makefile drwxrwxr-x 8 rootroot rootroot 4096 Jun 13 11:40 ndk/ drwxrwxr-x 4 rootroot rootroot 4096 Jun 26 16:43 out/ drwxrwxr-x 8 rootroot rootroot 4096 Jun 13 11:40 packages/ drwxrwxr-x 5 rootroot rootroot 4096 Jun 13 11:40 pdk/ drwxrwxr-x 10 rootroot rootroot 4096 Jun 13 11:41 prebuilts/ drwxr-xr-x 2 rootroot rootroot 4096 Jun 25 13:01 read_pcf8563/ drwxrwxr-x 6 rootroot rootroot 4096 Jun 13 11:38 .repo/ drwxrwxr-x 51 rootroot rootroot 4096 Jun 13 11:41 sdk/ drwxrwxr-x 9 rootroot rootroot 4096 Jun 13 11:41 system/ drwxrwxr-x 4 rootroot rootroot 4096 Jun 13 11:41 tools/ rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android$ rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android$ rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android$ cd i2c-util/ rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android/i2c-util$ rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android/i2c-util$ rootroot@rootroot-E400:~/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android/i2c-util$ mm ============================================ PLATFORM_VERSION_CODENAME=REL PLATFORM_VERSION=4.2.2 TARGET_PRODUCT=nuclear_evb TARGET_BUILD_VARIANT=eng TARGET_BUILD_TYPE=release TARGET_BUILD_APPS= TARGET_ARCH=arm TARGET_ARCH_VARIANT=armv7-a-neon HOST_ARCH=x86 HOST_OS=linux HOST_OS_EXTRA=Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty HOST_BUILD_TYPE=release BUILD_ID=JDQ39 OUT_DIR=out ============================================ PRODUCT_COPY_FILES frameworks/base/data/sounds/effects/ogg/Effect_Tick.ogg:system/media/audio/ui/Effect_Tick.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/effects/ogg/KeypressStandard.ogg:system/media/audio/ui/KeypressStandard.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/effects/ogg/KeypressSpacebar.ogg:system/media/audio/ui/KeypressSpacebar.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/effects/ogg/KeypressDelete.ogg:system/media/audio/ui/KeypressDelete.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/effects/ogg/KeypressReturn.ogg:system/media/audio/ui/KeypressReturn.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/effects/ogg/VideoRecord.ogg:system/media/audio/ui/VideoRecord.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/effects/ogg/camera_click.ogg:system/media/audio/ui/camera_click.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/effects/ogg/LowBattery.ogg:system/media/audio/ui/LowBattery.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/effects/ogg/Dock.ogg:system/media/audio/ui/Dock.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/effects/ogg/Undock.ogg:system/media/audio/ui/Undock.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/effects/ogg/Lock.ogg:system/media/audio/ui/Lock.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/effects/ogg/Unlock.ogg:system/media/audio/ui/Unlock.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/ringtones/ogg/Sceptrum.ogg:system/media/audio/ringtones/Sceptrum.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/effects/ogg/KeypressStandard_120.ogg:system/media/audio/ui/KeypressStandard.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/effects/ogg/KeypressSpacebar_120.ogg:system/media/audio/ui/KeypressSpacebar.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/effects/ogg/KeypressDelete_120.ogg:system/media/audio/ui/KeypressDelete.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/effects/ogg/KeypressReturn_120.ogg:system/media/audio/ui/KeypressReturn.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/notifications/ogg/Capella.ogg:system/media/audio/notifications/Capella.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/notifications/ogg/CetiAlpha.ogg:system/media/audio/notifications/CetiAlpha.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/notifications/ogg/Polaris.ogg:system/media/audio/notifications/Polaris.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/notifications/ogg/Pollux.ogg:system/media/audio/notifications/Pollux.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/notifications/ogg/Procyon.ogg:system/media/audio/notifications/Procyon.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/ringtones/ogg/Aquila.ogg:system/media/audio/ringtones/Aquila.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/ringtones/ogg/ArgoNavis.ogg:system/media/audio/ringtones/ArgoNavis.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/ringtones/ogg/Carina.ogg:system/media/audio/ringtones/Carina.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/ringtones/ogg/Centaurus.ogg:system/media/audio/ringtones/Centaurus.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/ringtones/ogg/Cygnus.ogg:system/media/audio/ringtones/Cygnus.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/ringtones/ogg/Draco.ogg:system/media/audio/ringtones/Draco.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/ringtones/ogg/Machina.ogg:system/media/audio/ringtones/Machina.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/ringtones/ogg/Orion.ogg:system/media/audio/ringtones/Orion.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/ringtones/ogg/Pegasus.ogg:system/media/audio/ringtones/Pegasus.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/ringtones/ogg/Pyxis.ogg:system/media/audio/ringtones/Pyxis.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/ringtones/ogg/Rigel.ogg:system/media/audio/ringtones/Rigel.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/ringtones/ogg/Scarabaeus.ogg:system/media/audio/ringtones/Scarabaeus.ogg ignored. PRODUCT_COPY_FILES frameworks/base/data/sounds/ringtones/ogg/Solarium.ogg:system/media/audio/ringtones/Solarium.ogg ignored. PRODUCT_COPY_FILES device/softwinner/nuclear-common/googleservice/gapps-jb-20121130-signed/system/tts/lang_pico/es-ES_zl0_sg.bin:system/tts/lang_pico/es-ES_zl0_sg.bin ignored. PRODUCT_COPY_FILES device/softwinner/nuclear-common/googleservice/gapps-jb-20121130-signed/system/tts/lang_pico/es-ES_ta.bin:system/tts/lang_pico/es-ES_ta.bin ignored. PRODUCT_COPY_FILES device/softwinner/nuclear-common/googleservice/gapps-jb-20121130-signed/system/tts/lang_pico/fr-FR_nk0_sg.bin:system/tts/lang_pico/fr-FR_nk0_sg.bin ignored. PRODUCT_COPY_FILES device/softwinner/nuclear-common/googleservice/gapps-jb-20121130-signed/system/tts/lang_pico/fr-FR_ta.bin:system/tts/lang_pico/fr-FR_ta.bin ignored. PRODUCT_COPY_FILES device/softwinner/nuclear-common/googleservice/gapps-jb-20121130-signed/system/tts/lang_pico/de-DE_gl0_sg.bin:system/tts/lang_pico/de-DE_gl0_sg.bin ignored. PRODUCT_COPY_FILES device/softwinner/nuclear-common/googleservice/gapps-jb-20121130-signed/system/tts/lang_pico/it-IT_cm0_sg.bin:system/tts/lang_pico/it-IT_cm0_sg.bin ignored. PRODUCT_COPY_FILES device/softwinner/nuclear-common/googleservice/gapps-jb-20121130-signed/system/tts/lang_pico/it-IT_ta.bin:system/tts/lang_pico/it-IT_ta.bin ignored. PRODUCT_COPY_FILES device/softwinner/nuclear-common/googleservice/gapps-jb-20121130-signed/system/tts/lang_pico/de-DE_ta.bin:system/tts/lang_pico/de-DE_ta.bin ignored. No private recovery resources for TARGET_DEVICE nuclear-evb make: Entering directory `/home/rootroot/wyb/pcf8563_i2c1_r8_ruoge_ov2640/android' target thumb C: i2c-util cd R:\wyb\pcf8563_i2c1_r8_ruoge_ov2640\android\out\target\product\nuclear-evb\system\bin C:\Users\Administrator.USER-20150913SZ>r: R:\wyb\pcf8563_i2c1_r8_ruoge_ov2640\android\out\target\product\nuclear-evb\system\bin>adb remount remount succeeded R:\wyb\pcf8563_i2c1_r8_ruoge_ov2640\android\out\target\product\nuclear-evb\system\bin> R:\wyb\pcf8563_i2c1_r8_ruoge_ov2640\android\out\target\product\nuclear-evb\system\bin>dir i2c* 驱动器 R 中的卷是 rootroot 卷的序列号是 1A1C-E71D R:\wyb\pcf8563_i2c1_r8_ruoge_ov2640\android\out\target\product\nuclear-evb\system\bin 的目录 2016/06/26 21:10 5,388 i2c-util 1 个文件 5,388 字节 0 个目录 268,337,782,784 可用字节 R:\wyb\pcf8563_i2c1_r8_ruoge_ov2640\android\out\target\product\nuclear-evb\system\bin> R:\wyb\pcf8563_i2c1_r8_ruoge_ov2640\android\out\target\product\nuclear-evb\system\bin>adb push i2c-util /data/ 29 KB/s (5388 bytes in 0.180s) R:\wyb\pcf8563_i2c1_r8_ruoge_ov2640\android\out\target\product\nuclear-evb\system\bin> 将R8的串口连接到windows电脑上。通过串口工具:比如Xshell5(有些人可能喜欢使用SecureCRT)读取R8的串口打印 (ubuntu下请使用minicom,使用方法请自行搜索了) 波特率选择:115200 N 8 1 等R8的android启动完成之后(LCD进android主界面),输入:su [ 37.990060] init: process 'ril-daemon', pid 950 exited [ 38.010049] init: process 'ril-daemon' killing any children in process group su root@android:/ # root@android:/ # root@android:/ # cd /data root@android:/data # root@android:/data # ll drwxrwxr-x system system 1970-01-11 08:58 anr drwxrwx--x system system 1970-01-02 08:01 app drwx------ root root 1980-10-01 11:03 app-asec drwxrwx--x system system 1970-01-02 08:01 app-lib drwxrwx--x system system 1980-10-01 11:03 app-private drwx------ system system 1980-10-01 11:04 backup drwxrwx--x system system 1970-01-02 08:00 dalvik-cache drwxrwx--x system system 2016-06-21 10:11 data drwxr-x--- root log 1980-10-01 11:03 dontpanic drwxrwx--- drm drm 1980-10-01 11:04 drm -rw-rw-rw- root root 5388 2016-06-26 21:10 i2c-util drwxr-x--x root root 1980-10-01 11:03 local drwxrwx--- root root 1970-01-01 08:00 lost+found drwxrwx--- media_rw media_rw 1980-10-01 11:03 media drwxrwx--t system misc 1980-10-01 11:03 misc -rw------- system system 154 1970-01-02 08:02 pointercal drwx------ root root 1970-01-02 08:00 property -rwxrwxrwx root root 5392 2016-06-25 13:01 read_pcf8563 drwxrwx--x system system 1980-10-01 11:03 resource-cache drwxr-x--- root shell 1980-10-01 11:03 ssh drwxrwxr-x system system 1970-01-02 08:00 system drwx------ system system 1970-01-02 08:03 tombstones drwx--x--x system system 1980-10-01 11:03 user root@android:/data # (让i2c-util具有可执行权限:) root@android:/data # chmod 777 i2c-util root@android:/data # root@android:/data # ll i2c* -rwxrwxrwx root root 5388 2016-06-26 21:10 i2c-util root@android:/data # root@android:/data # root@android:/data # (可选执行) root@android:/data # sync root@android:/data # 注意:串口打印会打印很多log信息。上面的步骤中的状态信息已经被过滤了。 如果你的串口打印过量的log信息,属于正常现象! 如果不想要这么多的状态信息,可以考虑使用adb shell。 不过windows命令行中的adb shell不能够按TAB键自动补充,ubuntu的可以。 也许我们可以把windows的命令行特别设计一下(给它修正一下),让它也可以通过按TAB键来自动补全!^_ 读取pcf8563的第2个寄存器(秒钟值): 表 5:BCD 格式寄存器概况 标明“-”的位无效 地址 寄存器名称 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 02h 秒 VL 00~59BCD 码格式数 root@android:/data # ./i2c-util /dev/i2c-1 0x51 0x02 0 read salve:51 reg:02 Read /dev/i2c-1-51 reg 2, read value:11 root@android:/data # ./i2c-util /dev/i2c-1 0x51 0x02 0 read salve:51 reg:02 Read /dev/i2c-1-51 reg 2, read value:12 root@android:/data # ./i2c-util /dev/i2c-1 0x51 0x02 0 read salve:51 reg:02 Read /dev/i2c-1-51 reg 2, read value:12 root@android:/data # ./i2c-util /dev/i2c-1 0x51 0x02 0 read salve:51 reg:02 Read /dev/i2c-1-51 reg 2, read value:13 root@android:/data # ./i2c-util /dev/i2c-1 0x51 0x02 0 read salve:51 reg:02 Read /dev/i2c-1-51 reg 2, read value:14 root@android:/data # ./i2c-util /dev/i2c-1 0x51 0x02 0 read salve:51 reg:02 Read /dev/i2c-1-51 reg 2, read value:14 root@android:/data # ./i2c-util /dev/i2c-1 0x51 0x02 0 read salve:51 reg:02 Read /dev/i2c-1-51 reg 2, read value:15 可以知道秒钟的值是变化的,基本上是一秒钟递增一次,I2C读取成功。 如果感兴趣的话,在执行读取命令的时候通过协议分析仪或者示波器来抓取I2C1的SCL/SDA的波形,来进行更加详尽的分析!^_ 方法二: 给出了一种复杂的解决办法(步骤从简,更多请参考开头的方法): R:\wyb\pcf8563_i2c1_r8_ruoge_ov2640\lichee\linux-3.4\drivers\rtc\rtc-sun5i.c 给这个驱动文件增加设备节点:/dev/a20_r8_pcf8563 增加设备节点的方法请参考: http://blog.csdn.net/mirkerson/article/details/8844997 android驱动学习---led实验 然后在这个驱动文件的pcf8563_probe函数处截获它的client指针(struct i2c_client *client) client2 = client; 用户可以通过在userspace直接访问设备节点:/dev/a20_r8_pcf8563(open) 然后调用ioctl:ioctl(fd, 0x00000001, 0x02); 来获取第2个寄存器:秒钟的值了。 #include #include #include #include #include #include #include #include #include #include #include int fd; int main(int argc, char **argv) { fd = open("/dev/a20_r8_pcf8563", O_RDWR); ioctl(fd, 0x00000001, 0x02); close(fd); return 0; } 执行过程(直接从内核打印秒钟值了,也可以看到秒钟值大概也是一秒钟递增一次!): root@android:/data # root@android:/data # ./read_pcf8563 [ 1397.060015] ****wyb drivers/rtc/rtc-sun5i.c:1169/r8_pcf8563_open()! open init.... [ 1397.071009] ****wyb drivers/rtc/rtc-sun5i.c:1130/r8_pcf8563_ioctl()! cmd=0x00000001 [ 1397.079076] ****wyb drivers/rtc/rtc-sun5i.c:1160/r8_pcf8563_ioctl()! cmd=0x00000001, value=0x00000046 [ 1397.088342] ****wyb drivers/rtc/rtc-sun5i.c:1177/r8_pcf8563_close()! close init root@android:/data # root@android:/data # ./read_pcf8563 [ 1398.409888] ****wyb drivers/rtc/rtc-sun5i.c:1169/r8_pcf8563_open()! open init.... [ 1398.411203] ****wyb drivers/rtc/rtc-sun5i.c:1130/r8_pcf8563_ioctl()! cmd=0x00000001 [ 1398.419273] ****wyb drivers/rtc/rtc-sun5i.c:1160/r8_pcf8563_ioctl()! cmd=0x00000001, value=0x00000047 [ 1398.428546] ****wyb drivers/rtc/rtc-sun5i.c:1177/r8_pcf8563_close()! close init root@android:/data # root@android:/data # root@android:/data # ./read_pcf8563 [ 1399.668173] ****wyb drivers/rtc/rtc-sun5i.c:1169/r8_pcf8563_open()! open init.... [ 1399.670939] ****wyb drivers/rtc/rtc-sun5i.c:1130/r8_pcf8563_ioctl()! cmd=0x00000001 [ 1399.679022] ****wyb drivers/rtc/rtc-sun5i.c:1160/r8_pcf8563_ioctl()! cmd=0x00000001, value=0x00000048 [ 1399.688299] ****wyb drivers/rtc/rtc-sun5i.c:1177/r8_pcf8563_close()! close init root@android:/data #
20161114全志R16配置为前ov5640后UVC的双摄像头 1、 Z:\home\wwt\uvc_r16_project\android\device\softwinner\astar-evb20\configs\camera.cfg 修改: number_of_camera = 1 为: number_of_camera = 2 如果不改这里,兄弟,你在camera这个APP里面是绝对看不到前后摄像头的切换选项的!!!!^_ 修改ov5640的分辨率: used_preview_size = 1 key_support_preview_size = 640x480 key_default_preview_size = 640x480 used_picture_size = 1 key_support_picture_size = 640x480 key_default_picture_size = 640x480 为(根据你驱动里面的摄像头的寄存器配置分辨率而实际修改): used_preview_size = 1 key_support_preview_size = 2592x1936, 2048x1536, 1600x1200, 1280x960, 1280x960, 1024x768, 1920x1080 ,1280x720, 800x600, 640x480 key_default_preview_size = 640x480 used_picture_size = 1 key_support_picture_size = 2592x1936, 2048x1536, 1600x1200, 1280x960, 1280x960, 1024x768, 1920x1080 ,1280x720, 800x600, 640x480 key_default_picture_size = 640x480 2、 Z:\home\wwt\uvc_r16_project\android\device\softwinner\astar-evb20\astar_evb20.mk #include device/softwinner/polaris-common/prebuild/google/products/gms_minimal.mk 注释掉这里干掉Google Play。可以不改。 3、这里讲UVC配置为模块了,请注意UVC所需要的模块的加载顺序。 Z:\home\wwt\uvc_r16_project\android\device\softwinner\astar-evb20\init.sun8i.rc 默认为: #csi module insmod /system/vendor/modules/videobuf-core.ko insmod /system/vendor/modules/videobuf-dma-contig.ko insmod /system/vendor/modules/cam_detect.ko # insmod /system/vendor/modules/actuator.ko # insmod /system/vendor/modules/ad5820_act.ko insmod /system/vendor/modules/cci.ko insmod /system/vendor/modules/vfe_os.ko insmod /system/vendor/modules/vfe_subdev.ko insmod /system/vendor/modules/gc0307.ko # insmod /system/vendor/modules/ov2035.ko insmod /system/vendor/modules/vfe_v4l2.ko 修改为: #csi module # /dev/video0 ov5640 insmod /system/vendor/modules/videobuf-core.ko insmod /system/vendor/modules/videobuf-dma-contig.ko #insmod /system/vendor/modules/cam_detect.ko insmod /system/vendor/modules/cci.ko insmod /system/vendor/modules/vfe_os.ko insmod /system/vendor/modules/vfe_subdev.ko insmod /system/vendor/modules/ov5640.ko insmod /system/ven

1,318

社区成员

发帖
与我相关
我的任务
社区描述
主要是开发驱动技术
社区管理员
  • 驱动程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧