LPC54114 ISP over SPI

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

LPC54114 ISP over SPI

1,959 Views
seku
Contributor I

Hi All,

How to verify the LPC54114 SPI ISP from the host. I am planning to imx8 as my host. 

- I've put my LPC54114 in ISP SPI mode by pressing ISP0 and ISP1. 

- Should I need to write a proper c programming to code to send the SPI ISP commands? 

or 

- Is there any utility like echo "0xA1" > /dev/spidev0.1 can be used? 

    - I tried to send echo 0xA1 and the response from LPC is always 0xFF

Please share the right procedure to verify the ISP over SPI. 

Thanks,

Senthil 

Labels (1)
0 Kudos
15 Replies

1,600 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Senthil,

 

The LPC will respond correctly to the host if the host is sending the appropriate commands to the LPC54114.

 

Please check image below for the process.

pastedImage_1.png

Also, please make sure that you are configuring the SPI correctly on the host side:

 

SPI Config:

   -Clock should not exceed 2 MHz.

   -SPI SSEL to first clock timing should not be less than 100 us.

   -SPI transfer configuration should be SPI Mode 0 with 8 data bits.

 

In addition I recommend you to read chapter 4.7 of the User Manual.

 

I hope this helps.

 

Best regards,

Felipe

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

1,600 Views
seku
Contributor I

Hi Felipe,

Thanks. 

I am using the spi utility on the imx8 side and setting the clock speed 2Mhz and mode = 0 and 8 bits, delay=100us. 

As a next step, I am going to probe in the imx8m side to make sure all are configured properly.

Can you please clarify how this was tested at your end ? 

Thanks,

Senthil

0 Kudos

1,600 Views
seku
Contributor I

Hi Felipe,

I've connected the probe and make sure that all SPI connections were good between imx8 and LPC. The clock is good (2MHZ), delay 100 and the data sending is '0xA1' to get the version information using my test application. 

root@imx8mmevk:/home# ./spi_test -D /dev/spidev1.0 -s 2000000 -d 100 -p 0xA1 -v

spi mode: 0x0
bits per word: 8
max speed: 2000000 Hz (2000 KHz)
TX | 30 78 41 31 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  |0xA1|
RX | FF FF FF FF __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  |....|
root@imx8mmevk:/home#

I've connected wire on the ISP1_IRQ1 and probed the signal, the line is always high after I sent the command packet - 0xA1.

As per the flow diagram, the ISP1_IRQ1 should go low. anything else am I missing ? 

Please share your inputs. 

Note : ISP0  & ISP1 were pressed to put the LPC in SPI ISP mode.

Thanks,

Senthil

0 Kudos

1,600 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Senthil,

 

Please accept my apologies for my late reply. Could you please try sending the probe command first? Please check UM chapter 4.8.5.

This command is required to select I2C or SPI interface when booting from a reset condition.

 

Please check flowchart below:

pastedImage_4.png

Hope it helps!

Best regards,

Felipe

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

1,600 Views
seku
Contributor I

Hi Felipe,

Thanks for the response. 

I've tried with the probe command this morning and am able to see the response from LPC. The ISP1_IRQ de-asserted. 

My script : 

----------------

#!/bin/sh
# Gpio pin for ISP_IRQ from LPC to IMX8M
echo 137 > /sys/class/gpio/export
echo "Sending 0xA5..."
./spi_test -D /dev/spidev1.0 -s 2000000 -d 100 -p "\xa5\x04\x00\x00\x00\x00\x00\xa1" -v
echo -n "ISP1_IRQ state:"
cat /sys/class/gpio/gpio137/value
echo -n "ISP1_IRQ state:"
cat /sys/class/gpio/gpio137/value

Script Output :

------------------

Sending 0xA5...
spi mode: 0x0
bits per word: 8
max speed: 2000000 Hz (2000 KHz)
TX | A5 04 00 00 00 00 00 A1 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  |........|
RX | 55 A5 00 00 00 00 00 00 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  |U.......|
ISP1_IRQ state:0
ISP1_IRQ state:0
root@imx8mmevk:/home# cat /sys/class/gpio/gpio137/value

Please clarify if I execute the next command for example - command - 0xA1". Will the ISP1_IRQ pin will stay low ? 

Thanks,

Senthil

0 Kudos

1,600 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Senthil,

 

Yes, the MCU will respond to the Host command by driving ISP1_IRQ low. Please have in mind the following note from the user manual.

 

Note: SPI transactions are bi-directional. During the command packet phase, the host

system should ignore the read data (send data from LPC5411x). During the response

phase, the LPC5411x will ignore the read data (send data from host).

 

Regards,

Felipe

0 Kudos

1,600 Views
seku
Contributor I

Hi Felipe,

I am able to get the response from LPC when I chose SPI in Probe command. 

Whenever I execute the flash related commands (page erase, sector erase and bulk erase), the response is 80 or 01.

Should I need to do anything special for flash commands? 

If I give the wrong sector number then LPC reports the error code as 0x7. 

Please share your inputs. 

root@imx8mmevk:/home# ./myspi

// Probe command 

Tx:A5 04 00 00 00 00 00 A1
Rx:00 00 00 00 00 00 00 00
Tx:A5 04 00 00 00 00 00 A1
Rx:55 A5 00 00 01 00 00 00

// Get version command 
Tx:A1 00 00 00 00 00 00 00
Rx:55 A1 02 00 80 01 00 00
Tx:A1 00 00 00 00 00 00 00
Rx:55 A1 02 00 80 01 00 00

// Flash Sector Erase command 
Tx:A8 00 00 00 00 00 00 00
Rx:80 80 80 80 80 80 80 80  // Weird output. 

Thanks,

Senthil

0 Kudos

1,600 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Senthil,

 

According to what you mentioned the error code the LPC returns is correct if you are not sending the correct sector the error 0x7 is INVALID SECTOR.

 

Please check below image from error.h file.

 

 pastedImage_2.png

By any chance, did you enable CRP?

 

Best regards,

Felipe

0 Kudos

1,600 Views
seku
Contributor I

No. When I set the ISP0 and ISP1 for USB boot mode. I could see that CRP DISABLED as a label in the windows machine. 

Hope the CRP disabled for SPI ISP mode also. Am I CORRECT?

How to set the CRP mode disabled? Any jumper settings?

0 Kudos

1,600 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Senthil,

 

CRP is invoked when you program an specific pattern in the flash image at offset 0x0000 02FC.

 

I recommend you to check chapter 4.3.6 of the User Manual.

 

Best regards,

Felipe

0 Kudos

1,600 Views
seku
Contributor I

Hi Felpie,

I programmed the hex file using SWD and the CRP is not enabled. 

#if !defined (CORE_M0PLUS)
#include <NXP/crp.h>
__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;
#endif

//**********

Attached the HEX file for reference. After that, I put the LPC in ISP SPI mode and sent the following command to erase the sector.

// Request command 

cmd[0] = 0xA8;
cmd[1] = 0x00;
cmd[2] = 0x00;
cmd[3] = 0x01;

ret = send_cmd(fd,cmd,4);

>>> My code output : 

[*] Enter the menu :2
[*] Erasing sector(s) command ...
[*] LPC Part Id : 0x36454113
[*] LPC Part : LPC54113J256
[*] Flash base : 0x00000000
[*] Flash size : 0x00040000
[*] Firmware file size : 14244
[*] Number of sector to be erased : 1
[*] Sending command (A8)
[*] Wait for response...
[*] Exporting gpio..
[*] ISP1_IRQ state : ACTIVE_LOW
[*] Response ready indication
[*] Response for command (A8) :55 A8 04 00 07 00 00 00
[*] Erasing sector 1 is not completed

I am not sure that when the CRP is disabled, the LPC always returning that invalid sector number. I am trying to erase the sector 1 from 0x8000 .

What is the right format to send the erase sector command? 

Thanks,

Senthil

my hex file output. 

pastedImage_1.png

0 Kudos

1,600 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi,

 

Sorry for the late response.

 

Is this error happening only in sector 1? Are you able to send a different command than erase sector?

 

Regards,

Felipe

0 Kudos

1,600 Views
seku
Contributor I

Hi Felipe,

Yes. The probe and get version commands were working fine with the proper response. 

I tried for only sector 1. I can try other sectors. 

Can you confirm whether the command format is correct ?

Thanks,

Senthil

0 Kudos

1,600 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Senthil,

The command seems correct. I am wondering if there is an issue with the flash.

Regards,

Felipe

0 Kudos

1,600 Views
seku
Contributor I

I passed sector 2. I've received invalid sector for sector 2 as well.

0 Kudos