After LPC54XXX enter ISP mode, there are two methods to upgrade the application through UART/I2C/SPI/USB. One method is to change the ISP pin state when power on, and the other method is to reinvoke ISP Boot ROM in source code during code running. The first method does not require user to write any code, and the operation is simple, but the disadvantage is that it is not flexible and is not suitable for on-site operation; The second method is more flexible and is widely used in Secondary Bootloader applications developed by yourself, but it requires users to write their own code.
In actual development, because the USB port of personal computer is easy to use, the method of using the USB port for application upgrade is becoming more and more popular. Unfortunately, we currently do not have instructions for upgrading the application by the USB port in ISP mode. So we write this article to share the method here.
There are two methods to enter ISP mode:
On the hardware side, configure the ISP0~2 pins before power-on or reset, and the MCU enters ISP mode to upgrade the application. The pin configuration method is as follows:
In ISP mode, the application is upgraded through UART/I2C/SPI/USB. This article focuses on the USB method. Here for USB, Both USB0 (Full Speed) and USB1 (High Speed) of LPC54XXX can be used for application upgrade. There are two USB upgrade modes: DFU (Device Firmware Updata) and MSC (Mass Storage Device Class), as follows:
Select the application upgrade mode by modifying byte 0 and byte 1 of the ISP parameter array. The key code is as follows
There are 3 key point we need to pay attention in Figure 3:
-When isp_mode is configured as 0xAA, it is DFU mode, otherwise it is MSC mode (for example, isp_mode is configured as 0xFF).
-When isp_mode is configured as 8, USB FS is used, and when it is configured as 9, USB HS is used.
-Enter the ISP mode through the Chip_IAP_ReinvokeISP function.
2.1 Use DFU for application upgrade
To work with DFU, dfu-util tool is needed to use DFU to upgrade the application, you can download the DFU tool on the DFU official website. The link is as follows:
NXP also includes the dfu-util tool in LPCScrypt. If you have downloaded LPCScrypt, you can use it directly in the bin directory.
DFU update application Steps:
Take LPC54628 as an example, ISP is configured as DUF mode, and USB1 is used to upgrade the application.
isp_mode = 0xAA; isp_mode = SL_USBHS;
Build and download the application to the MCU, power on again, and connect USB1 to the computer. Here
Use the command: ./dfu-util -l Find the DFU devices.
Use the command: ./dfu-util -D .\lpcxpresso54628_gpio_led_output.bin -a 0
Download the lpcxpresso54628_gpio_led_output.bin file to the device with alt number 0. Alt0 is "FLASH", alt1 is "RAM", and the specific operations are as follows:
After downloading the application successfully, reset the MCU and observe the blinking phenomenon of the LED on the development board.
2.2 Use MSC for application upgrade
Take LPC54628 as an example, ISP is configured as MSC mode, and USB1 is used to upgrade the application. Modify the relevant code in Figure 3, as follows:
isp_mode = 0xFF; isp_mode = SL_USBHS;
Build and download the application to the MCU, power on again, and connect USB1 to the computer. You will found another disk in my computer, as follows:
Then do the following to update firmware:
-Remove the original firmware.bin in the CRP DISABLD disk.
-Rename the application (for example, lpcxpresso54628_gpio_led_output.bin) to firmware.bin.
-Copy the application firmware.bin to the CRP DISABLD disk.
-Reset the MCU, if the LED is observed blinking, it proves that the application has been successfully upgraded.
Note: The application must be renamed, and the rename cannot be performed in the CRP DISABLD disk.
Application upgrade file：lpcxpresso54628_gpio_led_output.bin (generated by SDK demo code)