platformio / platform-ststm32

ST STM32: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/ststm32
Apache License 2.0
394 stars 308 forks source link

There's a lot of variation in "extra_flags" #759

Closed jcw closed 6 months ago

jcw commented 6 months ago

As the title says. Here's an example:

$ cd ~/.platformio/platforms/ststm32/boards/
$ grep '"extra_flags":' nucleo_*
nucleo_f030r8.json:    "extra_flags": "-DSTM32F030x8",
nucleo_f031k6.json:    "extra_flags": "-DSTM32F031x6",
nucleo_f042k6.json:    "extra_flags": "-DSTM32F042x6",
nucleo_f070rb.json:    "extra_flags": "-DSTM32F070xB",
nucleo_f072rb.json:    "extra_flags": "-DSTM32F072xB",
nucleo_f091rc.json:    "extra_flags": "-DSTM32F091xC",
nucleo_f103rb.json:    "extra_flags": "-DSTM32F103xB",
nucleo_f207zg.json:    "extra_flags": "-DSTM32F207xx",
nucleo_f302r8.json:    "extra_flags": "-DSTM32F302x8",
nucleo_f303k8.json:    "extra_flags": "-DSTM32F303x8",
nucleo_f303re.json:    "extra_flags": "-DSTM32F303xE",
nucleo_f303ze.json:    "extra_flags": "-DSTM32F303xE",
nucleo_f334r8.json:    "extra_flags": "-DSTM32F334x8",
nucleo_f401re.json:    "extra_flags": "-DSTM32F4 -DSTM32F401xE -DSTM32F40_41xxx",
nucleo_f410rb.json:    "extra_flags": "-DSTM32F410Rx",
nucleo_f411re.json:    "extra_flags": "-DSTM32F411xE",
nucleo_f412zg.json:    "extra_flags": "-DSTM32F412Zx",
nucleo_f413zh.json:    "extra_flags": "-DSTM32F413xx",
nucleo_f429zi.json:    "extra_flags": "-DSTM32F429xx",
nucleo_f439zi.json:    "extra_flags": "-DSTM32F439xx",
nucleo_f446re.json:    "extra_flags": "-DSTM32F446xx",
nucleo_f446ze.json:    "extra_flags": "-DSTM32F4 -DSTM32F446xx",
nucleo_f722ze.json:    "extra_flags": "-DSTM32F722xx",
nucleo_f746zg.json:    "extra_flags": "-DSTM32F746xx",
nucleo_f756zg.json:    "extra_flags": "-DSTM32F756xx",
nucleo_f767zi.json:    "extra_flags": "-DSTM32F767xx",
nucleo_g031k8.json:    "extra_flags": "-DSTM32G0xx -DSTM32G031xx",
nucleo_g070rb.json:    "extra_flags": "-DSTM32G0xx -DSTM32G070xx",
nucleo_g071rb.json:    "extra_flags": "-DSTM32G0xx -DSTM32G071xx",
nucleo_g0b1re.json:    "extra_flags": "-DSTM32G0xx -DSTM32G0B1xx",
nucleo_g431kb.json:    "extra_flags": "-DSTM32G4xx -DSTM32G431xx",
nucleo_g431rb.json:    "extra_flags": "-DSTM32G4xx -DSTM32G431xx",
nucleo_g474re.json:    "extra_flags": "-DSTM32G4xx -DSTM32G474xx",
nucleo_h723zg.json:    "extra_flags": "-DSTM32H7xx -DSTM32H723xx",
nucleo_h743zi.json:    "extra_flags": "-DSTM32H7xx -DSTM32H743xx",
nucleo_h745zi_q.json:    "extra_flags": "-DSTM32H7xx -DSTM32H745xx",
nucleo_h753zi.json:    "extra_flags": "-DSTM32H7xx -DSTM32H753xx",
nucleo_l010rb.json:    "extra_flags": "-DSTM32L010xB",
nucleo_l011k4.json:    "extra_flags": "-DSTM32L011xx",
nucleo_l031k6.json:    "extra_flags": "-DSTM32L031xx",
nucleo_l053r8.json:    "extra_flags": "-DSTM32L053xx",
nucleo_l073rz.json:    "extra_flags": "-DSTM32L073xx",
nucleo_l152re.json:    "extra_flags": "-DSTM32L152xE",
nucleo_l412kb.json:    "extra_flags": "-DSTM32L412xx",
nucleo_l412rb_p.json:    "extra_flags": "-DSTM32L412xx",
nucleo_l432kc.json:    "extra_flags": "-DSTM32L432xx",
nucleo_l433rc_p.json:    "extra_flags": "-DSTM32L433xx",
nucleo_l452re.json:    "extra_flags": "-DSTM32L452xx",
nucleo_l476rg.json:    "extra_flags": "-DSTM32L476xx",
nucleo_l486rg.json:    "extra_flags": "-DSTM32L486xx",
nucleo_l496zg.json:    "extra_flags": "-DSTM32L496xx",
nucleo_l496zg_p.json:    "extra_flags": "-DSTM32L496xx",
nucleo_l4r5zi.json:    "extra_flags": "-DSTM32L4R5xx",
nucleo_l552ze_q.json:    "extra_flags": "-DSTM32L552xx",
nucleo_u575zi_q.json:    "extra_flags": "-DSTM32U5xx -DSTM32U575xx",
nucleo_wb55rg_p.json:    "extra_flags": "-DSTM32WB55xx",
nucleo_wl55jc.json:    "extra_flags": "-DSTM32WLxx -DSTM32WLE5xx",

A few are also inconsistent by including the ram memory size, which is not relevant w.r.t. board features:

nucleo_l152re.json:    "extra_flags": "-DSTM32L152xE",

My suggestion would be to include both the most specific define, and the least specific one:

nucleo_g431kb.json:    "extra_flags": "-DSTM32G4 -DSTM32G431xx",

I'm using automated scripts in my projects, and a consistent naming convention for defines would be very helpful.

The one drawback that I see is that any change here may break existing projects - but everyone will benefit in the long term if the current inconsistencies are resolved, IMNSHO.

valeros commented 6 months ago

Hi @jcw, a PR with necessary changes is very welcome.

jcw commented 6 months ago

I'll be happy to give it a go, across all the STM32 boards, if you're ok with this approach (and the potential breakage for existing projects), i.e as suggested for nucleo_g431kb.json. The "long" name has to match the SVD filename. Not sure yet what to do with STM32WB vs STM32WL for the short names (are they substantially different from each other?).

valeros commented 6 months ago

and the potential breakage for existing projects

I thought you wanted to only add new defines, so I'm not sure what could possibly go wrong.

The "long" name has to match the SVD filename.

Just to make sure we are on the same page, the long name (e.g. -DSTM32G431xx) has little to do with the SVD file, it's needed by the STM32Cube framework to resolve a proper header file internally.

jcw commented 6 months ago

Oh, ok - new "short" defines is ok with me (and some long "xx" ones, as for the l152 above). Ah, yes, I was confused w.r.t. to defines vs svd - you're right.

jcw commented 6 months ago

IOW, "STM32G4", "STM32H7", etc added, right? This is an example of how I use it: https://git.sr.ht/~jcw/jeeh/tree/main/item/arch/stm32.cpp.

valeros commented 6 months ago

OK, the extra_flags option is mostly used to add framework-specific (not project-specific) flags, but I believe we can add family-wide defines like STM32G4 as they are used (although optional) by STM32Cube.

jcw commented 6 months ago

Well, adding a flag (if not yet present) is pretty easy, I've generated this script:

# 272 boards
sed -i '' '/"extra/s/"-D/"-DSTM32L0 -D/' acsip_s76s.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' adafruit_feather_f405.json
sed -i '' '/"extra/s/"-D/"-DSTM32F1 -D/' afroflight_f103cb.json
sed -i '' '/"extra/s/"-D/"-DSTM32G0 -D/' agafia_sg0.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' armstrap_eagle1024.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' armstrap_eagle2048.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' armstrap_eagle512.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' b96b_aerocore2.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' b96b_argonkey.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' b96b_f446ve.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' b96b_neonkey.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' blackpill_f401cc.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' blackpill_f401ce.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' blackpill_f411ce.json
sed -i '' '/"extra/s/"-D/"-DSTM32G0 -D/' btt_ebb42_v1_1.json
sed -i '' '/"extra/s/"-D/"-DSTM32L4 -D/' bw_swan_r5.json
sed -i '' '/"extra/s/"-D/"-DSTM32L4 -D/' cloud_jam_l4.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' coreboard_f401rc.json
sed -i '' '/"extra/s/"-D/"-DSTM32F0 -D/' demo_f030f4.json
sed -i '' '/"extra/s/"-D/"-DSTM32H7 -D/' devebox_h743vitx.json
sed -i '' '/"extra/s/"-D/"-DSTM32H7 -D/' devebox_h750vbtx.json
sed -i '' '/"extra/s/"-D/"-DSTM32G4 -D/' disco_b_g431b_esc1.json
sed -i '' '/"extra/s/"-D/"-DSTM32U5 -D/' disco_b_u585i_iot02a.json
sed -i '' '/"extra/s/"-D/"-DSTM32F0 -D/' disco_f030r8.json
sed -i '' '/"extra/s/"-D/"-DSTM32F0 -D/' disco_f051r8.json
sed -i '' '/"extra/s/"-D/"-DSTM32F0 -D/' disco_f072rb.json
sed -i '' '/"extra/s/"-D/"-DSTM32F1 -D/' disco_f100rb.json
sed -i '' '/"extra/s/"-D/"-DSTM32F3 -D/' disco_f334c8.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' disco_f401vc.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' disco_f412zg.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' disco_f413zh.json
sed -i '' '/"extra/s/"-D/"-DSTM32F7 -D/' disco_f723ie.json
sed -i '' '/"extra/s/"-D/"-DSTM32F7 -D/' disco_f746ng.json
sed -i '' '/"extra/s/"-D/"-DSTM32F7 -D/' disco_f750n8.json
sed -i '' '/"extra/s/"-D/"-DSTM32F7 -D/' disco_f769ni.json
sed -i '' '/"extra/s/"-D/"-DSTM32G0 -D/' disco_g031j6.json
sed -i '' '/"extra/s/"-D/"-DSTM32G0 -D/' disco_g071rb.json
sed -i '' '/"extra/s/"-D/"-DSTM32H7 -D/' disco_h735ig.json
sed -i '' '/"extra/s/"-D/"-DSTM32H7 -D/' disco_h747xi.json
sed -i '' '/"extra/s/"-D/"-DSTM32L0 -D/' disco_l053c8.json
sed -i '' '/"extra/s/"-D/"-DSTM32L0 -D/' disco_l072cz_lrwan1.json
sed -i '' '/"extra/s/"-D/"-DSTM32L1 -D/' disco_l100rc.json
sed -i '' '/"extra/s/"-D/"-DSTM32L4 -D/' disco_l475vg_iot01a.json
sed -i '' '/"extra/s/"-D/"-DSTM32L4 -D/' disco_l476vg.json
sed -i '' '/"extra/s/"-D/"-DSTM32L4 -D/' disco_l496ag.json
sed -i '' '/"extra/s/"-D/"-DSTM32L4 -D/' disco_l4s5i_iot01a.json
sed -i '' '/"extra/s/"-D/"-DSTM32H7 -D/' electrosmith_daisy.json
sed -i '' '/"extra/s/"-D/"-DSTM32H7 -D/' electrosmith_daisy_patch_sm.json
sed -i '' '/"extra/s/"-D/"-DSTM32H7 -D/' electrosmith_daisy_petal_sm.json
sed -i '' '/"extra/s/"-D/"-DSTM32F0 -D/' elektor_f072c8.json
sed -i '' '/"extra/s/"-D/"-DSTM32F0 -D/' elektor_f072cb.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' elmo_f411re.json
sed -i '' '/"extra/s/"-D/"-DSTM32F0 -D/' eval_f072vb.json
sed -i '' '/"extra/s/"-D/"-DSTM32L0 -D/' eval_l073z.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' fysetc_s6.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F401CB.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F401CC.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F401CD.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F401CE.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F401RB.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F401RC.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F401RD.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F401RE.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F405RG.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F410C8.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F410CB.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F410R8.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F410RB.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F411CC.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F411CE.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F411RC.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F411RE.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F412CE.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F412CG.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F412RE.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F412RG.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F413CG.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F413CH.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F413RG.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F413RH.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F415RG.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F417VE.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F417VG.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F423CH.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F423RH.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F446RC.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' genericSTM32F446RE.json
sed -i '' '/"extra/s/"-D/"-DSTM32G4 -D/' genericSTM32G431CB.json
sed -i '' '/"extra/s/"-D/"-DSTM32H7 -D/' genericSTM32H750VB.json
sed -i '' '/"extra/s/"-D/"-DSTM32F1 -D/' hy_tinystm103tb.json
sed -i '' '/"extra/s/"-D/"-DSTM32L4 -D/' leafony_ap03.json
sed -i '' '/"extra/s/"-D/"-DSTM32WL -D/' lora_e5_dev_board.json
sed -i '' '/"extra/s/"-D/"-DSTM32WL -D/' lora_e5_mini.json
sed -i '' '/"extra/s/"-D/"-DSTM32F0 -D/' malyanm200_f070cb.json
sed -i '' '/"extra/s/"-D/"-DSTM32F1 -D/' malyanm200_f103cb.json
sed -i '' '/"extra/s/"-D/"-DSTM32F0 -D/' malyanm300_f070cb.json
sed -i '' '/"extra/s/"-D/"-DSTM32F1 -D/' maple.json
sed -i '' '/"extra/s/"-D/"-DSTM32F1 -D/' maple_mini_b20.json
sed -i '' '/"extra/s/"-D/"-DSTM32F1 -D/' maple_mini_origin.json
sed -i '' '/"extra/s/"-D/"-DSTM32F1 -D/' maple_ret6.json
sed -i '' '/"extra/s/"-D/"-DSTM32F1 -D/' microduino32_flash.json
sed -i '' '/"extra/s/"-D/"-DSTM32WB -D/' mkr_sharky.json
sed -i '' '/"extra/s/"-D/"-DSTM32L1 -D/' mote_l152rc.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' mts_mdot_f411re.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' mxchip_az3166.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' netduino2plus.json
sed -i '' '/"extra/s/"-D/"-DSTM32F0 -D/' nucleo_f030r8.json
sed -i '' '/"extra/s/"-D/"-DSTM32F0 -D/' nucleo_f031k6.json
sed -i '' '/"extra/s/"-D/"-DSTM32F0 -D/' nucleo_f042k6.json
sed -i '' '/"extra/s/"-D/"-DSTM32F0 -D/' nucleo_f070rb.json
sed -i '' '/"extra/s/"-D/"-DSTM32F0 -D/' nucleo_f072rb.json
sed -i '' '/"extra/s/"-D/"-DSTM32F0 -D/' nucleo_f091rc.json
sed -i '' '/"extra/s/"-D/"-DSTM32F1 -D/' nucleo_f103rb.json
sed -i '' '/"extra/s/"-D/"-DSTM32F2 -D/' nucleo_f207zg.json
sed -i '' '/"extra/s/"-D/"-DSTM32F3 -D/' nucleo_f302r8.json
sed -i '' '/"extra/s/"-D/"-DSTM32F3 -D/' nucleo_f303k8.json
sed -i '' '/"extra/s/"-D/"-DSTM32F3 -D/' nucleo_f303re.json
sed -i '' '/"extra/s/"-D/"-DSTM32F3 -D/' nucleo_f303ze.json
sed -i '' '/"extra/s/"-D/"-DSTM32F3 -D/' nucleo_f334r8.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' nucleo_f410rb.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' nucleo_f411re.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' nucleo_f412zg.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' nucleo_f413zh.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' nucleo_f429zi.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' nucleo_f439zi.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' nucleo_f446re.json
sed -i '' '/"extra/s/"-D/"-DSTM32F7 -D/' nucleo_f722ze.json
sed -i '' '/"extra/s/"-D/"-DSTM32F7 -D/' nucleo_f746zg.json
sed -i '' '/"extra/s/"-D/"-DSTM32F7 -D/' nucleo_f756zg.json
sed -i '' '/"extra/s/"-D/"-DSTM32F7 -D/' nucleo_f767zi.json
sed -i '' '/"extra/s/"-D/"-DSTM32G0 -D/' nucleo_g031k8.json
sed -i '' '/"extra/s/"-D/"-DSTM32G0 -D/' nucleo_g070rb.json
sed -i '' '/"extra/s/"-D/"-DSTM32G0 -D/' nucleo_g071rb.json
sed -i '' '/"extra/s/"-D/"-DSTM32G0 -D/' nucleo_g0b1re.json
sed -i '' '/"extra/s/"-D/"-DSTM32G4 -D/' nucleo_g431kb.json
sed -i '' '/"extra/s/"-D/"-DSTM32G4 -D/' nucleo_g431rb.json
sed -i '' '/"extra/s/"-D/"-DSTM32G4 -D/' nucleo_g474re.json
sed -i '' '/"extra/s/"-D/"-DSTM32H7 -D/' nucleo_h723zg.json
sed -i '' '/"extra/s/"-D/"-DSTM32H7 -D/' nucleo_h743zi.json
sed -i '' '/"extra/s/"-D/"-DSTM32H7 -D/' nucleo_h745zi_q.json
sed -i '' '/"extra/s/"-D/"-DSTM32H7 -D/' nucleo_h753zi.json
sed -i '' '/"extra/s/"-D/"-DSTM32L0 -D/' nucleo_l010rb.json
sed -i '' '/"extra/s/"-D/"-DSTM32L0 -D/' nucleo_l011k4.json
sed -i '' '/"extra/s/"-D/"-DSTM32L0 -D/' nucleo_l031k6.json
sed -i '' '/"extra/s/"-D/"-DSTM32L0 -D/' nucleo_l053r8.json
sed -i '' '/"extra/s/"-D/"-DSTM32L0 -D/' nucleo_l073rz.json
sed -i '' '/"extra/s/"-D/"-DSTM32L1 -D/' nucleo_l152re.json
sed -i '' '/"extra/s/"-D/"-DSTM32L4 -D/' nucleo_l412kb.json
sed -i '' '/"extra/s/"-D/"-DSTM32L4 -D/' nucleo_l412rb_p.json
sed -i '' '/"extra/s/"-D/"-DSTM32L4 -D/' nucleo_l432kc.json
sed -i '' '/"extra/s/"-D/"-DSTM32L4 -D/' nucleo_l433rc_p.json
sed -i '' '/"extra/s/"-D/"-DSTM32L4 -D/' nucleo_l452re.json
sed -i '' '/"extra/s/"-D/"-DSTM32L4 -D/' nucleo_l476rg.json
sed -i '' '/"extra/s/"-D/"-DSTM32L4 -D/' nucleo_l486rg.json
sed -i '' '/"extra/s/"-D/"-DSTM32L4 -D/' nucleo_l496zg.json
sed -i '' '/"extra/s/"-D/"-DSTM32L4 -D/' nucleo_l496zg_p.json
sed -i '' '/"extra/s/"-D/"-DSTM32L4 -D/' nucleo_l4r5zi.json
sed -i '' '/"extra/s/"-D/"-DSTM32L5 -D/' nucleo_l552ze_q.json
sed -i '' '/"extra/s/"-D/"-DSTM32U5 -D/' nucleo_u575zi_q.json
sed -i '' '/"extra/s/"-D/"-DSTM32WB -D/' nucleo_wb55rg_p.json
sed -i '' '/"extra/s/"-D/"-DSTM32WL -D/' nucleo_wl55jc.json
sed -i '' '/"extra/s/"-D/"-DSTM32F1 -D/' olimex_f103.json
sed -i '' '/"extra/s/"-D/"-DSTM32F1 -D/' olimexino.json
sed -i '' '/"extra/s/"-D/"-DSTM32F3 -D/' olimexino_stm32f3.json
sed -i '' '/"extra/s/"-D/"-DSTM32L0 -D/' piconomix_px_her0.json
sed -i '' '/"extra/s/"-D/"-DSTM32F0 -D/' pybstick26_duino.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' pybstick26_lite.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' pybstick26_pro.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' pybstick26_std.json
sed -i '' '/"extra/s/"-D/"-DSTM32L1 -D/' rak811_tracker.json
sed -i '' '/"extra/s/"-D/"-DSTM32L1 -D/' rak811_tracker_32.json
sed -i '' '/"extra/s/"-D/"-DSTM32F7 -D/' remram_v1.json
sed -i '' '/"extra/s/"-D/"-DSTM32L0 -D/' rhf76_052.json
sed -i '' '/"extra/s/"-D/"-DSTM32L4 -D/' rhombio_l476dmw1k.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' rumba32_f446ve.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' sakuraio_evb_01.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' seeedArchMax.json
sed -i '' '/"extra/s/"-D/"-DSTM32L4 -D/' silica_sensor_node.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' sparkfun_micromod_f405.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' steval_fcu001v1.json
sed -i '' '/"extra/s/"-D/"-DSTM32L4 -D/' steval_mksboxv1.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' stm32f4stamp.json
sed -i '' '/"extra/s/"-D/"-DSTM32L0 -D/' thunder_pack.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' thunder_pack_f411.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' ublox_c030_r410m.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' vake_v1.json
sed -i '' '/"extra/s/"-D/"-DSTM32H7 -D/' weact_mini_h743vitx.json
sed -i '' '/"extra/s/"-D/"-DSTM32H7 -D/' weact_mini_h750vbtx.json
sed -i '' '/"extra/s/"-D/"-DSTM32F4 -D/' wio_3g.json
sed -i '' '/"extra/s/"-D/"-DSTM32F0 -D/' wraith32_v1.json
sed -i '' '/"extra/s/"-D/"-DSTM32L1 -D/' xdot_l151cc.json
# 70 skipped

If you run the above through a shell in the boards/ dir, it'll insert those flags (I used MacOS). Do I need to fork and submit a patch on GitHub (meh ...), or is this good enough for you?

PS. Generated from a listing using grep -r '"extra_flags":' >~/Desktop/eflags.txt, then some manual batch edits in vi, which gave me a file like this:

1bitsy_stm32f415rgt STM32F4 STM32F415xx STM32F40_41xxx
acsip_s76s STM32L073xx
adafruit_feather_f405 STM32F405xx
...

And then I ran this python3 script as last step:

#!/usr/bin/env python3

with open("eflags.txt") as fd:
    boards = fd.read().splitlines()

print(f'# {len(boards)} boards')

present = 0
for b in boards:
    name, *defs = b.split()
    #print(name, defs)
    n = ''
    for d in defs:
        if d[:5] == 'STM32':
            n = d[:7]
            break
    if n and n in defs:
        #print(name, defs)
        present += 1
    elif n:
        print(f'''sed -i '' '/"extra/s/"-D/"-D{n} -D/' {name}.json''')
print(f'# {present} skipped')

Update: 11 weird entries removed, see next comment.

jcw commented 6 months ago

Ehm, I do see a few odd ones - not sure what defines they were supposed to have:

sed -i '' '/"extra/s/"-D/"-D -D/' cicada_l082cz.json
sed -i '' '/"extra/s/"-D/"-D -D/' cricket_l082cz.json
sed -i '' '/"extra/s/"-D/"-D -D/' econode_l082cz.json
sed -i '' '/"extra/s/"-D/"-D -D/' gnat_l082cz.json
sed -i '' '/"extra/s/"-D/"-D -D/' grasshopper_l082cz.json
sed -i '' '/"extra/s/"-D/"-D -D/' nicla_vision.json
sed -i '' '/"extra/s/"-D/"-D -D/' nicla_vision_m4.json
sed -i '' '/"extra/s/"-D/"-D -D/' opta.json
sed -i '' '/"extra/s/"-D/"-D -D/' opta_m4.json
sed -i '' '/"extra/s/"-D/"-D -D/' portenta_h7_m4.json
sed -i '' '/"extra/s/"-D/"-D -D/' portenta_h7_m7.json
jcw commented 6 months ago

And to finish it all off, those 11 weird ones can be fixed with this manually-edited script:

sed -i '' '/"extra/s/"-D/"-DSTM32L0 -D/' cicada_l082cz.json
sed -i '' '/"extra/s/"-D/"-DSTM32L0 -D/' cricket_l082cz.json
sed -i '' '/"extra/s/"-D/"-DSTM32L0 -D/' econode_l082cz.json
sed -i '' '/"extra/s/"-D/"-DSTM32L0 -D/' gnat_l082cz.json
sed -i '' '/"extra/s/"-D/"-DSTM32L0 -D/' grasshopper_l082cz.json
sed -i '' '/"extra/s/"-D/"-DSTM32H7 -D/' nicla_vision.json
sed -i '' '/"extra/s/"-D/"-DSTM32H7 -D/' nicla_vision_m4.json
sed -i '' '/"extra/s/"-D/"-DSTM32H7 -D/' opta.json
sed -i '' '/"extra/s/"-D/"-DSTM32H7 -D/' opta_m4.json
sed -i '' '/"extra/s/"-D/"-DSTM32H7 -D/' portenta_h7_m4.json
sed -i '' '/"extra/s/"-D/"-DSTM32H7 -D/' portenta_h7_m7.json

As far as I can tell, that leads to a consistent STM32<letter><digit> define for all STM32 boards.

valeros commented 6 months ago

Thanks for the info, a PR would be much appreciated.

valeros commented 6 months ago

Resolved in https://github.com/platformio/platform-ststm32/pull/760