diff --git a/userspace/root/usr/comma/hardware-init.sh b/userspace/root/usr/comma/hardware-init.sh index fd988f1..a6d7bc2 100755 --- a/userspace/root/usr/comma/hardware-init.sh +++ b/userspace/root/usr/comma/hardware-init.sh @@ -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 diff --git a/userspace/root/usr/comma/init.qcom.sh b/userspace/root/usr/comma/init.qcom.sh deleted file mode 100755 index 7aba08e..0000000 --- a/userspace/root/usr/comma/init.qcom.sh +++ /dev/null @@ -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 diff --git a/userspace/root/usr/comma/set-hostname.sh b/userspace/root/usr/comma/set-hostname.sh deleted file mode 100755 index 187ec9d..0000000 --- a/userspace/root/usr/comma/set-hostname.sh +++ /dev/null @@ -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" diff --git a/userspace/root/usr/lib/systemd/system/agnos-debug.service b/userspace/root/usr/lib/systemd/system/agnos-debug.service deleted file mode 100644 index 8dbb59e..0000000 --- a/userspace/root/usr/lib/systemd/system/agnos-debug.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -After=local-fs.target - -[Service] -Type=oneshot -User=comma -ExecStart=/usr/comma/debug.py - -[Install] -WantedBy=multi-user.target diff --git a/userspace/root/usr/lib/systemd/system/hardware-init.service b/userspace/root/usr/lib/systemd/system/hardware-init.service index 56978a9..38cb636 100644 --- a/userspace/root/usr/lib/systemd/system/hardware-init.service +++ b/userspace/root/usr/lib/systemd/system/hardware-init.service @@ -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 diff --git a/userspace/root/usr/lib/systemd/system/init-qcom.service b/userspace/root/usr/lib/systemd/system/init-qcom.service deleted file mode 100644 index 430fe95..0000000 --- a/userspace/root/usr/lib/systemd/system/init-qcom.service +++ /dev/null @@ -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 diff --git a/userspace/root/usr/lib/systemd/system/serial-hostname.service b/userspace/root/usr/lib/systemd/system/serial-hostname.service deleted file mode 100644 index 29f309d..0000000 --- a/userspace/root/usr/lib/systemd/system/serial-hostname.service +++ /dev/null @@ -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 diff --git a/userspace/services.sh b/userspace/services.sh index 9c61ca2..a89b95e 100755 --- a/userspace/services.sh +++ b/userspace/services.sh @@ -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