Help understanding boards.txt (adding new board)

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
gentijo
Posts: 2
Joined: Fri Jul 03, 2020 6:26 am

Help understanding boards.txt (adding new board)

Post by gentijo »

Hi, I am a bit confused on how new boards work, I am coming from the perspective on understanding how the existing
BlackPill 411CE works.

After loading V1.9 of the board support package, I get entries for the Generic 411CE and the BlackPill 411.
If I select BlackPill 411 and compile / load the Blink example it works.
If I select Generic 411CE it will compile and load, but it won't run or it may be running but the LED does not blink.

I wanted to see how the two boards were supported and what was different, I was expecting a different pin mapping.
In the variant directory, there is no entry for the BlackPill F411CE, there are other BlackPill entries but not the 411
In boards.txt, I find the BlackPill entry (below) but it looks as if it's an alias entry for the Generic 411CE entry since the
product_line and build_variant entries are identical.

I went to the Github entry to look at the code there and it appears to be the boot code for a micro python environment.

Can someone explain how this works ?

Thank you
-John


# BlackPill F411CE
# https://github.com/mcauser/WEACT_F411CEU6
GenF4.menu.pnum.BLACKPILL_F411CE=BlackPill F411CE
GenF4.menu.pnum.BLACKPILL_F411CE.upload.maximum_size=524288
GenF4.menu.pnum.BLACKPILL_F411CE.upload.maximum_data_size=131072
GenF4.menu.pnum.BLACKPILL_F411CE.build.board=BLACKPILL_F411CE
GenF4.menu.pnum.BLACKPILL_F411CE.build.product_line=STM32F411xE
GenF4.menu.pnum.BLACKPILL_F411CE.build.variant=Generic_F411Cx

# Generic F411CE
GenF4.menu.pnum.Generic_F411CE=Generic F411CE
GenF4.menu.pnum.Generic_F411CE.upload.maximum_size=524288
GenF4.menu.pnum.Generic_F411CE.upload.maximum_data_size=131072
GenF4.menu.pnum.Generic_F411CE.build.board=GENERIC_F411CE
GenF4.menu.pnum.Generic_F411CE.build.product_line=STM32F411xE
GenF4.menu.pnum.Generic_F411CE.build.variant=Generic_F411Cx
User avatar
fpiSTM
Posts: 1754
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Help understanding boards.txt (adding new board)

Post by fpiSTM »

Hi,
in fact this is the same variant as it is the same mcu.
The only difference is that the board name definition is used to perform some change:

https://github.com/stm32duino/Arduino_C ... .h#L74-L87

Code: Select all

// On-board LED pin number
#ifdef ARDUINO_BLACKPILL_F411CE
#define LED_BUILTIN             PC13
#elif !defined(LED_BUILTIN)
#define LED_BUILTIN             PA5
#endif
#define LED_GREEN               LED_BUILTIN

// On-board user button
#ifdef ARDUINO_BLACKPILL_F411CE
#define USER_BTN                PA0
#elif !defined(USER_BTN)
#define USER_BTN                PC13
#endif
As you can see for the Blackpill the LED_BUILTIN and the USER_BTN are defined differently.
Moreover the HSE value is not the same:

Code: Select all

#ifdef ARDUINO_BLACKPILL_F411CE
#define HSE_VALUE               25000000U
#endif
That's explain why the generic doesn't work. Anyway it is possible to use the generic by redefining the HSE_VALUE and using the correct pin for the LED.
gentijo
Posts: 2
Joined: Fri Jul 03, 2020 6:26 am

Re: Help understanding boards.txt (adding new board)

Post by gentijo »

Thank you, that was very helpful
Post Reply

Return to “General discussion”