Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By picstart
#77768 OK
I understand the fact that it was dumbed down but it is unfortunate that if can't also be smartened up by work arounds. It is very convenient to buy boards farther than chips avoiding having to solder paste bare chips to a custom board.
I now have used a handful of different boards many now are upgraded via OTA. The OTA at least for esp32 does show the board in the ports list next to the IP. However it is possible to upload code to the wrong board by accident. This nearly resulted in an electrical fire when the wrong pin assignment flipped a relay.

I suspect I can work around this by including a well named h file that contains the board constraints for electrical safety and giving it the ability to stop compilation success.

Using the standard GPIO numbers and always generic boards even if using a brand name board is a good suggestion in that it is safer.
I am now aware of the hidden risks in dumbed down code and ways to avoid them.
Thanks
User avatar
By martinayotte
#77770
picstart wrote:I wish was verbose enough to specify the board

On my side, using my old 2.3.0, I'm clearly seeing those defines on every gcc calls :
Code: Select all-DARDUINO=10801 -DARDUINO_ESP8266_WEMOS_D1MINI -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_WEMOS_D1MINI"  -DESP8266


This is provided by platform.txt
Code: Select all-DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}"

https://github.com/esp8266/Arduino/blob ... rm.txt#L86
User avatar
By picstart
#77799 Thankyou
This locks down the board at compile time .
Yeah! It prevents electrons from being moved accidentally around the wrong board

The code below goes in as the first lines and explicitly enforces electrical compliance
#if !(defined( ARDUINO_ESP8266_WEMOS_D1R1))
#error Oops! Make sure you have 'WeMos D1 R1' board selected from the 'Tools -> Boards' menu.
#endif
Observation
The ARDUINO_ is a fixed term of art and the ESP8266_WEMOS_D1R1 is passed from boards.txt ( caution make sure you have the right one a standard installation results in more than one) via the line d1.build.board=ESP8266_WEMOS_D1R1 to the compiler and defined/managed by platform.txt
Ok a few references in and out of files but very acceptable and an easy way to lock the code to the board

I somewhat get the convenience of writing one body of code that can compile and upload to many boards with the IDE controlling the selection. However It can be risky since boards have electrical constraints and code that might be electrically safe on one board may not be as safe on another.

Well I tested the above esp8266 boards and it works
Just in case and frequently there is always a case it tried
#if !(defined( ARDUINO_ESP32_DEV))
#error Oops! Make sure you have 'ESP Dev Module' board selected from the 'Tools -> Boards' menu.
#endif
It doesn't work and allows a compile to a different board go figure.
OK digging a bit deeper I tested the above only against fire beetle ESP32 when specifying ESP32 DEV

Well I love it firebeetle has the same board code namely ESP_DEV so instead of it failing it passed the compilation. So be aware fire beetle and esp32 dev are welded together in boards.txt.
As long as all boards are uniquely identified the above works