0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ボード定義を作ってみた

Posted at

macOS 12.7.6
VScode 1.93.1
PlatformIO 3.3.3
WeAct STM32G031CoreBoard

ボード定義がなかったので作ってみた。

プロジェクトフォルダーで boards/ボード定義ファイル.json を作ります。

image.png

genericSTM32G031F6P6.json
{
  "build": {
    "core": "stm32",
    "cpu": "cortex-m0plus",
    "extra_flags": "-DSTM32G0 -DSTM32G0xx -DSTM32G031xx",
    "f_cpu": "64000000L",
    "framework_extra_flags": {
      "arduino": "-D__CORTEX_SC=0"
    },
    "mcu": "stm32g031f6p6",
    "product_line": "STM32G031xx",
    "variant": "STM32G0xx/G031F(4-6-8)P_G031Y8Y_G041F(6-8)P_G041Y8Y"
  },
  "debug": {
    "default_tools": [
      "stlink"
    ],
    "jlink_device": "STM32G031F6",
    "onboard_tools": [
      "stlink"
    ],
    "openocd_target": "stm32g0x",
    "svd_path": "STM32G031.svd"
  },
  "frameworks": [
    "arduino",
    "cmsis",
    "stm32cube"
  ],
  "name": "GENERIC_G031F6PX",
  "upload": {
    "maximum_ram_size": 8192,
    "maximum_size": 32768,
    "protocol": "stlink",
    "protocols": [
      "blackmagic",
      "cmsis-dap",
      "dfu",
      "jlink",
      "serial",
      "stlink",
      "mbed"
    ]
  },
  "url": "https://www.st.com/ja/microcontrollers-microprocessors/stm32g031f6.html",
  "vendor": "ST"
}

似た機種の定義をコピーして修正しました。
一回ではうまくいきませんでした。末尾参考URL

    "mcu": "stm32g031f6p6",

例えばここは stm32G031 ではなく stm32g031f6 でもない。

platformio.ini
[env]

platform = ststm32
board = genericSTM32G031F6P6

platform_packages =
  ; latest openOCD from PlatformIO Package Registry
  tool-openocd

  ; source code of ST-Link
  ;tool-stlink-source @ https://github.com/texane/stlink.git

framework = arduino

[env:genericSTM32G031F6P6_mac]

debug_tool = stlink
debug_init_break = tbreak setup
build_type = debug
debug_server =
  /Users/numeru55/.platformio/packages/tool-openocd/bin/openocd
  -s /Users/numeru55/.platformio/packages/tool-openocd/openocd/scripts
  -f interface/stlink.cfg
  -c "transport select hla_swd"
  -c "set CPUTAPID 0x0bc11477"
  -f target/stm32g0x.cfg
  -c "reset_config none"


[env:genericSTM32G031F6P6_win]

debug_tool = stlink
debug_init_break = tbreak setup
build_type = debug
debug_server =
  C:\Users\numeru55\.platformio\packages\tool-openocd\bin/openocd.exe
  -s C:\Users\numeru55\.platformio\packages\tool-openocd\openocd\scripts
  -f interface/stlink.cfg
  -c "transport select hla_swd"
  -c "set CPUTAPID 0x0bc11477"
  -f target/stm32g0x.cfg
  -c "reset_config none"

WinとMacでフォルダーの指定が異なりましたので、書き分けました。
互換品のSTLINKを使う前提です。

適当なソースを準備します。

main.cpp
#include <Arduino.h>

void setup() {
  pinMode(PA4,OUTPUT);
}

void loop() {
  digitalWrite(PA4,HIGH); // off
  delay(1000);
  digitalWrite(PA4,LOW); // on
  delay(100);
}

[env:genericSTM32G031F6P6_mac] を選び、コマンドパレットで Platformio Start debug を選ぶとデバッグできました!

image.png

ボードのBOOTボタンやRESETボタンは押す必要がありません。

参考 URL

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?