Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > sci.electronics.design > #510155 > unrolled thread
| Started by | bitrex <user@example.net> |
|---|---|
| First post | 2018-07-05 11:00 -0400 |
| Last post | 2018-07-06 12:59 +0100 |
| Articles | 12 — 7 participants |
Back to article view | Back to sci.electronics.design
Hamming ECC bitrex <user@example.net> - 2018-07-05 11:00 -0400
Re: Hamming ECC Martin Brown <'''newspam'''@nezumi.demon.co.uk> - 2018-07-06 09:31 +0100
Re: Hamming ECC David Brown <david.brown@hesbynett.no> - 2018-07-06 11:05 +0200
Re: Hamming ECC bitrex <user@example.net> - 2018-07-06 22:15 -0400
Re: Hamming ECC gnuarm.deletethisbit@gmail.com - 2018-07-06 20:03 -0700
Re: Hamming ECC bitrex <user@example.net> - 2018-07-06 23:41 -0400
Re: Hamming ECC bitrex <user@example.net> - 2018-07-06 23:48 -0400
Re: Hamming ECC bitrex <user@example.net> - 2018-07-07 00:17 -0400
Re: Hamming ECC +++ATH0 <news@ringpiece.local> - 2018-07-11 20:47 -0700
Re: Hamming ECC bitrex <user@example.net> - 2018-07-12 00:12 -0400
Re: Hamming ECC Rob <nomail@example.com> - 2018-07-12 08:15 +0000
Re: Hamming ECC Clive Arthur <cliveta@nowaytoday.co.uk> - 2018-07-06 12:59 +0100
| From | bitrex <user@example.net> |
|---|---|
| Date | 2018-07-05 11:00 -0400 |
| Subject | Hamming ECC |
| Message-ID | <8oq%C.202594$mD.79637@fx31.iad> |
Do you use Hamming/Reed Solomon/etc. codes to check for data errors when writing/reading e.g. large battery-backed SRAMs or Flash memory that's are used for non-volatile storage of user data for significant periods of time (couple weeks)? Or do you find single-bit errors in RAM reads to be not much of an issue in practice? I'm considering writing the external memory in pages of say 8 bytes with 8 nibbles of Hamming code and 1 byte of parity bits for single-bit correction 2 bit detection. In this application a single-bit error would not be life-threatening or anything but significantly annoying for the user, the data isn't intrinsically fault tolerant to some degree like say image or audio data.
[toc] | [next] | [standalone]
| From | Martin Brown <'''newspam'''@nezumi.demon.co.uk> |
|---|---|
| Date | 2018-07-06 09:31 +0100 |
| Message-ID | <phn9dv$sd5$2@gioia.aioe.org> |
| In reply to | #510155 |
On 05/07/2018 16:00, bitrex wrote: > Do you use Hamming/Reed Solomon/etc. codes to check for data errors when > writing/reading e.g. large battery-backed SRAMs or Flash memory that's > are used for non-volatile storage of user data for significant periods > of time (couple weeks)? Or do you find single-bit errors in RAM reads to > be not much of an issue in practice? Provided that you are not in a hot environment full of alpha particles or cosmic rays I'd say the risk was vanishingly small. All bets are off if your bus timings are out of spec but apart from that they are rare. > I'm considering writing the external memory in pages of say 8 bytes with > 8 nibbles of Hamming code and 1 byte of parity bits for single-bit > correction 2 bit detection. In this application a single-bit error would > not be life-threatening or anything but significantly annoying for the > user, the data isn't intrinsically fault tolerant to some degree like > say image or audio data. Parity error detection so that you know there is a problem with a particular byte might be good enough. -- Regards, Martin Brown
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2018-07-06 11:05 +0200 |
| Message-ID | <phnbc6$vli$1@dont-email.me> |
| In reply to | #510155 |
On 05/07/18 17:00, bitrex wrote: > Do you use Hamming/Reed Solomon/etc. codes to check for data errors when > writing/reading e.g. large battery-backed SRAMs or Flash memory that's > are used for non-volatile storage of user data for significant periods > of time (couple weeks)? Or do you find single-bit errors in RAM reads to > be not much of an issue in practice? > > I'm considering writing the external memory in pages of say 8 bytes with > 8 nibbles of Hamming code and 1 byte of parity bits for single-bit > correction 2 bit detection. In this application a single-bit error would > not be life-threatening or anything but significantly annoying for the > user, the data isn't intrinsically fault tolerant to some degree like > say image or audio data. For configuration data and the like, I usually have a CRC checksum and dual copies of the data. The most likely failure mode is a power-off or reset while writing one copy of the data, rather than corruption of the memory, but it would handle that too. It is a different matter if you have NAND flash - there bit-level failures are to be expected and you will need some sort of ECC. If you really expect problems, or have high-value data, then you may want more than one flash chip in case of total failure. I've done that on a board for extreme environments - there were several flash chips and data was stored in RAID-5 stripes (with checksums on each block). I didn't see any stripe failures in practice.
[toc] | [prev] | [next] | [standalone]
| From | bitrex <user@example.net> |
|---|---|
| Date | 2018-07-06 22:15 -0400 |
| Message-ID | <9nV%C.258249$p05.239018@fx28.iad> |
| In reply to | #510210 |
On 07/06/2018 05:05 AM, David Brown wrote: > On 05/07/18 17:00, bitrex wrote: >> Do you use Hamming/Reed Solomon/etc. codes to check for data errors when >> writing/reading e.g. large battery-backed SRAMs or Flash memory that's >> are used for non-volatile storage of user data for significant periods >> of time (couple weeks)? Or do you find single-bit errors in RAM reads to >> be not much of an issue in practice? >> >> I'm considering writing the external memory in pages of say 8 bytes with >> 8 nibbles of Hamming code and 1 byte of parity bits for single-bit >> correction 2 bit detection. In this application a single-bit error would >> not be life-threatening or anything but significantly annoying for the >> user, the data isn't intrinsically fault tolerant to some degree like >> say image or audio data. > > For configuration data and the like, I usually have a CRC checksum and > dual copies of the data. The most likely failure mode is a power-off or > reset while writing one copy of the data, rather than corruption of the > memory, but it would handle that too. Thanks, yeah that's the most realistic situation where errors would pop up in this application, "burst errors" where a page write doesn't complete due to power loss and you have half the page correct and half garbage. > It is a different matter if you have NAND flash - there bit-level > failures are to be expected and you will need some sort of ECC. > > If you really expect problems, or have high-value data, then you may > want more than one flash chip in case of total failure. I've done that > on a board for extreme environments - there were several flash chips and > data was stored in RAID-5 stripes (with checksums on each block). I > didn't see any stripe failures in practice. > I was thinking one could do like a quasi-"journaling filesystem" that combines strategies but doesn't require storing two complete independent copies of the data. Start with two flag bits in a table in the external SRAM for each memory page and unset them both at the start of a write. In a buffer in internal RAM calculate parity bytes for the data, call the data + parity bytes a page, calculate CRC-16, and write out the CRC to a page header. Set flag bit one for the page. Then write data and parity bytes, set flag bit two when done. When you come back to read if the first flag is unset it means that a write to that page was interrupted in during the parity/CRC generation process and the page contains whatever it held before. If bit 1 is set but bit 2 isn't it means it was interrupted in the page writeout and the page is probably garbage, no point to attempt error correction. If they're both set but the CRC doesn't match then something else went wrong you can attempt error correction using the parity bytes.
[toc] | [prev] | [next] | [standalone]
| From | gnuarm.deletethisbit@gmail.com |
|---|---|
| Date | 2018-07-06 20:03 -0700 |
| Message-ID | <2b2fcca1-645d-44d8-9f5d-cb2792a312c8@googlegroups.com> |
| In reply to | #510272 |
On Friday, July 6, 2018 at 10:15:37 PM UTC-4, bitrex wrote: > > I was thinking one could do like a quasi-"journaling filesystem" that > combines strategies but doesn't require storing two complete independent > copies of the data. Start with two flag bits in a table in the external > SRAM for each memory page and unset them both at the start of a write. > In a buffer in internal RAM calculate parity bytes for the data, call > the data + parity bytes a page, calculate CRC-16, and write out the CRC > to a page header. Set flag bit one for the page. Then write data and > parity bytes, set flag bit two when done. > > When you come back to read if the first flag is unset it means that a > write to that page was interrupted in during the parity/CRC generation > process and the page contains whatever it held before. If bit 1 is set > but bit 2 isn't it means it was interrupted in the page writeout and the > page is probably garbage, no point to attempt error correction. If > they're both set but the CRC doesn't match then something else went > wrong you can attempt error correction using the parity bytes. You need to give this more thought. Your conclusions about the states of the flags are not correct. Work through your process as a list of steps. See what the state of the flags are at every point in the steps. Rick C.
[toc] | [prev] | [next] | [standalone]
| From | bitrex <user@example.net> |
|---|---|
| Date | 2018-07-06 23:41 -0400 |
| Message-ID | <TDW%C.250834$IF4.68413@fx14.iad> |
| In reply to | #510276 |
On 07/06/2018 11:03 PM, gnuarm.deletethisbit@gmail.com wrote: > On Friday, July 6, 2018 at 10:15:37 PM UTC-4, bitrex wrote: >> >> I was thinking one could do like a quasi-"journaling filesystem" that >> combines strategies but doesn't require storing two complete independent >> copies of the data. Start with two flag bits in a table in the external >> SRAM for each memory page and unset them both at the start of a write. >> In a buffer in internal RAM calculate parity bytes for the data, call >> the data + parity bytes a page, calculate CRC-16, and write out the CRC >> to a page header. Set flag bit one for the page. Then write data and >> parity bytes, set flag bit two when done. >> >> When you come back to read if the first flag is unset it means that a >> write to that page was interrupted in during the parity/CRC generation >> process and the page contains whatever it held before. If bit 1 is set >> but bit 2 isn't it means it was interrupted in the page writeout and the >> page is probably garbage, no point to attempt error correction. If >> they're both set but the CRC doesn't match then something else went >> wrong you can attempt error correction using the parity bytes. > > You need to give this more thought. Your conclusions about the states of the flags are not correct. Work through your process as a list of steps. See what the state of the flags are at every point in the steps. > > Rick C. > I'm guessing I've simply invented a wrong version of something that's already been invented.
[toc] | [prev] | [next] | [standalone]
| From | bitrex <user@example.net> |
|---|---|
| Date | 2018-07-06 23:48 -0400 |
| Message-ID | <4KW%C.510626$PE5.87358@fx37.iad> |
| In reply to | #510279 |
On 07/06/2018 11:41 PM, bitrex wrote: > On 07/06/2018 11:03 PM, gnuarm.deletethisbit@gmail.com wrote: >> On Friday, July 6, 2018 at 10:15:37 PM UTC-4, bitrex wrote: >>> >>> I was thinking one could do like a quasi-"journaling filesystem" that >>> combines strategies but doesn't require storing two complete independent >>> copies of the data. Start with two flag bits in a table in the external >>> SRAM for each memory page and unset them both at the start of a write. >>> In a buffer in internal RAM calculate parity bytes for the data, call >>> the data + parity bytes a page, calculate CRC-16, and write out the CRC >>> to a page header. Set flag bit one for the page. Then write data and >>> parity bytes, set flag bit two when done. >>> >>> When you come back to read if the first flag is unset it means that a >>> write to that page was interrupted in during the parity/CRC generation >>> process and the page contains whatever it held before. If bit 1 is set >>> but bit 2 isn't it means it was interrupted in the page writeout and the >>> page is probably garbage, no point to attempt error correction. If >>> they're both set but the CRC doesn't match then something else went >>> wrong you can attempt error correction using the parity bytes. >> >> You need to give this more thought. Your conclusions about the states >> of the flags are not correct. Work through your process as a list of >> steps. See what the state of the flags are at every point in the steps. >> >> Rick C. >> > > I'm guessing I've simply invented a wrong version of something that's > already been invented. The flaw is likely that there's no reasonable way to guarantee the setting of the "flag bits" is itself an atomic operation.
[toc] | [prev] | [next] | [standalone]
| From | bitrex <user@example.net> |
|---|---|
| Date | 2018-07-07 00:17 -0400 |
| Message-ID | <o9X%C.373423$ll2.82505@fx35.iad> |
| In reply to | #510276 |
On 07/06/2018 11:03 PM, gnuarm.deletethisbit@gmail.com wrote: > On Friday, July 6, 2018 at 10:15:37 PM UTC-4, bitrex wrote: >> >> I was thinking one could do like a quasi-"journaling filesystem" that >> combines strategies but doesn't require storing two complete independent >> copies of the data. Start with two flag bits in a table in the external >> SRAM for each memory page and unset them both at the start of a write. >> In a buffer in internal RAM calculate parity bytes for the data, call >> the data + parity bytes a page, calculate CRC-16, and write out the CRC >> to a page header. Set flag bit one for the page. Then write data and >> parity bytes, set flag bit two when done. >> >> When you come back to read if the first flag is unset it means that a >> write to that page was interrupted in during the parity/CRC generation >> process and the page contains whatever it held before. If bit 1 is set >> but bit 2 isn't it means it was interrupted in the page writeout and the >> page is probably garbage, no point to attempt error correction. If >> they're both set but the CRC doesn't match then something else went >> wrong you can attempt error correction using the parity bytes. > > You need to give this more thought. Your conclusions about the states of the flags are not correct. Work through your process as a list of steps. See what the state of the flags are at every point in the steps. > > Rick C. > To start with the simpler one-flag-bit case it seems hard to get wrong. To begin a write you load the appropriate flag table byte that holds the flag bit you want to zero into say a processor register, flip the bit to zero, write it back out. If power is lost at any point during that process prior to the commit (e.g. WE being de-asserted after the address and data registers are latched on a parallel SRAM) then nothing has changed in the SRAM and the associated data page should have whatever it had originally. If processor power is lost during the page write-out then the associated flag bit is still zero and it will be assumed the page write-out did not complete. If power is lost during the flag table byte flip bit back to 1 after a page write it's the reverse of the first paragraph, it will be assumed that the write-out did not complete when it actually did if power to the processor is lost during that, that sucks but seems like a fairly unlikely edge-case.
[toc] | [prev] | [next] | [standalone]
| From | +++ATH0 <news@ringpiece.local> |
|---|---|
| Date | 2018-07-11 20:47 -0700 |
| Message-ID | <3MadnSnFhOujUtvGnZ2dnUU7-WfNnZ2d@supernews.com> |
| In reply to | #510281 |
On 2018-07-06 21:17, bitrex wrote: > To start with the simpler one-flag-bit case it seems hard to get wrong. > To begin a write you load the appropriate flag table byte that holds the > flag bit you want to zero into say a processor register, flip the bit to > zero, write it back out. If power is lost at any point during that > process prior to the commit (e.g. WE being de-asserted after the address > and data registers are latched on a parallel SRAM) then nothing has > changed in the SRAM and the associated data page should have whatever it > had originally. > > If processor power is lost during the page write-out then the associated > flag bit is still zero and it will be assumed the page write-out did not > complete. If power is lost during the flag table byte flip bit back to 1 > after a page write it's the reverse of the first paragraph, it will be > assumed that the write-out did not complete when it actually did if > power to the processor is lost during that, that sucks but seems like a > fairly unlikely edge-case. Problems arise if you have any sort of multi-tasking, because then you need to have semaphores/mutexes around all this stuff, and you probably need to make the whole thing asynchronous to avoid deadlocks. Journalling file systems end up writing a complete copy of the changed data to the journal, then to the file system, then updating the file system metadata and even then it's not 100% guaranteed safe because the final metadata update can be corrupted too. It's just a smaller window at risk. You need a full copy of the data which is being changed in the journal so you can recover from interrupted partial page writes to the main file system. Simply knowing it failed or no longer has the correct checksum isn't much use.
[toc] | [prev] | [next] | [standalone]
| From | bitrex <user@example.net> |
|---|---|
| Date | 2018-07-12 00:12 -0400 |
| Message-ID | <wyA1D.364095$T14.327350@fx44.iad> |
| In reply to | #510685 |
On 07/11/2018 11:47 PM, +++ATH0 wrote: > On 2018-07-06 21:17, bitrex wrote: >> To start with the simpler one-flag-bit case it seems hard to get wrong. >> To begin a write you load the appropriate flag table byte that holds the >> flag bit you want to zero into say a processor register, flip the bit to >> zero, write it back out. If power is lost at any point during that >> process prior to the commit (e.g. WE being de-asserted after the address >> and data registers are latched on a parallel SRAM) then nothing has >> changed in the SRAM and the associated data page should have whatever it >> had originally. >> >> If processor power is lost during the page write-out then the associated >> flag bit is still zero and it will be assumed the page write-out did not >> complete. If power is lost during the flag table byte flip bit back to 1 >> after a page write it's the reverse of the first paragraph, it will be >> assumed that the write-out did not complete when it actually did if >> power to the processor is lost during that, that sucks but seems like a >> fairly unlikely edge-case. > > Problems arise if you have any sort of multi-tasking, because then you > need to have semaphores/mutexes around all this stuff, and you probably > need to make the whole thing asynchronous to avoid deadlocks. > > Journalling file systems end up writing a complete copy of the changed > data to the journal, then to the file system, then updating the file > system metadata and even then it's not 100% guaranteed safe because the > final metadata update can be corrupted too. It's just a smaller window > at risk. > > You need a full copy of the data which is being changed in the journal > so you can recover from interrupted partial page writes to the main file > system. Simply knowing it failed or no longer has the correct checksum > isn't much use. > The situation I'm thinking of in a real-time application is for example where battery-backed SRAM is used to store e.g. sequences of user entered data for some purpose, like say a list of pulse lengths or something. User punches "1234567", it shows up on the screen, user hits "commit" and at that point it's stored to a list in "mass storage." If during the write-out after the "commit" button is pushed power is lost during some part of the write sequence, if I know that it failed, I can at least on restart wipe that block of memory and not add the entry to the table the user sees so they at least know it didn't take.
[toc] | [prev] | [next] | [standalone]
| From | Rob <nomail@example.com> |
|---|---|
| Date | 2018-07-12 08:15 +0000 |
| Message-ID | <slrnpke3he.ebu.nomail@xs9.xs4all.nl> |
| In reply to | #510688 |
bitrex <user@example.net> wrote:
> On 07/11/2018 11:47 PM, +++ATH0 wrote:
>> On 2018-07-06 21:17, bitrex wrote:
>>> To start with the simpler one-flag-bit case it seems hard to get wrong.
>>> To begin a write you load the appropriate flag table byte that holds the
>>> flag bit you want to zero into say a processor register, flip the bit to
>>> zero, write it back out. If power is lost at any point during that
>>> process prior to the commit (e.g. WE being de-asserted after the address
>>> and data registers are latched on a parallel SRAM) then nothing has
>>> changed in the SRAM and the associated data page should have whatever it
>>> had originally.
>>>
>>> If processor power is lost during the page write-out then the associated
>>> flag bit is still zero and it will be assumed the page write-out did not
>>> complete. If power is lost during the flag table byte flip bit back to 1
>>> after a page write it's the reverse of the first paragraph, it will be
>>> assumed that the write-out did not complete when it actually did if
>>> power to the processor is lost during that, that sucks but seems like a
>>> fairly unlikely edge-case.
>>
>> Problems arise if you have any sort of multi-tasking, because then you
>> need to have semaphores/mutexes around all this stuff, and you probably
>> need to make the whole thing asynchronous to avoid deadlocks.
>>
>> Journalling file systems end up writing a complete copy of the changed
>> data to the journal, then to the file system, then updating the file
>> system metadata and even then it's not 100% guaranteed safe because the
>> final metadata update can be corrupted too. It's just a smaller window
>> at risk.
>>
>> You need a full copy of the data which is being changed in the journal
>> so you can recover from interrupted partial page writes to the main file
>> system. Simply knowing it failed or no longer has the correct checksum
>> isn't much use.
>>
>
> The situation I'm thinking of in a real-time application is for example
> where battery-backed SRAM is used to store e.g. sequences of user
> entered data for some purpose, like say a list of pulse lengths or
> something. User punches "1234567", it shows up on the screen, user hits
> "commit" and at that point it's stored to a list in "mass storage."
>
> If during the write-out after the "commit" button is pushed power is
> lost during some part of the write sequence, if I know that it failed, I
> can at least on restart wipe that block of memory and not add the entry
> to the table the user sees so they at least know it didn't take.
When that is the usage, it is easy.
The usual situation is that the SRAM is used to store configuration
data that is valid as a complete set. It has to be checked if valid
(e.g. CRC) and if not valid it should revert to the previous state or
back to defaults, depending on the specs. That is where the 2 copies
potentially come in.
What you have is just a serial storage of data and it requires only a
CRC per record. ECC is not much use as bit errors in SRAM are rare,
and the cause of errors more likely is power failure (both during the
write and during powerdown when the battery runs out), and doing ECC
potentially makes things worse ("correcting" bad data to seemingly
valid good data that actually is trash).
[toc] | [prev] | [next] | [standalone]
| From | Clive Arthur <cliveta@nowaytoday.co.uk> |
|---|---|
| Date | 2018-07-06 12:59 +0100 |
| Message-ID | <phnljo$q7f$1@dont-email.me> |
| In reply to | #510155 |
On 05/07/2018 16:00, bitrex wrote: > Do you use Hamming/Reed Solomon/etc. codes to check for data errors when > writing/reading e.g. large battery-backed SRAMs or Flash memory that's > are used for non-volatile storage of user data for significant periods > of time (couple weeks)? Or do you find single-bit errors in RAM reads to > be not much of an issue in practice? > > I'm considering writing the external memory in pages of say 8 bytes with > 8 nibbles of Hamming code and 1 byte of parity bits for single-bit > correction 2 bit detection. In this application a single-bit error would > not be life-threatening or anything but significantly annoying for the > user, the data isn't intrinsically fault tolerant to some degree like > say image or audio data. I used a NAND flash memory which had 2 'spare' bytes for every 64 'normal' bytes in an embedded system. I think this may be quite a common arrangement. The uC had a built in CRC generator so it was easy to write a 16 bit CRC for every 64 data bytes. As well as detecting errors, this allows you to correct 1 bit error, not a brilliant performance, but easy to do. Cheers -- Clive
[toc] | [prev] | [standalone]
Back to top | Article view | sci.electronics.design
csiph-web