Programming ATSAMD21 -U part, with factory bootloader

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm trying to use an ATMEL ICE to program via SWD a development board that has an ATSAMD21G18A-U part mounted on the board.  The D21 data sheet tells me that the -U parts come in a 45 ball grid array type of thing and include a pre-programmed bootloader.  The part mounted on the board is a 12 pin on-a-side gull wing package (48 TQFP?).  The board includes the 2x5 pins posts on 50mil centers for SWD to the ICE.  Am I misreading the orders codes on the data sheet?  Because the part I have clearly is not a 45 ball grid array device.

 

Also, when I try to program the device I get the following statement about memory use and the an error message:

 

The following memory area(s) will be programmed:
program memory: start address = 0x0, end address = 0x5ff

 

 

configuration memory

NVMCtrl error bits set! (STATUS = 0x8, INTFLAG = 0x3)
NVMctrl reports an error

 

Is this error due to my trying to overwrite a pre-programmed bootloader?  I don't really care about the bootloader so I'm OK with overwriting it, if that's the problem.  I just don't know how to do that.

 

thanks,

 

Paul

 

 

 

 

 

This topic has a solution.
Last Edited: Sun. Mar 7, 2021 - 07:25 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"-U"? Pre-programmed bootloader? What "D21 data sheet" tells you that?

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

ezharkov wrote:

"-U"? Pre-programmed bootloader? What "D21 data sheet" tells you that?

 

See   https://ww1.microchip.com/downlo...

 

Section 3 (PDF page 17), Package Type (the parameter after the dash in the order code).  The U package type appears to indicate a WLCSP package, with footnotes 2 and 3.   Footnote 3:  WLCSP parts are programmed with a specific SPI/I2C bootloader. Refer to "Application Note AT09002" for additional information. Contact Microchip sales office for additional information on availability.

 

It's quite possible that I'm reading the data sheet incorrectly, but from what I see things are not making sense to me.

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

OK, thanks, I didn't realize that they had parts with a bootloader. I assume you are doing a chip erase before reprogramming? Do you use Atmel/Microchip studio tools or something else?

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

ezharkov wrote:
Do you use Atmel/Microchip studio tools or something else?

 

Using MPLAB X IDE with Harmony V3 and an Atmel ICE.

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

I suspect that you are trying to reprogram a locked region. That is why I asked about chip erase. I assume that chip erase would unlock everything.

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


ezharkov is correct.

 

The bootloader is protected with bootprot fuse bits. You can easily get rid of this by doing a full flash CHIPERASE.

 

 

Datasheet also mentions this.

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

Adithya Yuri wrote:
You can easily get rid of this by doing a full flash CHIPERASE.

 

Thanks for this info.  I see the CHIP ERASE in section 13.7 of the data sheet.  From that description in the data sheet it seems that to CHIP ERASE I need do that procedure by executing code on the processor, which I'm not able to do because of the NVMCtrl error.  Is there a way that I can do CHIP ERASE from MPLAB X IDE?  Without running code on the processor itself?

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

Dont know about MPLABX but in Atmel Studio you can go to device programming window and do a chip erase. 

 

You can do CHIPERASE through debugger, no need to do it pragmatically. 

 

In Atmel Studio you can do chip erase through

Tools->Device Programming->Memories->Erase Now

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

Adithya Yuri wrote:

Dont know about MPLABX but in Atmel Studio you can go to device programming window and do a chip erase. 

 

You can do CHIPERASE through debugger, no need to do it pragmatically. 

 

In Atmel Studio you can do chip erase through

Tools->Device Programming->Memories->Erase Now

 

Thanks.  I'll give that a try.

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

Well, I'm still stumped.  I've tried doing full chip erase in both MPLAB X IDE and Studio 7 using the Atmel ICE.  The IDEs report that chip has been erased, but I still get the error message:

 

NVMCtrl error bits set! (STATUS = 0x8, INTFLAG = 0x3)
NVMctrl reports an error

 

when I try to program the onboard flash with my code.

 

So I'm guessing that the Chip Erase procedure cleared all of the chip EXCEPT for the part that contains the bootloader.  I'd like to remove to the bootloader so that I can program the SAMD21 with my own code built from Harmony V3.

 

I see in the data sheet, section 13.7 CHIP ERASE, the procedure  to Chip-Erase by writing a '1' to the CE bit in DSU.CTRL and then checking for the result by looking for a '1' in the DONE bit in the DSU.STATUSA register.  I can set up a watch on those two SFRs in MPLAB X IDE but I can't get the IDE to read those SFRs from the SAMD21 let alone write to either SFR on the SAMD21, perhaps because of the NVMctrl error.

 

Any suggestion about how to get MPLAB X IDE to read and write to DSU.CTRL as well as DSU.STATUSA in the SAMD21?  Perhaps I'm missing some critical step to get access to those SFRs from the IDE.

 

thanks,

 

Paul

 

 

 

 

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

I guess you need to change the BOOTPROT fuse (to 7).

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ezharkov wrote:

I guess you need to change the BOOTPROT fuse (to 7).

 

Thanks for this suggestion.

 

I now see that in prior attempts I had bungled the the programming of the configuration bits back into the SAMD21.  Once I had successfully read the config bits, then changed the NVMCTLR_BOOTPROT size from 16384 bytes to ZERO bytes and then successfully wrote the config bits back into the SAMD21, I was able to flash the SAMD21 with my code without getting the NVMctlr error messages.

 

Thank you to ezharkov and Adithya Yuri for your guidance.     I'm back in business, until I hit the next stumbling block.

 

Paul