How to disable 'chip erase' before programming in Atmel Studio?

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

Hello

 

I use ATmega4809 and I'm happy that MCU saves user data (approx. 4kB) in Flash memory instead of EEPROM or external memory. But I experience one problem - when I program the chip with Atmel Studio and Atmel ICE, whole flash is erased and after programming the application needs to store used data again. Probably a 'chip erase' command is executed at the beginning of memory programming procedure. In Tools / Device programming / Memories there is a checkbox "Erase device before programming" this is what I need, but when I upload program with Start With/Without Debugging all flash is erased and this checkbox is not applicable. How can I disable erasing whole memory before programming?

extronic.pl

Last Edited: Mon. Jul 8, 2019 - 09:29 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In the project properties window, there is a tab called "tool" where you can disable programming. Maybe not exactly what you want, but it should help at least.

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


But you MUST erase what's there first before programming or you can't program the chip correctly.

 

If the chip is brand new and blank where you want to put you data then you may try what El Tangas is suggesting, but it would be a one time only

 

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

As El Tangas said, the Programming Dialog does not do anything to your project. To change this behaviour, look under Tools in the project properties.

:: 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


js wrote:
But you MUST erase what's there first before programming or you can't program the chip correctly.

 

Yes, but the AVR-0/1 have an erase/write command that erases only the flash pages that are written. So you don't need to wipe the entire flash (i.e. do a chip erase) before programming.

This can be easily confirmed with a real chip - if you disable "erase device before programming" the verify step will still succeed, even if you are writing over an old program.

 

meolsen wrote:

As El Tangas said, the Programming Dialog does not do anything to your project. To change this behaviour, look under Tools in the project properties.

 

Indeed. This is where the setting is found:

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

Is this different that the one I posted above where you uncheck the "Erase device before programming"?

 

And will a chip or part of a chip that had some previous data written to it be still programmed without erasing the area first?

 

Or does the new programming way allow for single byte to be erased before re-programming without erasing the whole page? I don't really know.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

js wrote:

Is this different that the one I posted above where you uncheck the "Erase device before programming"?

 

The difference is that the debugger just ignores the settings in #3 because that dialog window is kind of standalone (for example, you can access it even if no project is open), but respects the ones in #5 because they are part of the project configuration.

 

js wrote:

And will a chip or part of a chip that had some previous data written to it be still programmed without erasing the area first?

 

Or does the new programming way allow for single byte to be erased before re-programming without erasing the whole page? I don't really know.

 

Yeah, the area is erased, of course, but it's just on a page by page basis, instead of the whole chip.

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

As an aside, you would also need to make sure that your 'user data' is not on the same page as any part of the new program. 

 

I can think of some other ways:  Keep your 'user data' in a separate file, and #include it at the end of the code.  Hex file hacking;  run your output .hex file through a (python?) script that replaces blank space at a certain address with the 'user data' (read the chip first to store the 'user data') before programming.

 

Note further that I hope the 'user data' doesn't change very often.  The flash is only rated for 10,000 erases/writes, and if you do that ten times a day(ish) your chip will fail in rather less than three years.  Data in EEPROM would last twenty-seven(ish), at the same rate of rewriting.*

S.

 

* Of course, there are ways around that too - e.g. load-leveling - but they're a bit beyond the scope of this thread.