1、android设备竖、横屏
android 5.1 launcher
packages\apps\Launcher2android:screenOrientation="sensor" 设置由传感器转屏
另外经验证,【测试发现强制转换无效:android:screenOrientation="landscape"】是由于设备没有清除缓存,需要重新下载所有文件。
########################################################################################
2017.7.25
1.
驱动框架
1)写led_first_drv_open、led_first_drv_write函数
2)怎么告诉内核:
a.定义一个file_operations结构体
b.把这个结构体告诉内核:
register_chrdev
c.谁来调用 谁:驱动的入口函数(led_first_frv_init)
d.修饰 module_init
应用程序open("/dev/xxx"),read、write
属性: c , xxx(主设备号)
查找驱动是通过:设备类型的主设备号(major),而不是名字
2.
问题:第一个驱动程序,make时候 报错:/bin/sh: 1: arm-eabi-gcc: not found
解决:添加arm-eabi-gcc环境变量
sudo vi /etc/profile
添加:export PATH=$PATH:/usr/local/arm/arm-eabi-4.6/bin
source /etc/profile
3.传输文件
A:服务器和设备处于同一个路由器下通过scp进行复制
scp led_first_drv.o [email protected]:/etc/test
B:不在同一个路由器下,通过Samba服务,并在电脑打开设备存储文件(手机的存储:/sdcard),直接进行复制粘贴
C:adb push led.ko /work
注:关闭金山卫士和毒霸,原因:占用端口
2017.7.15
1、由于编译Android系统,需要至少4G内存,部署虚拟机到服务器上。
Do:
A:复制压缩文件:StandardUbuntu64.rar
B:解压StandardUbuntu64.rar文件,运行虚拟机,自动分配IP地址(192.168.98.165)
#######################################################################################################
2017.7.17
1、为了支持远程登录,虚拟机安装ssh软件
Do:
命令:sudo apt-get install ssh
2、对比、更新补丁文件
已经更新:
20170407
Android
1、EC20模块新版本补丁,兼容旧版本
cdrom\4418-2nd-patches\20170401-4418-EC20-new-version-patch
\device\nexell\s5p4418_drone\device.mk
#add by yangbin for EC20,2016-01-04
PRODUCT_COPY_FILES += \
#device/nexell/s5p4418_drone/rpdzkj/system/bin/pppd:system/bin/pppd \
#device/nexell/s5p4418_drone/rpdzkj/system/bin/chat:system/bin/chat \
#device/nexell/s5p4418_drone/rpdzkj/system/etc/ppp/ip-down:system/etc/ppp/ip-down \
#device/nexell/s5p4418_drone/rpdzkj/system/etc/ppp/ip-up:system/etc/ppp/ip-up \
#device/nexell/s5p4418_drone/rpdzkj/system/lib/libreference-ril.so:system/lib/libreference-ril.so \
device/nexell/s5p4418_drone/rpdzkj/etc/apns-conf.xml:system/etc/apns-conf.xml
#add by yangbin for EC20,2016-01-04
PRODUCT_COPY_FILES += \
device/nexell/s5p4418_drone/rpdzkj/system/bin/pppd:system/bin/pppd \
device/nexell/s5p4418_drone/rpdzkj/system/bin/chat:system/bin/chat \
device/nexell/s5p4418_drone/rpdzkj/system/etc/ppp/ip-down:system/etc/ppp/ip-down \
device/nexell/s5p4418_drone/rpdzkj/system/etc/ppp/ip-up:system/etc/ppp/ip-up \
device/nexell/s5p4418_drone/rpdzkj/system/lib/libreference-ril.so:system/lib/libreference-ril.so \
device/nexell/s5p4418_drone/rpdzkj/etc/apns-conf.xml:system/etc/apns-conf.xml
两种编译方法:
=======================================================
第一步:
在lollipop_2nd_release目录下,执行
source jdk_openJdk17.sh
第二步:
在lollipop_2nd_release目录下,执行
. ./build/envsetup.sh
第三步:
在lollipop_2nd_release目录下,执行 lunch 进行选择 s5p4418
第四步:
在目录lollipop_2nd_release下执行:./make.sh kernel
第五步:
在目录lollipop_2nd_release下执行:./make.sh android
========================================================
内核编译:
./device/nexell/tools/build.sh -t kernel
android 编译:
./device/nexell/tools/build.sh -t android
#######################################################################################################
2017.7.18
1.
显示屏再用MIPI接口,S5P4418提供MIPI接口配置,只需配置相关参数即可。
u-boot\boart\s5p4418\drone\include\Cfg_gpio.h
kernel\arch\arm\plat-s5p4418\drone\include\Cfg_gpio.h
u-boot/board/s5p4418/drone/display.c
注:
A:MIPI/LVDS 接口为J103,LCD 接口为104
B:两种显示屏实现方式不同,硬件上LCD可以修改引脚,MIPI/LVDS 具有专有的接口引脚且不能修改硬件引脚
2.(修改的多,也许不用gt9147)
TP触摸屏:客户自定义参数:
gt9xx.h
//PART1:ON/OFF define
#define GTP_CUSTOM_CFG 1
// STEP_2(REQUIRED): Customize your I/O ports & I/O operations
#define GTP_RST_PORT CFG_IO_TOUCH_RESET_PIN
#define GTP_INT_PORT CFG_IO_TOUCH_PENDOWN_DETECT
//PART2:TODO define
#if GTP_CUSTOM_CFG
#define GTP_MAX_HEIGHT 1280
#define GTP_MAX_WIDTH 720
#define GTP_INT_TRIGGER 0 // 0: Rising 1: Falling
#else
#define GTP_MAX_HEIGHT 4096
#define GTP_MAX_WIDTH 4096
#define GTP_INT_TRIGGER 1
#endif
参考文件:GT9XX驱动移植说明书_for_Android_2014011401.pdf
3.
Android系统横竖屏修改
Android手机屏幕的横竖由加速度传感器感应,横竖屏的转换在Android系统框架中
所以需要修改Android源码。
#######################################################################################################
2017.7.19
1.(由于需要修改Android源码,所以使用Android studio进行阅读)
第一步:
在lollipop_2nd_release目录下,执行
source jdk_openJdk17.sh
第二步:
在lollipop_2nd_release目录下,执行
. ./build/envsetup.sh
第三步:
在lollipop_2nd_release目录下,执行
mmm development/tools/idegen/
第四步:
在lollipop_2nd_release目录下,执行
sh ./development/tools/idegen/idegen.sh
生成android.iml和android.ipr这两个文件,这两个文件是Android Studio的工程配置文件。
注:
时间可能会久点:
Read excludes: 59ms
Traversed tree: 258249ms
第五步:(不进行过滤在索引时候需要花费很长时间,若是电脑配置低会卡死)
过滤一下我们不需要的源码文件,只导入我们需要的模块
打开android.iml文件,加入如下代码:除了frameworks模块的其他所有模块都过滤掉了
2.(java不能使用SecureCRT等类似软件修改,文件类型错误:error: class, interface, or enum expected)
1.修改frameworks\base\core\res\res\values\config.xml中config_lidOpenRotation的值为90。
old:-1
2.修改frameworks\base\services\core\java\com\android\server\wm\WindowManagerService.java中:
int mRotation = 1;
3.修改frameworks\native\services\surfaceflinger\DisplayDevice.cpp里面:
setProjection(DisplayState::eOrientation90, mViewport, mFrame);
frame = Rect(h, w);
Transform R;
orientation = DisplayState::eOrientation90;
DisplayDevice::orientationToTransfrom(orientation, w, h, &R);
old: setProjection(DisplayState::eOrientationDefault, mViewport, mFrame);
frame = Rect(w, h);
Transform R;
DisplayDevice::orientationToTransfrom(orientation, w, h, &R);
4.进入frameworks/native/services/surfaceflinger/surfaceFlinger.cpp
修改函数voidSurfaceFlinger::onInitializeDisplay()中:
d.orientation = DisplayState::eOrientationDefault ;----->d.orientation=DisplayState::eOrientatio90;
5、交换一下Bootanimation 里面的h和w
进入frameworks/base/cmds/bootanimation/BootAnimation.cpp
修改status_t BootAnimation::readyToRun函数中的
spcontrol=session()- >createsurface(String8("BootAnimation"),dinfo.w,dinfo.h.PIXEL_FORMAT_RGB_565);
为:
spcontrol=session()- >createsurface(String8("BootAnimation"),dinfo.h,dinfo.w.PIXEL_FORMAT_RGB_565);
#######################################################################################################
2017.7.20
之前修改了横屏显示(感觉逻辑上还是存在问题),只是把竖屏改为横屏,界面的宽度还是没变。
android 5.1 launcher
packages\apps\Launcher2
packages\apps\Launcher3
AndroidManifest.xml
android:screenOrientation="sensor" 设置由传感器转屏
注:测试发现强制转换无效:android:screenOrientation="landscape"
2.加速度方向分析
驱动位置:/kernel/drivers/input/misc/bca2xx/bma2x2.c
反向调用:
朝向:
static int bma2x2_set_orient_mode(struct i2c_client *client, unsigned char mode)
static ssize_t bma2x2_orient_mode_store(struct device *dev,struct device_attribute *attr,const char *buf, size_t count)
static DEVICE_ATTR(orient_mode, 0664/*S_IRUGO|S_IWUSR|S_IWGRP|S_IWOTH*/,bma2x2_orient_mode_show, bma2x2_orient_mode_store)
cat /sys/devices/virtual/bst/ACC/orient_mode
cat /sys/devices/virtual/input/input3/orient_mode
默认为0
echo 2 > /sys/devices/virtual/bst/ACC/orient_mode
echo 2 > /sys/devices/virtual/input/input3/orient_mode
加速度方向设定:
/kernel/drivers/input/misc/bca2xx/bst_sensor_common.h
struct bosch_sensor_specific {
char *name;
/* 0 to 7 */
unsigned int place:3;
int irq;
int (*irq_gpio_cfg)(void);
};
static const struct bosch_sensor_axis_remap bst_axis_remap_tab_dft[MAX_AXIS_REMAP_TAB_SZ] =
{
/* src_x src_y src_z sign_x sign_y sign_z */
{ 0, 1, 2, 1, 1, 1 }, /* P0 */
{ 1, 0, 2, 1, -1, 1 }, /* P1 */
{ 0, 1, 2, -1, -1, 1 }, /* P2 */
{ 1, 0, 2, -1, 1, 1 }, /* P3 */
{ 0, 1, 2, -1, 1, -1 }, /* P4 */
{ 1, 0, 2, -1, -1, -1 }, /* P5 */
{ 0, 1, 2, 1, -1, -1 }, /* P6 */
{ 1, 0, 2, 1, 1, -1 }, /* P7 */
};
==>
void bst_remap_sensor_data(struct bosch_sensor_data *data,const struct bosch_sensor_axis_remap *remap)
==>
void bst_remap_sensor_data_dft_tab(struct bosch_sensor_data *data,int place)
==>
kernel/drivers/input/misc/bca2xx/bma2x2.c
static void bma2x2_remap_sensor_data(struct bma2x2acc *val,struct bma2x2_data *client_data)
==>
static int bma2x2_read_accel_xyz(struct i2c_client *client,signed char sensor_type, struct bma2x2acc *acc)
==>
static ssize_t bma2x2_value_show(struct device *dev,struct device_attribute *attr, char *buf)
==> static DEVICE_ATTR(value, S_IRUGO,bma2x2_value_show, NULL);
==> cat /sys/devices/virtual/input/input3/value 传感器 x,y,z
*bma2x2 = input_get_drvdata(input);
*input = to_input_dev(dev);
注释掉了
static void bma2x2_irq_work_func(struct work_struct *work)
到这来后,发现bma2x2_data参数是通过to_input_dev获取的,系统通过platform总线注册设备,并把私有用户参数存放在i2c_board_info中,
放置方向缺省
#define SENSOR_NAME "bma2x2"
static struct i2c_driver bma2x2_driver = {
.driver = {
.owner = THIS_MODULE,
.name = SENSOR_NAME, //与i2c_board_info一致
},
.suspend = bma2x2_suspend,
.shutdown = bma2x2_shutdown,
.resume = bma2x2_resume,
.id_table = bma2x2_id,
.probe = bma2x2_probe,
.remove = __devexit_p(bma2x2_remove),
};
static struct i2c_board_info __initdata bma22x_i2c_bdi = {
.type = "bma2x2",
.addr = 0x18,//(0x4c),
.irq = PB_PIO_IRQ(CFG_IO_BMA250_DETECT),
};
驱动注册
kernel/arch/arm/plat-s5p4418/drone/device.c
//添加私有数据 BMA_pd
#if defined(CONFIG_SENSORS_BMA2X2)
++#include
#define BMA22X_I2C_BUS (2)
++struct bosch_sensor_specific BMA_pd ={
++ .name = "bma2x2 sersor",
++ .place = 1,
++};
/* CODEC */
static struct i2c_board_info __initdata bma22x_i2c_bdi = {
.type = "bma2x2",
.addr = 0x18,//(0x4c),
.irq = PB_PIO_IRQ(CFG_IO_BMA250_DETECT),
++ .platform_data = &BMA_pd,
};
#endif
#######################################################################################################
2017.7.24
1.经验证,【测试发现强制转换无效:android:screenOrientation="landscape"】是由于设备没有清除缓存,需要重新下载所有文件。
2.常用文件
sys\devices\platform\rpdzkj-sysfs.c
arch\arm\plat-s5p4418\drone\Device.c
arch\arm\plat-s5p4418\drone\include\Cfg_main.h
arch\arm\mach-s5p4418\Devices.c
kernel\arch\arm\mach-s5p4418\soc\gpio.c
drivers\rongpin\Rp_gpio_ctrl.c
drivers\rongpin\Rp_gpio_set.c
drivers\input\touchscreen\Gt9xx.c
drivers\i2c\busses\I2c-gpio.c
drivers\input\keyboard\Nxp_io_key.c
#######################################################################################################
2017.7.25
1.
驱动框架
1)写led_first_drv_open、led_first_drv_write函数
2)怎么告诉内核:
a.定义一个file_operations结构体
b.把这个结构体告诉内核:
register_chrdev
c.谁来调用 谁:驱动的入口函数(led_first_frv_init)
d.修饰 module_init
应用程序open("/dev/xxx"),read、write
属性: c , xxx(主设备号)
查找驱动是通过:设备类型的主设备号(major),而不是名字
2.
问题:第一个驱动程序,make时候 报错:/bin/sh: 1: arm-eabi-gcc: not found
解决:添加arm-eabi-gcc环境变量
sudo vi /etc/profile
添加:export PATH=$PATH:/usr/local/arm/arm-eabi-4.6/bin
source /etc/profile
3.传输文件
A:
服务器和设备处于同一个路由器下通过scp进行复制
scp led_first_drv.o [email protected]:/etc/test
B:
不在同一个路由器下,通过Samba服务,并在电脑打开设备存储文件(手机的存储:/sdcard),直接进行复制粘贴
C:
adb push led.ko /work
注:关闭金山卫士和毒霸,原因:占用端口
arm-eabi-gcc -o test test.c
1、sys/ types.h: No such file or directory
2、cannot find crt0.o: No such file or directory
3、cannot find -lc
第一个:-I/usr/include
第二个:1)-L/home/xunfang/work/lollipop_2nd_release/linux/bootloader/u-boot-2014.07/arch/arm/lib 无效
2)LIBRARY_PATH=/home/xunfang/work/lollipop_2nd_release/linux/bootloader/u-boot-2014.07/arch/arm/lib:$LIBRARY_PATH
export LIBRARY_PATH 无效
3)cp /home/xunfang/work/lollipop_2nd_release/linux/bootloader/u-boot-2014.07/arch/arm/lib/crt0.o /usr/local/arm/arm-eabi-4.6/arm-eabi/lib 可行
第三个:cp /home/xunfang/work/lollipop_2nd_release/out/target/product/s5p4418_drone/obj/lib/libc.so /usr/local/arm/arm-eabi-4.6/arm-eabi/lib
arm-linux-gcc -o test test.c
arm-eabi-gcc -o led_first_drv_test led_first_drv_test.c -v -I/usr/include -L/home/xunfang/work/lollipop_2nd_release/linux/bootloader/u-boot-2014.07/arch/arm/lib -static
export PATH=$PATH:/usr/local/arm/gcc-3.4.5-glibc-2.3.6/bin
arm-linux-gcc -o led_first_drv_test -c led_first_drv_test.c
arm-eabi-gcc -o led_first_drv_test led_first_drv_test.c
fatal error: sys/ types.h: No such file or directory
arm-eabi-gcc -o led_first_drv_test -I/usr/include led_first_drv_test.c
/usr/local/arm/arm-eabi-4.6/bin/../lib/gcc/arm-eabi/4.6.x-google/../../../../arm-eabi/bin/ld: cannot find crt0.o: No such file or directory
/usr/local/arm/arm-eabi-4.6/bin/../lib/gcc/arm-eabi/4.6.x-google/../../../../arm-eabi/bin/ld: cannot find -lc
collect2: ld returned 1 exit status
LIBRARY_PATH=/home/xunfang/work/lollipop_2nd_release/linux/bootloader/u-boot-2014.07/arch/arm/lib:$LIBRARY_PATH
export LIBRARY_PATH
xunfang@ubuntu:/usr/local/arm/arm-eabi-4.6/arm-eabi/lib$ cp /home/xunfang/work/lollipop_2nd_release/linux/bootloader/u-boot-2014.07/arch/arm/lib/crt0.o ./
xunfang@ubuntu:~/work/lollipop_2nd_release/android5.1/led/led_first$ arm-eabi-gcc -o led_first_drv_test -I/usr/include led_first_drv_test.c -v
Using built-in specs.
COLLECT_GCC=arm-eabi-gcc
COLLECT_LTO_WRAPPER=/usr/local/arm/arm-eabi-4.6/bin/../libexec/gcc/arm-eabi/4.6.x-google/lto-wrapper
Target: arm-eabi
Configured with: /tmp/android-15472/src/build/../gcc/gcc-4.6/configure --prefix=/usr/local --target=arm-eabi --host=x86_64-linux-gnu --build=x86_64-linux-gnu --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --with-gmp=/tmp/android-15472/obj/temp-install --with-mpfr=/tmp/android-15472/obj/temp-install --with-mpc=/tmp/android-15472/obj/temp-install --without-ppl --without-cloog --disable-libssp --enable-threads --disable-nls --disable-libmudflap --disable-libgomp --disable-libstdc__-v3 --disable-sjlj-exceptions --disable-shared --disable-tls --disable-libitm --with-float=soft --with-fpu=vfp --with-arch=armv5te --enable-target-optspace --with-abi=aapcs --with-gcc-version=4.6 --with-binutils-version=2.21 --with-gmp-version=4.2.4 --with-mpfr-version=2.4.1 --with-gdb-version=7.3.x --with-arch=armv5te --with-sysroot=/tmp/android-15472/install/sysroot --with-prefix=/tmp/android-15472/install --with-gold-version=2.21 --enable-gold --disable-gold --disable-multilib --program-transform-name='s&^&arm-eabi-&'
Thread model: single
gcc version 4.6.x-google 20120106 (prerelease) (GCC)
COLLECT_GCC_OPTIONS='-o' 'led_first_drv_test' '-I' '/usr/include' '-v' '-march=armv5te' '-mfloat-abi=soft' '-mfpu=vfp' '-mabi=aapcs'
/usr/local/arm/arm-eabi-4.6/bin/../libexec/gcc/arm-eabi/4.6.x-google/cc1 -quiet -v -I /usr/include -iprefix /usr/local/arm/arm-eabi-4.6/bin/../lib/gcc/arm-eabi/4.6.x-google/ -D__USES_INITFINI__ led_first_drv_test.c -quiet -dumpbase led_first_drv_test.c -march=armv5te -mfloat-abi=soft -mfpu=vfp -mabi=aapcs -auxbase led_first_drv_test -version -o /tmp/cc1mO9t2.s
GNU C (GCC) version 4.6.x-google 20120106 (prerelease) (arm-eabi)
compiled by GNU C version 4.4.3, GMP version 4.2.4, MPFR version 2.4.1, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/arm/arm-eabi-4.6/bin/../lib/gcc/arm-eabi/4.6.x-google/../../../../arm-eabi/include"
ignoring duplicate directory "/usr/local/arm/arm-eabi-4.6/bin/../lib/gcc/../../lib/gcc/arm-eabi/4.6.x-google/include"
ignoring nonexistent directory "/tmp/android-15472/install/sysroot/usr/local/include"
ignoring duplicate directory "/usr/local/arm/arm-eabi-4.6/bin/../lib/gcc/../../lib/gcc/arm-eabi/4.6.x-google/include-fixed"
ignoring nonexistent directory "/usr/local/arm/arm-eabi-4.6/bin/../lib/gcc/../../lib/gcc/arm-eabi/4.6.x-google/../../../../arm-eabi/include"
ignoring nonexistent directory "/tmp/android-15472/install/sysroot/usr/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include
/usr/local/arm/arm-eabi-4.6/bin/../lib/gcc/arm-eabi/4.6.x-google/include
/usr/local/arm/arm-eabi-4.6/bin/../lib/gcc/arm-eabi/4.6.x-google/include-fixed
End of search list.
GNU C (GCC) version 4.6.x-google 20120106 (prerelease) (arm-eabi)
compiled by GNU C version 4.4.3, GMP version 4.2.4, MPFR version 2.4.1, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 7e0a3541f55243241c747ff83ef85799
COLLECT_GCC_OPTIONS='-o' 'led_first_drv_test' '-I' '/usr/include' '-v' '-march=armv5te' '-mfloat-abi=soft' '-mfpu=vfp' '-mabi=aapcs'
/usr/local/arm/arm-eabi-4.6/bin/../lib/gcc/arm-eabi/4.6.x-google/../../../../arm-eabi/bin/as -v -I /usr/include -march=armv5te -mfloat-abi=soft -mfpu=vfp -meabi=5 -o /tmp/ccA1GPfG.o /tmp/cc1mO9t2.s
GNU assembler version 2.21 (arm-eabi) using BFD version (GNU Binutils) 2.21
COMPILER_PATH=/usr/local/arm/arm-eabi-4.6/bin/../libexec/gcc/arm-eabi/4.6.x-google/:/usr/local/arm/arm-eabi-4.6/bin/../libexec/gcc/:/usr/local/arm/arm-eabi-4.6/bin/../lib/gcc/arm-eabi/4.6.x-google/../../../../arm-eabi/bin/
LIBRARY_PATH=/usr/local/arm/arm-eabi-4.6/bin/../lib/gcc/arm-eabi/4.6.x-google/:/usr/local/arm/arm-eabi-4.6/bin/../lib/gcc/:/usr/local/arm/arm-eabi-4.6/bin/../lib/gcc/arm-eabi/4.6.x-google/../../../../arm-eabi/lib/
COLLECT_GCC_OPTIONS='-o' 'led_first_drv_test' '-I' '/usr/include' '-v' '-march=armv5te' '-mfloat-abi=soft' '-mfpu=vfp' '-mabi=aapcs'
/usr/local/arm/arm-eabi-4.6/bin/../libexec/gcc/arm-eabi/4.6.x-google/collect2 --sysroot=/tmp/android-15472/install/sysroot -X -o led_first_drv_test /usr/local/arm/arm-eabi-4.6/bin/../lib/gcc/arm-eabi/4.6.x-google/crti.o /usr/local/arm/arm-eabi-4.6/bin/../lib/gcc/arm-eabi/4.6.x-google/crtbegin.o /usr/local/arm/arm-eabi-4.6/bin/../lib/gcc/arm-eabi/4.6.x-google/../../../../arm-eabi/lib/crt0.o -L/usr/local/arm/arm-eabi-4.6/bin/../lib/gcc/arm-eabi/4.6.x-google -L/usr/local/arm/arm-eabi-4.6/bin/../lib/gcc -L/usr/local/arm/arm-eabi-4.6/bin/../lib/gcc/arm-eabi/4.6.x-google/../../../../arm-eabi/lib /tmp/ccA1GPfG.o --start-group -lgcc -lc --end-group /usr/local/arm/arm-eabi-4.6/bin/../lib/gcc/arm-eabi/4.6.x-google/crtend.o /usr/local/arm/arm-eabi-4.6/bin/../lib/gcc/arm-eabi/4.6.x-google/crtn.o
/usr/local/arm/arm-eabi-4.6/bin/../lib/gcc/arm-eabi/4.6.x-google/../../../../arm-eabi/bin/ld: cannot find -lc
collect2: ld returned 1 exit status
arm-linux-gcc test.c -o test -I/home/sec/sqlite3-arm/include -L/home/sec/sqlite3-arm/lib -lsqlite3
arm-eabi-gcc不支持编译linux应用
http://www.veryarm.com/296.html
换个版本
或者用android.mk
http://rpdzkj.cn/forum.php?mod=viewthread&tid=12&highlight=spi
#######################################################################################################
2017.7.26
1、编译程序总结。
注:arm-eabi-gcc 、arm-linux-gcc 均不能成功编译
arm-eabi-gcc:始终无法编译通过,原因:arm-eabi-gcc是Android ARM 编译器,arm-eabi-gcc不支持编译linux应用
arm-linux-gcc:生成的执行文件无法执行,原因:编译器可能冲突
1)下载安装:arm-none-linux-gnueabi-gcc 交叉编译
arm-2008q3-41-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2下载地址(http://blog.csdn.net/wangzhiyu1980/article/details/16972937包含有):
https://sourcery.mentor.com/sgpp/lite/arm/portal/package3397/public/arm-none-linux-gnueabi/arm-2008q3-41-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
参考:
http://blog.csdn.net/cbbbc/article/details/46708437
http://blog.csdn.net/wangzhiyu1980/article/details/16972937
2)安装配置
目录位置:cd /usr/local/arm
解压命令:sudo tar -jxvf arm-2008q3-41-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
环境配置:
sudo vi /etc/profile
添加路径:export PATH=$PATH:/usr/local/arm/arm-2008q3/bin
环境配置生效:source /etc/profile
3)编译文件
export CROSS_COMPILE=/usr/local/arm/arm-2008q3/bin/arm-none-linux-gnueabi-
arm-none-linux-gnueabi-gcc test.c -o test -static
注:必须使用静态库
未使用-static 运行程序是报错:No such file or directory
2、创建字符设备:
a.手动:
mknod /dev/xxx c 111 0 (mknod /dev/xxx c 主 次)
b.自动创建: mdev (根据系统信息创建节点)
cat /proc/devices
#######################################################################################################
2017.7.27
1、
由于需要对设备进行开发,在设备内核中添加文件,位置:/system/work
注:根目录和其他目录无法添加文件夹或者文件
2、写LED驱动
相同类型设备可以使用此设备号进行区分
#######################################################################################################
2017.7.28
1、驱动框架
a、构建结构体
file_operations
{
.open
.write
.read
}
b、入口函数里注册和出口函数卸载
c、给sysfs提供更多信息,udev机制 可以自动创建设备节点
2、Android测试程序脚本
#! /system/bin/sh
while true
do
sleep 1
./ledtest on
sleep 1
./ledtest off
done
注:#! /system/bin/sh 是Android中的sh,注意中间有空格
#!/bin/sh 是linux的脚本
#######################################################################################################
2017.8.1
后台运行
./sencondtest &
查看程序占用CUP资源
top
中断:
request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char * name, void * dev)
查看设备
cat /proc/devives
查看中断
cat /proc/interrupts
打开中断设备(以文件描述符5)
exec 5 /dev/key1)
关闭key1文件,释放中断:exec 5<&-
查看是否打开驱动设备:cat /proc/interrupts (没有了:68: 0 0 0 0 GPIO key1)
#######################################################################################################
2017.8.2
arm-none-linux-gnueabi-gcc
按键
应用程序去调用
驱动机制:查询、中断、poll
由驱动发信号给应用程序
驱动机制:异步信号
poll机制:中断驱动,应用程序进行查询时,如果没有发生中断,将read函数永远不会返回值;poll机制提供了超时返回。
异步通知(信号机制)
进程间发信号
eg:kill -9 PID
发 signal 接
目标:按下按键时,驱动通知应用程序,并在自定义signal_handle函数中read驱动
1、应用程序注册信号处理函数
2、谁发:驱动
3、发给谁 ==>app ==>app要告诉驱动PID
4、怎么发: kill_fasync
1、signal(SIGIO,signal_handle);
3、
fcntl(fd,F_SETOWN,getpid());
oflags = fcntl(fd,F_GETFL);
fcntl(fd, F_SETFL, oflags| FASYNC);
#######################################################################################################
2017.8.3
同步互斥
目的:同一时刻,只能有一个app应用程序打开 /dev/keys
1、原子操作
atomic_t v = ATOMIC_INIT(1); //定义原子变量并初始化为1
int atomic_dec_and_test(atomic_t *v); //自减操作后测试是否为0,为0则返回ture,否则返回false
atomic_dec(atomic_t *v); //原子变量减少1
atomic_inc(atomic_t *v); //原子变量增加1
2、信号量
信号量(semaphore)是用于保护临界区的一种常用方法,只有得到信号量的进程才能执行临界区代码
当获取不到信号量时,进程进入休眠等待状态
方法1:动态法
定义信号量
struct semaphore sem;
初始化信号量
void sema_init(struct semaphore * sem, int val); //val为初始化信号量的值
方法2:静态法
DEFINE_SEMAPHORE(name);//在新的内核中直接用semaphore
此时信号量被初始化为1,即互斥量。效果等同于DEFINE_MUTEX(name);
获取信号量:
void down(struct semaphore *sem);
int down_interruptible(struct semaphore *sem);
int down_trylock(struct semaphore *sem);
释放信号量
void up(struct semaphore *sem);
注:down () 函数现已不建议继续使用,建议使用 down_killable ()或 down_interruptible ()
3、阻塞
阻塞操作
是指在执行设备操作时,若不能获得资源则挂起进程,直到满足可操作的条件后再进行操作。
被挂起的进程进入休眠状态,被从调度器的运行队列移走,直到等待的条件被满足
fd = open(".....", O_RDWR); //阻塞
非阻塞操作
进程在不能进行设备操作时并不挂起,他或者放弃,或者不停的查询,直至可以进行操作位置。
fd = open(".....", O_RDWR | O_NONBLOCK); //非阻塞
#######################################################################################################
2017.8.4
去抖动:定时器
按键发生中断时,
中断函数中修改定时器启动时间于10ms后,
定时器时间到好,唤醒中断函数,上报按键值
输入子系统
之前写的按键驱动程序,只能自己使用,其他人用不了,因为不知道接口。
所以需要使用现成的驱动,即input子系统
输入子系统框架
1、input.c(核心层)
2、【右】向上注册input_register_handler【纯软件】 eg:evdev.c keyboard.c mousedev.c
2、【左】向上注册input_register_device【设备:代表硬件】
注册input_handler
input_register_handle
//放入数据
input_table[handler->minor >> 5] = handler;
//放入链表
list_add_tail(&handler->node, &input_handler_list);
//对于每个input_dev,调用input_attach_handler
list_for_each_entry(dev, &input_dev_list, node)
input_attach_handler(dev, handler);//根据input_attach_handler的id_table判断能否支持这个input_dev
注册输入设备:
input_register_device
//放入链表
list_add_tail(&dev->node, &input_dev_list);
//对应每一个input_handler,都调用input_attach_handler
list_for_each_entry(handler, &input_handler_list, node)
input_attach_handler(dev, handler);//根据input_attach_handler的id_table判断能否支持这个input_dev
input_attach_handler
id = input_match_device(handler, dev);
error = handler->connect(handler, dev, id);
注册input_dev或input_handler时,会两两比较左边的input_dev和右边的input_handler,
根据input_handler的id_table判断这个input_handler能否支持这个input_dev,
如果能支持,则调用inout_handler的connect函数建立连接
怎么建立连接?
1.分配一个input_handle结构体
2.
evdev->handle.dev = input_dev; //指向左边的input_dev
evdev->handle.handler = input_handler; //指向右边的input_handler
3.注册
input_dev->h_list = &input_handle
input_handler->h_list = &input_handle
evdev_connect
evdev = kzalloc(sizeof(struct evdev), GFP_KERNEL);//分配一个input_handle
//设备
evdev->handle.dev = input_get_device(dev); //指向左边的input_dev
evdev->handle.name = dev_name(&evdev->dev);
evdev->handle.handler = handler; //指向右边的input_handler
evdev->handle.private = evdev;
//注册handle
error = input_register_handle(&evdev->handle);
怎么读按键?
app: read
----------------------
.............
evdev_read
//休眠
retval = wait_event_interruptible(evdev->wait,
client->packet_head != client->tail ||
!evdev->exist);
谁来唤醒?
evdev_event
wake_up_interruptible(&evdev->wait);
evdev_event被谁调用?
在设备的中断服务程序中,确定事件是什么,然后调用相应的input_handler的event处理函数
按键中断定时器去抖动中断函数
gpio_keys_irq_timer
//上报事件
input_event(input, EV_KEY, bdata->button->code, 0);
input_sync(input);
void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
input_handle_event
if ((disposition & INPUT_PASS_TO_DEVICE) && dev->event)
dev->event(dev, type, code, value);//调用evdev_event
怎么写符合输入子系统框架的驱动程序?
1.分配一个input_dev结构体
2.设置
3.注册
4.硬件相关的代码,比如在中断服务程序里上报事件。
struct input_dev {
const char *name;
const char *phys;
const char *uniq;
struct input_id id;
unsigned long propbit[BITS_TO_LONGS(INPUT_PROP_CNT)];
unsigned long evbit[BITS_TO_LONGS(EV_CNT)]; //表示能产生哪类事件
unsigned long keybit[BITS_TO_LONGS(KEY_CNT)]; //表示能产生哪些按键
unsigned long relbit[BITS_TO_LONGS(REL_CNT)]; //表示能产生哪些相对位移事件,x,y,滚轮
unsigned long absbit[BITS_TO_LONGS(ABS_CNT)]; //表示能产生哪些绝对位移事件
unsigned long mscbit[BITS_TO_LONGS(MSC_CNT)];
unsigned long ledbit[BITS_TO_LONGS(LED_CNT)];
unsigned long sndbit[BITS_TO_LONGS(SND_CNT)];
unsigned long ffbit[BITS_TO_LONGS(FF_CNT)];
unsigned long swbit[BITS_TO_LONGS(SW_CNT)];
o SGl8023W
o A5SHB 场效应管
o S8050D J3Y 三极管
o 618 功率开关晶体管 三极管
o QX4054 BA4N 充电IC
o 105v胆电容
o 106c胆电容
双色灯珠
#######################################################################################################
2017.8.7
bus - drv - dev 模型
1、bus
2、【左边】device(硬件相关)
2、【右边】driver(比较稳定的代码)
driver
platform_driver_register
driver_register
1.把driver结构体放到bus的drv链表中
2.从bus的dev链表取出每一个dev,用bus的match函数判断dev能否支持drv
3.若可以支持,则调用drv的probe函数
device
platform_device_register
platform_device_add
device_add
1.把device放入bus的dev链表
2.从bus的drv链表取出每一个drv,用bus的match函数判断drv能否支持dev
3.若可以支持,则调用drv的probe函数
以上所述是一种左右建立联系的机制。
内核2.6版本
I2C驱动框架
APP: open, read, write
--------------------------------------------
驱动: drv_open, drv_read, drv_write
1、I2C设备驱动:知道数据含义
----------------------------
I2C总线驱动程序
1、识别
2、听过读写函数:知道如何收、发
--------------------------------------------
硬件: 具体的I2C设备
bus - drv - dev 模型
1、bus
2、【左边】device(适配器/插槽)
向上注册:i2c_add_adapter
2、【右边】driver(设备驱动程序)
向上注册:i2c_add_driver
device(client适配器/插槽)
I2C总线驱动程序
1、分配i2c_adapter
2、设置:algo = xxx
.master_xfer
3、注册:i2c_add_adapter
i2c_add_adapter
1、把i2c_adapter放入bus中的i2c_bus_type的链表中
2、调用drv的attach_adapter
3、i2c_probe(adapter,设备地址,function)
1、用adapter的master_xfer发信号,确定有无该设备
2、若有,则调用function
driver(设备驱动程序)
i2c_drivr
.attach_adapter 接到适配器上去
i2c_add_driver
i2c_register_driver
1、把i2c_driver放入bus中的i2c_bus_type的链表中
driver->driver.bus = &i2c_bus_type;
2、从adapter链表中取出“适配器”,调用drv的attach_adapter
res = driver_register(&driver->driver);
ret = bus_add_driver(drv);
error = driver_attach(drv);
3、i2c_probe(adapter,设备地址,function)
1、用adapter的master_xfer发信号,确定有无该设备
2、若有,则调用function
http://blog.csdn.net/lickylin/article/details/6692691
#######################################################################################################
2017.8.8
内核3.4版本
1. 框架
1.1 硬件协议简介
1.2 驱动框架
1.3 bus-drv-dev模型及写程序
a. 设备的4种构建方法
a.1 定义一个i2c_board_info, 里面有:名字, 设备地址
然后i2c_register_board_info(busnum, ...) (把它们放入__i2c_board_list链表)
list_add_tail(&devinfo->list, &__i2c_board_list);
链表何时使用:
i2c_register_adapter > i2c_scan_static_board_info > i2c_new_device
使用限制:必须在 i2c_register_adapter 之前 i2c_register_board_info
所以:不适合我们动态加载insmod
a.2 直接i2c_new_device, i2c_new_probed_device
a.2.1 i2c_new_device : 认为设备肯定存在
a.2.2 i2c_new_probed_device :对于"已经识别出来的设备"(probed_device),才会创建("new")
i2c_new_probed_device
probe(adap, addr_list[i]) /* 确定设备是否真实存在 */
info->addr = addr_list[i];
i2c_new_device(adap, info);
a.3 从用户空间创建设备
创建设备
echo at24c08 0x50 > /sys/class/i2c-adapter/i2c-0/new_device
导致i2c_new_device被调用
删除设备
echo 0x50 > /sys/class/i2c-adapter/i2c-0/delete_device
导致i2c_unregister_device
a.4 前面的3种方法都要事先确定适配器(I2C总线,I2C控制器)
如果我事先并不知道这个I2C设备在哪个适配器上,怎么办?去class表示的所有的适配器上查找
有上一些I2C设备的地址是一样,怎么继续分配它是哪一款?用detect函数
static struct i2c_driver at24cxx_driver = {
.class = I2C_CLASS_HWMON, /* 表示去哪些适配器上找设备 */
.driver = {
.name = "100ask",
.owner = THIS_MODULE,
},
.probe = at24cxx_probe,
.remove = __devexit_p(at24cxx_remove),
.id_table = at24cxx_id_table,
.detect = at24cxx_detect, /* 用这个函数来检测设备确实存在 */
.address_list = addr_list, /* 这些设备的地址 */
};
去"class表示的这一类"I2C适配器,用"detect函数"来确定能否找到"address_list里的设备",
如果能找到就调用i2c_new_device来注册i2c_client, 这会和i2c_driver的id_table比较,
如果匹配,调用probe
i2c_add_driver
i2c_register_driver
a. at24cxx_driver放入i2c_bus_type的drv链表
并且从dev链表里取出能匹配的i2c_client并调用probe
driver_register
b. 对于每一个适配器,调用__process_new_driver
对于每一个适配器,调用它的函数确定address_list里的设备是否存在
如果存在,再调用detect进一步确定、设置,然后i2c_new_device
/* Walk the adapters that are already present */
i2c_for_each_dev(driver, __process_new_driver);
__process_new_driver
i2c_do_add_adapter
/* Detect supported devices on that bus, and instantiate them */
i2c_detect(adap, driver);
for (i = 0; address_list[i] != I2C_CLIENT_END; i += 1) {
err = i2c_detect_address(temp_client, driver);
/* 判断这个设备是否存在:简单的发出S信号确定有ACK */
if (!i2c_default_probe(adapter, addr))
return 0;
memset(&info, 0, sizeof(struct i2c_board_info));
info.addr = addr;
// 设置info.type
err = driver->detect(temp_client, &info);
i2c_new_device
b. 驱动的写法
2. 完善设备驱动程序
3. 不自己写驱动直接访问
Device Drivers
I2C support
<*> I2C device interface
4. 编写"总线(适配器adapter)"驱动
Device Drivers
I2C support
I2C Hardware Bus support
< > S3C2410 I2C Driver
book:
深入理解android内核设计思想
深入理解android 卷3
#######################################################################################################
2017.8.9
多点触摸屏驱动程序
1 分配input_dev结构体
struct input_dev *ts_dev;
ts_dev = input_allocate_device();
2 设置
2.1 能产生哪类事件
set_bit(EV_SYN, ts_dev->evbit);
set_bit(EV_ABS, ts_dev->evbit);
2.2 能产生这类事件中的哪些
set_bit(ABS_MT_TRACKING_ID, ts_dev->absbit);
set_bit(ABS_MT_POSITION_X, ts_dev->absbit);
set_bit(ABS_MT_POSITION_Y, ts_dev->absbit);
2.3 这些事件的范围
//最大ID值由硬件决定
input_set_abs_params(ts_dev, ABS_MT_TRACKING_ID, 0, 最大ID值, 0, 0);
input_set_abs_params(ts_dev, ABS_MT_POSITION_X, 0, 最大X坐标, 0, 0);
input_set_abs_params(ts_dev, ABS_MT_POSITION_Y, 0, 最大Y坐标, 0, 0);
// Android会根据它找到配置文件
ts_dev->name = MTP_NAME;
3 注册
input_register_device(ts_dev);input_register_device(ts_dev);
4 硬件相关操作
4.1 注册中断
request_irq(…);
4.2 上报事件
4.2.1 按下/滑动
for(每个触点i) {
input_report_abs(ts_dev, ABS_MT_POSITION_X, x);
input_report_abs(ts_dev, ABS_MT_POSITION_Y, y);
input_report_abs(ts_dev, ABS_MT_TRACKING_ID, id);
input_mt_sync(ts_dev);
}
input_sync(ts_dev);
4.2.2 松开
//完成松开
input_mt_sync(ts_dev);
input_sync(ts_dev);
#######################################################################################################
2017.8.10
Android输入系统深入分析
1.输入系统框架
3. reader/dispatcher线程启动过程源码分析
4. Reader线程_使用EventHub读取事件
5. Reader线程_核心类及配置文件
6. Reader线程_核心类及配置文件_分析
7. Reader线程_简单处理
8. Dispatcher线程_总体框架
9. Dispatcher线程情景分析_Reader线程传递事件
10. Dispatcher线程情景分析_dispatch前处理
#######################################################################################################
2017.8.30
mipi屏驱动修改:1280*800
使用以前系统默认的配置参数
触摸屏改为ft5x06
IC:FT5426
ADDR:0x70
grep "TOUCHSCREEN_FT5X0X" Kconfig
Makefile
修改系统配置:make ARCH=arm menuconfig
添加文件:ft5x0x_ts_2.c ft5x0x_ts_2.h
修改Makefile
ft5x0x_ts.o == > ft5x0x_ts_2.o
修改驱动
修改设备名字
busybox i2cget -f -y 1 0x44 0x01 w
i2cget -f -y 1 0x38 0x01 w
busybox i2cget -f -y 1 0x88 0x01 w
] ft5x0x_ts_probe
[ 2.635000] msg ft5x0x_i2c_read i2c read error: -6
[ 2.727000] msg ft5x0x_i2c_read i2c read error: -6
[ 2.819000] msg ft5x0x_i2c_read i2c read error: -6
[ 2.911000] msg ft5x0x_i2c_read i2c read error: -6
#######################################################################################################
2017.9.5
触摸屏使用4412的驱动,兼容ft5406 和 ft5426
之前的问题是连接座有问题,scl和sda连接到一起,后来scl和gnd又连接到一起了
屏幕导航栏消失:
屏的右边一直有一栏黑色的,但没有导航栏。
第一种情况,DPI太大,导航栏出现在右侧或显示不出来,接HDMI的时候会出现溢出或不满。
第二种情况,DPI太小,显示的图标和字体偏小,触摸操作容易出现误操作。
如何改DPI
修改DPI就是要修改系统里的ro.sf.lcd_density这个变量的值
a) 修改
4418:lollipop_2nd_release\device\nexell\s5p4418_drone\device.mk
找到ro.sf.lcd_density这个变量,修改成你需要的值。一般常用的值120 160 240 320。其他值没有验证,用户可以自行验证。
此次修改10寸屏 值为:160
b)编译
如果用户已经编译过系统了,需要要手动删除
lollipop_2nd_release\out\target\product\s5p4418_drone\system\build.prop
接着编译android,编译完成后烧写system.img。
#######################################################################################################
2017.9.6
触摸屏设备驱动:
#define FT5X0X_NAME "ft5x0x_ts_2"
触摸屏设备:
.type = "ft5x0x_ts_2",
触摸屏配置文件:系统会根据设备名字对配置文件逐个访问匹配
总结来看安卓为输入设备打开配置文件依次会访问
/system/usr/idc/Vendor_XXXX_Product_XXXX_Version_XXXX.idc
/system/usr/idc/Vendor_XXXX_Product_XXXX.idc
/system/usr/idc/DEVICE_NAME.idc
/data/system/devices/idc/Vendor_XXXX_Product_XXXX_Version_XXXX.idc
/data/system/devices/idc/Vendor_XXXX_Product_XXXX.idc
/data/system/devices/idc/DEVICE_NAME.idc
但是:
如果在驱动里面定义了触摸类型,系统就不会去查找配置文件:
__set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
参考:韦东山视频Android 输入系统:第10课第22节_输入系统_多点触摸驱动程序_idc配置文件_P
摄像头驱动:
加载入口:V4l2框架
#if defined(CONFIG_V4L2_NXP) || defined(CONFIG_V4L2_NXP_MODULE)
printk("plat: add device nxp-v4l2\n");
platform_device_register(&nxp_v4l2_dev);
#endif
光感传感器驱动加载:
芯片类型:ISL29003
通信类型:i2c
地址:0x88>>1
查找所有".h"文件中的含有"helloworld"字符串的文件
find /PATH -name "*.h" | xargs grep -in "helloworld"
find ./ -name "build.gradle" | xargs grep -in "targetSdkVersion"
find ./ -name Kconfig | xargs grep -in "Miscellaneous I2C Chip support"
find ./ -name Kconfig | xargs grep -in "/bca2xx"
find ./ -name Kconfig | xargs grep -in "/misc"
grep -in "CONFIG_ISL29003"
修改配置:
device drivers
misc devices
[*]intersil isl29003 ambient light sensor
busybox find -name "lux"
cd /sys/devices/platform/i2c-gpio.1/i2c-1/1-0044/
busybox echo "0" > power_state
busybox echo 3 > range
busybox echo 1 > power_state
busybox i2cget -y -f 1 0x3a 0x02
busybox i2cget -f -y 1 0x44 0x02
add vale
00 40
01 00
02 00
03 00
busybox i2cset -y -f 1 0x44 0x00 0xa0
include\linux\
#######################################################################################################
2017.9.18
gpio定义文件:
u-boot\boart\s5p4418\drone\include\Cfg_gpio.h
对比 第四代网关 pro4418
1、充电指示灯 与软件无关 由核心板充电IC(axp228)控制
2、用户指示灯 4路用户指示灯 GPIOC24用于用户按键 LED1:GPIOC24 :CFG_GPIO_LED
1:GPIOD0 2:GPIOC9 3:GPIOC11 4:GPIOC12
3、红外 无 IR:GPIOD0 :CFG_IO_BUTTON_LG
4、耳机耳麦 NAU8822 WM8960 :MCU_AMP_EN :GPIOC4 :CFG_IO_AUDIO_AMP_POWER
5、4G U9300 EC20
6、GPS 内置于U9300 GPS模块 RXD3 TXD3 : GPIOE17 GPIOE10
#######################################################################################################
2017.9.19
gps源码位置:lollipop_2nd_release\hardware\samsung_slsi\drone
注:http://www.rpdzkj.cn/forum.php?mod=viewthread&tid=106&extra=page%3D4
如何去掉GPS模块,释放串口3
1、lollipop_2nd_release/device/nexell/s5p4418_drone/BoardConfig.mk
lollipop_2nd_release/device/nexell/s5p4418_drone/BoardConfig.mk
# GPS
BOARD_HAVE_RPDZKJ_GPS :=false //编译需要改成true
2、lollipop_2nd_release \out\target\product\s5p4418_drone\system\lib\hw\目录下的gps.slsiap.so库删掉,
然后重新编译android,如果此目录下没有生成gps.slsiap.so库文件,则证明修改成功
注:http://www.rpdzkj.cn/forum.php?mod=viewthread&tid=42&highlight=gps
查找所有".mk"文件中的含有"helloworld"字符串的文件
find ./ -name "*.mk" | xargs grep -in "sensors.$(TARGET_BOOTLOADER_BOARD_NAME)"
BoardConfig.mk
TARGET_BOARD_PLATFORM := slsiap
TARGET_BOOTLOADER_BOARD_NAME := s5p4418_drone
TARGET_CPU_ABI := armeabi-v7a
TARGET_CPU_ABI2 := armeabi
TARGET_CPU_SMP := true
TARGET_ARCH := arm
TARGET_ARCH_VARIANT := armv7-a-neon
TARGET_CPU_VARIANT := cortex-a9
ARCH_ARM_HAVE_TLS_REGISTER := true
TARGET_CPU_VARIANT2 := s5p4418
TARGET_NO_BOOTLOADER := false
TARGET_NO_KERNEL := false
TARGET_BOOTLOADER_IS_2ND := false
TARGET_NO_RADIOIMAGE := false
#######################################################################################################
2017.9.20
1.kernle/drivers/usb/serial/option.c中加入VID和PID
{ USB_DEVICE( 0x1c9e, 0x9b3c ) }
2如果拨号上网则配置PPP,make menuconfig后
Device Drivers --->
-*-Network device support --->
{*}ppp(point-to-point protocol) support
……
[*] ppp support for async serial ports
[*] ppp support for sync tty ports
……
一般选择以上即可,如果需要更多PPP服务,则PPP相关都选择上。
……
3.配置USB MODEM
Device Drivers --->
[*]USB support --->
[*]USB Serial Conerter support --->
[*]USB Generic Serial Driver
……
[*]USB driver for GSM and CDMA modems
……
重新编译内核。设备正常加载后,输入命令“ls /dev/ttyUSB*”后会看到有ttyUSB(0,1,2,-,-)映射出来。
系统应用部分:
1.在init.rc中加入下面服务,下面“-- -d /dev/ttyUSB(1,2,3,,)”部分使用哪个端口根据实际情况,若没有指定端口默认AT端口使用/dev/ttyUSB2,上网使用/dev/ttyUSB1
service ril-daemon /system/bin/rild -l /system/lib/libreference-ril-lslte.so -- -d /dev/ttyUSB2 -m /dev/ttyUSB1
class main
socket rild stream 660 root radio
socket rild-debug stream 660 radio system
user root
group radio cache inet misc audio sdcard_rw
service pppd_gprs /system/bin/init.gprs-pppd
socket rild-ppp stream 660 root radio
user root
group radio cache inet misc
disabled
on property:net.gprs.enable=1
start pppd_gprs
on property:net.gprs.enable=0
stop pppd_gprs
2.库及拨号脚本文件需要放在相应路径下,如下
cp init.gprs-pppd ../out/target/product/s5p4418_drone/system/bin/
// cp libreference-ril.so ../out/target/product/s5p4418_drone/system/lib/
cp libreference-ril.so ..\device\nexell\s5p4418_drone\rpdzkj\lib
3.更改init.gprs-pppd内对应拨号用的modem端口号,默认为/dev/ttyUSB1。
4.编译,重新生成镜像。
echo -e "AT+CGREG?\r\n" > /dev/ttyUSB2
echo -e "AT+CGMI=?\r\n" > /dev/ttyUSB2
echo -e "AT+CREG?\r\n" > /dev/ttyUSB2
echo -e "AT+COPS?\r\n" > /dev/ttyUSB2
echo -e "AT+CEREG?\r\n" > /dev/ttyUSB2
service ril-daemon /system/bin/rild -l /system/lib/libreference-ril.so -- -d /dev/ttyUSB2 -m /dev/ttyUSB1
rild -l /system/lib/libreference-ril.so -- -d /dev/ttyUSB2 -m /dev/ttyUSB1
rild -l /system/lib/libui.so
rild -l /sdcard/libreference-ril.so -- -d /dev/ttyUSB2 -m /dev/ttyUSB1
rild -l /sdcard/Download/libreference-ril.so -- -d /dev/ttyUSB2 -m /dev/ttyUSB1
service ril-daemon /system/bin/rild -l /sdcard/Download/libreference-ril.so -- -d /dev/ttyUSB2 -m /dev/ttyUSB1
rild -l /system/lib/libreference-ril.so
会报错:WARNING: linker: libreference-ril.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
相同文件放在其他位置不会报错
rild -l /sdcard/Download/libreference-ril.so
echo -e "ATD18037590150;" > /dev/ttyUSB2
echo -e -r -n "AT+CGMI=? \r" > /dev/ttyUSB2
AT+CGMI=?
busybox route add default gw 10.64.64.64
baidu
ping 119.75.217.109
ping 10.64.64.64
cat /dev/ttyUSB2
logcat -b radio
logcat ril-daemon:D *:S
rild -l /system/xxx/libreference-ril.so
busybox route add 10.64.64.64/32 dev ppp0
busybox ifconfig ppp0 10.74.58.1 netmask 255.255.255.0 broadcast 10.64.64.64
busybox route add default gw 10.52.5.201
logcat -b radio -b system -b main -v time
adb pull /system/xx/log.txt .
1、在加载U9300的库时候,会有以下提示:
WARNING: linker: libreference-ril.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
2、目前状况:打电话能够拨码成功,能够拨通;4G信号有,ip地址有,但是无法上网,并且ping 不同 10.64.64.64
解答:三星的不认10.64.64.64 ,找原厂更换库。
#######################################################################################################
2017.9.30
4G网络分享热点,设备连接上后无法上网:
解决:
vi /device/nexell/s5p4418_drone/overlay/frameworks/base/core/res/res/values/config.xml
注释掉
#######################################################################################################
2017.10.11
先找一下ubuntu里有没有背光控制的应用,如果没有就自己写应用来调用,修改这个
/sys/class/backlight/pwm-backlight/brightness
#######################################################################################################
2017.10.12
原理图分析:
模块 原理图 核心板引脚
蜂鸣器 GPIO3_Beep GPIO3
LED-G User_LED1 GPIOD0/PWM3
LED-G User_LED2 GPIOC9
LED-G User_LED3 GPIOC12
LED-G User_LED4 GPIOC11
S2 KEY_MENU GPIOC7
S3 KEY_HOME GPIOC29
S4 KEY_VOL+ GPIOB30
S5 KEY_VOL- GPIOB31
S6 KEY_BACK GPIOC27
S7 KEY_User1 GPIOC24
S8 KEY_User2 GPIOC5
4G WAKEUP_IN GPIOD8 (默认为唤醒状态,保持高电平)
4G WAKEUP_OUT GPIOC17
4G RST_4G GPIOB8
ISL29023 Light_INT GPIOD22
SP7685 Flash_EN GPIOD25
SP7685 Flash_Mode GPIOD24
磁力计 MAG_GPIOC30 GPIOC31
振子 VIB_GPIOC27 GPIOC30
三轴 BMA250_INT GPIOB25
开关机和复位按键:(预留)
NRESETIN_Zig、PWRKEY_Zig对应ZigBee(cc2530) P0.6 和 P0.7;
作用:通过ZigBee进行关机、复位,不能进行远程开机(主板3.3V电源由核心板控制,然后3.3V供电给ZigBee模块)
有效电平:高电平触发
注:当cc2530复位之后,所有的数字输入/输出引脚都设置为通用输入引脚;
在系统工作期间,应保持NRESETIN_Zig、PWRKEY_Zig为低电平。
ZigBee远程关机功能需要持续输出高电平。
音频:
WM8960GEFL更换为NAU8822,驱动复用WM8978的。
i2c设备地址0x1a(同WM8978完全一致)
注:NAU8822(管脚兼容WM8976,WM8978,ALC5621)
#######################################################################################################
2017.10.13
4G(U9300):
U9300C 模块休眠和唤醒控制接口
WAKEUP_IN H: DTE唤醒U9300C;
L: DTE让U9300C进入休眠模式。 ( 串口/USB不可用)
WAKEUP_OUT H: 模块处于唤醒模式,并且串口/USB处于可用状态;
L: 模块处于睡眠模式,并且串口/USB不可用。
AP应用端给的模块 WAKEUP_IN 的控制信号,用于控制模块的休眠唤醒
警告:RST_4G复位引脚的三极管控制端电阻未接!!!
注:
1、使用中模块上电后应保持模块 WAKEUP_IN 为高电平;
2、在 AP 端控制模块拉低 WAKEUP_IN 信号后,模块进入休眠模式, 此时如果有
电话/短信等唤醒模块后, AP 端检测到 WAKEUP_OUT 变为高电平时,应把 WAKEUP_IN信号同步拉高。
ZigBee模块:
1.与核心板串口3(T:GPIOD21 R:GPIOD17)数据通信(R:P0.2 T:P0.3)
2.远程控制设备关机、复位(预留):NRESETIN_Zig、PWRKEY_Zig对应ZigBee(cc2530) P0.6 和 P0.7
3.组网指示灯(P1.0),向节点下发数据指示灯(P1.3)
UART转USB:
芯片:ch340G
用途:FTDI设备通信
引脚:串口1(T:GPIOD19 R:GPIOD15)
stm32最小系统的模块接口详情:
can接口:PA12/CAN_TX
PA11/CAN_RX
----------------------------------------------------
核心板接口:PA10/USART1_RX TXD2 GPIOD20
PA9 /USART1_TX RXD2 GPIOD16
----------------------------------------------------
红外接口: PA8
----------------------------------------------------
NB-IoT模块接口:PC11/UART4_RX
PC10/UART4_TX
控制引脚: PC16、PB15、PB14
----------------------------------------------------
LoRa模块接口: PD2 /UART5_RX
PC12/UART5_TX
控制引脚: PA0、PA1、PA5
----------------------------------------------------
RS-485模块接口:PB10/USART3_TX
PB11/USART3_RX
半双工,读/写使能引脚: RD_485
----------------------------------------------------
预留调试串口接口: PA2/USART2_TX
PA3/USART2_RX
IPV6(ZigBee)模块:
1.与核心板串口4(T:GPIOB28 R:GPIOB29)数据通信(R:P0.2 T:P0.3)
2.组网指示灯(P1.0),向节点下发数据指示灯(P1.3)
I2C0复用: HDMI、 MIPI Camera、 音频NAU8822
I2C1复用: Touch、 light(新增)
I2C2复用: BMA250、 磁力计
light光感传感器:ISL29023
i2c:I2C1
中断引脚: Light_INT (GPIOD22)
磁力计:MAG3110
i2c:I2C2
中断引脚: MAG_GPIOC30 (GPIOC31)
三轴加速度:BMA250
i2c:I2C2
中断引脚: BMA250_INT (GPIOB25)
USB To UART:
驱动:兼用ch341
USB引脚:USBDN3_Send / USBDP3_Send
#######################################################################################################
2017.10.16
蜂鸣器、振子开机初始化
GPIO3、GPIOC30
u-boot修改:
lollipop_2nd_release\u-boot\board\s5p4418\drone\include\cfg_gpio.h
修改引脚默认配置。
#######################################################################################################
2017.10.17
ALIVEGPIO1 ~ ALIVEGPIO5分别在软件中对应PAD_GPIO_ALV + 1~5
OTG功能:
删除主从设备判断(去掉U10芯片),只保留从机模式,规避先插入OTG后无法启动的现象。
#######################################################################################################
2017.10.18
网关MIPI屏接口接触不良,无法正常显示。
192.168.98.207
192.168.98.248
[ 174.164000] usb 1-1.1: USB disconnect, device number 8
[ 174.171000] option1 ttyUSB1: GSM modem (1-port) converter now disconnected from ttyUSB1
[ 174.180000] option 1-1.1:1.0: device disconnected
[ 174.186000] option: option_instat_callback: error -108
[ 174.192000] option1 ttyUSB2: GSM modem (1-port) converter now disconnected from ttyUSB2
[ 174.201000] option 1-1.1:1.1: device disconnected
[ 174.202000] init: untracked pid 1398 exited with status 16
[ 174.212000] option: option_instat_callback: error -108
[ 174.219000] option1 ttyUSB3: GSM modem (1-port) converter now disconnected from ttyUSB3
[ 174.227000] option 1-1.1:1.2: device disconnected
[ 174.233000] option: option_instat_callback: error -108
[ 174.241000] option1 ttyUSB4: GSM modem (1-port) converter now disconnected from ttyUSB4
[ 174.251000] option 1-1.1:1.3: device disconnected
[ 174.257000] option: option_instat_callback: error -108
[ 174.264000] option1 ttyUSB5: GSM modem (1-port) converter now disconnected from ttyUSB5
[ 174.272000] option 1-1.1:1.4: device disconnected
[ 174.455000] usb 1-1.1: new high-speed USB device number 9 using nxp-ehci
[ 174.553000] usb 1-1.1: New USB device found, idVendor=1c9e, idProduct=9b3c
[ 174.560000] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 174.567000] usb 1-1.1: Product: USB Modem
[ 174.572000] usb 1-1.1: Manufacturer: LONGSUNG
[ 174.623000] option 1-1.1:1.0: GSM modem (1-port) converter detected
[ 174.630000] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB1
[ 174.638000] option 1-1.1:1.1: GSM modem (1-port) converter detected
[ 174.645000] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB2
[ 174.652000] option 1-1.1:1.2: GSM modem (1-port) converter detected
[ 174.660000] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB3
[ 174.667000] option 1-1.1:1.3: GSM modem (1-port) converter detected
[ 174.674000] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB4
[ 174.682000] option 1-1.1:1.4: GSM modem (1-port) converter detected
[ 174.689000] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB5
ttyUSB0
ttyUSB1
ttyUSB2
ttyUSB3
ttyUSB4
ttyUSB5
#######################################################################################################
2017.10.20
USB设备更新信息保存文件
/proc/tty/driver/usbserial
nmea
google earth
U9300C 枚举接口
Vendor ID:0x1C9E Product ID:0x9B3C
Interface Number Interface Function Interface Name
0 Debug Device Diagnostic Interface
1 Modem Modem Connector
2 AT Device Application Interface
3 Pipe Device Pipe
4 NDIS Wireless Data Device Ethernet Adapter
5 adb Android Composite ADB Interface lc
如是没有其他usb设备,U9300C 枚举的各个USB接口功能如上所示,
若有其他USB设备抢占了USB端口号,U9300C 枚举接口会逐个下移。
加上CH340串口模块,U9300C枚举的端口号后移:
ttyUSB0 //ch341-uart
ttyUSB1 //Debug
ttyUSB2 //Modem
ttyUSB3 //AT
ttyUSB4 //Pipe
ttyUSB5 //NDIS
注:没有断电就进行重启,由于4G模块始终处于供电状态,会造成遭遇CH340枚举USB
驱动修改点:
service ril-daemon /system/bin/rild -l /system/lib/libreference-ril-lslte.so -- -d /dev/ttyUSB2 -m /dev/ttyUSB1
==》
service ril-daemon /system/bin/rild -l /system/lib/libreference-ril-lslte.so -- -d /dev/ttyUSB3 -m /dev/ttyUSB2
xunfang@ubuntu:~/work/lollipop_2nd_release$ find -name "init.rc" | xargs ls -la
-rw-rw-r-- 1 xunfang xunfang 2942 Mar 24 2016 ./bootable/recovery/etc/init.rc
-rwxrw-r-- 1 xunfang xunfang 23076 Sep 22 10:41 ./out/target/product/s5p4418_drone/obj/ETC/init.rc_intermediates/init.rc
-rw-rw-r-- 1 xunfang xunfang 2942 Sep 30 16:26 ./out/target/product/s5p4418_drone/recovery/root/init.rc
-rw-r--r-- 1 xunfang xunfang 23075 Sep 30 16:53 ./out/target/product/s5p4418_drone/root/init.rc
-rw-r--r-- 1 xunfang xunfang 23075 Sep 30 16:53 ./result/root/init.rc
-rwxrw-r-- 1 xunfang xunfang 23076 Sep 20 16:58 ./system/core/rootdir/init.rc
拨打电话无法拨出
打印信息输出到1.log
logcat -b radio -b main -b system -v time 1>1.log
电脑端cmd,adb上传文件
adb pull 1.log .
GPS:
vi device/nexell/s5p4418_drone/BoardConfig.mk
编译GPS模块:ture
BOARD_HAVE_RPDZKJ_GPS :=true
去掉编译模块:false
BOARD_HAVE_RPDZKJ_GPS :=false
vi hardware/samsung_slsi/drone/librpdkzj-gps/gps_mstar.c
#define MSTAR_DEVICES "/dev/ttyAMA3"
#define MSTAR_DEVICES "/dev/ttyUSB4"(失败)
注:ttyUSB4为4G模块PIPE端口
#define MSTAR_DEVICES "/dev/ttyUSB3"
注:ttyUSB3为4G模块at端口
echo -e "AT+GPSSTART=1 \r\n" > /dev/ttyUSB3
echo -e "At+gpsstart=? \r\n" > /dev/ttyUSB3
cat /dev/ttyUSB3
AT+GPSEND
配置:
echo -e "AT+GPSCONFIG=20,180,9999999,1,2 \r\n" > /dev/ttyUSB3
echo -e "AT+GPSCONFIG=20,180,9999999,1,2,1 \r\n" > /dev/ttyUSB3
echo -e "AT+GPSCONFIG? \r\n" > /dev/ttyUSB3
设置
echo -e "AT+GPSMODE=1 \r\n" > /dev/ttyUSB3
启动
echo -e "AT+GPSSTART=1 \r\n" > /dev/ttyUSB3
停止
echo -e "AT+GPSEND \r\n" > /dev/ttyUSB3
cat /dev/ttyUSB4 1>2.nmea &
logcat *:S gps_mstar:D -v time
#######################################################################################################
2017.10.25
4G模块GPS无有效数据输出原因:天线应匹配无源GPS天线
shell脚本编写:
#!/system/bin/sh
while [ ! -c /dev/ttyUSB3 ]; do
# sleep 1 防止 cpu 占用率过高
echo "no"
sleep 1
done
echo "yes"
内核启动,加载枚举4G模块USB端口,系统需要检查枚举的USB端口,然后发送AT命令配置、启动GPS功能
开机执行脚本,循环检测ttyUSB3、ttyUSB4结点
编写gps.sh文件如下:
#!/system/bin/sh
while [ ! -c /dev/ttyUSB3 ]; do
# sleep 4 防止 cpu 占用率过高
echo "/dev/ttyUSB3 non-existent "
sleep 4
done
echo "/dev/ttyUSB3 exist "
while [ ! -c /dev/ttyUSB4 ]; do
# sleep 1 防止 cpu 占用率过高
echo "/dev/ttyUSB4 non-existent "
sleep 4
done
echo "/dev/ttyUSB4 exist "
echo -e "AT+GPSCONFIG=20,180,9999999,1,2,1 \r\n" > /dev/ttyUSB3
echo -e "AT+GPSSTART=1 \r\n" > /dev/ttyUSB3
echo "The GPS have start !!! "
cd
find ./ -name "*.mk" | xargs grep -in "adj_lowmem.sh"
修改device/nexell/s5p4418_drone/device.mk
device/nexell/s5p4418_drone/adj_lowmem.sh:root/adj_lowmem.sh \
device/nexell/s5p4418_drone/gps.sh:system/gps.sh
# device/nexell/s5p4418_drone/bootanimation.zip:system/media/bootanimation.zip
xunfang@ubuntu:~/work/lollipop_2nd_release$ find ./ -name "*.rc" | xargs grep -in "adj_lowmem.sh"
./out/target/product/s5p4418_drone/root/init.s5p4418_drone.rc:268:service adjlowmem /adj_lowmem.sh
./result/root/init.s5p4418_drone.rc:268:service adjlowmem /adj_lowmem.sh
./device/nexell/s5p6818_drone/init.s5p6818_drone.rc:242:service adjlowmem /adj_lowmem.sh
./device/nexell/s5p6818_drone/init.s5p6818_drone64.rc:238:service adjlowmem /adj_lowmem.sh
./device/nexell/lepus/init.lepus.rc:244:service adjlowmem /adj_lowmem.sh
./device/nexell/s5p4418_drone/init.s5p4418_drone.rc:268:service adjlowmem /adj_lowmem.sh
####### eeboard申请GD32
chown root shell /system/gps.sh
chmod 0777 /system/gps.sh
service gpsstart /system/gps.sh
class main
user root
group root
oneshot
init: cannot execve('/system/gps.sh'): Permission denied
system/core/include/private/android_filesystem_config.h
static struct fs_path_config android_files[] = {
{ 00755, AID_ROOT, AID_SHELL, 0, "system/gps.sh" },
disabled
on property:net.gprs.enable=1
start gpsstart
on property:net.gprs.enable=0
stop gpsstart
#!/system/bin/sh
echo "GPS start \r\n" >> GPS.log
while [ ! -c /dev/ttyUSB3 ]; do
# sleep 4 ...... cpu .......... echo
sleep 4
echo "/dev/ttyUSB3 non-existent \r\n" >> GPS.log
done
echo "/dev/ttyUSB3 exist " >> GPS.log
while [ ! -c /dev/ttyUSB4 ]; do
# sleep 1 ...... cpu .......... echo
sleep 4
echo "/dev/ttyUSB4 non-existent \r\n" >> GPS.log
done
echo "/dev/ttyUSB4 exist " >> 2.log
echo -e "AT+GPSCONFIG=20,180,9999999,1,2,1 \r\n" > /dev/ttyUSB3
sleep 1
echo -e "AT+GPSCONFIG=20,180,9999999,1,2,1 \r\n" > /dev/ttyUSB3
sleep 1
echo -e "AT+GPSCONFIG=20,180,9999999,1,2,1 \r\n" > /dev/ttyUSB3
sleep 1
echo -e "AT+GPSCONFIG=20,180,9999999,1,2,1 \r\n" > /dev/ttyUSB3
sleep 1
echo -e "AT+GPSCONFIG=20,180,9999999,1,2,1 \r\n" > /dev/ttyUSB3
sleep 1
echo -e "AT+GPSCONFIG=20,180,9999999,1,2,1 \r\n" > /dev/ttyUSB3
sleep 1
echo -e "AT+GPSCONFIG=20,180,9999999,1,2,1 \r\n" > /dev/ttyUSB3
sleep 1
echo -e "AT+GPSSTART=1 \r\n" > /dev/ttyUSB3
sleep 1
echo -e "AT+GPSSTART=1 \r\n" > /dev/ttyUSB3
sleep 1
echo -e "AT+GPSSTART=1 \r\n" > /dev/ttyUSB3
sleep 1
echo -e "AT+GPSSTART=1 \r\n" > /dev/ttyUSB3
sleep 1
echo -e "AT+GPSSTART=1 \r\n" > /dev/ttyUSB3
sleep 1
echo -e "AT+GPSSTART=1 \r\n" > /dev/ttyUSB3
sleep 1
echo -e "AT+GPSSTART=1 \r\n" > /dev/ttyUSB3
sleep 1
echo "The GPS have start !!! " >> GPS.log
./sys/devices/platform/i2c-gpio.1/i2c-1/1-0044/lux
echo 5 > /sys/devices/platform/i2c-gpio.1/i2c-1/1-0044/mode
sleep 1
echo 5 > /sys/devices/platform/i2c-gpio.1/i2c-1/1-0044/mode
sleep 1
echo 1 > /sys/devices/platform/i2c-gpio.1/i2c-1/1-0044/power_state
sleep 1
echo 1 > /sys/devices/platform/i2c-gpio.1/i2c-1/1-0044/power_state
sleep 1
find ./ -name "*.*" | xargs grep -in "/sys/devices/platform/s3c2440-i2c.5/i2c-5/5-0044/mode"
#!/system/bin/sh
echo 5 > /sys/devices/platform/i2c-gpio.1/i2c-1/1-0044/mode
sleep 1
cat /sys/devices/platform/i2c-gpio.1/i2c-1/1-0044/mode >> GPS.log
sleep 1
echo 1 > /sys/devices/platform/i2c-gpio.1/i2c-1/1-0044/power_state
sleep 1
cat /sys/devices/platform/i2c-gpio.1/i2c-1/1-0044/power_state >> GPS.log
sleep 1
#######################################################################################################
2017.10.27
isl29023 光敏传感器:
1.加载完驱动后,无法获取lux值
cat /sys/devices/platform/i2c-gpio.1/i2c-1/1-0044/lux
原因:未使能
power_state:
0: device is disabled (default)
1: device is enabled
2、加载完驱动后,获取lux值 不变
cat /sys/devices/platform/i2c-gpio.1/i2c-1/1-0044/lux
原因:未使能
mode:
ISL29023_PD_MODE 0x0
ISL29023_ALS_ONCE_MODE 0x1
ISL29023_IR_ONCE_MODE 0x2
ISL29023_ALS_CONT_MODE 0x5
ISL29023_IR_CONT_MODE 0x6
解决方法:
添加脚本,并且分开写(两个文件操作,只有后者有效)
power_state.sh
#!/system/bin/sh
echo 1 > /sys/devices/platform/i2c-gpio.1/i2c-1/1-0044/power_state
mode.sh
#!/system/bin/sh
echo 5 > /sys/devices/platform/i2c-gpio.1/i2c-1/1-0044/mode
在gps.sh中添加启动
/system/mode.sh
/system/power_state.sh
修改权限:
chmod 777 /system/mode.sh
chmod 777 /system/power_state.sh
测试:
cat /sys/devices/platform/i2c-gpio.1/i2c-1/1-0044/lux
#######################################################################################################
2017.10.30
find ./ -name "*sensor*" | xargs grep -in "Accelerometer" 1 > sensor.log &
获取输入设备:
getevent -i
add device 3: /dev/input/event0
bus: 0018
vendor 0000
product 0000
version 0000
name: "isl29023 light sensor"
location: "1-0044"
id: ""
version: 1.0.1
events:
ABS (0003): 0028 : value 0, min 0, max 11405, fuzz 0, flat 0, resolution 0
input props:
add device 4: /dev/input/event4
bus: 0018
vendor 0000
product 0000
version 0000
name: "bma2x2"
location: ""
id: ""
version: 1.0.1
events:
REL (0002): 0001 0002 0006 0007 0008 0009
ABS (0003): 0000 : value 30, min -512, max 512, fuzz 0, flat 0, resolution 0
0001 : value 0, min -512, max 512, fuzz 0, flat 0, resolution 0
0002 : value -290, min -512, max 512, fuzz 0, flat 0, resolution 0
0018 : value 0, min 0, max 0, fuzz 0, flat 0, resolution 0
0019 : value 0, min 0, max 0, fuzz 0, flat 0, resolution 0
input props:
logcat *:S sensor:D -v time
find ./lollipop_2nd_release -name "*.cpp" | xargs grep -in "bma2x2" 1 > bma1.log &
find ./lollipop_2nd_release -name "*.c" | xargs grep -in "bma2x2" 1 > bma2.log &
find ./lollipop_2nd_release -name "*.java" | xargs grep -in "bma2x2" 1 > bma3.log &
find ./lollipop_2nd_release -name "*.mk" | xargs grep -in "bma2x2" 1 > bma4.log &
find ./lollipop_2nd_release -name "*.cpp" | xargs grep -in "open_sensors" 1 > open.log &
ro.hardware.sensors
sensors.s5p4418_drone.so
find ./lollipop_2nd_release -name "*.mk" | xargs grep -in "sensors" | xargs grep -in "s5p4418_drone" 1 > s5p4418_drone.log &
grep -rn "8960" * 1 > 8960.log &
#######################################################################################################
2017.10.31
音频:
WM8960GEFL更换为NAU8822,驱动复用WM8978的。
i2c设备地址0x1a(同WM8978完全一致)
注:NAU8822(管脚兼容WM8976,WM8978,ALC5621)
#if defined(CONFIG_SND_CODEC_WM8976) || defined(CONFIG_SND_CODEC_WM8976_MODULE)
#include
#define WM8976_I2C_BUS (0)
/* CODEC */
static struct i2c_board_info __initdata wm8976_i2c_bdi = {
.type = "wm8978", // compatilbe with wm8976
.addr = (0x34>>1), // 0x1A (7BIT), 0x34(8BIT)
};
/* DAI */
struct nxp_snd_dai_plat_data i2s_dai_data = {
.i2s_ch = 0,
.sample_rate = 48000,
.hp_jack = {
.support = 1,
.detect_io = PAD_GPIO_E + 8,
.detect_level = 1,
},
};
static struct platform_device wm8976_dai = {
.name = "wm8976-audio",
.id = 0,
.dev = {
.platform_data = &i2s_dai_data,
}
};
#endif
CONFIG_SND_CODEC_WM8976_MODULE
tristate "Build WM8978 CODEC drivers"
default n
help
driver support wm8978
i2cget
i2cdetect -l
i2cdump -y 0 0x1a
旧版:
static struct i2c_board_info i2c_devs4_wm8978[] __initdata = {
{
I2C_BOARD_INFO("wm8978", 0x1a),
},
};
s3c_i2c4_set_platdata(NULL);
i2c_register_board_info(4, i2c_devs4_wm8978, ARRAY_SIZE(i2c_devs4_wm8978));
static struct platform_device samsung_audio = {
.name = "SOC-AUDIO-SAMSUNG",
.id = -1,
};
static struct platform_device *smdk4x12_devices[] __initdata = {
&samsung_audio,
}
platform_add_devices(smdk4x12_devices, ARRAY_SIZE(smdk4x12_devices));
新版:
#include
#define WM8976_I2C_BUS (0)
/* CODEC */
static struct i2c_board_info __initdata wm8976_i2c_bdi = {
.type = "wm8960", // compatilbe with wm8976
.addr = (0x34>>1), // 0x1A (7BIT), 0x34(8BIT)
};
struct nxp_snd_dai_plat_data i2s_dai_data = {
.i2s_ch = 0,
.sample_rate = 48000,
.pcm_format = SNDRV_PCM_FMTBIT_S16_LE,
.hp_jack = {
.support = 1,
.detect_io = PAD_GPIO_B + 27,
.detect_level = 1,
},
};
static struct platform_device wm8976_dai = {
.name = "wm8976-audio",
.id = 0,
.dev = {
.platform_data = &i2s_dai_data,
}
};
i2c_register_board_info(WM8976_I2C_BUS, &wm8976_i2c_bdi, 1);
platform_device_register(&wm8976_dai);
#######################################################################################################
2017.10.31
1、修改配置
2、硬件连接 CSB/GPIO1 ----------- GPIOC4
3、修改注册i2c i2s
相关源码:
kernel\sound\soc\nexell\nxp-wm8978.c
kernel\sound\soc\codecs\wm8978.c
kernel\arch\arm\plat-s5p4418\drone\device.c
#######################################################################################################
2017.11.9
1、添加mag3110.c驱动文件
2、在kernel\arch\arm\plat-s5p4418\drone\device.c中注册I2C设备
3、修改\kernel\drivers\hwmon\Makefile 修改\kernel\drivers\hwmon\Kconfig
4、make ARCH=arm menuconfig 配置加载mag3110驱动,并配置加载input-polldev (CONFIG_INPUT_POLLDEV)
#if defined(CONFIG_SENSORS_MAG3110)
#define MAG3110_I2C_BUS (2)
/* CODEC */
static struct i2c_board_info __initdata mag3110_i2c_bdi = {
.type = "mag3110",
.addr = 0x0E,
.irq = PB_PIO_IRQ(CFG_IO_MAG3110_INT),
};
#endif
#if defined(CONFIG_SENSORS_MAG3110)
//TP_I2C_BUS I2C共用
printk("plat: add light(mag3110) device\n");
i2c_register_board_info(MAG3110_I2C_BUS, &mag3110_i2c_bdi, 1);
#endif
#######################################################################################################
2017.11.10
getevent -i
cat /proc/bus/input/devices
logcat -s Sensors
D/Sensors ( 399): the sSensorList[0] is isl29023 light sensor
D/Sensors ( 399): the mSensors[light] is 0
D/Sensors ( 399): LightSensor::LightSensor()
D/Sensors ( 399): the sSensorList[1] is BMA255 3-axis Accelerometer
D/Sensors ( 399): the mSensors[accel] is 0
D/Sensors ( 399): AccelerationSensor::AccelerationSensor()
D/Sensors ( 399): AccelerationSensor::input_sysfs_path : /sys/class/input/event5/device/
D/Sensors ( 399): LightSensor::~enable(0, 0)
D/Sensors ( 399): AccelerationSensor::~enable(0, 0)
D/Sensors ( 399): AccelerationSensor::~enable(0, 1)
D/Sensors ( 399): AccelerationSensor::~setDelay(0, 66667000)
D/Sensors ( 399): LightSensor::~enable(0, 1)
D/Sensors ( 399): LightSensor::~enable(0, 1)
cat /sys/devices/platform/i2c-gpio.1/i2c-1/1-0044/mode
#######################################################################################################
2017.11.14
光传感器移植总结:
1、https://community.nxp.com/thread/384502
数据为上报:
驱动中模式加载应该为中单、并且需要启动线程:schedule_work(&data->work);
在线程中循环上报
2、待解决问题:不会进入中断
#######################################################################################################
2017.11.17
wm8978数据手册:
引脚功能:
LIP:同相放大连接端
LIN:反相接线端
L2 :同连接端
#######################################################################################################
2018.01.27
home按键无法上报
你在device目录中keypad_s5p4418_drone.kl中添加这个按键事件
key 172 HOMEPAGE WAKE
记得删除out目录中的keypad_s5p4418_drone.kl
振子:
echo 4000 > /sys/devices/virtual/misc/xf_vibrator/vibrator_time
logcat *:S vibrator:D -v time
logcat *:S VibratorService:D