Custom board weactstudio ESP32-C3FH4 extra_flags questions

hi,
i’m in the process of creating a custom board for the WeActStudio ESP32 C3FH4

I’ve created a new board.json (placed in a boards directory in the project folder
I’ve created a pins_arduino.h inside a weactstudio_esp32c3fh4 directory inboards/variants` directory

all seems to work and basic code compile

I’ve just a question regardin the extra_flags in boards.json

    "extra_flags": [
        "-DARDUINO_WEACTSTUDIO_ESP32C3FH4",
        "-DARDUINO_USB_MODE=1",
        "-DARDUINO_USB_CDC_ON_BOOT=1"]

what the purpose of the first DARDUINO_XXXXX flag, in my understanding it’s some buildflag passed to the compiler
in all .json I’ve looked at, this flag match by its name with the board_build.variant value
Do I have to follow the same logic for my custom board, or do I miss something here ?

here my “custom” .json file for reference
WeActStudio_ESP32C3FH4_core.json

    "build": {
      "arduino": {
        "ldscript": "esp32c3_out.ld"
      },
      "core": "esp32",
      "extra_flags": [
        "-DARDUINO_WEACTSTUDIO_ESP32C3FH4",
        "-DARDUINO_USB_MODE=1",
        "-DARDUINO_USB_CDC_ON_BOOT=1"
      ],
      "f_cpu": "160000000L",
      "f_flash": "80000000L",
      "flash_mode": "qio",
      "hwids": [
        [
          "0X303A",
          "0x1001"
        ]
      ],
      "mcu": "esp32c3",
      "variant": "weactstudio_esp32c3fh4"
    },
    "connectivity": [
      "wifi"
    ],
    "debug": {
      "openocd_target": "esp32c3.cfg"
    },
    "frameworks": [
      "arduino",
      "espidf"
    ],
    "name": "WeActStudio ESP32-C3FH4 CoreBoard",
    "upload": {
      "flash_size": "4MB",
      "maximum_ram_size": 327680,
      "maximum_size": 4194304,
      "require_upload_port": true,
      "speed": 460800
    },
    "url": "https://github.com/WeActStudio/WeActStudio.ESP32C3CoreBoard",
    "vendor": "WEACTSTUDIO"
  }

and the platformio.ini

[env:WeActStudio_ESP32C3FH4_core]
platform = espressif32
board = WeActStudio_ESP32C3FH4_core
framework = arduino

; set where the folder with all the board variants is
board_build.variants_dir = ./boards/variants
; change which exact variant to use default is set in board.json file
;board_build.variant = my_custom_mega 
1 Like

extra_flags are like build_flags, that is they’re extra compiler flags that are always passed when that board is used. The exact effect of the ARDUINO_x flags has to be read from the Arduino-ESP32 core.

thanks
Do you have some hints to where to start my research ?
this part is not documented in the custom board section of platformio.
I don’t know where to search in GitHub - espressif/arduino-esp32: Arduino core for the ESP32 about this topic :confused:

Oh just searching for direct occurrences of ARDUINO_USB_MODE, etc. will yield results.

For example,

with

Already gives you the decoding for USB mode and CDC on Boot (“USB Serial”). Then every board usually has its own “I am this board” define like ARDUINO_WEACTSTUDIO_ESP32C3FH4, but most of those go unused in the core (but can be used by the programmer to distinguish which board is selected).

ho, seems my question in my first post, was not presented clearly enough
my question was specifically about the DARDUINO_BOARD_NAME flag
wondering what is its purpose and if the compiler or core do something with it other that specify a ''define" available for programmers.
looking at several non generic board json files, all have the DARDUINO flag named with same name as the ‘‘variants’’ value

I’ve applied the same logic (the ARDUINO_WEACTSTUDIO_ESP32C3FH4 is my creation) and wondered is there is something behind that I was missing, maybe the core find the variants pin file by this flag or this kind of hidden mechanism.
and finally I wonder if it is preferable, to take the generic board flag (that could be in this case DARDUINO_ESP32C3_DEV)