Pages: [1] 2   Go Down
Author Topic: Arduino Ethernet no network connection(toolchain problem on amd64 linux)  (Read 3582 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
/*
 * 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:
//EthernetClient client;
by removing the comment.
The sketch doesn't work anymore (no serial output).

Any help is appreciated.

Greetings
Anaxi
« Last Edit: March 09, 2012, 04:17:08 pm by Anaximander » Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 63
Posts: 6049
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

How does the client object get an IP address?
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 63
Posts: 6049
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?
« Last Edit: March 09, 2012, 04:20:46 pm by Anaximander » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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:
#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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: March 10, 2012, 03:08:34 am by Anaximander » Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 115
Posts: 5367
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

« Last Edit: March 10, 2012, 07:42:43 am by SurferTim » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm using Gentoo on AMD64
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

avr-gcc-4.5.3
avr-libc 1.7.1-2
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

also i found the patch info here:

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

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
*  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:
*  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...
« Last Edit: March 10, 2012, 04:12:17 pm by Anaximander » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you all for your help.

I replaced the Ethernet/utility folder content with the files from github, but still no ethernet  smiley-sad

Still no luck with Ethernet.

Regards
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1] 2   Go Up
Jump to: