diff --git a/src/Script_ABC_Blanton/Blanton_Script/ddr5_temp.sh b/src/Script_ABC_Blanton/Blanton_Script/ddr5_temp.sh new file mode 100644 index 0000000..c3c866a --- /dev/null +++ b/src/Script_ABC_Blanton/Blanton_Script/ddr5_temp.sh @@ -0,0 +1,34 @@ +#!/bin/bash +#============================================================================== +# Author : ETWen +# Date : 20260923 +# Purpose : Read DDR5 DIMM temperature from SPD5118 hub (MR49/MR50 @ 0x31) +# Usage : ./ddr5_temp_V1.0.1.sh [bus] [addr ...] +# default: bus=5, addr=0x50 0x51 +# +# Version History: +# V1.0.0 20260923 Initial Version +# V1.0.1 20260923 Output label "DDR temp" +#============================================================================== + +BUS=${1:-5} +shift 2>/dev/null +ADDRS=("$@") +[[ ${#ADDRS[@]} -eq 0 ]] && ADDRS=(0x50 0x51) + +REG_TEMP=0x31 + +for ADDR in "${ADDRS[@]}"; do + raw=$(i2cget -y "$BUS" "$ADDR" "$REG_TEMP" w 2>&1) + if [[ $? -ne 0 || ! $raw =~ ^0x[0-9a-fA-F]+$ ]]; then + echo "[bus $BUS $ADDR] read fail: $raw" + continue + fi + + # bit[12:2] = temperature, bit12 = sign, 0.25 C/LSB + v=$(( (raw >> 2) & 0x7FF )) + (( v & 0x400 )) && v=$(( v - 0x800 )) + + awk -v b="$BUS" -v a="$ADDR" -v r="$raw" -v v="$v" \ + 'BEGIN { printf "[bus %s %s] DDR temp: %.2f C (raw=%s)\n", b, a, v * 0.25, r }' +done diff --git a/src/Script_ABC_Blanton/Blanton_Script/hsc_temp_readback.sh b/src/Script_ABC_Blanton/Blanton_Script/hsc_temp_readback.sh new file mode 100644 index 0000000..bb8228d --- /dev/null +++ b/src/Script_ABC_Blanton/Blanton_Script/hsc_temp_readback.sh @@ -0,0 +1,65 @@ +#!/bin/bash +#============================================================================== +# Author : ETWen +# Date : 20260923 +# Purpose : Read LTC4287 hot-swap controller temperatures (HSC_MAIN / HSC_STBY) +# Select source via 0xF3 (0xEB internal / 0xEF external), then read +# READ_TEMPERATURE 0x8D (Kelvin) and convert to Celsius +# Usage : ./hsc_temp_readback.sh +# bus = BUS (28), HSC_MAIN @ 0x40, HSC_STBY @ 0x45 +# +# Version History: +# V1.0.0 20260922 Initial Version +# V1.0.1 20260923 Add header; fix delay comments (DELAY is 0.5 s, not 100 ms); +# CRLF -> LF (CRLF breaks bash on SONiC) +#============================================================================== + +BUS=28 +DELAY=0.5 # seconds between I2C transactions; ~4 s per run (4 readings x 2) + +read_temp() { + local addr="$1" + local name="$2" + local sel="$3" + + # Select temperature source + i2ctransfer -f -y "$BUS" w3@"$addr" 0xF3 "$sel" 0x00 > /dev/null + + # DELAY between I2C transactions + sleep "$DELAY" + + # Read temperature register 0x8D + raw=$(i2cget -f -y "$BUS" "$addr" 0x8D w 2>/dev/null) + + if [ -z "$raw" ]; then + printf "%-32s : READ ERROR\n" "$name" + sleep "$DELAY" + return + fi + + # Remove 0x prefix and convert hexadecimal to decimal + raw_dec=$((16#${raw#0x})) + + # LTC4287 temperature is in Kelvin + temp_c=$(awk "BEGIN {printf \"%.2f\", $raw_dec - 273.15}") + + printf "%-32s : %8s °C (raw %s)\n" \ + "$name" "$temp_c" "$raw" + + # DELAY before next I2C transaction + sleep "$DELAY" +} + +echo "==========================================================" +echo " LTC4287 Temperature Readback" +echo "==========================================================" + +# HSC_MAIN - LTC4287 @ 0x40 +read_temp 0x40 "HSC_MAIN Internal (PU11)" 0xEB +read_temp 0x40 "HSC_MAIN External (PQ1)" 0xEF + +# HSC_STBY - LTC4287 @ 0x45 +read_temp 0x45 "HSC_STBY Internal (PU46)" 0xEB +read_temp 0x45 "HSC_STBY External (PQ53)" 0xEF + +echo "==========================================================" diff --git a/src/Script_ABC_Blanton/utils/setup_pmon.ttl b/src/Script_ABC_Blanton/utils/setup_pmon.ttl index 3f4f24b..00593f5 100644 --- a/src/Script_ABC_Blanton/utils/setup_pmon.ttl +++ b/src/Script_ABC_Blanton/utils/setup_pmon.ttl @@ -5,6 +5,10 @@ sendln "show platform fan" wait prompt_sonic_root sendln "show platform temperature" wait prompt_sonic_root +sendln "~/Blanton_Script/ddr5_temp.sh" +wait prompt_sonic_root +sendln "~/Blanton_Script/hsc_temp_readback.sh" +wait prompt_sonic_root sendln "show platform psustatus" wait prompt_sonic_root sendln "show platform voltage"