xref: /OK3568_Linux_fs/debian/overlay/etc/init.d/rockchip.sh (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1#!/bin/bash -e
2### BEGIN INIT INFO
3# Provides:          rockchip
4# Required-Start:
5# Required-Stop:
6# Default-Start:
7# Default-Stop:
8# Short-Description:
9# Description:       Setup rockchip platform environment
10### END INIT INFO
11
12PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
13
14install_packages() {
15    case $1 in
16        rk3288)
17		MALI=midgard-t76x-r18p0-r0p0
18		ISP=rkisp
19		# 3288w
20		cat /sys/devices/platform/*gpu/gpuinfo | grep -q r1p0 && \
21		MALI=midgard-t76x-r18p0-r1p0
22		sed -i "s/always/none/g" /etc/X11/xorg.conf.d/20-modesetting.conf
23		[ -e /usr/lib/arm-linux-gnueabihf/ ] && apt install -fy --allow-downgrades /camera_engine_$ISP*.deb
24		;;
25        rk3399|rk3399pro)
26		MALI=midgard-t86x-r18p0
27		ISP=rkisp
28		sed -i "s/always/none/g" /etc/X11/xorg.conf.d/20-modesetting.conf
29		[ -e /usr/lib/aarch64-linux-gnu/ ] && apt install -fy --allow-downgrades /camera_engine_$ISP*.deb
30		;;
31        rk3328|rk3528)
32		MALI=utgard-450
33		ISP=rkisp
34		sed -i "s/always/none/g" /etc/X11/xorg.conf.d/20-modesetting.conf
35		[ -e /usr/lib/aarch64-linux-gnu/ ] && apt install -fy --allow-downgrades /camera_engine_$ISP*.deb
36		;;
37        rk3326|px30)
38		MALI=bifrost-g31-g13p0
39		ISP=rkisp
40		sed -i "s/always/none/g" /etc/X11/xorg.conf.d/20-modesetting.conf
41		[ -e /usr/lib/aarch64-linux-gnu/ ] && apt install -fy --allow-downgrades /camera_engine_$ISP*.deb
42		;;
43        rk3128|rk3036)
44		MALI=utgard-400
45		ISP=rkisp
46		sed -i "s/always/none/g" /etc/X11/xorg.conf.d/20-modesetting.conf
47		[ -e /usr/lib/arm-linux-gnueabihf/ ] && apt install -fy --allow-downgrades /camera_engine_$ISP*.deb
48		;;
49        rk3568|rk3566)
50		MALI=bifrost-g52-g13p0
51		ISP=rkaiq_rk3568
52		[ -e /usr/lib/aarch64-linux-gnu/ ] && tar xvf /rknpu2-*.tar -C /
53		[ -e /usr/lib/aarch64-linux-gnu/ ] && apt install -fy --allow-downgrades /camera_engine_$ISP*.deb
54		;;
55        rk3562)
56		MALI=bifrost-g52-g13p0
57		ISP=rkaiq_rk3562
58		[ -e /usr/lib/aarch64-linux-gnu/ ] && tar xvf /rknpu2-*.tar -C /
59		[ -e /usr/lib/aarch64-linux-gnu/ ] && apt install -fy --allow-downgrades /camera_engine_$ISP*.deb
60		;;
61        rk3588|rk3588s)
62		ISP=rkaiq_rk3588
63		MALI=valhall-g610-g13p0
64		[ -e /usr/lib/aarch64-linux-gnu/ ] && tar xvf /rknpu2-*.tar -C /
65		[ -e /usr/lib/aarch64-linux-gnu/ ] && apt install -fy --allow-downgrades /camera_engine_$ISP*.deb
66		;;
67        *)
68        echo "This chip does not support gpu acceleration or not input!!!"
69		;;
70    esac
71
72    apt install -fy --allow-downgrades /libmali-*$MALI*-x11*.deb
73}
74
75function update_npu_fw() {
76    /usr/bin/npu-image.sh
77    sleep 1
78    /usr/bin/npu_transfer_proxy&
79}
80
81COMPATIBLE=$(cat /proc/device-tree/compatible)
82if [[ $COMPATIBLE =~ "rk3288" ]];
83then
84    CHIPNAME="rk3288"
85elif [[ $COMPATIBLE =~ "rk3328" ]]; then
86    CHIPNAME="rk3328"
87elif [[ $COMPATIBLE =~ "rk3399" && $COMPATIBLE =~ "rk3399pro" ]]; then
88    CHIPNAME="rk3399pro"
89    update_npu_fw
90elif [[ $COMPATIBLE =~ "rk3399" ]]; then
91    CHIPNAME="rk3399"
92elif [[ $COMPATIBLE =~ "rk3326" ]]; then
93    CHIPNAME="rk3326"
94elif [[ $COMPATIBLE =~ "px30" ]]; then
95    CHIPNAME="px30"
96elif [[ $COMPATIBLE =~ "rk3128" ]]; then
97    CHIPNAME="rk3128"
98elif [[ $COMPATIBLE =~ "rk3562" ]]; then
99    CHIPNAME="rk3562"
100elif [[ $COMPATIBLE =~ "rk3566" ]]; then
101    CHIPNAME="rk3566"
102elif [[ $COMPATIBLE =~ "rk3568" ]]; then
103    CHIPNAME="rk3568"
104elif [[ $COMPATIBLE =~ "rk3588" ]]; then
105    CHIPNAME="rk3588"
106elif [[ $COMPATIBLE =~ "rk3036" ]]; then
107    CHIPNAME="rk3036"
108elif [[ $COMPATIBLE =~ "rk3308" ]]; then
109    CHIPNAME="rk3208"
110elif [[ $COMPATIBLE =~ "rv1126" ]]; then
111    CHIPNAME="rv1126"
112elif [[ $COMPATIBLE =~ "rv1109" ]]; then
113    CHIPNAME="rv1109"
114else
115    echo "please check if the Socs had been supported on rockchip linux!!!!!!!"
116fi
117COMPATIBLE=${COMPATIBLE#rockchip,}
118BOARDNAME=${COMPATIBLE%%rockchip,*}
119
120# first boot configure
121if [ ! -e "/usr/local/first_boot_flag" ] ;
122then
123    echo "It's the first time booting."
124    echo "The rootfs will be configured."
125
126    # Force rootfs synced
127    mount -o remount,sync /
128
129    install_packages ${CHIPNAME}
130
131    setcap CAP_SYS_ADMIN+ep /usr/bin/gst-launch-1.0
132
133    if [ -e "/dev/rfkill" ] ;
134    then
135       rm /dev/rfkill
136    fi
137
138    rm -rf /*.deb
139    rm -rf /*.tar
140
141    # The base target does not come with lightdm/rkaiq_3A
142if [ -e /etc/gdm3/daemon.conf ]; then
143    systemctl restart gdm3.service || true
144elif [ -e /etc/lightdm/lightdm.conf ]; then
145    systemctl restart lightdm.service || true
146fi
147    systemctl restart rkaiq_3A.service || true
148
149    touch /usr/local/first_boot_flag
150fi
151
152# enable rkwifbt service
153#service rkwifibt start
154
155# enable async service
156#service async start
157
158# enable adbd service
159#service adbd start
160
161# support power management
162if [ -e "/usr/sbin/pm-suspend" -a -e /etc/Powermanager ] ;
163then
164    mv /etc/Powermanager/power-key.sh /usr/bin/
165    mv /etc/Powermanager/power-key.conf /etc/triggerhappy/triggers.d/
166    if [[ "$CHIPNAME" == "rk3399pro" ]];
167    then
168        mv /etc/Powermanager/01npu /usr/lib/pm-utils/sleep.d/
169        mv /etc/Powermanager/02npu /lib/systemd/system-sleep/
170    fi
171    mv /etc/Powermanager/03wifibt /usr/lib/pm-utils/sleep.d/
172    mv /etc/Powermanager/04wifibt /lib/systemd/system-sleep/
173    mv /etc/Powermanager/triggerhappy /etc/init.d/triggerhappy
174
175    rm /etc/Powermanager -rf
176    service triggerhappy restart
177fi
178
179# Create dummy video node for chromium V4L2 VDA/VEA with rkmpp plugin
180echo dec > /dev/video-dec0
181echo enc > /dev/video-enc0
182chmod 660 /dev/video-*
183chown root:video /dev/video-*
184
185# The chromium using fixed pathes for libv4l2.so
186ln -rsf /usr/lib/*/libv4l2.so /usr/lib/
187[ -e /usr/lib/aarch64-linux-gnu/ ] && ln -Tsf lib /usr/lib64
188
189# sync system time
190hwclock --systohc
191
192# read mac-address from efuse
193# if [ "$BOARDNAME" == "rk3288-miniarm" ]; then
194#     MAC=`xxd -s 16 -l 6 -g 1 /sys/bus/nvmem/devices/rockchip-efuse0/nvmem | awk '{print $2$3$4$5$6$7 }'`
195#     ifconfig eth0 hw ether $MAC
196# fi
197