Go Down

Topic: Advanced programmers advice needed. (Read 919 times) previous topic - next topic

Jantje

maybe I have not been all to clear about the nature of the problem.
Sometimes with the same sketch (no new upload) it works and then it stops working.
When it stops working it is after a cold start. When I simply reset the leonardo the behaviour seems to be is consistent. When I cold start it is not.
Which is pretty annoying as I go to sleep happy that it works and when I start the next day .......

This behaviour makes me think more in the area of uninitialize variables. However with -wall these are marked and -even though they do cost program memory- I have initialized all variables in my code.
Removing the invalid PROGMEM warnings below all the warnings that remain in my sketch when compiled with -wall
Code: [Select]
Description Resource Path Location Type
"USB_MANUFACTURER" redefined USBCore.cpp /batterijlader/arduino/core line 59 C/C++ Problem
unused variable 'current_config' HardwareSerial.cpp /batterijlader/arduino/core line 329 C/C++ Problem
unused variable 'c' HardwareSerial.cpp /batterijlader/arduino/core line 115 C/C++ Problem
#warning this may not be correct Tone.cpp /batterijlader/arduino/core line 210 C/C++ Problem
unused variable 'r' HID.cpp /batterijlader/arduino/core line 514 C/C++ Problem
#warning Timer 2 not finished (may not be present on this CPU) wiring.c /batterijlader/arduino/core line 274 C/C++ Problem
unused variable 'zero' USBCore.cpp /batterijlader/arduino/core line 270 C/C++ Problem
#warning Timer 2 not finished (may not be present on this CPU) wiring.c /batterijlader/arduino/core line 265 C/C++ Problem

Now I'm looking at this list I see this warning "#warning Timer 2 not finished (may not be present on this CPU)"
This is the code it points to
Code: [Select]
// set timer 2 prescale factor to 64
#if defined(TCCR2) && defined(CS22)
sbi(TCCR2, CS22);
#elif defined(TCCR2B) && defined(CS22)
sbi(TCCR2B, CS22);
#else
#warning Timer 2 not finished (may not be present on this CPU)
#endif

// configure timer 2 for phase correct pwm (8-bit)
#if defined(TCCR2) && defined(WGM20)
sbi(TCCR2, WGM20);
#elif defined(TCCR2A) && defined(WGM20)
sbi(TCCR2A, WGM20);
#else
#warning Timer 2 not finished (may not be present on this CPU)
#endif

Which is part of init() which is being called before setup. This feels like a lead.
I guess I best open an issue/thread on this one in the yun specific locations and try to remove the wire usage and see what that gives.

An update on the code on github.
Github decide to update their windows client to use .net4. Moreover they decided to update my installation which runs on XP without my permission. After upgrading my xp to the very latest version (I had turned off auto update for very good reasons) I found out .net4  is not supported on xp.

Best regards
Jantje
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

holmes4

Quote
When it stops working it is after a cold start. When I simply reset the leonardo the behaviour seems to be is consistent. When I cold start it is not.


Could you explain this, by cold start do you mean upload? or restarting both processors on the yun, What do you mean by "consistent".

Mark

Jantje

cold start= take power of system (that is from linino and leonardo) let it cool down (at least 10 seconds but prefably far more) and then repower.
consistent= 2 examples
Quote
Using SerialCommunicator instead of SerialBridgeCommunicator works
removing the overloaded setReceivedMessage and it works. Putting the overloaded setReceivedMessage back in and it failed.

Quote
Now setup is called but fails very early in the call Bridge.begin(); (this is my mini version of Bridge not the official bridge)
So I add some Serial.print statements to Bridge.begin() to find where it fails.
result setup is no longer called.
I removed the Serial.print statements and the setup works again and Bridge.begin() does not return  smiley-roll
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Jantje

on the code.
Seems it is still supported on xp professional but doesn't get installed via update center.
So I could upload now.
https://github.com/jantje/libraries
Best regards
Jantje
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Jantje

Update
As I have been reducing the size i can now switch between altsoftserial and softserial.
It looked as if things were stable with softserial. But today I started the yun again and didn't want to move (with softserial)
serveral resets no ttyACM0 lcd gets no info ... (looks like dead)
Recompiled with altsoftware serial and uploaded and bam it works  :smiley-eek-blue:

I also ran the available memory in the beginning of setup (when it is working) and I had 600+ bytes free. I calculated that around 20 bytes were used. Seemed okish to me since we are in main setup so some stack is being used I see 5 bytes in setup +2 times 2 for the function pointers.

I removed the memfree function changed some Serial.println to Serial.print and i don't get into the setup again.

In my experience this behaviour is cause by a memory overwrite. Something is overwriting and it depends on the compiler what is overwritten.

Any help is welcomed.
Best regards
Jantje
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

holmes4

Sounds like incorrect use of a pointer some where.

Mark

Go Up