cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
emacann
Visitor
Visitor
1,097 Views
Registered: ‎09-14-2017

Microblaze break_handler attribute

Hi,

I am working on a design with a Microblaze core that utilizes hardware breaks.
I am having troubles implementing the break handler in C.


From the documentation (UG984):
The break handler code must be defined with attribute break_handler to ensure that the compiler will generate code to save and restore used registers and emit an rtbd instruction to return from the handler:

void function_name() __attribute__((break_handler));

So I wrote this piece of code:

// includes, defines, ...

void _break_handler() __attribute__((break_handler));

int main () {
  // some initialization instructions

  // test break handler
  asm volatile ("brki r16 0x18");

  // other instructions
}

void _break_handler() {
  asm volatile ("suspend");
}

The microblaze is configured without a MMU (C_USE_MMU = 0) and with base vectors located at 0x00000000 (C_BASE_VECTORS = 0x00000000).


By simulating, I can tell that all the initialization instructions and the brki instruction are actually executed (the simulation shows a jump to address 0x00000018).

After that, instead of executing the suspend instruction (as expected), a branch to an infinite loop is taken.

Thanks,

Emanuele

0 Kudos
Reply
5 Replies
stephenm
Moderator
Moderator
1,033 Views
Registered: ‎09-12-2007

For break_handler, users need to manually add the break vector in the linker script, as this is not automatically done by the linker generator

 

for example:

 

.section .vectors.break, “ax”

.align 2

_vector_break:

      brai  _break_handler

0 Kudos
Reply
Hrishikesh
Contributor
Contributor
288 Views
Registered: ‎09-26-2020

Hello,

I am testing TMR Microblaze system, the functional faults are been getting injected but the program is not enetering the break handler. I have included break handler vector at 0x18 in linker script and also included it in crt0.s startup file. I have also made RIR bit = 1 in TMR Manager CR. May I know am I missing something if not why the program is not enetering the break handler.

0 Kudos
Reply
Hrishikesh
Contributor
Contributor
281 Views
Registered: ‎09-26-2020

Even after following all the steps the break_handler is being placed at 0x14 and interrupt handler is missing. How can this issue be solved ?

1.png
0 Kudos
Reply
timrprobocom
Visitor
Visitor
198 Views
Registered: ‎12-23-2020

Your linker script must not be right.  The vector at 0x10 is pointing to mb_break_handler; did you change the name to that, instead of _break_handler?

Show us the linker script.

0 Kudos
Reply
Hrishikesh
Contributor
Contributor
185 Views
Registered: ‎09-26-2020

The issue got solved it was not a problem with linker script. We must not take startup files from default location, instead we must include startup files in the project sources.