cancel
Showing results for 
Search instead for 
Did you mean: 

Bug found in CubeMX 6.12.0

Bill Dempsey
Senior

Hi

Testing CubeMX 6.12.0 and found a bug.  This may exist in other editions.

 

The code generator improperly places the user code comments in the final while(1) loop.  This causes MX (and its integration into IDE) to delete all user code.  While testing in IDE, the correct comments will prevent the code from getting deleted.  Please see a snip from CubeMX code generator below:

========THIS IS WHAT CUBEMX 6.12.0 GENERATES =========

/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */

 

===========THIS IS WHAT IT *should* GENERATE ========

/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE BEGIN 3 */

/* USER CODE END 3 */
}
/* USER CODE END WHILE */

 

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

Can you please address this ASAP?  Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

I don't think there's a bug here. Code within USER CODE blocks is not touched. It makes no sense to allow USER CODE blocks to be nested.

What code did you write that it deleted that you think it should not have? Lots of places to write code inside and outside of the main loop:

/* USER CODE BEGIN WHILE */
// code here is not deleted
while (1)
{
  // code here is not deleted
/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */
  // code here is not deleted
}
/* USER CODE END 3 */

 L 

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

3 REPLIES 3
TDK
Guru

I don't think there's a bug here. Code within USER CODE blocks is not touched. It makes no sense to allow USER CODE blocks to be nested.

What code did you write that it deleted that you think it should not have? Lots of places to write code inside and outside of the main loop:

/* USER CODE BEGIN WHILE */
// code here is not deleted
while (1)
{
  // code here is not deleted
/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */
  // code here is not deleted
}
/* USER CODE END 3 */

 L 

If you feel a post has answered your question, please click "Accept as Solution".
KnarfB
Principal III

@TDK is absolutely right here: The  USER CODE ... WHILE block gives you a chance to add some initialization before the loop, the USER CODE ...3 block gives a chance to increment loop counters... etc at the end.

Indeed, I have seen generated code for periodic housekeeping inbetween both user code blocks, like when X-CUBE-BLE1 middleware is added:

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */

  MX_BlueNRG_MS_Process();
    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */

hth

KnarfB

 

Ahhh,  I see your point.  I was focused on "inside the braces" which worked only when I did my change but you are right there would be no point to nest...I see the "END WHILE" occurring *after* the closing brace so that's what threw me off.