mirror of
https://github.com/commaai/agnos-builder.git
synced 2026-10-27 00:23:47 +08:00
merge qcom and hardware init (#586)
* merge qcom and hardware init * rm file * mv hostname * lil more * wait for proc * better ordering * start/end logging * log to console * atomic * kmsg is up too late
This commit is contained in:
@@ -1,5 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
function init_qcom {
|
||||
# don't restart whole SoC on subsystem crash
|
||||
for i in {0..7}; do
|
||||
echo "related" | sudo tee /sys/bus/msm_subsys/devices/subsys${i}/restart_level
|
||||
done
|
||||
|
||||
# raise scaling_max so policy=performance can reach the BOOST top step
|
||||
echo 2649600 | sudo tee /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq
|
||||
echo 2649600 | sudo tee /sys/devices/system/cpu/cpufreq/policy4/scaling_max_freq
|
||||
|
||||
# setup firmware
|
||||
echo -n "/firmware/image" > /sys/module/firmware_class/parameters/path
|
||||
count=0
|
||||
while [ ! -s /firmware/image/adsp.mdt ]; do
|
||||
# wait 10s for /firmware mounted
|
||||
count=$(( $count + 1 ))
|
||||
if [ $count -ge 100 ]; then
|
||||
echo "[ERROR] /firmware not mounted"
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
# boot wifi
|
||||
echo 1 > /sys/kernel/boot_wlan/boot_wlan
|
||||
/usr/bin/irsc_util /etc/sec_config
|
||||
|
||||
# boot audio + compute DSPs
|
||||
echo 1 > /sys/kernel/boot_adsp/boot
|
||||
echo 1 > /sys/kernel/boot_cdsp/boot
|
||||
|
||||
# ipa
|
||||
echo 1 > /dev/ipa
|
||||
|
||||
echo "qcom init done"
|
||||
}
|
||||
|
||||
function init_gpio {
|
||||
local pins=(
|
||||
49 # SOM_ST_IO
|
||||
@@ -56,8 +92,51 @@ function init_screen_calibration {
|
||||
/usr/comma/screen_calibration.py
|
||||
}
|
||||
|
||||
init_gpio &
|
||||
init_sound &
|
||||
init_screen_calibration &
|
||||
function init_hostname {
|
||||
local serial
|
||||
while [ ! -r /proc/cmdline ]; do
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
serial="$(cat /proc/cmdline | sed -e 's/^.*androidboot.serialno=//' -e 's/ .*$//')"
|
||||
echo "serial: '$serial'"
|
||||
sysctl kernel.hostname="comma-$serial"
|
||||
}
|
||||
|
||||
function init_debug {
|
||||
while ! mountpoint -q /cache; do
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
sudo -u comma /usr/comma/debug.py
|
||||
}
|
||||
|
||||
function run_init {
|
||||
local name="$1"
|
||||
local start_time end_time elapsed
|
||||
|
||||
log_init "$name started"
|
||||
start_time="$EPOCHREALTIME"
|
||||
|
||||
"$name"
|
||||
|
||||
end_time="$EPOCHREALTIME"
|
||||
elapsed="$(awk "BEGIN { printf \"%.1f\", $end_time - $start_time }")"
|
||||
log_init "$name finished after ${elapsed}s"
|
||||
}
|
||||
|
||||
function log_init {
|
||||
local msg="hardware-init: $*"
|
||||
|
||||
echo "$msg"
|
||||
echo "$msg" > /dev/console
|
||||
}
|
||||
|
||||
run_init init_qcom &
|
||||
run_init init_gpio &
|
||||
run_init init_sound &
|
||||
run_init init_screen_calibration &
|
||||
run_init init_hostname &
|
||||
run_init init_debug &
|
||||
|
||||
wait
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# centralized qualcomm init
|
||||
# *************************
|
||||
|
||||
# don't restart whole SoC on subsystem crash
|
||||
for i in {0..7}; do
|
||||
echo "related" | sudo tee /sys/bus/msm_subsys/devices/subsys${i}/restart_level
|
||||
done
|
||||
|
||||
# raise scaling_max so policy=performance can reach the BOOST top step
|
||||
echo 2649600 | sudo tee /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq
|
||||
echo 2649600 | sudo tee /sys/devices/system/cpu/cpufreq/policy4/scaling_max_freq
|
||||
|
||||
# setup firmware
|
||||
echo -n "/firmware/image" > /sys/module/firmware_class/parameters/path
|
||||
count=0
|
||||
while [ ! -s /firmware/image/adsp.mdt ]; do
|
||||
# wait 10s for /firmware mounted
|
||||
count=$(( $count + 1 ))
|
||||
if [ $count -ge 100 ]; then
|
||||
echo "[ERROR] /firmware not mounted"
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
# boot wifi
|
||||
echo 1 > /sys/kernel/boot_wlan/boot_wlan
|
||||
/usr/bin/irsc_util /etc/sec_config
|
||||
|
||||
# boot audio + compute DSPs
|
||||
echo 1 > /sys/kernel/boot_adsp/boot
|
||||
echo 1 > /sys/kernel/boot_cdsp/boot
|
||||
|
||||
# ipa
|
||||
echo 1 > /dev/ipa
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
SERIAL="$(cat /proc/cmdline | sed -e 's/^.*androidboot.serialno=//' -e 's/ .*$//')"
|
||||
echo "serial: '$SERIAL'"
|
||||
sysctl kernel.hostname="comma-$SERIAL"
|
||||
@@ -1,10 +0,0 @@
|
||||
[Unit]
|
||||
After=local-fs.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
User=comma
|
||||
ExecStart=/usr/comma/debug.py
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,7 +1,7 @@
|
||||
[Unit]
|
||||
Description=Hardware init
|
||||
After=init-qcom.service
|
||||
Before=lte.service
|
||||
DefaultDependencies=no
|
||||
Before=network.target lte.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
[Unit]
|
||||
Description=QCOM init
|
||||
After=sysinit.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/comma/init.qcom.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,12 +0,0 @@
|
||||
[Unit]
|
||||
Description=Sets the hostname to the device's serial number
|
||||
After=basic.target
|
||||
Before=network.target
|
||||
|
||||
[Service]
|
||||
User=root
|
||||
Type=oneshot
|
||||
ExecStart=/usr/comma/set-hostname.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -2,13 +2,10 @@
|
||||
|
||||
# Enable our services
|
||||
systemctl enable fs_setup.service
|
||||
systemctl enable serial-hostname.service
|
||||
systemctl enable comma.service
|
||||
systemctl enable agnos-debug.service
|
||||
systemctl enable hardware-init.service
|
||||
systemctl enable lte.service
|
||||
systemctl enable magic.service
|
||||
systemctl enable init-qcom.service
|
||||
systemctl enable varwatch.service
|
||||
systemctl enable power_monitor.service
|
||||
systemctl enable power_drop_monitor.service
|
||||
|
||||
Reference in New Issue
Block a user