Forum: Mikrocontroller und Digitale Elektronik Enable Monitor Mode on Arm Cortex M4 | Execution of breakpoint instrcution CPU halts


von benstar (Gast)


Lesenswert?

Hi,
I am working in a monitor for MK64f12 an ARM Cortex M4.

I have followed the tips in your tutorial to develop my monitor using a 
serial interface. The problem I cannot enable the Monitor Debug Mode and 
the exception is not handled.

I am using J-Link to load the monitor and debug.

My monitor is able to load an application to RAM and _Read and Write 
memory. Set software breakpoint is working.

The problem is when the breakpoint instruction is executed the CPU 
halts. It should not halt but execute the Monitor Exception.

Here is a description of my settings:

1- Vector Table:

_vectors:
    .long   0x20000000                  /* Top of Stack 
*/
    .long   ResetHandler                /* Reset Handler 
*/
    .long   ResetHandler                /* NMI Handler 
*/
    .long   myHandler                   /* Hard Fault Handler 
*/
    .long   AbortEntry                  /* MPU Fault Handler 
*/
    .long   AbortEntry                  /* Bus Fault Handler 
*/
    .long   AbortEntry                  /* Usage Fault Handler 
*/
    .long   0                           /* Reserved 
*/
    .long   0                           /* Reserved 
*/
    .long   0                           /* Reserved 
*/
    .long   0                           /* Reserved 
*/
    .long   IsrDefault                  /* SVCall Handler 
*/
    .long   BreakEntry                  /* Debug Monitor Handler 
*/
    .long   IsrDefault                  /* Reserved 
*/
    .long   IsrDefault                  /* PendSV Handler 
*/
    .long   IsrDefault                  /* SysTick Handler 
*/
................... b _IntCtrlInit ...................

2- Copy the vector table from ROM to RAM Copy to the physical start 
address of the RAM (0x1FFF0000).

3- Enable the Monitor Debug Mode _IntCtrlInit is called from the stratup 
code

void _IntCtrlInit(void)
{
   //* disable HALT Debug mode; enable DEBUG Monitor exception */
    DHCSR_Write = DBGKEY;  //Debug key should be written to be able to 
write this register
     //DHCSR_Write &= C_DEBUGEN;
    DEMCR = MON_EN ; // Enable Monitor mode
   // Enable FPB unit
     FP_CTRL = 3;
}
4- My Application is buit for RAM with monitor (Monitor variant)

5- The Monitor is loaded using the J-TAG

6- The monitor is initialized and I use t R232

7- Software breakpoint are set in the right position.

8- The breakpoint is hit, I got in Eclipse:

Program received signal SIGTRAP, Trace/breakpoint trap.
0x1fff1618 in ?? ()
9- I also tried without the J-TAG but resetting the board and 
disconnecting the J-Link. I add my breakpoint in the application code 
after some output (in RootTask function for example). The program 
execution stops at the desired place but I do not enter the Monitor 
Exception, and CPU halts.

The problem is the MonitorHandler (BreakEntry) is never reached. The CPU 
seems to halt which is not desired. As I enable the Monitor Debug Mode, 
this should be reached.

I want to reach the BreakEntry (Monitor Exception handler). Do you have 
an idea?

Best tegards

von benstar (Gast)


Lesenswert?

Hi,
I am working in a monitor for MK64f12 an ARM Cortex M4.

I have followed the tips in your tutorial to develop my monitor using a 
serial interface. The problem I cannot enable the Monitor Debug Mode and 
the exception is not handled.

I am using J-Link to load the monitor and debug.

My monitor is able to load an application to RAM and _Read and Write 
memory. Set software breakpoint is working.

The problem is when the breakpoint instruction is executed the CPU 
halts. It should not halt but execute the Monitor Exception.

Here is a description of my settings:

1- Vector Table:
1
_vectors:
2
    .long   0x20000000                  /* Top of Stack                 */
3
    .long   ResetHandler                /* Reset Handler                */
4
    .long   ResetHandler                /* NMI Handler                  */
5
    .long   myHandler                   /* Hard Fault Handler           */
6
    .long   AbortEntry                  /* MPU Fault Handler            */
7
    .long   AbortEntry                  /* Bus Fault Handler            */
8
    .long   AbortEntry                  /* Usage Fault Handler          */
9
    .long   0                           /* Reserved                     */
10
    .long   0                           /* Reserved                     */
11
    .long   0                           /* Reserved                     */
12
    .long   0                           /* Reserved                     */
13
    .long   IsrDefault                  /* SVCall Handler               */
14
    .long   BreakEntry                  /* Debug Monitor Handler        */
15
    .long   IsrDefault                  /* Reserved                     */
16
    .long   IsrDefault                  /* PendSV Handler               */
17
    .long   IsrDefault                  /* SysTick Handler              */
18
................... b _IntCtrlInit ...................
2- Copy the vector table from ROM to RAM Copy to the physical start 
address of the RAM (0x1FFF0000).

3- Enable the Monitor Debug Mode _IntCtrlInit is called from the stratup 
code
1
void _IntCtrlInit(void)
2
{
3
   //* disable HALT Debug mode; enable DEBUG Monitor exception */
4
    DHCSR_Write = DBGKEY;  //Debug key should be written to be able to write this register
5
     //DHCSR_Write &= C_DEBUGEN;
6
    DEMCR = MON_EN ; // Enable Monitor mode
7
   // Enable FPB unit
8
     FP_CTRL = 3;
9
}
4- My Application is buit for RAM with monitor (Monitor variant)

5- The Monitor is loaded using the J-TAG

6- The monitor is initialized and I use t R232

7- Software breakpoint are set in the right position.

8- The breakpoint is hit, I got in Eclipse:
1
Program received signal SIGTRAP, Trace/breakpoint trap.
2
0x1fff1618 in ?? ()
9- I also tried without the J-TAG but resetting the board and 
disconnecting the J-Link. I add my breakpoint in the application code 
after some output (in RootTask function for example). The program 
execution stops at the desired place but I do not enter the Monitor 
Exception, and CPU halts.

The problem is the MonitorHandler (BreakEntry) is never reached. The CPU 
seems to halt which is not desired. As I enable the Monitor Debug Mode, 
this should be reached.

I want to reach the BreakEntry (Monitor Exception handler). Do you have 
an idea?

Best tegards

von Rufus Τ. F. (rufus) Benutzerseite


Lesenswert?

Once is enough.

This forum's prefererred language is german.

If you're unabled to communicate in german, you might use this forum's 
english sibling - embdev.net.

von Stephen Tigher (Gast)


Lesenswert?

Könnte jemand bitte einen Link auf die in der Zeit nach der OP genannten 
Tutorial zur Verfügung stellen . Vielen Dank!

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.