core and version identification

Post here first, or if you can't find a relevant section!
Post Reply
ag123
Posts: 1657
Joined: Thu Dec 19, 2019 5:30 am
Answers: 25

core and version identification

Post by ag123 »

is there a preprocessor define or a #define tag which i can tell between the cores (e.g. between official & libmaple) and version?
i think there is ARDUINO define, but i'd guess that's for the original Arduino?

it is a little unfortunate as APIs (e.g. SPI) between cores are at least a little different so some ifdefs are necessary
;)
MoDu
Posts: 16
Joined: Mon Jul 20, 2020 10:43 pm

Re: core and version identification

Post by MoDu »

I think ARDUINO_ARCH_STM32F1 works for libmaple (roger's and steve's). Not sure about STM core.

Have you tried this? viewtopic.php?f=7&t=870
ag123
Posts: 1657
Joined: Thu Dec 19, 2019 5:30 am
Answers: 25

Re: core and version identification

Post by ag123 »

it seemed the official stm core could reserve the tag STM32DUINO or __STM32DUINO__ for its tag
not sure what is a failsafe way to do versions, e.g. so that we can have

Code: Select all

#if defined(STM32DUINO) && VERSION > 10000
 //do this
#else
  //do that
#endif
But literally i don't like it just that that's the way the world evolves
:lol:

oh btw i saw that, maybe this would do

Code: Select all

ARDUINO_ARCH_STM32
User avatar
fpiSTM
Posts: 1746
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: core and version identification

Post by fpiSTM »

ag123 wrote: Tue Jan 26, 2021 12:02 pm oh btw i saw that, maybe this would do

Code: Select all

ARDUINO_ARCH_STM32
Right this is the official defintion to use for STM32 core.
For Libmaple F1 as mentionned by@GonzoG :

Code: Select all

ARDUINO_ARCH_STM32F1 
For Libmaple F4:

Code: Select all

ARDUINO_ARCH_STM32F4 
In fact this is specified by Arduino: https://arduino.github.io/arduino-cli/l ... hitectures

Code: Select all

-DARDUINO_ARCH_{build.arch}
ag123
Posts: 1657
Joined: Thu Dec 19, 2019 5:30 am
Answers: 25

Re: core and version identification

Post by ag123 »

thanks ! i'd use these symbols for now :)

oh what about version, does it matter?
i think for now we'd make do 'without versions' (too complicated) :lol:

glibc did something like this
https://stackoverflow.com/questions/426 ... bc-is-used
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: core and version identification

Post by mrburnette »

in the compile/link environment, version is available from platform.txt
name=STM32F1 Boards (Arduino_STM32)
version=0.1.2
User avatar
fpiSTM
Posts: 1746
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: core and version identification

Post by fpiSTM »

For STM32 core since version 1.5.0 IIRW, the version are available this help to maintains some backward compatibility and check:
https://github.com/stm32duino/Arduino_C ... f.h#L5-L21

Code: Select all

/**
 * @brief STM32 core version number
 */
#define STM32_CORE_VERSION_MAJOR    (0x02U) /*!< [31:24] major version */
#define STM32_CORE_VERSION_MINOR    (0x00U) /*!< [23:16] minor version */
#define STM32_CORE_VERSION_PATCH    (0x00U) /*!< [15:8]  patch version */
/*
 * Extra label for development:
 * 0: official release
 * [1-9]: release candidate
 * F[0-9]: development
 */
#define STM32_CORE_VERSION_EXTRA    (0xF0U) /*!< [7:0]  extra version */
#define STM32_CORE_VERSION          ((STM32_CORE_VERSION_MAJOR << 24U)\
                                        |(STM32_CORE_VERSION_MINOR << 16U)\
                                        |(STM32_CORE_VERSION_PATCH << 8U )\
                                        |(STM32_CORE_VERSION_EXTRA))
You can use it like this:

Code: Select all

#if defined(STM32_CORE_VERSION) && (STM32_CORE_VERSION  > 0x01090000)
 // do some specific stuff
#endif
Post Reply

Return to “General discussion”