From d288340098b0940e538f6463e90b15b43bb15dc7 Mon Sep 17 00:00:00 2001 From: xychen Date: Tue, 12 Jul 2022 15:58:52 +0800 Subject: [PATCH] =?UTF-8?q?serial:=20=E5=B0=86=20CMD=5FFLASH=5FEND=20?= =?UTF-8?q?=E4=BD=9C=E4=B8=BA=E5=8D=95=E7=8B=AC=E7=9A=84=20soft=20reset=20?= =?UTF-8?q?=E6=8F=90=E4=BE=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 该问题由 03e057b25e2beeea9efa85ee9b3419d37e84bbbd 引入,会导致每烧完一个分区后 芯片被软复位。 该问题的影响: * 在 CSK4 中,该问题会导致第2个及之后的分区烧录失败,或带上 --verify-all 烧录 没有响应 * 在 CSK6 中,会导致烧录第1个分区之后退回 ROM code loader (若 PB1 仍下拉),由 ROM code 完成余下分区的烧录 --- cskburn/src/main.c | 4 +++- libcskburn_serial/include/cskburn_serial.h | 4 +++- libcskburn_serial/src/core.c | 10 +++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/cskburn/src/main.c b/cskburn/src/main.c index af0db60..3879edf 100644 --- a/cskburn/src/main.c +++ b/cskburn/src/main.c @@ -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; diff --git a/libcskburn_serial/include/cskburn_serial.h b/libcskburn_serial/include/cskburn_serial.h index 940f264..dfe4f73 100644 --- a/libcskburn_serial/include/cskburn_serial.h +++ b/libcskburn_serial/include/cskburn_serial.h @@ -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__ diff --git a/libcskburn_serial/src/core.c b/libcskburn_serial/src/core.c index 78ed81f..e74d924 100644 --- a/libcskburn_serial/src/core.c +++ b/libcskburn_serial/src/core.c @@ -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); @@ -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