Description
Basic Infos
- This issue complies with the issue POLICY doc.
- I have read the documentation at readthedocs and the issue is not addressed there.
- I have tested that the issue is present in current master branch (aka latest git).
- I have searched the issue tracker for a similar issue.
- If there is a stack dump, I have decoded it.
- I have filled out all fields below.
Platform
- Hardware: ESP8286 / ESP8285
- Core Version: 2.7.1
- Development Env: Any
Settings in IDE
- Module: Generic ESP8266 Module / ESP8285
Problem Description
This is more of a feature proposal issue.
Currently, a way to distinguish between esp8266 and esp8285 is by selecting build variant manually, hard-coding certain constants, macros and pin values. Main example is isFlashInterfacePin(X)
macro:
Arduino/variants/esp8285/common.h
Line 34 in 27ef03f
Which happens to be used defensively across the Core:
https://github.com/plerup/espsoftwareserial/blob/594904c7e4eb0ddb23969765ec55f0b91c5b2ca9/src/SoftwareSerial.cpp#L51
However, based on current RTOS code and snippets from esptool.py, we can actually replace macro with a real function detecting pin configuration at runtime (e.g., like one can notice when uploading stuff via esptool.py to the esp8285 device):
https://github.com/espressif/esptool/blob/f04d34bcab29ace798d2d3800ba87020cccbbfdd/esptool.py#L1060-L1070
https://github.com/espressif/ESP8266_RTOS_SDK/blob/3c055779e9793e5f082afff63a011d6615e73639/components/esp8266/include/esp8266/efuse_register.h#L20-L21
Which becomes this piece of code somewhere:
const uint32_t efuse_blocks[4] {
READ_PERI_REG(0x3ff00050),
READ_PERI_REG(0x3ff00054),
READ_PERI_REG(0x3ff00058),
READ_PERI_REG(0x3ff0005c)
};
bool is_esp8285 = (
(efuse_blocks[0] & (1 << 4))
|| (efuse_blocks[2] & (1 << 16))
);
The intent of that is that Generic variant can be merged with esp8285, thus any binary could be built and used with both types of devices.
Although, I wonder if I am missing documentation piece where this is described more clearly, instead of referencing 2-3 lines of code from somewhere.