Device running flashloader

The flashloader will be ready to receive the commands once

  • the flashloader binary is downloaded on the device connected in USB DFU mode

  • starts its execution on the LPC540xx/LPC54S0xx platform

  • a physical USB connection is estabilished between the device platform and host

For this example, we have an LPC540xx/LPC54S0xx device running flashloader.bin connected over USB that enumerates on a Windows PC as a HID compliant device.

USB connection to LPC540xx/LPC54S0xx platform running flashloader application

Testing flashloader execution using blhost

This section describes a simple usage of the blhost host utility program to demonstrate communication with the LPC540xx/LPC54S0xx flashloader.

  • Open a command prompt in the directory containing blhost. For Windows OS, it is <sdk_package>/middleware/mcu-boot/bin/Tools/blhost/win.

  • Type blhost --help to see the complete usage of the blhost utility.

For this step, verify that the device is properly connected and is running the flashloader firmware application.

  • Note the USB vendor and product identifiers (VID and PID) of the device as shown in the above screenshot. The VID and PID are provided to identify the device with blhost when sending commands to the device.

  • Type blhost -u 0x1fc9,0x01a2 -- get-property 1 to get the bootloader version from the flashloader application.

  • The below screenshot indicates that blhost.exe is successfully communicating with the flashloader.

Host communication with ROM bootloader

Flashing the user application

After establishing communication between the flashloader and the host, use blhost commands to configure and program the demo application on the external Quad SPI memory.

Configuring external Quad SPI flash

Before accessing the Quad SPI flash memory, the SPIFI peripheral interface needs to be configured to the correct type of external Quad SPI flash present on the device. The flashloader command configure-memory is used for configuring, initializing, and preparing the SPIFI peripheral interface. The blhost application can be used to send the configure-memory command. The command require two arguments, memory-id and address-of-spi-nor-config-option-block. The memory-id for Quad SPI flash is 0xA. The address should point to the appropriate SRAM location where the configuration options block data is written prior to calling the configure-memory command. The bootloader commands, write-memory/fill-memory can be used to set the configuration data for the Quad SPI at the SRAM address. The following image shows the fill-memory command being used to fill the 4 bytes at address 0x2000b000 with configuration data 0xc0000004.

Note: The configuration block for Quad SPI flash memory should be programmed to SRAM other than reserved region.

The configuration structure is described in Chapter QuadSPI configuration structure.

Fill-memory command

The following example shows the call to configure-memory command:

Call configure-memory command

Once the QSPI is successfully configured, the Quad SPI memory can then be access for further operations to erase, read, write, and so on.

Bootloader uses its get-property command to read the external memory attributes for the configured QSPI memory. The following image shows the response for QSPI memory available on the LPC540xx/LPC54S0xx platform. The command requires two arguments, the property ID, 25, to read external memory attributes and memory ID, and 0xA, for external Quad SPI memory devices.

Response for QSPI memory

Programming application to Quad SPI memory

As already stated, once the Quad SPI is configured using the configure-memory command, the external memory becomes accessible. The flash area must be first erased before programming the demo application image. The following examples show the external flash memory region being erased using the flash-erase-region command and write-memory command being used to program the application image on the erased region.

External flash memory erased

The application used in the above example is a simple LED blinking example (led_blinky.bin) from the MCUXpresso SDK package. The application begins executing on the next boot or reset. The bootloader command -- reset can also be used to reset the device to boot and execute the led blinking application from the Quad SPI memory.

Reset command

Note: For a description of each bootloader command, see the blhost User’s Guide .