-->
Page 1 of 2

Preventing compilation to the wrong board

PostPosted: Tue Aug 14, 2018 11:43 pm
by picstart
Observation
Code moves electrons in and out of the MCU's pins. Electrons and Pins are paramount.

Often it is unpleasant to see the pins assigned behind the scenes ( not in main). Like I2C and SPI that have PINs defaulted to Ex D1 D2. This misdirection is quickly learned and when pins aren't explicitly declared the prime directive is to dig them out before using any library routine.

With multiple boards the fact that the board selection is an IDE option and not a code option is unfortunate and requires a work around
To avoid compilation to the wrong MCU esp8266 or esp32 ....code like this is necessary as the first line in main
#if !(defined( ARDUINO_ARCH_ESP8266))
#error Oops! Make sure you have 'ESP8266' compatible board selected from the 'Tools -> Boards' menu.
#endif
Issue
A more perfect workaround would be to specify compilation to a specific board like WeMos D1 R2.
Does anyone Know how to do this?

Re: Preventing compilation to the wrong board

PostPosted: Wed Aug 15, 2018 2:06 pm
by martinayotte
Turn ON Verbosity, you will see that there is also a define per board type.

Re: Preventing compilation to the wrong board

PostPosted: Wed Aug 15, 2018 6:19 pm
by picstart
I run with verbosity on and I do see over 100 references to code but nothing about pins used or the board.
The MCU is disclosed and maybe the board is buried in the hundreds of lines but I don't think so.
I wish was verbose enough to specify the board, the CPU and the pins the compiler is asked to send electrons in and out at the top of the compilation disclosure.
If the electrons don't go out the correct pins or if the board doesn't bring them out so they can influence sensor etc then the code with its hundreds of disclosed dependencies is useless.

Re: Preventing compilation to the wrong board

PostPosted: Thu Aug 16, 2018 2:45 am
by schufti
just strictly use "generic esp8266", use the correct way of designating pins by gpio# and select appropriate settings in IDE for your board. Unfortunately some libraries that use i2c etc don't (visibly) provide means to set used pins. If you initialise i2c before that will most likely work.

All that other fancy stuff for toy-boards (with that Dx name scheme) is unnecessary and useless if you want to know what is happening behind the scene. It is just there for Arduino boys who can't find their way around w/o simplification by uniformity.