I'm using freeRTOS for a quick test. I'm going to use the functionality
of "EXCEPTION_HANDLERS" on Microblaze CPU.
I created the MicroBlaze CPU with these settings for "exceptions":
PARAMETER CMAXIIBUSEXCEPTION = 1
PARAMETER CMAXIDBUSEXCEPTION = 1
PARAMETER CILLOPCODEEXCEPTION = 1
PARAMETER COPCODE0x0ILLEGAL = 1
PARAMETER CUSESTACKPROTECTION = 1
PARAMETER CUNALIGNEDEXCEPTIONS = 1
PARAMETER CPVR = 2
I compiled the BSP in Eclipse activating exceptions:
PARAMETER MICROBLAZE_EXCEPTIONS = true
In "FreeRTOSConfig.h" I have activate installation of exception handling:
define configINSTALLEXCEPTIONHANDLERS 1
The compilation is successful.
The system works, I blink two LEDs with two separate tasks, using a
third task where the serial run I try to start a routine that triggers
typedef void (*crashinstructions_t) (void);
crashinstructions = 0;
crashinstructions = 1;
crashinstructions = 2;
crashinstructions = 3;
crashinstructionsp = (crashinstructionst) crashinstructions;
I put a breakpoint at 0x20 "vectorhwexception" and one on the
Once I triggered the exception I have the first break at 0x20
"vectorhwexception", but once again given the "run" the
"VPortExceptionHandle" function is never called, and debugging ends.
Performing "vectorhwexception" step by step, I notice that the execution
is always crashes here:
ori r6, r0, 7;
cmp r6, r5, r6;
bgti r6, handleotherex_tail;
ori r5, r0, 0x7;
PUSHREG(7); <<<<< block on this instruction
I had a look to the example supplied with freeRTOS: "MicroBlazeKintex7EthernetLite"
but not well-known differences, excluding exception of FP and DIV.
What could it be ?
I'm afraid this is a little detailed as the device is so configurable,
so my comments here are suggestions to look for, rather than absolutes.
The instruction you say is causing the issue is pushing a register so:
If a separate exception stack is being used (can't recall without
digging out the hardware manual), is the stack defined and set up correctly?
If certain stack alignment is required, could it be that the alignment
is not being maintained, and the exception is itself causing an exception?
I followed the hardware configuration proposed in freeRTOS package v9.0.0 for inquiries concerning the "MicroBlaze".
However I tried to compile the software in "Release" mode, start "Run" and the exception is now being captured.
Task Name: Uart
Registers that were stacked prior to this function being called:
R15: 0x8006E1B8 (return address from subroutine)
The value of all other registers:
R2: 0x8008A9C0 (small data area)
R13: 0x8008E730 (read write small data area)
R14: 0x8003FA80 (return address from interrupt)
R16: 0xA5A5A5A5 (return address from trap)
R17: 0x82084418 (return address from exceptions)
R1: 0x820843F8 (stack pointer)
Exception cause: XEXCIDILLEGAL_OPCODE
I still can not perform the "Debug" using the same program.
I'll do some more testing.
Thanks very much.
The return address is being set to 0xa5a5a5a5, which is the value the stack is filled with when the task is created. So it appears the program counter was loaded with a value from the stack when the stack was corrupt.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.