Showing results for 
Search instead for 
Did you mean: 

How to import STM32CubeWL repository projects onto different packages

ST Employee

Problem formulation

Examples provided by ST may not fit your specific STM32WL or other STM32 family chips in a given package. As a result, you may be in a situation where you cannot use the full potential of the STM32CubeMX software with your chip.

Solution options

There are three solution options for this case. In this article, case number 3 is described below with a step-by-step guide. 

  1. If it is only a matter of a different package, keep the project as is and simply pretend that you are using the original chip. This may also work with some basic functionality or peripherals while keeping the same family.

    This solution is simple and keeps the STM32CubeMX code-generation functionality
    Disadvantage: You may not see the pins that you need, or you may see pins that are not present on your package.

  2.  Create an empty project and redo the example with STM32CubeMX.

    Advantage: No additional code is generated, and the project is under your control.
    Disadvantage: More work is required to get the original example running. You may lose the STM32CubeMX code-generation ability due to the manual linking in the project.

  3. Import the example into the empty project using the built-in STM32CubeMX functionality.

    Advantage: Files are copied and linked to your specific chip in a couple of clicks.
    Disadvantage: You may still need to adjust the pinout in case of a smaller package.


This guide provides a step-by-step instruction for the third case. Generally, the STM32CubeMX import function can be used on any STM32 example but the viability may vary. The model situation for this guide is that the STM32WLE5CC (single-core, QFN package) was chosen as an MCU for a project. The example project selected is the LoRaWAN® end node.

However, the ST32CubeWL only contains projects for STM32WL55-Nucleo with an STM32WL55JC (dual-core, BGA package). The standalone STM32CubeMX is used to show the import functionality. Once the import is complete, you can continue in STM32CubeIDE as in this guide or any other supported IDE (Keil®, IAR).


Step-by-step guide for case 3

  1. Open STM32CubeMX (standalone) and create a new project for QFN STM32WLE5CC.
  2. Navigate to File -> Import project and navigate to the .ioc file of the Nucleo End_node  "\STM32Cube_FW_WL_V1.3.0\Projects\NUCLEO-WL55JC\Applications\LoRaWAN\LoRaWAN_End_Node".
  3. Import all configurations using the automatic import feature and click on "Try import."


  1. Once the import is complete, the configuration for the QFN package should be the same as for the BGA package.
  1. Enable "Alarm A" for RTC and ensure that all necessary interrupts are enabled in NVIC RTC, UART, and sub-GHz.


  1. In the project settings, provide a name in the "Project options". and select an IDE to generate for (e.g., STM32CubeIDE).


  1. Ensure that STM32CubeMX is set to "copy only the necessary library files". This means the project is linked to libraries copied within the project and not to the STM32CubeWL repository. By doing so, the project is standalone.


  1. Generate the code. The generator may report some pins that cannot be generated. These warnings can be ignored as they can be redefined manually in main.h.


  1. Once the project is generated, open it in an IDE (in this case CubeIDE). If you compile now, it will report missing BSP (board support package – a simple library for the specific Nucleo board that the example was made for).


  1. Manually copy the BSP from the STM32CubeWL repository \Drivers\BSP\STM32WLxx_Nucleo into the project \Drivers folder. To link .c files in STM32CubeIDE, create a BSP folder in the STM32CubeIDE project structure. Drag and drop (link only, the file is already copied manually) the .c files from \WLE5_import_End_Node\Drivers\BSP\STM32WLxx_Nucleo.


  1. To link the .h files, open the project properties, C/C++ General, Paths and Symbols. Add ../Drivers/BSP/STM32WLxx_Nucleo



  2. Copy the definitions main.h from the example STM32Cube_FW_WL_V1.3.0\Projects\NUCLEO-WL55JC\Applications\LoRaWAN\LoRaWAN_End_Node. Keep in mind that any modification outside of the user code section can be overwritten by the next STM32CubeMX code generation.  Therefore, a #if 0 trick can be used. 



  3. Copy the lora_app.c contents as the STM32CubeMX provides only an application skeleton - LoRaWAN_End_Node\LoRaWAN\App\lora_app.c. Finally copy the \LoRaWAN_End_Node\Core\Src\timer_if.c contents to provide the RTC interface to the virtual timer.

  4. At this point, the project should be able to compile successfully and can be even run on a WL55-Nucleo.FilipSCHWANK_32-1702398638712.png


  5. For the Import function of STM32CubeMX, the job is done.

Next steps

The example project is now imported onto an empty QFN package project. At this point, it is possible to run the example with a WL55-Nucleo. However, to run the project on your own PCB, the pinout must be adjusted. The following guidelines should help you bring up the full project on your device:

  • In \Drivers\BSP\STM32WLxx_Nucleo\stm32wlxx_nucleo_radio.h

#define RF_SW_CTRLX_[PIN|PORT|CLK] - redefine the RF switches to match the layout. According to the truth table in the Nucleo schematic, it should be enough to operate CTRL2. If the RF switch is not tied to VDD and is controlled by a pin, it should also be reflected by the CTRL pins. You can also rewrite and simplify the stm32wlxx_nucleo_radio.c functions that operate the switch, if that would be a better solution for you.

  • In \Drivers\BSP\STM32WLxx_Nucleo\stm32wlxx_nucleo.h

Check for any pin collisions with your design. If available on your PCB, you can also have the buttons/LEDs active as on the Nucleo. Also, UART2 is used for communication through the End_Node on PA2, PA3. Check that this is available on your PCB or reconfigure to work with the UART available.

  • In \LoRaWAN\Target\radio_conf.h

DCDC_ENABLE - based on whether you want to use SMPS or LDO.

XTAL_DEFAULT_CAP_VALUE - if Crystal is used instead of TCXO, this should be the tuning for the internal capacitor bank. For the initial testing, it should be enough to go with the default, but it should be tuned to provide the correct frequence. One can use PA8 with MCO "master clock output" to measure the frequency and tune it using the capacitor bank.  For this reason, there should be no external capacitors around the HSE. If TCXO is used, this part is not used.


  • In \LoRaWAN\Target\radio_board_if.h

IS_DCDC_SUPPORTED - board support for SMPS/LDO.

IS_TCXO_SUPPORTED - 1 if TCXO mounted, 0 for Crystal.

  • In \Core\Inc\sys_conf.h

APP_LOG_ENABLED - leave enabled for traces on UART.

DEBUGGER_ENABLED - if you are porting the firmware to your PCB, set to 1 so that the debugger can connect in low power modes. At this stage, it is useful to enable the debugger and run a debug session to go step by step with the porting. As an example, you could see through the debugger that you are stuck in clock initialization.  In this case, you should focus on the HSE/LSE configuration. For current consumption measurements, it should be disabled.

LOW_POWER_DISABLE - this uses sleep instead of stop modes in case there are issues with low power modes.

Congratulations! You have successfully imported an example project onto an empty QFN package project and adjusted the pinout to run the project on your own PCB. Furthermore, how to adjust the pinout to run the project on your own device. We hope that this guide has been helpful in showing you how to import an example project using STM32CubeMX.  

If you have any further questions or need additional assistance, refer to the STMicroelectronics website, create a post in the ST Community, or contact our technical support team. Happy coding!


Version history
Last update:
‎2024-01-03 09:21 AM
Updated by: