njh / EtherCard

EtherCard is an IPv4 driver for the ENC28J60 chip, compatible with Arduino IDE
https://www.aelius.com/njh/ethercard/
GNU General Public License v2.0
1.03k stars 455 forks source link

place mac to SRAM instead of flash #397

Closed nagimov closed 4 years ago

nagimov commented 4 years ago

This example doesn't work when mac is placed to flash (using nano v3 with old bootloader)

nagimov commented 4 years ago

@nuno-silva Yes if it could be implemented similarly to dnsLookup and accept optional fromRam flag that would be ideal:

https://github.com/njh/EtherCard/blob/420dd84ca4b5b4187896cf4aa23cd8ac66ae2cab/src/dns.cpp#L91

nuno-silva commented 4 years ago

No need for an additional argument :) It just needs to be overloaded to receive const __FlashStringHelper* instead of const uint8_t*, like this:

https://github.com/arduino/ArduinoCore-avr/blob/3055c1efa3c6980c864f661e6c8cc5d5ac773af4/cores/arduino/Print.cpp#L44-L55

The overloaded begin method would just need to read the uint8_t array from flash to a temporary buffer in the stack/RAM and call the regular const uint8_t* method. It's also possible to avoid the temporary array by "copy pasting" the regular method and changing the memcpy call to a loop reading from flash :)

nuno-silva commented 4 years ago

I could implemented it, but I have no setup to test it at the moment.

nagimov commented 4 years ago

Better solution is in #398