【SemeDrive】【X9HP】【PTG4.3】X9HP PTG4.3 SDFactoryTool read flash 失败

前言:X9HP PTG4.3 SDFactoryTool read flash 失败

【问题详述】:

在 PTG4.3+SDToolBox_R2.22.3701 上使用 SDFactoryTool 的 read flash 功能回读 emmc 时,遇到了 invalid ptn/size 错误。

 

【分析过程】:

1. 取消勾选 emmmc1$safety$partition 分区后,发现 read flash 功能可以继续进行,直到 read emmmc1$safety$add_safety 分区时报同样的错误。


2. 继续取消勾选其他二级分区表所在的分区以及以 add_* 为前缀的分区,发现 read flash 功能可以成功读取其他分区的固件。





3. 对比烧录进去的一级分区表 emmc1_partition.bin 和回读的 emmc1_partition.bin,发现有少部分字节不一致。

4. 在烧录 prebuild 固件后,回读 emmc,出现了相同的问题。这表明问题不是出现在客制化部分,而是与原始的烧录代码或烧录工具有关。


【解决方案】:

  1. 参考芯驰给的补丁,手动修改 dloader.c,修改内容如下:
diff --git a/lib/dloader/dloader.c b/lib/dloader/dloader.c
index 63b1099..5f0628b 100644
--- a/lib/dloader/dloader.c
+++ b/lib/dloader/dloader.c
@@ -886,19 +886,28 @@ static bool erase_nor_flash_partition(struct partition_device *ptdev,
{
struct storage_device *storage;
uint64_t size, ptn, erase_size;
-
+ bool is_whole;
if (!ptdev || !ptdev->storage
|| !st_info || !img_sz)
return false;

storage = ptdev->storage;
+ is_whole = !strcmp(full_ptname, "all");

- size = ptdev_get_size(ptdev, full_ptname);
- ptn = ptdev_get_offset(ptdev, full_ptname);
+ if (!is_whole)
+ {
+ size = ptdev_get_size(ptdev, full_ptname);
+ ptn = ptdev_get_offset(ptdev, full_ptname);

- if (!ptn || !size) {
- ERROR("ptn or size is 0. name:%s\n", full_ptname);
- return false;
+ if (!ptn || !size) {
+ ERROR("ptn or size is 0. name:%s\n", full_ptname);

+ return false;
+ }
+ }
+ else
+ {
+ ptn = 0;
+ size = storage->get_capacity(storage);
}

erase_size = round_up(img_sz, st_info->erase_grp_sz);
@@ -1016,6 +1025,12 @@ static uint32_t cmd_flash_sparse_img(fastboot_t *fb, const char *arg,
ERROR("boot partition doesn't use sparse image \n");
goto fail;
}
+ else if(pttype == TYPE_ALL_PT)
+ {
+ ptn = 0;
+ size = storage->get_capacity(storage);
+ snprintf(full_ptname, sizeof(full_ptname), "%s", ptname);
+ }
else {
switch_pt_num = PART_ACCESS_DEFAULT;

@@ -5311,7 +5326,7 @@ static bool __verify_partition(fastboot_t *fb,
}

if (remain) {
- if (storage->read(storage, ptn, buf, buf_sz)) {
+ if (storage->read(storage, ptn, buf, round_up(remain, bk_sz))) {
dprintf(CRITICAL, "Fail to read data, ptn:%lld!", ptn);
goto out;
}
@@ -5347,7 +5362,7 @@ static bool verify_partition(fastboot_t *fb,
bool ret = false;
struct storage_device *storage = NULL;
uint64_t ptn, pt_size;
-
+ bool is_whole;
storage = ptdev->storage;
DBG("pt_name:%s verify_sz:%lld type:%d", pt_name, verify_sz,
st_info->type);
@@ -5407,10 +5422,23 @@ static bool verify_partition(fastboot_t *fb,
ptn = ptdev_get_offset(ptdev, pt_name);
pt_size = ptdev_get_size(ptdev, pt_name);
DBG("ptn:%lld pt_size:%lld", ptn, pt_size);
-
+ is_whole = !strcmp(pt_name, "all");
if (!ptn || !pt_size) {
dprintf(CRITICAL, "Invalid partition:%s offset or size!", pt_name);
goto out;
+ if (!is_whole) {
+

★博文内容均由个人提供,与平台无关,如有违法或侵权,请与网站管理员联系。

★文明上网,请理性发言。内容一周内被举报5次,发文人进小黑屋喔~

评论