Firstly, I am using the "boot_fw" project in <SDK_ROOT>/firmware/boot_fw as the basis for my bootloader.
My goal is to have our device boot to this bootloader from SPI flash by default when it is turned on. It will then be recognized by the PC, and when our PC software runs, the PC software will quickly upload the latest version of the actual goal firmware that is shipped with our software to the FX3's RAM, and then have the bootloader boot the uploaded goal firmware.
Thus, I am using the USB_BOOT method inside of the "boot_fw" source code.
The only code I have changed are:
* The strings in the USB Device Descriptors (to rename the device).
* The VID and PID values (I have recompiled the host/Windows drivers to find these devices).
The "boot_fw" project was compiled and the image was uploaded to the device's SPI flash, from which it will boot at power up.
I can successfully upload the firmware to the CyFX3Device instance (which is correctly found and opened by the CyAPI library).
CyFX3Device::IsBootLoaderRunning() returns true before I call CyFX3Device::DownloadFw().
Furthermore, the internal method CyFX3Device::DownloadFwToRam() appears to return correctly. All of the downloaded FW data is uploaded back to the PC, and the byte-wise check/comparison shows that the data is correct.
However, as soon as the 0-length packet is sent to the device to tell it to call CyFx3BootJumpToProgramEntry(), Windows emits a "device disconnected" sound and the firmware doesn't seem to boot properly. None of the new device descriptors are sent to the PC, and no "device attached" sounds are emitted.
The device then reboots back to the bootloader firmware that was uploaded to the SPI flash.
The same Firmware image boots perfectly fine by uploading it to RAM using the built-in bootloader on the device.
So here is the general approach I have followed:
1. Use the "boot_fw" source code to compile a custom boot Fw image.
2. Upload this "boot_fw" image to SPI flash to be the default firmware that is booted.
3. Switch the FX3 out of bootloader/programming mode, so it loads the newly flashed "boot_fw" image by default.
4. Use CyAPI to download the intended device firmware to RAM, and have it boot.
Am I not doing something correctly? Should I be flashing my custom "boot_fw" to a different location, or is SPI flash okay?
I actually got it to work correctly.
I had to switch the first parameter of the method:
apiRetStatus = CyFx3BootUsbStart (CyTrue, myUsbEventCallback);
apiRetStatus = CyFx3BootUsbStart (CyFalse, myUsbEventCallback);
And now it appears to boot the primary FW correctly.
Why is this not set to CyFalse by default?