TS-4900 EMMC: Difference between revisions

From embeddedTS Manuals
No edit summary
No edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 5: Line 5:
When this pSLC mode is turned on it will reduce the available space to under half, and reduce the write speed.
When this pSLC mode is turned on it will reduce the available space to under half, and reduce the write speed.


See our post on [https://www.embeddedarm.com/blog/preventing-filesystem-corruption-in-embedded-linux/ preventing filesystem corruption].
See our post on [https://www.embeddedTS.com/blog/preventing-filesystem-corruption-in-embedded-linux/ preventing filesystem corruption].


The mmc-utils package is used to enable these modes. First determine the exact size of the flash you're using:
The mmc-utils package is used to enable these modes. First determine the exact size of the flash you're using:
Line 15: Line 15:
  i.e. 1888256 KiB
  i.e. 1888256 KiB
</pre>
</pre>
So in this case, 1888256 KiB is the max size of the enhanced partition. This number should be used for the enh_area command:
 
So in this case, 1888256 KiB (1.801 GiB) is the max size of the enhanced partition.
<source lang=bash>
<source lang=bash>
MAX_ENH_SIZE=$(mmc extcsd read /dev/mmcblk2 | grep "\\[MAX_ENH_SIZE_MULT\\]" -A 1 | sed -n '2p' | cut -f 3 -d ' ')
mmc write_reliability set -n 0 /dev/mmcblk2
mmc write_reliability set -n 0 /dev/mmcblk2
mmc enh_area set -y 0 1888256 /dev/mmcblk2
# If write_reliability fails with "WR_REL_SET is read-only", this can be ignored. Many newer
# eMMC chipsets ship with write reliability always on
 
mmc enh_area set -y 0 "$MAX_ENH_SIZE" /dev/mmcblk2
</source>
</source>
{{Warning|Setting either of those modes is permanent.  Using the wrong value it is possible to brick eMMC which will not be covered by the warranty.  Evaluation units with fuses set will not be accepted through returns.}}
{{Warning|Setting either of those modes is permanent.  Using the wrong value it is possible to brick eMMC which will not be covered by the warranty.  Evaluation units with fuses set will not be accepted through returns.}}
Line 30: Line 35:
mmc extcsd read /dev/mmcblk2 > /tmp/csd
mmc extcsd read /dev/mmcblk2 > /tmp/csd
PART_DONE=$(grep PARTITION_SETTING_COMPLETED < /tmp/csd | cut -f 2 -d ':' | tr -d '[:space:]')
PART_DONE=$(grep PARTITION_SETTING_COMPLETED < /tmp/csd | cut -f 2 -d ':' | tr -d '[:space:]')
if [ "$PART_DONE" == "0x00" ]; then
if [ "$PART_DONE" = "0x00" ]; then
     WR_REL_SET=$(grep "\\[WR_REL_SET\\]" < /tmp/csd | cut -f 2 -d ':' | tr -d '[:space:]')
     WR_REL_SET=$(grep "\\[WR_REL_SET\\]" < /tmp/csd | cut -f 2 -d ':' | tr -d '[:space:]')
     MAX_ENH_SIZE_MULT=$(grep "\\[MAX_ENH_SIZE_MULT\\]" < /tmp/csd | cut -f 2 -d ':' | tr -d '[:space:]')
     MAX_ENH_SIZE=$(grep "\\[MAX_ENH_SIZE_MULT\\]" < /tmp/csd -A 1 | sed -n '2p' | cut -f 3 -d ' ')
    MAX_ENH_SIZE=$((MAX_ENH_SIZE_MULT*4096))


     # Some eMMC devices ship with this enabled already
     # Some eMMC devices ship with this enabled already
     if [ "$WR_REL_SET" == "0x00" ]; then
     if [ "$WR_REL_SET" = "0x00" ]; then
         mmc write_reliability set -n 0 /dev/mmcblk2
         mmc write_reliability set -n 0 /dev/mmcblk2
     fi
     fi
Line 46: Line 50:
else
else
     echo "Paritioning is completed!"
     echo "Paritioning is completed!"
    exit 0
fi
fi
</source>
</source>

Latest revision as of 12:50, 3 February 2023

This board includes a Micron eMMC module with builds that have "4096F" in the part number. Our off the shelf builds are 4GiB, but up to 64GiB are available for larger builds. The eMMC flash appears to Linux as an SD card at /dev/mmcblk2. Our default programming will include one partition programmed with our Yocto image.

The eMMC are like SD cards in that they should not be powered down during a write/erase cycle. This eMMC module includes support for setting a fuse for a "Write Reliability" mode, and a "psuedo SLC" mode. With both of these enabled then any writes will be atomic to 512B. If a sector is being written during a power loss, a block is guaranteed to have either the old or new data. This scheme is far more resilient to power loss than more traditional flash media. In cases of old 512B data fsck will still be able to recover a mountable filesystem. In cases where the corrupted file is a database it can still need a mechanism for recovery.

When this pSLC mode is turned on it will reduce the available space to under half, and reduce the write speed.

See our post on preventing filesystem corruption.

The mmc-utils package is used to enable these modes. First determine the exact size of the flash you're using:

mmc extcsd read /dev/mmcblk2 | grep MAX_ENH_SIZE_MULT -A 1
Max Enhanced Area Size [MAX_ENH_SIZE_MULT]: 0x0001cd
 i.e. 1888256 KiB

So in this case, 1888256 KiB (1.801 GiB) is the max size of the enhanced partition.

MAX_ENH_SIZE=$(mmc extcsd read /dev/mmcblk2 | grep "\\[MAX_ENH_SIZE_MULT\\]" -A 1 | sed -n '2p' | cut -f 3 -d ' ')
mmc write_reliability set -n 0 /dev/mmcblk2
# If write_reliability fails with "WR_REL_SET is read-only", this can be ignored. Many newer 
# eMMC chipsets ship with write reliability always on

mmc enh_area set -y 0 "$MAX_ENH_SIZE" /dev/mmcblk2
WARNING: Setting either of those modes is permanent. Using the wrong value it is possible to brick eMMC which will not be covered by the warranty. Evaluation units with fuses set will not be accepted through returns.

After this is run, cycle power to the board. On all future boots the eMMC will be detected at the smaller size. Changing the enhanced area will erase the drive. After these mmc commands the disk will need to be rewritten.

This can be applied automatically from our usb production blast.sh with:

#!/bin/bash

mmc extcsd read /dev/mmcblk2 > /tmp/csd
PART_DONE=$(grep PARTITION_SETTING_COMPLETED < /tmp/csd | cut -f 2 -d ':' | tr -d '[:space:]')
if [ "$PART_DONE" = "0x00" ]; then
    WR_REL_SET=$(grep "\\[WR_REL_SET\\]" < /tmp/csd | cut -f 2 -d ':' | tr -d '[:space:]')
    MAX_ENH_SIZE=$(grep "\\[MAX_ENH_SIZE_MULT\\]" < /tmp/csd -A 1 | sed -n '2p' | cut -f 3 -d ' ')

    # Some eMMC devices ship with this enabled already
    if [ "$WR_REL_SET" = "0x00" ]; then
        mmc write_reliability set -n 0 /dev/mmcblk2
    fi
    mmc enh_area set -y 0 "$MAX_ENH_SIZE" /dev/mmcblk2
    # This requires a power cycle on the eMMC for these settings.  
    # This pokes a register in the FPGA to cause a real POR rather 
    # than software reset
    tshwctl --addr 30 --poke 0x2
else
    echo "Paritioning is completed!"
fi