emmc `env erase` erase unrelated data
Hello,
I noticed an issue with env erase command when environment is stored in a emmc device, in case start/end are not aligned to the emmc erase groups size additional data is erased with just a warning.
``` Erasing Environment on MMC... Caution! Your devices Erase group is 0x400 The erase range would be change to 0xf800~0xfbff ```
Output from mmc info:
``` Device: FSL_SDHC Manufacturer ID: 13 OEM: 14e Name: S0J56 Bus Speed: 200000000 Mode: HS400 (200MHz) Rd Block Len: 512 MMC version 5.1 High Capacity: Yes Capacity: 14.8 GiB Bus Width: 8-bit DDR Erase Group Size: 512 KiB HC WP Group Size: 8 MiB User Capacity: 14.8 GiB WRREL Boot Capacity: 31.5 MiB ENH RPMB Capacity: 4 MiB ENH ```
I do not think that this is the correct behavior, I think that in case the env is not aligned to the erase block size the erase should either fail or fall back to just writing 0xff. Not sure if just changing mmc_berase() is going to affect any other use case in which is valid to have a non-aligned start/size and just erase around it after a warning.
Any comment?
Francesco
Quoted 33 lines · Francesco Dolcini
Hello,
I noticed an issue with env erase command when environment is stored in a emmc device, in case start/end are not aligned to the emmc erase groups size additional data is erased with just a warning.``` Erasing Environment on MMC... Caution! Your devices Erase group is 0x400 The erase range would be change to 0xf800~0xfbff ```Output from
mmc info:``` Device: FSL_SDHC Manufacturer ID: 13 OEM: 14e Name: S0J56 Bus Speed: 200000000 Mode: HS400 (200MHz) Rd Block Len: 512 MMC version 5.1 High Capacity: Yes Capacity: 14.8 GiB Bus Width: 8-bit DDR Erase Group Size: 512 KiB HC WP Group Size: 8 MiB User Capacity: 14.8 GiB WRREL Boot Capacity: 31.5 MiB ENH RPMB Capacity: 4 MiB ENH ```
Quoted 8 lines
I do not think that this is the correct behavior, I think that in case the env is not aligned to the erase block size the erase should either fail or fall back to just writing
0xff. Not sure if just changingmmc_berase()is going to affect any other use case in which is valid to have a non-aligned start/size and just erase around it after a warning.Any comment?
Largely intentional behavior. Perhaps the help text at least should be updated to note that environment size for MMC needs to be a multiple of erase block size? And further that when using redundant environment it's strongly encouraged to make sure each environment is on its own erase block.
Signature · 1 line
Tom
Hello Tom,
Quoted 4 lines · Tom Rini
Quoted 3 lines · Francesco Dolcini
I noticed an issue with env erase command when environment is stored in a emmc device, in case start/end are not aligned to the emmc erase groups size additional data is erased with just a warning.
...
Quoted 7 lines
Quoted 6 lines
I do not think that this is the correct behavior, I think that in case the env is not aligned to the erase block size the erase should either fail or fall back to just writing
0xff. Not sure if just changingmmc_berase()is going to affect any other use case in which is valid to have a non-aligned start/size and just erase around it after a warning.
Quoted 5 lines
Largely intentional behavior. Perhaps the help text at least should be updated to note that environment size for MMC needs to be a multiple of erase block size? And further that when using redundant environment it's strongly encouraged to make sure each environment is on its own erase block.
I'm not really convinced, but let's move forward from this point.
Are you aware of any other issues in case the emmc environment is not a multiple/aligned to the erase size? I believe that the rest of the code just read/write to it, so once it is aligned to the read/write block size (512 bytes, usually) there should be no problem.
Francesco
Quoted 15 lines · Francesco Dolcini
Hello Tom,
Quoted 4 lines · Tom Rini
Quoted 3 lines · Francesco Dolcini
I noticed an issue with env erase command when environment is stored in a emmc device, in case start/end are not aligned to the emmc erase groups size additional data is erased with just a warning.
...
Quoted 7 lines
Quoted 6 lines
I do not think that this is the correct behavior, I think that in case the env is not aligned to the erase block size the erase should either fail or fall back to just writing
0xff. Not sure if just changingmmc_berase()is going to affect any other use case in which is valid to have a non-aligned start/size and just erase around it after a warning.
Quoted 7 lines
Quoted 5 lines
Largely intentional behavior. Perhaps the help text at least should be updated to note that environment size for MMC needs to be a multiple of erase block size? And further that when using redundant environment it's strongly encouraged to make sure each environment is on its own erase block.
I'm not really convinced, but let's move forward from this point.
Alright. I'll also agree that it was designed when erase blocks were probably smaller and that yes, it's a lot more wasteful these days.
Quoted 4 lines
Are you aware of any other issues in case the emmc environment is not a multiple/aligned to the erase size? I believe that the rest of the code just read/write to it, so once it is aligned to the read/write block size (512 bytes, usually) there should be no problem.
I believe you're correct.
Signature · 1 line
Tom