4 Replies Latest reply on Sep 23, 2020 2:09 AM by PrM_1403381

    Cypress FX3 Second stage boot loader using SPI

    PrM_1403381

      Hi,

       

      I am referring to FX3 Fail Safe Firmware Update , and able to implement the second stage boot loader for i2c and it is working as expected. same way I would like to use the second stage boot loader for SPI. How it can be achieved ? Do you have any reference design. So it would be very helpful.

       

      Thanks in advance,

       

      Best Regards,

      Prasanna

        • 1. Re: Cypress FX3 Second stage boot loader using SPI
          JayakrishnaT_76

          Hello,

           

          We do not have an example project for implementing Fail Safe Firmware update using second stage bootloader for SPI. But, you can refer to the response 1 of the following thread and develop your own project.

          FX3 Boot / Firmware Update Best Practices

           

          Please let us know if you face any issues or if you have any doubts while implementing this solution.

           

          Best Regards,

          Jayakrishna

          • 2. Re: Cypress FX3 Second stage boot loader using SPI
            PrM_1403381

            Hi Jayakrishna,

             

            Thanks for the quick response. I will go through the link provided. As well in the SDK installation path C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\boot_fw\src. Reference also provided and it will provide bootFromSpi(), also. I should be able to make my own project.

            My only concern is while writing from the host application to SPI flash. like in i2c. we will write the .img file. We need to write the continuously to SPI flash ? or do I need any care should be taken while writing to the SPI Flash ?

             

            Best Regards,

            Prasanna

            • 3. Re: Cypress FX3 Second stage boot loader using SPI
              JayakrishnaT_76

              Hello,

               

              I assume that your question is on updating the firmware using the host application by using vendor commands like the way done in the blog post. If this is the case, you need to make sure that the SPI flash sectors are erased correctly before writing the data into it. As you know, before writing to a sector of SPI flash, that sector needs to be erased. So if a part of both the application firmware .imgs (first and second) falls in a particular sector, then while erasing the sector the flash contents will be lost.

               

              In order to avoid the situation mentioned above, you can store second stage bootloader in the first sector of the flash. The first application firmware image can be stored from the second sector. The number of sectors required for storing the first application firmware image depends on the sector size of the flash used. The second application firmware should be stored in the next sector (after the sectors used for storing the first application firmware). The free space left after storing the firmware in a particular sector can be filled with 0s.

               

              For example, suppose the second stage bootloader makes use of 28KB and the sector size is 64KB. Then you can fill the remaining space of the first sector (64KB-28KB) with 0s. Please note that the merger tool in the blog post does not create a .img as mentioned above. For this, you need to create your own host application. Now, suppose you need to update firmware image 1, then you need to first erase the sectors used for storing firmware image 1. Then you can write the new .img to that sector. The same should be done for firmware image 2 also if it needs to be updated.

               

              Please refer to the SDK example cyfxflashprog which has vendor commands implemented for erasing, updating or reading from an SPI flash. This example can be found in the following location:

              C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\basic_examples\cyfxflashprog

               

              You can implement the same in your custom host application and the application firmware for firmware update.

               

              Note that the above path depends on the installation directory of FX3 SDK.

               

              If you do not want to update the firmware on the go (using host application by sending vendor commands to the application firmware), then there is no need of storing the .imgs in separate sectors. You can merge them together and store it into SPI flash at once using Control Center application. If any of the firmware image need to be updated, then you can create a new .img by merging the updates firmware, old firmware and second stage bootloader. This can be loaded into flash again using Control Center application.

               

              Please let me know if you have any queries on this.

               

              Best Regards,

              Jayakrishna

              • 4. Re: Cypress FX3 Second stage boot loader using SPI
                PrM_1403381

                Thank you so much. Nice info, it helps a lot. I will check If anything needed I will get back.

                 

                Best Regards,

                Prasanna