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.

Enabling flash ECC causes prefetch abort excpetion

Other Parts Discussed in Thread: HALCOGEN, NOWECC

Hello, I am using HALcogen to generate my code, but whenever I  use _coreEnableFlashEcc_() function provided by HALcogen it causes a prefetch exception.

Here is the coded provided by HALcogen:

_coreEnableFlashEcc_

        stmfd sp!, {r0}
        mrc   p15, #0x00, r0,         c1, c0,  #0x01
        orr   r0,  r0,    #0x02000000
        dmb
        mcr   p15, #0x00, r0,         c1, c0,  #0x01
        ldmfd sp!, {r0}        
        bx    lr

    .endasmfunc

the instructions up to ldmfd are doing their job properly.

When this instruction is executed in THIS function, it causes a prefecth abort exception, even though all other functions that use the same mechanism don't cause it.

Any ideas aso to why this is happening?

EDIT:

Everything works fine when I remove it by generating a new code with HALcogen.

EDIT2:

If I remove the internal code that is enabling the flash ECC, ATCMPCEN bit, it works fine, excepth for the code that checks the fucntionality for flash ECC, as excepted.

EDIT3:

I just finished installing CCS5.4, using compiler version TI 5.0.4, instead of TI 5.1.1 and noticed that it worked perfectly. Suggestions as to why it isn't working?

  • Hello,

    It seems like you do not have the correct ECC programmed for the contents of the flash memory.

    The Error Correction Codes (ECC) need to be programmed along with the actual program (and constants) when you actually program the flash memory. This is done automatically by default in the newer versions of the CodeGen tools (linker-generated ECC). In this case the linker appends the ECC section to the out file itself.

    Also, CCS versions 5.4 (and later) include a feature to automatically generate and program ECC codes whenever you program the flash memory. In this case you do not need to enable the linker-generated ECC.

    Either of the above methods would work in programming the correct ECC for the contents of the main flash memory.

    Regards, Sunil

  • Ok.

    So I enabled "Auto ECC generation" in flash settings. This should append the ECC to the .out file?

    When I try to debug now it says: "Load program error ... Encountered problem loading file. Could not open file".

    Any idea how to resolve this? After you told me this I went after the information on how to enable ECC in CCS 5.5. And, according to what I read, I would have to open the .out file with nowECC and only after that I would be able to load the file with ECC and all. I really don't want to do this every time I need to debug, so is there a way to fix this?

  • Pablo,

    I think you need to force 64-bit alignment for each section in the linker command file by using the palign(8) directive. An example is shown in this forum thread. Please try this and let me know.

    Regards, Sunil

  • I didn't need to do that. After getting the same problem about the .out file I went to check the project properties and noticed that all the configurations were lost.


    After that I just reset all changes to a previous commit and tried again. Got a few problems with the runtime library, but after fixing them everything started working. Thank you very much for your help.