Skip to main content
YWor.1
Associate III
April 10, 2022
Solved

Wireless stack and FUS image addresses for upgrading

  • April 10, 2022
  • 13 replies
  • 3566 views

Hello.

I'm planning a project that will use large amount of flash memory, therefore, I will need to be cautious with memory saved for app updates.

I'm using STM32WB55VGQ6 with 1MB of flash memory on custom designed board. my current application is about 300KB and it will grow larger.

I read in AN5185 document that when I send FUS_FW_UPGRADE command, there is an option to add address for image location and image destination. When I started to check this option, I have read @Remi QUINTIN in https://community.st.com/s/question/0D53W00001MwMvLSAV/shcic2fusfwupgrade-usage that this option is not used and FUS knows to locate the image address by finding some magic word and it finds the destination by itself. I wanted to know if this feature is optionally and can I use it by sending these 2 parameters with FUS_FW_UPGRADE command?

Another question, if I'm deleting current BLE stack before updating, will the FUS move the SFSA address forward and make some more user space in the flash memory?

Thanks.

This topic has been closed for replies.
Best answer by Remy ISSALYS

Hello,

The formula in the AN5185 will be updated soon. According to this update, use the following formula to calculate the most optimized download address:

1/ When the update is larger that the running wireless Firmware:

Download Addr = OldStackAdd(=SFSA) - NewStackSize(4Kb aligned) - 1 Sector

2/ When the update is smaller that the running wireless Firmware:

Download Addr = OldStackAdd(=SFSA) - NewStackSize(4Kb aligned)

I have perform some tests and there isn't any problem to update wireless stack between v1.10 and v1.13.

  • Full stack v1.10 to full stack v1.13, see formula 2 :
    • Download Addr = OldStackAdd(=SFSA) - NewStackSize(4Kb aligned) = 0x080CB000 - 0x00024000 = 0x080A7000

  • Full stack v1.13 to full stack v1.10, see formula 1:
    • Download Addr = OldStackAdd(=SFSA) - NewStackSize(4Kb aligned) - 1 Sector = 0x080D0000 - 0x00029000 - 0x00001000 = 0x080A6000

Best Regards

13 replies

Remy ISSALYS
ST Technical Moderator
April 13, 2022

Hello,

The FUS is not using the source address (nor the destination address) as it looks for some magic word starting from the beginning of the Flash memory, so you can't use FUS_FW_UPGRADE command with these 2 parameters, this feature isn't available.

For your second question, indeed when you delete your current BLE stack, the FUS will move the SFSA address forward in order to protect only the FUS and make more user space in the flash memory.

Best Regards

YWor.1
YWor.1Author
Associate III
April 24, 2022

Thanks. I have another question about the upgrade procedure.

After FUS finds this magic word, where will it install this new FW? will it be installed in the same address it finds it, or will it somehow move this image up the flash memory to an optimal address. my experience with stm32cubeProgrammer and Nucleo board, it seems that FUS installs this image in the same address it finds it and SFSA is set to the the address written in "Start address".

Remy ISSALYS
ST Technical Moderator
April 25, 2022

Hello,

After FUS finds this magic word, there is two cases:

> If there is only the FUS, the new FW will be installed in the same address the FUS finds it and set the SFSA at this address.

> If there is already a wireless stack, the new FW will be installed at the optimal address

Best Regards

YWor.1
YWor.1Author
Associate III
April 25, 2022

So in order to keep as much free space as possible, I will need to receive the new FW and save it somewhere, then delete the current FW, move the new one to the correct place and begin the upgrade procedure. Is it correct?

What happens with FUS upgrade procedure, where do I need to place it in memory and will it be installed in the address it is placed (like stack FW) or that in FUS upgrade, FUS itself knows to move this image and place it in the correct space?

Thanks.

Remy ISSALYS
ST Technical Moderator
May 2, 2022

Hello,

For wireless stack, we can do this but you can simplify the procedure:

> Receive the new FW and save it somewhere between the end of your application and the start of secure part (SFSA)

> Send FUS_FW_UPGRADE command, this command allows to check the new FW and delete the current FW and install the new FW at the optimal address instead of old FW.

For FUS upgrade, download and save the new FUS FW between the end of your application and the start of secure part (SFSA), then the FUS knows itself the right place to move the image and install it.

Best Regards

YWor.1
YWor.1Author
Associate III
May 3, 2022

Hi.

Thanks for clarifying both, stack and FUS, update procedure.

Just one more issue. I was trying to test the procedure with some test cases. Using ST OTA application with some changes I made so the update procedure will start when button 3 was pressed. All tests was working as you described except for the case when the new FW size was bigger than current image size (for example BLE_Stack_full_fw vs BLE_Stack_basic_fw or 1.13 version vs 1.10 version). In those cases, no matter what was the address I loaded the new image to, new image was kept in memory at the same address it was loaded to, SFSA stayed as before and wireless stack was working as before, like nothing happened.

Any idea what may be the reason and how can I solve this problem?

Thanks again.

Yair.

Remy ISSALYS
ST Technical Moderator
May 4, 2022

Hello,

Can you describe a bit more your test ? Can you give the address where the new image is loaded and the third digit of the stack version and SFSA value ?

Best Regards,

Remy

YWor.1
YWor.1Author
Associate III
May 8, 2022

The relevant tests are when BLE stack is already installed at several different addresses, 0x080A2000 (arbitrary address) ,0x080D1000 (for 1.13  BLE_Stack_basic_fw) and 0x080CB000 (for 1.10  BLE_Stack_full_fw). New image to be updated was loaded to address calculated with formula written in AN5185 document:

(current_FW_address - (2 * new_image_size - current_FW_size)).

It was also tested with some lower arbitrary addresses like 0x08070000.

SFSA was set according to current stack installed, like detailed above, and did not changed after update procedure was ended.

Thanks for helping.

Yair.

Remy ISSALYS
ST Technical Moderator
May 13, 2022

Hello,

Have you perform a flash erase of memory regions between the end of your application and SFSA, in order to clean the flash memory before loading the new image ?

Best Regards

YWor.1
YWor.1Author
Associate III
May 15, 2022

Hi.

From what I remembered, I was erasing the flash on every test. Just to be sure, I just now tried those scenarios: 1.10 BLE_Stack_full_fw is running and SFSA set to 0xCB, erased both full chip and selected sectors between OTA app and SFSA, download 1.13 BLE_Stack_full_fw to address 0x08090000. FW_Upgrade initiated and after several seconds a system reset was detected and when CPU2 asynch event occurred, FUS is running and image is still loaded, like no upgrade happened.

Regards.

Yair.

YWor.1
YWor.1Author
Associate III
May 17, 2022

Update:

I tried some more tests and figure out that what was causing the system resets is receiving FUS error on FUS_State command. The error code received is 0x04 - FUS_SATE_NO_ENOUGH_SPACE.

That made me think that the formula written in AN5185 may be mistaken. Formula for new image larger than current FW is:

WirelessStackAddress - (2xImageSize – WirelessStackSize). In my case: 0xCB-(2*0x2D-0x29) = 0x9A. Didn't work, same error received.

I tried to change formula to: WirelessStackAddress - 2xImageSize. In my case: 0xCB-2*0x2D = 0x71. Didn't work, same error received.

Another try to change formula to: ImageAddress(from release notes document) - 2xImageSize. In my case: 0xC7-2*0x2D = 0x6D. Finally, That worked, version was updated, SFSA was set to 0xC7 and FW stack Started automatically.

Just to be sure about this address, I downgrade version back to 1.10 and tried to load 1.13 to 0x6E. Upgrade received FUS_SATE_NO_ENOUGH_SPACE error again.

Can you please check that I am not mistaken, that there is a problem in the formula?

Thanks.

Yair.

Remy ISSALYS
Remy ISSALYSBest answer
ST Technical Moderator
June 1, 2022

Hello,

The formula in the AN5185 will be updated soon. According to this update, use the following formula to calculate the most optimized download address:

1/ When the update is larger that the running wireless Firmware:

Download Addr = OldStackAdd(=SFSA) - NewStackSize(4Kb aligned) - 1 Sector

2/ When the update is smaller that the running wireless Firmware:

Download Addr = OldStackAdd(=SFSA) - NewStackSize(4Kb aligned)

I have perform some tests and there isn't any problem to update wireless stack between v1.10 and v1.13.

  • Full stack v1.10 to full stack v1.13, see formula 2 :
    • Download Addr = OldStackAdd(=SFSA) - NewStackSize(4Kb aligned) = 0x080CB000 - 0x00024000 = 0x080A7000

  • Full stack v1.13 to full stack v1.10, see formula 1:
    • Download Addr = OldStackAdd(=SFSA) - NewStackSize(4Kb aligned) - 1 Sector = 0x080D0000 - 0x00029000 - 0x00001000 = 0x080A6000

Best Regards

YWor.1
YWor.1Author
Associate III
June 6, 2022

I have tried this new formula and it actually works.

I had 1.10 BLE_Stack_full_fw running and SFSA set to 0xCB. 1.13 BLE_Stack_full_fw size(4Kb aligned) is 0x2D, so Download Addr = 0x080CB000 - 0x0002D000 - 1 Sector = 0x0809D000.

Looks like new formula is working, plus it needs less flash space for Stack upgrade which is also very good news for my purpose.

Thanks for all the tips and advices.

Yair.