0

I have a system that has an eMMC card on it, and I am trying to use the erase functioanlity defined in the eMMC specification (6.6.9 Erase) using the the mmc-utils user space tool.

The implantation correct to me. But when I run the command the erase does not work as expected. mmc erase secure-erase <start address in erase blocks> <end address in erase blocks> <device/path>

root@sys:~# # write 0x02 to every byte on the on block device 
root@sys:~# tr '\0' '\2' < /dev/zero > /dev/mmcblk0
root@sys:~# mmc erase secure-erase 0 2 /dev/mmcblk0
Executing Secure Erase from 0x00000000 to 0x00000002
High Capacity Erase Unit Size=524288 bytes
High Capacity Erase Timeout=300 ms
High Capacity Write Protect Group Size=8388608 bytes
 Secure Erase Succeed
root@sys:~# hexdump /dev/mmcblk0
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
0080000 0202 0202 0202 0202 0202 0202 0202 0202
*

I was expecting 2 blocks of 524288 (0x0080000) to be erased. But only one block was erased. I tried several other values and they also did not erase more then one block.

Am I using the tool correctly? does it work for others? Could this be an issue with my mmc driver? or does the issue lay with the firmware on the eMMC?

John b
  • 1,338
  • 8
  • 16
  • What's the size of the storage device? from a peek at the eMMC specification, the addresses are in bytes if <= 2GB, and (512B) sectors if > 2GB (and I'll note that `mmc-utils` doesn't seem to do any processing on the input parameters). – Hasturkun Dec 16 '21 at 09:38
  • I should have specified the mmc is greater then 2GB. It is sold as a 16 GB. The size in bytes is 15634268160 – John b Dec 16 '21 at 19:00
  • Just guessing, but since in either bytes or sectors the end address 2 is in the first block, I'd try passing 2048 (as it should be in sectors) as the end address. – Hasturkun Dec 16 '21 at 19:23
  • You passed the addresses, and not block numbers. Read what you write (what command tells you). – 0andriy Dec 18 '21 at 09:02
  • @0andriy thanks for attempting to help. The eMMC specification states in (section 6.6.9) "The address field in the erase commands is an Erase Group address, in byte units for densities up to 2GB, and in sector units for densities greater than 2GB". I assume this is keep the original size (uint32) for the erase commands. I have also looked at the source for the erase functions, they do not convert the address to sector. It looks like you are new, please be either courteous or correct. – John b Dec 20 '21 at 18:43
  • So, then the tool is correct and erases 2 bytes with the 512k erase block size. Good luck! – 0andriy Dec 20 '21 at 19:21

0 Answers0