cancel
Showing results for 
Search instead for 
Did you mean: 

Issues with custom BLE service generation in STM32CubeIDE/STM32CubeMX

AClif
Associate III

TLDR; The current tools for BLE in STM32CubeIDE and STM32CubeMX do not work properly for custom BLE profiles in the STM32WB55. When will the tools support it, and when will the documentation be updated with the current system?

Firstly, I would prefer to raise the following with the ST **Issues** system (referred to README.md in the fw packs), but I can't find it!

I am using the STM32CubeIDE to develop software for a small bluetooth project I am working on using the STM32WB55CGU (1M flash in UFQFPN48 package).

I was running through the STM32WB workshop MOOC (https://www.st.com/content/st_com/en/support/learning/stm32-education/stm32-moocs/STM32WB_workshop_MOOC.html, youtube playlist: https://www.youtube.com/playlist?list=PLnMKNibPkDnGRfqUO1Q_-1nW-tOKfDQbc), which is really good and helpful, UNTIL you get to section 4, "How to modify BLE profile", at which point the whole thing falls apart if you are using any of ST's tools from the last 6 months.

The issues I have observed (thus far) in the Device Configuration Tool (i.e. the CubeMX view in STM32CubeIDE) are as below. As far as I can tell these apply to STM32CubeMX as well.

Version information: 

STM32CubeIde version 1.3.1, build 6291_20200406_0752 (UTC)

STM32CubeMX (tested separately), version 5.6.0

STM32Cube MCU Package for STM32Wb Series version 1.7.0 (these issues were also present, and raised, with version 1.5.0 at least)

Issues:

In STM32_WPAN -> BLE Application and Services, if Custom Template is Enabled, several new tabs appear:

BLE Pairing

BLE Advertising

BLE GATT

In the BLE GATT window, you can add new services. As you add a new service, you also get a new tab with the name of the service.

I have no problem with this, and it seems like a good way to approach setting up services. However, this has been present for at least 3 releases of the MCU package and still does not work. There is also literally zero supporting information (that I can find) on these changes. An update of the MOOC would go an awfully long way to making this functionality useful.

In the BLE Advertising tab, it seems to default to everything turned off. By turning bits on, it allows you run the code generation, and creates a variable "ad_data[]" int app_ble.c. This seems to replace the "manuf_data[]" variable used in the P2P server modes, but also used in the MOOC example on modify a BLE profile.

Unfortunately, trying to fill in the various entries on this tab cause the code generation to fail in a couple of different ways:

  1. If you include "AD_TYPE_SHORTENED_LOCAL_NAME", the generated entry in ad_data[] is "valueNotSetted, AD_TYPE_SHORTENED_LOCAL_NAME , 'T', 'E', 'S', 'T', '1', //Shortened name"

Looking at the other entries, it looks like the first value (which is valueNotSetted, and "Setted"? Really?) is actually the length of the entry plus 1, so it should be 5 in the CubeMX view, it does show "5" in the LENGTH field, but this doesn't make it into the code.

If you include AD_TYPE_ADVERTISING_INTERVAL, you can't change any of the settings (it is set to CFG_FAST_CONN_ADV_INTERVAL_MAX), the generation process seems to fail completely, although you don't get any outward error messages or feedback: In app_ble.c, 126 empty lines are empty, just after the file header, and the file ends with the following:

/**
 * Advertising Data
 */
uint8_t ad_data[21] = {
    2, AD_TYPE_TX_POWER_LEVEL, 0x1F /* 6dBm */, //Transmission Power
    9, AD_TYPE_COMPLETE_LOCAL_NAME, 'C', 'O', 'R', 'O', 'R', 'I', '0', '1',  //Complete name
    3, AD_TYPE_APPEARANCE, 0x00, 0x00 /* UNKNOWN_APPEARANCE */,
    3, AD_TYPE_ADVERTISING_INTERVAL,  0xA0, 0x
Expression res[2] is undefined on line 902, column 176 in stm32_wpan_ble_app_ble_c.ftl.
The problematic instruction:
----------
==> ${res[2]} [on line 902, column 174 in stm32_wpan_ble_app_ble_c.ftl]
----------
 
Java backtrace for programmers:
----------
freemarker.core.InvalidReferenceException: Expression res[2] is undefined on line 902, column 176 in stm32_wpan_ble_app_ble_c.ftl.
	at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
	at freemarker.core.Expression.getStringValue(Expression.java:118)
	at freemarker.core.Expression.getStringValue(Expression.java:93)
	at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.Environment.process(Environment.java:188)
	at freemarker.template.Template.process(Template.java:237)
	at com.st.microxplorer.codegenerator.CodeEngine.freemarkerDo(CodeEngine.java:277)
	at com.st.microxplorer.codegenerator.CodeEngine.genCode(CodeEngine.java:194)
	at com.st.microxplorer.codegenerator.CodeGenerator.generateOutputCode(CodeGenerator.java:3862)
	at com.st.microxplorer.codegenerator.CodeGenerator.generateSpecificCode(CodeGenerator.java:3357)
	at com.st.microxplorer.codegenerator.CodeGenerator.generateSpecificCodeFile(CodeGenerator.java:1297)
	at com.st.microxplorer.codegenerator.CodeGenerator.generateCodeFiles(CodeGenerator.java:1499)
	at com.st.microxplorer.codegenerator.CodeGenerator.generateDefaultConfig(CodeGenerator.java:7097)
	at com.st.microxplorer.codegenerator.CodeGenerator.generateCode(CodeGenerator.java:1133)
	at com.st.microxplorer.plugins.projectmanager.engine.ProjectBuilder.generateCode(ProjectBuilder.java:1768)
	at com.st.microxplorer.plugins.projectmanager.engine.ProjectBuilder.createCode(ProjectBuilder.java:1636)
	at com.st.microxplorer.plugins.projectmanager.engine.ProjectBuilder.createProject(ProjectBuilder.java:534)
	at com.st.microxplorer.plugins.projectmanager.engine.ProjectBuilder.createProject(ProjectBuilder.java:347)
	at com.st.microxplorer.plugins.projectmanager.engine.MainProjectManager.startGenerateCode(MainProjectManager.java:1339)
	at com.st.microxplorer.plugins.projectmanager.engine.MainProjectManager$3.onCommandEntered(MainProjectManager.java:217)
	at com.st.components.util.CommandLineManager$3.run(CommandLineManager.java:150)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

0693W000001rejLQAQ.jpg

Fundamentally, I have two questions:

  1. When can we expect a version of the Cube MCU package for the STM32WB55 that works for custom BLE profiles?
  2. When can we expect an update to the documentation/tutorials/MOOC that works with up-to-date tools?

There are other issues with the BLE setup (e.g. I can't define all 128 bits of a UUID, even I select it), but the above questions are more fundamental I think.

12 REPLIES 12
gada
Associate III

I am starting off with stm32wb nucleo board and the issues mentioned here are what I am facing as well. Could anyone from ST guide further as to what are the issues? I don't think they'll release stuff that is broken???

AClif
Associate III

I got an answer to another post (for some reason, the answer has disappeared), that gave an update schedule for the software chain that will, with any luck, fix some of the issues. I think week 30 is the 4th week in July (week beginning 20-Jul):

Cube1.5.0 => expected by week 30

new: Browsing of examples, CubeExpansion for CubeMX, DIY CubeExpansion

  CubeMX 6.0.0

  CubeIDE 1.4.0

  CubeProg 2.5.0

CubeFW - H7 V1.8.0, G4 V1.3.0, L5 V1.3.0, L4 V1.16.0, WB 1.8.0, MP1 Kernel updates

Hopefully an updated MOOC tutorial will follow, although looking at the release history, the BLE stuff has been different in Cube for over a year!

gada
Associate III

Thanks

KPenn.1
Associate II

I'm hitting the same problem. And I'm sure you've noticed that none of the example programs are built with templates compatible with any recent CubeFW releases. Unmodified code generated by CubeMX (without errors) should compile and run without error (even if it does nothing), but the fact that you need to add a few ISRs and calls the sequencer in the main loop just to get the darn thing to advertise properly is very concerning.

Last year the STM32WB55 was the only SoC with wireless copro on the market, but now Nordic (nRF5340), Maxim (MAX32666), and Cypress (PSoC 62-64) are all out with functionally identical products. For such a new market, the best development tools will win the day; get your head in the game, ST!

Chandler
Associate II

I second all of the above, having experienced it all exactly as detailed, after much banging my head against the wall. Fortunately, some kind souls had documented it above, so I just stopped when I found this thread. WHAT is the problem in their development department? I've been noticing that they have been throwing untested software out into the wild at an alarming rate (i.e., not just in this instance, with this one subset of their tools; this stuff is more widespread than some may realize). What a shame. If anyone at corporate is monitoring this thread, hear me: The number one --- and two and three -- rule of software development is "don't break the build". You boys had better get all in, or for your company's sake, get out of the software business. Users are going to move on.

MDaub.1
Associate III

I wonder if this is the same root cause that keeps me busy for the last 4 days banging my head against the wall...

Gtrei.11
Associate

same problem(s) here, any news...?

There was significant progress made in CubeMX v6.2.0 + STM32CubeWB_v1.11.0, in terms of generating a project that works out of the box. Since CubeMX v6.2.0 now handles the IPCC, you'll have to enable the peripheral and enable the associated NVIC interrupts. There's still a couple of the missing pieces though that didn’t make it in this version, so, with CubeMX v6.2.0, you still need to make the following changes manually in the code, if you were to generate a code project from the attached basic .ioc project:

1)      In main.c, add the UTIL_SEQ_Run( UTIL_SEQ_DEFAULT );  call in the main() while loop  + the #include "stm32_seq.h"

     #include "stm32_seq.h"

.

.

  /* Infinite loop */

  /* USER CODE BEGIN WHILE */

  while (1)

  {

    UTIL_SEQ_Run( UTIL_SEQ_DEFAULT );   

    /* USER CODE END WHILE */

2)    In stm32wbxx_it.c, modify RTC_WKUP_IRQHandler() to call HW_TS_RTC_Wakeup_Handler(); instead of HAL_RTCEx_WakeUpTimerIRQHandler(&hrtc);

void RTC_WKUP_IRQHandler(void)

{

 /* USER CODE BEGIN RTC_WKUP_IRQn 0 */

 /* USER CODE END RTC_WKUP_IRQn 0 */

 //HAL_RTCEx_WakeUpTimerIRQHandler(&hrtc); //Comment this call

 /* USER CODE BEGIN RTC_WKUP_IRQn 1 */

 HW_TS_RTC_Wakeup_Handler(); //Add this call

 /* USER CODE END RTC_WKUP_IRQn 1 */

}

The next release of CubeMX is expected to generate these sections of code automatically so the user doesn't have to add them manually.

Not applicable

Yes its common don't worry about it you can see here some points about its guidance hopefully this guide will work for you.