ST STM32WB

From SEGGER Wiki
Revision as of 09:44, 17 December 2021 by Fabian (talk | contribs) (How to delete the Wireless Stack)
Jump to: navigation, search

Multicore Architecture

The STM32WB55 is a heterogeneous dual-core MCU with a Cortex-M4 for the end-user application and a Corte-M0 for the BLE stack.

RSS / FUS

Root Security Service(RSS) and the Firmware Upgrade Service(FUS) are responsible for secure wireless stack updates and encryption key management. This firmware is executed by the secure core(Cortex-M0)and is not accessible by the end user or a debug probe. This firmware is factory installed in the STM32WB55 flash memory and is marked as secured. Therefore the end-user needs to take into consideration when choosing this device, as part of the memory will be already reserved for the RSS(around 5%). The RSS uses between 10 sectors(v0.5.3) and 12 sectors(v1.1.0) and is written in the flash memory end sectors. For example, for a 1MB device, this will be stored starting at the address 0x080F4000 for v1.1.0 and 0x080F6000 for v0.5.3.

How to update the Wireless Stack

Uploading a wireless stack to the STM32WB55 can be done with- J-Link Commander(J-Link.exe). This section describes how this is done via the following steps:

  1. Acquire Wireless Stack binaries and determine the correct flash address.
  2. Start the device in boot loader mode.
  3. Connect to the MCU using J-Link Commander.
  4. Load wireless stack to target using J-Link Commander.

Acquire Wireless Stack binaries

The wireless stack binaries can be downloaded from https://www.st.com/en/embedded-software/stm32cubewb.html.
After downloading:

  • Unpack the package
  • Navigate to STM32Cube_FW_WB_V<Version>\Projects\STM32WB_Copro_Wireless_Binaries\.
  • Open Release_Notes.html, which contains information about:
    • Where each stack starts.
    • The corresponding binary files and where they should be programmed to.

Bellow in Available Stacks from ST you may find the current available stacks and assigned addresses.

Start Device in system boot loader mode

It is important that the device starts in system boot mode. The update procedure relies on the system boot loader to be executed, as the system bootloader sets up the shared tables, which are required for the Wireless Stack and FUS upgrade.

This can be done with the following configurations:

nBOOT1
FLASH_OPTR[23]
nBOOT0
FLASH_OPTR[27]
BOOT0
pin PH3
nSWBOOT0
FLASH_OPTR[26]
Main Flash
empty
--- --- NO.png YES.png YES.png
YES.png --- YES.png YES.png ---
YES.png NO.png --- NO.png ---

YES.png == Set
NO.png == Not set
--- == Don't care

Connect to the Device with J-Link Commander

Before connecting to the Device, please make sure you are using the latest version of the J-Link Software Pack. Open the J-Link commander (%JLinkInstallDir%\JLink.exe) using the following command line:

Windows: 
  JLink.exe -autoconnect 1 -device "STM32WB55xx - FUS" -if swd -speed 4000
Linux/MacOS:
  JLinkExe  -autoconnect 1 -device "STM32WB55xx - FUS" -if swd -speed 4000

The above command output should be as following:
600px

Downloading the wireless stack

After connecting to the MCU successfully, download the Update using the Reset and LoadFile commands. Even though resetting the device is not mandatory, it is highly recommended.

r
loadfile <PathToBinary>\stm32wb5x_BLE_Stack_fw.bin, <Address>
Note:
The address the wireless stack has to be downloaded to differs depending on update version and device.

Example (STM32WB5xxG, version 1.1.0):

J-Link> loadfile C:\Users\Pedro\Desktop\STM32WB_Copro_Wireless_Binaries\stm32wb5x_BLE_Stack_fw.bin, 0x080CC000

The output should look like the following:
1000px

How to delete the Wireless Stack

  1. Start the device in system boot loader mode as described here.
  2. Connect to the device as described here.
  3. (Optional/Recommended) Reset the device using the Reset command.
  4. Erase the the device using the Erase command.
r
Erase 
Note:

Doing this might cause some errors/warnings to be shown in den J-Link Commander (see below). This is expected and does not mean that the erase process failed. The reason for the error is that a part of the Flash is protected (boot loader). Therefore trying to delete the flash is going to return an error.

A successful erase operation should output "RSS: Wireless stack successfully deleted.".

STM32WB55 erase under J-Link commander

How to update the RSS

Same process as a wireless Stack. Simply loadbin over J-Link Commander to the memory specified by ST and wait for the process to finish.

Warning: Once the FUS is updated from the v0.5.3 to v1.0.1 is not possible to reverse RSS or install WS from previous versions. The RSS/FUS can only upload wireless stacks within the same release version.

How does it work

The process for uploading a Wireless stack to STM32WB55 with J-Link works by uploading the binary to the flash memory and then by requesting a Wireless stack upgrade to the FUS(Firmware Upgrade Service), by means of communication with IPPC and shared tables.

The upgrade process

  1. Before the upgrade is started the J-Link will request the FUS/RSS to delete any current wireless stack that might be installed.
  2. The uploaded stack to the flash will be checked by J-Link if it contains a valid image signature.
  3. A WS_UPGRADE request is made to the FUS. During this process, the MCU will reset several times. Until the Cortex-M0 becomes responsive the J-Link will try every second to establish a connection with the FSU.
Note:
This process takes around 20 to 30 seconds depending on the Wireless stack size.

Available Stacks from ST

600px

For STM32CUBEWS vs 1.1.0 the following stacks should be installed in the below addresses.

Wireless Stack Installation address
stm32wb5x_BLE_Stack_fw.bin 0x080CC000
stm32wb5x_BLE_HCILayer_fw.bin 0x080DC000
stm32wb5x_Thread_FTD_fw.bin 0x0809F000
stm32wb5x_Thread_MTD_fw.bin 0x080B5000
stm32wb5x_BLE_Thread_fw.bin 0x08079000
stm32wb5x_Mac_802_15_4_fw.bin 0x080E6000
stm32wb5x_rfmonitor_phy802_15_4_fw.bin 0x080EC000


FAQ

So how does J-Link communicates with the FUS and performs the Wireless stack upgrade/delete requests? The communication between the J-Link and the RSS/FUS is performed by use of the IPPC(Inter-Processor Communication Channel) and shared tables that are pre-defined by Cortex-M0.

Does this mean that the Cortex-M0 is always running the RSS firmware? No, the RSS firmware is only running when a wireless stack is not installed or a request is made through the IPCC and shared tables.

Can I delete the RSS firmware? No, this is marked as secure and is not possible to delete.

Can I make my own Wireless stack and upload it? Currently, ST only allows uploading STs encrypted wireless stacks.