Clock sometimes fails(?) on startup, with wifi module

More
2 weeks 6 days ago #12557 by goffrie
OK, I programmed the clock firmware onto an Arduino Uno and transplanted the atmega onto the clock, and it seems to work.
I also had a lot of difficulty trying to program the original chip with a usbtinyisp. I was able to get the Arduino bootloader onto it and then use that to program the clock firmware, but that still fails at boot.
So... my hypothesis is that there was some issue with the atmega chip?

Please Log in or Create an account to join the conversation.

More
2 weeks 6 days ago #12558 by Ty_Eeberfest
Yeah, good luck with that "in the mail" stuff. From where I sit (USA) it looks like there's a worldwide pandemic of Postal Fail in progress. Not sure what's going on but stuff is taking excessive time to arrive if it arrives at all.

Anyway - thank you for sticking with it and reporting your results! I am inclined to agree with your theory that the Atmega was somehow defective, as rare as that may be. Assuming a counterfeit chip didn't slip in there somehow, those things are pretty solid. I do want to ask about Fuses though. It would be useful to know what the fuse values are on the problem chip and what they ended up being on your replacement chip.

With the ICSP connected this command should get you lots of chip info including fuses:
avrdude -v -c usbtiny -p m328p -P usb

Something like this will be shown at the very end of the command output. You can safely ignore the several screenfulls of info that precede it:
avrdude: Device signature = 0x1e950f
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DE
avrdude: safemode: efuse reads as 5

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DE
avrdude: safemode: efuse reads as 5
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

Look into it later when the dust is clearing off the crater.

Please Log in or Create an account to join the conversation.

More
2 weeks 4 days ago #12559 by goffrie
Both my chips read the same:
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: hfuse reads as DE
avrdude: safemode: efuse reads as FD

avrdude: safemode: hfuse reads as DE
avrdude: safemode: efuse reads as FD
avrdude: safemode: Fuses OK (E:FD, H:DE, L:FF)
The following user(s) said Thank You: Ty_Eeberfest

Please Log in or Create an account to join the conversation.

More
2 weeks 4 days ago #12560 by goffrie
Alright, I did a bit more debugging on the "faulty" AVR and I found that it was hanging on the Wire.endTransmission() call inside of getRTCTime(). Adding
Wire.setWireTimeout(10000 /* us */, true /* reset_with_timeout */);
to setup() fixes that, and lets it boot up reliably. I guess since the ESP is booting up around the same time it might be interfering on the I2C bus?

Incidentally I found an unrelated bug in the wifi firmware: the call to setTime(2020,9,13,0,0,0) happens too late, and on a fast internet connection it can overwrite the time found by the initial NTP sync. (Also the parameters are in the wrong order.)

Please Log in or Create an account to join the conversation.

More
2 weeks 4 days ago #12561 by Ty_Eeberfest
No clues there. I was just wondering...

The difference between your EFUSE (FD) and mine (05) is not significant. All it means is that your setting sets all the undefined / unused bits to1 where mine sets them to 0. Somewhere sometime the Arduino people decided that best practice was EFUSE = FD instead of 5, so my info is old but has never caused me a problem.

Look into it later when the dust is clearing off the crater.

Please Log in or Create an account to join the conversation.

More
2 weeks 4 days ago #12562 by Ty_Eeberfest
Thanks for that firmware debug info. I imagine Ian will find it interesting. I haven't had my fingers in that firmware for several years so I can't say much about what you found. The business about the I2C timeout sure sounds like there's a race between Atmega and ESP at boot time, doesn't it?

Look into it later when the dust is clearing off the crater.

Please Log in or Create an account to join the conversation.

Moderators: AccutronTy_EeberfestIan
Time to create page: 0.117 seconds
Go to top
JSN Boot template designed by JoomlaShine.com