Android: Hass platform Miscellany

am startservice -n com.xbh.distributor.menu/.app.TvMenuWindowManagerService -e com.xbh.distributor.menu.commmand com.xbh.distributor.menu.commmand.factory_menu\n

9c:f6:dd:b1:71:8c

source Customer/build.sh Customer/customer/lango/LANGO_001_XMH811B_4096M_32G.cus
repo forall -c 'git branch -v'


XBHV811:/ # echo read 5 3 > /proc/msp/gpio
[ 610.180579] Value [5][3] = low
XBHV811:/ # echo read 5 2 > /proc/msp/gpio
[ 611.331131] Value [5][2] = high

 

] [Rtc drive adapter
(1) modify the kernel configuration file, rtc compiled module (rtc-hym8563) driving
the Z: \ Workspace \ XBHV811 \ the Customer \ toolchains \ Board \ XMH811B \ hi3751v810_arm64_android_defconfig
# CONFIG_RTC_DRV_HYM8563 IS SET Not changed: CONFIG_RTC_DRV_HYM8563 = m

(2) adding i2c bus driver
Z: \ workSpace \ XBHV811 \ device \ hisilicon \ bigfish \ sdk \ source \ msp \ drv \ i2cbus
and modified Z: \ workSpace \ XBHV811 \ device \ hisilicon \ bigfish \ sdk \ source \ msp \ drv \ Makefile: objects + = i2cbus


(3) modify dtsi, increasing the device information corresponding platform: Z: \ workSpace \ XBHV811 \ device \ hisilicon \ bigfish \ sdk \ source \ kernel \ linux-4.9.y \ arch \ arm64 \ boot \ dts \ hisilicon \ hi3751v81x.dtsi
increase i2c port ----------------------------------------------- -------------
// Start by gerhard.lao XBH Patch
I2C0: @ f8b10000 {I2C
compatible = "hisilicon, hisilicon-I2C";
bus_num = <0>;
Status = "Okay";
};

i2c1: i2c@f8b11000 {
compatible = "hisilicon,hisilicon-i2c";
bus_num = <1>;
status = "okay";
};

i2c2: i2c@f8b12000 {
compatible = "hisilicon,hisilicon-i2c";
bus_num = <2>;
status = "okay";
};

i2c3: i2c@f8b13000 {
compatible = "hisilicon,hisilicon-i2c";
bus_num = <3>;
status = "okay";
};

i2c4: i2c@f8b1d000 {
compatible = "hisilicon,hisilicon-i2c";
bus_num = <4>;
status = "okay";

hym8563: hym8563@a3 {
compatible = "haoyu,hym8563";
reg = <0xa3>;
};
};
//xbh patch end

(4)
./Customer/compile.sh kernel (建议先rm -rf out/target/product/Hi3751V811/obj/KERNEL_OBJ/),生成kernel.img和dtb在 Z:\workSpace\XBHV811\out\target\product\Hi3751V811\Emmc目录下,烧录指令如下:
dd if=/mnt/media_rw/sda4/kernel.img of=/dev/block/platform/soc/f9830000.emmc/by-name/kernel
dd if=/mnt/media_rw/sda4/Hi3751V811.dtb of=/dev/block/platform/soc/f9830000.emmc/by-name/dtb


Refer to: https: //blog.csdn.net/zhangweihui123/article/details/78581847

Debug command:
logcat -v -b Time Kernel | grep below -ie hisilicon_i2c_probe below -ie HYM8563
logcat -v Time | grep below -ie AlarmManager

adb shell "busybox hwclock -r"
adb shell "insmod /vendor/lib64/modules/rtc-hym8563.ko"

app-> kernel call flow:

app方法:AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Z:\workSpace\XBHV811\frameworks\base\core\java\android\app\AlarmManager.java
---》public void setTime(long millis)
Z:\workSpace\XBHV811\frameworks\base\services\core\java\com\android\server\AlarmManagerService.java
Z:\workSpace\XBHV811\frameworks\base\services\core\jni\com_android_server_AlarmManagerService.cpp
---》android_server_AlarmManagerService_setKernelTime
---》int AlarmImpl::setTime(struct timeval *tv)
---》res = ioctl(fd, RTC_SET_TIME, &rtc);
Z:\workSpace\XBHV811\device\hisilicon\bigfish\sdk\source\kernel\linux-4.9.y\drivers\rtc\rtc-dev.c ---》rtc_dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
Z:\workSpace\XBHV811\device\hisilicon\bigfish\sdk\source\kernel\linux-4.9.y\drivers\rtc\rtc-hym8563.c


服务启动过程:
Z:\workSpace\XBHV811\frameworks\base\services\java\com\android\server\SystemServer.java
---》mSystemServiceManager.startService(AlarmManagerService.class);
Z:\workSpace\XBHV811\frameworks\base\services\core\java\com\android\server\AlarmManagerService.java
---》 onStart()
---》init()
Z:\workSpace\XBHV811\frameworks\base\services\core\jni\com_android_server_AlarmManagerService.cpp
---》
static const JNINativeMethod sMethods[] = {
/* name, signature, funcPtr */
{"init", "()J", (void*)android_server_AlarmManagerService_init},
{"close", "(J)V", (void*)android_server_AlarmManagerService_close},
{"set", "(JIJJ)V", (void*)android_server_AlarmManagerService_set},
{"waitForAlarm", "(J)I", (void*)android_server_AlarmManagerService_waitForAlarm},
{"setKernelTime", "(JJ)I", (void*)android_server_AlarmManagerService_setKernelTime},
{"setKernelTimezone", "(JI)I", (void*)android_server_AlarmManagerService_setKernelTimezone},
};

RTC related interfaces

HY8563 RTC module
reads the RTC time:
|| i2c_channel device_addr register_addr register_addr_len read_bytes_number

i2c_read 0x04 0xa3 0x02 0x01 0x07
data read:
0x10 0x51 0x04 0x14 0x12 0x06 0x48
second: 0x10
minute: 0x51
hour: 0x04
date: 0x14
week: 0x12 & 0x07
month: 0x06
year: 0x48 + 1970

Write RTC time:
i2c_write 0xA3 0x04 0x02 0x01 0x07 0x10 0x51 0x04 0x14 0x12 0x06 0x48

Read RTC timer switch:
i2c_read 0x01 0x01 0x01 0x04 0xA3
Data Read:
0x02
bit1 1 to start to close to 0
is written RTC timer switch
i2c_write 0x04 0xa3 0x01 0x01 0x01 0x00

Write RTC timer time
i2c_write 0x04 0xa3 0x09 0x01 0x04 0x51 0x04 0x14 0x02

Testing RTC wake-up command:
i2c_write 0x04 0xA3 0x01 0x01 0x01 0x02
i2c_write 0x04 0xA3 0x02 0x01 0x07 0x50 0x51 0x04 0x14 0x12 0x06 0x48
i2c_write 0x04 0xA3 0x09 0x01 0x04 0x52 0x04 0x14 0x02
i2c_read 0x04 0xA3 0x02 0x01 0x07
view RTC interrupt IO there is no level, HY8563 interrupt pin should be set low.


24V open detection
i2c_write 0x01 0x4C 0x80 0x01 0x04 0x03 0x23 0x01 0xA1
off 24V detection
i2c_write 0x01 0x4C 0x80 0x01 0x04 0x03 0x23 0x00 0xA0

Open all detected
i2c_write 0x01 0x4C 0x80 0x01 0x04 0x03 0xFF 0x01 0x7D
close all detected
i2c_write 0x01 0x4C 0x80 0x01 0x04 0x03 0xFF 0x00 0x7C

echo write 5 3 0 > /proc/msp/gpio
echo write 5 2 1 > /proc/msp/gpio

echo write 5 3 0 > /proc/msp/gpio
echo write 5 2 0 > /proc/msp/gpio

Guess you like

Origin www.cnblogs.com/blogs-of-lxl/p/11588820.html