Howto select STM32C011 MCU?

As of PlatformIO Registry STM32C011 support is listed.
But whatever I try, I’m to untalented to get support for it.

Whatever I do, I always get “UnknownBoard” error.
Also pio pkg exec --package "platformio/framework-arduinoststm32" -- pio boards doesn’t list any STM32C011 MCU :frowning:

Any suggestions?

There is indeed no board definition for it and the only issue about it was closed prematurely (https://github.com/search?q=repo%3Aplatformio%2Fplatform-ststm32+stm32c0+&type=issues).

Which C011 chip or board are we talking about exactly?

Quite thanks for replying!

Good to know that I didn’t missed to read some docs :wink:

It’s a custom designed board with STM32C011F6P6 without external xtal/osc.

Assuming you’re running Windows, can I ask you to test this project?

It compiles for a generic STM32C011F6P6 with no clock requirements. I had to add an updated version of OpenOCD into it because PlatformIO’s 1 year old version did not have STM32C0x support. Albeit C++ (register) warnings from the STM32HAL, it compiles fine.

Hurray, quick as always!! :wink: Thanks a lot!!

Unfortunately I dropped Windows approx. 15 years ago :innocent:.

However, it also compiles well on my Linux (debian 12.x) machine (with a lot warnings related to clock, HAL, …).

Unfortunately the board just get produced and I expect to receive it earliest next week. So I can’t test right now :frowning:

BUT: Many thanks for your quick support!! I can go on now with development.

The warning about the clock were actually fixed some time ago https://github.com/stm32duino/Arduino_Core_STM32/commit/75bda51e7c6d79415326ac43a199ee36200d93a1, I tracked that down. But there hasn’t been a new stable release since then by STM32Duino.

This seems important, so I did just include the current git commit version manually and added a surpression for -Wregister warnings to not spam the output. Now it builds cleanly. (Git project updated)

The issues about -Wregister warnings were raised in

Thank you very much!! :heart_eyes:

In between I received my custom boards with the STM32C011F6 and can confirm that it’s working well! :+1:

However, I’ve a problem remapping PA9/PA11 and PA10/PA12 to get USART1 on pin 16 (TX) and 17 (RX). Already tried some stuff but need to confess that I miss some generic understanding.

What I tried/understood in general is, that I need to remap those pins, which I tried via:

SYSCFG->CFGR1 |= 0b11000; // Remap PA12 to PA10 and PA11 to PA9

and than expected to get usart1 i.e. via:

HardwareSerial hostSerial(PA10, PA9);

or

HardwareSerial hostSerial(PA12, PA11); ?!?

But my code always freeze at the moment where the handler get attached (but work flawless when using i.e. USART2).

Unfortunately I didn’t found any useful docs how the remapping is handled in stm32duino :grimacing:. Yes I know “code is doc” :innocent:, but that’s the part where I need to admit my personal limits :innocent:

Close! It should be

HardwareSerial hostSerial(PA10_R, PA9_R);

for the alternative (remapped) pins. That uses the int, int constructor. But you can also use the constructor with the PinName, PinName types, that would be

HardwareSerial hostSerial(PA_10_R,  PA_9_R);

You can see that in list of available int type pins

that get remapped to PinName type pins by using them as index in this array

And then the peripheral info is retrieved by searching these arrays for an entry that has the matching PinName type pin

The pin_function specifically then detects that | PREMAP macro for specific pins and calls

Also, if the hostSerial is supposed to be the main Serial object, you can take advantage of the overridable macros that select the instance and pins for that because

So you can have

build_flags =
  -DSERIAL_UART_INSTANCE=1
  -DPIN_SERIAL_RX=PA10_R
  -DPIN_SERIAL_TX=PA9_R

in the platformio.ini so it’ll just overwrite the defaults.

Close :joy: … is also off-target :see_no_evil:

Quite cool!! That compiles and doesn’t freeze anymore. Need to get another USB/UART from downstairs to validate, but I’m pretty sure it will :+1:

Also quite thanks for your detailed description :pray:. Will try to understand and decide which solution is preferable for me.

Took some time to get downstairs :see_no_evil:. Checked remapped UART which work flawless!

Also checked your code explanations. Interesting :face_with_peeking_eye: and I can follow somehow… also might find another remap stuff which I probably need later :+1:
But I’m pretty sure, without your solution and your pointing finger, it has taken hours for me to find that by myself :innocent:

So: Quite thanks one more for your quick support and detailed explanation!