Using the Debug Mailbox with IAR tools

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using the Debug Mailbox with IAR tools

546 Views
Hoditohod
Contributor I

Hi,

I have an LPC55S69 based board and I would like to use the Debug MailBox commands with the IAR C-Spy debugger and I-jet probe. I've written a debugger macro that prints the MailBox ID register correctly, but nothing else seems to work. 
Reading back the command immediately returns 0, result register is always zero, and none of the requests is actually executed. Details below.

I'm not experienced with this, any pointer/suggestion is really appreciated!

Regards,
   Gyorgy

 

The part I'm using has the following markings (Rev 1B 2022 week 17, I assume):

LPC55S69
JEV98
WA44003
sSD22171B

The macro looks like this:

 

execUserPreload()
{
  // Called after communication with the target system is established but before
  // downloading the target application.
  if (__hasDAPRegs())
  {
    __message "Has DAP registers";
    __message "DPIDR:", __readDPReg(0x0):%x;

    __writeDPReg(0x020000F0, 0x08);
    __message "MailBox ID reg:", __readAPReg(0xFC):%x;

    // Resynch/reset
    __writeAPReg(0x21, 0x0);
    __message "SYNC readback: ",  __readAPReg(0x00):%x;
    __delay(500);
    __message "SYNC status: ",  __readAPReg(0x00):%x;

    // Mass erase
    __writeAPReg(0x03, 0x4);
    __message "ERASE readback: ",  __readAPReg(0x04):%x;
    __delay(500);
    __message "ERASE status: ",  __readAPReg(0x00):%x;
    __message "ERASE result: ",  __readAPReg(0x08):%x;

    // Enter ISP mode (2 words)
    __writeAPReg(0x00010005, 0x04);
    __message "ISP1 readback: ",  __readAPReg(0x04):%x;
    __delay(500);
    __message "ISP1 status: ",  __readAPReg(0x00):%x;
    __message "ISP1 result: ",  __readAPReg(0x08):%x;

    __writeAPReg(0xffffffff, 0x4);
    __message "ISP2 readback: ",  __readAPReg(0x04):%x;
    __delay(500);
    __message "ISP2 status: ",  __readAPReg(0x00):%x;
    __message "ISP2 result: ",  __readAPReg(0x08):%x;
  }
}

 

The output:

Has DAP registers
DPIDR:6ba02477
MailBox ID reg:2a0000
SYNC readback: 0
SYNC status: 0
ERASE readback: 0
ERASE status: 0
ERASE result: 0
ISP1 readback: 0
ISP1 status: 0
ISP1 result: 0
ISP2 readback: 0
ISP2 status: 0
ISP2 result: 0

 

 

 

Labels (1)
0 Kudos
Reply
1 Reply

511 Views
Harry_Zhang
NXP Employee
NXP Employee

Hi @Hoditohod 

You can try to reset the Debug Mailbox before issuing any commands. Ensure that the Debug Mailbox is not locked by the system.

       // Reset and synchronize
       __writeAPReg(0x21, 0x0); // SYNC
       __delay(500);
       while (__readAPReg(0x00) & 0x1) {
           __delay(10); // Wait for ready
       }
       __message "SYNC complete";

BR

Harry

0 Kudos
Reply