Hello, this is my first post!!! (take care of this and about my not perfect english) :-)
I have a problem to compile a sketch into the arduino original IDE (under windows).
My problem is very strange and very long because i have tried without success many ways to resolve it!
Let's go...----- How the problem come out -----
I wrote a sketch for arduino Mega 2560 and the original Ethernet shield.
For the purpose I have found a library that seems to be ok.http://www.webweavertech.com/ovidiu/weblog/archives/000477.html
It use the micro-SD on the Ethernet shield and like a webserver send all the page requested by a broswer.
I modified the example called “FileUpload” by adding a function and an handler to manage a GET request with parameters (.../example.htm?param1=123
All things work ok!!!
I receive the parameter from the browser and, in my function, I manage it correctly! (obviously the arduino IDE compile it without problems).
But this webserver freeze in a particular condition!
All the functions in arduino locks: I used a blinking led, in a cooperative task mode, like an heartbeat and it don't blink anymore when the arduino freeze.
Using some debug I found that the cause is a browser request of the file “favicon.ico” (the little icon on the left of the address bar) after a reset of arduino.
More debug shown me that the function, called from the library, that freeze is malloc()!
Malloc() (memory allocation) is called many times but freeze only in that code flow position (the call is made for allocate 8 byte when I have more than 6kB free...)
Google shown me that malloc() in avr-libc 1.6.4 (arduino 0022) have a bug:http://savannah.nongnu.org/bugs/?22567http://savannah.nongnu.org/bugs/?25723
Seems that in the avr-libc 1.7.1 (the last update available) these bugs have been corrected so I want to upgrade the arduino libc to this version and compile again.----- How I tried to solve the problem -----
Arduino ide use winavr to compile.
I have seen that replacing the folder “avr” in the path “...\arduino\hardware\tools\” with the installation path of a newer version of winavr I can upgrade the avr-libc.
At this point the problem is that winavr in not more manteined... (last update is 20100110 / libc 1.6.7 and don't work: arduino freeze) http://arduino.cc/forum/index.php/topic,61093.0.html
So I tried to use MHV tools http://www.makehackvoid.com/group-projects/mhvavrtools
or Atmel's toolchain http://www.atmel.com/dyn/products/tools_card.asp?tool_id=4118&category_id=163&family_id=607&subfamily_id=760
that both have the avr-libc 1.7.1 version.
In both cases I substituted the folder “avr” and tried to compile (the avr tools also need an “#include math.h” somewhere...) but I receive from the compiler the same error:----- The final problem -----
In file included from c:\programmi\arduino\hardware\tools\avr\bin\../lib/gcc/avr/4.5.2/../../../../avr/include/util/delay.h:42:0,
c:\programmi\arduino\hardware\tools\avr\bin\../lib/gcc/avr/4.5.2/../../../../avr/include/math.h:426:15: error: expected identifier or '(' before 'double'
c:\programmi\arduino\hardware\tools\avr\bin\../lib/gcc/avr/4.5.2/../../../../avr/include/math.h:426:15: error: expected ')' before '>=' token
Seems that there is a problem with the function at row 426 in the file math.h
--- math.h ---
419: The round() function rounds \a __x to the nearest integer, but rounds
420: halfway cases away from zero (instead of to the nearest even integer).
421: Overflow is impossible.
423: \return The rounded value. If \a __x is an integral or infinite, \a
424: __x itself is returned. If \a __x is \c NaN, then \c NaN is returned.
426:extern double round (double __x) __ATTR_CONST__;
427:#define roundf round /**< The alias for round(). */
like in this post http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=84750&start=0
seems that somewere the round function is declared as a macro, but I am not able to find where.
I want to find a secure way to upgrade the avr folder and compile (successfully) with the arduino ide and an avr-libc upgraded and this post may be a reference to all the arduino user community.
I prefer to adopt the atmel's toolchains that seems to be more updated
Thank for replies and I wait for someone that can help me to understand what don't work.
Sorry again for the length of the exposition.