MPLAB snap to atmega328pb program and debugWIRE

Go To Last Post
110 posts / 0 new

Pages

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you using the IPE by any chance? The IPE will reset fuses unless you have them in the hex file..

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

April 11, 2019                                                  File: SNAP Test Notes

Micro Chip SNAP Programmer testing with AVR Mega328P:

Testbed: 

Arduino Nano with a M328P, 5V,  16 MHz Ext Xtal.

A few LEDs and PB Switches attached.

 

Step #1:

Use Studio to program Nano to flash an LED at 1 Hz, using 16 MHz external Xtal.

Studio:  Atmel Studio 7.0.1645  (Programmer: AVR ISP mkII)

File:  Nano Breadboard LED Test V1.bas    ---> .hex

Fuses:

Ext: 0xFF, High: 0xD9, Low: 0xD6

Ext. Full Swing Crystal, Div by 8 disabled.

Micro runs as expected, at 16 MHz, flashes an LED at 1 Hz via ISR.

Close out  Studio.

 

Step #2:

Use MPLab X IDE to load the same pre-compiled .hex file into the same Nano.

MPLab X IDE Version: 5.15

Open Project fails, (Presumably because it isn't a C program)

So instead use: Import Hex/Elf (Prebuilt) File, which is what I'm trying to do anyways.

Select the SNAP programmer from the HW Tool box.

In the top left box, select the hex file.

The hex file shows up in the top right box, (Source).

The Lower right box has 3 tabs: Output, Program Memory, Configuration Bits.

The Config bits are all RED, and the clock says Int RC Osc 8 MHz..., and the Div8 is SET.

Press the little "Read Configuration Bits" button, the top one of the stack, to PRESUMABLY read / upload the current Fuse settings.

Nothing happens.

The Config bits box remains all red, and it doesn't upload the micro's current Fuse settings.

The lower box settings are: Memory: Configuration Bit, Format: Read Only.

 

 

Oh well, I just want to burn a .hex file, (without any embedded Fuse data).

It appears that the only "Burn a hex file" option I can see is the button on the upper bar that says:

"Make and Program Device Main Project", with the green download to device arrow.

 

Note: I don't want to "MAKE" the project, I JUST want to download a pre-compiled .Hex file!!!

And I can't seem to be able to upload my current Config Bits (Fuses)...

And in the Conf Bits view, lower right box, "Read Only" is the only pull-down option available.

I can't seem to edit / change the Fuse settings.

OH well, try the burn, perhaps it will just write the .hex file, and not mess with the Fuses:

Error Failed to launch debug session using debugWire.

 Note: I DON'T want to debug, I JUST want to burn a .hex file!!!

Screenshot taken.

 

So, two options here, first try:

Say no, I don't want to use ISP to enable debugWire.  --> Get: Programming did not complete.

Now do the same, but say Yes, use ISP to enable debugWire:

Get "Please toggle power on the target device", OK, done.

Get the same Failed to launch debug session using debugWire: message.

 

So, perhaps the issue is the Arduino Nano's Reset\ line hardware?

Unfortunately the same sequence occurs with a custom PCB with a M328PB chip and only a 10K pull-up on the Reset\ line.

So it doesn't seem that the Arduino Nano HW Reset\ line is likely an issue.

The original program and Fuse settings were untouched by the above process.

 

The programming box says:  Change communications interface to ISP in the project properties to read or write configuration bits.

Snapshot taken. Project Properties box.

 

Since the Project Properties box doesn't have a "Communications" pull-down, go look in the Manage Config sub-box.  Nope.

So try clicking on the SNAP in the Project Properties Categories box:

Then in Options Category select Communications.

See that debugWire is the currently selected version, so change it to ISP via the pull-down.

BUT: The "OK" button is grayed out. 

So HOW does one make the Comm mode ISP???

Screenshot: Comm ISP Mode

 

 

 

OK, try again:

File / Project Properties / Now in the Categories Box try "Loading"

Good, there is an option to "Load this .hex file instead of or dist/default/....

So, select my pre-compiled Nano Breadboard LED Test V1.hex file.

Click "Add loadable file"

Screenshot: Load this hex file instead.

 

 

 

Again: there are grayed out "OK" and "Apply" buttons, so HOW does one make one's selection take effect?

Very frustrating.

Apparently using MPLab X IDE V5.15 and the SNAP programmer to simply burn a pre-compiled hex file is a non-trivial process.

It would appear that I can almost get there..., but not quite.

.........................................................................................................

So, let's switch gears and try to simply burn a pre-compiled hex file using MPLab X IPE, (instead of the IDE, used above).

MPLAB X IPE V5.15

Close out the IDE and run the IPE.

It sees the SNAP programmer and shows this in the Tools box.

Select the hex file, and get a message that the file was loaded successfully, (into the IPE, not yet into the micro).

Screenshot: IPE Hex file loaded.

 

 

 

Press the Connect button by the Tool/SNAP, and it connects, and says:

Application version.....0.14.230

Target voltage detected.

 

In left column, Memory, Manual select:   Deselect Configuration Memory.

 

Press the Program button, and:

Error.  Failed to connect to device using ISP.

Screenshot: IPE ISP failed.

 

 

What?  With the IDE it wouldn't / couldn't use the debugWire mode.

Now with the IPE it can't connect with the ISP mode...

So, click YES to enable ISP and one is in an infinite loop with the same pop up asking if one wants to use ISP...

Click No to get out of the error pop up box loop.

 

Of course the left column, Settings, shows that the "Communications settings for AVR or SAM devices" is already set to ISP at 0.1 MHz.

Screenshot IPE ISP already set

Why, BTW, does the "output" tell me that the configuration memory will be programmed, when the Config Memory ISN'T selected in the Memory options????

Screenshot: IPE Memory selection

 

 

So, in the past I could at least burn a pre-compiled hex file, although the MPLab X reset the Fuses to use the internal RC Osc with the div by 8 enabled.

(And yes, I am sure that was happening, as I went through the process, resetting the Fuses with Studio, several times...)

 

Today I haven't quite hit on the right sequence with either the IDE or the IPE to burn the pre-compiled hex file.

 

The hex file was created by my Bascom compiler.  It is a simple hex file for a simple LED flasher.  There are no embedded Fuse settings, eeprom data, elf files, or anything else.  Studio 7 and my AVR ISP mkII burn the hex file, (and all of my other hex files over the past years), just fine.

 

I find this incredibly frustrating...

I purchased a couple of SNAP programmers so that I could give one away and not risk the individual damaging my AVR ISP mkII, and so that the individual could use the "easy/simple" MPLAB X IPE interface to simply download pre-compiled hex files, instead of using the full Atmel Studio and my mkII.

 

I consider this endeavor a total failure.  I spent several days on this a few weeks ago, and I've spent several hours on this today, all without success.

 

Perhaps I'm missing something simple, and burning a M328P or M328PB with a canned hex file is doable.  If that's the case then I will apparently need some incredibly detailed hand-holding to walk me through the process.

 

Engineering Tech Notice #36, linked to above by mraardvark would not seem to be applicable in this particular case, as I am attempting to program plain old M328P and M328PB, which use ISP, and not UPDI, PDI, or TPI interfaces.

 

Having now vented, let me say that I am appreciative of your interest in replicating / solving this issue.  I appreciate any further  guidance in the right direction.  

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK, so one more image.

Not sure why after posting the above, I get the Unable to send eMail, Contact Site Admin messages.

 

Not, obviously, related to the issue within this Thread, but indicative that clearly a little more work on the web site is still indicated.

 

JC

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not sure why after posting the above, I get the Unable to send eMail, Contact Site Admin messages.

We are all getting that and not getting any emails notifications for a bout 2 days now.

I don't want to "MAKE" the project, I JUST want to download a pre-compiled .Hex file!!!

Now, now let's watch the blood pressure.....cheeky I have downloaded the latest MPLABX and have the pickit4 on the bench ready to try things out but maybe not for now, I have enough blood pressure rising stuff with my piano lessons.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you get to make it work? (with the Arduino Nano) Mine arrived yesterday; and I would like to see if it works with a Nano? Did you have to Desolder the capacitor in the Board, or not? I was planing of uninstalling Windows and start using Linux; to exclusively use MPLAB for both AVR and SAMD21 development.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A Nano will never work with debugWIRE unless you disconnect the DTR capacitor and replace the 1k0 RESET pullup resistor with 10k (or remove entirely)

 

A genuine Uno has a proper 10k pullup and a RESET-EN solder-bridge.   Cut the bridge with a Stanley knife.

Follow the instructions from AS7.0 or MPLABX.

 

You can make/break with a soldering iron as required i.e. to restore Bootloader / enable debugWIRE.

 

The SNAP should work ok with correct debugWIRE schematic.   

Likewise,   ATMEL-ICE, PicKit4, Dragon, ...

 

ASk if you have a problem.

 

David.

 

p.s. if you are determined to use a Nano,   cut track(s) with sharp knife or mini-drill.    It is easier to restore by hand-wiring a patch than to move SMD components.

Last Edited: Wed. Aug 7, 2019 - 05:25 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your early reply @david.prentice.

A Nano will never work with debugWIRE unless you disconnect the DTR capacitor and replace the 1k0 RESET pullup resistor with 10k (or remove entirely)

I have 3 Nano's, and  plan to use 1 as a development board. I have already done the aforementioned setup in this one. I will consider an Arduino Uno too.

 

Besides this tweak, I wonder if I'll need to do any workaround in my PC, especially considering a will be focusing in a Linux enviroment; and reading a few of the forum posts, it seems some have had trouble with it.

 

I'm currently at my workplace and it's noon here; so anything intended will be done this afternoon.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you have 3 Nanos,   I would remove the capacitor and 1k pullup on one Nano.   Enable debugWIRE.   Never restore as a Nano.

 

I find Uno format easier for development.   You can even buy XMINI-328P or XMINI-328PB.

 

If you need a small Target pcb,   after develop/debug on a Uno then just burn the working HEX on the Nano.

 

David.

 

You need MPLABX v5.25.    AS7.0 does not support SNAP.

Last Edited: Wed. Aug 7, 2019 - 05:52 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Thanks for your discussion/help so far!

I have spent some hours now to use Snap to debug/program an ATmega328P device (minimal HW) with MPLAB X IDE v5.20 and Windows 7, and it finally works.

Programming and fuse read/write with ICP is ok and debugging with debugWire, too.

Maybe this is not new for the forum but I miss the success post in the ongoing discussion.

I updated to MPLAB X IDE v5.25 and got the same results.

Regards Gustav, Vienna 

 

Last Edited: Mon. Oct 7, 2019 - 07:05 PM

Pages