mirror of
https://github.com/commaai/agnos-builder.git
synced 2026-06-08 11:04:51 +08:00
simple hardware init (#570)
* merge hw init * lil more * leftover from tici * parallel * mv that
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
function gpio {
|
||||
echo "out" > /sys/class/gpio/gpio$1/direction
|
||||
echo $2 > /sys/class/gpio/gpio$1/value
|
||||
}
|
||||
|
||||
pins=(
|
||||
# 27 # SW_3V3_EN
|
||||
# 25 # SW_5V_EN
|
||||
30 # HUB_RST_N
|
||||
49 # SOM_ST_IO
|
||||
134 # ST_BOOT0
|
||||
41 # PANDA_1V8_EN_N
|
||||
50 # LTE_RST_N
|
||||
116 # LTE_PWRKEY
|
||||
124 # ST_RST_N
|
||||
34 # GPS_PWR_EN
|
||||
33 # GPS_SAFEBOOT_N
|
||||
32 # GPS_RST_N
|
||||
52 # LTE_BOOT
|
||||
1264 # POWER ALERT
|
||||
)
|
||||
|
||||
for p in ${pins[@]}; do
|
||||
echo $p
|
||||
|
||||
# this is SSD_3v3 EN on tici
|
||||
if [ "$p" -eq 41 ] && grep -q "comma tici" /sys/firmware/devicetree/base/model; then
|
||||
echo "Skipping $p"
|
||||
continue
|
||||
fi
|
||||
|
||||
echo $p > /sys/class/gpio/export
|
||||
until [ -d /sys/class/gpio/gpio$p ]
|
||||
do
|
||||
sleep .05
|
||||
done
|
||||
done
|
||||
|
||||
|
||||
HUB_RST_N=30
|
||||
gpio $HUB_RST_N 1
|
||||
63
userspace/root/usr/comma/hardware-init.sh
Executable file
63
userspace/root/usr/comma/hardware-init.sh
Executable file
@@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
|
||||
function init_gpio {
|
||||
local pins=(
|
||||
49 # SOM_ST_IO
|
||||
134 # ST_BOOT0
|
||||
41 # PANDA_1V8_EN_N
|
||||
50 # LTE_RST_N
|
||||
116 # LTE_PWRKEY
|
||||
124 # ST_RST_N
|
||||
34 # GPS_PWR_EN
|
||||
33 # GPS_SAFEBOOT_N
|
||||
32 # GPS_RST_N
|
||||
52 # LTE_BOOT
|
||||
1264 # POWER ALERT
|
||||
)
|
||||
|
||||
echo "initializing gpio"
|
||||
|
||||
for p in ${pins[@]}; do
|
||||
echo $p
|
||||
|
||||
echo $p > /sys/class/gpio/export
|
||||
until [ -d /sys/class/gpio/gpio$p ]; do
|
||||
sleep .05
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
function init_sound {
|
||||
echo "waiting for sound card to come online"
|
||||
while [ ! -d /proc/asound/sdm845tavilsndc ] || [ "$(cat /proc/asound/card0/state 2> /dev/null)" != "ONLINE" ] ; do
|
||||
sleep 0.01
|
||||
done
|
||||
echo "sound card online"
|
||||
|
||||
while ! /usr/comma/sound/tinymix controls | grep -q "SEC_MI2S_RX Audio Mixer MultiMedia1"; do
|
||||
sleep 0.01
|
||||
done
|
||||
echo "tinymix controls ready"
|
||||
|
||||
/usr/comma/sound/tinymix set "SEC_MI2S_RX Audio Mixer MultiMedia1" 1
|
||||
if grep -q mici /sys/firmware/devicetree/base/model; then
|
||||
/usr/comma/sound/tinymix set "MultiMedia1 Mixer SEC_MI2S_TX" 1
|
||||
else
|
||||
/usr/comma/sound/tinymix set "MultiMedia1 Mixer TERT_MI2S_TX" 1
|
||||
/usr/comma/sound/tinymix set "TERT_MI2S_TX Channels" Two
|
||||
fi
|
||||
}
|
||||
|
||||
function init_screen_calibration {
|
||||
while ! mountpoint -q /persist; do
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
/usr/comma/screen_calibration.py
|
||||
}
|
||||
|
||||
init_gpio &
|
||||
init_sound &
|
||||
init_screen_calibration &
|
||||
|
||||
wait
|
||||
@@ -5,7 +5,6 @@ function gpio {
|
||||
echo $2 > /sys/class/gpio/gpio$1/value
|
||||
}
|
||||
|
||||
HUB_RST_N=30
|
||||
LTE_RST_N=50
|
||||
LTE_BOOT=52
|
||||
LTE_PWRKEY=116
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "waiting for sound card to come online"
|
||||
while [ ! -d /proc/asound/sdm845tavilsndc ] || [ "$(cat /proc/asound/card0/state 2> /dev/null)" != "ONLINE" ] ; do
|
||||
sleep 0.01
|
||||
done
|
||||
echo "sound card online"
|
||||
|
||||
while ! /usr/comma/sound/tinymix controls | grep -q "SEC_MI2S_RX Audio Mixer MultiMedia1"; do
|
||||
sleep 0.01
|
||||
done
|
||||
echo "tinymix controls ready"
|
||||
|
||||
/usr/comma/sound/tinymix set "SEC_MI2S_RX Audio Mixer MultiMedia1" 1
|
||||
if grep -q mici /sys/firmware/devicetree/base/model; then
|
||||
/usr/comma/sound/tinymix set "MultiMedia1 Mixer SEC_MI2S_TX" 1
|
||||
else
|
||||
/usr/comma/sound/tinymix set "MultiMedia1 Mixer TERT_MI2S_TX" 1
|
||||
/usr/comma/sound/tinymix set "TERT_MI2S_TX Channels" Two
|
||||
fi
|
||||
@@ -1,9 +0,0 @@
|
||||
[Unit]
|
||||
Description=GPIO export
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/comma/gpio.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,11 +1,11 @@
|
||||
[Unit]
|
||||
Description=Sound
|
||||
Requires=init-qcom.service
|
||||
Description=Hardware init
|
||||
After=init-qcom.service
|
||||
Before=lte.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/comma/sound/sound_init.sh
|
||||
ExecStart=/usr/comma/hardware-init.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,6 +1,6 @@
|
||||
[Unit]
|
||||
Description=LTE
|
||||
After=gpio.service network.target
|
||||
After=hardware-init.service network.target
|
||||
|
||||
[Service]
|
||||
Restart=no
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
[Unit]
|
||||
After=multi-user.target
|
||||
Description=Set screen calibration
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
User=root
|
||||
ExecStart=/usr/comma/screen_calibration.py
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -5,9 +5,8 @@ systemctl enable fs_setup.service
|
||||
systemctl enable serial-hostname.service
|
||||
systemctl enable comma.service
|
||||
systemctl enable agnos-debug.service
|
||||
systemctl enable gpio.service
|
||||
systemctl enable hardware-init.service
|
||||
systemctl enable lte.service
|
||||
systemctl enable sound.service
|
||||
systemctl enable magic.service
|
||||
systemctl enable init-qcom.service
|
||||
systemctl enable varwatch.service
|
||||
@@ -21,7 +20,6 @@ systemctl enable adb-param-watcher.service
|
||||
systemctl enable logrotate-hourly.timer
|
||||
systemctl enable avahi-daemon
|
||||
systemctl enable avahi-ssh-publish.service
|
||||
systemctl enable screen_calibration.service
|
||||
systemctl enable tftp_server.service
|
||||
|
||||
# Disable SSH by default
|
||||
|
||||
Reference in New Issue
Block a user