Go Down

Topic: Monitor serial0 while code is being uploaded (Read 241 times) previous topic - next topic

chris_db

Oct 13, 2019, 04:50 pm Last Edit: Oct 13, 2019, 04:54 pm by chris_db
I'm trying to upload the sketch on a Mega 2560 via the serial port 0 using another microcontroller.

To better undestand the process, I decided to first observe what avrdude is doing while it is uploading a hex file. To do this, I'm using another arduino (ESP32) with the following sketch:
Code: [Select]
void setup()
{
    Serial.begin(115200);
    Serial2.begin(115200);
}

void loop()
{
    while (Serial2.available()) {
        Serial.print(Serial2.read(), HEX);
        Serial.print(":");
    }
}

ESP32's Serial (serial0) is connected to PC via USB, and Serial2 is connected to Mega's Serial (serial0), the one connected to PC via USB, used by avrdude.

According to this answer the first things avrdude is sending over the serial interface are:
STK_GET_SYNC / CRC_EOP  (0x30/0x20)

But this is not what I receive through ESP32:
Code: [Select]
1B:1:0:1:E:1:14:1B:2:0:C:E:10:C8:64:19:20:0:53:3:AC:53:0:0:31:1B:3:0:8:E:1D:4:4:0:30:0:0:0:33:1B:4:0:8:E:1D:4:4:0:30:0:1:0:35:1B:5:0:8:E:1D:4:4:0:30:0:2:0:37:1B:6:0:8:E:1D:4:4:0:50:0:0:0:56:1B:7:0:8:E:1D:4:4:0:50:0:0:0:57:1B:8:0:8:E:1D:4:4:0:50:0:0:0:58:1B:9:0:8:E:1D:4:4:0:58:8:0:0:59:1B:A:0:8:E:1D:4:4:0:58:8:0:0:5A:1B:B:0:8:E:1D:4:4:0:58:8:0:0:5B:1B:C:0:8:E:1D:4:4:0:50:8:0:0:54:1B:D:0:8:E:1D:4:4:0:50:8:0:0:55:1B:E:0:8:E:1D:4:4:0:50:8:0:0:56:1B:F:0:5:E:6:80:0:0:0:99:1B:10:1:A:E:13:1:0:C1:A:40:4C:20:0:0:71:C0:0:0:81:C0:0:0:7F:C0:0:0:7D:C0:0:0:7B:C0:0:0:79:C0:0:0:77:C0:0:0:75:C0:0:0:73:C0:0:0:71:C0:0:0:6F:C0:0:0:6D:C0:0:0:6B:C0:0:0:69:C0:0:0:67:C0:0:0:65:C0:0:0:63:C0:0:0:61:C0:0:0:5F:C0:0:0:5D:C0:0:0:5B:C0:0:0:59:C0:0:0:57:C0:0:0:56:C0:0:0:53:C0:0:0:51:C0:0:0:4F:C0:0:0:4D:C0:0:0:4B:C0:0:0:49:C0:0:0:47:C0:0:0:45:C0:0:0:43:C0:0:0:41:C0:0:0:3F:C0:0:0:3D:C0:0:0:3B:C0:0:0:39:C0:0:0:37:C0:0:0:35:C0:0:0:33:C0:0:0:31:C0:0:0:2F:C0:0:0:2D:C0:0:0:2B:C0:0:0:29:C0:0:0:27:C0:0:0:25:C0:0:0:23:C0:0:0:21:C0:0:0:1F:C0:0:0:1D:C0:0:0:1B:C0:0:0:19:C0:0:0:17:C0:0:0:15:C0:0:0:13:C0:0:0:11:24:1F:BE:CF:EF:D1:E2:DE:BF:CD:BF:0:E0:C:BF:22:E0:A0:E0:B2:E0:1:C0:1D:92:A9:30:19:1B:11:0:5:E:6:80:0:0:80:7:1B:12:1:A:E:13:1:0:C1:A:40:4C:20:0:0:B2:7:E1:F7:4C:D0:C2:C0:7B:CF:1F:92:F:92:F:B6:F:92:11:24:2F:93:3F:93:8F:93:9F:93:AF:93:BF:93:80:91:5:2:90:91:6:2:A0:91:7:2:B0:91:8:2:30:91:4:2:23:E0:23:F:2D:37:20:F4:1:96:A1:1D:B1:1D:5:C0:26:E8:23:F:2:96:A1:1D:B1:1D:20:93:4:2:80:93:5:2:90:93:6:2:A0:93:7:2:B0:93:8:2:80:91:0:2:90:91:1:2:A0:91:2:2:B0:91:3:2:1:96:A1:1D:B1:1D:80:93:0:2:90:93:1:2:A0:93:2:2:B0:93:3:2:BF:91:AF:91:9F:91:8F:91:3F:91:2F:91:F:90:F:BE:F:90:1F:90:18:95:78:94:84:B5:82:60:84:BD:84:B5:81:60:84:BD:85:B5:82:60:85:BD:85:B5:81:60:85:BD:80:91:6E:0:81:60:80:93:6E:0:10:92:81:0:80:91:81:0:82:60:80:93:81:0:80:91:81:0:81:60:80:93:81:0:80:91:80:0:81:60:80:93:80:0:80:91:B1:0:84:60:80:93:B1:0:80:91:B0:0:81:60:1B:13:0:5:E:6:80:0:1:0:84:1B:14:1:A:E:13:1:0:C1:A:40:4C:20:0:0:91:0:80:91:91:0:81:60:80:93:91:0:80:91:90:0:81:60:80:93:90:0:80:91:A1:0:82:60:80:93:A1:0:80:91:A1:0:81:60:80:93:A1:0:80:91:A0:0:81:60:80:93:A0:0:80:91:21:1:82:60:80:93:21:1:80:91:21:1:81:60:80:93:21:1:80:91:20:1:81:7A:0:80:91:7A:0:81:60:80:93:7A:0:80:91:7A:0:80:68:80:93:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:1B:15:0:8:E:1D:4:4:0:50:0:0:0:45:1B:16:0:8:E:1D:4:4:0:50:0:0:0:46:1B:17:0:8:E:1D:4:4:0:50:0:0:0:47:1B:18:0:8:E:1D:4:4:0:58:8:0:0:48:1B:19:0:8:E:1D:4:4:0:58:8:0:0:49:1B:1A:0:8:E:1D:4:4:0:58:8:0:0:4A:1B:1B:0:8:E:1D:4:4:0:50:8:0:0:43:1B:1C:0:8:E:1D:4:4:0:50:8:0:0:44:1B:1D:0:8:E:1D:4:4:0:50:8:0:0:45:1B:1E:0:3:E:11:1:1:19:
I can't find 30:20 anywhere. What am I missing?

The baud rate is 115200 everywhere which I believe is the right one. The link is good because if I send char 'A' from PC over the serial connected to Mega, I get 41: via ESP32 on the other side, which is correct.

tf68

The Mega uses the wiring bootloader, not optiboot. So you are expecting the wrong output.
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] ...
If you run avrdude in a terminal with -v -v -v -v in the command-line it will output a detailed log of its activity.
If you have verbose output enabled you can copy the avrdude command from the lower window of the IDE.

Go Up