LPC1769 with SWD Interface

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

LPC1769 with SWD Interface

2,638 Views
pds_mateus
Contributor I

Hello, NXP Community!

We are developing a microcontroller recorder with SWD Interface, which is already implemented and it already records some micros, they are: ARM STM32F107, ARM ATMEL SAMD10, SAMD20 and SAM4E. The next microcontroller we are trying to record is the LPC1769, but there are some difficulties. We have already studied the document UM10360 LPC176x / 5x User manual Rev. 3.1 - 2 April 2014 and in it no we find a lot of useful information to assist in recording the microcontroller using the SWD.

Since the SWD interface is already implemented, we were able to perform the JTAG-to-SWD reset, read the IDCode and set the CDBGPWRUPREQ and CSYSPWRUPREQ registers, but we do not have the write and read register addresses for recording the LPC, which can be accessed via SWD through the TAR register and manipulated by the DRW.
Is there any documentation to help us with this task?

Mateus José Barbosa

Software Developer
PD Solutions in Technology, Brazil

Labels (1)
Tags (2)
0 Kudos
11 Replies

1,979 Views
pds_mateus
Contributor I

Hello,

Right! What would an application like that look like?
Could you provide an example of an application to reside in RAM?
How can we load this application into RAM, configure the stack pointer and PC and then run via SWD?

Thank you.

0 Kudos

1,979 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Mateus José Barbosa,
Just like Con Verse mentioned, the LPC series MCU hasn't provided the register level access to the internal flash, I hope this is clear.
NXP doesn't provide some application note which guides you to access the flash via the SWD interface.
So I'd like to suggest you capture the waves of SWDIO and SWDCLK pins by the oscilloscope or logic analyzer when erasing or programming the LPC1769 in the J-Flash lite, these waves definitely follow the SWD protocol and you can find the process of erasing or program via analyzing them.

pastedImage_1.png


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,979 Views
pds_mateus
Contributor I

First of all, thank you for the quick response.
Let's use as an example the programming that we perform in the microcontroller of Atmel, the SAM4E.
We use the following SAM4E document as a reference:

http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-11157-32-bit-Cortex-M4-Microcontroller-SAM4E16...


We use the following document (chapter "Debug Access Port") as a reference for SWD (ARM):
http://infocenter.arm.com/help/topic/com.arm.doc.ddi0314h/DDI0314H_coresight_components_trm.pdf

Following is the process that we followed to erase the SAM4E memory:
- We write the value 0x400E0A04 (address of the SAM4E register that has the bit that enables Erase all) in the SWD TAR register.
- Then we write in SWD DRW register the value 0x5A000005 (value to enable Erase all)

Following is the procedure we followed to perform memory programming:
- We write in the TAR register of SWD the value of the Flash address where we want to save the data. In this case, the starting address is 0x00400000.
- Then we write in SWD register DRW the value of the data contained in the .hex.
- After writing the address and the data of 512 bytes, we send the command to programming, as described below:
- Write the value 0x400E0A04 (address of the SAM4E register that has the bit that enables writing to the SAM4E flash memory) in the SWD TAR register.
- Then we write in SWD DRW register the value 0x5A000001 (value to enable write to flash memory of SAM4E)
- In this way, we continue until the end of the .hex.

We also perform the programming of SAMD10, SAMD20 and STM32F107 ARMs.

We need an LPC1769 document that explains how we can manipulate its flash memory by showing us the addresses of the registers and the values that these registers must take so that we can access the address of these registers through the TAR and write or read the data, using the DRW register.

0 Kudos

1,979 Views
converse
Senior Contributor V

NXP do NOT provide register level access to their flash. the ONLY way to erase and program the flash is by executing code on the device. This is true for all NXP LPC devices.

You can do this in a couple of ways:

1. write small application that resides in RAM, download (through SWD) the code into RAM, setup the stack pointer and the PC, and execute the code. The application will make the correct IAP alls to Erase, Prepare and Program the flash or

2. setup the PC, stack and stack pointer and call each of the IAP routines individually.

Most (if not all) debugger vendors use method 1.

0 Kudos

1,979 Views
pds_mateus
Contributor I

We understand how we should program Flash from LPC, but we do not know how to do this using SWD, as we are developing a generic programming, and the LPC is one of the microcontrollers to be programmed. The microcontroller that we are using to develop this programming is the Freescale K82.

0 Kudos

1,979 Views
converse
Senior Contributor V

It’s hard tohelp, as I don’t know what you don’t know! Perhaps you can explain in detail what you are trying to do, and what you have been able to do on other Cortex-M mcus.

0 Kudos

1,979 Views
pds_mateus
Contributor I

Hello,

Sorry for the long interval between messages as we were testing before sending this message.

In the LPC Manual it is described very well on the IAP commands, however it is done based on that it will be used in a micro programming of the LPC. In our case we need to access these commands in the LPC ROM from addresses and values for the TAR and DRW registers, respectively, in the SWD Interface. How would we access the IAP commands through the SWD Interface using DRW and TAR (they are the only registers we can access via SWD).

Thank you.

0 Kudos

1,979 Views
converse
Senior Contributor V

The only way to program the flash on LPC parts, is to call the IAP commands in ROM. This is what the debugger does with its 'flash drivers' - the flash driver is downloaded to RAM and executed to program the flash

0 Kudos

1,979 Views
pds_mateus
Contributor I

Hello,
We need a document that provides addresses for write and read operations via SWD, in order to write the LPC1769 via SWD. For example, to erase the memory of the ARM STM32F107 we access the address 0x4002 2010, which can be found on page 7 in the document.

Thank you!

0 Kudos

1,979 Views
converse
Senior Contributor V

Anything that is generic Cortex-M3 will be the same regardless of which vendor supplies the chip. But things that are vendor specific will, of course, be different, such as flash programming.

The flash LPC1700 parts can ONLY be programmed (erased or written) by executing code in the ROM of the part. This is fully described in the IAP section of the User Manual. Just to be clear, you cannot erase flash by writing to a ‘special register’.

0 Kudos

1,979 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Mateus José Barbosa,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
I'm not very clear the document you want,  I was wondering if you can share an example of it.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos