Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the STM32U0 #798

Open
chintal opened this issue Sep 8, 2024 · 1 comment
Open

Add support for the STM32U0 #798

chintal opened this issue Sep 8, 2024 · 1 comment

Comments

@chintal
Copy link

chintal commented Sep 8, 2024

ST has recently launched a series of low cost ULP MCUs - STM32U0. They've also released Nucleo boards for one of the more capable variants : NUCLEO-U083RC.

I have managed to get my hands on a NUCLEO-U083RC. I intend to use this board baremetal, with ST Cube Framework code manually added where needed.

  1. Is there any way I can add the board definition for this Nucleo for myself? As far as I can tell, I only really need it to set the correct flags for the MCU and configure it to use the Nucleo's on-board STLink debugger - or is there something I'm missing? (I don't intend to use any framework)

  2. What would be needed to add this support to platformio itself? Since I have the board, I'm open to trying to port from one of the other nucleos. The reason I'm concerned is that the version of the ST Cube framework included in platform IO is old enough for Cube MX generated code to error out pretty easily, so it might not include support for the STM32U0 at all.

@chintal
Copy link
Author

chintal commented Sep 17, 2024

I've created a nucleo_u083rc.json using nucleo_g071rb.json as a template.

{
  "build": {
    "core": "stm32",
    "cpu": "cortex-m0plus",
    "extra_flags": "-DSTM32U0 -DSTM32U0xx -DSTM32U083xx",
    "f_cpu": "64000000L",
    "framework_extra_flags": {
      "arduino": "-D__CORTEX_SC=0"
    },
    "mcu": "stm32u083rct6",
    "product_line": "STM32U083xx",
    "variant": "STM32U0xx/U083RC"
  },
  "debug": {
    "default_tools": [
      "stlink"
    ],
    "jlink_device": "STM32U083RC",
    "onboard_tools": [
      "stlink"
    ],
    "openocd_target": "stm32u0x",
    "svd_path": "STM32U083.svd"
  },
  "frameworks": [
    "arduino",
    "cmsis",
    "libopencm3",
    "stm32cube",
    "zephyr"
  ],
  "name": "Nucleo U083RC",
  "upload": {
    "maximum_ram_size": 40960,
    "maximum_size": 262144,
    "protocol": "stlink",
    "protocols": [
      "stlink",
      "jlink",
      "cmsis-dap",
      "blackmagic",
      "mbed"
    ]
  },
  "url": "https://www.st.com/en/evaluation-tools/nucleo-u083rc.html",
  "vendor": "ST"
}

I expect none of the frameworks are functional.

Using the current version of ST CubeMX to provide CMSIS, STM32U0xx_HAL_Driver, startup file, and system files seems to build using toolchain-gccarmnoneeabi@>1.120000.0 with no framework, though I don't know yet if it works as expected. Manually writing the generated elf file using STM32CubeProgrammer has not yet resulted in a blinking LED. I expect it's likely there's a mistake in the code somewhere, since I almost blindly retargeted code written for STM32F4. I will try with a minimal blink example using the ST provided HAL over the next few days.

The svd file does not exist and the openocd target (stm32u0x.cfg) does not exist, so flashing and debugging this chip from platformIO is presently not viable.

STM32CubeIDE does include a version of openocd which includes stm32u0x.cfg and can connect to the chip. Unfortunately, that file is entirely different structurally from the files used in vanilla openocd and platformio. I don't know if platformIO will be able to debug using the ST provided stm32u0x.cfg. A naive check by just dumping the cfg file into the platformio openocd folder has not worked, even though the two openocd binaries have the same major version (0.12.0-01004... vs 0.12.0+dev-00597). The ST file looks for and does not find gdb_helper.tcl when used with platformIO's tool-openocd.

There appears to be a patch for adding support in upstream openocd here. I have not yet attempted to build it. I plan to try out the approach discussed here for the moment, and see how that goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants