Explorar o código

Merge branch 'fix/fix_sync_response_reception' into 'master'

fix(protocol): Fix SYNC packet response reception

Closes ESF-94

See merge request espressif/esp-serial-flasher!84
Djordje Nedic %!s(int64=2) %!d(string=hai) anos
pai
achega
033fb55566
Modificáronse 3 ficheiros con 17 adicións e 4 borrados
  1. 1 1
      idf_component.yml
  2. 7 1
      src/protocol_uart.c
  3. 9 2
      test/test.cpp

+ 1 - 1
idf_component.yml

@@ -1,3 +1,3 @@
-version: "0.4.2"
+version: "0.4.3"
 description: Serial flasher component provides portable library for flashing or loading ram loadble app to Espressif SoCs from other host microcontroller
 url: https://github.com/espressif/esp-serial-flasher

+ 7 - 1
src/protocol_uart.c

@@ -51,7 +51,13 @@ esp_loader_error_t send_cmd(const void *cmd_data, uint32_t size, uint32_t *reg_v
     RETURN_ON_ERROR( SLIP_send((const uint8_t *)cmd_data, size) );
     RETURN_ON_ERROR( SLIP_send_delimiter() );
 
-    return check_response(command, reg_value, &response, sizeof(response));
+    const uint8_t response_cnt = command == SYNC ? 8 : 1;
+    
+    for (uint8_t recv_cnt = 0; recv_cnt < response_cnt; recv_cnt++) {
+        RETURN_ON_ERROR(check_response(command, reg_value, &response, sizeof(response)));
+    }
+
+    return ESP_LOADER_SUCCESS;
 }
 
 

+ 9 - 2
test/test.cpp

@@ -128,7 +128,11 @@ void queue_connect_response(target_chip_t target = ESP32_CHIP, uint32_t magic_va
     auto magic_value_response = read_reg_response;
     magic_value_response.data.common.value = magic_value ? magic_value : chip_magic_value[target];
     clear_buffers();
-    queue_response(sync_response);
+
+    for (uint8_t resp = 0; resp < 8; resp++) {
+        queue_response(sync_response);
+    }
+    
     queue_response(magic_value_response);
 
     if (target == ESP8266_CHIP) {
@@ -323,7 +327,10 @@ TEST_CASE( "Sync command is constructed correctly" )
     };
 
     clear_buffers();
-    queue_response(sync_response);
+    
+    for (uint8_t resp = 0; resp < 8; resp++) {
+        queue_response(sync_response);
+    }
 
     REQUIRE_SUCCESS( loader_sync_cmd() );