How to access the memory mapped debug registers?

Now that the funny PABT-behaviour is found to be (probably) caused ny debug state, I'd like to exit debug state before return from PABT exception. The ARM v7-A/R ARM says that I should write RRQ to DBGDRCR, but it seems that in Cortex-A7 it's not accessible via CP14.

It should be accessible via memory-mapped registers, and the manual gives the offset, but offset from what?

I understood that the register offset is the register number multiplied by four, so for DBGDRCR the offset would be 36*4 = 144 (0x90).

In the TRM it says:

Table 10-26 Address mapping for debug trace components

Address range Componenta

0x00000 - 0x00FFF ROM table

0x01000 - 0x0FFFF Reserved

0x10000 - 0x10FFF CPU 0 Debug

0x11000 - 0x11FFF CPU 0 PMU

0x12000 - 0x12FFF CPU 1 Debug

0x13000 - 0x13FFF CPU 1 PMU

0x14000 - 0x14FFF CPU 2 Debug

0x15000 - 0x15FFF CPU 2 PMU

0x16000 - 0x16FFF CPU 3 debug

Are these too offsets from somewhere, or absolute addresses?

Do I write to DBGDRCR by just writing the value into address 0x100090 (core 0, assuming not locked)?

Or do I need to calculate the register address from the contents of DBGDRAR?

And what's the ROM table?

Parents
  • Ah, figured out the debug register accesses. Still can't tell from the ROM table and ID registers, which component is the right one.

    (I know it's the first component, though.)

    And I still don't seem to be able to return from the BKPT (added some debug about the components, unlocked the registers and wrote the RRQ-bit to exit debug state).

    Not much better?

    PIDR is actually a word formed from the lowest bytes of PIDR 3-0.

    Finally! Got into main()

    DBGDRAR: 40020003 DBGDSAR: 40030003 DBGLSR: 00000003 DBGLSR2: 00000001

    comp: 00000000 : 00010003

    CIDR1: 00000090

    PIDR5: 00000004

    PIDR: 005bbc07

    comp: 00000001 : 00011003

    CIDR1: 00000090

    PIDR5: 00000004

    PIDR: 005bb9a7

    comp: 00000002 : 00012003

    CIDR1: 00000090

    PIDR5: 00000004

    PIDR: 005bbc07

    comp: 00000003 : 00013003

    CIDR1: 00000090

    PIDR5: 00000004

    PIDR: 005bb9a7

    comp: 00000004 : 00014003

    CIDR1: 00000090

    PIDR5: 00000004

    PIDR: 005bbc07

    comp: 00000005 : 00015003

    CIDR1: 00000090

    PIDR5: 00000004

    PIDR: 005bb9a7

    comp: 00000006 : 00016003

    CIDR1: 00000090

    PIDR5: 00000004

    PIDR: 005bbc07

    comp: 00000007 : 00017003

    CIDR1: 00000090

    PIDR5: 00000004

    PIDR: 005bb9a7

    comp: 00000008 : 00000000

    trying SVC

    SVC EXCEPTION

    exc_addr: 000003e8

    SPSR: 68000013

    returned from SVC

    trying BKPT1

    PABT EXCEPTION

    exc_addr: 000090d4

    SPSR: 60000013

    my_cpsr: 60000197

    dbgdscr: 0204000e

    IFSR: 00000002

    dbgdscr2: 0204000e

    i: 00000000returned

    UNDEFINED EXCEPTION

    exc_addr: 00900008

    SPSR: 600103d3

    Looks like it returned from PABT, but made an UNDEFINED exception right after, and the address is, to put it mildly, weird.

    The mode was, however, SVC again, before the UNDEFINED EXCEPTION, and it didn't restart.

    I haven't changed anything in the main below the first SVC. Added the component info dump before it, though.

    Before this "debug circus" I found out that adding 3 debug prints in the PABT handler made it return fine, but removing any of them, caused different weird return problems depending on which print I removed.

    I guess I'll try again with all this plus the debug prints.

    My head hurts...

    [EDIT]

    With the debug prints, it booted 3 times and jammed.

    This time the first time the exceptions were entered from SVC-mode (as expected), but the second time from FIQ (I don't have it in use) and the 3rd time from IRQ.

    IFSR was 2 => the cause was BKPT.

    [/EDIT]

    [EDIT2]

    Added some more debug, and seems like it's getting even more weird. The reboot seems to take place a more or less random time after returning from the PABT.

    Also after restart the mode seems to be about random.

    trying SVC

    SVC EXCEPTION

    exc_addr: 000003e8

    SPSR: 68000013

    returned from SVC

    trying BKPT1

    PABT EXCEPTION

    exc_addr: 000090f4

    SPSR: 60000013

    my_cpsr: 60000197

    dbgdscr: 0204000e

    IFSR: 00000002

    PABT done

    my_cpsr: 60000013

    returned from BKPT1

    Finally! Got into main()

    ...

    trying SVC

    SVC EXCEPTION

    exc_addr: 000003e8

    SPSR: 6800001f

    returned from SVC

    trying BKPT1

    PABT EXCEPTION

    exc_addr: 000090f4

    SPSR: 6000001f

    my_cpsr: 60000197

    dbgdscr: 0204000e

    IFSR: 00000002

    PABT done

    my_cpsr: 6000001f

    returned from BKPT1

    entering main

    and then nothing. The echoing doesn't work, and even the rest of the string is not printed (should be "entering main loop").

    [/EDIT2]

Reply
  • Ah, figured out the debug register accesses. Still can't tell from the ROM table and ID registers, which component is the right one.

    (I know it's the first component, though.)

    And I still don't seem to be able to return from the BKPT (added some debug about the components, unlocked the registers and wrote the RRQ-bit to exit debug state).

    Not much better?

    PIDR is actually a word formed from the lowest bytes of PIDR 3-0.

    Finally! Got into main()

    DBGDRAR: 40020003 DBGDSAR: 40030003 DBGLSR: 00000003 DBGLSR2: 00000001

    comp: 00000000 : 00010003

    CIDR1: 00000090

    PIDR5: 00000004

    PIDR: 005bbc07

    comp: 00000001 : 00011003

    CIDR1: 00000090

    PIDR5: 00000004

    PIDR: 005bb9a7

    comp: 00000002 : 00012003

    CIDR1: 00000090

    PIDR5: 00000004

    PIDR: 005bbc07

    comp: 00000003 : 00013003

    CIDR1: 00000090

    PIDR5: 00000004

    PIDR: 005bb9a7

    comp: 00000004 : 00014003

    CIDR1: 00000090

    PIDR5: 00000004

    PIDR: 005bbc07

    comp: 00000005 : 00015003

    CIDR1: 00000090

    PIDR5: 00000004

    PIDR: 005bb9a7

    comp: 00000006 : 00016003

    CIDR1: 00000090

    PIDR5: 00000004

    PIDR: 005bbc07

    comp: 00000007 : 00017003

    CIDR1: 00000090

    PIDR5: 00000004

    PIDR: 005bb9a7

    comp: 00000008 : 00000000

    trying SVC

    SVC EXCEPTION

    exc_addr: 000003e8

    SPSR: 68000013

    returned from SVC

    trying BKPT1

    PABT EXCEPTION

    exc_addr: 000090d4

    SPSR: 60000013

    my_cpsr: 60000197

    dbgdscr: 0204000e

    IFSR: 00000002

    dbgdscr2: 0204000e

    i: 00000000returned

    UNDEFINED EXCEPTION

    exc_addr: 00900008

    SPSR: 600103d3

    Looks like it returned from PABT, but made an UNDEFINED exception right after, and the address is, to put it mildly, weird.

    The mode was, however, SVC again, before the UNDEFINED EXCEPTION, and it didn't restart.

    I haven't changed anything in the main below the first SVC. Added the component info dump before it, though.

    Before this "debug circus" I found out that adding 3 debug prints in the PABT handler made it return fine, but removing any of them, caused different weird return problems depending on which print I removed.

    I guess I'll try again with all this plus the debug prints.

    My head hurts...

    [EDIT]

    With the debug prints, it booted 3 times and jammed.

    This time the first time the exceptions were entered from SVC-mode (as expected), but the second time from FIQ (I don't have it in use) and the 3rd time from IRQ.

    IFSR was 2 => the cause was BKPT.

    [/EDIT]

    [EDIT2]

    Added some more debug, and seems like it's getting even more weird. The reboot seems to take place a more or less random time after returning from the PABT.

    Also after restart the mode seems to be about random.

    trying SVC

    SVC EXCEPTION

    exc_addr: 000003e8

    SPSR: 68000013

    returned from SVC

    trying BKPT1

    PABT EXCEPTION

    exc_addr: 000090f4

    SPSR: 60000013

    my_cpsr: 60000197

    dbgdscr: 0204000e

    IFSR: 00000002

    PABT done

    my_cpsr: 60000013

    returned from BKPT1

    Finally! Got into main()

    ...

    trying SVC

    SVC EXCEPTION

    exc_addr: 000003e8

    SPSR: 6800001f

    returned from SVC

    trying BKPT1

    PABT EXCEPTION

    exc_addr: 000090f4

    SPSR: 6000001f

    my_cpsr: 60000197

    dbgdscr: 0204000e

    IFSR: 00000002

    PABT done

    my_cpsr: 6000001f

    returned from BKPT1

    entering main

    and then nothing. The echoing doesn't work, and even the rest of the string is not printed (should be "entering main loop").

    [/EDIT2]

Children
No data