NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Support Forum » Intermittent success writing to MCU
April 03, 2012 by JamesFysh |
I've found that I'm unable to write a new .hex file to my MCU maybe.. 95% of the time? Maybe more? Some important facts:
So far, I have written initialload.hex to the MCU successfully, two times. After writing it one time, I pulled the power to the MCU, re-connected, re-ran make and BAM! back to not working (ahh, the point is - I didn't change anything at all, it just worked, then stopped working). I've tried different USB ports, I've tried pulling it apart and re-assembling, leaving the LCD detached, jiggling wires, using a bigger cap over the power-supply pins (7 and 8), etc. It just seems to be fundamentally unreliable. Anyway, what I'm wondering is - should I just solder everything onto a PCB, and make some jumper wires from the PCB back to the breadboard (for future prototyping)? What tricks have people used to make writing to the MCU more reliable? Do I perhaps just have a dud MCU or USB cable? |
---|---|
April 03, 2012 by pcbolt |
James - Before you jump to soldering to a PCB, there might be a few things to try first. Try posting a pic of your board (might be something simple). Also, if you can post the entire error message you get when you try uploading (from where you type "make" to the final line). You certainly narrowed down the possibilities with your diagnostics :D |
April 03, 2012 by pcbolt |
James - One thing jumped to mind. Do you have a Windows box you could try? If so, this would eliminate the bum MCU/USB theory. |
April 04, 2012 by JamesFysh |
Hey pcbolt, Thanks for the idea - I've just written to the MCU successfully 3 times in a row (just writing the initialload program) under Windows 7. This is a shame - I really don't want to have to boot into Windows just to program the MCU. Has anyone else had similar reliability issues under Linux? And, more imporantly, figured out any way to resolve these issues? Thanks |
April 04, 2012 by JamesFysh |
Ok, I'm back in Linux and..
:( P.S. Obviously, I have not changed anything on the breadboard while rebooting. All I have done is disconnect & reconnect the power-supply to the MCU to reset it. |
April 04, 2012 by Ralphxyz |
Try unplugging and replugging your USB, check your com port also a reboot might be necessary! Ralph |
April 04, 2012 by pcbolt |
James - I've seen some posts on this both here and on othe forums but no real solution. It has something to do with the fuse reading stage and safemode or the Com port being renamed. Unfortunately I'm not a Linux guy just yet, so I'll have to defer to others for more expertise. You can try Googling "avrdude linux problems" etc to see if someone has seen this before. If you do find an answer...please post it here. |
April 04, 2012 by hevans (NerdKits Staff) |
Hi JamesFysh, I have a thought, you may be running into a similar issue that some Mac users have been running into. Try altering your Makefile to put in a sleep between the read and write cycles? Take a look at this forum post where this similar issue is discussed. About half way down on Jaunary 24th Mike suggests a fix to the Makefile you can make that might fix this problem. Humberto |
April 04, 2012 by JamesFysh |
Hi Humberto. Yep, that did the trick! Have been able to load initialload.hex twice in a row now, on Linux It's a shame there's no command-line option (in avrdude) to introduce a small delay -- I think this would be a better fix than multiple calls + a sleep, in a Makefile. For anyone else experiencing this issue under Linux (or OS X?), you want to seek out the lines:
and replace with:
(NOTE: This is a Makefile, you MUST have a TAB character before each line following the rule) So what does this do? With the original avrdude invocation, avrdude performs the following:
As Mike / Humberto suggest, the issue occurs because the last step, writing, is attempted by avrdude too early after the delete step is finished. With this change, avrdude now does the following: (first avrdude instance spawned by make)
(make sleeps here for ~100ms) (second avrdude instance spawned by make)
And with the delay introduced, it seems to work really reliably! |
April 04, 2012 by pcbolt |
James - Good job...and better explanation. This will make for an excellent thread for future users to refer to. Two thumbs up. |
April 05, 2012 by JamesFysh |
It's a pity there isn't a way to "sticky" posts that describe common issues and how to fix them. I also had the issue where text would always be written to the first line of the LCD (looks like avr-gcc optimisations are unreliable), which is fixed by changing -Os to -O0 in all Makefiles and recompiling all .o, .hex files. It took me a bit of searching around the forums to find this one out. I'll have to look at the library, and if there's anywhere sensible there to put these problems + resolutions. Thanks for all the help everyone :) P.S. Usually I have a far superior experience developing code under Linux versus Windows or Mac.. avr under Linux (at least, Ubuntu) seems very broken so far! Maybe I need to grab the latest avrdude / avr-gcc tar-balls and build it all from source? |
Please log in to post a reply.
Did you know that you can adjust most wire strippers to make it easier to strip insulation faster? Learn more...
|