embeddedartistry / athena-bootloader

An AVR Arduino bootloader that supports uploads over Ethernet (via TFTP) and Serial.
GNU Lesser General Public License v2.1
12 stars 5 forks source link

Investigate: Ariadne Misuses W5100 and W5200 #19

Closed phillipjohnston closed 2 years ago

phillipjohnston commented 4 years ago

From original project:

From @davidhaenggi on February 9, 2015 14:40 Hi I downloaded the Ariadne-Bootloader to use it with a OpenMediaController. It's based on a Atmega2560 and includes a Wiznet W5100 ethernet chip. In general the bootloader works great, thanks for the nice work. While trying to upload bigger firmware files I was running into the "64-Package" Problem. For me it looks like the arduino is receiving a completely messed up message instead of package number 64. When it tries to read the source IP address of the package it gets some random IP and therefor tries to send a response to this random IP. Thats why the Wiznet chip tries to reach to gateway, because the random IP is not in its IP range.

hagaigold commented 2 years ago

this is probably because of misuses of the RX Read Pointer Register (REG_S3_RX_RD0) and the TX Write Pointer Register (REG_S3_TX_WR0).

this was reported by @MarekLew here and then copy to here

A suggested fix can be found in misuses-Read-and-Write-Pointers branch
diff: https://github.com/hagaigold/athena-bootloader/compare/master...fix/misuses-Read-and-Write-Pointers

Currently, I don't have a W5100 (or W5200), so it has still not been tested

hagaigold commented 2 years ago

Currently, I don't have a W5100 (or W5200), so it has still not been tested

Tested with Mega+W5100. This fix helps resolve issue #18 as well- when working properly with the WIZnet chip, we can decrease TFTP_PACKET_DELAY.

Attached are logs with the issue and without, after applying the suggested fix: Mega_w5100_bigimage_working.txt Mega_w5100_bigimage_fail.txt

the issue is obvious if you follow the message Processing packet of size nnnn:

[2022-01-20 20:39:40.326] Tftp: Processing packet of size 0x8A0C
[2022-01-20 20:39:40.326] Tftp: Overflow
[2022-01-20 20:39:40.341] Tftp: Set up return address
[2022-01-20 20:39:40.341] Tftp: This is block 0x0002 with opcode 0x0003 and data length 0x0200
[2022-01-20 20:39:40.341] Tftp: Data block
[2022-01-20 20:39:40.341] Tftp: Writing data from address 0x000200
[2022-01-20 20:39:40.357] Tftp: Packet length adjusted to 0x0200
[2022-01-20 20:39:40.373] Tftp: Sent ACK
[2022-01-20 20:39:40.373] Tftp: Response sent
[2022-01-20 20:39:40.779] Tftp: Processing packet of size 0x8A0C
[2022-01-20 20:39:40.779] Tftp: Overflow