cancel
Showing results for 
Search instead for 
Did you mean: 

Compile error for STM32G071RB Nucleo with UCPD and GUI interface enabled

NathanWolcott
Associate III

While trying to test out the USB-PD middleware, I generated a project for the STM32G071RB Nulceo dev board with Tracer EMB and GUI interface enabled. Generating the code works fine however, I'm getting a compile error that traces back to the FLASH_SIZE macro in stm32g071xx.h

If I turn off the GUI module, the error goes away.

I was able to work around the problem by changing the FLASH_SIZE macro to just be the hard-coded size of the flash on my part, but this isn't a good solution.

The weird thing is, once I got the project to compile and load, I was able to past the original macro expression into the debugger expression evaluator and it came back with the correct answer (0x20000), so it doesn't seem to be a simple syntax error.

Here is the error:

In file included from ../Drivers/CMSIS/Device/ST/STM32G0xx/Include/stm32g0xx.h:117,
                 from ../Core/Inc/usbpd_gui_memmap.h:31,
                 from ../Utilities/GUI_INTERFACE/bsp_gui.h:23,
                 from ../Utilities/GUI_INTERFACE/bsp_gui.c:22:
../Drivers/CMSIS/Device/ST/STM32G0xx/Include/stm32g071xx.h:640:34: error: operator '*' has no left operand
  640 | #define FLASH_SIZE            (((*((uint32_t *)FLASHSIZE_BASE)) & (0x00FFU)) << 10U)
      |                                  ^
../Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash.h:889:42: note: in expansion of macro 'FLASH_SIZE'
  889 | #define FLASH_BANK_SIZE                 (FLASH_SIZE)   /*!< FLASH Bank Size */
      |                                          ^~~~~~~~~~
../Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash.h:893:42: note: in expansion of macro 'FLASH_BANK_SIZE'
  893 | #define FLASH_PAGE_NB                   (FLASH_BANK_SIZE/FLASH_PAGE_SIZE) /* Number of pages per bank */
      |                                          ^~~~~~~~~~~~~~~
../Core/Inc/usbpd_gui_memmap.h:55:34: note: in expansion of macro 'FLASH_PAGE_NB'
   55 | #define INDEX_PAGE              (FLASH_PAGE_NB - 1u)                           /* Index of latest page */
      |                                  ^~~~~~~~~~~~~
../Core/Inc/usbpd_gui_memmap.h:57:48: note: in expansion of macro 'INDEX_PAGE'
   57 | #define ADDR_FLASH_LAST_PAGE    (FLASH_BASE + (INDEX_PAGE * FLASH_PAGE_SIZE))  /* Base @ of latest page */
      |                                                ^~~~~~~~~~
../Core/Inc/usbpd_gui_memmap.h:60:40: note: in expansion of macro 'ADDR_FLASH_LAST_PAGE'
   60 | #define GUI_FLASH_MAGIC_NUMBER         ADDR_FLASH_LAST_PAGE
      |                                        ^~~~~~~~~~~~~~~~~~~~
../Utilities/GUI_INTERFACE/bsp_gui.c:24:5: note: in expansion of macro 'GUI_FLASH_MAGIC_NUMBER'
   24 | #if GUI_FLASH_MAGIC_NUMBER
      |     ^~~~~~~~~~~~~~~~~~~~~~

Has anybody else seen this error?

1 ACCEPTED SOLUTION

Accepted Solutions
Yohann M.
ST Employee

Dear @NathanWolcott​ 

In the G0 package V1.4.0, this error should be linked to an issue in bsp_gui.c.

Please try to replace

#if GUI_FLASH_MAGIC_NUMBER

by

#if defined(GUI_FLASH_MAGIC_NUMBER)

Regards,

Yohann

View solution in original post

5 REPLIES 5
Yohann M.
ST Employee

Dear @NathanWolcott​ 

In the G0 package V1.4.0, this error should be linked to an issue in bsp_gui.c.

Please try to replace

#if GUI_FLASH_MAGIC_NUMBER

by

#if defined(GUI_FLASH_MAGIC_NUMBER)

Regards,

Yohann

Thanks Yohann!

I'm actually using G0 package V1.4.1 but apparently the problem is the same for both versions.

Your suggestion fixed the problem. I assume I will have to manually change these macros every time I regenerate the project?

Yohann M.
ST Employee

Dear @NathanWolcott​ 

This issue has been logged into our side. For sure, it will fix in next G0 maintenance release.

Btw, we just delivered a X-CUBE-TCPP V2.2.0 package under GitHub, which already includes this fix.

Feel free to have a look at this release!

Regards,

Yohann

Hi @Yohann M.​ , I downloaded the new x-cube-tcpp package but I can't seem to find any instructions on how to install it. I tried to use the CubeMx import "from local" button in the software packages manager window but it gives an error that it doesn't recognize the package. I guess it's a stupid question, but how am I supposed to use this package with cubeIDE/cubeMX?

Thanks,

Nathan

Hi @NathanWolcott​ 

This package is not part of the X-CUBE package downloaded directly through CubeMX.

You should open directly IOC files provided in each USB-PD application like:

https://github.com/STMicroelectronics/x-cube-tcpp/blob/main/Projects/NUCLEO-G071RB/Applications/USB_PD/SNK1M1_Sink/SNK1M1_Sink.ioc

When you open it CubeMX, you should see that it is linked to your package you uploader on your laptop like this:

0693W000008xrRAQAY.jpg 

Regards,

Yohann