Skip to content

Commit

Permalink
minipack: Add crashdump to receive me log. (#81)
Browse files Browse the repository at this point in the history
Summary:
1. When BMC receive 0xEB error number, it will send crashdump request to get me log.
Pull Request resolved: facebookexternal/openbmc.accton#81

Test Plan:
1. Make a fake error as CATERR_B(0XEB), and check whether "crashdump_scm.tar.gz" file is existing in /mnt/data.

Test on Minipack:pass

Reviewed By: mikechoifb

fbshipit-source-id: 99318c58e
  • Loading branch information
mikechoifb authored and facebook-github-bot committed Sep 6, 2018
1 parent a67d2cb commit dcb1830
Show file tree
Hide file tree
Showing 12 changed files with 4,236 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ IMAGE_INSTALL += " \
bitbang \
cpldupdate \
cpldupdate-i2c \
crashdump \
flashrom \
front-paneld \
fscd \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright 2018-present Facebook. All Rights Reserved.
#
# This program file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program in a file named COPYING; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301 USA
SUMMARY = "Crashdump utility"
DESCRIPTION = "Util for generating crashdumps"
SECTION = "base"
PR = "r1"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=eb723b61539feef013de476e68b5c50a"

SRC_URI = "file://dump.sh \
file://crashdump_coreid \
file://crashdump_msr \
file://autodump.sh \
file://COPYING \
"

S = "${WORKDIR}"

binfiles += "dump.sh \
autodump.sh \
"

pkgdir = "crashdump"
RDEPENDS_${PN} += "bash"

do_install() {
dst="${D}/usr/local/fbpackages/${pkgdir}"
bin="${D}/usr/local/bin"
install -d $dst
install -d $bin
install -m 644 crashdump_coreid ${dst}/crashdump_coreid
install -m 644 crashdump_msr ${dst}/crashdump_msr
for f in ${binfiles}; do
install -m 755 $f ${dst}/$f
ln -snf ../fbpackages/${pkgdir}/$f ${bin}/$f
done
}

FBPACKAGEDIR = "${prefix}/local/fbpackages"

FILES_${PN} = "${FBPACKAGEDIR}/crashdump ${prefix}/local/bin "

INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
INHIBIT_PACKAGE_STRIP = "1"
340 changes: 340 additions & 0 deletions meta-facebook/meta-minipack/recipes-minipack/crashdump/files/COPYING

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

SLOT_NAME=$1

case $SLOT_NAME in
scm)
SLOT_NUM=1
;;
*)
N=${0##*/}
N=${N#[SK]??}
echo "Usage: $N {scm}"
exit 1
;;
esac

# File format autodump<slot_id>.pid (See pal_is_crashdump_ongoing()
# function definition)
PID_FILE="/var/run/autodump$SLOT_NUM.pid"

# check if auto crashdump is already running
if [ -f $PID_FILE ]; then
echo "Another auto crashdump for $SLOT_NAME is runnung"
exit 1
else
touch $PID_FILE
fi

# Set crashdump timestamp
sys_runtime=$(awk '{print $1}' /proc/uptime)
sys_runtime=$(printf "%0.f" $sys_runtime)
echo $((sys_runtime+630)) > /tmp/cache_store/fru${SLOT_NUM}_crashdump

DUMP_SCRIPT="/usr/local/bin/dump.sh"
CRASHDUMP_FILE="/mnt/data/crashdump_$SLOT_NAME"
CRASHDUMP_LOG_ARCHIVE="/mnt/data/crashdump_$SLOT_NAME.tar.gz"

echo "Auto Dump for $SLOT_NAME Started"

#HEADER LINE for the dump
$DUMP_SCRIPT "time" > $CRASHDUMP_FILE
#COREID dump
$DUMP_SCRIPT $SLOT_NAME "coreid" >> $CRASHDUMP_FILE
#MSR dump
$DUMP_SCRIPT $SLOT_NAME "msr" >> $CRASHDUMP_FILE
# Sensors & sensor thresholds
echo "Sensor history at dump:" >> $CRASHDUMP_FILE 2>&1
$DUMP_SCRIPT $SLOT_NAME "sensors" >> $CRASHDUMP_FILE
echo "Sensor threshold at dump:" >> $CRASHDUMP_FILE 2>&1
$DUMP_SCRIPT $SLOT_NAME "threshold" >> $CRASHDUMP_FILE

tar zcf $CRASHDUMP_LOG_ARCHIVE -C `dirname $CRASHDUMP_FILE` `basename $CRASHDUMP_FILE` && \
rm -rf $CRASHDUMP_FILE && \
logger -t "ipmid" -p daemon.crit "Crashdump for $SLOT_NAME is generated at $CRASHDUMP_LOG_ARCHIVE"

echo "Auto Dump for $SLOT_NAME Completed"

rm $PID_FILE
exit 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
echo
echo CPU COREID DUMP:
echo ================
echo
echo < CPUID Read >
0xb8 0x40 0x57 0x01 0x00 0x30 0x05 0x05 0xa1 0x00 0x00 0x00 0x00
echo < CPU Microcode Update Revision Read >
0xb8 0x40 0x57 0x01 0x00 0x30 0x05 0x05 0xa1 0x00 0x00 0x04 0x00
echo < MCA ERROR SOURCE LOG Read -- The socket which MCA_ERR_SRC_LOG[30]=0 is the socket that asserted IERR first >
0xb8 0x40 0x57 0x01 0x00 0x30 0x05 0x05 0xa1 0x00 0x00 0x05 0x00
echo ********************************************************
echo * IERRLOGGINGREG *
echo ********************************************************
0xb8 0x44 0x57 0x01 0x00 0x40 0xa4 0x00 0x04 0x00 0x03
echo ********************************************************
echo * MCERRLOGGINGREG *
echo ********************************************************
0xb8 0x44 0x57 0x01 0x00 0x40 0xa8 0x00 0x04 0x00 0x03

0 comments on commit dcb1830

Please sign in to comment.