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.
Hello,
I'm seeing a Group3 Channel 3 ESM error during initialization (address 0xFFFFF520 has a value of 0x00000008) . I've noticed a few patterns:
* It only happens during a hard reset (turning the PSU off/on). Once I clear the flag, it doesn't seem to be triggered by a Debugger reset.
* It only happens when the binary was compiled/linked with arm-none-eabi-gcc. If I switch the HALCoGen layer to TI and compile with CCS, this does not happen.
* If I clear the flag at the beginning of _c_int00() with esmREG->SR1[2] = 0xFFFFFFFF; the MCU will run as expected with no observable issues.
I've dug through the disassembly and stepped through initialization instruction by instruction and I'm not seeing a functional difference between the TI and GCC generated instructions before the ESM Group3 self test. I haven't been able to identify a root cause.
Does the binary I'm flashing need to adhere to certain requirements before code starts to execute? Can you clarify what gcc flags I should be using? I'm wondering if this is a linking issue.
If not, any debugging tips?
Thanks,
Brad
Hi Sunil,
I've identified the root cause, and have new questions. How I got here is a long story so I'll skip to the end.
When I changed the HALCoGen layer's toolchain from TI to GCC, HALCoGen changed the function declaration of getResetSource() as follows:
-resetSource_t getResetSource(void); +resetSource_t getResetSource(void) __attribute__((naked));
As a result, GCC ignored the function's return statement. When the Program Counter reached the end of the function, there were no BX LR instructions to return to _c_int00(). The Program Counter would just continue on to run through the next function in HL_system.c, which is systemGetConfigValue(). This function is never called anywhere in code, it should be functionally dead code. Once the Program Counter reached the end of that function, it would finally return to _c_int00(). In hindsight, the ECC uncorrectable error seems appropriate.
Can you clarify why this attribute was added for GCC? Does it address a concern that could be addressed some other way? The only other place the naked attribute was added during the toolchain conversion is _c_int00().
Thanks,
Brad
Thanks Sunil, I appreciate it.
In case I wasn't clear in my last post; when I delete that attribute the function does return as expected and the ECC error no longer expresses itself.
I did some research and found this:
"This attribute allows the compiler to construct the requisite function declaration, while allowing the body of the function to be assembly code. The specified function will not have prologue/epilogue sequences generated by the compiler. Only basic asm statements can safely be included in naked functions (see Basic Asm). While using extended asm or a mixture of basic asm and C code may appear to work, they cannot be depended upon to work reliably and are not supported."
The key phrase in that section is "will not have prologue/epilogue sequences." GCC appears to be behaving correctly given that attribute in the declaration. It's also worth noting that the function only contains C code, which the GCC documentation says is not safe when that attribute is used.
Best,
Brad