BLOZI 10.1寸LCD价签折腾记1-软硬件分析

分析BLOZI 10.1寸LCD价签的软硬件

价格

30元一块,商家有买五送一,加上邮费15,最后165拿下6块,平均每块27.5

配置

MCU:F1C200S

存储:MXIC的1G NandFlash

WIFI:XR819

MIPI:SSD2828

屏幕:10.1寸LCD 1280*800,型号未知

连接

原装使用Type-C进行供电和数据传输

拆开可以发现Type-C板与主板由四组共八个弹簧座-触点连接,分别为DM、DP、IN+、IN-

在弹簧座旁有RXD、TXD、DM、DP、3.3V、12V、GND的触点,暂未测试

提示

据论坛所述,在开启WIFI后可能存在供电不足导致屏幕闪烁的问题,需要焊接TRR(-)接IN-测试点,IN+测试点接R57(R)

ADB连接

使用Type-C线缆直连设备和电脑,若非直连可能无法正常识别

若需打驱动可以参考知乎:# LCPI(F1C200S)+如何在Windows 下安装驱动?

使用adb shell可以直连设备

警告

根据后续一次事故表明,若/空间不足或busybox配置有问题则ADB将会失效

具体原因仍需分析

系统基础信息

账号密码

默认账号为root,默认密码为tina

系统版本

手动打开自启程序bloziplayer输出显示系统为全志基于openWRT制作的tina系统,版本为3.5

1
2
3
4
5
6
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> tina_multimedia <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
tag   : tina3.5
branch: tina-dev
date  : Mon Jul 15 19:04:59 2019 +0800
Change-Id: I5f6c8a88d7b387a312b7744797a0d5f8ab07ee7a
-------------------------------------------------------------------------------

使用uname获取Linux信息可得系统版本为3.10.65

1
2
3
> uname -a  

Linux TinaLinux 3.10.65 #526 Tue Mar 1 04:28:42 UTC 2022 armv5tejl GNU/Linux  

通过输出/etc/openwrt_version/etc/openwrt_release可得更多详细信息

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
> cat /etc/openwrt_version  

3.5.1  

> cat /etc/openwrt_release  

DISTRIB_ID='tina.jason.20220301.042736'  

DISTRIB_RELEASE='Neptune'  

DISTRIB_REVISION='5C1C9C53'  

DISTRIB_TARGET='c200s-F1C200s/generic v2.1'  

DISTRIB_DESCRIPTION='tina.jason.20220301.042736 3.5.1'  

DISTRIB_TAINTS='no-all no-ipv6'  

总结来说就是系统是系统是基于OpenWRT 3.5.1Tina Linux 3.10.65 同时推测bloziplayerDISTRIB_DESCRIPTION中的系统版本号是写死的,并不具有多少参考价值

系统启动流程分析

stp.1 启动入口 /etc/inittab

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
null::sysinit:/bin/mount -o remount,rw /  

null::sysinit:/bin/mkdir -p /dev/pts  

null::sysinit:/bin/mount -a  

::sysinit:/etc/init.d/rcS boot  

/dev/console::respawn:-/bin/sh  

::ctrlaltdel:/sbin/reboot  

null::shutdown:/bin/umount -a -r  
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
sysinit(初始化)  

 -> 将根文件系统`/`以读写模式(rw)重新挂载
 -> 创建目录`/dev/pts`(用于伪终端设备)
 -> 挂载`/etc/fstab`中定义的所有文件系统
 -> 执行系统初始化脚本`/etc/init.d/rcS`,并传递参数`boot`
respawn(持续监控)  

 -> 在控制台`/dev/console`启动Shell(`/bin/sh`)
ctrlaltdel  

 -> 按下`Ctrl+Alt+Del`组合键时执行`/sbin/reboot`命令重启系统
shutdown  

 -> 安全卸载文件系统

stp.2 系统初始化脚本 /etc/init.d/rcS

启动顺序函数函数定义
1rc_preboot()执行预启动脚本 /etc/init.d/rc.preboot
2rc_init()基础初始化
-> 从内核参数 loglevel 设置日志级别
-> 设置主机名 TinaLinux
-> 启用回环接口 lo
3rc_log()执行日志配置脚本 /etc/init.d/rc.log
4rc_mount()挂载关键分区
-> 挂载 UDISK (/dev/by-name/UDISK/mnt/UDISK)
-> 启动 mdev 动态管理设备节点
5rc_load_modules()加载内核模块(执行 /etc/init.d/rc.modules
6rc_load_script()并行启动服务
-> 从 /etc/init.d/load_script.conf 读取服务列表
-> 以 boot 参数后台运行符合规范的服务
7rc_final()执行最终初始化脚本 /etc/init.d/rc.final
8rc_ota()后台启动 OTA 升级日志服务 (/sbin/aw_upgrade_log.sh)
modulemkfs_jffs2()格式化 JFFS2 文件系统
-> 检查 mkfs.jffs2 工具是否存在
-> 从 /proc/mtd 获取擦除块大小
-> 创建临时镜像并写入设备
modulerc_mount_filesystem()挂载文件系统
-> 支持 jffs2(MTD 设备)和 ext4(块设备)
-> 挂载失败时自动格式化分区

stp.2.1 预启动脚本 /etc/init.d/rc.preboot

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/etc/init.d/preboot  

 -> blozi_init
	 -> cd /sys/class/sunxi_dum
		echo 0xf1c01100 0x0000>write  

        echo 0xf1c01104 0x0000>write  

        echo 0xf1c01108 0x0000>write  

        echo 0xf1c0110c 0x0000>write  

        echo 0xf1c01110 0x0000>write  

        echo 0xf1c01114 0x0000>write  

        echo 0xf1c01118 0x00006000>write  

        echo 0xf1c0111c 0x00000000>write  

        echo 0xf1c01120 0x00000000>write  

        echo 0xf1c01124 0x0000>write  

        echo 0xf1c01128 0x0000>write  

        echo 0xf1c0112c 0x0000>write  

        echo 0xf1c01140 0x0000>write  

 -> mkdir -p /mnt/private
 -> mount -t vfat -r /dev/by-name/private /mnt/private
 -> cp /mnt/private/ULI/factory/SN.txt  /usr/product_sn

脚本首先使用全志的sunxi_dum工具写入寄存器 然后挂载私有分区并复制序列号 输出SN.txt可得SN号

1
2
3
> cat /mnt/private/ULI/factory/SN.txt  

5000003927  

stp.2.2 日志配置脚本 /etc/init.d/rc.log

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#!/bin/sh
mkdir -p /var/log  

if [ -d /var/log ]  

then  

	touch /var/log/messages  

	/sbin/syslogd -n -m 0 &  

	/sbin/klogd -n &  

fi  

stp.2.3 内核模块/etc/init.d/rc.modules

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#!/bin/sh

[ -d /etc/modules.d ] && \  

        /sbin/kmodloader "/etc/modules.d/"  


[ -d /etc/modules-boot.d ] && \  

        /sbin/kmodloader "/etc/modules-boot.d/" &  

可得加载了两部分的内核模块,/etc/modules.d//etc/modules-boot.d/ 分别获取信息

1
2
3
4
5
6
7
8
9
>cd /etc/modules.d/ && ll  

drwxr-xr-x    2 root     root            72 Mar  1  2022 .  

drwxr-xr-x    1 root     root          1024 Jan  1 00:00 ..  

-rw-r--r--    1 root     root            86 Mar  1  2022 30-sound-core
-rw-r--r--    1 root     root             9 Mar  1  2022 cfg80211
-rw-r--r--    1 root     root            35 Mar  1  2022 xradio-xr819
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
> cat 30-sound-core  

soundcore  

snd  

snd-seq-device  

snd-timer  

snd-pcm  

snd-mixer-oss  

snd-pcm-oss  

snd-compress  

> cat cfg80211  

cfg80211  

> cat xradio-xr819  

xradio_mac  

xradio_core  

xradio_wlan  

文件夹/etc/modules-boot.d/不存在

stp.2.4 服务列表/etc/init.d/load_script.conf

1
2
3
4
5
adbd  

tinatest  

wpa_supplicant  
stp.2.4.1 adbd

脚本为/bin/sh脚本,基于/etc/rc.common框架管理生命周期(80-99) 通过动态配置USB Gadget并启动adbd,使设备支持ADB协议。核心依赖Linux内核的USB Gadget框架和Procd进程管理器

stp.2.4.2 tinatest

没有找到该服务

stp.2.4.3 wpa_supplicant

脚本为/bin/sh脚本,基于/etc/rc.common框架管理生命周期(96-98) 仅有启动阶段存在,停止和重启部分均被注释掉

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
start_service() {  

    procd_open_instance  

    ifconfig wlan0 up  

    procd_set_param oom_adj $OOM_ADJ  

    procd_set_param command $PROG -iwlan0 -Dnl80211 -c/etc/wifi/wpa_supplicant.conf -I/etc/wifi/wpa_supplicant_overlay  

    procd_close_instance  

}  

基于这段代码的信息,修改/etc/wifi/wpa_supplicant.conf

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
ctrl_interface=/etc/wifi/sockets  

disable_scan_offload=1  

update_config=1n  

wowlan_triggers=any  


network={  

  ssid="SSID"  

  psk="Password"  

  priority=5  

}  

重启发现文件被覆盖(network信息丢失),需要进一步的分析

stp.2.5 最终初始化脚本 /etc/init.d/rc.final

1
2
3
4
5
6
7
8
9
/etc/init.d/rc.final  

 -> if [ -f "/usr/bin/F1C200s-board" ]; then
	    /usr/bin/F1C200s-board > /dev/null 2>&1 &  

	fi  

 -> blozi_player_init
	 -> check dir

ls /usr/bin/可得/usr/bin/F1C200s-board并不存在

stp.3 文件系统挂载 /etc/fstab

1
2
3
4
# /etc/fstab: static file system information.
#
# <file system>		<mount pt>	<type>	<options>			<dump>		<pass>
devpts			/dev/pts	devpts	defaults,gid=5,mode=620		0		0  

挂载伪终端

stp.4 启动目录/etc/rc.d

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
drwxr-xr-x    2 root     root           219 Mar  1  2022 .  

drwxr-xr-x    1 root     root          1024 Jan  1 00:00 ..  

lrwxrwxrwx    1 root     root            13 Mar  1  2022 K89log -> ../init.d/log  

lrwxrwxrwx    1 root     root            17 Mar  1  2022 K90network -> ../init.d/network  

lrwxrwxrwx    1 root     root            24 Mar  1  2022 K98wpa_supplicant -> ../init.d/wpa_supplicant  

lrwxrwxrwx    1 root     root            14 Mar  1  2022 K99adbd -> ../init.d/adbd  

lrwxrwxrwx    1 root     root            13 Mar  1  2022 S12log -> ../init.d/log  

lrwxrwxrwx    1 root     root            17 Mar  1  2022 S20network -> ../init.d/network  

lrwxrwxrwx    1 root     root            14 Mar  1  2022 S50cron -> ../init.d/cron  

lrwxrwxrwx    1 root     root            14 Mar  1  2022 S80adbd -> ../init.d/adbd  

lrwxrwxrwx    1 root     root            24 Mar  1  2022 S96wpa_supplicant -> ../init.d/wpa_supplicant  

lrwxrwxrwx    1 root     root            17 Mar  1  2022 S98sysntpd -> ../init.d/sysntpd  

lrwxrwxrwx    1 root     root            26 Mar  1  2022 S99swupdate_autorun -> ../init.d/swupdate_autorun  

可以看到所有的启动文件均为/etc/init.d/对应脚本的软链接

stp.5 脚本目录/etc/init.d/

分析脚本在启动和关机时的顺序

1
2
3
4
5
6
7
> Start  

log -> network -> cron -> adbd -> sysntpd -> swupdate_autorun  

> Kill  

log -> network -> adbd  

一一访问脚本文件进行分析(除了已经分析过的) network -> 基础的网络接口初始化 cron -> 定时工具,定时文件在/etc/crontabs/中,ls可得空无一物 ntpd -> NTP时间同步 swupdate_autorun -> 全志的自动更新工具

stp.6 按钮事件

有文件/etc/rc.button/wps

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
if [ "$ACTION" = "pressed" -a "$BUTTON" = "wps" ]; then  

        cd /var/run/hostapd  

        for socket in *; do  

                [ -S "$socket" ] || continue  

                hostapd_cli -i "$socket" wps_pbc  

        done  

fi  

终端启动流程分析

/etc/profile.d/中可找到bloziplayer.sh

1
2
3
4
5
6
7
8
9
wpa_supplicant_init  

 -> cp -f /etc/wifi/wpa_supplicant_src.conf /etc/wifi/wpa_supplicant.conf
blozi_player_start  

 -> bloziplayer
blozi_player_daemon  

 -> watch dog

故将所有项全部注释,再次修改/etc/wifi/wpa_supplicant.conf 重启即可连接上WIFI

日志分析

日志脚本改写

ls /var/log/可得只有一个messages的日志文件,故需要对rc.log进行改写

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh
mkdir -p /var/log  

rm -f /var/log/messages /var/log/kernel.log 2>/dev/null  

mkdir -p /etc  


cat > /etc/syslog.conf << 'EOF'  

kern.*    -/var/log/kernel.log  

*.*       /var/log/messages  

EOF  


if [ -d /var/log ]  

then  

    touch /var/log/kernel.log  

    touch /var/log/messages  

    chmod 644 /var/log/kernel.log  

    
    killall syslogd klogd 2>/dev/null  

    
    /sbin/syslogd -n -m 0 -f /etc/syslog.conf -L &  

    /sbin/klogd -n -c 8 &  

    
    sleep 2  

    dmesg > /var/log/kernel.log  

fi  

保存并重启

日志预处理

在使用adb shell连接后会发现messages在被疯狂灌水(多次ll /var/log可得)

1
[DISP] disp_al_layer_set_framebuffer,line:2029:    not support fmt!  

只能说BLOZI官方写的代码还是太抽象了,而且从屏幕上也能看到奇奇怪怪的刷新 推测是使用adb shell后创建了一个新终端,由终端启动流程分析可得执行了bloziplayer 执行ps | grep blozi可得

1
2
3
  176 root     23:57 bloziplayer  

  403 root      0:32 bloziplayer  

所以不断刷屏的消息应该是开机自启的bloziplayer输出的demo帧和后续创建的bloziplayer的empty帧冲突导致的 所以想要抓取正常的包含bloziplayer消息的日志,需要在进入时进行进行抓取

1
cp /var/log/messages /var/log/messages.bak  

提示 此处亦可参考BLOZI 10.1寸LCD价签折腾记3-环境配置中的关闭BLOZI的环境操作后再进行抓包,但无法获取包含bloziplayer输出的日志

然后就能下载log文件进行分析

1
2
3
4
5
6
7
mkdir log  

cd log  

adb pull /var/log/kernel.log  

adb pull /var/log/messages.bak  

然后使用vim去除掉messages中被灌入的垃圾内容

1
2
3
4
5
vim messages.bak  

:g/disp_al_layer_set_framebuffer,line:2029/d  

:wq  

DTS

DTS F1C200S https://whycan.com/t_11396.html#p100965

INFOS

https://whycan.com/t_11396.html#p100966 https://whycan.com/t_11396.html#p100967

使用 Hugo 构建
主题 StackJimmy 设计,DoubleCat 修改
© Copyright Licensed under CC BY-NC-SA 4.0