Enable Monitor Mode on Arm Cortex M4 | Execution of breakpoint instrcution CPU halts

Gast #4557850
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
Gast #4557868
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

Antwort schreiben

Eine eigene Frage? Dieser Thread ist über 10 Jahre alt. Stell sie in einem eigenen Thread – dort lesen mehr Leute mit, und sie wird öfter und schneller beantwortet.

Neuen Thread starten

Eine Lösung, Ergänzung oder Rückmeldung zu diesem Thread? Dann antworte hier.

Formatierung
  • [c]C-Code[/c]
  • [code]Code in anderen Sprachen, ASCII-Zeichnungen[/code]
  • [math]Formel in LaTeX-Syntax[/math]
  • [[Titel]] – Link zu einem Artikel
  • Verweis auf einen anderen Beitrag: Rechtsklick auf dessen Beitrags-ID (#8078628), „Adresse kopieren“, in den Text einfügen

Mehr zur Formatierung

Längeren Sourcecode als Anhang, nicht in den Text. JPG nur für Fotos und Scans; Zeichnungen und Screenshots als PNG oder GIF. Siehe Bildformate.

Schon registriert? Anmelden

Wird nicht angezeigt. Wir schicken dir einen Link; sobald du damit bestätigst, erscheint dein Beitrag.

Mit dem Abschicken legst du einen kostenlosen Account an und erkennst die Nutzungsbedingungen und die Datenschutzerklärung an.