Platform.ini for STM32L431RCT6

Hello!

I started my work with the STM32F401RC and everythink worked fine. But now I need to switch to the STM32L431RCT6. I have a custom board.

My problem is: I did not find the correct configuration for this processor an board.

Has someone a hint for me for the correct configuration?

Thanks and regards
Hans

platform-ststm32 does currently not have a board definition for it, but you can construct one from close ones like a stm32l432.

E.g., create a new project for any microcontroller and any framework, then create

boards/genericSTM32L431RC.json

{
  "build": {
    "cpu": "cortex-m4",
    "extra_flags": "-DSTM32L4 -DSTM32L431xx",
    "f_cpu": "80000000L",
    "mcu": "stm32l431rct6",
    "product_line": "STM32L431xx",
    "variant": "STM32L4xx/L431R(B-C)(I-T-Y)"
  },
  "debug": {
    "default_tools": [
      "stlink"
    ],
    "jlink_device": "STM32L431RC",
    "onboard_tools": [
      "stlink"
    ],
    "openocd_target": "stm32l4x",
    "svd_path": "STM32L4x1.svd"
  },
  "frameworks": [
    "arduino",
    "cmsis",
    "stm32cube",
    "libopencm3"
  ],
  "name": "Generic STM32L431RC",
  "upload": {
    "maximum_ram_size": 65536,
    "maximum_size": 262144,
    "protocol": "stlink",
    "protocols": [
      "jlink",
      "cmsis-dap",
      "stlink",
      "blackmagic",
      "mbed"
    ]
  },
  "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32l431rc.html",
  "vendor": "ST"
}

And platformio.ini

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

This compiles with a simple blinky example with src/main.cpp

#include <Arduino.h>
#define LED PC13
void setup() {
    pinMode(LED, OUTPUT);
}

void loop() {
    digitalWrite(LED, HIGH);
    delay(1000);
    digitalWrite(LED, LOW);
    delay(1000);
}

to

Linking .pio\build\genericSTM32L431RC\firmware.elf
Checking size .pio\build\genericSTM32L431RC\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   1.9% (used 1244 bytes from 65536 bytes)
Flash: [          ]   4.8% (used 12532 bytes from 262144 bytes)
Building .pio\build\genericSTM32L431RC\firmware.bin
======================= [SUCCESS] Took 7.06 seconds =======================