Help adding support for wio-e5 using stm32cube framework

Hi, I’m trying to add support to the wio e5 module using the stm32cube framework, in order to do so I followed the suggestion in the following thread How to use STM32WL55JC under STM32Cube framework. Specifically I did the following.

1.- Copy the ststm32 repo to the platforms folder inside platformio folder .platform in my case since i’m using ubuntu 22
2.- Added a file called wioe5.json inside the boards folder with the following code:

{
  "build": {
    "core": "stm32",
    "cpu": "cortex-m4",
    "extra_flags": "-DSTM32WLxx -DSTM32WLE5xx",
    "f_cpu": "32000000L",
    "mcu": "stm32wle5jc",
    "product_line": "STM32WLE5xx"
  },
  "debug": {
    "default_tools": [
      "stlink"
    ],
    "jlink_device": "STM32WLE5JC",
    "onboard_tools": [
      "stlink"
    ],
    "openocd_target": "stm32wlex",
    "svd_path": "STM32WLE5x_CM4.svd"
  },
  "frameworks": [
    "stm32cube"
  ],
  "name": "Wio E5",
  "upload": {
    "maximum_ram_size": 65536,
    "maximum_size": 262144,
    "protocol": "stlink",
    "protocols": [
      "stlink"
    ]
  },
  "url": "https://wiki.seeedstudio.com/LoRa-E5_STM32WLE5JC_Module",
  "vendor": "Seeedstudio"
}

3.- Modified the ststm32’s platform.json file adding the following entry in the packages section:

"framework-stm32cubewl": {
      "type": "framework",
      "optional": true,
      "owner": "platformio",
      "version": "symlink:///home/felipe/.platformio/packages/STM32CubeWL"
    },

4.- Cloned the STM32CubeWL repo inside my packages folder inside the platformio folder.
5.- Added a file called package.json to the cloned STM32CubeWL folder with the following contents.

{
  "description": "STM32Cube is a set of tools and embedded software bricks available free of charge to enable fast and easy development on the STM32 platform (STM32CubeWL MCU Firmware Package)",
  "keywords": [
    "framework",
    "hal",
    "stm32",
    "st"
  ],
  "name": "framework-stm32cubewl",
  "version": "1.26.2",
  "homepage": "https://github.com/STMicroelectronics/STM32CubeWL"
}

6.- Created a blank pio proyect with the following platform.ini file


[env:wioe5]
platform = ststm32
board = wioe5
framework = stm32cube

7.- Tried to run pio run and get the following output

pio run -v
Processing wioe5 (platform: ststm32; board: wioe5; framework: stm32cube)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tool Manager: Installing symlink:///home/felipe/.platformio/packages/STM32CubeWL
Tool Manager: framework-stm32cubewl@1.26.2 has been installed!
AttributeError: 'PosixPath' object has no attribute 'read_text':
  File "/home/felipe/anaconda3/lib/python3.9/site-packages/platformio/builder/main.py", line 32:
    from platformio.platform.base import PlatformBase
  File "/home/felipe/anaconda3/lib/python3.9/site-packages/platformio/platform/base.py", line 17:
    import semantic_version
  File "/home/felipe/anaconda3/lib/python3.9/site-packages/semantic_version/__init__.py", line 14:
    __version__ = version("semantic_version")
  File "/home/felipe/anaconda3/lib/python3.9/importlib/metadata.py", line 569:
    return distribution(distribution_name).version
  File "/home/felipe/anaconda3/lib/python3.9/importlib/metadata.py", line 266:
    return self.metadata['Version']
  File "/home/felipe/anaconda3/lib/python3.9/importlib/metadata.py", line 254:
    self.read_text('METADATA')
  File "/home/felipe/anaconda3/lib/python3.9/importlib/metadata.py", line 529:
    return self._path.joinpath(filename).read_text(encoding='utf-8')

I don’t know what causes this error, reading in the internet it seems that it appears in other projects non related to platformio, the closer I read is that it was caused by trying to directly open a string of a path as seen in a post that will be added next since the forum only lets me add 2 links. Any suggestions or help will be very much appreciated. Thanks!

Here it is the wioE5 wiki and the related issue

Thanks in advance!

Anaconda has been associated with countless problems here. Can you run it in VSCode with the PlatformIO extension that has the isolated python environment?

Thanks for the quick answer, I did as you told me and it seems that it’s working now but now i get the following error

Processing wioe5 (platform: ststm32; board: wioe5; framework: stm32cube)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/wioe5.html
PLATFORM: ST STM32 (15.6.0) > Wio E5
HARDWARE: STM32WLE5JC 32MHz, 64KB RAM, 256KB Flash
DEBUG: Current (stlink) On-board (stlink)
PACKAGES: 
 - framework-stm32cubewl @ 1.26.2 
 - tool-ldscripts-ststm32 @ 0.2.0 
 - toolchain-gccarmnoneeabi @ 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 12 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_adc.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_adc_ex.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_comp.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_cortex.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_crc.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_crc_ex.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_cryp.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_cryp_ex.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_dac.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_dac_ex.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_dma.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_dma_ex.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_exti.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_flash.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_flash_ex.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_gpio.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_gtzc.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_hsem.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_i2c.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_i2c_ex.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_i2s.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_ipcc.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_irda.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_iwdg.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_lptim.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_pka.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_pwr.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_pwr_ex.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_rcc.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_rcc_ex.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_rng.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_rng_ex.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_rtc.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_rtc_ex.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_smartcard.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_smartcard_ex.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_smbus.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_smbus_ex.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_spi.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_spi_ex.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_subghz.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_tim.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_tim_ex.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_uart.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_uart_ex.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_usart.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_usart_ex.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_hal_wwdg.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_ll_adc.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_ll_comp.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_ll_crc.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_ll_dac.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_ll_dma.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_ll_exti.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_ll_gpio.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_ll_i2c.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_ll_lptim.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_ll_lpuart.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_ll_pka.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_ll_pwr.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_ll_rcc.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_ll_rng.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_ll_rtc.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_ll_spi.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_ll_tim.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_ll_usart.o
Compiling .pio/build/wioe5/FrameworkHALDriver/Src/stm32wlxx_ll_utils.o
Compiling .pio/build/wioe5/FrameworkCMSISDevice/gcc/startup_stm32wle5xx.o
Compiling .pio/build/wioe5/FrameworkCMSISDevice/system_stm32wlxx.o
Archiving .pio/build/wioe5/libFrameworkCMSISDevice.a
Indexing .pio/build/wioe5/libFrameworkCMSISDevice.a
Linking .pio/build/wioe5/firmware.elf
.pio/build/wioe5/libFrameworkCMSISDevice.a(startup_stm32wle5xx.o): In function `LoopFillZerobss':
(.text.Reset_Handler+0x32): undefined reference to `main'
collect2: error: ld returned 1 exit status
*** [.pio/build/wioe5/firmware.elf] Error 1

I just noticed that there is no main.c file generated by platformio, what should I include, a project that already compiles in the stm32cube ide perhaps?

I added a main.cpp file in the src folder and inside I just added the following code now it compiles no problem!

int main(void){
    return 0;
}

I’ll update any errors I find, but this seems as a good way to work in platformio with the wio e5 module.