Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions csm-check-repair.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,26 @@
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear
#******************************************************************************/
source csm-collect-conf.sh
check-repair() {
local PATH="$1"
DEVICE_PATH="$1"
ext4_images=(cache.img.raw persist.img.raw system.img.raw userdata.img.raw systemrw.img.raw)
for img in ${ext4_images[@]}; do
echo "checking for image : $PATH/$img"
/usr/sbin/e2fsck -n $PATH/$img
echo "checking for image : $DEVICE_PATH/$img"
e2fsck -n $DEVICE_PATH/$img
status=$?
if [[ $status != 0 ]]; then
/usr/sbin/e2fsck -pf $PATH/$img
e2fsck -pf $DEVICE_PATH/$img
status=$?
if [[ $status -lt 3 ]]; then
echo "$PATH/$img checked and repaired as needed..."
echo "$DEVICE_PATH/$img checked and repaired as needed..."
elif [[ $status -eq 4 || $status -eq 8 ]]; then
echo "$PATH/$img could not be repaired, copying from flatimg..."
echo "$DEVICE_PATH/$img could not be repaired, copying from flatimg..."
LASSEN_RAW_IMG_FOLDER=/lib/firmware/qcom/qdu100/flatimg/
/usr/bin/rsync -av $LASSEN_RAW_IMG_FOLDER/$img $PATH/
rsync -av $LASSEN_RAW_IMG_FOLDER/$img $DEVICE_PATH/
if [ "$img" = "system.img.raw" ]; then
restore-conf $DEVICE_PATH
fi
fi
fi
done
Expand Down
61 changes: 61 additions & 0 deletions csm-collect-conf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash
#******************************************************************************
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear
#******************************************************************************/

# device_collect_config - Receive indication from device to backup conf from systemrw
# restore-conf - Restores the backed up conf on file corruption

source /usr/bin/decimal-to-hex.sh
backup_conf=(
"/etc/splane/internal/si5518_dload_image_cfg.conf"
"/etc/splane/internal/sync_timing_ptp2_boundary_clock_G_8275_1_multicast.conf"
"/etc/splane/internal/sync_timing_ptp2_slave_clock_G_8275_1_multicast.conf"
"/etc/splane/internal/sync_timing_ptp2_t_gm_G_8275_1_multicast.conf"
"/etc/splane/internal/sync_timing_ptp2_t_gm_only.conf"
"/etc/sync_timing_driver.conf"
"/etc/splane/internal/x100/splane_intern_cfg.conf"
"/etc/transceiver_dual_speed_cfg.conf"
"/etc/transceiver_fault_management_cfg.conf"
"/etc/transceiver_logger_cfg.conf"
"/etc/transceiver_perf_cfg.conf"
"/etc/fault_manager/public/Qualcomm_fault_configuration.conf"
)

device_collect_config() {
# mount system.img to view the device info
decimal_serial=$(cat /sys/bus/mhi/devices/mhi$1/serial_number | cut -d " " -f3)
serialno=$(convert_serial_to_hex "$decimal_serial")
DEVICE_FOLDER=/lib/firmware/qcom/qdu100/$serialno
mkdir -m 644 -p /tmp/tmp.$serialno
mount $DEVICE_FOLDER/system.img.raw /tmp/tmp.$serialno
DEVICE_CONF_PATH=$DEVICE_FOLDER/conf
if [ ! -d "$DEVICE_CONF_PATH" ];then
mkdir -m 644 -p $DEVICE_CONF_PATH
fi
echo "Backing up configs to backup path $DEVICE_CONF_PATH..."
for conf in ${backup_conf[@]}; do
rsync -av /tmp/tmp.$serialno$conf $DEVICE_CONF_PATH
done
umount /tmp/tmp.$serialno
}

restore-conf() {
DEVICE_CONF_PATH=$1/conf
serialno=$(basename $1)
if [ -d "$DEVICE_CONF_PATH" ];then
echo "Restoring configs from backup path $DEVICE_CONF_PATH..."
mkdir -m 644 -p /tmp/tmp.$serialno
mount $1/system.img.raw /tmp/tmp.$serialno
for conf_path in ${backup_conf[@]}; do
conf_name=$(basename $conf_path)
rsync -av $DEVICE_CONF_PATH/$conf_name /tmp/tmp.$serialno$conf_path
done
umount /tmp/tmp.$serialno
fi
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
device_collect_config $1
fi
9 changes: 9 additions & 0 deletions csm-collect-conf@.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Backup conf on Host

[Service]
Type=oneshot
ExecStart=/usr/bin/csm-collect-conf.sh %i

[Install]
WantedBy=multi-user.target
9 changes: 9 additions & 0 deletions csm-collect-conf@.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Backup conf timer

[Timer]
OnCalendar=*:0/10
Unit=csm-collect-conf@%i.service

[Install]
WantedBy=timers.target
14 changes: 12 additions & 2 deletions csm-configure-ip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,24 @@ config_interface()
# @1: MHI Channel no
#
configure_ipaddress() {
SWIP0_LOCAL_INTERFACE="mhi$1_IP_SW0"
if ! [[ "$1" =~ ^[0-9]+$ ]]; then
echo "Error: channel number must be a non-negative."
exit 2
fi

local channel=$1
local base=$(( channel * 2 ))
SWIP0_LOCAL_INTERFACE="mhi_swip${base}"
MPLANE_INTERFACE="mhi_swip$(( base + 1 ))"
echo "Host MHI interface name --> $SWIP0_LOCAL_INTERFACE"
echo "Mplane MHI interface name --> $MPLANE_INTERFACE"

SWIP0_LOCAL_ADDR="192.200.100.$1"
SWIP0_REMOTE_ADDR="192.200.101.$1"
echo "configure interface $SWIP0_LOCAL_INTERFACE $SWIP0_LOCAL_ADDR $SWIP0_REMOTE_ADDR"
config_interface $SWIP0_LOCAL_INTERFACE $SWIP0_LOCAL_ADDR $SWIP0_REMOTE_ADDR

# Configure mhi_swipe1 interface for QDU Mplane App - OEM OAM App
MPLANE_INTERFACE="mhi$1_IP_SW1"
OAM_HOST_ADDR="192.200.102.$1"
MPLANE_ADDR="192.200.103.$1"
echo "configure interface $MPLANE_INTERFACE $OAM_HOST_ADDR $MPLANE_ADDR"
Expand Down
67 changes: 67 additions & 0 deletions csm-device-health.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash
#******************************************************************************
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear
#******************************************************************************/

source decimal-to-hex.sh
source csm-host-logger.sh

BOOT_TIME_OUT=600
INTERVAL=5 # Check every 5 seconds

# Checks the boot status by polling for
# boot_flag file

device_boot_check () {
LASSEN_FW_FOLDER=/lib/firmware/qcom/qdu100/
decimal_serial=$(cat /sys/bus/mhi/devices/mhi$1/serial_number | cut -d " " -f3)
serialno=$(convert_serial_to_hex "$decimal_serial")

mnt_dir=$(mktemp -d)
boot_status_file=$mnt_dir/post_boot/boot_flag
LASSEN_DEVICE_FOLDER=$LASSEN_FW_FOLDER$serialno
while [ "$BOOT_TIME_OUT" > 0 ]; do
if mount $LASSEN_DEVICE_FOLDER/userdata.img.raw $mnt_dir; then
if [[ -f $boot_status_file ]]; then
recv_msg=$(cat $boot_status_file)
echo "Received message from device $recv_msg"
boot_status=success
device_log_collection $1
rm -f $boot_status_file
umount $mnt_dir
return
fi
umount $mnt_dir
fi
sleep $INTERVAL
BOOT_TIME_OUT=$(( BOOT_TIME_OUT - INTERVAL ))
done

# Check exit status of timeout
echo "Boot up confirmation not received within BOOT_TIME_OUT"
echo "Invoke csm host debugger"
source csm-host-debugger.sh $1
boot_status="error"
}
# Udev rule triggers csm_nbdkit service with SAHARA channel as argument when Device detected on PCIe channel at boot
# $1 - MHI#_CSM_CTRL
channel="$1"
echo "Device detected in $channel"
# Retrieve channel no from the /dev/mhi#_CSM_CTRL string
channelno=$(echo $channel | cut -d "_" -f1 | cut -d "i" -f2)
echo "Channel number retrieved $channelno"
# check for device boot
boot_status=""
device_boot_check $channelno
if [ "$boot_status" == "error" ]; then
echo "Device boot failed"
exit
fi

#Start a timer to collect logs from device
sudo systemctl start csm-host-logger@$channelno.timer
sudo systemctl start csm-collect-conf@$channelno.timer

echo "$(date) :Collect host log if X100 just crashed" >> /tmp/host_log_crash.log
csm-host-log-crash.sh "$channelno" >> /tmp/host_log_crash.log 2>&1
12 changes: 12 additions & 0 deletions csm-device-health@.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Run csm device health service
After=csm-configure-ip@.service
Requires=csm-configure-ip@.service

[Service]
Type=oneshot
Group=root
ExecStart=/usr/bin/csm-device-health.sh %I

[Install]
WantedBy=multi-user.target
3 changes: 3 additions & 0 deletions csm-event-handler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ else
echo "csm-event: $DEVICE: starting csm-configure-ip service for CSM_CTRL" > /dev/kmsg
systemd-run --no-block systemctl restart csm-configure-ip@"$DEVICE".service &
echo "csm-event: $DEVICE: csm-configure-ip service completed with status:$?" > /dev/kmsg
echo "csm-event: $DEVICE: starting csm-device-health service for CSM_CTRL" > /dev/kmsg
systemd-run --no-block systemctl restart csm-device-health@"$DEVICE".service &
echo "csm-event: $DEVICE: csm-device-health service completed with status:$?" > /dev/kmsg
fi
Loading
Loading