fix run stub()

This commit is contained in:
hathach 2023-02-17 22:02:30 +07:00
parent 7145cd3bf4
commit 72c94939c8
No known key found for this signature in database
GPG key ID: F5D50C6D51D17CBA

View file

@ -404,7 +404,7 @@ bool ESP32BootROMClass::endMem(uint32_t entry) {
command(ESP_MEM_END, data, sizeof(data)); command(ESP_MEM_END, data, sizeof(data));
return (response(ESP_MEM_DATA, 3000) == 0); return (response(ESP_MEM_END, 3000) == 0);
} }
bool ESP32BootROMClass::syncStub(void) { bool ESP32BootROMClass::syncStub(void) {
@ -422,15 +422,21 @@ bool ESP32BootROMClass::syncStub(void) {
} }
} }
if ( count == 6 && 0 == memcmp(ohai, buf, 6) ) { #if DEBUG
Serial.println("Stub running...\r\n"); if ( count ) {
return true; Serial.print("<= ");
}else{
Serial.printf("Failed to start stub. Unexpected response: count = %d", count);
for(size_t i=0; i<count; i++) { for(size_t i=0; i<count; i++) {
Serial.printf("%02x ", buf[i]); Serial.printf("%02x ", buf[i]);
} }
Serial.println(); Serial.println();
}
#endif
if ( count == 6 && 0 == memcmp(ohai, buf, 6) ) {
Serial.println("Stub running...\r\n");
return true;
}else{
Serial.println("Failed to start stub. Unexpected response");
return false; return false;
} }
} }
@ -475,19 +481,12 @@ bool ESP32BootROMClass::uploadStub(void) {
// sync stub // sync stub
Serial.println("Syncing stub..."); Serial.println("Syncing stub...");
VERIFY( syncStub()); VERIFY( syncStub() );
Serial.println("LOCKED DOWN !!!");
while(1) {
delay(100);
}
return true; return true;
} }
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// Command & Response // Command & Response
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@ -557,7 +556,6 @@ int ESP32BootROMClass::response(uint8_t opcode, uint32_t timeout_ms, void *body,
if (data[0] != 0xc0 || data[1] != 0x01 || data[2] != opcode || if (data[0] != 0xc0 || data[1] != 0x01 || data[2] != opcode ||
data[responseLength + 5] != 0x00 || data[responseLength + 6] != 0x00 || data[responseLength + 5] != 0x00 || data[responseLength + 6] != 0x00 ||
data[responseLength + 9] != 0xc0) { data[responseLength + 9] != 0xc0) {
Serial.printf("Line %d: responseLength = %u\r\n", __LINE__, responseLength);
return -1; return -1;
} }