Go Down

Topic: Arduino Ethernet no network connection(toolchain problem on amd64 linux) (Read 4789 times) previous topic - next topic

Anaximander

Mar 08, 2012, 09:07 pm Last Edit: Mar 09, 2012, 10:17 pm by Anaximander Reason: 1
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:
Code: [Select]
/*
* 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
Code: [Select]
//EthernetClient client; by removing the comment.
The sketch doesn't work anymore (no serial output).

Any help is appreciated.

Greetings
Anaxi

James C4S

How does the client object get an IP address?
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Anaximander

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.

James C4S

Try giving a static IP and see if the behavior changes.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Anaximander

#4
Mar 09, 2012, 04:15 pm Last Edit: Mar 09, 2012, 10:20 pm by Anaximander Reason: 1
Changed sketch to look like this:
Quote

/*
* 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 ?

scriptjerk

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)
Code: [Select]
#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:
Code: [Select]
#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

Anaximander

#6
Mar 10, 2012, 08:49 am Last Edit: Mar 10, 2012, 09:08 am by Anaximander Reason: 1
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 https://wiki.archlinux.org/index.php/Arduino#delay.28.29_function_doesn.27t_work
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

SurferTim

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.





Anaximander

#11
Mar 10, 2012, 09:59 pm Last Edit: Mar 10, 2012, 10:12 pm by Anaximander Reason: 1
Unfortunately it still doesn't work.
I'm using a.t.m:

Code: [Select]
*  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:
Code: [Select]
*  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...

Michel Graciano

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

Anaximander

Thank you all for your help.

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

Still no luck with Ethernet.

Regards

Michel Graciano

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.

Go Up