Custom board definition STM32L431RC

I’m trying to make a project for a new board based on an stm32l431rct6 but it won’t compile. I’ve generated an empty platformio project in CLion so there is just an empty main function.

The first issue I’m hitting is this and then I get tons of errors about stdint types that are not defined:

Compiling .pio/build/genericSTM32L431RC/FrameworkHALDriver/Src/stm32l4xx_hal_adc.o
In file included from /home/simon/.platformio/packages/framework-stm32cubel4/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_def.h:30:0,
from /home/simon/.platformio/packages/framework-stm32cubel4/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_rcc.h:29,
from /home/simon/.platformio/packages/framework-stm32cubel4/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_conf.h:253,
from /home/simon/.platformio/packages/framework-stm32cubel4/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal.h:30,
from /home/simon/.platformio/packages/framework-stm32cubel4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c:36:
/home/simon/.platformio/packages/framework-stm32cubel4/Drivers/CMSIS/Device/ST/STM32L4xx/Include/stm32l4xx.h:176:3: error: #error “Please select first the target STM32L4xx device used in your application (in stm32l4xx.h file)”
#error “Please select first the target STM32L4xx device used in your application (in stm32l4xx.h file)”
^~~~~

The platformio.ini

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

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

The board definition. I suspect I’ve done something wrong here as I’ve just copied one of my previous definitions and just replaced values based on guessing. I haven’t found great documentation for the attributes here and what values are valid.

{
  "build": {
    "core": "stm32",
    "cpu": "cortex-m4",
    "extra_flags": "-DSTM32L431xC",
    "f_cpu": "80000000L",
    "mcu": "stm32l431rct6",
    "product_line": "STM32L431xC"
  },
  "debug": {
      "jlink_device": "STM32L431RC",
      "openocd_target": "stm32l4x",
      "svd_path": "STM32L431.svd"
  },
  "frameworks": [
      "stm32cube",
      "cmsis"
  ],
  "name": "Generic STM32L431RC (64k RAM. 256k Flash)",
  "upload": {
    "maximum_ram_size": 65535,
    "maximum_size": 262144,
    "protocol": "stlink",
    "protocols": [
      "jlink",
      "stlink",
      "cmsis-dap"
    ]
  },
  "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32l4x1.html",
  "vendor": "Generic"
}

Any help is much appreciated

Look at

where in

are you defining the device class as needed by the STM32HAL? There needs to be -DSTM32L431xx additionally in there.

1 Like

Thanks, that was the issue. I realize now the error message was actually quite helpful, I was just too tired to realize