Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime ESP8285 detection and isFlashInterfacePin(x) #7340

Closed
6 tasks done
mcspr opened this issue May 29, 2020 · 1 comment · Fixed by #8604
Closed
6 tasks done

Runtime ESP8285 detection and isFlashInterfacePin(x) #7340

mcspr opened this issue May 29, 2020 · 1 comment · Fixed by #8604

Comments

@mcspr
Copy link
Collaborator

mcspr commented May 29, 2020

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:

#define isFlashInterfacePin(p) ((p) == 6 || (p) == 7 || (p) == 8 || (p) == 11)

Which happens to be used defensively across the Core:
https://github.com/plerup/espsoftwareserial/blob/594904c7e4eb0ddb23969765ec55f0b91c5b2ca9/src/SoftwareSerial.cpp#L51

if ((pin > 16) || isFlashInterfacePin(pin)) {

if (!isFlashInterfacePin(i))

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.

MCVE Sketch

Debug Messages

@5chufti
Copy link
Contributor

5chufti commented Sep 2, 2020

AFAIK the "generic esp8285" variant is not a necessity but more a convenience, reducing the number of mandatory settings; one can achieve the same result with "generic esp8266" choosing the correct settings.
Some (most) of them primarily necessary for building the fw image or errorchecking.
e.g.: flash config. if one detects esp8285 flashmode dout (and thus used pins) are fixed, but for "the other" esp modules the options for flashmode still are relevant and mandatory (the esp8285 setting being one of the possible options).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants