CC3000 hangs on ANY server.begin call

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
pkourany
 
Posts: 51
Joined: Wed Nov 27, 2013 12:57 pm

CC3000 hangs on ANY server.begin call

Post by pkourany »

I have a CC3000 connected to a Teensy 3. I am trying to run the ChatServer and EchoServer examples. They connect to my router just fine and get an ip but then the CC3000 code hangs at the end of setup() at the xxxServer.begin() call. In fact, ANY call to the "begin" method of an object of type Adafruit_CC3000_Server will hang.

Anyone have this happen?

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: CC3000 hangs on ANY server.begin call

Post by adafruit »

Try it with an Arduino UNO? that way you can tell if its a wiring thing or a hardware thing or a software thing :)

User avatar
pkourany
 
Posts: 51
Joined: Wed Nov 27, 2013 12:57 pm

Re: CC3000 hangs on ANY server.begin call

Post by pkourany »

DId that with an Arduino Pro mini running at 3.3V, 8MHz with same results. I just upgraded my router and I will be trying again with either the UNO or the Pro Mini instead of the Teensy 3.

User avatar
paulstoffregen
 
Posts: 444
Joined: Sun Oct 11, 2009 11:23 am

Re: CC3000 hangs on ANY server.begin call

Post by paulstoffregen »

If you're able to get an IP number assigned, or even if it's able to detect the names of routers, then your connections between the Teensy3 and CC3000 are certainly fine.

If you find ANYTHING that works on Arduino Uno or Mini but doesn't work the same on a Teensy, please let me know?

User avatar
lhagan
 
Posts: 2
Joined: Mon Nov 11, 2013 10:44 am

Re: CC3000 hangs on ANY server.begin call

Post by lhagan »

I have the same issue, but only on Teensy 3. My CC3000 works fine in server mode on Arduino Uno, but hangs at Server.begin() with Teensy 3.

teachop
 
Posts: 25
Joined: Sun Feb 10, 2013 7:10 am

Re: CC3000 hangs on ANY server.begin call

Post by teachop »

I am thinking it hangs in the echoServer.available() first time it tries to loop. If I put a delay after "Listening for connections..." that does print.

If .available() is followed through in Adafruit_CC3000_Server.cpp, it turns out .available() calls acceptNewConnections() which in turn calls the socket.cpp accept(). However, it calls accept() with null pointers that end up getting used!

Could this write to zero do silent damage on AVR but crash an ARM architecture? When I replaced the NULL pointers with valid pointers it proceeded to loop() without hanging.

User avatar
paulstoffregen
 
Posts: 444
Joined: Sun Oct 11, 2009 11:23 am

Re: CC3000 hangs on ANY server.begin call

Post by paulstoffregen »

Ah, yes, that would explain a lot. On ARM, writing to a NULL pointer causes a hard fault which stops your program.

I posted here yesterday about trying to reproduce the problem.

http://forum.pjrc.com/threads/24619-Tee ... #post38261

I got "Listening for connecetions..." (using 1.17-rc2) but it was probably crashed right after that.

User avatar
paulstoffregen
 
Posts: 444
Joined: Sun Oct 11, 2009 11:23 am

Re: CC3000 hangs on ANY server.begin call

Post by paulstoffregen »

I sent a pull request to ignore the null pointers.

https://github.com/adafruit/Adafruit_CC ... ry/pull/42

@teachop - great investigative work you did tracking this one down. :)

teachop
 
Posts: 25
Joined: Sun Feb 10, 2013 7:10 am

Re: CC3000 hangs on ANY server.begin call

Post by teachop »

Ok thanks! My pull request was to pass valid pointers (in the Adafruit library not wanting to edit TI files). Your approach is better using less stack.

User avatar
ktownsend
 
Posts: 1447
Joined: Thu Nov 05, 2009 2:18 am

Re: CC3000 hangs on ANY server.begin call

Post by ktownsend »

Integrated the pull request ... good job tracking this down. ARM is actually easier for this kind of thing since you end up in the HardFault handler, etc.

Kevin

User avatar
pkourany
 
Posts: 51
Joined: Wed Nov 27, 2013 12:57 pm

Re: CC3000 hangs on ANY server.begin call

Post by pkourany »

Works great now! Thanks for the hard work.

:P

User avatar
tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: CC3000 hangs on ANY server.begin call

Post by tdicola »

Nice, thanks for tracking that down. Unfortunately the CC3000 socket APIs are just close enough yet different to the real socket APIs to be dangerous.

User avatar
paulstoffregen
 
Posts: 444
Joined: Sun Oct 11, 2009 11:23 am

Re: CC3000 hangs on ANY server.begin call

Post by paulstoffregen »

Yup, so true. Here's what the Linux man page for accept() says:

The argument addr is a pointer to a sockaddr structure. This structure is filled in with the address of the peer socket, as known to the communications layer. The exact format of the address returned addr is determined by the socket's address family (see socket(2) and the respective protocol man pages). When addr is NULL, nothing is filled in; in this case, addrlen is not used, and should also be NULL.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”