Ezportdl:programming Kinetis EZport by MCU-Link Pro
NXP launched MCU-Link Pro at the end of 2021. This is a new debugger probe that has been significantly upgraded based on mcu-link. The focus of the upgrade is to add current measurement, analog signal monitoring, USB to SPI and I2C bridge working modes, and on-board lpc804 for peripheral simulation. Among these upgrades, USB to SPI and I2C are more interesting and practical. Combining Kinetis EZport and flashloader, MCU-Link Pro can directly download programs to the target chip, instead of bridge through another board as before. This project uses the USB to SPI function of MCU-Link Pro to download programs to kinetis K series chips through EZport. In addition to the Kinetis series, many ColdFire chips of NXP also support EZport. In addition, since EZport interface protocol is compatible with SPI NOR flash, this project can also directly burn SPI NOR flash chip. This can also be used when debugging or producing i.mxRT500 and i.mxRT600.
MCU Link Pro can easily use USB to SPI and I2C interfaces because NXP provides LIBUSBSIO library. Readers can download this library and related documents from NXP's official website. Here is a brief introduction. The SUB to SIO function is only an optional additional function for lpclink2 and MCU-Link Pro devices. Its main function is to provide CMSIS-DAP debugging interface for the target microcontroller, and provide virtual serial communication using USB VCOM class. The following figure is the process framework of LIBUSBSIO. As shown in the figure, LIBUSBSIO library can support SPI, I2C and GPIO.
The core of LIBUSBSIO communication is SPI_Transfer (lpc_handle hspi, spi_xfer_t * xfer) function. This function can send and receive 1024 bytes at most at one time. In addition, LIBUSBSIO library can set baud rate, clock polarity, sampling edge, and frame length. The following figure shows the output waveform captured by the logic analyzer.
Command |
Description |
WREN |
Write Enable |
WRDI |
Write Disable |
RDSR |
Read Status Register |
READ |
Flash Read Data |
SP |
Flash Section Program |
SE |
Flash Sector Erase |
BE |
Flash Bulk Erase |
RESET |
Reset Chip |
WRFCCOB |
Write FCCOB Registers |
dl |
Image download |
fw |
Write/read any sequence to SPI port |
This project has been tested on FRDM-K64F.
Hardware connection:
MCU-Link pro FRDM-K64F
J19-2 --- R75-1(flying a line is needed)
J19-3 --- J1-8
J19-4 --- J11-1
J19-5 --- J1-12
Connect ground together.
Operation steps:
Before power on, R75-1 should be connected to ground, then connect openSDA USB. Thus, K64 will enter EZport status.
ezportdl read [address] [number]
ezportdl wren
ezportdl sp [length] [data]
Ezportdl dl [address] [file name] [flag]
address means start address flag=0 means erase flash before programming, flag=1 means don’t erase the flash.
Project download address:
https://github.com/jophpan/ezportdl/tree/master