Introduction
The secure firmware download example "DownloadLibEx1" from LPC55S16 Host Software demonstrates how the user can update the PN7642 NXP secure firmware via the Host Interface. This post describes how to enable the download via UART.
Resources needed to follow this guide
Hardware Connections
On the PN7642 there are various shifters and multiplexers in between the host and the
actual PN7642 inputs. In order to bypass them quickly, we will interconnect the boards as follows.
UART Tx and Rx:
Locate J68 on the PNEV7642A board. These 4 jumpers are the host interface connectors
(ATX_A, ATX_B, ATX_C, ATX_D). Take the jumpers off as we are going to directly connect to this pin-header.

| LPC55S16-EVK |
|
PNEV7642A Eval Board |
| Pin |
Signal (LPC) |
|
Pin |
Signal (PNEV) |
| J12-14 |
UART Tx |
→ |
J68-2 |
UART Rx |
| J12-16 |
UART Rx |
← |
J68-8 |
UART Tx |
| JP12-17 |
GND |
↔ |
J47-6 |
GND |
IRQ, VEN and DWL_REQ connection
Note: In this case, please do not remove the jumpers of J45 and J20 on the PNEV7642A, we are going to attach the jumpers directly onto those headers.

Also, please remove the jumper on J25.
| |
IRQ |
VEN |
DWL_REQ |
| LPC55S16-EVK |
J13-1 |
J12-12 |
J13-3 |
| PNEV7642A |
J45 |
J20 |
J25-2 |
In order to select the UART Host Interface in the PNEV7642A, we need to set the HIF switches (SW5-SW7) as indicated:

Software
Prior to the following steps, please follow section 8 of the PN76 family evaluation board quick start guide.
To run the example in UART mode, first we need to compile the following libraries:


Please compile the main example the exact same way after this.

Code Modifications:
In lpc55S16Board.c (LPC55S16_Lib/source)
In the “lpc55S16Board_Init” function we need to add the following lines in order to enable one the ports and the clock for the USART of the Flexcomm2 peripheral.

GPIO_PortInit(GPIO, 1);
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM2);
In pin_mux.c (LPC55S16_Lib/board)
In the “BOARD_InitPins” functions we need to add the following line to enable GPIO 1’s clock.

CLOCK_EnableClock(kCLOCK_Gpio1);
In phHdll_Lib.c (Hdll_Lib/comps/phHdllLib/src)
In this file we are going to include the following library:

#include "fsl_usart.h"
In the “phHdll_Lib_HalHwExchange” function we are going to add the following lines right after performing the UART transmission of the command.

while(USART2->FIFOSTAT & 0x40)
{
USART_ReadByte(USART2);
}
This is done to empty the RX FIFO of the UART before performing a reception, in order to prevent reading errors.
In fsl_usart.c (LPC55S16_Lib/drivers)
In the “USART_ReadBlocking” function please copy the line 625 and paste it again after clearing the reception flags.

This is done in order to avoid erroneous interpretation of the RX frame.
In DownloadLibEx1.c
Lastly, we need to change the path of the ESFWU files to the local path where the files will be located. Please visit PN7642 Product Page, Software section to download the Firmware file.

Final Build:
Now we need to rebuild the main example, and we should be able to flash and debug after this.
