This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

why ram ecc donot update when writing to ram

Dear All

After memory initialization, all the ram data are 0, and the ram ecc region is filled with 0x0C.

But when I write to them, no change on ram ecc region

I put these code in main:

 (*(volatile uint64 *)(0x08000000U)) = 0xFFFFFFFFFFFFFFFF;
 (*(volatile uint64 *)(0x08000008U)) = 0xAAAAAAAAAAAAAAAA;

So why the ram ecc  donot update when writing ram, if ram ecc stay 0x0c constantly, how ram ecc detect the fault?

Regards

Leo

  • and there are some more weird observation
    tcramA1bitError ^= 0x1U; this code is to flip one bit of ram ecc, actually 8 ecc bytes (64 bits )change from 0x0c to 0x0d,
    if I forcedly write data to ram ecc, tcramA1bitError = 0x0c0c0c0d; , it is still all 0x0d0d0d0d...... very confused.
  • and another strange thing is
    you can only flip bit at address of 0x08400000U, if you change to 0x08400010U like this
    (*(volatile uint64 *)(0x08400010U)) ^= 0x1U; the ram ecc will not change
    but if you write like this:
    (*(volatile uint64 *)(0x08400010U)) ^= 0x3U;
    ram ecc can be changed to 0x0f
    Leo
  • Hi Leo,
    In order to write to ECC space you need to enable the bit 8 of the RAMCTRL register.
  • Hi Charles
    My question is why the ram ecc donot update when writing ram, I am not writing to ram ecc space.
    Leo
  • Hi Leo,

     My misunderstanding. You have three threads and one of them you talked about flipping bit at 0x08400000 which is the ECC space.

     Let's go through your questions here:

     (*(volatile uint64 *)(0x08000000U)) = 0xFFFFFFFFFFFFFFFF;

    (*(volatile uint64 *)(0x08000008U)) = 0xAAAAAAAAAAAAAAAA;

    So why the ram ecc  donot update when writing ram, if ram ecc stay 0x0c constantly, how ram ecc detect the fault?

    Charles>> Did you enable ECC? Also bear in mind that for a 64-bit data there are 2^64 combinations while the 8-bit ECC only gives 2^8 combinations. It is possible that two different 64-bit data gives the same 8-bit ECC checksum. Please make sure you enable ECC and try with some random data and see if the ECC changes. 

     

    and there are some more weird observation

    tcramA1bitError ^= 0x1U; this code is to flip one bit of ram ecc, actually 8 ecc bytes (64 bits )change from 0x0c to 0x0d,

    if I forcedly write data to ram ecc, tcramA1bitError = 0x0c0c0c0d; , it is still all 0x0d0d0d0d...... very confused.

     

    Charles>> The ECC is 8-bit. However, it occupies a 64-bit space. The 8-bit ECC is just replicated 8 times when you read. The RAM controller simplifies the logic by broadcasting the 8-bit data eight times knowing that the CPU will pick the right byte lane.

     

    and another strange thing is

    you can only flip bit at address of 0x08400000U, if you change to 0x08400010U like this

    (*(volatile uint64 *)(0x08400010U)) ^= 0x1U; the ram ecc will not change

    but if you write like this:

    (*(volatile uint64 *)(0x08400010U)) ^= 0x3U;

    ram ecc can be changed to 0x0f

     

    Charles>> I don't know for sure at this moment why you can't write to 0x08400010U. It may have something to do with endianism. For an experiment, can you try (*(volatile uint64 *)(0x08400010U)) ^= 0x0101010101010101U. Don't worry that you are flipping 8 different bits here. It will not.  As I said the ECC is only 8-bit  physically but occupies 64-bit of logical address.  So one of the 8 bytes will get updated to the ECC space. I just want to prove it has something to do with endianism. Or you can try 8 different steps like:

    (*(volatile uint64 *)(0x08400010U)) ^= 0x01U 

    (*(volatile uint64 *)(0x08400010U)) ^= 0x0100U 

    (*(volatile uint64 *)(0x08400010U)) ^= 0x010000U 

    ....

    (*(volatile uint64 *)(0x08400010U)) ^= 0x010000000000

     

    If this experiment proves true then it may also explain about question 1. 

     

  •  Dear Charles

    You are absolutely right.Thank you for your help.

    I'd like to share my findings here for others who may have same question.

    enable the ram ecc or not, when you write ram, the ram ecc code will update, if put 0xFFFFFFFFFFFFFFFF;  and  0xAAAAAAAAAAAAAAAA

    it happens to generate the same ecc, so I  erroneously think that it did not update.

    secondly, there is "The ECC memory can only be written to as a 64-bit access"  so the code generated by hacogen is not completely correct, it accesses ecc as 32 bits, and it didnt consider the endianness. it better be like : (*(volatile uint64 *)(0x08400000U)) ^= 0x100000000U;

    Charles is right about the memory size although every 64 bits data has 8 bits ecc, but in memory, every 64 bits data has 64 bits ecc(which is duplicated).

    Thank you again.

    Leo

  • Hi Leo,
    Glad that everything is clear to you now.