Selecting STM32F103CB instead of default

I'm trying to compile for the Arduino Maple target. This is according to the STM32 core GitHub - stm32duino/Arduino_Core_STM32: STM32 core support for Arduino README the STM32F103CB.

I can compile with the commandline

 arduino-cli compile --fqbn  STMicroelectronics:stm32:GenF1

but this does not select the right target. I see the linker script is taken from

 Arduino15/packages/STMicroelectronics/hardware/stm32/2.5.0/variants/STM32F1xx/F103C4T_F103C6(T-U)

instead of

  Arduino15/packages/STMicroelectronics/hardware/stm32/2.5.0/variants/STM32F1xx/F103C8T_F103CB(T-U)/

I've tried

    --build-property "build.variant=STM32F1xx/F103C8T_F103CB(T-U)"

but that hasn't changed anything.

Any suggestions on how to select the correct target platform are very much appreciated.

try build.board=BLUEPILL_F103CB

By the way, why do you compile from command line?
Try compile with Arduino IDE with correctly selected board and then copy the command line to arduino-cli

That leads to errors:

 arduino-cli compile --fqbn  STMicroelectronics:stm32:GenF1 --build-property "build.board=BLUEPILL_F103CB"
<command-line>: fatal error: variant_BLUEPILL_F103CB.h: No such file or directory
compilation terminated.
Used platform            Version Path
STMicroelectronics:stm32 2.5.0   /Users/deets/Library/Arduino15/packages/STMicroelectronics/hardware/stm32/2.5.0
Error during build: exit status 1

And I use the commandline because that's what I thought a tool called CLI is made for. I don't even have the IDE installed. If figuring out these things is only possible through the IDE, I will do that.

Hi @deetz.

The Arduino boards platform framework allows the platform developer to include "custom board options" in a board definition. These "custom board options" can be used by the user to adjust the configuration of that board definition. In order to make it easier for the users to select their board from the large number of targets supported by the platform, the developers of the STMicroelectronics:stm32 platform created a board definition only for each of the STM32 microcontroller series. The specific board part number within that series is then selected via a "custom board option".

When using Arduino CLI, the custom board options are set via --board-options flags added to the arduino-cli commands.

The format of the flag is like this:

--board-options "<menu ID>=<option ID>"

(where <menu ID> and <option ID> are placeholders for the custom board options menu and menu option you are setting)

If you don't set an option ID via your arduino-cli command, the default option is used. The reason you aren't getting your intended results is because you didn't set the board part number option and the default option doesn't happen to match your board model.

You can learn all the available menu IDs and option IDs for a given board by running the following arduino-cli command:

arduino-cli board details --fqbn <FQBN>

(where <FQBN> is replaced by the fully qualified board name of the board definition you are using)

For example:

arduino-cli board details --fqbn STMicroelectronics:stm32:GenF1

Board name:            Generic STM32F1 series
FQBN:                  STMicroelectronics:stm32:GenF1
Board version:         2.5.0
Debugging supported:   ✔

Package name:          STMicroelectronics
Package maintainer:    STMicroelectronics
Package URL:           https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
Package website:       https://github.com/stm32duino
Package online help:   http://www.stm32duino.com/

Platform name:         STM32 MCU based boards
Platform category:     Contributed
Platform architecture: stm32
Platform URL:          https://github.com/stm32duino/Arduino_Core_STM32/releases/download/2.5.0/STM32-2.5.0.tar.bz2
Platform file name:    STM32-2.5.0.tar.bz2
Platform size (bytes): 43417522
Platform checksum:     SHA-256:31fa78777834e869bd488e34e53c47a03f0f3dd6c63a3a2c5e0039d0baa8fcb1

Required tool: STMicroelectronics:CMSIS             5.7.0
Required tool: STMicroelectronics:STM32Tools        2.2.0
Required tool: STMicroelectronics:xpack-arm-none-eabi-gcc 12.2.1-1.2
Required tool: STMicroelectronics:xpack-openocd     0.12.0-1

Option:        Board part number                               pnum
               BluePill F103C6 (32K)                ✔          pnum=BLUEPILL_F103C6
               BluePill F103C8                                 pnum=BLUEPILL_F103C8
               BluePill F103CB (or C8 with 128k)               pnum=BLUEPILL_F103CB
               BlackPill F103C8                                pnum=BLACKPILL_F103C8
               BlackPill F103CB (or C8 with 128k)              pnum=BLACKPILL_F103CB
               VCCGND F103ZET6 Mini                            pnum=VCCGND_F103ZET6_MINI
               VCCGND F103ZET6                                 pnum=VCCGND_F103ZET6
               HY-TinySTM103TB                                 pnum=HY_TINYSTM103TB
               Maple Mini F103CB                               pnum=MAPLEMINI_F103CB
               Blue Button F103R8T                             pnum=BLUEBUTTON_F103R8T
               Blue Button F103RBT                             pnum=BLUEBUTTON_F103RBT
               Blue Button F103RCT                             pnum=BLUEBUTTON_F103RCT
               Blue Button F103RET                             pnum=BLUEBUTTON_F103RET
               Generic F100C4Tx                                pnum=GENERIC_F100C4TX
               Generic F100C6Tx                                pnum=GENERIC_F100C6TX
               Generic F100C8Tx                                pnum=GENERIC_F100C8TX
               Generic F100CBTx                                pnum=GENERIC_F100CBTX
               Generic F100R4Hx                                pnum=GENERIC_F100R4HX
               Generic F100R6Hx                                pnum=GENERIC_F100R6HX
               Generic F100R8Tx                                pnum=GENERIC_F100R8TX
               Generic F100RBTx                                pnum=GENERIC_F100RBTX
               Generic F100V8Tx                                pnum=GENERIC_F100V8TX
               Generic F100VBTx                                pnum=GENERIC_F100VBTX
               Generic F100ZCTx                                pnum=GENERIC_F100ZCTX
               Generic F100ZDTx                                pnum=GENERIC_F100ZDTX
               Generic F100ZETx                                pnum=GENERIC_F100ZETX
               Generic F101C4Tx                                pnum=GENERIC_F101C4TX
               Generic F101C6Tx                                pnum=GENERIC_F101C6TX
               Generic F101R4Tx                                pnum=GENERIC_F101R4TX
               Generic F101R6Tx                                pnum=GENERIC_F101R6TX
               Generic F101T4Ux                                pnum=GENERIC_F101T4UX
               Generic F101T6Ux                                pnum=GENERIC_F101T6UX
               Generic F101V8Tx                                pnum=GENERIC_F101V8TX
               Generic F101VBTx                                pnum=GENERIC_F101VBTX
               Generic F101ZCTx                                pnum=GENERIC_F101ZCTX
               Generic F101ZDTx                                pnum=GENERIC_F101ZDTX
               Generic F101ZETx                                pnum=GENERIC_F101ZETX
               Generic F103C4Tx                                pnum=GENERIC_F103C4TX
               Generic F103C6Tx                                pnum=GENERIC_F103C6TX
               Generic F103C6Ux                                pnum=GENERIC_F103C6UX
               Generic F103C8Tx                                pnum=GENERIC_F103C8TX
               Generic F103CBTx                                pnum=GENERIC_F103CBTX
               Generic F103CBUx                                pnum=GENERIC_F103CBUX
               Generic F103R4Hx                                pnum=GENERIC_F103R4HX
               Generic F103R6Hx                                pnum=GENERIC_F103R6HX
               Generic F103R4Tx                                pnum=GENERIC_F103R4TX
               Generic F103R6Tx                                pnum=GENERIC_F103R6TX
               Generic F103R8Hx                                pnum=GENERIC_F103R8HX
               Generic F103RBHx                                pnum=GENERIC_F103RBHX
               Generic F103R8Tx                                pnum=GENERIC_F103R8TX
               Generic F103RBTx                                pnum=GENERIC_F103RBTX
               Generic F103RCTx                                pnum=GENERIC_F103RCTX
               Generic F103RDTx                                pnum=GENERIC_F103RDTX
               Generic F103RETx                                pnum=GENERIC_F103RETX
               Generic F103RCYx                                pnum=GENERIC_F103RCYX
               Generic F103RDYx                                pnum=GENERIC_F103RDYX
               Generic F103REYx                                pnum=GENERIC_F103REYX
               Generic F103RFTx                                pnum=GENERIC_F103RFTX
               Generic F103RGTx                                pnum=GENERIC_F103RGTX
               Generic F103T4Ux                                pnum=GENERIC_F103T4UX
               Generic F103T6Ux                                pnum=GENERIC_F103T6UX
               Generic F103T8Ux                                pnum=GENERIC_F103T8UX
               Generic F103TBUx                                pnum=GENERIC_F103TBUX
               Generic F103V8Hx                                pnum=GENERIC_F103V8HX
               Generic F103VBHx                                pnum=GENERIC_F103VBHX
               Generic F103V8Tx                                pnum=GENERIC_F103V8TX
               Generic F103VBTx                                pnum=GENERIC_F103VBTX
               Generic F103VBIx                                pnum=GENERIC_F103VBIX
               Generic F103VCHx                                pnum=GENERIC_F103VCHX
               Generic F103VDHx                                pnum=GENERIC_F103VDHX
               Generic F103VEHx                                pnum=GENERIC_F103VEHX
               Generic F103VCTx                                pnum=GENERIC_F103VCTX
               Generic F103VDTx                                pnum=GENERIC_F103VDTX
               Generic F103VETx                                pnum=GENERIC_F103VETX
               Generic F103VFTx                                pnum=GENERIC_F103VFTX
               Generic F103VGTx                                pnum=GENERIC_F103VGTX
               Generic F103ZCHx                                pnum=GENERIC_F103ZCHX
               Generic F103ZDHx                                pnum=GENERIC_F103ZDHX
               Generic F103ZEHx                                pnum=GENERIC_F103ZEHX
               Generic F103ZCTx                                pnum=GENERIC_F103ZCTX
               Generic F103ZDTx                                pnum=GENERIC_F103ZDTX
               Generic F103ZETx                                pnum=GENERIC_F103ZETX
               Generic F103ZFHx                                pnum=GENERIC_F103ZFHX
               Generic F103ZGHx                                pnum=GENERIC_F103ZGHX
               Generic F103ZFTx                                pnum=GENERIC_F103ZFTX
               Generic F103ZGTx                                pnum=GENERIC_F103ZGTX
Option:        U(S)ART support                                 xserial
               Enabled (generic 'Serial')           ✔          xserial=generic
               Enabled (no generic 'Serial')                   xserial=none
               Disabled (no Serial support)                    xserial=disabled
Option:        USB support (if available)                      usb
               None                                 ✔          usb=none
               CDC (generic 'Serial' supersede U(S)ART)            usb=CDCgen
               CDC (no generic 'Serial')                       usb=CDC
               HID (keyboard and mouse)                        usb=HID
Option:        USB speed (if available)                        xusb
               Low/Full Speed                       ✔          xusb=FS
               High Speed                                      xusb=HS
               High Speed in Full Speed mode                   xusb=HSFS
Option:        Optimize                                        opt
               Smallest (-Os default)               ✔          opt=osstd
               Smallest (-Os) with LTO                         opt=oslto
               Fast (-O1)                                      opt=o1std
               Fast (-O1) with LTO                             opt=o1lto
               Faster (-O2)                                    opt=o2std
               Faster (-O2) with LTO                           opt=o2lto
               Fastest (-O3)                                   opt=o3std
               Fastest (-O3) with LTO                          opt=o3lto
               Debug (-Og)                                     opt=ogstd
               No Optimization (-O0)                           opt=o0std
Option:        Debug symbols and core logs                     dbg
               None                                 ✔          dbg=none
               Symbols Enabled (-g)                            dbg=enable_sym
               Core logs Enabled                               dbg=enable_log
               Core Logs and Symbols Enabled (-g)              dbg=enable_all
Option:        C Runtime Library                               rtlib
               Newlib Nano (default)                ✔          rtlib=nano
               Newlib Nano + Float Printf                      rtlib=nanofp
               Newlib Nano + Float Scanf                       rtlib=nanofs
               Newlib Nano + Float Printf/Scanf                rtlib=nanofps
               Newlib Standard                                 rtlib=full
Option:        Upload method                                   upload_method
               STM32CubeProgrammer (SWD)            ✔          upload_method=swdMethod
               STM32CubeProgrammer (Serial)                    upload_method=serialMethod
               STM32CubeProgrammer (DFU)                       upload_method=dfuMethod
               BMP (Black Magic Probe)                         upload_method=bmpMethod
               HID Bootloader 2.2                              upload_method=hidMethod
               Maple DFU Bootloader 2.0                        upload_method=dfu2Method
               Maple DFU Bootloader original                   upload_method=dfuoMethod
Programmers:   ID                                   Name

Here we can see that the ID for the "Board part number" menu is pnum and the ID for the "Maple Mini F103CB" option is MAPLEMINI_F103CB.

So, if you wanted to compile a sketch with this custom board option, you would use the following command:

arduino-cli compile --fqbn STMicroelectronics:stm32:GenF1 --board-options "pnum=MAPLEMINI_F103CB"

You can add multiple --board-options flags to an arduino-cli command if you want to set multiple custom board options menus.


The --build-property flag allows doing very advanced things, but it should be used only when absolutely necessary because it requires an in depth understanding of the Arduino boards platform framework as well as the target platform's configuration. That configuration can change from one release of the platform to another without notice since the properties are not part of the platform's public API.

In this case where the platform developers have provided a nice public interface for configuring the board part number, it doesn't make sense to use the --build-property flag.

2 Likes

That helped a lot, thank you very much! I still exceed flash by 90Kb, but that's probably a C++ standard library issue my new code caused, so I need a different strategy there.

You are welcome. I'm glad if I was able to be of assistance.

Regards,
Per

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.