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.

TDA3MV: ECC behavior of unaligned access to DDR3

Part Number: TDA3MV
Other Parts Discussed in Thread: SYSBIOS

Hi,

I am working on a project with TDA3 SR2.0. We use both M4 cores, DSP, EVE, ISP, DSS, LDC, CSI-2.
First I noticed the errata "i882 EMIF: DDR ECC Corrupted Read/Write Status Response" and thougth that in SR2.0 ECC will work fine. Yesterday I activated the ECC in our EMIF driver for the bootstrap. After that the software that normally boots did not boot properly. M4_1 did not start or had an exception, I don't know. After disabling the ECC booting was ok, again.

Than I found the application note "ECC/EDC on TDAxx" sprac42b

I was surprized that there is a restriction to access the DDR3 with activated ECC.

"EMIF supports ECC on the data written or read from the SDRAM. Enable the ECC feature by writing to
the appropriate registers inside the EMIF subsystem. ECC accesses are allowed for both SYS and the
MPU ports. 7-bit ECC is calculated over 32-bit data when in 32-bit DDR mode. 6-bit ECC is calculated
over 16-bit data when in 16-bit DDR mode. The ECC is calculated for all accesses that are within the
address ranges protected by ECC. These address ranges are software configurable. The ECC must be
enabled and only aligned writes with byte count in multiple of 4 bytes (2 bytes for narrow mode) should be
used. This is true for all TDA devices other than TDA2PX where you can have sub quanta writes as well."

"2.5.1.1 Restrictions Due to Non-Availability of Read Modify Write ECC Support in EMIF
In normal mode, a 7-bit ECC is computed for each 32-bit word, whereas, in narrow mode, a 6-bit ECC is
computed for each 16-bit word. EMIF does not provide read-modify-write support for ECC for all TDA
devices except TDA2PX. This means that any sub-quanta write access (less than 32 bit for normal and
less than 16 bit for narrow mode) generates an incorrect ECC and writes it into ECC memories. Any
further reads to such corrupted regions will very likely generate false 1-bit or 2-bit errors. To ensure this
does not happen, software design should take care of the following points."

To be sure...so in the end, if an unaligned write access by the M4 occured, reading of this same address later generates an 1-bit or 2-bit error event and the read value is corrupted. Is it right?
I assume in case of 2-bit error the value should be correct, cause of no wrong correction?

I know, there are some complex workarounds for M4 and DSP in case of cached or non-cached variants. In case of EVE the solution to handle the ECC restriction is in software possible, only. And devices like DSS or EDMA have to follow the restriction of 32bit alignement accesses.

Is it realy a good idea to check and modify the whole software to avoid unaligned write accesses? What about SYS/BIOS? Is it prepared for this ECC restriction?

I think it is more likely that an unaligned access remains undetected, than an ECC error happens. So another solution would be to use DDR3 with integrated ECC functionality.

What do you thing about it?

Best regards,
Milan

  • Hi Milan,

    Unfortunately this is a HW limitation with sub quanta writes not allowed.

    However you can enable cache on M4 and make it write back write allocate.

    With this there will be no sub quanta writes and ECC will work fine.

    Regards,

    Rishabh

  • Hi Rishabh,

    thank you for your fast reply.

    Regarding to the application note, with enabled cache on M4 it is not so clear that ECC will work fine.

    2.5.1.3 Cached CPU Accesses to EMIF
    For cached CPU access to EMIF, the accesses are typically cache line aligned. Hence, the restriction of
    RMW is not applicable. However, the cache used must be “write-back, write-allocate”. Non “write-allocate”
    caches might generate non-quanta aligned write accesses. Besides this, there are few more points that
    need to be considered for the following CPUs.
    • M4
    Cortex M4 has a write allocate cache. Hence one can set cache policy to "Write back, Write Allocate"
    in order to prevent sub quanta accesses to the memory. However this is not true during cache
    maintenance operations:
    – In IPU system, an access can result in a cache miss while maintenance operation is going on. This
    can happen with either single core or both cores running. In such cases:
    • Cache Read Miss will not Allocate
    • Cache Write Miss will be write-through No-Allocate
    – Hence, unaligned writes go through to DDR memory when a cache maintenance operation is
    ongoing and ECC error interrupts are generated.
    – This does not happen for normal cache eviction.
    – Cache maintenance operations are: Write back, pre fetch, invalidate, lock and unlock
    Below software workarounds can be used to mitigate this:
    – This workaround is applicable to systems where both cores of dual core IPU subsystem are used.
    The idea is to stop the other core from doing anything when the first core calls cache maintenance
    API. Modify the cache wrapper APIs to follow the below sequence:
    • Disable_task_scheduling
    • Take_spinlock
    • Disable_interrupts
    • Stop_other_core
    • Do cache maintenance
    • Start_other_core
    • Restore_interrupts
    • Release_spinlock
    • Restore_task_scheduling
    Note that one CPU will have to be idle when the other is doing cache maintenance.

    2.5.1.4 Non CPU Access of EMIF Memory
    -->These restrictions are also very complex and riskfull and may not be respected in all situations.

    This is a realy hard workaround and what is meant by mitigate? This workaround should work 100% otherwise it is useless to use ECC.

    Please do you have answers to my primary questions, too?

    Best regards,
    Milan

  • Hi Milan,

    This workaround is applicable when cache maintenance operations are done.

    In your case you have not enabled enabled cache and hence this workaround is not needed.

    This workaround is 100%.

    EMIF ECC works for single bit error correction and double bit error detection.

    You will not need to modify SYSBIOS or any other software when cache is enabled.

    If I have missed any other question please post the question as a reply.

    Regards,

    Rishabh

  • Hi Rishabh,

    thank you for your answers.

    Our software use the cache on M4 and DSP side activated in the bootstrap.

    Here is a list of my questions:

    Q1)
    From my first message: To be sure...so in the end, if an unaligned write access by the M4 without cache enabled occured, reading of this same address later generates an 1-bit or 2-bit error event and the read value is corrupted. Is it right?
    I assume in case of 2-bit error the read value should be correct, cause of no possibility of correction?

    Q2)
    Is it realy a good idea to check and modify the whole software on all cores to avoid unaligned write accesses? I think it is more likely that an unaligned access remains undetected, than an ECC error happens. So another solution would be to use DDR3 with integrated ECC functionality. What do you thing about it?

    Q3)
    What about SYS/BIOS? Is it prepared for all ECC restrictions on all cores with and without cache enabled (A15, M4, DSP, EVE)? I mean also the workaround in case of cache maintenance operations and the use of both M4 cores.

    Q4)
    For workaround for cache maintenance operations. What is meant by: "Below software workarounds can be used to mitigate this:". Mitigate is not 100%. And what about EVE and Sys/Bios?

    Best regards,
    Milan

  • Hi,

    Please find answers below:

    1. EMIF ECC generates error in three conditions:

    a. Single bit error: This is detected and value is corrected in DDR. Interrupt is generated upon reaching threshold value

    b. Two bit error: This is just detection when two bits flip. Interrupt is generated.

    c. Sub quanta access: In this case also interrupt is generated

    There is no option using which one can enable a subset of these conditions. In case the CPU does not handle these interrupts, hard fault will occur.

    Two bit error occurs when 2 bits get flipped in a 32 bit word. Hence value read will be wrong in this case.

    2. As I said previously in case the user enables write back and write allocate cache feature there is no need to change SW. Please note that this is true only in case of M4. You can refer to section 2.5 of App Note to see care about in case of other CPUs. It is up to customers to decide whether they want to go for DDR with integrated ECC depending upon their use case.

    3. SYSBIOS is not aware of ECC.

    4. Workaround is 100%. I will take this feedback and update this particular sentence in the app note.

    Regards,

    Rishabh

  • Hi,

    I haven't heard back from you, I'm assuming you were able to resolve your issue.
    If not, just post a reply below (or create a new thread if the thread has locked due to time-out).

    Regards,
    Rishabh