8. Очистка разделов флеш-памяти eMMC
Очистка разделов выполняется функцией sunxi_sprite_erase_flash
if (sunxi_sprite_erase_flash(img_mbr))
{ printf("sunxi sprite error: erase flash err\n");
return -1;
}
tick_printf("successed in erasing flash\n");
int sunxi_sprite_erase_flash(void *img_mbr_buffer)
{ int nodeoffset;
uint32_t need_erase_flag = 0;
int mbr_num = SUNXI_MBR_COPY_NUM; // =4
char buf[SUNXI_MBR_SIZE * SUNXI_MBR_COPY_NUM];
//--------------------
// Здесь часть текста пропущена !!!!
// .............................
//------------------------
printf("begin to erase");
sunxi_sprite_erase(need_erase_flag, img_mbr_buffer);
printf("finish erase");
sunxi_sprite_init(0);
printf("rewrite");
sunxi_sprite_download_mbr(img_mbr_buffer,
ALIGN(sizeof(sunxi_mbr_t) * mbr_num,
CONFIG_SYS_CACHELINE_SIZE));
sunxi_flash_write_end();
memset(buf, 0, SUNXI_MBR_SIZE * SUNXI_MBR_COPY_NUM);
if (sunxi_sprite_read_mbr(buf, mbr_num))
{ printf("read local mbr on flash failed");
goto __ERROR_END;
}
if (sunxi_sprite_restore_part_data(buf))
{ sunxi_flash_write_end();
sunxi_sprite_exit(0);
return -1;
}
sunxi_flash_write_end();
printf("flash exit");
sunxi_sprite_exit(0);
return 0;
__ERROR_END:
sunxi_sprite_exit(1);
sunxi_sprite_erase(need_erase_flag, img_mbr_buffer);
return 0;
}
Лог: Очистка разделов флеш-памяти eMMC
[06.421]begin to erase flash
total part: 26
mbr 0, 8000, 8000
bootloader_a 1, 10000, 8000
bootloader_b 2, 10000, 8000
env_a 3, 200, 8000
env_b 4, 200, 8000
boot_a 5, 20000, 8000
boot_b 6, 20000, 8000
vendor_boot_a 7, 10000, 8000
vendor_boot_b 8, 10000, 8000
super 9, 600000, 8000
misc 10, 8000, 8000
vbmeta_a 11, 100, 8000
vbmeta_b 12, 100, 8000
vbmeta_system_a 13, 80, 8000
vbmeta_system_b 14, 80, 8000
vbmeta_vendor_a 15, 80, 8000
vbmeta_vendor_b 16, 80, 8000
frp 17, 400, 8000
empty 18, 7800, 8000
metadata 19, 8000, 8000
private 20, 8000, 8000
dtbo_a 21, 1000, 8000
dtbo_b 22, 1000, 8000
media_data 23, 8000, 8000
Reserve0 24, 8000, 8000
UDISK 25, 0, 8100
[06.481]erase all part start
need erase flash: 1
private part exist
GPT:bootloader_a: 12000 21fff
GPT:bootloader_b: 22000 31fff
GPT:env_a : 32000 321ff
GPT:env_b : 32200 323ff
GPT:boot_a : 32400 523ff
GPT:boot_b : 52400 723ff
GPT:vendor_boot_a: 72400 823ff
GPT:vendor_boot_b: 82400 923ff
GPT:super : 92400 6923ff
GPT:misc : 692400 69a3ff
GPT:vbmeta_a : 69a400 69a4ff
GPT:vbmeta_b : 69a500 69a5ff
GPT:vbmeta_system_a: 69a600 69a67f
GPT:vbmeta_system_b: 69a680 69a6ff
GPT:vbmeta_vendor_a: 69a700 69a77f
GPT:vbmeta_vendor_b: 69a780 69a7ff
GPT:frp : 69a800 69abff
GPT:empty : 69ac00 6a23ff
GPT:metadata : 6a2400 6aa3ff
GPT:private : 6aa400 6b23ff
GPT:dtbo_a : 6b2400 6b33ff
GPT:dtbo_b : 6b3400 6b43ff
GPT:media_data : 6b4400 6bc3ff
GPT:Reserve0 : 6bc400 6c43ff
GPT:userdata : 6c4400 1d59fde
begin to store data
part 0 name bootloader_a
keydata = 0x0
part 1 name bootloader_b
keydata = 0x0
part 2 name env_a
keydata = 0x0
part 3 name env_b
keydata = 0x0
part 4 name boot_a
keydata = 0x0
part 5 name boot_b
keydata = 0x0
part 6 name vendor_boot_a
keydata = 0x0
part 7 name vendor_boot_b
keydata = 0x0
part 8 name super
keydata = 0x0
part 9 name misc
keydata = 0x0
part 10 name vbmeta_a
keydata = 0x0
part 11 name vbmeta_b
keydata = 0x0
part 12 name vbmeta_system_a
keydata = 0x0
part 13 name vbmeta_system_b
keydata = 0x0
part 14 name vbmeta_vendor_a
keydata = 0x0
part 15 name vbmeta_vendor_b
keydata = 0x0
part 16 name frp
keydata = 0x1
find keypart frp
keypart read start: 0x690800, sectors 0x400
keypart part frp read 0x690800, sectors 0x400
part 17 name empty
keydata = 0x0
part 18 name metadata
keydata = 0x0
part 19 name private
keydata = 0x0
find keypart private
keypart read start: 0x6a0400, sectors 0x8000
keypart part private read 0x6a0400, sectors 0x8000
part 20 name dtbo_a
keydata = 0x0
part 21 name dtbo_b
keydata = 0x0
part 22 name media_data
keydata = 0x0
part 23 name Reserve0
keydata = 0x0
part 24 name userdata
keydata = 0x0
begin to erase
[06.804]erase all part start
card2 erase boot0
erase bootloader_b part
[06.820][mmc]: erase from: 139264, to: 204799, cnt: 65536, erase_group: 1024
[06.831][mmc]: sunxi_mmc_do_send_cmd_common: cmd 38 wait rsp busy 0x4 ms
erase env_a part
[06.839][mmc]: after adjust nr, no more space need to erase!!
[06.844][mmc]: after align erase group, no space need to erase, erase failed
[06.851][mmc]: mmc_mmc_erase: erase emmc fail!
[06.855][mmc]: mmc_mmc_erase: some sectors in emmc are ignored!
[06.861][mmc]: --0: from204800 nr512
erase env_b part
[06.880][mmc]: after adjust start addr, no more space need to erase!!
[06.886][mmc]: Erase addr is not erase group alignment!
[06.891][mmc]: erase failed, range 205824 - 206336
[06.896][mmc]: mmc_mmc_erase: erase emmc fail!
[06.900][mmc]: mmc_mmc_erase: some sectors in emmc are ignored!
[06.905][mmc]: --0: from205312 nr512
erase boot_a part
[06.923][mmc]: erase from: 205824, to: 336895, cnt: 131072, erase_group: 1024
[06.953][mmc]: sunxi_mmc_do_send_cmd_common: cmd 38 wait rsp busy 0x17 ms
erase boot_b part
[06.961][mmc]: erase from: 336896, to: 467967, cnt: 131072, erase_group: 1024
[06.976][mmc]: sunxi_mmc_do_send_cmd_common: cmd 38 wait rsp busy 0x7 ms
erase vendor_boot_a part
[06.985][mmc]: erase from: 467968, to: 533503, cnt: 65536, erase_group: 1024
[06.996][mmc]: sunxi_mmc_do_send_cmd_common: cmd 38 wait rsp busy 0x4 ms
erase vendor_boot_b part
[07.005][mmc]: erase from: 533504, to: 599039, cnt: 65536, erase_group: 1024
[07.017][mmc]: sunxi_mmc_do_send_cmd_common: cmd 38 wait rsp busy 0x5 ms
erase super part
[07.025][mmc]: erase from: 599040, to: 6890495, cnt: 6291456, erase_group: 1024
[07.229][mmc]: sunxi_mmc_do_send_cmd_common: cmd 38 wait rsp busy 0xc4 ms
erase misc part
[07.237][mmc]: erase from: 6890496, to: 6923263, cnt: 32768, erase_group: 1024
[07.248][mmc]: sunxi_mmc_do_send_cmd_common: cmd 38 wait rsp busy 0x3 ms
erase vbmeta_a part
[07.256][mmc]: after adjust nr, no more space need to erase!!
[07.262][mmc]: after align erase group, no space need to erase, erase failed
[07.269][mmc]: mmc_mmc_erase: erase emmc fail!
[07.273][mmc]: mmc_mmc_erase: some sectors in emmc are ignored!
[07.278][mmc]: --0: from6923264 nr256
erase vbmeta_b part
[07.293][mmc]: after adjust start addr, no more space need to erase!!
[07.299][mmc]: Erase addr is not erase group alignment!
[07.304][mmc]: erase failed, range 6924288 - 6924544
[07.308][mmc]: mmc_mmc_erase: erase emmc fail!
[07.313][mmc]: mmc_mmc_erase: some sectors in emmc are ignored!
[07.318][mmc]: --0: from6923520 nr256
erase vbmeta_system_a part
[07.342][mmc]: after adjust start addr, no more space need to erase!!
[07.348][mmc]: Erase addr is not erase group alignment!
[07.353][mmc]: erase failed, range 6924288 - 6924416
[07.358][mmc]: mmc_mmc_erase: erase emmc fail!
[07.362][mmc]: mmc_mmc_erase: some sectors in emmc are ignored!
[07.368][mmc]: --0: from6923776 nr128
erase vbmeta_system_b part
[07.382][mmc]: after adjust start addr, no more space need to erase!!
[07.388][mmc]: Erase addr is not erase group alignment!
[07.393][mmc]: erase failed, range 6924288 - 6924416
[07.398][mmc]: mmc_mmc_erase: erase emmc fail!
[07.402][mmc]: mmc_mmc_erase: some sectors in emmc are ignored!
[07.407][mmc]: --0: from6923904 nr128
erase vbmeta_vendor_a part
[07.424][mmc]: after adjust start addr, no more space need to erase!!
[07.430][mmc]: Erase addr is not erase group alignment!
[07.435][mmc]: erase failed, range 6924288 - 6924416
[07.440][mmc]: mmc_mmc_erase: erase emmc fail!
[07.444][mmc]: mmc_mmc_erase: some sectors in emmc are ignored!
[07.450][mmc]: --0: from6924032 nr128
erase vbmeta_vendor_b part
[07.466][mmc]: after adjust start addr, no more space need to erase!!
[07.472][mmc]: Erase addr is not erase group alignment!
[07.477][mmc]: erase failed, range 6924288 - 6924416
[07.482][mmc]: mmc_mmc_erase: erase emmc fail!
[07.486][mmc]: mmc_mmc_erase: some sectors in emmc are ignored!
[07.492][mmc]: --0: from6924160 nr128
erase frp part
[07.505][mmc]: erase from: 6924288, to: 6925311, cnt: 1024, erase_group: 1024
[07.515][mmc]: sunxi_mmc_do_send_cmd_common: cmd 38 wait rsp busy 0x2 ms
erase empty part
[07.522][mmc]: erase from: 6925312, to: 6956031, cnt: 30720, erase_group: 1024
[07.532][mmc]: sunxi_mmc_do_send_cmd_common: cmd 38 wait rsp busy 0x2 ms
erase metadata part
[07.540][mmc]: erase from: 6956032, to: 6988799, cnt: 32768, erase_group: 1024
[07.551][mmc]: sunxi_mmc_do_send_cmd_common: cmd 38 wait rsp busy 0x3 ms
erase private part
[07.559][mmc]: erase from: 6988800, to: 7021567, cnt: 32768, erase_group: 1024
[07.570][mmc]: sunxi_mmc_do_send_cmd_common: cmd 38 wait rsp busy 0x2 ms
erase dtbo_a part
[07.578][mmc]: erase from: 7021568, to: 7025663, cnt: 4096, erase_group: 1024
[07.588][mmc]: sunxi_mmc_do_send_cmd_common: cmd 38 wait rsp busy 0x3 ms
erase dtbo_b part
[07.596][mmc]: erase from: 7025664, to: 7029759, cnt: 4096, erase_group: 1024
[07.606][mmc]: sunxi_mmc_do_send_cmd_common: cmd 38 wait rsp busy 0x3 ms
erase media_data part
[07.614][mmc]: erase from: 7029760, to: 7062527, cnt: 32768, erase_group: 1024
[07.625][mmc]: sunxi_mmc_do_send_cmd_common: cmd 38 wait rsp busy 0x3 ms
erase Reserve0 part
[07.634][mmc]: erase from: 7062528, to: 7095295, cnt: 32768, erase_group: 1024
[07.643][mmc]: sunxi_mmc_do_send_cmd_common: cmd 38 wait rsp busy 0x2 ms
erase UDISK part
sunxi_sprite_mmc_phyerase: @nr is 0, erase from @from to end
[07.657][mmc]: erase from: 7095296, to: 30776319, cnt: 23681024, erase_group: 1024
[07.965][mmc]: sunxi_mmc_do_send_cmd_common: cmd 38 wait rsp busy 0x12c ms
[07.971][mmc]: mmc_mmc_erase: some sectors in emmc are ignored!
[07.977][mmc]: --0: from30776320 nr1023
card erase all
finish erase
rewrite
write primary GPT success
write Backup GPT success
[08.077]update partition map
keypart write start: 0x690800, sectors 0x400
keypart write start: 0x6a0400, sectors 0x8000
flash exit
[08.222]successed in erasing flash