Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ethernet library not compiling #574

Closed
Letreguilly opened this issue Jul 20, 2015 · 14 comments
Closed

Ethernet library not compiling #574

Letreguilly opened this issue Jul 20, 2015 · 14 comments

Comments

@Letreguilly
Copy link

I trying to use the Ethernet lib (w5100) with the esp8266.

I know that the esp8266 has built in wifi controler, but wired connection are more stable and can provide power using POE. From my point of view the esp8266 is more than wifi.

When i tried to compile :

arduino-1.6.5/libraries/Ethernet/src/Ethernet.cpp: In member function 'int EthernetClass::begin(uint8_t*)':
arduino-1.6.5/libraries/Ethernet/src/Ethernet.cpp:19:45: error: no matching function for call to 'SPIClass::beginTransaction(int, SPISettings)'
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);

This error occur many times.

I have look inside the function signature from the esp8266 SPI.h file :

void beginTransaction(SPISettings settings);

and from the AVR SPI.h file :

inline static void beginTransaction(SPISettings settings) {

The two signature are very close. But each one has is own SPISettings class.

According to the projet homepage, SPI is working. I suppose that the SPISettings class from esp8266 is working. And then i have no other idea how debug this issue.

I'm not a C++ or MCU killer, just an enthusiast user and i have limited knowledge

Thank in advance for help

@Links2004
Copy link
Collaborator

the problem comes from the W5100.h
change:

#if defined(ARDUINO_ARCH_AVR)
#define SPI_ETHERNET_SETTINGS SPISettings(4000000, MSBFIRST, SPI_MODE0)
#else
#define SPI_ETHERNET_SETTINGS SPI_CS,SPISettings(4000000, MSBFIRST, SPI_MODE0)
#endif

to

#if defined(ARDUINO_ARCH_AVR)
#define SPI_ETHERNET_SETTINGS SPISettings(4000000, MSBFIRST, SPI_MODE0)
#elif defined(ESP8266)  
#define SPI_ETHERNET_SETTINGS SPISettings(14000000, MSBFIRST, SPI_MODE0)
#else
#define SPI_ETHERNET_SETTINGS SPI_CS,SPISettings(4000000, MSBFIRST, SPI_MODE0)
#endif

@Letreguilly
Copy link
Author

thank for help,

I have made your modification inside my w5100.h file.

Some other issue appear, i have tried to fix them :

#if defined(ARDUINO_ARCH_AVR)
  SPI.begin();
  initSS();
#elif defined(ESP8266)  
  SPI.begin();
#else
  SPI.begin(SPI_CS);
  // Set clock to 4Mhz (W5100 should support up to about 14Mhz)
  SPI.setClockDivider(SPI_CS, 21);
  SPI.setDataMode(SPI_CS, SPI_MODE0);
#endif

i have modified 5 codes bloc using the same logic. I hope it's working, but the SPI SS management is completely disabled ...

But this is not the main "new" problem, i have a new compilation error out of my knowledge :

Ethernet/Ethernet.cpp.o:(.text+0x18): undefined reference to `__cxa_guard_acquire'
Ethernet/Ethernet.cpp.o:(.text+0x1c): undefined reference to `__cxa_guard_release'
Ethernet/Ethernet.cpp.o:(.text+0x3e): undefined reference to `__cxa_guard_acquire'
Ethernet/Ethernet.cpp.o:(.text+0x4e): undefined reference to `__cxa_guard_release'
collect2: error: ld returned 1 exit status

any idea ?

another ways to get ethernet on the ESP8266 is to use the ENC28J60 and this library : https://github.com/ntruchsess/arduino_uip. Maybe this lib is easier to port on ESP8266 ?

EDIT : i'have tried to hack a little bit the ENC28J60 lib, inside Enc28J60Network.h :

#if defined(ARDUINO_ARCH_AVR)
// AVR-specific code
#define SPI_MOSI        MOSI
#define SPI_MISO        MISO
#define SPI_SCK         SCK
#define SPI_SS          SS
#define ENC28J60_USE_SPILIB 0
#elif defined(ARDUINO_ARCH_SAM)
#define ENC28J60_USE_SPILIB 1
#elif defined(ESP8266)
#define ENC28J60_USE_SPILIB 1  
#endif

i have a similar error :

.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: WebServer.cpp.elf section `.text' will not fit in region `iram1_0_seg'
UIPEthernet/UIPEthernet.cpp.o: In function `UIPEthernetClass::init(unsigned char const*)':
UIPEthernet.cpp:(.text+0x3b8): undefined reference to `__cxa_guard_acquire'
UIPEthernet.cpp:(.text+0x3bc): undefined reference to `__cxa_guard_release'
UIPEthernet.cpp:(.text+0x3d5): undefined reference to `__cxa_guard_acquire'
UIPEthernet/UIPEthernet.cpp.o: In function `UIPEthernetClass::configure(IPAddress, IPAddress, IPAddress, IPAddress)':
UIPEthernet.cpp:(.text+0x3e6): undefined reference to `__cxa_guard_release'
collect2: error: ld returned 1 exit status

@Links2004
Copy link
Collaborator

the __cxa_guard_release problem is handled here #500
but not fixed for the moment.
cxa_guard_acquire and cxa_guard_release need to be implemented.

@Letreguilly
Copy link
Author

OK, is there a way to workaround this issue or i have just to wait ?

@Links2004
Copy link
Collaborator

yes, replace all places where static is initialized by an function / or class in a function.
like this:

int EthernetClass::begin(uint8_t *mac_address)
{
  static DhcpClass s_dhcp;

in this specific case this will work:

static DhcpClass s_dhcp;
int EthernetClass::begin(uint8_t *mac_address)
{

but how to rework it can be different from static case to static case.

@Links2004
Copy link
Collaborator

compiling but no function test.
Links2004@10c5dec
and has many potential for getting more speed of SPI by using writeBytes and transferBytes form SPI instead of transfaring data byte by byte

@Chris2011
Copy link

I use Netbeans with an arduino plugin and I got the same issue, when I build the project. Here is my makefile: http://pastebin.com/Md0R2t4R. I got many errors: http://pastebin.com/qHppisX6

I use windows 7 64bit, GnuWin and Arduino 1.6.4. Do I have really change the w5100.h file? Is there no bug fix for this?

Regards

Chris

@Links2004
Copy link
Collaborator

look like it using the AVR SPI lib sound wrong.

./hardware/arduino/avr/libraries/spi/SPI.h

@Chris2011
Copy link

Do I have to change smth?

@Links2004
Copy link
Collaborator

look like your Netbeans plugin uses the wrong one,
in the Arduino IDE and Eclipse its working.
ask the autor of the plugin to fix the problem.

@Chris2011
Copy link

And which one is the correct one?

@Links2004
Copy link
Collaborator

for ESP8266 the one in the in the esp8266 dir?
https://github.com/esp8266/Arduino/tree/master/libraries/SPI

@Chris2011
Copy link

Thx I will check when I'm home.

@Chris2011
Copy link

As I understand it right, I have to install this plugin first? Because my folder Arduino/libraries has no Folder SPI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants