Skip to content

Instantly share code, notes, and snippets.

@graste
Created December 30, 2020 09:58
Show Gist options
  • Save graste/451e1c93ca71d5d7d19b242a0be859c3 to your computer and use it in GitHub Desktop.
Save graste/451e1c93ca71d5d7d19b242a0be859c3 to your computer and use it in GitHub Desktop.

Aside from estimating it, you can also ask the eMMC itself to tell you how far it has degraded so far (assuming it supports EMMC 5.1 or above).

The JEDEC standard (JESD84-B51) specifies that in the ext_csd field (offset 268-269) bytes indicate the level of type A/B wear. (value 0x1-0xA reflects 10%-100%, 0x0B means lifetime exceeded)

For example, on a typical linux distro, you could run the following script in bash to tell you:

RES=`cat /sys/kernel/debug/mmc1/mmc1:0001/ext_csd`
typea="${RES:536:2}" ;
typeb="${RES:538:2}" ;
typead=`echo "ibase=16; $typea"|bc`
typebd=`echo "ibase=16; $typeb"|bc`
echo "Type A percent: $((typead * 10)) %"
echo "Type B percent: $((typebd * 10)) %"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment