FX3 second stage boot-loader

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
IlPa_4625406
Level 1
Level 1
First like given

Hi Cypress,

I am trying to implement a custom I2C boot using the second stage boot-loader. I am looking to address a failure case wherein the EEPROM firmware needs an update or is corrupted. This firmware now needs to be updated using the second stage boot-loader. I could jump to the second stage boot-loader using the CyU3PJumpBackToBooter() API but I need to know how I could access the I2C EEPROM so that I can burn my new firmware image over the USB interface.

Thanks,

IP

0 Likes
1 Solution

Hello,

Please try the following and let me know if it helps.

1. In the second stage bootloader code, define both macros i.e I2C boot and USB boot. This is used to fallback to USB boot when I2C boot fails. Now, combine the image files of the second stage bootloader and the application firmware and load it into I2C EEPROM. Upon resetting the device, the second stage bootloader will be loaded to RAM first followed by the application firmware.

2. Whenever, the firmware needs an update, just make the I2C boot fail. For this, In the application firmware  use a vendor command to change the first byte of the EEPROM where the application firmware is stored. The first byte of a valid image will be 'C' . The second byte will be 'Y'. If this byte is changed, the I2C boot will fail. Now upon jumping back to the second stage bootloader, I2C boot will fail. Then USB boot can be used. The device will enumerate as Bulkloop example device.

3. Now, load a dummy firmware to RAM by using control center. This dummy firmware should accept a vendor command so as to update the EEPROM with the new image file. After successfully updating the EEPROM with the new firmware, jump back to the second stage bootloader. This time, I2C boot will not fail as the CY signature will be proper.

We do not have any examples to update the EEPROM inside the second stage bootloader so please use the procedure mentioned above and let me know the result.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna

View solution in original post

12 Replies
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello,

Please let me know the following details:

1. Initially, how are you loading the firmware to the device?

2. How are you planning to detect when the firmware needs an update?

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hi Jayakrishna,

1. I am using a second stage boot-loader with I2C EEPROM boot to load the firmware initially.

2. Firmware update is need-specific. Whenever, there needs to be a new feature added or if there needs to be a fix in the firmware, update is required.

Thanks,

IP

0 Likes

Hello,

Please go through the following blog

FX3 Fail Safe Firmware Update

This describes how to update the firmware stored in I2C EEPROM.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hi Jayakrishna,


I am aware of this document. This blog tells about how to add a secondary firmware using a vendor command on the running firmware. My requirement is to update the firmware from the second-stage boot-loader over USB and not using the currently running firmware.

Thanks,

IP

0 Likes

Hello,

According to my understanding, at the beginning you merge the .img files for your firmware and the second stage bootloader (with macro for I2C boot enabled). Then you load the merged .img file to the EEPROM. The ROM Bootloader will load the 2nd stage bootloader into the SRAM first and then the secondary bootloader will load the application firmware from I2C into SRAM. Please correct me if my understanding is wrong.

Now, at a particular point of time, you need to update the existing application firmware. Please let me know how this need for updating the present firmware is conveyed to the device or on the occurrence of which event due you plan to call the CyU3PJumpBackToBooter(

) API?

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hi Jayakrishna,

Yes, your understanding is correct.

I would like to update the firmware at any point during the operation of the device if there needs to be an update. I would jump back to the second stage boot-loader using a vendor command in the main application firmware.

Thanks,

IP

0 Likes

Hello,

In that case, whenever the vendor command is issued to the application firmware, you will use the CyU3PJumpBackToBooter() API to return to the second stage bootloader. But the second stage bootloader has the macro for I2C boot enabled. This will only read from the I2C EEPROM and dont have the provision to update the EEPROM with the new firmware.

So, please update the existing firmware in the EEPROM by making use of the blog mentioned before. This makes use of a fail-safe boot that is even if the booting of new firmware image fails, the older firmware image will be still retained in the EEPROM.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hi Jayakrishna,

I understand that I cannot update the firmware if I have only the I2C_BOOT macro. To overcome this, I can have both the I2C_BOOT and USB_BOOT macro in the second stage boot-loader.

The problem with the approach mentioned in the blog is that it uses two main application firmware images and uses one firmware to update the other firmware. But, I would like to use only a single main application firmware in addition to the second stage boot-loader firmware.

As I had mentioned above, I can use the USB_BOOT option to update the EEPROM firmware over a vendor command. But, below are the two scenarios:

1. Normal usage: Use I2C_BOOT

2. FW update required: Use USB_BOOT

I need a way to distinguish the above two scenarios.

Thanks,

IP

0 Likes

Hello,

Once you build the second stage bootloader code with I2C boot macro enabled, it is not possible to switch it to USB_BOOT macro on the run.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hi Jayakrishna,

It should be possible to use both I2C_BOOT and USB_BOOT in the same firmware. In fact, "I2C, on fail USB" boot method should use both I2C and USB boot options. I am trying to implement something similar. I would like to use I2C as the primary boot option. If I2C fails or if FW update is required, I would like to use the USB boot option.

Thanks,

IP

0 Likes

Hello,

Please try the following and let me know if it helps.

1. In the second stage bootloader code, define both macros i.e I2C boot and USB boot. This is used to fallback to USB boot when I2C boot fails. Now, combine the image files of the second stage bootloader and the application firmware and load it into I2C EEPROM. Upon resetting the device, the second stage bootloader will be loaded to RAM first followed by the application firmware.

2. Whenever, the firmware needs an update, just make the I2C boot fail. For this, In the application firmware  use a vendor command to change the first byte of the EEPROM where the application firmware is stored. The first byte of a valid image will be 'C' . The second byte will be 'Y'. If this byte is changed, the I2C boot will fail. Now upon jumping back to the second stage bootloader, I2C boot will fail. Then USB boot can be used. The device will enumerate as Bulkloop example device.

3. Now, load a dummy firmware to RAM by using control center. This dummy firmware should accept a vendor command so as to update the EEPROM with the new image file. After successfully updating the EEPROM with the new firmware, jump back to the second stage bootloader. This time, I2C boot will not fail as the CY signature will be proper.

We do not have any examples to update the EEPROM inside the second stage bootloader so please use the procedure mentioned above and let me know the result.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna

Hi Jayakrishna,

This sounds like a solution. Hope this works.

Thank you for your assistance. This thread can be closed. I shall open a new thread if there are any queries in the future.


Thanks,IP

0 Likes