Working of Second Stage Bootloader in FX3™ - KBA90266

Version 1
    Version: **


    Question: How does the second stage bootloader work in FX3™ and how is it used?



    On powerup or reset, FX3 will start executing the bootloader code stored in the internal ROM (BootROM). The BootROM identifies the desired boot source by checking the state of the PMODE pins. It then initializes the appropriate interface block (GPIF, I2C, SPI, or USB) and tries to obtain the user firmware image. This image is parsed and the parsed contents are loaded into FX3's SRAM. (See Chapter 5 of the FX3 Programmer's Manual for details)

    However, if you need to have more control over the booting process, use the second stage bootloader (available in the {FX3_INSTALL_PATH}/firmware/boot_fw folder). The default bootloader will download the second stage bootloader into SRAM and transfer execution to it, which can then be programmed, as required.

    The second stage bootloader, similar to the default bootloader, initializes the appropriate interface block and tries to obtain the user firmware image.

    For USB boot, the myUsbBoot() function starts the USB block, sets up the descriptors, and connects the device to the host. The main firmware should not be re-enumerated if it needs to switch back to the bootloader (via CyU3PUsbJumpBackToBooter). Therefore, the bootloader must have the same descriptors as the main firmware. The binary image is then downloaded using 0xA0 vendor commands, parsed, and loaded into SRAM. When the last section of the image is received, control is transferred to the main application using CyFx3BootJumpToProgramEntry.

    Other boot methods work similarly.

    When the main firmware needs to jump back to the bootloader, it needs to de-initialize all peripherals and then call CyU3PUsbJumpBackToBooter with the firmware entry address of the bootloader. To know this, enable verbose prints in the elf2img tool (go to Fx3BootAppGcc > Project Properties > C/C++ Build > Settings > Build Steps and add the '-v' flag to the post-build command). During build, the tool prints “Entry point : 0x[some_address] ” and the some_address value is to be used with CyU3PUsbJumpBackToBooter.