Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sensortile_box_pro board: add sample to upgrade BlueNRG SoC firmware #74255

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions boards/st/sensortile_box_pro/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ sensors on board)
Hardware
********

The following is a summary of the main board features. More info can be find on `UM3133`_
and the `schematic`_.

The STM32U585xx devices are an ultra-low-power microcontrollers family (STM32U5
Series) based on the high-performance Arm|reg| Cortex|reg|-M33 32-bit RISC core.
They operate at a frequency of up to 160 MHz.
Expand Down Expand Up @@ -212,6 +215,15 @@ The final application may use it to declare SensorTile.box PRO device as belongi
certain standard or vendor class, e.g. a CDC, a mass storage or a composite device with both
functions.

BlueNRG-LP chip
===============

The board is equipped with an STMicroelectronics `BlueNRG-LP`_ chip. Before using the board Bluetooth
functionality, a firmware upgrade of the chip may be necessary, in order to run a firmware which is
compatible with the Zephyr BT stack (see `stsw-mkbox-bleco`_ for more information).
The upgrade may be easily performed following the procedure explained in
:zephyr:code-sample:`sensortile_box_pro_sample_ble_fwupg` sample.

Console
=======

Expand Down Expand Up @@ -333,12 +345,21 @@ References
.. _SensorTile.box PRO website:
https://www.st.com/en/evaluation-tools/steval-mkboxpro.html

.. _UM3133:
https://www.st.com/resource/en/user_manual/um3133-getting-started-with-sensortilebox-pro-multisensors-and-wireless-connectivity-development-kit-for-any-intelligent-iot-node-stmicroelectronics.pdf

.. _schematic:
https://www.st.com/resource/en/schematic_pack/steval-mkboxpro-schematic.pdf

.. _STM32U585 on www.st.com:
https://www.st.com/en/microcontrollers-microprocessors/stm32u575-585.html

.. _STM32U585 reference manual:
https://www.st.com/resource/en/reference_manual/rm0456-stm32u575585-armbased-32bit-mcus-stmicroelectronics.pdf

.. _BlueNRG-LP:
https://www.st.com/en/wireless-connectivity/bluenrg-lp.html

.. _lsm6dsv16x datasheet:
https://www.st.com/en/mems-and-sensors/lsm6dsv16x.html

Expand All @@ -362,3 +383,6 @@ References

.. _DFU-UTIL website:
http://dfu-util.sourceforge.net/

.. _stsw-mkbox-bleco:
https://www.st.com/en/embedded-software/stsw-mkbox-bleco.html
8 changes: 8 additions & 0 deletions boards/st/sensortile_box_pro/sensortile_box_pro.dts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
zephyr,console = &cdc_acm_uart0;
zephyr,shell-uart = &cdc_acm_uart0;
zephyr,bt-c2h-uart = &cdc_acm_uart0;
zephyr,bootloader-uart = &usart2;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,code-partition = &slot0_partition;
Expand Down Expand Up @@ -135,6 +136,13 @@ stm32_lp_tick_source: &lptim1 {
status = "okay";
};

&usart2 {
pinctrl-0 = <&usart2_tx_pd5 &usart2_rx_pd6>;
pinctrl-names = "default";
current-speed = <115200>;
status = "okay";
};

&usart3 {
pinctrl-0 = <&usart3_tx_pd8 &usart3_rx_pd9>;
pinctrl-names = "default";
Expand Down
11 changes: 11 additions & 0 deletions samples/boards/sensortile_box_pro/ble-fw-upgrade/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (c) 2024 STMicroelectronics
#
# SPDX-License-Identifier: Apache-2.0
#
cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(sensortile_box_pro)

target_sources(app PRIVATE src/main.c)
target_sources(app PRIVATE src/ble_fw.c)
10 changes: 10 additions & 0 deletions samples/boards/sensortile_box_pro/ble-fw-upgrade/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2024 STMicroelectronics
# SPDX-License-Identifier: Apache-2.0

mainmenu "Sensortile.box PRO ble f/w upgrade"

config BLOB_ENABLED
bool "Use ble f/w image blob"
default y

source "Kconfig.zephyr"
109 changes: 109 additions & 0 deletions samples/boards/sensortile_box_pro/ble-fw-upgrade/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
.. zephyr:code-sample:: sensortile_box_pro_sample_ble_fwupg
:name: ST SensorTile.box Pro BLE Firmware Upgrade

Upgrade the BLE firmware on STEVAL-MKBOXPRO board

Overview
********
This sample provides a simple method to upgrade the firmware for
the BLE chip present on :ref:`sensortile_box_pro_board` board.
It is based on the BlueNRG-LPS UART bootloader protocol explained in `AN5471`_ .

Requirements
************

The application requires a SensorTile.box Pro board connected to the PC
through USB.

To run this sample the console is not strictly needed, but might be useful.
Following is an example for minicom.

.. code-block:: console

$ minicom -D <tty_device> -b 115200

Replace :code:`<tty_device>` with the correct device path automatically created on
the host after the SensorTile.box Pro board gets connected to it,
usually :samp:`/dev/ttyUSB{x}` or :samp:`/dev/ttyACM{x}` (with x being 0, 1, 2, ...).
The ``-b`` option sets baud rate ignoring the value from config.

Building and Running
********************

To build and flash the sample, it is required fetching the controller-only BLE f/w
image for sensortile_box_pro board, which is hosted by external repo
(see `stsw-mkbox-bleco`_ for more information):

To fetch Binary Blobs:

.. code-block:: console

west blobs fetch stm32

Then, build the sample:

.. zephyr-app-commands::
:zephyr-app: samples/boards/sensortile_box_pro/ble-fw-upgrade
:board: sensortile_box_pro
:goals: build flash

Please note that flashing the board requires a few preliminary steps described
in :ref:`sensortile_box_pro_board`.
Comment on lines +50 to +51
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the link provided should mention the possibility of downloading some specific blob file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I forgot it. Now there is a mention to it.


After flashing, the sample starts and asks the user to acknowledge the f/w update.
User should press :kbd:`y` or :kbd:`Y` to proceed in upgrading the BLE f/w.

.. code-block:: console

Start BLE f/w update (press Y to proceed):

Nevertheless it is not strictly necessary to use the console, as the user may also acknowledge
the f/w update pressing the User BT2 button (see :ref:`sensortile_box_pro_board` board and
check on user manual and/or schematic to see where the button is located and how
it works).

LEDs status
-----------

The blue LED blinks three times with 200ms interval to indicate the procedure is starting.
Then blue LED start blinking very fast to indicate the BLE flash activity is on going.

After BLE flashing is complete:

- If status is OK the green LED blinks three times with 200ms interval and remains on.
- If flashing failed the red LED blinks three times with 200ms interval and remains on.

Console messages
----------------

To properly see messages on your terminale emulatore you may also need to set lineWrap to on.
In case of minicom just enter the menu with :kbd:`Ctrl-A Z` an then press :kbd:`W`.

The sample outputs following messages.

.. code-block:: console

SensorTile.box Pro BLE f/w upgrade
bootloader activated!
ble bootloader version is 4.0
MASS ERASE ok
..............................................................................................
..............................................................................................
..............................................................................................
..............................................................................................
..............................................................................................
..............................................................................................
..............................................................................................
............................................
BLE f/w upgrade ok

References
**********

.. target-notes::

.. _AN5471:
https://www.st.com/resource/en/application_note/an5471-the-bluenrglp-bluenrglps-uart-bootloader-protocol-stmicroelectronics.pdf

.. _stsw-mkbox-bleco:
https://www.st.com/en/embedded-software/stsw-mkbox-bleco.html
2 changes: 2 additions & 0 deletions samples/boards/sensortile_box_pro/ble-fw-upgrade/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_GPIO=y
CONFIG_LOG=y
13 changes: 13 additions & 0 deletions samples/boards/sensortile_box_pro/ble-fw-upgrade/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sample:
description: SensorTile.box Pro board ble firmware upgrade
name: SensorTile.box Pro fw upgrade
tests:
sample.board.sensortile_box_pro.ble-fw-upgrade:
harness: bluetooth
platform_allow: sensortile_box_pro
tags: bluetooth
depends_on:
- gpio
- uart
extra_configs:
- CONFIG_BLOB_ENABLED=n
16 changes: 16 additions & 0 deletions samples/boards/sensortile_box_pro/ble-fw-upgrade/src/ble_fw.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2024 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <stdint.h>

const uint8_t ble_fw_img[] = {
/* if not enabled do nothing, just remove blob dependency */
#ifdef CONFIG_BLOB_ENABLED
#include <dtm.bin.inc>
#endif
};

const uint32_t ble_fw_img_len = sizeof(ble_fw_img);
Loading
Loading