Skip to content

Instantly share code, notes, and snippets.

@netom
Created October 4, 2021 12:07
Show Gist options
  • Save netom/748434e04970d10ebf2b0c983a45e47f to your computer and use it in GitHub Desktop.
Save netom/748434e04970d10ebf2b0c983a45e47f to your computer and use it in GitHub Desktop.
Search through `dmesg` output, look for BERT related messages and try to save the BERT content as both .hex and binary files.
#!/bin/bash
NOW=$(date +%s)
HEXFNAME=bert-data-${NOW}.hex
BINFNAME=bert-data-${NOW}.bin
{ dmesg \
| grep '\[Hardware Error]: \+[0-9]' \
| sed -r '/.*/ {s/^.*\[Hardware Error]: +[0-9a-FA-F]{4}([0-9a-FA-F]{4}): (([0-9a-FA-F]{8} ){4}).*$/:10 \1 00 \2 00/;s/ //g}' \
; echo ':00000001FF'; \
} | srec_cat - -intel -IGnore_Checksums -o - -intel > $HEXFNAME
objcopy --input-target=ihex --output-target=binary $HEXFNAME $BINFNAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment