loathingKernel / ariadne-bootloader

A little less unfinished TFTP bootloader for Arduino Ethernet or Arduino with Ethernet Shield
45 stars 18 forks source link

Address SPI Communication Problem on ATMega2560 #38

Closed phillipjohnston closed 4 years ago

phillipjohnston commented 4 years ago

When using the Arduino Mega platform with the W5500 shield, there is contention between the LED signal and the SCK signal. On the Mega, the LED is mapped to digital pin 13. On the Uno, 13 is the SCK signal, but on the Mega these signals are routed to different headers altogether.

The shield still works in sketches because the SPI signals are also routed to the ISCP header, which is connected to the shield.

The logic in the bootloader is that if the SCK pin and LED pin definitions don't match, the LED pin will be initialized and will blink in the bootloader's main polling loop. On the Mega 2560, the SCK pin definition and LED pin definition do not match, meaning this logic was included.

Because of the routing of the signals, LED pin (Digital 13) and SCK are actually shorted together, so blinking the LED is causing contention on the SCK line.

For now, LED blinking is disabled on the ATMega2560. With this change, we can successfully upload binaries to the device over Ethernet.

Fixes #37

hagaigold commented 4 years ago

@phillipjohnston why do you think there is contention between the LED and the SCK on ATMega2560? the SCK is pin 52 (PINB1) while the LED is pin 13 (PINB7).

I actually have a setup with W5500 shield who work with a blinking LED.

The problem you experience is actually in the W5500. W5500 shield can be used with different boards, e.g. uno or mega. for the mega the W5500 should be configure differently by "Not Mount" D11, D12 & D13.

switch the LED off will just solve the bootloader contention, if your sketch will use pin 11/12/13 you will have again the same problem.

http://wizwiki.net/wiki/doku.php?id=osh:w5500_ethernet_shield:start

image image

phillipjohnston commented 4 years ago

Hi @hagaigold,

You answered the question with your answer. I did not perform (or notice) the necessary rework to eliminate the contention.

phillipjohnston commented 4 years ago

I understand your perspective and appreciate receiving your input. I made the fix with the information I had available to me at the time. None of us is perfect.

Cheers,

Phillip

On 29Jun2020, at 13:10, Hagai Gold notifications@github.com wrote:

I wan not asking a "real" question ;) your fix to the code suggests there is a problem in the code, while I don't think there is. W5500 shield should be configured correctly if you use it on the Mega board, and want to use pin D11/12/13 (which the bootloader does).

I put this information with the hope others can befit from it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/loathingKernel/ariadne-bootloader/pull/38#issuecomment-651333771, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANBIB24TLCQKSE54QNSO73RZDYM7ANCNFSM4JP3MO3A.