Arduino Ethernet no network connection(toolchain problem on amd64 linux)

Hello,
I just received my Arduino Ethernet and tried some example sketches. Most of them worked, but all Ethernet related examples refused to work. To track down the problem I use the following sketch:

/*
 * Prints a message on serial console
 
 */
#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = {  0x90, 0xA2, 0xDA, 0x00, 0xF0, 0x59 };

//EthernetClient client;

void setup() {
  // start the serial library:
  Serial.begin(9600);
  // print your local IP address:
  Serial.println("Hello I'm your arduino");
  Serial.println("Trying to get an IP Address...");
}

void loop() {
}

This sketch works until I activate the line //EthernetClient client; by removing the comment.
The sketch doesn't work anymore (no serial output).

Any help is appreciated.

Greetings
Anaxi

How does the client object get an IP address?

It should get one by dhcp. But it doesn't matter because as soon as I use any ethernet related feature (notice I just want to instantiate client object) the program stops to work at all.

Try giving a static IP and see if the behavior changes.

Changed sketch to look like this:

/*

  • Prints a message on serial console

*/
#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xF0, 0x59 };
IPAddress ip(192,168,10,22);

EthernetClient client;

void setup() {
// start the serial library:
Serial.begin(9600);
// print your local IP address:
Serial.println("Hello I'm your arduino");
Serial.println("Trying to get an IP Address...");
Ethernet.begin(mac,ip);
}

void loop() {
}

Still no answer via serial console.

Edit1:
I narrowed the problem down to the wz5100 functions. As soon as one of Ethernetserver or Ethernetclient is used, the arduino stops working. If I only use Ethernet.begin(mac, ip) I can at least ping the arduino.

Edit2:
Problem seems to be the toolchain on my amd64 linux box. On my windows machine everythings ok now.
This is sad. I tried avr-gcc-4.5.3 and avr-gcc-4.3.6 both without success.

Does anybody know which combination of avr-gcc / avr-libc is working on amd64 linux ?

This problem got me for the last 3 days, i found a fix tho, i dont think it has anythign to do with 64bit, it is ubuntu 11.10 itself.

Here is the fix for arduino-1.0:

Open /libraries/Ethernet/utility/w5100.h from you arduino installation.

Find: (around line 268)

#define __SOCKET_REGISTER16(name, address)                   \
  static void write##name(SOCKET _s, uint16_t _data) {       \
    writeSn(_s, address,   _data >> 8);                      \
    writeSn(_s, address+1, _data & 0xFF);                    \
  }                                                          \
  static uint16_t read##name(SOCKET _s) {                    \
    uint16_t res = readSn(_s, address);                      \
    res = (res << 8) + readSn(_s, address + 1);              \
    return res;                                              \
  }

Replace with:

#define __SOCKET_REGISTER16(name, address)                   \
  static void write##name(SOCKET _s, uint16_t _data) {       \
    writeSn(_s, address,   _data >> 8);                      \
    writeSn(_s, address+1, _data & 0xFF);                    \
  }                                                          \
  static uint16_t read##name(SOCKET _s) {                    \
    uint16_t res = readSn(_s, address);                      \
    uint16_t res2 = readSn(_s,address + 1); 			\
    res = res << 8;						\
    res2 = res2 & 0xFF;						\
    res = res | res2;						\
    return res;                                              \
  }

Verified working with Ubuntu 11.10 64bit and Arduino-1.0 with ethernet shield

Hi,
I changed those lines but unfortunately it doesn't help.
I also tried the "blink" example this morning and found out it doesn't work on linux, too.
Can you post me your toolchain versions (avr-gcc, avr-libc) ?

Thanks

Update
Oh well, I think I bought a hell lot of problems with these µController things.
First the blink example can be "fixed" as described here Arduino - ArchWiki
Seems that the avr-toolchain is awfully broken. Not only avr-gcc and avr-libc also binutils is affected.
Now on to find out which combination works correctly

Any help is greatly appreciated

avr-gcc v4.5.3 and avr-libc v1.7.1 (with patch) works with a 32 bit version of Ubuntu.

Which flavor of Linux are you using?

edit: avr-libc versions prior to 1.7.1 will have serial and/or delay problems.
avr-libc v1.7.1 or v1.8.0 (also requires a patch) are best.

I'm using Gentoo on AMD64

avr-gcc-4.5.3
avr-libc 1.7.1-2

also i found the patch info here:

http://code.google.com/p/arduino/issues/detail?id=605

Unfortunately it still doesn't work.
I'm using a.t.m:

*  cross-avr/avr-libc
      Latest version installed: 1.7.1
*  cross-avr/gcc
      Latest version installed: 4.4.6-r1
*  cross-avr/binutils
      Latest version installed: 2.19.1-r1

Ethernet still not working...

Update:
Tested:

*  cross-avr/avr-libc
      Latest version installed: 1.7.1
*  cross-avr/gcc
      Latest version installed: 4.5.3-r2
*  cross-avr/binutils
      Latest version installed: 2.19.1-r1

Ethernet still not working...

I was facing a similar problem here, but I am using a 32 bits workstation. To fix the issue I followed the steps of Reply #5 but it wasn't enough, so I have updated all the Ethernet utilities sources [1] and now it is working. I will do more tests but looks like it is fixed for me. I hope it can help you too.

Regards
[1] https://github.com/arduino/Arduino/tree/master/libraries/Ethernet/utility

Thank you all for your help.

I replaced the Ethernet/utility folder content with the files from github, but still no ethernet :frowning:

Still no luck with Ethernet.

Regards

Have you tried it with or without DHCP? I am still unable to connect to the internet using static IP, but I can connect to the internet with DHCP. I can ping the Arduino interface using both modes but can't access the internet with an static IP. I have tried passing the gateway and the subnet too, without success.

Well,
first of all with IDE on windows all modes work fine.
On Linux no mode works at all. It didn't even succeed the init of e.g. EthernetClient object.

I would like to add some a little comment. Looks like we have a bug at Ethernet class. Following another topic at this forum [1], I have found that Ethernet.begin method expect a different parameter than exposed at the documentation.

version 0022 Ethernet.begin(mac, ip, gateway, subnet);
version 1.0 Ethernet.begin(mac, ip, subnet, gateway);

It is weird. How can I file a bug about it?

Regards
[1] Arduino Forum

Actually, that is incorrect for v1.0. Here are the options for the Ethernet.begin() function:

Ethernet.begin(mac);
Ethernet.begin(mac,ip);
Ethernet.begin(mac,ip,dns);
Ethernet.begin(mac,ip,dns,gateway);
Ethernet.begin(mac,ip,dns,gateway,subnet);

There is a dns server ip in there too.

Yes, I have just found it out. There is an updated documentation where we can look at this? I am new with arduino too, so I am not really sure where to get this updated documentation. Thanks a lot for your help.

I did not get that from documentation. I dig through the ethernet library source code. It is much better than documentation to me.

Here is a link to the documentation, and it is not correct for either version.