We are filling up RAM with predefined value (0xDF) after RAM initialization in startup. But as we enable the SVC interrupt for illegal opcode, it gives hard fault interrupt and even if we do not fill up RAM with 0xDF, it gives exception.
Is there any way/sequence to initialize RAM for illegal opcode? How do we debug this issue?
Sorry for the late response. If I understood correctly, the hard fault occurs once you install and initialize the SVC interrupt, correct? Where are you calling the function INT_SYS_InstallHandler? Please keep in mind that before calling this function, the RAM memory should be initialized, did you considered this?
I recommend you to take a look at the following community document where one of my coworkers explains how to fill the unused memory.
Hope it helps!
The function INT_SYS_InstallHandler is called in main function after startup.
How do we ensure that RAM memory initialized properly?
I am unable to access community document.
This is a quick post about an interesting thread shared on Kinetis community, this is also applicable for S32DS + S32K1xx, following the below steps, we can fill up the unused memory with any command/data we want. On the other hand, ARM devices have the opcode feature to generate an SVC_Handler (0xDFDF ). So, if R13 goes to an unexpected address and this random address has 0xDFDF there, the CPU will jump to this SVC function. When using this feature we could avoid errors in case the CPU goes to blank memory space.
2.1 . No fill() command involed.
Define segment in MEMORY section:
2.2 Use FILL(0xaa) command to fill unused area of my_section with 0xAA.
We have issue with SVC interrupt for illegal opcode. As we enable the SVC interrupt for illegal opcode, it gives a hard fault interrupt (Microcontroller S32K142).
Earlier you replied " Where are you calling the function INT_SYS_InstallHandler? Please keep in mind that before calling this function, the RAM memory should be initialized"
How do we verify that RAM is initialized properly.
Sorry for the misunderstood, I didn't notice that you are using the function: INT_SYS_EnableIRQ(SVCall_IRQn); This is what is causing the problem. This function should be called only for the device-specific interrupts, not for the core interrupts (like the SVC).
In the case of the SVC interrupt you need to call only the function INT_SYS_InstallHandler(SVCall_IRQn, SVC_Handler, (isr_t *)0); The name of the new handler must be the same as the one you assign on the startup, in this case, SVC_Handler.
The example that I mentioned before, can be used for any memory. You just need to define the origin of where you want to start and the length in the variable my_section.
I'm not sure that I understood correctly your question. Do you want to trigger the SVC interrupt? If so, unfortunately, we don't have an example that shows how to trigger this interrupt, but you could try to write directly to the following register
you should use assemlly instruction "svc" to trigger the SVC exception.
information quoted from ARMv7-M Architecture Reference Manual ( DDI 0403E.d (ID070218) ):
An exception caused explicitly by the SVC instruction. Application software uses the SVC instruction
to make a call to an underlying operating system. This is called a Supervisor Call. The SVC
instruction enables the application to issue a Supervisor Call that requires privileged access to the
system and executes in program order with respect to the application. ARMv7-M also supports an
interrupt-driven Supervisor-calling mechanism, PendSV.
This Supervisor Call handles the exception caused by the SVC instruction. SVCall is permanently
enabled and has a configurable priority