Completely Erasing atmega256 flash using bootloader

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

Hi,

 

I have implemented a bootloader for the atmega256. The SPM can only erase the flash page by page which is too slow for the firmware I am implementing.

Is there any way to erase all the flash at once using the SPM, like how the AVRISP MKII programmer does which is very fast?

 

Thanks

This topic has a solution.
Last Edited: Tue. Jan 30, 2018 - 02:10 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No.

 

You need an external programmer to do the erase-in-one-quick-step.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

crying

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

Why do you think you need to do it all at once?  You could simply acknowledge the erase chip command, but defer the actual erasing until each page is actually programmed.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

joeymorin wrote:
Why do you think you need to do it all at once?

I want to hear why it is too slow.  It is about 4ms per page (on '88PA family) for full operation including erase.  If actually bootloading, can the next page be transferred faster than that?  Perhaps...a 1Mbps link would be a millisecond for 1000bits/125 bytes.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

It is about 4ms per page

 That would be about 4 seconds for the whole chip.

There's a set of bugs open against the Arduino bootloader (and/or avrdude) - the bootloader doesn't erase pages that aren't explicitly programmed, and avrdude doesn't upload pages that are all 0xFF...

 

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

A mega2560 has got 1024 Flash pages.    This would be about 4 sec to erase and 4 sec to program.

Transferring a HEX file on a Serial line @ 115200 baud is about 2.5 * 256k * 87us = 56 sec

 

In practice you only erase a page just before programming it.   And use USB to transfer a HEX or BIN file faster than 115200 baud.

 

There are simple limits on any programming time.    Mostly the traffic between PC and programmer (e.g. HEX file) and SPI traffic between programmer and AVR (e.g. ISP commands)

 

The actual Flash page erase or programming is fairly insignificant.

 

Bootloader on Mega2560 or Due is fairly slow.   Hey-ho.   It uses one USB cable and no external programmer.

JTAG or SWD is a lot faster.    But for uploading finished Arduino binaries a bootloader is convenient.

 

Note that most punters buy a 256kB or 512kB Arduino and run a 1kB Blinky on it.

 

David.

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

hadez803 wrote:

Is there any way to erase all the flash at once using the SPM..

If it would be the way you ask, it would leave you without bootloader. If your requirements are so tight, you might want to look at XMega microcontrollers; they can erase the application section in one shot.

westfw wrote:

the bootloader doesn't erase pages that aren't explicitly programmed

I wouldn't call it a bug.

westfw wrote:

avrdude doesn't upload pages that are all 0xFF...

It sounds fair to me if the pages in question are not present in the hex file. If they are, they should be erased at least. Someone would want to put in there a lookup table spanning few pages with the last page full of FFs.

Last Edited: Mon. Feb 5, 2018 - 02:15 AM