Skip to content

Instantly share code, notes, and snippets.

@Krutonium
Last active October 18, 2024 21:55
Show Gist options
  • Save Krutonium/488184bab170cdd23de6f778f8b2db6a to your computer and use it in GitHub Desktop.
Save Krutonium/488184bab170cdd23de6f778f8b2db6a to your computer and use it in GitHub Desktop.
A script to dump and archive all the basic information available on a running system, needed for making a CoreBoot port. Requires Nix (not NixOS).
#!/usr/bin/env nix-shell
#! nix-shell -i bash --pure
#! nix-shell -p bash
#! nix-shell -p pciutils
#! nix-shell -p usbutils
#! nix-shell -p superiotool
#! nix-shell -p inteltool
#! nix-shell -p ectool
#! nix-shell -p msrtool
#! nix-shell -p dmidecode
#! nix-shell -p nvramtool
#! nix-shell -p coreboot-toolchain.x64
#! nix-shell -p flashrom
#! nix-shell -p util-linux
#! nix-shell -p p7zip
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# Run commands and generate logs
lspci -nnvvvxxxx > lspci.log 2> lspci.err.log
lsusb -vvv > lsusb.log 2> lsusb.err.log
superiotool -deV > superiotool.log 2> superiotool.err.log
inteltool -a > inteltool.log 2> inteltool.err.log
ectool -i > ectool.log 2> ectool.err.log
msrtool > msrtool.log 2> msrtool.err.log
dmidecode > dmidecode.log 2> dmidecode.err.log
biosdecode > biosdecode.log 2> biosdecode.err.log
nvramtool -x > nvramtool.log 2> nvramtool.err.log
dmesg > dmesg.log 2> dmesg.err.log
acpidump > acpidump.log 2> acpidump.err.log
# Capture sound pin and codec info
for x in /sys/class/sound/card0/hw*; do
cat "$x/init_pin_configs" > pin_"$(basename "$x")"
done
for x in /proc/asound/card0/codec#*; do
cat "$x" > "$(basename "$x")"
done
# Capture CPU and IO ports information
cat /proc/cpuinfo > cpuinfo.log 2> cpuinfo.err.log
cat /proc/ioports > ioports.log 2> ioports.err.log
cat /sys/class/input/input*/id/bustype > input_bustypes.log
# Flashrom operations
flashrom -V -p internal:laptop=force_I_want_a_brick > flashrom_info.log 2> flashrom_info.err.log
flashrom -V -p internal:laptop=force_I_want_a_brick -r rom.bin > flashrom_read.log 2> flashrom_read.err.log
# Archive results
script_name=$(basename "$0")
7z a results.7z * -xr!"$script_name"
# Clean up generated log files
rm -f lspci.log lspci.err.log lsusb.log lsusb.err.log \
superiotool.log superiotool.err.log inteltool.log inteltool.err.log \
ectool.log ectool.err.log msrtool.log msrtool.err.log \
dmidecode.log dmidecode.err.log biosdecode.log biosdecode.err.log \
nvramtool.log nvramtool.err.log dmesg.log dmesg.err.log \
acpidump.log acpidump.err.log cpuinfo.log cpuinfo.err.log \
ioports.log ioports.err.log input_bustypes.log \
flashrom_info.log flashrom_info.err.log flashrom_read.log flashrom_read.err.log \
pin_hw* codec#* rom.bin
echo "Everything can be found in results.7z - Have fun!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment