Skip to content

Commit

Permalink
serial: 将 CMD_FLASH_END 作为单独的 soft reset 提供
Browse files Browse the repository at this point in the history
该问题由 03e057b 引入,会导致每烧完一个分区后
芯片被软复位。

该问题的影响:

* 在 CSK4 中,该问题会导致第2个及之后的分区烧录失败,或带上 --verify-all 烧录
  没有响应
* 在 CSK6 中,会导致烧录第1个分区之后退回 ROM code loader (若 PB1 仍下拉),由
  ROM code 完成余下分区的烧录
  • Loading branch information
xychen committed Jul 12, 2022
1 parent ae675a3 commit d288340
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion cskburn/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,13 +674,15 @@ serial_burn(uint32_t *addrs, char **images, int parts)
}
}

cskburn_serial_soft_reset(dev);

LOGI("Finished");
ret = true;

err_write:
free(image_buf);
err_enter:
cskburn_serial_reset(dev, options.reset_delay);
cskburn_serial_hard_reset(dev, options.reset_delay);
cskburn_serial_close(&dev);
err_open:
return ret;
Expand Down
4 changes: 3 additions & 1 deletion libcskburn_serial/include/cskburn_serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ bool cskburn_serial_verify(

bool cskburn_serial_read_chip_id(cskburn_serial_device_t *dev, uint64_t *chip_id);

bool cskburn_serial_reset(cskburn_serial_device_t *dev, uint32_t reset_delay);
bool cskburn_serial_soft_reset(cskburn_serial_device_t *dev);

bool cskburn_serial_hard_reset(cskburn_serial_device_t *dev, uint32_t reset_delay);

#endif // __LIB_CSKBURN_SERIAL__
10 changes: 7 additions & 3 deletions libcskburn_serial/src/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,6 @@ cskburn_serial_write(cskburn_serial_device_t *dev, uint32_t addr, uint8_t *image
}
#endif // FEATURE_MD5_CHALLENGE

cmd_flash_finish(dev);

uint64_t t2 = time_monotonic();

uint32_t spent = (uint32_t)((t2 - t1) / 1000);
Expand Down Expand Up @@ -330,7 +328,13 @@ cskburn_serial_read_chip_id(cskburn_serial_device_t *dev, uint64_t *chip_id)
}

bool
cskburn_serial_reset(cskburn_serial_device_t *dev, uint32_t reset_delay)
cskburn_serial_soft_reset(cskburn_serial_device_t *dev)
{
return cmd_flash_finish(dev);
}

bool
cskburn_serial_hard_reset(cskburn_serial_device_t *dev, uint32_t reset_delay)
{
serial_set_rts(dev->handle, !rts_active); // UPDATE=HIGH
serial_set_dtr(dev->handle, SERIAL_LOW); // RESET=LOW
Expand Down

0 comments on commit d288340

Please sign in to comment.