• AVR Freaks

Hot!Is it possible to write to program flash without erasing it if flash contains '1' only?

Author
LABtester
New Member
  • Total Posts : 5
  • Reward points : 0
  • Joined: 2018/11/02 02:31:17
  • Location: 0
  • Status: offline
2019/05/21 07:08:05 (permalink)
0

Is it possible to write to program flash without erasing it if flash contains '1' only?

When erasing flash memory we write '1' to all it's bits. And after erasing memory we can write to it.
But if the word in inactive program memory already contains FFFF is it possible to write to it without erasing?
PIC24FJ1024GA606 in dual partition mode. Trying to write to FBTSEQ.
#1

8 Replies Related Threads

    1and0
    Access is Denied
    • Total Posts : 9200
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Is it possible to write to program flash without erasing it if flash contains '1' only 2019/05/21 07:40:55 (permalink)
    5 (1)
    Why don't you just try it and see it for yourself?
     
    #2
    NKurzman
    A Guy on the Net
    • Total Posts : 17341
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: Is it possible to write to program flash without erasing it if flash contains '1' only 2019/05/21 07:55:04 (permalink)
    5 (2)
    You can write zeros as many times as you want without erasing. Except on chips that have error detecting Flash.
    #3
    NorthGuy
    Super Member
    • Total Posts : 5428
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: offline
    Re: Is it possible to write to program flash without erasing it if flash contains '1' only 2019/05/21 10:04:52 (permalink)
    5 (1)
    It is mostly irrelevant because FBTSEQ consists of two parts - one being the complement of the other, so you cannot convert a valid value into a different valid value by only writing '0'.
     
    You can turn a valid value into invalid, which will automatically change the partition to inactive, but once you do this you won't be able to make any useful changes without erase.
     
    Of course, you can write a valid value if the field contains all '1' once, but not much you can do afterwards.
    #4
    NKurzman
    A Guy on the Net
    • Total Posts : 17341
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: Is it possible to write to program flash without erasing it if flash contains '1' only 2019/05/21 15:31:35 (permalink)
    5 (1)
    So Not Really Program Flash then.
    #5
    LABtester
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2018/11/02 02:31:17
    • Location: 0
    • Status: offline
    Re: Is it possible to write to program flash without erasing it if flash contains '1' only 2019/05/22 00:49:54 (permalink)
    0
    NKurzman
    You can write zeros as many times as you want without erasing. Except on chips that have error detecting Flash.

    NorthGuy
    Of course, you can write a valid value if the field contains all '1' once.

    1and0
    Why don't you just try it and see it for yourself?

    I have tried of course.
    To protect the application in the inactive segment I write the raw with configuration bits and FBTSEQ among them to the inactive segment. FBTSEQ = FFFFFF (not valid).
    Then I write my application to this segment.
    Then I write the raw with the same configuration bits once more, but FBTSEQ equals some other value. Then I read FBTSEQ and compare it with the desired value. The result depends on this value.
    If desired FBTSEQ = 001FFE then actual FBTSEQ = 001FFE - OK
    If desired FBTSEQ = 002FFD then actual FBTSEQ = 012FFD - not OK
    If desired FBTSEQ = 003FFC then actual FBTSEQ = 003FF8 - not OK
    If desired FBTSEQ = 004FFB then actual FBTSEQ = 005FFE - not OK
    If desired FBTSEQ = 005FFA then actual FBTSEQ = 005FFA - OK
    If desired FBTSEQ = 006FF9 then actual FBTSEQ = 006FF9 - OK
    If desired FBTSEQ = 007FF8 then actual FBTSEQ = 003FF8 - not OK
    and so on.
     
    NKurzman
    You can write zeros as many times as you want without erasing. Except on chips that have error detecting Flash.

    Explain it please.
    #6
    JPortici
    Super Member
    • Total Posts : 674
    • Reward points : 0
    • Joined: 2012/11/17 06:27:45
    • Location: Grappaland
    • Status: offline
    Re: Is it possible to write to program flash without erasing it if flash contains '1' only 2019/05/22 01:07:37 (permalink)
    5 (1)
    LABtester
    Explain it please.



    there are MANY threads about this.
    basically, the process of "writing" flash memory is turning ones into zeros, whereas "erasing" is turning zeros into one.
    you can "overwrite" zeros with zeros as much as you like and you can "overwrite" ones with ones as much as you like.
     
    Then, we have chips with ECC memory. If your chip has ECC memory you can't do this. To understand why, go to the chip product page -> documents -> family reference manual, the chapter on flash with ECC.
    long story short, there is a parity word that is calculated every 48bits of flash, which is stored along with the 48 bits. When you change a bit a new parity word will be calculated and there is good chance that is going to be different.. let's say 0x70 is the old and 0x1F is the new... but you can't turn 0 into F by writing so the actual value will be 0x10.
    Next time the flash controller will have to read the two flash words an ECC trap will be generated and if no handler is present there will be a reset.
     
    the ECC is reset with an erase so
    -Overwrite the OTP and the OTP will be useless (can't erase it)
    -Overwrite the configuration words and you won't be able to start the device, at all. It can also be very tricky to enter programming mode to erase the device, so you may just want to toss it.
     
    If you still have questions.. there are MANY threads where this was explained in much more detail, then there's also the documentation.
    #7
    LABtester
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2018/11/02 02:31:17
    • Location: 0
    • Status: offline
    Re: Is it possible to write to program flash without erasing it if flash contains '1' only 2019/05/22 03:38:02 (permalink)
    0
    Jack_M
     

    Thank you. Start reading.
     
     
    #8
    LABtester
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2018/11/02 02:31:17
    • Location: 0
    • Status: offline
    Re: Is it possible to write to program flash without erasing it if flash contains '1' only 2019/05/22 05:22:15 (permalink)
    0
    Thanks to all. Problem solved by double word writing instead of row writing.
     
    #9
    Jump to:
    © 2019 APG vNext Commercial Version 4.5