1284p programming problems

Started by daemach, September 07, 2014, 02:21:32 PM

daemach

Can you please provide a part number for the resonator you're using in the mega?  A full parts list for all of your boards would be very useful to the open source community.

I'm building a custom board to be compatible with the moteino mega using a resonator with 15pf caps and AVR studio isn't able to enter programming mode when trying to program the device with a bootloader.  I'm wondering if the resonator is the problem because everything else looks OK.

Felix


oric_dan

#2
Why use a resonator, rather than a crystal? Typically their accuracy is light-years worse, eg 0.5% versus 20 ppm, or 0.00002%. You need external caps with the crystal, but seems worth it for the much better timing.

daemach

That's literally the same resonator I'm using...  http://screencast.com/t/pdlvfb9mb7C

Using the dragon, I can read the deviceID on my older boards based on the 328p, as well as the uno.  The only thing different on this board is the 1284p but it keeps failing saying it can't enter programming mode.  I've always used the arduino ide and usbtiny ISP to burn bootloaders to my boards (6 revs of this board and 7 revs of another also based on the 328p) so I'm not sure I'm doing everything right in avr studio, but it seems pretty intuitive.  I'm not sure why it isn't working :/  No shorted pins, and I checked the datasheet to ensure that the miso/mosi/sck/ss/reset pins are going to the right pins on the isp header...

Any advice you can give me would be appreciated.  The only other thing I can think of to do is try replacing the 1284p...

I attached my schematic and board files in case anyone is interested.  This is all intended to be open source.

@oric_dan - I may try a crystal in the future.  I didn't know there was that much variance.  To be honest, I grabbed the resonator from the uno schematic.

oric_dan

#4
There have been a lot people on the Arduino forum moaning about the poor timing with the Uno resonators. 0.5% is an amazing 432 sec/day, worst case, while 0.00002% is 1.7 sec/day.

I don't have a utility to read your board files. What do people use?

However, I always program the boot loader into the mega1284P chips for my projects using the Arduino IDE, and an Uno board as programmer. Works fine.

daemach

I'm not sure how to use an arduino board to program these.  I don't have pins broken out, other than for ISP and FTDI headers - they are all being used for something.

The files are in eagle format.  You can use the freeware license to view/manipulate them:  http://www.cadsoftusa.com/

daemach

I removed the RFM69HW, which was the only other thing connected to the MI/MO/SK and I was able to read the deviceID.  I haven't had a problem with the RFM modules being installed when burning the bootloader before, but I've never used AVR Studio either.

And, I was able to read the deviceID on another board with the RFM69W installed, but it was based on a 328p.  Bad RFM module?

On that note, I've never had to set fuses manually before either.  This is not intuitive to me.  Can anyone give me some advice on what exactly I need to do to ensure I'm able to burn a bootloader successfully so I can start programming via FTDI? 

Thanks in advance...

Felix

I still don't get why people think using "Arduino as ISP" is such a great thing. I think it's not, in fact when I once tried it I thought it was major PITA, and it barely worked after lots of messing around with caps and nonsense like that. I guess it can save you $40 (awesome!) which you'd otherwise spend on a AVR ISP MKii which does the job perfectly every time, in a split second.

AVR studio is the way to go, it's fast and reliable, as long as you connect your chip the right way. The target has to be powered independently (NOT FROM THE ICSP header!).
Open the programming dialog, choose the target signature, read it to confirm studio can talk to your target, then proceed to burning the fuses, bootloader, and lock fuses if any. Done.

daemach

Apparently I'm connected the right way because I can read the deviceID with an AVR Dragon now.

I've never seen an AVR MKII for $40 other than clones on ebay and I'm scared of those.  I'm having enough problems trying to figure out this process without worrying about whether or not the programmer is causing the problems.

Can you please give us all a quick explanation of how exactly to set the fuses, lock bits, etc. so we can learn something?  It's clearly easy for you and would be a great benefit for those of us trying to grow beyond the arduino environment.  An example using your dual-optiboot for the 1284p would  be perfect, since that's exactly what I'm trying to do... 

I'm just trying to avoid bricking this $9 chip.

Felix

Here, its not $40, its $37.88: http://www.digikey.com/product-detail/en/ATAVRISP2/ATAVRISP2-ND/898891
Plus shipping, which you have to pay anywhere anyway.

Remember, power the target chip independently of the ICSP. Then the ICSP 6 connections connect directly to the VCC/GND/RESET/MISO/MOSI/SCK pins of the target. Make sure the connections are solid and not subject to interference.

In AVR studio, once you confirm connectedness to the chip, go to the fuses tab, that should read the current fuses. Then change them to whatever you need. For Moteino/MoteinoMEGA fuses see the diagrams (legends): http://lowpowerlab.com/moteino/#pinoutMEGA

Then go to the Programming tab where you choose your HEX file and click Program to upload it to the chip. Precompiled HEXes here: https://github.com/LowPowerLab/DualOptiboot

And by the way I never bricked any chips while learning this or ever since. You CANT brick it, unless you do something grossly wrong. It happened that I bricked chips when the boards were faulty (shorts, broken traces) or other things like that. Those end up in the trash (you can unbrick them, but it's so involved it's not worth the time (but it does work on most bricked chips, except those bricked  beyond unbricking): http://mightyohm.com/blog/products/hv-rescue-shield-2-x/

This will work with AVRISPmkii, not sure about anything else. That's about all the details I can come up with. It's really straight forward.

oric_dan

#10
Quote from: daemach on September 08, 2014, 08:10:19 AM
I'm not sure how to use an arduino board to program these.  I don't have pins broken out, other than for ISP and FTDI headers - they are all being used for something.

The files are in eagle format.  You can use the freeware license to view/manipulate them:  http://www.cadsoftusa.com/

Felix is right, of course, that using an AVR programmer is the best way to go, but he's also burning bootloaders constantly - I'm sure. I've only had need to burn one every now and then, so using Arduino as ISP works fine. See this page,

http://arduino.cc/en/Tutorial/ArduinoToBreadboard

Rather than a whiteboard, I have my own target boards jumpered across to.

If all you have is the ISP header available, well it has the same pins that are needed, so should be able to jumper to those. However, if you're trying to burn a bootloader into a chip mounted in a custom board, you might have a hardware conflict, possibly with the MISO, SS, and CS pins.

daemach

Are you sure that was all there is to it?

http://screencast.com/t/6QgwGtHn

There is no programming tab - I attempted to use the memories tab, flash section.  Was that not right???

I did program the flash before setting the fuses - finger slipped as I was planning it out.  Is there any way to recover this??

Felix

#12
Quote from: daemach on September 08, 2014, 04:37:59 PM
Are you sure that was all there is to it?
http://screencast.com/t/6QgwGtHn
There is no programming tab - I attempted to use the memories tab, flash section.  Was that not right???
I did program the flash before setting the fuses - finger slipped as I was planning it out.  Is there any way to recover this??

I never upgraded AVR studio so it might have a different interface but it's all the same stuff. Fuses are on 1 tab, programming/memories on another, lock bits on yet another etc. Not sure how you're running into so many issues. Your fuses look right. It won't matter if you flash the memory first then set the fuses. In case you don't set the fuses then your program will run 2X slower due to internal oscillator. You of course need to have a valid 16Mhz clock reference hooked externally if you set it to my fuses.
If you set fuses to use external XTAL and your XTAL is not able to start, then your AVR programmer will not be able to talk to the chip any more. The way to unbrick it is to use the rescue shield from MightyOhm, OR you can use a square wave reference from your function generator or your oscilloscope and hook it to the OSC pin.
Then again, you're using a different programmer than what I do so I have no idea if that makes a difference. I was informed AVRispMKii is being deprecated so time to get one while supplies last ;)

Rule of thumb in electronics: *ALWAYS* buy plenty of chips (to allow for bugs and save a few weeks and shipping). For me that number is generally 3 (as is the number of OSHPark boards I order for a new prototype). The MEGA chips are expen$ive, but that's the cost of doing this ... we've all gone through it and hardware is cool because it's hard :)

daemach

QuoteYou of course need to have a valid 16Mhz clock reference hooked externally if you set it to my fuses.

Thanks for the info - that helped.  I had removed the resonator earlier to see if that was the problem and didn't solder it back in very well.  I removed and resoldered it and the board came back to life.  I read the deviceID and it showed the new fuses, so apparently they got set when I uploaded the bootloader.

Felix

You're welcome, BTW Fuses don't change from the bootloader unless you change them specifically.