flash partial erase question

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

If one wishes to put code and code-related constants like strings in area A of flash, and large amounts of text like HTML in area B of flash, are the following correct?

1) Using an ISP or JTAG must always erase all of flash, e.g,. A and B?

2) The ISP process could do a partial erase, e.g., the ISP device itself is programmed. Maybe not so JTAG? Maybe they just use use a hardware level chip erase? I can't remember if AVRs have that, versus the block erase that I know they have.

3) A bootloader could be designed to erase only the blocks that are receiving download data. That is, one could replace A and not erase or affect B? But I don't think bootloaders do that.

I know, one could add a large serial EEP for this.

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

It has been my experience that the ISP tools (or at least ISP under AVR Studio control) erases the entire flash before programming. I assume this is done for speed because a chip erase followed by programming is much faster than erasing each individual page before programmming. I have complained bitterly to Atmel about not having a feature to disable chip erase before programming.

As far as a bootloader goes, you can certainly write your own bootloader to only erase pages that you desire to program. In fact, I would say this is the prefered method because the lock bits won't protect the bootloader from a chip erase command.

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

Quote:

I have complained bitterly to Atmel about not having a feature to disable chip erase before programming.

I've never seen that to be a problem. You have to do the erase anyway to clear the lock bits to allow programming anyway; lock-bits-set would be the norm, I would think, for any "production" code. And for first programming, or dev, who cares?

Now, you DON'T necessarily have to do an erase; just clear that step as part of the auto-programming sequence, as you might for signature check. Then you could do an erase separately, and then load parts of flash if you ensure that they don't overlap. I don't know how you do a verify, then.

Lee

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

Verify is no problem. You will only be verifying the intel hex records that were sent to the programmer.

So you can add stuff to flash memory, but of course only data added to virgin 0xFF memory will verify ok. (Unless you know that your new data is never OR-ing new bits)

IMHO it is no great problem to just re-write the whole flash.

David.

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

The ISP programmers can either perform a hardware-level full chip erase, or else they can perform no Flash erasure at all - they don't have access to any facility to selectively erase only certain pages or banks of Flash.

From what I've read, the public JTAG programming algorithm is the same way - it must either erase all of Flash, or else it will not erase any of it. But I suppose it may be possible that the OCD unit could be used to "emulate" the correct timed SPM sequence to erase individual pages.

I think if you really want to modify B without affecting A, then a bootloader would be the cleanest solution, because it *does* have the ability to selectively erase only the pages that it knows are being modified.

Of course, if you don't erase the Flash before writing to it, the result will be the bitwise ANDing of any original Flash contents against the desired new Flash contents.

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

If you look at the datasheets under Memory Programming, none of the methods (SPI,Parallel, JTAG) have a command to page erase, only chip erase. So as others have said, its all or nothing unless using spm.

You could have a bootloader that just wipes and loads 'B' area only (address not in 'B' = no write). Don't know if it would be any better/easier than just loading evrything every time, though.

You could get clever and just upload the data as text (instead of something like an intel hex record). Start bootloader, erase 'B', upload 'raw' html text to 'B', bootloader writes ascii to 'B'. Error checking would require some thought. Just an idea. Maybe not good.