#!/bin/bash

# A simple script to gather state-dump information for mmc parts.  Data will
# be gathered for any device matching the pattern /dev/mmcblk?.

function dump_mmcsys() {
    # subtract the /dev/ string from the start of the input string
    local mmc_name=${1#/dev/}

    for f in type manfid oemid name prv serial date fwrev cid csd ocr dsr ; do
        local fname=/sys/block/${mmc_name}/device/${f}
        echo $fname
        cat $fname
    done
}

for mmcdev in /dev/mmcblk? ; do
    dump_mmcsys $mmcdev
    echo
    echo /usr/bin/mmc extcsd read $mmcdev
    /usr/bin/mmc extcsd read $mmcdev
done
