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

Conversation

avisconti
Copy link
Collaborator

@avisconti avisconti commented Jun 13, 2024

Add sample that implement the BlueNRG SoC firmware upgrade using the AN5471 protocol on uart2 channel.

It uses blobs that must be fetched with:
west blobs fetch stm32

Use of blobs approved by TSC (#74326)

(The CI for the sample is skipped because it requires the presence of a f/w blob that is not fetched by CI itself, as mentioned in https://docs.zephyrproject.org/latest/contribute/bin_blobs.html#support-and-maintenance)

@avisconti avisconti added area: Boards area: Samples Samples DNM This PR should not be merged (Do Not Merge) area: Bluetooth HCI Bluetooth HCI Driver area: Blobs Binary blobs labels Jun 13, 2024
@avisconti avisconti requested review from erwango and HoZHel June 13, 2024 14:37
@avisconti avisconti self-assigned this Jun 13, 2024
@zephyrbot zephyrbot added the platform: STM32 ST Micro STM32 label Jun 13, 2024
Copy link
Collaborator

@thedjnK thedjnK left a comment

Choose a reason for hiding this comment

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

no way, we do not allow binary blobs in samples

Copy link
Collaborator

@kartben kartben left a comment

Choose a reason for hiding this comment

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

some early comments re: documentation
also, I think including the binary will be problematic, and you may want to instead, if possible, direct people towards the ST website where I'm guessing the binary can probably be manuall downloaded by the end user?

boards/arm/sensortile_box_pro/doc/dtm.bin Outdated Show resolved Hide resolved
BlueNRG-LP chip
===============

The board is equipped with a ST Microelectronics `BlueNRG-LP`_ chip. Before using this
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
The board is equipped with a ST Microelectronics `BlueNRG-LP`_ chip. Before using this
The board is equipped with an ST Microelectronics `BlueNRG-LP`_ chip. Before using this

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, I missed it. I'll review your inputs carefully tomorrow.

Copy link
Collaborator

Choose a reason for hiding this comment

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

"STMicroelectronics" is attached, no!?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

"STMicroelectronics" is attached, no!?

Oh yes. Thanks for noticing it. I'll correct it

===============

The board is equipped with a ST Microelectronics `BlueNRG-LP`_ chip. Before using this
functionality on zephyr a chip f/w upgrade may be necessary. Please follow the information
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
functionality on zephyr a chip f/w upgrade may be necessary. Please follow the information
functionality on Zephyr, a firmware upgrade of the chip may be necessary. Please follow the information

Comment on lines 1 to 3
.. _sensortile_box_pro_sample_ble_fwupg:

ST SensorTile.box Pro BLE Firwmare Upgrade
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would recommend using .. zephyr:code-sample:: directive, see other samples using it for ... well... examples :D

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

seems cool!


The board is equipped with a ST Microelectronics `BlueNRG-LP`_ chip. Before using this
functionality on zephyr a chip f/w upgrade may be necessary. Please follow the information
on :ref:`sensortile_box_pro_sample_ble_fwupg` sample.
Copy link
Collaborator

Choose a reason for hiding this comment

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

use :zephyr:code-sample: to reference once you've update the sample's readme to use the code-sample directive

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ack


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 :code:`/dev/ttyUSBx` or :code:`/dev/ttyACMx` (with x being 0, 1, 2, ...).
Copy link
Collaborator

Choose a reason for hiding this comment

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

random sphinx trivia, you may make it look nicer using the below syntax:

Suggested change
usually :code:`/dev/ttyUSBx` or :code:`/dev/ttyACMx` (with x being 0, 1, 2, ...).
usually :samp:`/dev/ttyUSB{x}` or :samp:`/dev/ttyACM{x}` (with x being 0, 1, 2, ...).

https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-samp

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ack

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kartben Can you possibly take a look again after all the changes? Thanks

@avisconti
Copy link
Collaborator Author

no way, we do not allow binary blobs in samples

I saw that infineon is doing something similar, but they are using the Bluetooth firmware blob in the driver itself (brcm_patchram_buf). I guess that using it in drivers would be ok, right?

@thedjnK
Copy link
Collaborator

thedjnK commented Jun 13, 2024

no way, we do not allow binary blobs in samples

I saw that infineon is doing something similar, but they are using the Bluetooth firmware blob in the driver itself (brcm_patchram_buf). I guess that using it in drivers would be ok, right?

Errr, you what? Can you post a link?

I had a look and it doesn't have the blob in the driver, you need to get the blob using west blobs, and that was approved by the TSC. What is not acceptable is putting a blob into zepyhr itself, see https://docs.zephyrproject.org/latest/contribute/bin_blobs.html for process.

Though note samples are expected to build and pass in CI and there can be no blobs there, so I would say this sample is not acceptable for inclusion even if the blob is moved out as it can never be built in CI

@avisconti
Copy link
Collaborator Author

avisconti commented Jun 13, 2024

no way, we do not allow binary blobs in samples

I saw that infineon is doing something similar, but they are using the Bluetooth firmware blob in the driver itself (brcm_patchram_buf). I guess that using it in drivers would be ok, right?

Errr, you what? Can you post a link?

I had a look and it doesn't have the blob in the driver, you need to get the blob using west blobs, and that was approved by the TSC. What is not acceptable is putting a blob into zepyhr itself, see https://docs.zephyrproject.org/latest/contribute/bin_blobs.html for process

Not sure I got your point, my bad.
I'm actually using same method, i.e. getting the blob using west blobs fetch hal_st.

@thedjnK
Copy link
Collaborator

thedjnK commented Jun 13, 2024

no way, we do not allow binary blobs in samples

I saw that infineon is doing something similar, but they are using the Bluetooth firmware blob in the driver itself (brcm_patchram_buf). I guess that using it in drivers would be ok, right?

Errr, you what? Can you post a link?
I had a look and it doesn't have the blob in the driver, you need to get the blob using west blobs, and that was approved by the TSC. What is not acceptable is putting a blob into zepyhr itself, see https://docs.zephyrproject.org/latest/contribute/bin_blobs.html for process

Not sure I got your point, my bad. I'm actually using same method, i.e. getting the blob using west blobs fetch hal_st.

Why do you have a .bin file in this commit?

@avisconti
Copy link
Collaborator Author

Why do you have a .bin file in this commit?

Ops, I think it was left there by mistake. Thanks for catching it. :(

@avisconti avisconti force-pushed the add-stile-ble-doc branch from 765b008 to 3ae0469 Compare June 13, 2024 15:39
@avisconti avisconti force-pushed the add-stile-ble-doc branch from 3ae0469 to 5cc6d59 Compare June 14, 2024 13:39
@avisconti avisconti requested a review from ajarmouni-st June 14, 2024 13:40
@fabiobaltieri
Copy link
Member

@fabiobaltieri what do you think of the changes done? Any feedback related to blob handling?

Should be alright, went through TSC and approved.

switch (status) {
case BLE_FW_UPG_START:
for (i = 0; i < 7; i++) {
gpio_pin_toggle(blue_gpio.port, blue_gpio.pin);
Copy link
Member

Choose a reason for hiding this comment

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

gpio_pin_toggle_dt

{
/* led 0 */
if (!gpio_is_ready_dt(&green_gpio)) {
LOG_ERR("%s: device not ready.\n", green_gpio.port->name);
Copy link
Member

Choose a reason for hiding this comment

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

LOG_... calls don't need the explicit \n, also this file mixes printk and LOG, I think you should stick with one or the other, if you enable logging just use LOG everywhere

static int ble_bl_cmd_mass_erase(const struct device *bl_uart)
{
if (ble_uart_send_cmd(bl_uart, BLE_BL_CMD_ERASE) < 0) {
return -1;
Copy link
Member

Choose a reason for hiding this comment

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

how about having a temporary return variable, logging the error message and returning the actual code? same in the other cases, not much point keeping it ultra compact, if something fails it'll be a pain to troubleshoot

}

/* send address */
if (ble_uart_send_data(bl_uart, (uint8_t *)&address_be, 4) < 0) {
Copy link
Member

Choose a reason for hiding this comment

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

sizeof(address_be)

@thedjnK
Copy link
Collaborator

thedjnK commented Aug 27, 2024

no way, we do not allow binary blobs in samples

I saw that infineon is doing something similar, but they are using the Bluetooth firmware blob in the driver itself (brcm_patchram_buf). I guess that using it in drivers would be ok, right?

Errr, you what? Can you post a link?
I had a look and it doesn't have the blob in the driver, you need to get the blob using west blobs, and that was approved by the TSC. What is not acceptable is putting a blob into zepyhr itself, see https://docs.zephyrproject.org/latest/contribute/bin_blobs.html for process.
Though note samples are expected to build and pass in CI and there can be no blobs there, so I would say this sample is not acceptable for inclusion even if the blob is moved out as it can never be built in CI

@thedjnK the process took a while, but finally it was approved by TSC (see #74326). Can you please take a look again to this PR? Thanks.

The blob was approved, this PR was not, would like @nashif to comment on acceptability of this, this sample requires a blob to build and cannot be run on zephyr's CI at all, unlike other samples where the blob is optional for some boards, here it is a requirement

@avisconti
Copy link
Collaborator Author

no way, we do not allow binary blobs in samples

I saw that infineon is doing something similar, but they are using the Bluetooth firmware blob in the driver itself (brcm_patchram_buf). I guess that using it in drivers would be ok, right?

Errr, you what? Can you post a link?
I had a look and it doesn't have the blob in the driver, you need to get the blob using west blobs, and that was approved by the TSC. What is not acceptable is putting a blob into zepyhr itself, see https://docs.zephyrproject.org/latest/contribute/bin_blobs.html for process.
Though note samples are expected to build and pass in CI and there can be no blobs there, so I would say this sample is not acceptable for inclusion even if the blob is moved out as it can never be built in CI

@thedjnK the process took a while, but finally it was approved by TSC (see #74326). Can you please take a look again to this PR? Thanks.

The blob was approved, this PR was not, would like @nashif to comment on acceptability of this, this sample requires a blob to build and cannot be run on zephyr's CI at all, unlike other samples where the blob is optional for some boards, here it is a requirement

I understand your point despite the fact that there are already other samples (very few to be honest) which skip the CI. But I understand your point. The problem is that in order to increase the usability of the sensortile_box_pro board, in this case the ble usage, a method to update the ble chip f/w is necessary. Maybe a sample is not the answer, maybe there are other ways.

So, instead of a "you cannot do that" approach, I would rather appreciate some suggestions on an alternative way to perform the upgrade. Please note that this issue is common to other ST boards as well, so the solution that will come up on this PR will be probably generally adopted.

Maybe @nashif could really give his opinion on that.

@fabiobaltieri
Copy link
Member

There was a conversation about this some time ago, was about a vendor specific radio protocol that required a blob to build. IIRC the sample got blocked on the basis on not being buildable in CI since CI does not fetch any blobs. I think it's a bit of a weak argument though because the same can be said for most bluetooth HCI drivers, most of the ones that live in https://github.com/zephyrproject-rtos/zephyr/tree/main/drivers/bluetooth/hci can't built without blobs and no CI target builds them.

@avisconti
Copy link
Collaborator Author

avisconti commented Aug 28, 2024

There was a conversation about this some time ago, was about a vendor specific radio protocol that required a blob to build. IIRC the sample got blocked on the basis on not being buildable in CI since CI does not fetch any blobs. I think it's a bit of a weak argument though because the same can be said for most bluetooth HCI drivers, most of the ones that live in https://github.com/zephyrproject-rtos/zephyr/tree/main/drivers/bluetooth/hci can't built without blobs and no CI target builds them.

Yeah, exactly. For example at least the Infineon cyw208xx ble driver. This is the one I took a look at when I started to explore the way to do it. This driver should have the same CI issue I'm running into I guess...

@thedjnK
Copy link
Collaborator

thedjnK commented Aug 28, 2024

There was a conversation about this some time ago, was about a vendor specific radio protocol that required a blob to build. IIRC the sample got blocked on the basis on not being buildable in CI since CI does not fetch any blobs. I think it's a bit of a weak argument though because the same can be said for most bluetooth HCI drivers, most of the ones that live in https://github.com/zephyrproject-rtos/zephyr/tree/main/drivers/bluetooth/hci can't built without blobs and no CI target builds them.

This is a sample, this is not a driver. Blobs are hardware enablement, not sample enablement. The corresponding sample is https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/bluetooth/hci_ipc which can and is built without blobs in CI

So, instead of a "you cannot do that" approach, I would rather appreciate some suggestions on an alternative way to perform the upgrade. Please note that this issue is common to other ST boards as well, so the solution that will come up on this PR will be probably generally adopted.

From my point of view it should be done downstream, out of the zephyr repo

@avisconti
Copy link
Collaborator Author

So, instead of a "you cannot do that" approach, I would rather appreciate some suggestions on an alternative way to perform the upgrade. Please note that this issue is common to other ST boards as well, so the solution that will come up on this PR will be probably generally adopted.

From my point of view it should be done downstream, out of the zephyr repo

ok, I'll try to investigate in that direction then.

@fabiobaltieri
Copy link
Member

From my point of view it should be done downstream, out of the zephyr repo

What if the loader code was implemented as a drivers/misc/ driver?

@avisconti
Copy link
Collaborator Author

From my point of view it should be done downstream, out of the zephyr repo

What if the loader code was implemented as a drivers/misc/ driver?

But I guess it would have same blob/ci issue, isn't it?

@fabiobaltieri
Copy link
Member

fabiobaltieri commented Aug 30, 2024

But I guess it would have same blob/ci issue, isn't it?

Sure but no one seems to be concerned with that for ble hci drivers...

Or maybe you could have a sample Kconfig option enabled by the test run that replaces the blob with dummy data so that the sample can be compiled?

@avisconti
Copy link
Collaborator Author

But I guess it would have same blob/ci issue, isn't it?

Sure but no one seems to be concerned with that for ble hci drivers...

Or maybe you could have a sample Kconfig option enabled by the test run that replaces the blob with dummy data so that the sample can be compiled?

Well Fabio, I'm actually exploring the possibility to prepare an external zephyr application to accomplish this task. It is basically the same code of this sample, but replacing the blobs part which is not needed. It will require a bit of extra explanations in order to be used, but seems to me the best solution.

@fabiobaltieri
Copy link
Member

Sure I just find it incoherent that we are so worried about blobs in sample code and not worried at all about blobs in subsystem code.

@avisconti
Copy link
Collaborator Author

Or maybe you could have a sample Kconfig option enabled by the test run that replaces the blob with dummy data so that the sample can be compiled?

@fabiobaltieri I had an internal conversation with someone here in STM that was basically proposing similar approach. It should be very easy to do such modifications and it won't affect CI, but I'm not sure that it would be accepted.

Something like

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

And then user would build the sample with -DCONFIG_BLOB_ENABLED=y

Would that be approved?
@thedjnK what's also ur opinion?

@fabiobaltieri
Copy link
Member

And then user would build the sample with -DCONFIG_BLOB_ENABLED=y

Well it should be the opposite IMO, the default behavior uses the blob (so the user can use it as is) but the configuration used in CI (i.e. what's in sample.yaml) enables the dummy blob array thing. But yeah apart from that I think it would be fine, certainly worth trying anyway.

Just to be sure: so this is really not something one may want to compile in as part of their application? Just a standalone sample and that's it?

@avisconti
Copy link
Collaborator Author

And then user would build the sample with -DCONFIG_BLOB_ENABLED=y

Well it should be the opposite IMO, the default behavior uses the blob (so the user can use it as is) but the configuration used in CI (i.e. what's in sample.yaml) enables the dummy blob array thing. But yeah apart from that I think it would be fine, certainly worth trying anyway.

It makes sense, thx.

Just to be sure: so this is really not something one may want to compile in as part of their application? Just a standalone sample and that's it?

Yes, exactly.

My feeling is that it won't be accepted anyway, as the real issue seems not to be the CI, but the fact that sample concept should not be used to convey a functionality, but to make examples. Let's see.

This sample implement the ble firmware upgrade using the AN5471
protocol on uart2 channel.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
Extend sensortile_box_pro document adding BlueNRG-LP chip description.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
avisconti added a commit to avisconti/zephyr that referenced this pull request Sep 17, 2024
Since the mkbox board ble f/w upgrade method based on binary
blobs that was proposed in zephyrproject-rtos#74255 has been turned down, all
the work done in hal_stm32 module to host blobs is now reverted.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
@avisconti
Copy link
Collaborator Author

avisconti commented Sep 17, 2024

This PR has not been accepted and is going to be closed down.
A new PR (#78564) has been opened instead, with only the part concerning board ble chip documentation, including reference on how to upgrade the ble f/w (no more blobs required, https://github.com/STMicroelectronics/stsw-mkbox-bleco/blob/master/ble_fw_upg_app/README.rst)

@avisconti avisconti closed this Sep 17, 2024
avisconti added a commit to avisconti/zephyr that referenced this pull request Sep 18, 2024
Since the mkbox board ble f/w upgrade method based on binary
blobs that was proposed in zephyrproject-rtos#74255 has been turned down, all
the work done in hal_stm32 module to host blobs is now reverted.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
carlescufi pushed a commit that referenced this pull request Sep 19, 2024
Since the mkbox board ble f/w upgrade method based on binary
blobs that was proposed in #74255 has been turned down, all
the work done in hal_stm32 module to host blobs is now reverted.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
Jaafar-G pushed a commit to Jaafar-G/zephyr that referenced this pull request Dec 7, 2024
Since the mkbox board ble f/w upgrade method based on binary
blobs that was proposed in zephyrproject-rtos#74255 has been turned down, all
the work done in hal_stm32 module to host blobs is now reverted.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants