bugAVR Downloader/UploaDEr - Bugs: bug #37812, STK500V2 not programming...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #37812: STK500V2 not programming "blank" pages when not erasing flash (-D)

Submitted by:  Simon Sabato <simonls>
Submitted on:  Sun 25 Nov 2012 08:57:46 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: None
Status: DuplicatePrivacy: Public
Assigned to: Joerg Wunsch <joerg_wunsch>Originator Name: simonls
Open/Closed: ClosedRelease: None
Programmer hardware: Device type: 

Thu 07 Feb 2013 09:32:44 PM UTC, comment #4:

I will make three more cases for why I think there should be an option to skip the "don't program blank pages" optimization. Then I will go away.

1) there is an assumption built in that an "erased" page is full of 1's. It is slightly inelegant to not have any way of working around that assumption in a system which behaved differently, should such a system ever be implemented.

2) if you don't provide that option, you will be potentially incorrectly programming many many existing Arduinos where the default is now to use the bootloader to program.

3) if you don't provide that option, BEST CASE solution (and what you propose) is that the bootloader will have to emulate full-chip-erase by doing a page-by-page erase of the entire chip, before programming. This is (a) much slower than full-chip erase, and (b) almost never necessary, because most people don't program the whole chip.

#3 is a very inelegant best case solution to a problem that could be resolved by merely disabling an optimization in the code (which in 99% of cases will have no speed impact at all).

If this a matter of effort in making the change, I will gladly volunteer my time! :)

Simon Sabato <simonls>
Mon 26 Nov 2012 09:15:12 AM UTC, comment #3:

> The problem is that in the Arduino flow, the "full chip erase" is
> not happening (since this would erase the bootloader) and instead
> the boot loader erases PAGES during programming.


This is a bug in the Arduino bootloader, and you should report it
accordingly.

Sure, the bootloader is not supposed to actually perform a chip erase
(and a bootloader even has no means to do that at all), but it must
perform the best approximation of a chip erase, that would mean to
erase all application pages when being asked to erase the chip.
Everything else is asking for trouble.

Unfortunately, the STK500v2 command doesn't offer any means of erasing
just a page only (for non-Xmega devices), which is basically due to
the fact that there is no "page erase" ISP command. That's the reason
why AVRDUDE cannot perform page erases here.

Joerg Wunsch <joerg_wunsch>
Project AdministratorIn charge of this item.
Mon 26 Nov 2012 08:34:53 AM UTC, comment #2:

Hi Joerg,

The problem is that in the Arduino flow, the "full chip erase" is not happening (since this would erase the bootloader) and instead the boot loader erases PAGES during programming. Of course, without that page erase, nothing would ever be programmed correctly...

I agree that the "is_page_empty" optimization makes sense in most cases (where a chip erase can be assumed). But if the "-D" flag has been given, perhaps AVRDUDE should not assume that the chip is fully erased? Or perhaps another command line option could be used to force writing all pages.

I can understand your argument that this is a bootloader issue. It does seem to me to be faster and more flexible to provide a way to disable this optimization in AVRDUDE. Faster, because it doesn't require many page erases to simulate a full-chip erase when only a few pages may need to be programmed. Flexible, because I may want to program say the first 64KB from one ELF, then another 64KB later from another ELF. In which case I definitely can't give a full-chip erase the second time, and I may not want to trust that the flash is still erased at that point.

Anyway, whatever you decide, thanks very much for all the effort you put behind this great piece of open source technology. May the source be with you!

-Simon

Simon Sabato <simonls>
Mon 26 Nov 2012 07:28:19 AM UTC, comment #1:

Duplicate of bug #30061, which has been closed as "Invalid".

Flash cells can only be programmed to bit value "0". In order to get
a cell to level "1", it has to be erased rather than programmed.

Consequently, if you bypass the erase step, it is completely normal
that you cannot revert the cells to "1" by just programming over it
again. A logical consequence of that is that trying to program a bit
to "1" is a no-op, and thus, trying to program an entire flash page to
0xFF can always be omitted, as it is not supposed to change anything
in that page.

The current SVN code has been changed to only ever trying to program
any page that has got data from the input file, so the old STK500v2
optimization can now be left out. However, the actual failure is
still in your attempt to program something that isn't in erased state.

Joerg Wunsch <joerg_wunsch>
Project AdministratorIn charge of this item.
Sun 25 Nov 2012 08:57:46 PM UTC, original submission:

I tried to debug a flash issue by "erasing" the Flash via programming it full of FF's. In the Mega2560/stk500v2 world, the "chip erase" is skipped and pages are erased as they are programmed. However AVRDUDE appears to skip programming pages that are full of FFs.

I think the culprit is the stk500v2_is_page_empty which perhaps should return 0 always if the "-D" flag is given? Although I can understand wanting the efficiency of not programming "blank" data, it seems even worse to end up with a Flash that doesn't match the obj file.

I imagine this could be a problem for anyone that has a dataset including 256 bytes of FF (which maybe now more likely in the 128/256KB Mega devices)

Simon Sabato <simonls>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by joerg_wunsch (Posted a comment)
  • -unavailable- added by simonls (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 26 Nov 2012 07:28:19 AM UTCjoerg_wunschStatusNone=>Duplicate
      Assigned toNone=>joerg_wunsch
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1