Why exceptions are enabled before exception vector code is copied
Dear Wolfgang.
Can I ask you why exceptions are enabled before exception vector code is copied to the low RAM pages ? (I am talking about U-Boot/PPC)
On my board, U-Boot crashes before relocation (when debugging) since Xilinx Microprocessor Debugger (XMD) makes a spurious "Machine Check Exception". For other reasons, such an exception could arrived before u-boot starts.
Finally, it is a bug or a very strange coding behaviour...
Cedric VINCENT.
Quoted 3 lines · In message <[email protected]> you wrote:
Can I ask you why exceptions are enabled before exception vector code is copied to the low RAM pages ? (I am talking about U-Boot/PPC)
No exceptions are supposed to happen until then.
Quoted 4 lines
On my board, U-Boot crashes before relocation (when debugging) since Xilinx Microprocessor Debugger (XMD) makes a spurious "Machine Check Exception". For other reasons, such an exception could arrived before u-boot starts.
Well, then fix this problem. What do you suggest hoiw such a situation should be handled while running from flash?
Quoted 1 line
Finally, it is a bug or a very strange coding behaviour...
It does not happen on other systems.
Best regards,
Wolfgang Denk
Signature · 4 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de The universe does not have laws - it has habits, and habits can be broken.
Quoted 4 lines
No exceptions are supposed to happen until then.
What do you suggest hoiw such a situation should be handled while running from flash?
There is no reason to enable them before exception vector code is copied. So exceptions should be enabled *after* exception vector code is copied.
Quoted 1 line
It does not happen on other systems.
The spurious "Machine Check Excpetion" is well known on Virtex/PPC. Most Xilinx FPGA boards are affected (tested on Virtex-II Pro and Virtex 4).
regards, Cedric VINCENT.
Quoted 8 lines · In message <[email protected]> you wrote:
Quoted 4 lines
No exceptions are supposed to happen until then.
What do you suggest hoiw such a situation should be handled while running from flash?
There is no reason to enable them before exception vector code is copied. So exceptions should be enabled *after* exception vector code is copied.
Feel free to submit a patch.
But what would happen in your case of a Machine Check? What do you suggest to recover from that?
Best regards,
Wolfgang Denk
Signature · 4 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The optimum committee has no members.
- Norman AugustineQuoted 1 line
Feel free to submit a patch.
OK, maybe the next week.
Quoted 2 lines
But what would happen in your case of a Machine Check? What do you suggest to recover from that?
When this spurious "Machine Check Exception" occured, the MSR didn't contain any known causes. Maybe the function "MachineCheckException" (from cpu/ppc4xx/traps.c) may be modified with something like this :
---------
#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
if (debugger_exception_handler && (*debugger_exception_handler)(regs))
return;#endif
+ #if defined(CONFIG_USE_XMD)
+ if( SPURIOUS_MCE == (regs->msr & 0x000F0000) )
+ return;
+ #endif
printf("Machine check in kernel mode.\n");
printf("Caused by (from msr): ");
printf("regs %p ",regs);
switch( regs->msr & 0x000F0000) {---------
where CONFIG_USE_XMD is a macro (to use with care !) defined by user when he uses XMD (during debugging stage) and SPURIOUS_MCE is the MSR unknown cause.
This (ugly) stuff makes sense to enable exception after relocation. I didn't test this, since I disable Machine Check Exception when debugging my Virtex Board. Maybe it will not work (if this spurious exception occured more than once). I will try to test next week.
Regards,
Cedric VINCENT.
Here comes a patch to enable exceptions after exceptions vector code is copied (i.e after relocation). I tested it with my board (PPC 405), I also changed 440 and IOP480 target but without testing...
I run the MAKEALL script : there are no errors, warnings was not due to this patch.
CHANGELOG : * cpu/ppc4xx/start.S : exceptions are enabled after relocation.
About XMD, as I thought the spurious exception comes infinitely... So there is no easy way to fix it. If you apply this patch (this is an easy way to detect this spurious exception), you should add at the end of doc/README.ml300 :
========================
6. Warning
----------
It was reported that XMD makes (sometimes) a spurious "Machine Check Exception". When debugging, if you are sure that this exception doesn't come from your system,
comment this line into cpu/ppc4xx/start.S :
addi r7,r0,0x1000 /* set ME bit (Machine Exceptions) */
========================
Regards,
Cedric VINCENT
-------------- next part --------------
A non-text attachment was scrubbed...
Name: u-boot_exception.diff
Type: application/octet-stream
Size: 2467 bytes
Desc: not available
Url : http://lists.denx.de/pipermail/u-boot/attachments/20050706/1b1e86c7/attachment.obj
Quoted 9 lines · In message <[email protected]> you wrote:
Here comes a patch to enable exceptions after exceptions vector code is copied (i.e after relocation). I tested it with my board (PPC 405), I also changed 440 and IOP480 target but without testing...
I run the MAKEALL script : there are no errors, warnings was not due to this patch.
CHANGELOG : *
cpu/ppc4xx/start.S: exceptions are enabled after relocation.
Added, thanks.
Best regards,
Wolfgang Denk
Signature · 3 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Backed up the system lately?