1- /* Copyright 2020-2023 Espressif Systems (Shanghai) CO LTD
1+ /* Copyright 2020-2024 Espressif Systems (Shanghai) CO LTD
22 *
33 * Licensed under the Apache License, Version 2.0 (the "License");
44 * you may not use this file except in compliance with the License.
2222#include <string.h>
2323#include <assert.h>
2424
25- static const uint32_t DEFAULT_TIMEOUT = 1000 ;
26- static const uint32_t DEFAULT_FLASH_TIMEOUT = 3000 ;
27- static const uint32_t LOAD_RAM_TIMEOUT_PER_MB = 2000000 ;
25+ #define SHORT_TIMEOUT 100
26+ #define DEFAULT_TIMEOUT 1000
27+ #define DEFAULT_FLASH_TIMEOUT 3000
28+ #define LOAD_RAM_TIMEOUT_PER_MB 2000000
29+ #define MD5_TIMEOUT_PER_MB 8000
2830
2931typedef enum {
3032 SPI_FLASH_READ_ID = 0x9F
@@ -40,7 +42,6 @@ static uint32_t s_target_flash_size = 0;
4042
4143#if MD5_ENABLED
4244
43- static const uint32_t MD5_TIMEOUT_PER_MB = 8000 ;
4445static struct MD5Context s_md5_context ;
4546static uint32_t s_start_address ;
4647static uint32_t s_image_size ;
@@ -83,6 +84,7 @@ esp_loader_error_t esp_loader_connect(esp_loader_connect_args_t *connect_args)
8384 s_target_flash_size = 0 ;
8485
8586 if (s_target == ESP8266_CHIP ) {
87+ loader_port_start_timer (DEFAULT_TIMEOUT );
8688 return loader_flash_begin_cmd (0 , 0 , 0 , 0 , s_target );
8789 } else {
8890 uint32_t spi_config ;
@@ -132,6 +134,7 @@ esp_loader_error_t esp_loader_connect_secure_download_mode(esp_loader_connect_ar
132134 }
133135
134136 if (s_target == ESP8266_CHIP ) {
137+ loader_port_start_timer (DEFAULT_TIMEOUT );
135138 return loader_flash_begin_cmd (0 , 0 , 0 , 0 , s_target );
136139 } else {
137140 uint32_t spi_config ;
@@ -415,8 +418,9 @@ static uint32_t byte_popcnt(uint8_t byte)
415418
416419esp_loader_error_t esp_loader_get_security_info (esp_loader_target_security_info_t * security_info )
417420{
418- get_security_info_response_data_t resp ;
421+ loader_port_start_timer ( SHORT_TIMEOUT ) ;
419422
423+ get_security_info_response_data_t resp ;
420424 uint32_t response_received_size = 0 ;
421425 RETURN_ON_ERROR (loader_get_security_info_cmd (& resp , & response_received_size ));
422426
0 commit comments