diff --git a/.github/workflows/build-host.yml b/.github/workflows/build-host.yml new file mode 100644 index 0000000000..ae0353068d --- /dev/null +++ b/.github/workflows/build-host.yml @@ -0,0 +1,40 @@ +# Run host test suite under valgrind for runtime checking of code. +# Also, a quick test that the mocking builds work at all + +name: Build on host OS + +on: + pull_request: + +permissions: + contents: read + +jobs: + host-tests: + name: Tests + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - run: | + sudo apt update + sudo apt install valgrind lcov + bash ./tests/ci/host_test.sh + + mock-check: + name: Mock + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - run: | + cd tests/host + make -j ../../libraries/ESP8266WebServer/examples/FSBrowser/FSBrowser diff --git a/.github/workflows/build-ide.yml b/.github/workflows/build-ide.yml new file mode 100644 index 0000000000..565b08d392 --- /dev/null +++ b/.github/workflows/build-ide.yml @@ -0,0 +1,107 @@ +# Cross-platform builds to ensure our Core and toolchain works + +name: Build IDE examples + +on: + pull_request: + +permissions: + contents: read + +jobs: + + # Examples are built in parallel to avoid CI total job time limitation + sanity-check: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + with: + submodules: false + - uses: actions/cache@v4 + with: + path: ./tools/dist + key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh', 'tests/build.sh') }} + - name: Toolchain sanity checks + run: | + bash ./tests/sanity_check.sh + + build-linux: + name: Linux - LwIP ${{ matrix.lwip }} (${{ matrix.chunk }}) + runs-on: ubuntu-latest + defaults: + run: + shell: bash + strategy: + matrix: + lwip: ["default", "IPv6"] + chunk: [0, 1, 2, 3, 4, 5, 6, 7] + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + - uses: actions/cache@v4 + with: + path: ./tools/dist + key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh', 'tests/build.sh') }} + - name: Build Sketches + env: + ESP8266_ARDUINO_BUILDER: "arduino" + ESP8266_ARDUINO_IDE: "${{ runner.temp }}/arduino_ide" + ESP8266_ARDUINO_LWIP: ${{ matrix.lwip }} + run: | + bash ./tests/build.sh 8 ${{ matrix.chunk }} + + # Just try to build at least one sketch, since we spend so much time with the matrix above + + build-windows: + name: Windows + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: false + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + - uses: actions/cache@v4 + with: + path: ./tools/dist + key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh', 'tests/build.sh') }} + - name: Build Sketch + env: + ESP8266_ARDUINO_HARDWARE: "${{ runner.temp }}/hardware" + ESP8266_ARDUINO_IDE: "${{ runner.temp }}/arduino_ide" + ESP8266_ARDUINO_SKETCHES: "libraries/esp8266/examples/Blink/Blink.ino" + run: | + bash ./tests/build.sh + + build-mac: + name: macOS + runs-on: macOS-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + with: + submodules: false + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + - uses: actions/cache@v4 + with: + path: ./tools/dist + key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh', 'tests/build.sh') }} + - name: Build Sketch + env: + ESP8266_ARDUINO_HARDWARE: "${{ runner.temp }}/hardware" + ESP8266_ARDUINO_IDE: "${{ runner.temp }}/arduino_ide" + ESP8266_ARDUINO_SKETCHES: "libraries/esp8266/examples/Blink/Blink.ino" + run: | + bash ./tests/build.sh diff --git a/.github/workflows/build-platformio.yml b/.github/workflows/build-platformio.yml new file mode 100644 index 0000000000..5150a4bd29 --- /dev/null +++ b/.github/workflows/build-platformio.yml @@ -0,0 +1,39 @@ +# We do not distribute any environment settings, so just try to build some sketches +# using the 'master' branch and using the uploaded toolchain version via get.py +# Also, limit the amount of sketches and simply + +name: Build examples with PlatformIO + +on: + pull_request: + +permissions: + contents: read + +jobs: + build-pio: + name: Linux (random sketches) + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + - uses: actions/cache@v4 + with: + path: | + tools/dist + ~/.cache/pip + ~/.platformio/.cache + key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh', 'tests/build.sh') }} + - name: Build + env: + ESP8266_ARDUINO_BUILDER: "platformio" + run: | + pip install -U platformio + env ESP8266_ARDUINO_SKETCHES="$(find libraries/ -name '*.ino' | shuf -n 10 -)" bash ./tests/build.sh diff --git a/.github/workflows/check-autogenerated.yml b/.github/workflows/check-autogenerated.yml new file mode 100644 index 0000000000..40f3f93e70 --- /dev/null +++ b/.github/workflows/check-autogenerated.yml @@ -0,0 +1,62 @@ +# Ensure no manual edits happen to our autogenerated files + +name: Check autogenerated files + +on: + pull_request: + +permissions: + contents: read + +jobs: + pkgrefs-check: + name: .json template + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + with: + submodules: false + - run: | + bash ./tests/ci/pkgrefs_test.sh + + eboot-check: + name: eboot .elf + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + with: + submodules: false + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + - uses: actions/cache@v4 + with: + path: ./tools/dist + key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh') }} + - run: | + # ^ reuse toolchain cache from our linux build job + git submodule update --init --remote tools/sdk/uzlib + bash ./tests/ci/eboot_test.sh + + boards-txt-check: + name: boards.txt.py + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + with: + submodules: false + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + - name: Check git-diff result + run: | + bash ./tests/ci/build_boards.sh diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml new file mode 100644 index 0000000000..977570aad8 --- /dev/null +++ b/.github/workflows/documentation.yml @@ -0,0 +1,31 @@ +# Ensure Sphinx can build the documentation properly. + +name: Documentation + +on: + pull_request: + +permissions: + contents: read + +jobs: + documentation: + name: Sphinx build + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + - name: Build documentation + run: | + pushd doc/ + python3 -mvenv _venv + ./_venv/bin/pip install -r requirements.txt + env SPHINXBUILD=$(pwd)/_venv/bin/sphinx-build ../tests/ci/build_docs.sh + popd diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml deleted file mode 100644 index a1bd24d456..0000000000 --- a/.github/workflows/pull-request.yml +++ /dev/null @@ -1,330 +0,0 @@ -# Run whenever a PR is generated or updated. - -# Most jobs check out the code, ensure Python3 is installed, and for build -# tests the ESP8266 toolchain is cached when possible to speed up execution. - -name: ESP8266 Arduino CI - -on: - pull_request: - - -permissions: - contents: read - - -jobs: - -# Run 8 parallel jobs for the default build of all examples. - build-linux: - name: Build ${{ matrix.chunk }} - runs-on: ubuntu-latest - defaults: - run: - shell: bash - strategy: - matrix: - chunk: [0, 1, 2, 3, 4, 5, 6, 7] - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - name: Cache Linux toolchain - id: cache-linux - uses: actions/cache@v3 - with: - path: ./tools/dist - key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh') }} - - name: Build Sketches - env: - TRAVIS_BUILD_DIR: ${{ github.workspace }} - TRAVIS_TAG: ${{ github.ref }} - BUILD_PARITY: custom - mod: 8 - rem: ${{ matrix.chunk }} - run: | - bash ./tests/build.sh - - -# Cover the debug and IPv6 cases by enabling both and running 8 parallel jobs -# over all example code. - build-debug-ipv6: - name: Debug IPv6 ${{ matrix.chunk }} - runs-on: ubuntu-latest - defaults: - run: - shell: bash - strategy: - matrix: - chunk: [0, 1, 2, 3, 4, 5, 6, 7] - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - name: Cache Linux toolchain - id: cache-linux - uses: actions/cache@v3 - with: - path: ./tools/dist - key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh') }} - - name: Build Sketches - env: - TRAVIS_BUILD_DIR: ${{ github.workspace }} - TRAVIS_TAG: ${{ github.ref }} - BUILD_PARITY: custom - mod: 8 - rem: ${{ matrix.chunk }} - run: | - bash ./tests/debug6.sh - - -# Single build under Windows to ensure the Win toolchain is good. - build-windows: - name: Windows - runs-on: windows-latest - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - name: Cache Windows toolchain - id: cache-windows - uses: actions/cache@v3 - with: - path: ./tools/dist - key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh') }} - - name: Build Sketch - env: - TRAVIS_BUILD_DIR: ${{ github.workspace }} - TRAVIS_TAG: ${{ github.ref }} - WINDOWS: 1 - BUILD_PARITY: custom - mod: 500 - rem: 1 - run: | - # Windows has python3 already installed, but it's called "python". - # Copy python.exe to the proper name so scripts "just work". - try { Get-Command python3 } catch { copy (get-command python).source (get-command python).source.Replace("python.exe", "python3.exe") } - bash ./tests/build.sh - - -# Single build under macOS to ensure the Mac toolchain is good. - build-mac: - name: Mac - runs-on: macOS-latest - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - name: Cache Mac toolchain - id: cache-mac - uses: actions/cache@v3 - with: - path: ./tools/dist - key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh') }} - - name: Build Sketch - env: - TRAVIS_BUILD_DIR: ${{ github.workspace }} - TRAVIS_TAG: ${{ github.ref }} - MACOSX: 1 - BUILD_PARITY: custom - mod: 500 - rem: 1 - run: | - bash ./tests/build.sh - - -# Run a few Platform.IO jobs (not full suite) to check PIO integration. - build-pio: - name: Build Platform.IO - runs-on: ubuntu-latest - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - name: Build subset on Platform.IO - env: - TRAVIS_BUILD_DIR: ${{ github.workspace }} - TRAVIS_TAG: ${{ github.ref }} - BUILD_PARITY: custom - mod: 42 # Picked at random to give 4-5 builds and exit. - rem: 13 - run: | - sudo apt update - sudo apt install python3-pip python3-setuptools - PATH=/home/runner/.local/bin:$PATH bash ./tests/platformio.sh - - -# Run host test suite under valgrind for runtime checking of code. - host-tests: - name: Host tests - runs-on: ubuntu-latest - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - name: Run host tests - env: - TRAVIS_BUILD_DIR: ${{ github.workspace }} - TRAVIS_TAG: ${{ github.ref }} - run: | - sudo apt update - sudo apt install valgrind lcov - bash ./tests/ci/host_test.sh - - -# Ensure Sphinx can build the documentation properly. - documentation: - name: Documentation - runs-on: ubuntu-latest - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - name: Build documentation - env: - TRAVIS_BUILD_DIR: ${{ github.workspace }} - TRAVIS_TAG: ${{ github.ref }} - run: | - sudo apt update - sudo apt install python3-pip python3-setuptools - # GitHub CI installs pip3 and setuptools outside the path. - # Update the path to include them and run. - PATH=/home/runner/.local/bin:$PATH pip3 install --user -r doc/requirements.txt - PATH=/home/runner/.local/bin:$PATH bash ./tests/ci/build_docs.sh - - -# Standard Arduino formatting in all the examples - style-check: - name: Style and formatting - runs-on: ubuntu-latest - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - name: Style check - env: - LLVM_SNAPSHOT_KEY: "6084F3CF814B57C1CF12EFD515CF4D18AF4F7421" - TRAVIS_BUILD_DIR: ${{ github.workspace }} - TRAVIS_TAG: ${{ github.ref }} - run: | - export GNUPGHOME=$(mktemp -d) - gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$LLVM_SNAPSHOT_KEY" - gpg --batch --armor --export "$LLVM_SNAPSHOT_KEY" | \ - sudo tee /etc/apt/trusted.gpg.d/llvm-snapshot.gpg.asc - gpgconf --kill all - rm -r $GNUPGHOME - echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main" | \ - sudo tee /etc/apt/sources.list.d/llvm.list - sudo apt update - sudo apt install clang-format-13 - pip3 install pyyaml - bash ./tests/ci/style_check.sh - - -# Quick test that the mocking builds succeed - mock-check: - name: Mock trivial test - runs-on: ubuntu-latest - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - name: Mock build - env: - TRAVIS_BUILD_DIR: ${{ github.workspace }} - TRAVIS_TAG: ${{ github.ref }} - run: | - bash ./tests/buildm.sh - - -# Ensure no manual edits to boards.txt - boards-check: - name: Boards.txt check - runs-on: ubuntu-latest - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - name: Cache Linux toolchain - id: cache-linux - uses: actions/cache@v3 - with: - path: ./tools/dist - key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh') }} - - name: Boards.txt diff - env: - TRAVIS_BUILD_DIR: ${{ github.workspace }} - TRAVIS_TAG: ${{ github.ref }} - run: | - bash ./tests/ci/build_boards.sh - bash ./tests/ci/eboot_test.sh - bash ./tests/ci/pkgrefs_test.sh - - -# Validate orthography - code-spell: - name: Check spelling - runs-on: ubuntu-latest - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - name: Run codespell - uses: codespell-project/actions-codespell@master - with: - skip: ./libraries/ESP8266SdFat,./libraries/LittleFS/lib,./tools/pyserial,./tools/sdk,./tools/esptool,./libraries/SoftwareSerial,./libraries/Ethernet,./github/workflows,./libraries/ESP8266HTTPUpdateServer/examples/SecureBearSSLUpdater/SecureBearSSLUpdater.ino,./libraries/esp8266/examples/RTCUserMemory/RTCUserMemory.ino,./libraries/esp8266/examples/StreamString/StreamString.ino,./libraries/ESP8266WiFi/examples/BearSSL_Validation/BearSSL_Validation.ino,./libraries/ESP8266WiFi/examples/BearSSL_Sessions/BearSSL_Sessions.ino,./libraries/ESP8266WebServer/examples/HelloServerBearSSL/HelloServerBearSSL.ino,./libraries/ESP8266WebServer/examples/HttpHashCredAuth/HttpHashCredAuth.ino,./cores/esp8266/spiffs,./tests/device/test_libc/libm_string.c, ./libraries/Netdump/examples/Netdump/Netdump.ino,./libraries/ESP8266WiFi/examples/BearSSL_Server,./cores/esp8266/LwipIntfDev.h - ignore_words_list: ESP8266,esp8266,esp,dout,DOUT,ser,ans diff --git a/.github/workflows/release-to-publish.yml b/.github/workflows/release-to-publish.yml index cdba16b325..3a80412551 100644 --- a/.github/workflows/release-to-publish.yml +++ b/.github/workflows/release-to-publish.yml @@ -35,17 +35,13 @@ jobs: package: name: Update master JSON file runs-on: ubuntu-latest - defaults: - run: - shell: bash steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: false fetch-depth: 0 - name: Deploy updated JSON env: - TRAVIS_BUILD_DIR: ${{ github.workspace }} BUILD_TYPE: package CI_GITHUB_API_KEY: ${{ secrets.GITHUB_TOKEN }} GHCI_DEPLOY_KEY: ${{ secrets.GHCI_DEPLOY_KEY }} diff --git a/.github/workflows/style-check.yml b/.github/workflows/style-check.yml new file mode 100644 index 0000000000..c371c2f252 --- /dev/null +++ b/.github/workflows/style-check.yml @@ -0,0 +1,45 @@ +name: Style and syntax checks + +on: + pull_request: + +permissions: + contents: read + +jobs: + + # Generic formatting for Core and examples + + clang-format: + name: clang-format + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + - name: Style check + run: | + sudo apt update + python ./tests/test_restyle.py --quiet + env CLANG_FORMAT="clang-format-18" bash ./tests/ci/style_check.sh + + # Validate orthography + + code-spell: + name: codespell + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: false + - name: Run codespell + uses: codespell-project/actions-codespell@master + with: + skip: ./libraries/ESP8266SdFat,./libraries/LittleFS/lib,./tools/pyserial,./tools/sdk,./tools/esptool,./libraries/SoftwareSerial,./libraries/Ethernet,./github/workflows,./libraries/ESP8266HTTPUpdateServer/examples/SecureBearSSLUpdater/SecureBearSSLUpdater.ino,./libraries/esp8266/examples/RTCUserMemory/RTCUserMemory.ino,./libraries/esp8266/examples/StreamString/StreamString.ino,./libraries/ESP8266WiFi/examples/BearSSL_Validation/BearSSL_Validation.ino,./libraries/ESP8266WiFi/examples/BearSSL_Sessions/BearSSL_Sessions.ino,./libraries/ESP8266WebServer/examples/HelloServerBearSSL/HelloServerBearSSL.ino,./libraries/ESP8266WebServer/examples/HttpHashCredAuth/HttpHashCredAuth.ino,./cores/esp8266/spiffs,./tests/device/test_libc/libm_string.c, ./libraries/Netdump/examples/Netdump/Netdump.ino,./libraries/ESP8266WiFi/examples/BearSSL_Server,./cores/esp8266/LwipIntfDev.h + ignore_words_list: ESP8266,esp8266,esp,dout,DOUT,ser,ans diff --git a/.github/workflows/tag-to-draft-release.yml b/.github/workflows/tag-to-draft-release.yml index fc87f1ba87..e9311f9fce 100644 --- a/.github/workflows/tag-to-draft-release.yml +++ b/.github/workflows/tag-to-draft-release.yml @@ -18,28 +18,34 @@ jobs: run: shell: bash steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true fetch-depth: 0 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: '3.x' - name: Set GIT tag name run: | # Sets an environment variable used in the next steps - TRAVIS_TAG="$(git describe --exact-match --tags)" - echo "TRAVIS_TAG=${TRAVIS_TAG}" >> $GITHUB_ENV + ESP8266_ARDUINO_RELEASE_TAG="$(git describe --exact-match --tags)" + echo "ESP8266_ARDUINO_RELEASE_TAG=${ESP8266_ARDUINO_RELEASE_TAG}" >> $GITHUB_ENV - name: Build package JSON env: - TRAVIS_BUILD_DIR: ${{ github.workspace }} - BUILD_TYPE: package CI_GITHUB_API_KEY: ${{ secrets.GITHUB_TOKEN }} + BUILD_TYPE: package run: | - bash ./tests/ci/build_package.sh - pip3 install PyGithub - # Create a draft release and upload the ZIP and JSON files. - # This draft is not visible to normal users and needs to be - # updated manually with release notes and published from the - # GitHub web interface. - python3 ./package/upload_release.py --user "$GITHUB_ACTOR" --repo "$GITHUB_REPOSITORY" --token "$CI_GITHUB_API_KEY" --tag "$TRAVIS_TAG" --name "Release $TRAVIS_TAG" --msg "Update the draft with release notes before publishing." package/versions/*/*.zip package/versions/*/package_esp8266com_index.json + bash ./tests/ci/build_package.sh + # Create a draft release and upload the ZIP and JSON files. + # This draft is not visible to normal users and needs to be + # updated manually with release notes and published from the + # GitHub web interface. + pip3 install PyGithub + python3 ./package/upload_release.py \ + --user "$GITHUB_ACTOR" \ + --repo "$GITHUB_REPOSITORY" \ + --token "$CI_GITHUB_API_KEY" \ + --tag "$ESP8266_ARDUINO_RELEASE_TAG" \ + --name "Release ${ESP8266_ARDUINO_RELEASE_TAG}" \ + --msg "Update the draft with release notes before publishing." \ + package/versions/*/*.zip package/versions/*/package_esp8266com_index.json diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000000..867f3d40de --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,21 @@ +# Read the Docs configuration file for Sphinx projects +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +# Set the OS, Python version and other tools you might need +build: + os: ubuntu-24.04 + tools: + python: "3.12" + +# Build documentation in the "doc/" directory with Sphinx +sphinx: + configuration: doc/conf.py + +# Install same versions as our local tools +# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html +python: + install: + - requirements: doc/requirements.txt diff --git a/README.md b/README.md index 9f49aa9390..21ec6ef397 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Arduino core for ESP8266 WiFi chip # Quick links -- [Latest release documentation](https://arduino-esp8266.readthedocs.io/en/3.0.2/) +- [Latest release documentation](https://arduino-esp8266.readthedocs.io/en/3.1.2/) - [Current "git version" documentation](https://arduino-esp8266.readthedocs.io/en/latest/) - [Install git version](https://arduino-esp8266.readthedocs.io/en/latest/installing.html#using-git-version) ([sources](doc/installing.rst#using-git-version)) @@ -28,23 +28,22 @@ ESP8266 Arduino core comes with libraries to communicate over WiFi using TCP and Starting with 1.6.4, Arduino allows installation of third-party platform packages using Boards Manager. We have packages available for Windows, Mac OS, and Linux (32 and 64 bit). -- Install the current upstream Arduino IDE at the 1.8.9 level or later. The current version is on the [Arduino website](https://www.arduino.cc/en/software). -- Start Arduino and open the Preferences window. -- Enter ```https://arduino.esp8266.com/stable/package_esp8266com_index.json``` into the *File>Preferences>Additional Boards Manager URLs* field of the Arduino IDE. You can add multiple URLs, separating them with commas. +- [Download and install Arduino IDE 1.x or 2.x](https://www.arduino.cc/en/software) +- Start Arduino and open the Preferences window +- Enter `https://arduino.esp8266.com/stable/package_esp8266com_index.json` into the *File>Preferences>Additional Boards Manager URLs* field of the Arduino IDE. You can add multiple URLs, separating them with commas. - Open Boards Manager from Tools > Board menu and install *esp8266* platform (and don't forget to select your ESP8266 board from Tools > Board menu after installation). #### Latest release [![Latest release](https://img.shields.io/github/release/esp8266/Arduino.svg)](https://github.com/esp8266/Arduino/releases/latest/) Boards manager link: `https://arduino.esp8266.com/stable/package_esp8266com_index.json` -Documentation: [https://arduino-esp8266.readthedocs.io/en/3.0.2/](https://arduino-esp8266.readthedocs.io/en/3.0.2/) +Documentation: [https://arduino-esp8266.readthedocs.io/en/3.1.2/](https://arduino-esp8266.readthedocs.io/en/3.1.2/) ### Using git version -[![Linux build status](https://travis-ci.org/esp8266/Arduino.svg)](https://travis-ci.org/esp8266/Arduino) Also known as latest git or master branch. -- Install the current upstream Arduino IDE at the 1.8 level or later. The current version is on the [Arduino website](https://www.arduino.cc/en/software). -- Follow the [instructions in the documentation](https://arduino-esp8266.readthedocs.io/en/latest/installing.html#using-git-version). +- When using [Arduino IDE](https://www.arduino.cc/en/software), follow [our instructions here](https://arduino-esp8266.readthedocs.io/en/latest/installing.html#using-git-version). +- When using [PlatformIO](https://platformio.org/install), refer to [platformio/espressif8266 platform documentation](https://docs.platformio.org/en/stable/platforms/espressif8266.html#using-arduino-framework-with-staging-version). ### Using PlatformIO diff --git a/boards.txt b/boards.txt index 7204ffdca5..1b44fe3310 100644 --- a/boards.txt +++ b/boards.txt @@ -17,12 +17,14 @@ menu.FlashFreq=Flash Frequency menu.ResetMethod=Reset Method menu.dbg=Debug port menu.lvl=Debug Level +menu.optim=Debug Optimization menu.ip=lwIP Variant menu.vt=VTables menu.exception=C++ Exceptions menu.stacksmash=Stack Protection menu.wipe=Erase Flash -menu.sdk=Espressif FW +menu.sdk=NONOS SDK Version +menu.iramfloat=Floating Point operations menu.ssl=SSL Support menu.mmu=MMU menu.non32xfer=Non-32-Bit Access @@ -40,6 +42,7 @@ generic.build.mcu=esp8266 generic.build.core=esp8266 generic.build.variant=generic generic.build.spiffs_pagesize=256 +generic.build.debug_optim= generic.build.debug_port= generic.build.debug_level= generic.menu.xtal.80=80 MHz @@ -363,8 +366,8 @@ generic.menu.sdk.nonosdk_190313=nonos-sdk 2.2.1+61 (190313) generic.menu.sdk.nonosdk_190313.build.sdk=NONOSDK22x_190313 generic.menu.sdk.nonosdk221=nonos-sdk 2.2.1 (legacy) generic.menu.sdk.nonosdk221.build.sdk=NONOSDK221 -generic.menu.sdk.nonosdk3v0=nonos-sdk pre-3 (180626 known issues) -generic.menu.sdk.nonosdk3v0.build.sdk=NONOSDK3V0 +generic.menu.sdk.nonosdk305=nonos-sdk 3.0.5 (experimental) +generic.menu.sdk.nonosdk305.build.sdk=NONOSDK305 generic.menu.ip.lm2f=v2 Lower Memory generic.menu.ip.lm2f.build.lwip_include=lwip2/include generic.menu.ip.lm2f.build.lwip_lib=-llwip2-536-feat @@ -397,6 +400,12 @@ generic.menu.dbg.Serial1=Serial1 generic.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 generic.menu.lvl.None____=None generic.menu.lvl.None____.build.debug_level= +generic.menu.optim.Smallest=None +generic.menu.optim.Smallest.build.debug_optim=-Os +generic.menu.optim.Lite=Lite +generic.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +generic.menu.optim.Full=Optimum +generic.menu.optim.Full.build.debug_optim=-Og generic.menu.lvl.SSL=SSL generic.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL generic.menu.lvl.TLS_MEM=TLS_MEM @@ -488,6 +497,10 @@ generic.menu.eesz.autoflash.build.flash_size=16M generic.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld generic.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 generic.menu.eesz.autoflash.upload.maximum_size=1044464 +generic.menu.iramfloat.no=in IROM +generic.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +generic.menu.iramfloat.yes=allowed in ISR +generic.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## esp8285.name=Generic ESP8285 Module @@ -502,6 +515,7 @@ esp8285.serial.disableRTS=true esp8285.build.mcu=esp8266 esp8285.build.core=esp8266 esp8285.build.spiffs_pagesize=256 +esp8285.build.debug_optim= esp8285.build.debug_port= esp8285.build.debug_level= esp8285.menu.xtal.80=80 MHz @@ -708,8 +722,8 @@ esp8285.menu.sdk.nonosdk_190313=nonos-sdk 2.2.1+61 (190313) esp8285.menu.sdk.nonosdk_190313.build.sdk=NONOSDK22x_190313 esp8285.menu.sdk.nonosdk221=nonos-sdk 2.2.1 (legacy) esp8285.menu.sdk.nonosdk221.build.sdk=NONOSDK221 -esp8285.menu.sdk.nonosdk3v0=nonos-sdk pre-3 (180626 known issues) -esp8285.menu.sdk.nonosdk3v0.build.sdk=NONOSDK3V0 +esp8285.menu.sdk.nonosdk305=nonos-sdk 3.0.5 (experimental) +esp8285.menu.sdk.nonosdk305.build.sdk=NONOSDK305 esp8285.menu.ip.lm2f=v2 Lower Memory esp8285.menu.ip.lm2f.build.lwip_include=lwip2/include esp8285.menu.ip.lm2f.build.lwip_lib=-llwip2-536-feat @@ -742,6 +756,12 @@ esp8285.menu.dbg.Serial1=Serial1 esp8285.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 esp8285.menu.lvl.None____=None esp8285.menu.lvl.None____.build.debug_level= +esp8285.menu.optim.Smallest=None +esp8285.menu.optim.Smallest.build.debug_optim=-Os +esp8285.menu.optim.Lite=Lite +esp8285.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +esp8285.menu.optim.Full=Optimum +esp8285.menu.optim.Full.build.debug_optim=-Og esp8285.menu.lvl.SSL=SSL esp8285.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL esp8285.menu.lvl.TLS_MEM=TLS_MEM @@ -833,6 +853,10 @@ esp8285.menu.eesz.autoflash.build.flash_size=16M esp8285.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld esp8285.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 esp8285.menu.eesz.autoflash.upload.maximum_size=1044464 +esp8285.menu.iramfloat.no=in IROM +esp8285.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +esp8285.menu.iramfloat.yes=allowed in ISR +esp8285.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## gen4iod.name=4D Systems gen4 IoD Range @@ -848,6 +872,7 @@ gen4iod.serial.disableRTS=true gen4iod.build.mcu=esp8266 gen4iod.build.core=esp8266 gen4iod.build.spiffs_pagesize=256 +gen4iod.build.debug_optim= gen4iod.build.debug_port= gen4iod.build.debug_level= gen4iod.menu.xtal.80=80 MHz @@ -1010,6 +1035,12 @@ gen4iod.menu.dbg.Serial1=Serial1 gen4iod.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 gen4iod.menu.lvl.None____=None gen4iod.menu.lvl.None____.build.debug_level= +gen4iod.menu.optim.Smallest=None +gen4iod.menu.optim.Smallest.build.debug_optim=-Os +gen4iod.menu.optim.Lite=Lite +gen4iod.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +gen4iod.menu.optim.Full=Optimum +gen4iod.menu.optim.Full.build.debug_optim=-Og gen4iod.menu.lvl.SSL=SSL gen4iod.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL gen4iod.menu.lvl.TLS_MEM=TLS_MEM @@ -1101,6 +1132,10 @@ gen4iod.menu.eesz.autoflash.build.flash_size=16M gen4iod.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld gen4iod.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 gen4iod.menu.eesz.autoflash.upload.maximum_size=1044464 +gen4iod.menu.iramfloat.no=in IROM +gen4iod.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +gen4iod.menu.iramfloat.yes=allowed in ISR +gen4iod.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## huzzah.name=Adafruit Feather HUZZAH ESP8266 @@ -1115,6 +1150,7 @@ huzzah.serial.disableRTS=true huzzah.build.mcu=esp8266 huzzah.build.core=esp8266 huzzah.build.spiffs_pagesize=256 +huzzah.build.debug_optim= huzzah.build.debug_port= huzzah.build.debug_level= huzzah.menu.xtal.80=80 MHz @@ -1222,6 +1258,12 @@ huzzah.menu.dbg.Serial1=Serial1 huzzah.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 huzzah.menu.lvl.None____=None huzzah.menu.lvl.None____.build.debug_level= +huzzah.menu.optim.Smallest=None +huzzah.menu.optim.Smallest.build.debug_optim=-Os +huzzah.menu.optim.Lite=Lite +huzzah.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +huzzah.menu.optim.Full=Optimum +huzzah.menu.optim.Full.build.debug_optim=-Og huzzah.menu.lvl.SSL=SSL huzzah.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL huzzah.menu.lvl.TLS_MEM=TLS_MEM @@ -1313,6 +1355,10 @@ huzzah.menu.eesz.autoflash.build.flash_size=16M huzzah.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld huzzah.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 huzzah.menu.eesz.autoflash.upload.maximum_size=1044464 +huzzah.menu.iramfloat.no=in IROM +huzzah.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +huzzah.menu.iramfloat.yes=allowed in ISR +huzzah.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## wifi_slot.name=Amperka WiFi Slot @@ -1327,6 +1373,7 @@ wifi_slot.serial.disableRTS=true wifi_slot.build.mcu=esp8266 wifi_slot.build.core=esp8266 wifi_slot.build.spiffs_pagesize=256 +wifi_slot.build.debug_optim= wifi_slot.build.debug_port= wifi_slot.build.debug_level= wifi_slot.menu.xtal.80=80 MHz @@ -1528,6 +1575,12 @@ wifi_slot.menu.dbg.Serial1=Serial1 wifi_slot.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 wifi_slot.menu.lvl.None____=None wifi_slot.menu.lvl.None____.build.debug_level= +wifi_slot.menu.optim.Smallest=None +wifi_slot.menu.optim.Smallest.build.debug_optim=-Os +wifi_slot.menu.optim.Lite=Lite +wifi_slot.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +wifi_slot.menu.optim.Full=Optimum +wifi_slot.menu.optim.Full.build.debug_optim=-Og wifi_slot.menu.lvl.SSL=SSL wifi_slot.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL wifi_slot.menu.lvl.TLS_MEM=TLS_MEM @@ -1619,6 +1672,10 @@ wifi_slot.menu.eesz.autoflash.build.flash_size=16M wifi_slot.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld wifi_slot.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 wifi_slot.menu.eesz.autoflash.upload.maximum_size=1044464 +wifi_slot.menu.iramfloat.no=in IROM +wifi_slot.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +wifi_slot.menu.iramfloat.yes=allowed in ISR +wifi_slot.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## arduino-esp8266.name=Arduino @@ -1645,6 +1702,7 @@ arduino-esp8266.build.mcu=esp8266 arduino-esp8266.build.core=esp8266 arduino-esp8266.build.variant=generic arduino-esp8266.build.spiffs_pagesize=256 +arduino-esp8266.build.debug_optim= arduino-esp8266.build.debug_port= arduino-esp8266.build.debug_level= arduino-esp8266.menu.xtal.80=80 MHz @@ -1752,6 +1810,12 @@ arduino-esp8266.menu.dbg.Serial1=Serial1 arduino-esp8266.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 arduino-esp8266.menu.lvl.None____=None arduino-esp8266.menu.lvl.None____.build.debug_level= +arduino-esp8266.menu.optim.Smallest=None +arduino-esp8266.menu.optim.Smallest.build.debug_optim=-Os +arduino-esp8266.menu.optim.Lite=Lite +arduino-esp8266.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +arduino-esp8266.menu.optim.Full=Optimum +arduino-esp8266.menu.optim.Full.build.debug_optim=-Og arduino-esp8266.menu.lvl.SSL=SSL arduino-esp8266.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL arduino-esp8266.menu.lvl.TLS_MEM=TLS_MEM @@ -1843,6 +1907,10 @@ arduino-esp8266.menu.eesz.autoflash.build.flash_size=16M arduino-esp8266.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld arduino-esp8266.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 arduino-esp8266.menu.eesz.autoflash.upload.maximum_size=1044464 +arduino-esp8266.menu.iramfloat.no=in IROM +arduino-esp8266.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +arduino-esp8266.menu.iramfloat.yes=allowed in ISR +arduino-esp8266.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## espmxdevkit.name=DOIT ESP-Mx DevKit (ESP8285) @@ -1858,6 +1926,7 @@ espmxdevkit.serial.disableRTS=true espmxdevkit.build.mcu=esp8266 espmxdevkit.build.core=esp8266 espmxdevkit.build.spiffs_pagesize=256 +espmxdevkit.build.debug_optim= espmxdevkit.build.debug_port= espmxdevkit.build.debug_level= espmxdevkit.menu.xtal.80=80 MHz @@ -1997,6 +2066,12 @@ espmxdevkit.menu.dbg.Serial1=Serial1 espmxdevkit.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 espmxdevkit.menu.lvl.None____=None espmxdevkit.menu.lvl.None____.build.debug_level= +espmxdevkit.menu.optim.Smallest=None +espmxdevkit.menu.optim.Smallest.build.debug_optim=-Os +espmxdevkit.menu.optim.Lite=Lite +espmxdevkit.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +espmxdevkit.menu.optim.Full=Optimum +espmxdevkit.menu.optim.Full.build.debug_optim=-Og espmxdevkit.menu.lvl.SSL=SSL espmxdevkit.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL espmxdevkit.menu.lvl.TLS_MEM=TLS_MEM @@ -2088,6 +2163,10 @@ espmxdevkit.menu.eesz.autoflash.build.flash_size=16M espmxdevkit.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld espmxdevkit.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 espmxdevkit.menu.eesz.autoflash.upload.maximum_size=1044464 +espmxdevkit.menu.iramfloat.no=in IROM +espmxdevkit.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +espmxdevkit.menu.iramfloat.yes=allowed in ISR +espmxdevkit.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## oak.name=Digistump Oak @@ -2103,6 +2182,7 @@ oak.serial.disableRTS=true oak.build.mcu=esp8266 oak.build.core=esp8266 oak.build.spiffs_pagesize=256 +oak.build.debug_optim= oak.build.debug_port= oak.build.debug_level= oak.menu.xtal.80=80 MHz @@ -2210,6 +2290,12 @@ oak.menu.dbg.Serial1=Serial1 oak.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 oak.menu.lvl.None____=None oak.menu.lvl.None____.build.debug_level= +oak.menu.optim.Smallest=None +oak.menu.optim.Smallest.build.debug_optim=-Os +oak.menu.optim.Lite=Lite +oak.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +oak.menu.optim.Full=Optimum +oak.menu.optim.Full.build.debug_optim=-Og oak.menu.lvl.SSL=SSL oak.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL oak.menu.lvl.TLS_MEM=TLS_MEM @@ -2301,6 +2387,10 @@ oak.menu.eesz.autoflash.build.flash_size=16M oak.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld oak.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 oak.menu.eesz.autoflash.upload.maximum_size=1044464 +oak.menu.iramfloat.no=in IROM +oak.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +oak.menu.iramfloat.yes=allowed in ISR +oak.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## espduino.name=ESPDuino (ESP-13 Module) @@ -2324,6 +2414,7 @@ espduino.serial.disableRTS=true espduino.build.mcu=esp8266 espduino.build.core=esp8266 espduino.build.spiffs_pagesize=256 +espduino.build.debug_optim= espduino.build.debug_port= espduino.build.debug_level= espduino.menu.xtal.80=80 MHz @@ -2430,6 +2521,12 @@ espduino.menu.dbg.Serial1=Serial1 espduino.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 espduino.menu.lvl.None____=None espduino.menu.lvl.None____.build.debug_level= +espduino.menu.optim.Smallest=None +espduino.menu.optim.Smallest.build.debug_optim=-Os +espduino.menu.optim.Lite=Lite +espduino.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +espduino.menu.optim.Full=Optimum +espduino.menu.optim.Full.build.debug_optim=-Og espduino.menu.lvl.SSL=SSL espduino.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL espduino.menu.lvl.TLS_MEM=TLS_MEM @@ -2521,6 +2618,10 @@ espduino.menu.eesz.autoflash.build.flash_size=16M espduino.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld espduino.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 espduino.menu.eesz.autoflash.upload.maximum_size=1044464 +espduino.menu.iramfloat.no=in IROM +espduino.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +espduino.menu.iramfloat.yes=allowed in ISR +espduino.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## espectro.name=ESPectro Core @@ -2535,6 +2636,7 @@ espectro.serial.disableRTS=true espectro.build.mcu=esp8266 espectro.build.core=esp8266 espectro.build.spiffs_pagesize=256 +espectro.build.debug_optim= espectro.build.debug_port= espectro.build.debug_level= espectro.menu.xtal.80=80 MHz @@ -2642,6 +2744,12 @@ espectro.menu.dbg.Serial1=Serial1 espectro.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 espectro.menu.lvl.None____=None espectro.menu.lvl.None____.build.debug_level= +espectro.menu.optim.Smallest=None +espectro.menu.optim.Smallest.build.debug_optim=-Os +espectro.menu.optim.Lite=Lite +espectro.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +espectro.menu.optim.Full=Optimum +espectro.menu.optim.Full.build.debug_optim=-Og espectro.menu.lvl.SSL=SSL espectro.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL espectro.menu.lvl.TLS_MEM=TLS_MEM @@ -2733,6 +2841,10 @@ espectro.menu.eesz.autoflash.build.flash_size=16M espectro.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld espectro.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 espectro.menu.eesz.autoflash.upload.maximum_size=1044464 +espectro.menu.iramfloat.no=in IROM +espectro.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +espectro.menu.iramfloat.yes=allowed in ISR +espectro.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## espino.name=ESPino (ESP-12 Module) @@ -2747,6 +2859,7 @@ espino.serial.disableRTS=true espino.build.mcu=esp8266 espino.build.core=esp8266 espino.build.spiffs_pagesize=256 +espino.build.debug_optim= espino.build.debug_port= espino.build.debug_level= espino.menu.xtal.80=80 MHz @@ -2857,6 +2970,12 @@ espino.menu.dbg.Serial1=Serial1 espino.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 espino.menu.lvl.None____=None espino.menu.lvl.None____.build.debug_level= +espino.menu.optim.Smallest=None +espino.menu.optim.Smallest.build.debug_optim=-Os +espino.menu.optim.Lite=Lite +espino.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +espino.menu.optim.Full=Optimum +espino.menu.optim.Full.build.debug_optim=-Og espino.menu.lvl.SSL=SSL espino.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL espino.menu.lvl.TLS_MEM=TLS_MEM @@ -2948,6 +3067,10 @@ espino.menu.eesz.autoflash.build.flash_size=16M espino.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld espino.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 espino.menu.eesz.autoflash.upload.maximum_size=1044464 +espino.menu.iramfloat.no=in IROM +espino.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +espino.menu.iramfloat.yes=allowed in ISR +espino.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## espresso_lite_v1.name=ESPresso Lite 1.0 @@ -2962,6 +3085,7 @@ espresso_lite_v1.serial.disableRTS=true espresso_lite_v1.build.mcu=esp8266 espresso_lite_v1.build.core=esp8266 espresso_lite_v1.build.spiffs_pagesize=256 +espresso_lite_v1.build.debug_optim= espresso_lite_v1.build.debug_port= espresso_lite_v1.build.debug_level= espresso_lite_v1.menu.xtal.80=80 MHz @@ -3072,6 +3196,12 @@ espresso_lite_v1.menu.dbg.Serial1=Serial1 espresso_lite_v1.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 espresso_lite_v1.menu.lvl.None____=None espresso_lite_v1.menu.lvl.None____.build.debug_level= +espresso_lite_v1.menu.optim.Smallest=None +espresso_lite_v1.menu.optim.Smallest.build.debug_optim=-Os +espresso_lite_v1.menu.optim.Lite=Lite +espresso_lite_v1.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +espresso_lite_v1.menu.optim.Full=Optimum +espresso_lite_v1.menu.optim.Full.build.debug_optim=-Og espresso_lite_v1.menu.lvl.SSL=SSL espresso_lite_v1.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL espresso_lite_v1.menu.lvl.TLS_MEM=TLS_MEM @@ -3163,6 +3293,10 @@ espresso_lite_v1.menu.eesz.autoflash.build.flash_size=16M espresso_lite_v1.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld espresso_lite_v1.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 espresso_lite_v1.menu.eesz.autoflash.upload.maximum_size=1044464 +espresso_lite_v1.menu.iramfloat.no=in IROM +espresso_lite_v1.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +espresso_lite_v1.menu.iramfloat.yes=allowed in ISR +espresso_lite_v1.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## espresso_lite_v2.name=ESPresso Lite 2.0 @@ -3177,6 +3311,7 @@ espresso_lite_v2.serial.disableRTS=true espresso_lite_v2.build.mcu=esp8266 espresso_lite_v2.build.core=esp8266 espresso_lite_v2.build.spiffs_pagesize=256 +espresso_lite_v2.build.debug_optim= espresso_lite_v2.build.debug_port= espresso_lite_v2.build.debug_level= espresso_lite_v2.menu.xtal.80=80 MHz @@ -3287,6 +3422,12 @@ espresso_lite_v2.menu.dbg.Serial1=Serial1 espresso_lite_v2.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 espresso_lite_v2.menu.lvl.None____=None espresso_lite_v2.menu.lvl.None____.build.debug_level= +espresso_lite_v2.menu.optim.Smallest=None +espresso_lite_v2.menu.optim.Smallest.build.debug_optim=-Os +espresso_lite_v2.menu.optim.Lite=Lite +espresso_lite_v2.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +espresso_lite_v2.menu.optim.Full=Optimum +espresso_lite_v2.menu.optim.Full.build.debug_optim=-Og espresso_lite_v2.menu.lvl.SSL=SSL espresso_lite_v2.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL espresso_lite_v2.menu.lvl.TLS_MEM=TLS_MEM @@ -3378,6 +3519,10 @@ espresso_lite_v2.menu.eesz.autoflash.build.flash_size=16M espresso_lite_v2.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld espresso_lite_v2.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 espresso_lite_v2.menu.eesz.autoflash.upload.maximum_size=1044464 +espresso_lite_v2.menu.iramfloat.no=in IROM +espresso_lite_v2.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +espresso_lite_v2.menu.iramfloat.yes=allowed in ISR +espresso_lite_v2.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## sonoff.name=ITEAD Sonoff @@ -3401,6 +3546,7 @@ sonoff.serial.disableRTS=true sonoff.build.mcu=esp8266 sonoff.build.core=esp8266 sonoff.build.spiffs_pagesize=256 +sonoff.build.debug_optim= sonoff.build.debug_port= sonoff.build.debug_level= sonoff.menu.xtal.80=80 MHz @@ -3540,6 +3686,12 @@ sonoff.menu.dbg.Serial1=Serial1 sonoff.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 sonoff.menu.lvl.None____=None sonoff.menu.lvl.None____.build.debug_level= +sonoff.menu.optim.Smallest=None +sonoff.menu.optim.Smallest.build.debug_optim=-Os +sonoff.menu.optim.Lite=Lite +sonoff.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +sonoff.menu.optim.Full=Optimum +sonoff.menu.optim.Full.build.debug_optim=-Og sonoff.menu.lvl.SSL=SSL sonoff.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL sonoff.menu.lvl.TLS_MEM=TLS_MEM @@ -3631,6 +3783,10 @@ sonoff.menu.eesz.autoflash.build.flash_size=16M sonoff.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld sonoff.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 sonoff.menu.eesz.autoflash.upload.maximum_size=1044464 +sonoff.menu.iramfloat.no=in IROM +sonoff.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +sonoff.menu.iramfloat.yes=allowed in ISR +sonoff.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## inventone.name=Invent One @@ -3645,6 +3801,7 @@ inventone.serial.disableRTS=true inventone.build.mcu=esp8266 inventone.build.core=esp8266 inventone.build.spiffs_pagesize=256 +inventone.build.debug_optim= inventone.build.debug_port= inventone.build.debug_level= inventone.menu.xtal.80=80 MHz @@ -3752,6 +3909,12 @@ inventone.menu.dbg.Serial1=Serial1 inventone.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 inventone.menu.lvl.None____=None inventone.menu.lvl.None____.build.debug_level= +inventone.menu.optim.Smallest=None +inventone.menu.optim.Smallest.build.debug_optim=-Os +inventone.menu.optim.Lite=Lite +inventone.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +inventone.menu.optim.Full=Optimum +inventone.menu.optim.Full.build.debug_optim=-Og inventone.menu.lvl.SSL=SSL inventone.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL inventone.menu.lvl.TLS_MEM=TLS_MEM @@ -3843,6 +4006,249 @@ inventone.menu.eesz.autoflash.build.flash_size=16M inventone.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld inventone.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 inventone.menu.eesz.autoflash.upload.maximum_size=1044464 +inventone.menu.iramfloat.no=in IROM +inventone.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +inventone.menu.iramfloat.yes=allowed in ISR +inventone.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM + +############################################################## +d1_wroom_02.name=LOLIN(WEMOS) D1 ESP-WROOM-02 +d1_wroom_02.build.board=ESP8266_WEMOS_D1WROOM02 +d1_wroom_02.build.variant=d1_mini +d1_wroom_02.upload.tool=esptool +d1_wroom_02.upload.maximum_data_size=81920 +d1_wroom_02.upload.wait_for_upload_port=true +d1_wroom_02.upload.erase_cmd= +d1_wroom_02.serial.disableDTR=true +d1_wroom_02.serial.disableRTS=true +d1_wroom_02.build.mcu=esp8266 +d1_wroom_02.build.core=esp8266 +d1_wroom_02.build.spiffs_pagesize=256 +d1_wroom_02.build.debug_optim= +d1_wroom_02.build.debug_port= +d1_wroom_02.build.debug_level= +d1_wroom_02.menu.xtal.80=80 MHz +d1_wroom_02.menu.xtal.80.build.f_cpu=80000000L +d1_wroom_02.menu.xtal.160=160 MHz +d1_wroom_02.menu.xtal.160.build.f_cpu=160000000L +d1_wroom_02.menu.vt.flash=Flash +d1_wroom_02.menu.vt.flash.build.vtable_flags=-DVTABLES_IN_FLASH +d1_wroom_02.menu.vt.heap=Heap +d1_wroom_02.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM +d1_wroom_02.menu.vt.iram=IRAM +d1_wroom_02.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM +d1_wroom_02.menu.exception.disabled=Disabled (new aborts on oom) +d1_wroom_02.menu.exception.disabled.build.exception_flags=-fno-exceptions +d1_wroom_02.menu.exception.disabled.build.stdcpp_lib=-lstdc++ +d1_wroom_02.menu.exception.enabled=Enabled +d1_wroom_02.menu.exception.enabled.build.exception_flags=-fexceptions +d1_wroom_02.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc +d1_wroom_02.menu.stacksmash.disabled=Disabled +d1_wroom_02.menu.stacksmash.disabled.build.stacksmash_flags= +d1_wroom_02.menu.stacksmash.enabled=Enabled +d1_wroom_02.menu.stacksmash.enabled.build.stacksmash_flags=-fstack-protector +d1_wroom_02.menu.ssl.all=All SSL ciphers (most compatible) +d1_wroom_02.menu.ssl.all.build.sslflags= +d1_wroom_02.menu.ssl.basic=Basic SSL ciphers (lower ROM use) +d1_wroom_02.menu.ssl.basic.build.sslflags=-DBEARSSL_SSL_BASIC +d1_wroom_02.menu.mmu.3232=32KB cache + 32KB IRAM (balanced) +d1_wroom_02.menu.mmu.3232.build.mmuflags=-DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x8000 +d1_wroom_02.menu.mmu.4816=16KB cache + 48KB IRAM (IRAM) +d1_wroom_02.menu.mmu.4816.build.mmuflags=-DMMU_IRAM_SIZE=0xC000 -DMMU_ICACHE_SIZE=0x4000 +d1_wroom_02.menu.mmu.4816H=16KB cache + 48KB IRAM and 2nd Heap (shared) +d1_wroom_02.menu.mmu.4816H.build.mmuflags=-DMMU_IRAM_SIZE=0xC000 -DMMU_ICACHE_SIZE=0x4000 -DMMU_IRAM_HEAP +d1_wroom_02.menu.mmu.3216=16KB cache + 32KB IRAM + 16KB 2nd Heap (not shared) +d1_wroom_02.menu.mmu.3216.build.mmuflags=-DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x4000 -DMMU_SEC_HEAP=0x40108000 -DMMU_SEC_HEAP_SIZE=0x4000 +d1_wroom_02.menu.mmu.ext128k=128K Heap External 23LC1024 +d1_wroom_02.menu.mmu.ext128k.build.mmuflags=-DMMU_EXTERNAL_HEAP=128 -DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x8000 +d1_wroom_02.menu.mmu.ext8192k=8M w/256K Heap External 64 MBit PSRAM +d1_wroom_02.menu.mmu.ext8192k.build.mmuflags=-DMMU_EXTERNAL_HEAP=256 -DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x8000 +d1_wroom_02.menu.non32xfer.fast=Use pgm_read macros for IRAM/PROGMEM +d1_wroom_02.menu.non32xfer.fast.build.non32xferflags= +d1_wroom_02.menu.non32xfer.safe=Byte/Word access to IRAM/PROGMEM (very slow) +d1_wroom_02.menu.non32xfer.safe.build.non32xferflags=-DNON32XFER_HANDLER +d1_wroom_02.upload.resetmethod=--before default_reset --after hard_reset +d1_wroom_02.build.flash_mode=dio +d1_wroom_02.build.flash_flags=-DFLASHMODE_DIO +d1_wroom_02.build.flash_freq=26 +d1_wroom_02.menu.eesz.2M64=2MB (FS:64KB OTA:~992KB) +d1_wroom_02.menu.eesz.2M64.build.flash_size=2M +d1_wroom_02.menu.eesz.2M64.build.flash_ld=eagle.flash.2m64.ld +d1_wroom_02.menu.eesz.2M64.build.spiffs_pagesize=256 +d1_wroom_02.menu.eesz.2M64.build.rfcal_addr=0x1FC000 +d1_wroom_02.menu.eesz.2M64.build.spiffs_start=0x1F0000 +d1_wroom_02.menu.eesz.2M64.build.spiffs_end=0x1FB000 +d1_wroom_02.menu.eesz.2M64.build.spiffs_blocksize=4096 +d1_wroom_02.menu.eesz.2M128=2MB (FS:128KB OTA:~960KB) +d1_wroom_02.menu.eesz.2M128.build.flash_size=2M +d1_wroom_02.menu.eesz.2M128.build.flash_ld=eagle.flash.2m128.ld +d1_wroom_02.menu.eesz.2M128.build.spiffs_pagesize=256 +d1_wroom_02.menu.eesz.2M128.build.rfcal_addr=0x1FC000 +d1_wroom_02.menu.eesz.2M128.build.spiffs_start=0x1E0000 +d1_wroom_02.menu.eesz.2M128.build.spiffs_end=0x1FB000 +d1_wroom_02.menu.eesz.2M128.build.spiffs_blocksize=4096 +d1_wroom_02.menu.eesz.2M256=2MB (FS:256KB OTA:~896KB) +d1_wroom_02.menu.eesz.2M256.build.flash_size=2M +d1_wroom_02.menu.eesz.2M256.build.flash_ld=eagle.flash.2m256.ld +d1_wroom_02.menu.eesz.2M256.build.spiffs_pagesize=256 +d1_wroom_02.menu.eesz.2M256.build.rfcal_addr=0x1FC000 +d1_wroom_02.menu.eesz.2M256.build.spiffs_start=0x1C0000 +d1_wroom_02.menu.eesz.2M256.build.spiffs_end=0x1FB000 +d1_wroom_02.menu.eesz.2M256.build.spiffs_blocksize=4096 +d1_wroom_02.menu.eesz.2M512=2MB (FS:512KB OTA:~768KB) +d1_wroom_02.menu.eesz.2M512.build.flash_size=2M +d1_wroom_02.menu.eesz.2M512.build.flash_ld=eagle.flash.2m512.ld +d1_wroom_02.menu.eesz.2M512.build.spiffs_pagesize=256 +d1_wroom_02.menu.eesz.2M512.build.rfcal_addr=0x1FC000 +d1_wroom_02.menu.eesz.2M512.build.spiffs_start=0x180000 +d1_wroom_02.menu.eesz.2M512.build.spiffs_end=0x1FA000 +d1_wroom_02.menu.eesz.2M512.build.spiffs_blocksize=8192 +d1_wroom_02.menu.eesz.2M1M=2MB (FS:1MB OTA:~512KB) +d1_wroom_02.menu.eesz.2M1M.build.flash_size=2M +d1_wroom_02.menu.eesz.2M1M.build.flash_ld=eagle.flash.2m1m.ld +d1_wroom_02.menu.eesz.2M1M.build.spiffs_pagesize=256 +d1_wroom_02.menu.eesz.2M1M.build.rfcal_addr=0x1FC000 +d1_wroom_02.menu.eesz.2M1M.build.spiffs_start=0x100000 +d1_wroom_02.menu.eesz.2M1M.build.spiffs_end=0x1FA000 +d1_wroom_02.menu.eesz.2M1M.build.spiffs_blocksize=8192 +d1_wroom_02.menu.eesz.2M=2MB (FS:none OTA:~1019KB) +d1_wroom_02.menu.eesz.2M.build.flash_size=2M +d1_wroom_02.menu.eesz.2M.build.flash_ld=eagle.flash.2m.ld +d1_wroom_02.menu.eesz.2M.build.spiffs_pagesize=256 +d1_wroom_02.menu.eesz.2M.build.rfcal_addr=0x1FC000 +d1_wroom_02.menu.ip.lm2f=v2 Lower Memory +d1_wroom_02.menu.ip.lm2f.build.lwip_include=lwip2/include +d1_wroom_02.menu.ip.lm2f.build.lwip_lib=-llwip2-536-feat +d1_wroom_02.menu.ip.lm2f.build.lwip_flags=-DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 +d1_wroom_02.menu.ip.hb2f=v2 Higher Bandwidth +d1_wroom_02.menu.ip.hb2f.build.lwip_include=lwip2/include +d1_wroom_02.menu.ip.hb2f.build.lwip_lib=-llwip2-1460-feat +d1_wroom_02.menu.ip.hb2f.build.lwip_flags=-DLWIP_OPEN_SRC -DTCP_MSS=1460 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 +d1_wroom_02.menu.ip.lm2n=v2 Lower Memory (no features) +d1_wroom_02.menu.ip.lm2n.build.lwip_include=lwip2/include +d1_wroom_02.menu.ip.lm2n.build.lwip_lib=-llwip2-536 +d1_wroom_02.menu.ip.lm2n.build.lwip_flags=-DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=0 -DLWIP_IPV6=0 +d1_wroom_02.menu.ip.hb2n=v2 Higher Bandwidth (no features) +d1_wroom_02.menu.ip.hb2n.build.lwip_include=lwip2/include +d1_wroom_02.menu.ip.hb2n.build.lwip_lib=-llwip2-1460 +d1_wroom_02.menu.ip.hb2n.build.lwip_flags=-DLWIP_OPEN_SRC -DTCP_MSS=1460 -DLWIP_FEATURES=0 -DLWIP_IPV6=0 +d1_wroom_02.menu.ip.lm6f=v2 IPv6 Lower Memory +d1_wroom_02.menu.ip.lm6f.build.lwip_include=lwip2/include +d1_wroom_02.menu.ip.lm6f.build.lwip_lib=-llwip6-536-feat +d1_wroom_02.menu.ip.lm6f.build.lwip_flags=-DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=1 +d1_wroom_02.menu.ip.hb6f=v2 IPv6 Higher Bandwidth +d1_wroom_02.menu.ip.hb6f.build.lwip_include=lwip2/include +d1_wroom_02.menu.ip.hb6f.build.lwip_lib=-llwip6-1460-feat +d1_wroom_02.menu.ip.hb6f.build.lwip_flags=-DLWIP_OPEN_SRC -DTCP_MSS=1460 -DLWIP_FEATURES=1 -DLWIP_IPV6=1 +d1_wroom_02.menu.dbg.Disabled=Disabled +d1_wroom_02.menu.dbg.Disabled.build.debug_port= +d1_wroom_02.menu.dbg.Serial=Serial +d1_wroom_02.menu.dbg.Serial.build.debug_port=-DDEBUG_ESP_PORT=Serial +d1_wroom_02.menu.dbg.Serial1=Serial1 +d1_wroom_02.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 +d1_wroom_02.menu.lvl.None____=None +d1_wroom_02.menu.lvl.None____.build.debug_level= +d1_wroom_02.menu.optim.Smallest=None +d1_wroom_02.menu.optim.Smallest.build.debug_optim=-Os +d1_wroom_02.menu.optim.Lite=Lite +d1_wroom_02.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +d1_wroom_02.menu.optim.Full=Optimum +d1_wroom_02.menu.optim.Full.build.debug_optim=-Og +d1_wroom_02.menu.lvl.SSL=SSL +d1_wroom_02.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL +d1_wroom_02.menu.lvl.TLS_MEM=TLS_MEM +d1_wroom_02.menu.lvl.TLS_MEM.build.debug_level= -DDEBUG_ESP_TLS_MEM +d1_wroom_02.menu.lvl.HTTP_CLIENT=HTTP_CLIENT +d1_wroom_02.menu.lvl.HTTP_CLIENT.build.debug_level= -DDEBUG_ESP_HTTP_CLIENT +d1_wroom_02.menu.lvl.HTTP_SERVER=HTTP_SERVER +d1_wroom_02.menu.lvl.HTTP_SERVER.build.debug_level= -DDEBUG_ESP_HTTP_SERVER +d1_wroom_02.menu.lvl.SSLTLS_MEM=SSL+TLS_MEM +d1_wroom_02.menu.lvl.SSLTLS_MEM.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_TLS_MEM +d1_wroom_02.menu.lvl.SSLHTTP_CLIENT=SSL+HTTP_CLIENT +d1_wroom_02.menu.lvl.SSLHTTP_CLIENT.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_HTTP_CLIENT +d1_wroom_02.menu.lvl.SSLHTTP_SERVER=SSL+HTTP_SERVER +d1_wroom_02.menu.lvl.SSLHTTP_SERVER.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_HTTP_SERVER +d1_wroom_02.menu.lvl.TLS_MEMHTTP_CLIENT=TLS_MEM+HTTP_CLIENT +d1_wroom_02.menu.lvl.TLS_MEMHTTP_CLIENT.build.debug_level= -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_CLIENT +d1_wroom_02.menu.lvl.TLS_MEMHTTP_SERVER=TLS_MEM+HTTP_SERVER +d1_wroom_02.menu.lvl.TLS_MEMHTTP_SERVER.build.debug_level= -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_SERVER +d1_wroom_02.menu.lvl.HTTP_CLIENTHTTP_SERVER=HTTP_CLIENT+HTTP_SERVER +d1_wroom_02.menu.lvl.HTTP_CLIENTHTTP_SERVER.build.debug_level= -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER +d1_wroom_02.menu.lvl.SSLTLS_MEMHTTP_CLIENT=SSL+TLS_MEM+HTTP_CLIENT +d1_wroom_02.menu.lvl.SSLTLS_MEMHTTP_CLIENT.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_CLIENT +d1_wroom_02.menu.lvl.SSLTLS_MEMHTTP_SERVER=SSL+TLS_MEM+HTTP_SERVER +d1_wroom_02.menu.lvl.SSLTLS_MEMHTTP_SERVER.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_SERVER +d1_wroom_02.menu.lvl.SSLHTTP_CLIENTHTTP_SERVER=SSL+HTTP_CLIENT+HTTP_SERVER +d1_wroom_02.menu.lvl.SSLHTTP_CLIENTHTTP_SERVER.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER +d1_wroom_02.menu.lvl.TLS_MEMHTTP_CLIENTHTTP_SERVER=TLS_MEM+HTTP_CLIENT+HTTP_SERVER +d1_wroom_02.menu.lvl.TLS_MEMHTTP_CLIENTHTTP_SERVER.build.debug_level= -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER +d1_wroom_02.menu.lvl.SSLTLS_MEMHTTP_CLIENTHTTP_SERVER=SSL+TLS_MEM+HTTP_CLIENT+HTTP_SERVER +d1_wroom_02.menu.lvl.SSLTLS_MEMHTTP_CLIENTHTTP_SERVER.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER +d1_wroom_02.menu.lvl.CORE=CORE +d1_wroom_02.menu.lvl.CORE.build.debug_level= -DDEBUG_ESP_CORE +d1_wroom_02.menu.lvl.WIFI=WIFI +d1_wroom_02.menu.lvl.WIFI.build.debug_level= -DDEBUG_ESP_WIFI +d1_wroom_02.menu.lvl.HTTP_UPDATE=HTTP_UPDATE +d1_wroom_02.menu.lvl.HTTP_UPDATE.build.debug_level= -DDEBUG_ESP_HTTP_UPDATE +d1_wroom_02.menu.lvl.UPDATER=UPDATER +d1_wroom_02.menu.lvl.UPDATER.build.debug_level= -DDEBUG_ESP_UPDATER +d1_wroom_02.menu.lvl.OTA=OTA +d1_wroom_02.menu.lvl.OTA.build.debug_level= -DDEBUG_ESP_OTA +d1_wroom_02.menu.lvl.OOM=OOM +d1_wroom_02.menu.lvl.OOM.build.debug_level= -DDEBUG_ESP_OOM +d1_wroom_02.menu.lvl.MDNS=MDNS +d1_wroom_02.menu.lvl.MDNS.build.debug_level= -DDEBUG_ESP_MDNS +d1_wroom_02.menu.lvl.HWDT=HWDT +d1_wroom_02.menu.lvl.HWDT.build.debug_level= -DDEBUG_ESP_HWDT +d1_wroom_02.menu.lvl.HWDT_NOEXTRA4K=HWDT_NOEXTRA4K +d1_wroom_02.menu.lvl.HWDT_NOEXTRA4K.build.debug_level= -DDEBUG_ESP_HWDT_NOEXTRA4K +d1_wroom_02.menu.lvl.COREWIFIHTTP_UPDATEUPDATEROTAOOMMDNS=CORE+WIFI+HTTP_UPDATE+UPDATER+OTA+OOM+MDNS +d1_wroom_02.menu.lvl.COREWIFIHTTP_UPDATEUPDATEROTAOOMMDNS.build.debug_level= -DDEBUG_ESP_CORE -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_ESP_OOM -DDEBUG_ESP_MDNS +d1_wroom_02.menu.lvl.COREWIFIHTTP_UPDATEUPDATEROTAOOMMDNSHWDT=CORE+WIFI+HTTP_UPDATE+UPDATER+OTA+OOM+MDNS+HWDT +d1_wroom_02.menu.lvl.COREWIFIHTTP_UPDATEUPDATEROTAOOMMDNSHWDT.build.debug_level= -DDEBUG_ESP_CORE -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_ESP_OOM -DDEBUG_ESP_MDNS -DDEBUG_ESP_HWDT +d1_wroom_02.menu.lvl.COREWIFIHTTP_UPDATEUPDATEROTAOOMMDNSHWDT_NOEXTRA4K=CORE+WIFI+HTTP_UPDATE+UPDATER+OTA+OOM+MDNS+HWDT_NOEXTRA4K +d1_wroom_02.menu.lvl.COREWIFIHTTP_UPDATEUPDATEROTAOOMMDNSHWDT_NOEXTRA4K.build.debug_level= -DDEBUG_ESP_CORE -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_ESP_OOM -DDEBUG_ESP_MDNS -DDEBUG_ESP_HWDT_NOEXTRA4K +d1_wroom_02.menu.lvl.SSLTLS_MEMHTTP_CLIENTHTTP_SERVERCOREWIFIHTTP_UPDATEUPDATEROTAOOMMDNS=SSL+TLS_MEM+HTTP_CLIENT+HTTP_SERVER+CORE+WIFI+HTTP_UPDATE+UPDATER+OTA+OOM+MDNS +d1_wroom_02.menu.lvl.SSLTLS_MEMHTTP_CLIENTHTTP_SERVERCOREWIFIHTTP_UPDATEUPDATEROTAOOMMDNS.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_CORE -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_ESP_OOM -DDEBUG_ESP_MDNS +d1_wroom_02.menu.lvl.SSLTLS_MEMHTTP_CLIENTHTTP_SERVERCOREWIFIHTTP_UPDATEUPDATEROTAOOMMDNSHWDT=SSL+TLS_MEM+HTTP_CLIENT+HTTP_SERVER+CORE+WIFI+HTTP_UPDATE+UPDATER+OTA+OOM+MDNS+HWDT +d1_wroom_02.menu.lvl.SSLTLS_MEMHTTP_CLIENTHTTP_SERVERCOREWIFIHTTP_UPDATEUPDATEROTAOOMMDNSHWDT.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_CORE -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_ESP_OOM -DDEBUG_ESP_MDNS -DDEBUG_ESP_HWDT +d1_wroom_02.menu.lvl.SSLTLS_MEMHTTP_CLIENTHTTP_SERVERCOREWIFIHTTP_UPDATEUPDATEROTAOOMMDNSHWDT_NOEXTRA4K=SSL+TLS_MEM+HTTP_CLIENT+HTTP_SERVER+CORE+WIFI+HTTP_UPDATE+UPDATER+OTA+OOM+MDNS+HWDT_NOEXTRA4K +d1_wroom_02.menu.lvl.SSLTLS_MEMHTTP_CLIENTHTTP_SERVERCOREWIFIHTTP_UPDATEUPDATEROTAOOMMDNSHWDT_NOEXTRA4K.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_CORE -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_ESP_OOM -DDEBUG_ESP_MDNS -DDEBUG_ESP_HWDT_NOEXTRA4K +d1_wroom_02.menu.lvl.NoAssert-NDEBUG=NoAssert-NDEBUG +d1_wroom_02.menu.lvl.NoAssert-NDEBUG.build.debug_level= -DNDEBUG +d1_wroom_02.menu.wipe.none=Only Sketch +d1_wroom_02.menu.wipe.none.upload.erase_cmd= +d1_wroom_02.menu.wipe.sdk=Sketch + WiFi Settings +d1_wroom_02.menu.wipe.sdk.upload.erase_cmd=erase_region "{build.rfcal_addr}" 0x4000 +d1_wroom_02.menu.wipe.all=All Flash Contents +d1_wroom_02.menu.wipe.all.upload.erase_cmd=erase_flash +d1_wroom_02.menu.baud.921600=921600 +d1_wroom_02.menu.baud.921600.upload.speed=921600 +d1_wroom_02.menu.baud.57600=57600 +d1_wroom_02.menu.baud.57600.upload.speed=57600 +d1_wroom_02.menu.baud.115200=115200 +d1_wroom_02.menu.baud.115200.upload.speed=115200 +d1_wroom_02.menu.baud.230400.linux=230400 +d1_wroom_02.menu.baud.230400.macosx=230400 +d1_wroom_02.menu.baud.230400.upload.speed=230400 +d1_wroom_02.menu.baud.256000.windows=256000 +d1_wroom_02.menu.baud.256000.upload.speed=256000 +d1_wroom_02.menu.baud.460800.linux=460800 +d1_wroom_02.menu.baud.460800.macosx=460800 +d1_wroom_02.menu.baud.460800.upload.speed=460800 +d1_wroom_02.menu.baud.512000.windows=512000 +d1_wroom_02.menu.baud.512000.upload.speed=512000 +d1_wroom_02.menu.baud.3000000=3000000 +d1_wroom_02.menu.baud.3000000.upload.speed=3000000 +d1_wroom_02.menu.eesz.autoflash=Mapping defined by Hardware and Sketch +d1_wroom_02.menu.eesz.autoflash.build.flash_size=16M +d1_wroom_02.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld +d1_wroom_02.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 +d1_wroom_02.menu.eesz.autoflash.upload.maximum_size=1044464 +d1_wroom_02.menu.iramfloat.no=in IROM +d1_wroom_02.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +d1_wroom_02.menu.iramfloat.yes=allowed in ISR +d1_wroom_02.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## d1_mini.name=LOLIN(WEMOS) D1 R2 & mini @@ -3857,6 +4263,7 @@ d1_mini.serial.disableRTS=true d1_mini.build.mcu=esp8266 d1_mini.build.core=esp8266 d1_mini.build.spiffs_pagesize=256 +d1_mini.build.debug_optim= d1_mini.build.debug_port= d1_mini.build.debug_level= d1_mini.menu.xtal.80=80 MHz @@ -3964,6 +4371,12 @@ d1_mini.menu.dbg.Serial1=Serial1 d1_mini.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 d1_mini.menu.lvl.None____=None d1_mini.menu.lvl.None____.build.debug_level= +d1_mini.menu.optim.Smallest=None +d1_mini.menu.optim.Smallest.build.debug_optim=-Os +d1_mini.menu.optim.Lite=Lite +d1_mini.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +d1_mini.menu.optim.Full=Optimum +d1_mini.menu.optim.Full.build.debug_optim=-Og d1_mini.menu.lvl.SSL=SSL d1_mini.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL d1_mini.menu.lvl.TLS_MEM=TLS_MEM @@ -4055,6 +4468,10 @@ d1_mini.menu.eesz.autoflash.build.flash_size=16M d1_mini.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld d1_mini.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 d1_mini.menu.eesz.autoflash.upload.maximum_size=1044464 +d1_mini.menu.iramfloat.no=in IROM +d1_mini.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +d1_mini.menu.iramfloat.yes=allowed in ISR +d1_mini.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## d1_mini_clone.name=LOLIN(WEMOS) D1 mini (clone) @@ -4069,6 +4486,7 @@ d1_mini_clone.serial.disableRTS=true d1_mini_clone.build.mcu=esp8266 d1_mini_clone.build.core=esp8266 d1_mini_clone.build.spiffs_pagesize=256 +d1_mini_clone.build.debug_optim= d1_mini_clone.build.debug_port= d1_mini_clone.build.debug_level= d1_mini_clone.menu.xtal.80=80 MHz @@ -4193,6 +4611,12 @@ d1_mini_clone.menu.dbg.Serial1=Serial1 d1_mini_clone.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 d1_mini_clone.menu.lvl.None____=None d1_mini_clone.menu.lvl.None____.build.debug_level= +d1_mini_clone.menu.optim.Smallest=None +d1_mini_clone.menu.optim.Smallest.build.debug_optim=-Os +d1_mini_clone.menu.optim.Lite=Lite +d1_mini_clone.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +d1_mini_clone.menu.optim.Full=Optimum +d1_mini_clone.menu.optim.Full.build.debug_optim=-Og d1_mini_clone.menu.lvl.SSL=SSL d1_mini_clone.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL d1_mini_clone.menu.lvl.TLS_MEM=TLS_MEM @@ -4284,6 +4708,10 @@ d1_mini_clone.menu.eesz.autoflash.build.flash_size=16M d1_mini_clone.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld d1_mini_clone.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 d1_mini_clone.menu.eesz.autoflash.upload.maximum_size=1044464 +d1_mini_clone.menu.iramfloat.no=in IROM +d1_mini_clone.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +d1_mini_clone.menu.iramfloat.yes=allowed in ISR +d1_mini_clone.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## d1_mini_lite.name=LOLIN(WEMOS) D1 mini Lite @@ -4298,6 +4726,7 @@ d1_mini_lite.serial.disableRTS=true d1_mini_lite.build.mcu=esp8266 d1_mini_lite.build.core=esp8266 d1_mini_lite.build.spiffs_pagesize=256 +d1_mini_lite.build.debug_optim= d1_mini_lite.build.debug_port= d1_mini_lite.build.debug_level= d1_mini_lite.menu.xtal.80=80 MHz @@ -4437,6 +4866,12 @@ d1_mini_lite.menu.dbg.Serial1=Serial1 d1_mini_lite.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 d1_mini_lite.menu.lvl.None____=None d1_mini_lite.menu.lvl.None____.build.debug_level= +d1_mini_lite.menu.optim.Smallest=None +d1_mini_lite.menu.optim.Smallest.build.debug_optim=-Os +d1_mini_lite.menu.optim.Lite=Lite +d1_mini_lite.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +d1_mini_lite.menu.optim.Full=Optimum +d1_mini_lite.menu.optim.Full.build.debug_optim=-Og d1_mini_lite.menu.lvl.SSL=SSL d1_mini_lite.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL d1_mini_lite.menu.lvl.TLS_MEM=TLS_MEM @@ -4528,6 +4963,10 @@ d1_mini_lite.menu.eesz.autoflash.build.flash_size=16M d1_mini_lite.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld d1_mini_lite.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 d1_mini_lite.menu.eesz.autoflash.upload.maximum_size=1044464 +d1_mini_lite.menu.iramfloat.no=in IROM +d1_mini_lite.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +d1_mini_lite.menu.iramfloat.yes=allowed in ISR +d1_mini_lite.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## d1_mini_pro.name=LOLIN(WEMOS) D1 mini Pro @@ -4542,6 +4981,7 @@ d1_mini_pro.serial.disableRTS=true d1_mini_pro.build.mcu=esp8266 d1_mini_pro.build.core=esp8266 d1_mini_pro.build.spiffs_pagesize=256 +d1_mini_pro.build.debug_optim= d1_mini_pro.build.debug_port= d1_mini_pro.build.debug_level= d1_mini_pro.menu.xtal.80=80 MHz @@ -4641,6 +5081,12 @@ d1_mini_pro.menu.dbg.Serial1=Serial1 d1_mini_pro.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 d1_mini_pro.menu.lvl.None____=None d1_mini_pro.menu.lvl.None____.build.debug_level= +d1_mini_pro.menu.optim.Smallest=None +d1_mini_pro.menu.optim.Smallest.build.debug_optim=-Os +d1_mini_pro.menu.optim.Lite=Lite +d1_mini_pro.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +d1_mini_pro.menu.optim.Full=Optimum +d1_mini_pro.menu.optim.Full.build.debug_optim=-Og d1_mini_pro.menu.lvl.SSL=SSL d1_mini_pro.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL d1_mini_pro.menu.lvl.TLS_MEM=TLS_MEM @@ -4732,6 +5178,10 @@ d1_mini_pro.menu.eesz.autoflash.build.flash_size=16M d1_mini_pro.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld d1_mini_pro.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 d1_mini_pro.menu.eesz.autoflash.upload.maximum_size=1044464 +d1_mini_pro.menu.iramfloat.no=in IROM +d1_mini_pro.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +d1_mini_pro.menu.iramfloat.yes=allowed in ISR +d1_mini_pro.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## d1.name=LOLIN(WeMos) D1 R1 @@ -4746,6 +5196,7 @@ d1.serial.disableRTS=true d1.build.mcu=esp8266 d1.build.core=esp8266 d1.build.spiffs_pagesize=256 +d1.build.debug_optim= d1.build.debug_port= d1.build.debug_level= d1.menu.xtal.80=80 MHz @@ -4853,6 +5304,12 @@ d1.menu.dbg.Serial1=Serial1 d1.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 d1.menu.lvl.None____=None d1.menu.lvl.None____.build.debug_level= +d1.menu.optim.Smallest=None +d1.menu.optim.Smallest.build.debug_optim=-Os +d1.menu.optim.Lite=Lite +d1.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +d1.menu.optim.Full=Optimum +d1.menu.optim.Full.build.debug_optim=-Og d1.menu.lvl.SSL=SSL d1.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL d1.menu.lvl.TLS_MEM=TLS_MEM @@ -4944,6 +5401,10 @@ d1.menu.eesz.autoflash.build.flash_size=16M d1.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld d1.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 d1.menu.eesz.autoflash.upload.maximum_size=1044464 +d1.menu.iramfloat.no=in IROM +d1.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +d1.menu.iramfloat.yes=allowed in ISR +d1.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## agruminolemon.name=Lifely Agrumino Lemon v4 @@ -4958,6 +5419,7 @@ agruminolemon.serial.disableRTS=true agruminolemon.build.mcu=esp8266 agruminolemon.build.core=esp8266 agruminolemon.build.spiffs_pagesize=256 +agruminolemon.build.debug_optim= agruminolemon.build.debug_port= agruminolemon.build.debug_level= agruminolemon.menu.xtal.80=80 MHz @@ -5081,6 +5543,12 @@ agruminolemon.menu.dbg.Serial1=Serial1 agruminolemon.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 agruminolemon.menu.lvl.None____=None agruminolemon.menu.lvl.None____.build.debug_level= +agruminolemon.menu.optim.Smallest=None +agruminolemon.menu.optim.Smallest.build.debug_optim=-Os +agruminolemon.menu.optim.Lite=Lite +agruminolemon.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +agruminolemon.menu.optim.Full=Optimum +agruminolemon.menu.optim.Full.build.debug_optim=-Og agruminolemon.menu.lvl.SSL=SSL agruminolemon.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL agruminolemon.menu.lvl.TLS_MEM=TLS_MEM @@ -5172,6 +5640,233 @@ agruminolemon.menu.eesz.autoflash.build.flash_size=16M agruminolemon.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld agruminolemon.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 agruminolemon.menu.eesz.autoflash.upload.maximum_size=1044464 +agruminolemon.menu.iramfloat.no=in IROM +agruminolemon.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +agruminolemon.menu.iramfloat.yes=allowed in ISR +agruminolemon.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM + +############################################################## +mercury1.name=Mercury 1.0 +mercury1.build.board=mercury +mercury1.build.variant=mercury_v1 +mercury1.upload.tool=esptool +mercury1.upload.maximum_data_size=81920 +mercury1.upload.wait_for_upload_port=true +mercury1.upload.erase_cmd= +mercury1.serial.disableDTR=true +mercury1.serial.disableRTS=true +mercury1.build.mcu=esp8266 +mercury1.build.core=esp8266 +mercury1.build.spiffs_pagesize=256 +mercury1.build.debug_optim= +mercury1.build.debug_port= +mercury1.build.debug_level= +mercury1.menu.xtal.80=80 MHz +mercury1.menu.xtal.80.build.f_cpu=80000000L +mercury1.menu.xtal.160=160 MHz +mercury1.menu.xtal.160.build.f_cpu=160000000L +mercury1.menu.vt.flash=Flash +mercury1.menu.vt.flash.build.vtable_flags=-DVTABLES_IN_FLASH +mercury1.menu.vt.heap=Heap +mercury1.menu.vt.heap.build.vtable_flags=-DVTABLES_IN_DRAM +mercury1.menu.vt.iram=IRAM +mercury1.menu.vt.iram.build.vtable_flags=-DVTABLES_IN_IRAM +mercury1.menu.exception.disabled=Disabled (new aborts on oom) +mercury1.menu.exception.disabled.build.exception_flags=-fno-exceptions +mercury1.menu.exception.disabled.build.stdcpp_lib=-lstdc++ +mercury1.menu.exception.enabled=Enabled +mercury1.menu.exception.enabled.build.exception_flags=-fexceptions +mercury1.menu.exception.enabled.build.stdcpp_lib=-lstdc++-exc +mercury1.menu.stacksmash.disabled=Disabled +mercury1.menu.stacksmash.disabled.build.stacksmash_flags= +mercury1.menu.stacksmash.enabled=Enabled +mercury1.menu.stacksmash.enabled.build.stacksmash_flags=-fstack-protector +mercury1.menu.ssl.all=All SSL ciphers (most compatible) +mercury1.menu.ssl.all.build.sslflags= +mercury1.menu.ssl.basic=Basic SSL ciphers (lower ROM use) +mercury1.menu.ssl.basic.build.sslflags=-DBEARSSL_SSL_BASIC +mercury1.menu.mmu.3232=32KB cache + 32KB IRAM (balanced) +mercury1.menu.mmu.3232.build.mmuflags=-DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x8000 +mercury1.menu.mmu.4816=16KB cache + 48KB IRAM (IRAM) +mercury1.menu.mmu.4816.build.mmuflags=-DMMU_IRAM_SIZE=0xC000 -DMMU_ICACHE_SIZE=0x4000 +mercury1.menu.mmu.4816H=16KB cache + 48KB IRAM and 2nd Heap (shared) +mercury1.menu.mmu.4816H.build.mmuflags=-DMMU_IRAM_SIZE=0xC000 -DMMU_ICACHE_SIZE=0x4000 -DMMU_IRAM_HEAP +mercury1.menu.mmu.3216=16KB cache + 32KB IRAM + 16KB 2nd Heap (not shared) +mercury1.menu.mmu.3216.build.mmuflags=-DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x4000 -DMMU_SEC_HEAP=0x40108000 -DMMU_SEC_HEAP_SIZE=0x4000 +mercury1.menu.mmu.ext128k=128K Heap External 23LC1024 +mercury1.menu.mmu.ext128k.build.mmuflags=-DMMU_EXTERNAL_HEAP=128 -DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x8000 +mercury1.menu.mmu.ext8192k=8M w/256K Heap External 64 MBit PSRAM +mercury1.menu.mmu.ext8192k.build.mmuflags=-DMMU_EXTERNAL_HEAP=256 -DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x8000 +mercury1.menu.non32xfer.fast=Use pgm_read macros for IRAM/PROGMEM +mercury1.menu.non32xfer.fast.build.non32xferflags= +mercury1.menu.non32xfer.safe=Byte/Word access to IRAM/PROGMEM (very slow) +mercury1.menu.non32xfer.safe.build.non32xferflags=-DNON32XFER_HANDLER +mercury1.upload.resetmethod=--before default_reset --after hard_reset +mercury1.build.flash_mode=dio +mercury1.build.flash_flags=-DFLASHMODE_DIO +mercury1.build.flash_freq=40 +mercury1.menu.eesz.4M2M=4MB (FS:2MB OTA:~1019KB) +mercury1.menu.eesz.4M2M.build.flash_size=4M +mercury1.menu.eesz.4M2M.build.flash_ld=eagle.flash.4m2m.ld +mercury1.menu.eesz.4M2M.build.spiffs_pagesize=256 +mercury1.menu.eesz.4M2M.build.rfcal_addr=0x3FC000 +mercury1.menu.eesz.4M2M.build.spiffs_start=0x200000 +mercury1.menu.eesz.4M2M.build.spiffs_end=0x3FA000 +mercury1.menu.eesz.4M2M.build.spiffs_blocksize=8192 +mercury1.menu.eesz.4M3M=4MB (FS:3MB OTA:~512KB) +mercury1.menu.eesz.4M3M.build.flash_size=4M +mercury1.menu.eesz.4M3M.build.flash_ld=eagle.flash.4m3m.ld +mercury1.menu.eesz.4M3M.build.spiffs_pagesize=256 +mercury1.menu.eesz.4M3M.build.rfcal_addr=0x3FC000 +mercury1.menu.eesz.4M3M.build.spiffs_start=0x100000 +mercury1.menu.eesz.4M3M.build.spiffs_end=0x3FA000 +mercury1.menu.eesz.4M3M.build.spiffs_blocksize=8192 +mercury1.menu.eesz.4M1M=4MB (FS:1MB OTA:~1019KB) +mercury1.menu.eesz.4M1M.build.flash_size=4M +mercury1.menu.eesz.4M1M.build.flash_ld=eagle.flash.4m1m.ld +mercury1.menu.eesz.4M1M.build.spiffs_pagesize=256 +mercury1.menu.eesz.4M1M.build.rfcal_addr=0x3FC000 +mercury1.menu.eesz.4M1M.build.spiffs_start=0x300000 +mercury1.menu.eesz.4M1M.build.spiffs_end=0x3FA000 +mercury1.menu.eesz.4M1M.build.spiffs_blocksize=8192 +mercury1.menu.eesz.4M=4MB (FS:none OTA:~1019KB) +mercury1.menu.eesz.4M.build.flash_size=4M +mercury1.menu.eesz.4M.build.flash_ld=eagle.flash.4m.ld +mercury1.menu.eesz.4M.build.spiffs_pagesize=256 +mercury1.menu.eesz.4M.build.rfcal_addr=0x3FC000 +mercury1.menu.ip.lm2f=v2 Lower Memory +mercury1.menu.ip.lm2f.build.lwip_include=lwip2/include +mercury1.menu.ip.lm2f.build.lwip_lib=-llwip2-536-feat +mercury1.menu.ip.lm2f.build.lwip_flags=-DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 +mercury1.menu.ip.hb2f=v2 Higher Bandwidth +mercury1.menu.ip.hb2f.build.lwip_include=lwip2/include +mercury1.menu.ip.hb2f.build.lwip_lib=-llwip2-1460-feat +mercury1.menu.ip.hb2f.build.lwip_flags=-DLWIP_OPEN_SRC -DTCP_MSS=1460 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 +mercury1.menu.ip.lm2n=v2 Lower Memory (no features) +mercury1.menu.ip.lm2n.build.lwip_include=lwip2/include +mercury1.menu.ip.lm2n.build.lwip_lib=-llwip2-536 +mercury1.menu.ip.lm2n.build.lwip_flags=-DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=0 -DLWIP_IPV6=0 +mercury1.menu.ip.hb2n=v2 Higher Bandwidth (no features) +mercury1.menu.ip.hb2n.build.lwip_include=lwip2/include +mercury1.menu.ip.hb2n.build.lwip_lib=-llwip2-1460 +mercury1.menu.ip.hb2n.build.lwip_flags=-DLWIP_OPEN_SRC -DTCP_MSS=1460 -DLWIP_FEATURES=0 -DLWIP_IPV6=0 +mercury1.menu.ip.lm6f=v2 IPv6 Lower Memory +mercury1.menu.ip.lm6f.build.lwip_include=lwip2/include +mercury1.menu.ip.lm6f.build.lwip_lib=-llwip6-536-feat +mercury1.menu.ip.lm6f.build.lwip_flags=-DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=1 +mercury1.menu.ip.hb6f=v2 IPv6 Higher Bandwidth +mercury1.menu.ip.hb6f.build.lwip_include=lwip2/include +mercury1.menu.ip.hb6f.build.lwip_lib=-llwip6-1460-feat +mercury1.menu.ip.hb6f.build.lwip_flags=-DLWIP_OPEN_SRC -DTCP_MSS=1460 -DLWIP_FEATURES=1 -DLWIP_IPV6=1 +mercury1.menu.dbg.Disabled=Disabled +mercury1.menu.dbg.Disabled.build.debug_port= +mercury1.menu.dbg.Serial=Serial +mercury1.menu.dbg.Serial.build.debug_port=-DDEBUG_ESP_PORT=Serial +mercury1.menu.dbg.Serial1=Serial1 +mercury1.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 +mercury1.menu.lvl.None____=None +mercury1.menu.lvl.None____.build.debug_level= +mercury1.menu.optim.Smallest=None +mercury1.menu.optim.Smallest.build.debug_optim=-Os +mercury1.menu.optim.Lite=Lite +mercury1.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +mercury1.menu.optim.Full=Optimum +mercury1.menu.optim.Full.build.debug_optim=-Og +mercury1.menu.lvl.SSL=SSL +mercury1.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL +mercury1.menu.lvl.TLS_MEM=TLS_MEM +mercury1.menu.lvl.TLS_MEM.build.debug_level= -DDEBUG_ESP_TLS_MEM +mercury1.menu.lvl.HTTP_CLIENT=HTTP_CLIENT +mercury1.menu.lvl.HTTP_CLIENT.build.debug_level= -DDEBUG_ESP_HTTP_CLIENT +mercury1.menu.lvl.HTTP_SERVER=HTTP_SERVER +mercury1.menu.lvl.HTTP_SERVER.build.debug_level= -DDEBUG_ESP_HTTP_SERVER +mercury1.menu.lvl.SSLTLS_MEM=SSL+TLS_MEM +mercury1.menu.lvl.SSLTLS_MEM.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_TLS_MEM +mercury1.menu.lvl.SSLHTTP_CLIENT=SSL+HTTP_CLIENT +mercury1.menu.lvl.SSLHTTP_CLIENT.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_HTTP_CLIENT +mercury1.menu.lvl.SSLHTTP_SERVER=SSL+HTTP_SERVER +mercury1.menu.lvl.SSLHTTP_SERVER.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_HTTP_SERVER +mercury1.menu.lvl.TLS_MEMHTTP_CLIENT=TLS_MEM+HTTP_CLIENT +mercury1.menu.lvl.TLS_MEMHTTP_CLIENT.build.debug_level= -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_CLIENT +mercury1.menu.lvl.TLS_MEMHTTP_SERVER=TLS_MEM+HTTP_SERVER +mercury1.menu.lvl.TLS_MEMHTTP_SERVER.build.debug_level= -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_SERVER +mercury1.menu.lvl.HTTP_CLIENTHTTP_SERVER=HTTP_CLIENT+HTTP_SERVER +mercury1.menu.lvl.HTTP_CLIENTHTTP_SERVER.build.debug_level= -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER +mercury1.menu.lvl.SSLTLS_MEMHTTP_CLIENT=SSL+TLS_MEM+HTTP_CLIENT +mercury1.menu.lvl.SSLTLS_MEMHTTP_CLIENT.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_CLIENT +mercury1.menu.lvl.SSLTLS_MEMHTTP_SERVER=SSL+TLS_MEM+HTTP_SERVER +mercury1.menu.lvl.SSLTLS_MEMHTTP_SERVER.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_SERVER +mercury1.menu.lvl.SSLHTTP_CLIENTHTTP_SERVER=SSL+HTTP_CLIENT+HTTP_SERVER +mercury1.menu.lvl.SSLHTTP_CLIENTHTTP_SERVER.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER +mercury1.menu.lvl.TLS_MEMHTTP_CLIENTHTTP_SERVER=TLS_MEM+HTTP_CLIENT+HTTP_SERVER +mercury1.menu.lvl.TLS_MEMHTTP_CLIENTHTTP_SERVER.build.debug_level= -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER +mercury1.menu.lvl.SSLTLS_MEMHTTP_CLIENTHTTP_SERVER=SSL+TLS_MEM+HTTP_CLIENT+HTTP_SERVER +mercury1.menu.lvl.SSLTLS_MEMHTTP_CLIENTHTTP_SERVER.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER +mercury1.menu.lvl.CORE=CORE +mercury1.menu.lvl.CORE.build.debug_level= -DDEBUG_ESP_CORE +mercury1.menu.lvl.WIFI=WIFI +mercury1.menu.lvl.WIFI.build.debug_level= -DDEBUG_ESP_WIFI +mercury1.menu.lvl.HTTP_UPDATE=HTTP_UPDATE +mercury1.menu.lvl.HTTP_UPDATE.build.debug_level= -DDEBUG_ESP_HTTP_UPDATE +mercury1.menu.lvl.UPDATER=UPDATER +mercury1.menu.lvl.UPDATER.build.debug_level= -DDEBUG_ESP_UPDATER +mercury1.menu.lvl.OTA=OTA +mercury1.menu.lvl.OTA.build.debug_level= -DDEBUG_ESP_OTA +mercury1.menu.lvl.OOM=OOM +mercury1.menu.lvl.OOM.build.debug_level= -DDEBUG_ESP_OOM +mercury1.menu.lvl.MDNS=MDNS +mercury1.menu.lvl.MDNS.build.debug_level= -DDEBUG_ESP_MDNS +mercury1.menu.lvl.HWDT=HWDT +mercury1.menu.lvl.HWDT.build.debug_level= -DDEBUG_ESP_HWDT +mercury1.menu.lvl.HWDT_NOEXTRA4K=HWDT_NOEXTRA4K +mercury1.menu.lvl.HWDT_NOEXTRA4K.build.debug_level= -DDEBUG_ESP_HWDT_NOEXTRA4K +mercury1.menu.lvl.COREWIFIHTTP_UPDATEUPDATEROTAOOMMDNS=CORE+WIFI+HTTP_UPDATE+UPDATER+OTA+OOM+MDNS +mercury1.menu.lvl.COREWIFIHTTP_UPDATEUPDATEROTAOOMMDNS.build.debug_level= -DDEBUG_ESP_CORE -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_ESP_OOM -DDEBUG_ESP_MDNS +mercury1.menu.lvl.COREWIFIHTTP_UPDATEUPDATEROTAOOMMDNSHWDT=CORE+WIFI+HTTP_UPDATE+UPDATER+OTA+OOM+MDNS+HWDT +mercury1.menu.lvl.COREWIFIHTTP_UPDATEUPDATEROTAOOMMDNSHWDT.build.debug_level= -DDEBUG_ESP_CORE -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_ESP_OOM -DDEBUG_ESP_MDNS -DDEBUG_ESP_HWDT +mercury1.menu.lvl.COREWIFIHTTP_UPDATEUPDATEROTAOOMMDNSHWDT_NOEXTRA4K=CORE+WIFI+HTTP_UPDATE+UPDATER+OTA+OOM+MDNS+HWDT_NOEXTRA4K +mercury1.menu.lvl.COREWIFIHTTP_UPDATEUPDATEROTAOOMMDNSHWDT_NOEXTRA4K.build.debug_level= -DDEBUG_ESP_CORE -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_ESP_OOM -DDEBUG_ESP_MDNS -DDEBUG_ESP_HWDT_NOEXTRA4K +mercury1.menu.lvl.SSLTLS_MEMHTTP_CLIENTHTTP_SERVERCOREWIFIHTTP_UPDATEUPDATEROTAOOMMDNS=SSL+TLS_MEM+HTTP_CLIENT+HTTP_SERVER+CORE+WIFI+HTTP_UPDATE+UPDATER+OTA+OOM+MDNS +mercury1.menu.lvl.SSLTLS_MEMHTTP_CLIENTHTTP_SERVERCOREWIFIHTTP_UPDATEUPDATEROTAOOMMDNS.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_CORE -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_ESP_OOM -DDEBUG_ESP_MDNS +mercury1.menu.lvl.SSLTLS_MEMHTTP_CLIENTHTTP_SERVERCOREWIFIHTTP_UPDATEUPDATEROTAOOMMDNSHWDT=SSL+TLS_MEM+HTTP_CLIENT+HTTP_SERVER+CORE+WIFI+HTTP_UPDATE+UPDATER+OTA+OOM+MDNS+HWDT +mercury1.menu.lvl.SSLTLS_MEMHTTP_CLIENTHTTP_SERVERCOREWIFIHTTP_UPDATEUPDATEROTAOOMMDNSHWDT.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_CORE -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_ESP_OOM -DDEBUG_ESP_MDNS -DDEBUG_ESP_HWDT +mercury1.menu.lvl.SSLTLS_MEMHTTP_CLIENTHTTP_SERVERCOREWIFIHTTP_UPDATEUPDATEROTAOOMMDNSHWDT_NOEXTRA4K=SSL+TLS_MEM+HTTP_CLIENT+HTTP_SERVER+CORE+WIFI+HTTP_UPDATE+UPDATER+OTA+OOM+MDNS+HWDT_NOEXTRA4K +mercury1.menu.lvl.SSLTLS_MEMHTTP_CLIENTHTTP_SERVERCOREWIFIHTTP_UPDATEUPDATEROTAOOMMDNSHWDT_NOEXTRA4K.build.debug_level= -DDEBUG_ESP_SSL -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_CORE -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_ESP_OOM -DDEBUG_ESP_MDNS -DDEBUG_ESP_HWDT_NOEXTRA4K +mercury1.menu.lvl.NoAssert-NDEBUG=NoAssert-NDEBUG +mercury1.menu.lvl.NoAssert-NDEBUG.build.debug_level= -DNDEBUG +mercury1.menu.wipe.none=Only Sketch +mercury1.menu.wipe.none.upload.erase_cmd= +mercury1.menu.wipe.sdk=Sketch + WiFi Settings +mercury1.menu.wipe.sdk.upload.erase_cmd=erase_region "{build.rfcal_addr}" 0x4000 +mercury1.menu.wipe.all=All Flash Contents +mercury1.menu.wipe.all.upload.erase_cmd=erase_flash +mercury1.menu.baud.115200=115200 +mercury1.menu.baud.115200.upload.speed=115200 +mercury1.menu.baud.57600=57600 +mercury1.menu.baud.57600.upload.speed=57600 +mercury1.menu.baud.230400.linux=230400 +mercury1.menu.baud.230400.macosx=230400 +mercury1.menu.baud.230400.upload.speed=230400 +mercury1.menu.baud.256000.windows=256000 +mercury1.menu.baud.256000.upload.speed=256000 +mercury1.menu.baud.460800.linux=460800 +mercury1.menu.baud.460800.macosx=460800 +mercury1.menu.baud.460800.upload.speed=460800 +mercury1.menu.baud.512000.windows=512000 +mercury1.menu.baud.512000.upload.speed=512000 +mercury1.menu.baud.921600=921600 +mercury1.menu.baud.921600.upload.speed=921600 +mercury1.menu.baud.3000000=3000000 +mercury1.menu.baud.3000000.upload.speed=3000000 +mercury1.menu.eesz.autoflash=Mapping defined by Hardware and Sketch +mercury1.menu.eesz.autoflash.build.flash_size=16M +mercury1.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld +mercury1.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 +mercury1.menu.eesz.autoflash.upload.maximum_size=1044464 +mercury1.menu.iramfloat.no=in IROM +mercury1.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +mercury1.menu.iramfloat.yes=allowed in ISR +mercury1.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## nodemcu.name=NodeMCU 0.9 (ESP-12 Module) @@ -5186,6 +5881,7 @@ nodemcu.serial.disableRTS=true nodemcu.build.mcu=esp8266 nodemcu.build.core=esp8266 nodemcu.build.spiffs_pagesize=256 +nodemcu.build.debug_optim= nodemcu.build.debug_port= nodemcu.build.debug_level= nodemcu.menu.xtal.80=80 MHz @@ -5293,6 +5989,12 @@ nodemcu.menu.dbg.Serial1=Serial1 nodemcu.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 nodemcu.menu.lvl.None____=None nodemcu.menu.lvl.None____.build.debug_level= +nodemcu.menu.optim.Smallest=None +nodemcu.menu.optim.Smallest.build.debug_optim=-Os +nodemcu.menu.optim.Lite=Lite +nodemcu.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +nodemcu.menu.optim.Full=Optimum +nodemcu.menu.optim.Full.build.debug_optim=-Og nodemcu.menu.lvl.SSL=SSL nodemcu.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL nodemcu.menu.lvl.TLS_MEM=TLS_MEM @@ -5384,6 +6086,10 @@ nodemcu.menu.eesz.autoflash.build.flash_size=16M nodemcu.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld nodemcu.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 nodemcu.menu.eesz.autoflash.upload.maximum_size=1044464 +nodemcu.menu.iramfloat.no=in IROM +nodemcu.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +nodemcu.menu.iramfloat.yes=allowed in ISR +nodemcu.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## nodemcuv2.name=NodeMCU 1.0 (ESP-12E Module) @@ -5398,6 +6104,7 @@ nodemcuv2.serial.disableRTS=true nodemcuv2.build.mcu=esp8266 nodemcuv2.build.core=esp8266 nodemcuv2.build.spiffs_pagesize=256 +nodemcuv2.build.debug_optim= nodemcuv2.build.debug_port= nodemcuv2.build.debug_level= nodemcuv2.menu.xtal.80=80 MHz @@ -5509,6 +6216,12 @@ nodemcuv2.menu.dbg.Serial1=Serial1 nodemcuv2.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 nodemcuv2.menu.lvl.None____=None nodemcuv2.menu.lvl.None____.build.debug_level= +nodemcuv2.menu.optim.Smallest=None +nodemcuv2.menu.optim.Smallest.build.debug_optim=-Os +nodemcuv2.menu.optim.Lite=Lite +nodemcuv2.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +nodemcuv2.menu.optim.Full=Optimum +nodemcuv2.menu.optim.Full.build.debug_optim=-Og nodemcuv2.menu.lvl.SSL=SSL nodemcuv2.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL nodemcuv2.menu.lvl.TLS_MEM=TLS_MEM @@ -5600,6 +6313,10 @@ nodemcuv2.menu.eesz.autoflash.build.flash_size=16M nodemcuv2.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld nodemcuv2.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 nodemcuv2.menu.eesz.autoflash.upload.maximum_size=1044464 +nodemcuv2.menu.iramfloat.no=in IROM +nodemcuv2.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +nodemcuv2.menu.iramfloat.yes=allowed in ISR +nodemcuv2.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## modwifi.name=Olimex MOD-WIFI-ESP8266(-DEV) @@ -5614,6 +6331,7 @@ modwifi.serial.disableRTS=true modwifi.build.mcu=esp8266 modwifi.build.core=esp8266 modwifi.build.spiffs_pagesize=256 +modwifi.build.debug_optim= modwifi.build.debug_port= modwifi.build.debug_level= modwifi.menu.xtal.80=80 MHz @@ -5752,6 +6470,12 @@ modwifi.menu.dbg.Serial1=Serial1 modwifi.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 modwifi.menu.lvl.None____=None modwifi.menu.lvl.None____.build.debug_level= +modwifi.menu.optim.Smallest=None +modwifi.menu.optim.Smallest.build.debug_optim=-Os +modwifi.menu.optim.Lite=Lite +modwifi.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +modwifi.menu.optim.Full=Optimum +modwifi.menu.optim.Full.build.debug_optim=-Og modwifi.menu.lvl.SSL=SSL modwifi.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL modwifi.menu.lvl.TLS_MEM=TLS_MEM @@ -5843,6 +6567,10 @@ modwifi.menu.eesz.autoflash.build.flash_size=16M modwifi.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld modwifi.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 modwifi.menu.eesz.autoflash.upload.maximum_size=1044464 +modwifi.menu.iramfloat.no=in IROM +modwifi.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +modwifi.menu.iramfloat.yes=allowed in ISR +modwifi.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## phoenix_v1.name=Phoenix 1.0 @@ -5857,6 +6585,7 @@ phoenix_v1.serial.disableRTS=true phoenix_v1.build.mcu=esp8266 phoenix_v1.build.core=esp8266 phoenix_v1.build.spiffs_pagesize=256 +phoenix_v1.build.debug_optim= phoenix_v1.build.debug_port= phoenix_v1.build.debug_level= phoenix_v1.menu.xtal.80=80 MHz @@ -5967,6 +6696,12 @@ phoenix_v1.menu.dbg.Serial1=Serial1 phoenix_v1.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 phoenix_v1.menu.lvl.None____=None phoenix_v1.menu.lvl.None____.build.debug_level= +phoenix_v1.menu.optim.Smallest=None +phoenix_v1.menu.optim.Smallest.build.debug_optim=-Os +phoenix_v1.menu.optim.Lite=Lite +phoenix_v1.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +phoenix_v1.menu.optim.Full=Optimum +phoenix_v1.menu.optim.Full.build.debug_optim=-Og phoenix_v1.menu.lvl.SSL=SSL phoenix_v1.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL phoenix_v1.menu.lvl.TLS_MEM=TLS_MEM @@ -6058,6 +6793,10 @@ phoenix_v1.menu.eesz.autoflash.build.flash_size=16M phoenix_v1.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld phoenix_v1.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 phoenix_v1.menu.eesz.autoflash.upload.maximum_size=1044464 +phoenix_v1.menu.iramfloat.no=in IROM +phoenix_v1.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +phoenix_v1.menu.iramfloat.yes=allowed in ISR +phoenix_v1.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## phoenix_v2.name=Phoenix 2.0 @@ -6072,6 +6811,7 @@ phoenix_v2.serial.disableRTS=true phoenix_v2.build.mcu=esp8266 phoenix_v2.build.core=esp8266 phoenix_v2.build.spiffs_pagesize=256 +phoenix_v2.build.debug_optim= phoenix_v2.build.debug_port= phoenix_v2.build.debug_level= phoenix_v2.menu.xtal.80=80 MHz @@ -6182,6 +6922,12 @@ phoenix_v2.menu.dbg.Serial1=Serial1 phoenix_v2.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 phoenix_v2.menu.lvl.None____=None phoenix_v2.menu.lvl.None____.build.debug_level= +phoenix_v2.menu.optim.Smallest=None +phoenix_v2.menu.optim.Smallest.build.debug_optim=-Os +phoenix_v2.menu.optim.Lite=Lite +phoenix_v2.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +phoenix_v2.menu.optim.Full=Optimum +phoenix_v2.menu.optim.Full.build.debug_optim=-Og phoenix_v2.menu.lvl.SSL=SSL phoenix_v2.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL phoenix_v2.menu.lvl.TLS_MEM=TLS_MEM @@ -6273,6 +7019,10 @@ phoenix_v2.menu.eesz.autoflash.build.flash_size=16M phoenix_v2.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld phoenix_v2.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 phoenix_v2.menu.eesz.autoflash.upload.maximum_size=1044464 +phoenix_v2.menu.iramfloat.no=in IROM +phoenix_v2.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +phoenix_v2.menu.iramfloat.yes=allowed in ISR +phoenix_v2.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## eduinowifi.name=Schirmilabs Eduino WiFi @@ -6287,6 +7037,7 @@ eduinowifi.serial.disableRTS=true eduinowifi.build.mcu=esp8266 eduinowifi.build.core=esp8266 eduinowifi.build.spiffs_pagesize=256 +eduinowifi.build.debug_optim= eduinowifi.build.debug_port= eduinowifi.build.debug_level= eduinowifi.menu.xtal.80=80 MHz @@ -6394,6 +7145,12 @@ eduinowifi.menu.dbg.Serial1=Serial1 eduinowifi.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 eduinowifi.menu.lvl.None____=None eduinowifi.menu.lvl.None____.build.debug_level= +eduinowifi.menu.optim.Smallest=None +eduinowifi.menu.optim.Smallest.build.debug_optim=-Os +eduinowifi.menu.optim.Lite=Lite +eduinowifi.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +eduinowifi.menu.optim.Full=Optimum +eduinowifi.menu.optim.Full.build.debug_optim=-Og eduinowifi.menu.lvl.SSL=SSL eduinowifi.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL eduinowifi.menu.lvl.TLS_MEM=TLS_MEM @@ -6485,6 +7242,10 @@ eduinowifi.menu.eesz.autoflash.build.flash_size=16M eduinowifi.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld eduinowifi.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 eduinowifi.menu.eesz.autoflash.upload.maximum_size=1044464 +eduinowifi.menu.iramfloat.no=in IROM +eduinowifi.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +eduinowifi.menu.iramfloat.yes=allowed in ISR +eduinowifi.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## wiolink.name=Seeed Wio Link @@ -6499,6 +7260,7 @@ wiolink.serial.disableRTS=true wiolink.build.mcu=esp8266 wiolink.build.core=esp8266 wiolink.build.spiffs_pagesize=256 +wiolink.build.debug_optim= wiolink.build.debug_port= wiolink.build.debug_level= wiolink.menu.xtal.80=80 MHz @@ -6606,6 +7368,12 @@ wiolink.menu.dbg.Serial1=Serial1 wiolink.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 wiolink.menu.lvl.None____=None wiolink.menu.lvl.None____.build.debug_level= +wiolink.menu.optim.Smallest=None +wiolink.menu.optim.Smallest.build.debug_optim=-Os +wiolink.menu.optim.Lite=Lite +wiolink.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +wiolink.menu.optim.Full=Optimum +wiolink.menu.optim.Full.build.debug_optim=-Og wiolink.menu.lvl.SSL=SSL wiolink.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL wiolink.menu.lvl.TLS_MEM=TLS_MEM @@ -6697,6 +7465,10 @@ wiolink.menu.eesz.autoflash.build.flash_size=16M wiolink.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld wiolink.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 wiolink.menu.eesz.autoflash.upload.maximum_size=1044464 +wiolink.menu.iramfloat.no=in IROM +wiolink.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +wiolink.menu.iramfloat.yes=allowed in ISR +wiolink.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## blynk.name=SparkFun Blynk Board @@ -6711,6 +7483,7 @@ blynk.serial.disableRTS=true blynk.build.mcu=esp8266 blynk.build.core=esp8266 blynk.build.spiffs_pagesize=256 +blynk.build.debug_optim= blynk.build.debug_port= blynk.build.debug_level= blynk.menu.xtal.80=80 MHz @@ -6818,6 +7591,12 @@ blynk.menu.dbg.Serial1=Serial1 blynk.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 blynk.menu.lvl.None____=None blynk.menu.lvl.None____.build.debug_level= +blynk.menu.optim.Smallest=None +blynk.menu.optim.Smallest.build.debug_optim=-Os +blynk.menu.optim.Lite=Lite +blynk.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +blynk.menu.optim.Full=Optimum +blynk.menu.optim.Full.build.debug_optim=-Og blynk.menu.lvl.SSL=SSL blynk.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL blynk.menu.lvl.TLS_MEM=TLS_MEM @@ -6909,6 +7688,10 @@ blynk.menu.eesz.autoflash.build.flash_size=16M blynk.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld blynk.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 blynk.menu.eesz.autoflash.upload.maximum_size=1044464 +blynk.menu.iramfloat.no=in IROM +blynk.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +blynk.menu.iramfloat.yes=allowed in ISR +blynk.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## thing.name=SparkFun ESP8266 Thing @@ -6923,6 +7706,7 @@ thing.serial.disableRTS=true thing.build.mcu=esp8266 thing.build.core=esp8266 thing.build.spiffs_pagesize=256 +thing.build.debug_optim= thing.build.debug_port= thing.build.debug_level= thing.menu.xtal.80=80 MHz @@ -7030,6 +7814,12 @@ thing.menu.dbg.Serial1=Serial1 thing.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 thing.menu.lvl.None____=None thing.menu.lvl.None____.build.debug_level= +thing.menu.optim.Smallest=None +thing.menu.optim.Smallest.build.debug_optim=-Os +thing.menu.optim.Lite=Lite +thing.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +thing.menu.optim.Full=Optimum +thing.menu.optim.Full.build.debug_optim=-Og thing.menu.lvl.SSL=SSL thing.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL thing.menu.lvl.TLS_MEM=TLS_MEM @@ -7121,6 +7911,10 @@ thing.menu.eesz.autoflash.build.flash_size=16M thing.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld thing.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 thing.menu.eesz.autoflash.upload.maximum_size=1044464 +thing.menu.iramfloat.no=in IROM +thing.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +thing.menu.iramfloat.yes=allowed in ISR +thing.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## thingdev.name=SparkFun ESP8266 Thing Dev @@ -7135,6 +7929,7 @@ thingdev.serial.disableRTS=true thingdev.build.mcu=esp8266 thingdev.build.core=esp8266 thingdev.build.spiffs_pagesize=256 +thingdev.build.debug_optim= thingdev.build.debug_port= thingdev.build.debug_level= thingdev.menu.xtal.80=80 MHz @@ -7242,6 +8037,12 @@ thingdev.menu.dbg.Serial1=Serial1 thingdev.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 thingdev.menu.lvl.None____=None thingdev.menu.lvl.None____.build.debug_level= +thingdev.menu.optim.Smallest=None +thingdev.menu.optim.Smallest.build.debug_optim=-Os +thingdev.menu.optim.Lite=Lite +thingdev.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +thingdev.menu.optim.Full=Optimum +thingdev.menu.optim.Full.build.debug_optim=-Og thingdev.menu.lvl.SSL=SSL thingdev.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL thingdev.menu.lvl.TLS_MEM=TLS_MEM @@ -7333,6 +8134,10 @@ thingdev.menu.eesz.autoflash.build.flash_size=16M thingdev.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld thingdev.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 thingdev.menu.eesz.autoflash.upload.maximum_size=1044464 +thingdev.menu.iramfloat.no=in IROM +thingdev.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +thingdev.menu.iramfloat.yes=allowed in ISR +thingdev.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## esp210.name=SweetPea ESP-210 @@ -7347,6 +8152,7 @@ esp210.build.mcu=esp8266 esp210.build.core=esp8266 esp210.build.variant=generic esp210.build.spiffs_pagesize=256 +esp210.build.debug_optim= esp210.build.debug_port= esp210.build.debug_level= esp210.menu.xtal.80=80 MHz @@ -7454,6 +8260,12 @@ esp210.menu.dbg.Serial1=Serial1 esp210.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 esp210.menu.lvl.None____=None esp210.menu.lvl.None____.build.debug_level= +esp210.menu.optim.Smallest=None +esp210.menu.optim.Smallest.build.debug_optim=-Os +esp210.menu.optim.Lite=Lite +esp210.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +esp210.menu.optim.Full=Optimum +esp210.menu.optim.Full.build.debug_optim=-Og esp210.menu.lvl.SSL=SSL esp210.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL esp210.menu.lvl.TLS_MEM=TLS_MEM @@ -7545,6 +8357,10 @@ esp210.menu.eesz.autoflash.build.flash_size=16M esp210.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld esp210.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 esp210.menu.eesz.autoflash.upload.maximum_size=1044464 +esp210.menu.iramfloat.no=in IROM +esp210.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +esp210.menu.iramfloat.yes=allowed in ISR +esp210.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## espinotee.name=ThaiEasyElec's ESPino @@ -7559,6 +8375,7 @@ espinotee.serial.disableRTS=true espinotee.build.mcu=esp8266 espinotee.build.core=esp8266 espinotee.build.spiffs_pagesize=256 +espinotee.build.debug_optim= espinotee.build.debug_port= espinotee.build.debug_level= espinotee.menu.xtal.80=80 MHz @@ -7666,6 +8483,12 @@ espinotee.menu.dbg.Serial1=Serial1 espinotee.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 espinotee.menu.lvl.None____=None espinotee.menu.lvl.None____.build.debug_level= +espinotee.menu.optim.Smallest=None +espinotee.menu.optim.Smallest.build.debug_optim=-Os +espinotee.menu.optim.Lite=Lite +espinotee.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +espinotee.menu.optim.Full=Optimum +espinotee.menu.optim.Full.build.debug_optim=-Og espinotee.menu.lvl.SSL=SSL espinotee.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL espinotee.menu.lvl.TLS_MEM=TLS_MEM @@ -7757,6 +8580,10 @@ espinotee.menu.eesz.autoflash.build.flash_size=16M espinotee.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld espinotee.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 espinotee.menu.eesz.autoflash.upload.maximum_size=1044464 +espinotee.menu.iramfloat.no=in IROM +espinotee.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +espinotee.menu.iramfloat.yes=allowed in ISR +espinotee.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## wifi_kit_8.name=WiFi Kit 8 @@ -7771,6 +8598,7 @@ wifi_kit_8.serial.disableRTS=true wifi_kit_8.build.mcu=esp8266 wifi_kit_8.build.core=esp8266 wifi_kit_8.build.spiffs_pagesize=256 +wifi_kit_8.build.debug_optim= wifi_kit_8.build.debug_port= wifi_kit_8.build.debug_level= wifi_kit_8.menu.xtal.80=80 MHz @@ -7878,6 +8706,12 @@ wifi_kit_8.menu.dbg.Serial1=Serial1 wifi_kit_8.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 wifi_kit_8.menu.lvl.None____=None wifi_kit_8.menu.lvl.None____.build.debug_level= +wifi_kit_8.menu.optim.Smallest=None +wifi_kit_8.menu.optim.Smallest.build.debug_optim=-Os +wifi_kit_8.menu.optim.Lite=Lite +wifi_kit_8.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +wifi_kit_8.menu.optim.Full=Optimum +wifi_kit_8.menu.optim.Full.build.debug_optim=-Og wifi_kit_8.menu.lvl.SSL=SSL wifi_kit_8.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL wifi_kit_8.menu.lvl.TLS_MEM=TLS_MEM @@ -7969,6 +8803,10 @@ wifi_kit_8.menu.eesz.autoflash.build.flash_size=16M wifi_kit_8.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld wifi_kit_8.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 wifi_kit_8.menu.eesz.autoflash.upload.maximum_size=1044464 +wifi_kit_8.menu.iramfloat.no=in IROM +wifi_kit_8.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +wifi_kit_8.menu.iramfloat.yes=allowed in ISR +wifi_kit_8.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## wifiduino.name=WiFiduino @@ -7983,6 +8821,7 @@ wifiduino.serial.disableRTS=true wifiduino.build.mcu=esp8266 wifiduino.build.core=esp8266 wifiduino.build.spiffs_pagesize=256 +wifiduino.build.debug_optim= wifiduino.build.debug_port= wifiduino.build.debug_level= wifiduino.menu.xtal.80=80 MHz @@ -8090,6 +8929,12 @@ wifiduino.menu.dbg.Serial1=Serial1 wifiduino.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 wifiduino.menu.lvl.None____=None wifiduino.menu.lvl.None____.build.debug_level= +wifiduino.menu.optim.Smallest=None +wifiduino.menu.optim.Smallest.build.debug_optim=-Os +wifiduino.menu.optim.Lite=Lite +wifiduino.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +wifiduino.menu.optim.Full=Optimum +wifiduino.menu.optim.Full.build.debug_optim=-Og wifiduino.menu.lvl.SSL=SSL wifiduino.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL wifiduino.menu.lvl.TLS_MEM=TLS_MEM @@ -8181,6 +9026,10 @@ wifiduino.menu.eesz.autoflash.build.flash_size=16M wifiduino.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld wifiduino.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 wifiduino.menu.eesz.autoflash.upload.maximum_size=1044464 +wifiduino.menu.iramfloat.no=in IROM +wifiduino.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +wifiduino.menu.iramfloat.yes=allowed in ISR +wifiduino.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## wifinfo.name=WifInfo @@ -8212,6 +9061,7 @@ wifinfo.serial.disableRTS=true wifinfo.build.mcu=esp8266 wifinfo.build.core=esp8266 wifinfo.build.spiffs_pagesize=256 +wifinfo.build.debug_optim= wifinfo.build.debug_port= wifinfo.build.debug_level= wifinfo.menu.xtal.80=80 MHz @@ -8358,6 +9208,12 @@ wifinfo.menu.dbg.Serial1=Serial1 wifinfo.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 wifinfo.menu.lvl.None____=None wifinfo.menu.lvl.None____.build.debug_level= +wifinfo.menu.optim.Smallest=None +wifinfo.menu.optim.Smallest.build.debug_optim=-Os +wifinfo.menu.optim.Lite=Lite +wifinfo.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +wifinfo.menu.optim.Full=Optimum +wifinfo.menu.optim.Full.build.debug_optim=-Og wifinfo.menu.lvl.SSL=SSL wifinfo.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL wifinfo.menu.lvl.TLS_MEM=TLS_MEM @@ -8449,6 +9305,10 @@ wifinfo.menu.eesz.autoflash.build.flash_size=16M wifinfo.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld wifinfo.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 wifinfo.menu.eesz.autoflash.upload.maximum_size=1044464 +wifinfo.menu.iramfloat.no=in IROM +wifinfo.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +wifinfo.menu.iramfloat.yes=allowed in ISR +wifinfo.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM ############################################################## cw01.name=XinaBox CW01 @@ -8463,6 +9323,7 @@ cw01.serial.disableRTS=true cw01.build.mcu=esp8266 cw01.build.core=esp8266 cw01.build.spiffs_pagesize=256 +cw01.build.debug_optim= cw01.build.debug_port= cw01.build.debug_level= cw01.menu.xtal.80=80 MHz @@ -8573,6 +9434,12 @@ cw01.menu.dbg.Serial1=Serial1 cw01.menu.dbg.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1 cw01.menu.lvl.None____=None cw01.menu.lvl.None____.build.debug_level= +cw01.menu.optim.Smallest=None +cw01.menu.optim.Smallest.build.debug_optim=-Os +cw01.menu.optim.Lite=Lite +cw01.menu.optim.Lite.build.debug_optim=-Os -fno-optimize-sibling-calls +cw01.menu.optim.Full=Optimum +cw01.menu.optim.Full.build.debug_optim=-Og cw01.menu.lvl.SSL=SSL cw01.menu.lvl.SSL.build.debug_level= -DDEBUG_ESP_SSL cw01.menu.lvl.TLS_MEM=TLS_MEM @@ -8664,4 +9531,8 @@ cw01.menu.eesz.autoflash.build.flash_size=16M cw01.menu.eesz.autoflash.build.flash_ld=eagle.flash.auto.ld cw01.menu.eesz.autoflash.build.extra_flags=-DFLASH_MAP_SUPPORT=1 cw01.menu.eesz.autoflash.upload.maximum_size=1044464 +cw01.menu.iramfloat.no=in IROM +cw01.menu.iramfloat.no.build.iramfloat=-DFP_IN_IROM +cw01.menu.iramfloat.yes=allowed in ISR +cw01.menu.iramfloat.yes.build.iramfloat=-DFP_IN_IRAM diff --git a/bootloaders/eboot/eboot.c b/bootloaders/eboot/eboot.c index 6e15d137b2..c3d0c278f7 100644 --- a/bootloaders/eboot/eboot.c +++ b/bootloaders/eboot/eboot.c @@ -17,8 +17,39 @@ #define SWRST do { (*((volatile uint32_t*) 0x60000700)) |= 0x80000000; } while(0); -extern void ets_wdt_enable(void); -extern void ets_wdt_disable(void); +/* + After Power Enable Pin, EXT_RST, or HWDT event, at "main()" in eboot, WDT is + disabled. Key WDT hardware registers are zero. + + After "ESP.restart()" and other soft restarts, at "main()" in eboot, WDT is enabled. + + References for the under-documented ets_wdt_* API + https://mongoose-os.com/blog/esp8266-watchdog-timer/ + http://cholla.mmto.org/esp8266/bootrom/boot.txt + + After looking at esp8266-watchdog-timer some more, `ets_wdt_enable(4, 12, 12)` + is good for eboot's needs. From a ".map" the NON-OS SDK does not use the + ets_wdt_* APIs, so our choices are not too critical. + The SDK will set up the WDT as it wants it. + + A rationale for keeping the "ets_wdt_enable()" line, if the system is not + stable during a "soft restart," the HWDT would provide a recovery reboot. +*/ +extern void ets_wdt_enable(uint32_t mode, uint32_t arg1, uint32_t arg2); +/* + "ets_wdt_disable" + + Diables WDT, then feeds the dog. + For current modes other than 1 or 2, returns the current mode. + For current mode 1, calls ets_timer_disarm, then return the current mode. + For current mode 2, calls ets_isr_mask, then return the current mode. + + I always see a return value of 0xFFFFFFFF. + + The return value would normally be used with ets_wdt_restore; however, that is + not an option since a valid prior call to ets_wdt_enable() may not have been done. +*/ +extern uint32_t ets_wdt_disable(void); int print_version(const uint32_t flash_addr) { @@ -241,12 +272,12 @@ int main() ets_wdt_disable(); res = copy_raw(cmd.args[0], cmd.args[1], cmd.args[2], false); - ets_wdt_enable(); + ets_wdt_enable(4, 12, 12); // WDT about 13 secs. ets_printf("%d\n", res); #if 0 - //devyte: this verify step below (cmp:) only works when the end of copy operation above does not overwrite the - //beginning of the image in the empty area, see #7458. Disabling for now. + //devyte: this verify step below (cmp:) only works when the end of copy operation above does not overwrite the + //beginning of the image in the empty area, see #7458. Disabling for now. //TODO: replace the below verify with hash type, crc, or similar. // Verify the copy ets_printf("cmp:"); @@ -257,7 +288,7 @@ int main() } ets_printf("%d\n", res); -#endif +#endif if (res == 0) { cmd.action = ACTION_LOAD_APP; cmd.args[0] = cmd.args[1]; diff --git a/bootloaders/eboot/eboot.elf b/bootloaders/eboot/eboot.elf index 3ea8df6110..0e679ff46c 100755 Binary files a/bootloaders/eboot/eboot.elf and b/bootloaders/eboot/eboot.elf differ diff --git a/cores/esp8266/Arduino.h b/cores/esp8266/Arduino.h index 52c6be4cd9..60737e0195 100644 --- a/cores/esp8266/Arduino.h +++ b/cores/esp8266/Arduino.h @@ -33,6 +33,7 @@ extern "C" { #include #include +#include "umm_malloc/umm_malloc_cfgport.h" #include "stdlib_noniso.h" #include "binary.h" #include "esp8266_peri.h" @@ -311,7 +312,8 @@ void configTime(const char* tz, String server1, #endif #ifdef DEBUG_ESP_OOM -// reinclude *alloc redefinition because of undefining them -// this is mandatory for allowing OOM *alloc definitions in .ino files -#include "umm_malloc/umm_malloc_cfg.h" +// Position *alloc redefinition at the end of Arduino.h because would +// have undefined them. Mandatory for supporting OOM and other debug alloc +// definitions in .ino files +#include "heap_api_debug.h" #endif diff --git a/cores/esp8266/Esp-frag.cpp b/cores/esp8266/Esp-frag.cpp index 6913179974..9e4e9af6f1 100644 --- a/cores/esp8266/Esp-frag.cpp +++ b/cores/esp8266/Esp-frag.cpp @@ -19,10 +19,10 @@ */ #include "umm_malloc/umm_malloc.h" -#include "umm_malloc/umm_malloc_cfg.h" #include "coredecls.h" #include "Esp.h" +#if defined(UMM_INFO) void EspClass::getHeapStats(uint32_t* hfree, uint32_t* hmax, uint8_t* hfrag) { // L2 / Euclidean norm of free block sizes. @@ -60,3 +60,4 @@ uint8_t EspClass::getHeapFragmentation() { return (uint8_t)umm_fragmentation_metric(); } +#endif diff --git a/cores/esp8266/Esp.cpp b/cores/esp8266/Esp.cpp index 8cddd13353..67719dcfe7 100644 --- a/cores/esp8266/Esp.cpp +++ b/cores/esp8266/Esp.cpp @@ -31,6 +31,7 @@ #include "umm_malloc/umm_malloc.h" #include #include "reboot_uart_dwnld.h" +#include "hardware_reset.h" extern "C" { #include "user_interface.h" @@ -219,13 +220,15 @@ uint16_t EspClass::getVcc(void) uint32_t EspClass::getFreeHeap(void) { - return system_get_free_heap_size(); + return umm_free_heap_size_lw(); } +#if defined(UMM_INFO) uint32_t EspClass::getMaxFreeBlockSize(void) { return umm_max_block_size(); } +#endif uint32_t EspClass::getFreeContStack() { @@ -469,7 +472,7 @@ bool EspClass::checkFlashCRC() { uint32_t firstPart = (uintptr_t)&__crc_len - 0x40200000; // How many bytes to check before the 1st CRC val // Start the checksum - uint32_t crc = crc32((const void*)0x40200000, firstPart, 0xffffffff); + uint32_t crc = crc32((const void*)0x40200000, firstPart); // Pretend the 2 words of crc/len are zero to be idempotent crc = crc32(z, 8, crc); // Finish the CRC calculation over the rest of flash @@ -517,7 +520,7 @@ struct rst_info * EspClass::getResetInfoPtr(void) { } bool EspClass::eraseConfig(void) { - const size_t cfgSize = 0x4000; + const size_t cfgSize = 0x4000; // Sectors: RF_CAL + SYSTEMPARAM[3] size_t cfgAddr = ESP.getFlashChipSize() - cfgSize; for (size_t offset = 0; offset < cfgSize; offset += SPI_FLASH_SEC_SIZE) { @@ -529,6 +532,17 @@ bool EspClass::eraseConfig(void) { return true; } +bool EspClass::eraseConfigAndReset(void) { + // Before calling, ensure the WiFi state is equivalent to + // "WiFi.mode(WIFI_OFF)." This will reduce the likelihood of the SDK + // performing WiFi data writes to Flash between erasing and resetting. + bool reset = eraseConfig(); + if (reset) { + hardware_reset(); + } + return reset; +} + uint8_t *EspClass::random(uint8_t *resultArray, const size_t outputSizeBytes) { /** diff --git a/cores/esp8266/Esp.h b/cores/esp8266/Esp.h index 1bb793ef7f..9cb4141292 100644 --- a/cores/esp8266/Esp.h +++ b/cores/esp8266/Esp.h @@ -114,11 +114,12 @@ class EspClass { static uint32_t getChipId(); static uint32_t getFreeHeap(); +#if defined(UMM_INFO) static uint32_t getMaxFreeBlockSize(); static uint8_t getHeapFragmentation(); // in % static void getHeapStats(uint32_t* free = nullptr, uint16_t* max = nullptr, uint8_t* frag = nullptr) __attribute__((deprecated("Use 'uint32_t*' on max, 2nd argument"))); static void getHeapStats(uint32_t* free = nullptr, uint32_t* max = nullptr, uint8_t* frag = nullptr); - +#endif static uint32_t getFreeContStack(); static void resetFreeContStack(); @@ -211,6 +212,22 @@ class EspClass { static bool eraseConfig(); + /** + * @brief Erases 4 sectors at the end of flash, 1 - RF_CAL and 3 - SYSTEMPARM. + * These are the same additional sectors that are erase when you select + * Erase Flash: "Sketch + WiFi Settings" from the Arduino IDE Tools menu. + * + * This operation erases the running SDK's flash configuration space. + * As a precaution before calling, first call "WiFi.mode(WIFI_OFF)." + * + * If you need to erase "WiFi Settings" and reboot consider using + * "ArduinoOTA.eraseConfigAndReset()" it handles shutting down WiFi + * before the erase. + * @return bool result of operation. Always False on return. + * Function does not return on success. + */ + static bool eraseConfigAndReset(); + static uint8_t *random(uint8_t *resultArray, const size_t outputSizeBytes); static uint32_t random(); diff --git a/cores/esp8266/FS.cpp b/cores/esp8266/FS.cpp index d9e4209c0e..edfc1f8b49 100644 --- a/cores/esp8266/FS.cpp +++ b/cores/esp8266/FS.cpp @@ -173,18 +173,15 @@ File File::openNextFile() { return _fakeDir->openFile("r"); } -String File::readString() -{ +String File::readString() { String ret; ret.reserve(size() - position()); - char temp[256+1]; - int countRead = readBytes(temp, sizeof(temp)-1); - while (countRead > 0) - { - temp[countRead] = 0; - ret += temp; - countRead = readBytes(temp, sizeof(temp)-1); - } + uint8_t temp[256]; + int countRead; + do { + countRead = read(temp, sizeof(temp)); + ret.concat((const char*)temp, countRead); + } while (countRead > 0); return ret; } diff --git a/cores/esp8266/IPAddress.cpp b/cores/esp8266/IPAddress.cpp index c269d00506..6f68bc56e9 100644 --- a/cores/esp8266/IPAddress.cpp +++ b/cores/esp8266/IPAddress.cpp @@ -27,6 +27,11 @@ IPAddress::IPAddress(const IPAddress& from) ip_addr_copy(_ip, from._ip); } +IPAddress::IPAddress(IPAddress&& from) +{ + ip_addr_copy(_ip, from._ip); +} + IPAddress::IPAddress() { _ip = *IP_ANY_TYPE; // lwIP's v4-or-v6 generic address } @@ -36,24 +41,14 @@ bool IPAddress::isSet () const { } IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet) { - setV4(); - (*this)[0] = first_octet; - (*this)[1] = second_octet; - (*this)[2] = third_octet; - (*this)[3] = fourth_octet; -} + uint8_t addr[] { + first_octet, + second_octet, + third_octet, + fourth_octet, + }; -void IPAddress::ctor32(uint32_t address) { - setV4(); - v4() = address; -} - -IPAddress::IPAddress(const uint8_t *address) { - setV4(); - (*this)[0] = address[0]; - (*this)[1] = address[1]; - (*this)[2] = address[2]; - (*this)[3] = address[3]; + *this = &addr[0]; } bool IPAddress::fromString(const char *address) { @@ -111,8 +106,10 @@ bool IPAddress::fromString4(const char *address) { } IPAddress& IPAddress::operator=(const uint8_t *address) { - setV4(); - v4() = *reinterpret_cast(address); + uint32_t value; + memcpy_P(&value, address, sizeof(value)); + + *this = value; return *this; } @@ -123,7 +120,14 @@ IPAddress& IPAddress::operator=(uint32_t address) { } bool IPAddress::operator==(const uint8_t* addr) const { - return isV4() && v4() == *reinterpret_cast(addr); + if (!isV4()) { + return false; + } + + uint32_t value; + memcpy_P(&value, addr, sizeof(value)); + + return v4() == value; } size_t IPAddress::printTo(Print& p) const { diff --git a/cores/esp8266/IPAddress.h b/cores/esp8266/IPAddress.h index 894d431c68..99419b92a9 100644 --- a/cores/esp8266/IPAddress.h +++ b/cores/esp8266/IPAddress.h @@ -61,17 +61,16 @@ class IPAddress: public Printable { return reinterpret_cast(&v4()); } - void ctor32 (uint32_t); - public: - // Constructors IPAddress(); - IPAddress(const IPAddress& from); + IPAddress(const IPAddress&); + IPAddress(IPAddress&&); + IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet); - IPAddress(uint32_t address) { ctor32(address); } - IPAddress(unsigned long address) { ctor32(address); } - IPAddress(int address) { ctor32(address); } - IPAddress(const uint8_t *address); + IPAddress(uint32_t address) { *this = address; } + IPAddress(unsigned long address) { *this = address; } + IPAddress(int address) { *this = address; } + IPAddress(const uint8_t *address) { *this = address; } bool fromString(const char *address); bool fromString(const String &address) { return fromString(address.c_str()); } @@ -86,7 +85,7 @@ class IPAddress: public Printable { operator bool () { return isSet(); } // <- both are needed // generic IPv4 wrapper to uint32-view like arduino loves to see it - const uint32_t& v4() const { return ip_2_ip4(&_ip)->addr; } // for raw_address(const) + const uint32_t& v4() const { return ip_2_ip4(&_ip)->addr; } uint32_t& v4() { return ip_2_ip4(&_ip)->addr; } bool operator==(const IPAddress& addr) const { @@ -115,11 +114,18 @@ class IPAddress: public Printable { // Overloaded index operator to allow getting and setting individual octets of the address uint8_t operator[](int index) const { - return isV4()? *(raw_address() + index): 0; + if (!isV4()) { + return 0; + } + + return ip4_addr_get_byte_val(*ip_2_ip4(&_ip), index); } + uint8_t& operator[](int index) { setV4(); - return *(raw_address() + index); + + uint8_t* ptr = reinterpret_cast(&v4()); + return *(ptr + index); } // Overloaded copy operators to allow initialisation of IPAddress objects from other types diff --git a/cores/esp8266/LwipIntf.cpp b/cores/esp8266/LwipIntf.cpp index e142730df0..675063cd62 100644 --- a/cores/esp8266/LwipIntf.cpp +++ b/cores/esp8266/LwipIntf.cpp @@ -43,7 +43,7 @@ extern "C" // can return nullptr when STA is down // - Because WiFi is started in off mode at boot time, // wifi_station_set/get_hostname() is now no more used -// because setting hostname firt does not work anymore +// because setting hostname first does not work anymore // - wifi_station_hostname is overwritten by SDK when wifi is // woken up in WiFi::mode() // diff --git a/cores/esp8266/LwipIntf.h b/cores/esp8266/LwipIntf.h index 8d0bb1dce7..40907cd2bc 100644 --- a/cores/esp8266/LwipIntf.h +++ b/cores/esp8266/LwipIntf.h @@ -34,8 +34,6 @@ class LwipIntf public: using CBType = std::function; - static bool stateUpCB(LwipIntf::CBType&& cb); - // reorder WiFi.config() parameters for a esp8266/official Arduino dual-compatibility API // args | esp order arduino order // ---- + --------- ------------- @@ -67,8 +65,11 @@ class LwipIntf // ESP32 API compatibility const char* getHostname(); -protected: - static bool stateChangeSysCB(LwipIntf::CBType&& cb); + // whenever netif status callback is called + static bool statusChangeCB(LwipIntf::CBType); + + static bool stateUpCB(LwipIntf::CBType); + static bool stateDownCB(LwipIntf::CBType); }; #endif // _LWIPINTF_H diff --git a/cores/esp8266/LwipIntfCB.cpp b/cores/esp8266/LwipIntfCB.cpp index f7b9fd2b5a..945d7d43ac 100644 --- a/cores/esp8266/LwipIntfCB.cpp +++ b/cores/esp8266/LwipIntfCB.cpp @@ -25,44 +25,54 @@ #include #include -#define NETIF_STATUS_CB_SIZE 3 +static constexpr size_t LwipIntfCallbacks = 3; -static int netifStatusChangeListLength = 0; -LwipIntf::CBType netifStatusChangeList[NETIF_STATUS_CB_SIZE]; +static LwipIntf::CBType callbacks[LwipIntfCallbacks]; +static size_t size = 0; +// override empty weak function from glue-lwip extern "C" void netif_status_changed(struct netif* netif) { - // override the default empty weak function - for (int i = 0; i < netifStatusChangeListLength; i++) + for (size_t index = 0; index < size; ++index) { - netifStatusChangeList[i](netif); + callbacks[index](netif); } } -bool LwipIntf::stateChangeSysCB(LwipIntf::CBType&& cb) +bool LwipIntf::statusChangeCB(LwipIntf::CBType cb) { - if (netifStatusChangeListLength >= NETIF_STATUS_CB_SIZE) + if (size < LwipIntfCallbacks) { + callbacks[size++] = std::move(cb); + return true; + } #if defined(DEBUG_ESP_CORE) - DEBUGV("NETIF_STATUS_CB_SIZE is too low\n"); + DEBUGV("LwipIntf::CB %zu/%zu, cannot add more!\n", size, size); #endif - return false; - } - netifStatusChangeList[netifStatusChangeListLength++] = cb; - return true; + return false; +} + +bool LwipIntf::stateUpCB(LwipIntf::CBType cb) +{ + return statusChangeCB( + [cb](netif* interface) + { + if (netif_is_up(interface)) + { + cb(interface); + } + }); } -bool LwipIntf::stateUpCB(LwipIntf::CBType&& cb) +bool LwipIntf::stateDownCB(LwipIntf::CBType cb) { - return stateChangeSysCB( - [cb](netif* nif) + return statusChangeCB( + [cb](netif* interface) { - if (netif_is_up(nif)) - schedule_function( - [cb, nif]() - { - cb(nif); - }); + if (!netif_is_up(interface)) + { + cb(interface); + } }); } diff --git a/cores/esp8266/LwipIntfDev.h b/cores/esp8266/LwipIntfDev.h index 00f29e9dfe..d69e2d73d8 100644 --- a/cores/esp8266/LwipIntfDev.h +++ b/cores/esp8266/LwipIntfDev.h @@ -46,6 +46,13 @@ #define DEFAULT_MTU 1500 #endif +enum EthernetLinkStatus +{ + Unknown, + LinkON, + LinkOFF +}; + template class LwipIntfDev: public LwipIntf, public RawDev { @@ -56,17 +63,31 @@ class LwipIntfDev: public LwipIntf, public RawDev memset(&_netif, 0, sizeof(_netif)); } + //The argument order for ESP is not the same as for Arduino. However, there is compatibility code under the hood + //to detect Arduino arg order, and handle it correctly. boolean config(const IPAddress& local_ip, const IPAddress& arg1, const IPAddress& arg2, const IPAddress& arg3 = IPADDR_NONE, const IPAddress& dns2 = IPADDR_NONE); + // two and one parameter version. 2nd parameter is DNS like in Arduino. IPv4 only + [[deprecated("It is discouraged to use this 1 or 2 parameters network configuration legacy " + "function config(ip[,dns]) as chosen defaults may not match the local network " + "configuration")]] boolean + config(IPAddress local_ip, IPAddress dns = INADDR_ANY); + // default mac-address is inferred from esp8266's STA interface boolean begin(const uint8_t* macAddress = nullptr, const uint16_t mtu = DEFAULT_MTU); + void end(); const netif* getNetIf() const { return &_netif; } + uint8_t* macAddress(uint8_t* mac) + { + memcpy(mac, &_netif.hwaddr, 6); + return mac; + } IPAddress localIP() const { return IPAddress(ip4_addr_get_u32(ip_2_ip4(&_netif.ip_addr))); @@ -79,6 +100,21 @@ class LwipIntfDev: public LwipIntf, public RawDev { return IPAddress(ip4_addr_get_u32(ip_2_ip4(&_netif.gw))); } + IPAddress dnsIP(int n = 0) const + { + return IPAddress(dns_getserver(n)); + } + void setDNS(IPAddress dns1, IPAddress dns2 = INADDR_ANY) + { + if (dns1.isSet()) + { + dns_setserver(0, dns1); + } + if (dns2.isSet()) + { + dns_setserver(1, dns2); + } + } // 1. Currently when no default is set, esp8266-Arduino uses the first // DHCP client interface receiving a valid address and gateway to @@ -93,9 +129,11 @@ class LwipIntfDev: public LwipIntf, public RawDev void setDefault(bool deflt = true); // true if interface has a valid IPv4 address + // (and ethernet link status is not detectable or is up) bool connected() { - return !!ip4_addr_get_u32(ip_2_ip4(&_netif.ip_addr)); + return !!ip4_addr_get_u32(ip_2_ip4(&_netif.ip_addr)) + && (!RawDev::isLinkDetectable() || RawDev::isLinked()); } bool routable() @@ -106,6 +144,9 @@ class LwipIntfDev: public LwipIntf, public RawDev // ESP8266WiFi API compatibility wl_status_t status(); + // Arduino Ethernet compatibility + EthernetLinkStatus linkStatus(); + protected: err_t netif_init(); void check_route(); @@ -126,6 +167,7 @@ class LwipIntfDev: public LwipIntf, public RawDev int8_t _intrPin; uint8_t _macAddress[6]; bool _started; + bool _scheduled; bool _default; }; @@ -163,6 +205,24 @@ boolean LwipIntfDev::config(const IPAddress& localIP, const IPAddress& g return true; } +template +boolean LwipIntfDev::config(IPAddress local_ip, IPAddress dns) +{ + if (!local_ip.isSet()) + return config(INADDR_ANY, INADDR_ANY, INADDR_ANY); + + if (!local_ip.isV4()) + return false; + + IPAddress gw(local_ip); + gw[3] = 1; + if (!dns.isSet()) + { + dns = gw; + } + return config(local_ip, gw, IPAddress(255, 255, 255, 0), dns); +} + template boolean LwipIntfDev::begin(const uint8_t* macAddress, const uint16_t mtu) { @@ -217,6 +277,7 @@ boolean LwipIntfDev::begin(const uint8_t* macAddress, const uint16_t mtu if (!netif_add(&_netif, ip_2_ip4(&ip_addr), ip_2_ip4(&netmask), ip_2_ip4(&gw), this, netif_init_s, ethernet_input)) { + RawDev::end(); return false; } @@ -230,10 +291,11 @@ boolean LwipIntfDev::begin(const uint8_t* macAddress, const uint16_t mtu break; case ERR_IF: + RawDev::end(); return false; default: - netif_remove(&_netif); + end(); return false; } } @@ -260,28 +322,53 @@ boolean LwipIntfDev::begin(const uint8_t* macAddress, const uint16_t mtu } } - if (_intrPin < 0 - && !schedule_recurrent_function_us( + if (_intrPin < 0 && !_scheduled) + { + _scheduled = schedule_recurrent_function_us( [&]() { + if (!_started) + { + _scheduled = false; + return false; + } this->handlePackets(); return true; }, - 100)) - { - netif_remove(&_netif); - return false; + 100); + if (!_scheduled) + { + end(); + return false; + } } return true; } +template +void LwipIntfDev::end() +{ + if (_started) + { + netif_remove(&_netif); + _started = false; + RawDev::end(); + } +} + template wl_status_t LwipIntfDev::status() { return _started ? (connected() ? WL_CONNECTED : WL_DISCONNECTED) : WL_NO_SHIELD; } +template +EthernetLinkStatus LwipIntfDev::linkStatus() +{ + return RawDev::isLinkDetectable() ? _started && RawDev::isLinked() ? LinkON : LinkOFF : Unknown; +} + template err_t LwipIntfDev::linkoutput_s(netif* netif, struct pbuf* pbuf) { diff --git a/cores/esp8266/Schedule.cpp b/cores/esp8266/Schedule.cpp index 279e78ff6c..f6c650fcf9 100644 --- a/cores/esp8266/Schedule.cpp +++ b/cores/esp8266/Schedule.cpp @@ -17,6 +17,7 @@ */ #include +#include #include "Schedule.h" #include "PolledTimeout.h" @@ -34,6 +35,7 @@ static scheduled_fn_t* sFirst = nullptr; static scheduled_fn_t* sLast = nullptr; static scheduled_fn_t* sUnused = nullptr; static int sCount = 0; +static uint32_t recurrent_max_grain_mS = 0; typedef std::function mRecFuncT; struct recurrent_fn_t @@ -130,9 +132,39 @@ bool schedule_recurrent_function_us(const std::function& fn, } rLast = item; + // grain needs to be recomputed + recurrent_max_grain_mS = 0; + return true; } +uint32_t compute_scheduled_recurrent_grain () +{ + if (recurrent_max_grain_mS == 0) + { + if (rFirst) + { + uint32_t recurrent_max_grain_uS = rFirst->callNow.getTimeout(); + for (auto it = rFirst->mNext; it; it = it->mNext) + recurrent_max_grain_uS = std::gcd(recurrent_max_grain_uS, it->callNow.getTimeout()); + if (recurrent_max_grain_uS) + // round to the upper millis + recurrent_max_grain_mS = recurrent_max_grain_uS <= 1000? 1: (recurrent_max_grain_uS + 999) / 1000; + } + +#ifdef DEBUG_ESP_CORE + static uint32_t last_grain = 0; + if (recurrent_max_grain_mS != last_grain) + { + ::printf(":rsf %u->%u\n", last_grain, recurrent_max_grain_mS); + last_grain = recurrent_max_grain_mS; + } +#endif + } + + return recurrent_max_grain_mS; +} + void run_scheduled_functions() { // prevent scheduling of new functions during this run @@ -226,6 +258,9 @@ void run_scheduled_recurrent_functions() } delete(to_ditch); + + // grain needs to be recomputed + recurrent_max_grain_mS = 0; } else { diff --git a/cores/esp8266/Schedule.h b/cores/esp8266/Schedule.h index da86e5b7f5..362d15b5f3 100644 --- a/cores/esp8266/Schedule.h +++ b/cores/esp8266/Schedule.h @@ -39,6 +39,11 @@ // scheduled function happen more often: every yield() (vs every loop()), // and time resolution is microsecond (vs millisecond). Details are below. +// compute_scheduled_recurrent_grain() is used by delay() to give a chance to +// all recurrent functions to run per their timing requirement. + +uint32_t compute_scheduled_recurrent_grain (); + // scheduled functions called once: // // * internal queue is FIFO. diff --git a/cores/esp8266/StackThunk.cpp b/cores/esp8266/StackThunk.cpp index 7456fcaeeb..baa793bdc5 100644 --- a/cores/esp8266/StackThunk.cpp +++ b/cores/esp8266/StackThunk.cpp @@ -27,18 +27,26 @@ #include #include #include -#include "pgmspace.h" + #include "debug.h" #include "StackThunk.h" + +#include #include + #include #include extern "C" { +extern void optimistic_yield(uint32_t); + uint32_t *stack_thunk_ptr = NULL; uint32_t *stack_thunk_top = NULL; + uint32_t *stack_thunk_save = NULL; /* Saved A1 while in BearSSL */ +uint32_t *stack_thunk_yield_save = NULL; /* Saved A1 when yielding from within BearSSL */ + uint32_t stack_thunk_refcnt = 0; /* Largest stack usage seen in the wild at 6120 */ @@ -142,11 +150,45 @@ void stack_thunk_dump_stack() ets_printf("<< cont stacks */ + "movi a2, stack_thunk_yield_save\n\t" + "s32i.n a1, a2, 0\n\t" + "movi a2, stack_thunk_save\n\t" + "l32i.n a1, a2, 0\n\t" +/* optimistic_yield(10000) without extra l32r */ + "movi a2, 0x10\n\t" + "addmi a2, a2, 0x2700\n\t" + "call0 optimistic_yield\n\t" +/* Swap bearssl <-> cont stacks, again */ + "movi a2, stack_thunk_yield_save\n\t" + "l32i.n a1, a2, 0\n\t" + "\n" +/* Restore caller */ + "l32i.n a0, a1, 12\n\t" + "addi a1, a1, 16\n\t" + "ret.n\n\t" + ".size stack_thunk_yield, .-stack_thunk_yield\n\t" +); + +} diff --git a/cores/esp8266/StackThunk.h b/cores/esp8266/StackThunk.h index ffaeb32947..350775ec24 100644 --- a/cores/esp8266/StackThunk.h +++ b/cores/esp8266/StackThunk.h @@ -31,6 +31,8 @@ extern "C" { #endif +extern void stack_thunk_yield(void); + extern void stack_thunk_add_ref(); extern void stack_thunk_del_ref(); extern void stack_thunk_repaint(); @@ -41,7 +43,7 @@ extern uint32_t stack_thunk_get_stack_bot(); extern uint32_t stack_thunk_get_cont_sp(); extern uint32_t stack_thunk_get_max_usage(); extern void stack_thunk_dump_stack(); -extern void stack_thunk_fatal_overflow(); +extern void stack_thunk_fatal_smashing(); // Globals required for thunking operation extern uint32_t *stack_thunk_ptr; @@ -75,7 +77,7 @@ thunk_"#fcnToThunk":\n\ l32i.n a15, a15, 0 /* A15 now has contents of last stack entry */\n\ l32r a0, .LC_STACK_VALUE"#fcnToThunk" /* A0 now has the check value */\n\ beq a0, a15, .L1"#fcnToThunk"\n\ - call0 stack_thunk_fatal_overflow\n\ + call0 stack_thunk_fatal_smashing\n\ .L1"#fcnToThunk":\n\ movi a15, stack_thunk_save /* Restore A1(SP) */\n\ l32i.n a1, a15, 0\n\ diff --git a/cores/esp8266/Stream.cpp b/cores/esp8266/Stream.cpp index f6aa7487c7..b9b5b95f65 100644 --- a/cores/esp8266/Stream.cpp +++ b/cores/esp8266/Stream.cpp @@ -58,16 +58,16 @@ int Stream::timedPeek() { // returns peek of the next digit in the stream or -1 if timeout // discards non-numeric characters -int Stream::peekNextDigit() { +int Stream::peekNextDigit(bool detectDecimal) { int c; while(1) { c = timedPeek(); - if(c < 0) - return c; // timeout - if(c == '-') - return c; - if(c >= '0' && c <= '9') + if( c < 0 || // timeout + c == '-' || + ( c >= '0' && c <= '9' ) || + ( detectDecimal && c == '.' ) ) { return c; + } read(); // discard non-numeric } } @@ -141,7 +141,7 @@ long Stream::parseInt(char skipChar) { long value = 0; int c; - c = peekNextDigit(); + c = peekNextDigit(false); // ignore non numeric leading characters if(c < 0) return 0; // zero returned if timeout @@ -176,7 +176,7 @@ float Stream::parseFloat(char skipChar) { int c; float fraction = 1.0f; - c = peekNextDigit(); + c = peekNextDigit(true); // ignore non numeric leading characters if(c < 0) return 0; // zero returned if timeout @@ -262,6 +262,32 @@ String Stream::readStringUntil(char terminator) { return ret; } +String Stream::readStringUntil(const char* terminator, uint32_t untilTotalNumberOfOccurrences) { + String ret; + int c; + uint32_t occurrences = 0; + size_t termLen = strlen(terminator); + size_t termIndex = 0; + size_t index = 0; + + while ((c = timedRead()) > 0) { + ret += (char) c; + index++; + + if (terminator[termIndex] == c) { + if (++termIndex == termLen && ++occurrences == untilTotalNumberOfOccurrences) { + // don't include terminator in returned string + ret.remove(index - termIndex, termLen); + break; + } + } else { + termIndex = 0; + } + } + + return ret; +} + // read what can be read, immediate exit on unavailable data // prototype similar to Arduino's `int Client::read(buf, len)` int Stream::read (uint8_t* buffer, size_t maxLen) diff --git a/cores/esp8266/Stream.h b/cores/esp8266/Stream.h index 1dd2ee24a6..0706bec001 100644 --- a/cores/esp8266/Stream.h +++ b/cores/esp8266/Stream.h @@ -53,7 +53,7 @@ class Stream: public Print { unsigned long _startMillis; // used for timeout measurement int timedRead(); // private method to read stream with timeout int timedPeek(); // private method to peek stream with timeout - int peekNextDigit(); // returns the next numeric digit in the stream or -1 if timeout + int peekNextDigit(bool detectDecimal = false); // returns the next numeric digit in the stream or -1 if timeout public: virtual int available() = 0; @@ -115,6 +115,7 @@ class Stream: public Print { // Arduino String functions to be added here virtual String readString(); String readStringUntil(char terminator); + String readStringUntil(const char* terminator, uint32_t untilTotalNumberOfOccurrences = 1); virtual int read (uint8_t* buffer, size_t len); int read (char* buffer, size_t len) { return read((uint8_t*)buffer, len); } @@ -167,25 +168,53 @@ class Stream: public Print { // When result is 0 or less than requested maxLen, Print::getLastSend() // contains an error reason. +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + + // transfers already buffered / immediately available data (no timeout) + // returns number of transferred bytes + [[deprecated]] size_t sendAvailable (Print* to) { return sendGeneric(to, -1, -1, oneShotMs::alwaysExpired); } + [[deprecated]] size_t sendAvailable (Print& to) { return sendAvailable(&to); } + + // transfers data until timeout + // returns number of transferred bytes + [[deprecated]] size_t sendAll (Print* to, const oneShotMs::timeType timeoutMs = oneShotMs::neverExpires) { return sendGeneric(to, -1, -1, timeoutMs); } + [[deprecated]] size_t sendAll (Print& to, const oneShotMs::timeType timeoutMs = oneShotMs::neverExpires) { return sendAll(&to, timeoutMs); } + + // transfers data until a char is encountered (the char is swallowed but not transferred) with timeout + // returns number of transferred bytes + [[deprecated]] size_t sendUntil (Print* to, const int readUntilChar, const oneShotMs::timeType timeoutMs = oneShotMs::neverExpires) { return sendGeneric(to, -1, readUntilChar, timeoutMs); } + [[deprecated]] size_t sendUntil (Print& to, const int readUntilChar, const oneShotMs::timeType timeoutMs = oneShotMs::neverExpires) { return sendUntil(&to, readUntilChar, timeoutMs); } + + // transfers data until requested size or timeout + // returns number of transferred bytes + [[deprecated]] size_t sendSize (Print* to, const ssize_t maxLen, const oneShotMs::timeType timeoutMs = oneShotMs::neverExpires) { return sendGeneric(to, maxLen, -1, timeoutMs); } + [[deprecated]] size_t sendSize (Print& to, const ssize_t maxLen, const oneShotMs::timeType timeoutMs = oneShotMs::neverExpires) { return sendSize(&to, maxLen, timeoutMs); } + +#pragma GCC diagnostic pop + // transfers already buffered / immediately available data (no timeout) // returns number of transferred bytes - size_t sendAvailable (Print* to) { return sendGeneric(to, -1, -1, oneShotMs::alwaysExpired); } - size_t sendAvailable (Print& to) { return sendAvailable(&to); } + size_t sendAvailable (Stream* to) { return sendGeneric(to, -1, -1, oneShotMs::alwaysExpired); } + size_t sendAvailable (Stream& to) { return sendAvailable(&to); } + size_t sendAvailable (Stream&& to) { return sendAvailable(&to); } // transfers data until timeout // returns number of transferred bytes - size_t sendAll (Print* to, const oneShotMs::timeType timeoutMs = oneShotMs::neverExpires) { return sendGeneric(to, -1, -1, timeoutMs); } - size_t sendAll (Print& to, const oneShotMs::timeType timeoutMs = oneShotMs::neverExpires) { return sendAll(&to, timeoutMs); } + size_t sendAll (Stream* to, const oneShotMs::timeType timeoutMs = oneShotMs::neverExpires) { return sendGeneric(to, -1, -1, timeoutMs); } + size_t sendAll (Stream& to, const oneShotMs::timeType timeoutMs = oneShotMs::neverExpires) { return sendAll(&to, timeoutMs); } + size_t sendAll (Stream&& to, const oneShotMs::timeType timeoutMs = oneShotMs::neverExpires) { return sendAll(&to, timeoutMs); } // transfers data until a char is encountered (the char is swallowed but not transferred) with timeout // returns number of transferred bytes - size_t sendUntil (Print* to, const int readUntilChar, const oneShotMs::timeType timeoutMs = oneShotMs::neverExpires) { return sendGeneric(to, -1, readUntilChar, timeoutMs); } - size_t sendUntil (Print& to, const int readUntilChar, const oneShotMs::timeType timeoutMs = oneShotMs::neverExpires) { return sendUntil(&to, readUntilChar, timeoutMs); } + size_t sendUntil (Stream* to, const int readUntilChar, const oneShotMs::timeType timeoutMs = oneShotMs::neverExpires) { return sendGeneric(to, -1, readUntilChar, timeoutMs); } + size_t sendUntil (Stream& to, const int readUntilChar, const oneShotMs::timeType timeoutMs = oneShotMs::neverExpires) { return sendUntil(&to, readUntilChar, timeoutMs); } + size_t sendUntil (Stream&& to, const int readUntilChar, const oneShotMs::timeType timeoutMs = oneShotMs::neverExpires) { return sendUntil(&to, readUntilChar, timeoutMs); } // transfers data until requested size or timeout // returns number of transferred bytes - size_t sendSize (Print* to, const ssize_t maxLen, const oneShotMs::timeType timeoutMs = oneShotMs::neverExpires) { return sendGeneric(to, maxLen, -1, timeoutMs); } - size_t sendSize (Print& to, const ssize_t maxLen, const oneShotMs::timeType timeoutMs = oneShotMs::neverExpires) { return sendSize(&to, maxLen, timeoutMs); } + size_t sendSize (Stream* to, const ssize_t maxLen, const oneShotMs::timeType timeoutMs = oneShotMs::neverExpires) { return sendGeneric(to, maxLen, -1, timeoutMs); } + size_t sendSize (Stream& to, const ssize_t maxLen, const oneShotMs::timeType timeoutMs = oneShotMs::neverExpires) { return sendSize(&to, maxLen, timeoutMs); } + size_t sendSize (Stream&& to, const ssize_t maxLen, const oneShotMs::timeType timeoutMs = oneShotMs::neverExpires) { return sendSize(&to, maxLen, timeoutMs); } // remaining size (-1 by default = unknown) virtual ssize_t streamRemaining () { return -1; } @@ -202,11 +231,17 @@ class Stream: public Print { Report getLastSendReport () const { return _sendReport; } protected: + [[deprecated]] size_t sendGeneric (Print* to, const ssize_t len = -1, const int readUntilChar = -1, oneShotMs::timeType timeoutMs = oneShotMs::neverExpires /* neverExpires=>getTimeout() */); + size_t sendGeneric (Stream* to, + const ssize_t len = -1, + const int readUntilChar = -1, + oneShotMs::timeType timeoutMs = oneShotMs::neverExpires /* neverExpires=>getTimeout() */); + size_t SendGenericPeekBuffer(Print* to, const ssize_t len, const int readUntilChar, const oneShotMs::timeType timeoutMs); size_t SendGenericRegularUntil(Print* to, const ssize_t len, const int readUntilChar, const oneShotMs::timeType timeoutMs); size_t SendGenericRegular(Print* to, const ssize_t len, const oneShotMs::timeType timeoutMs); diff --git a/cores/esp8266/StreamSend.cpp b/cores/esp8266/StreamSend.cpp index bf07f397b8..b46d1c1560 100644 --- a/cores/esp8266/StreamSend.cpp +++ b/cores/esp8266/StreamSend.cpp @@ -22,9 +22,54 @@ #include #include +size_t Stream::sendGeneric(Stream* to, const ssize_t len, const int readUntilChar, + const esp8266::polledTimeout::oneShotFastMs::timeType timeoutMs) +{ + // "neverExpires (default, impossible)" is translated to default timeout + esp8266::polledTimeout::oneShotFastMs::timeType inputTimeoutMs + = timeoutMs >= esp8266::polledTimeout::oneShotFastMs::neverExpires ? getTimeout() + : timeoutMs; + + esp8266::polledTimeout::oneShotFastMs::timeType mainTimeoutMs = std::max( + inputTimeoutMs, (esp8266::polledTimeout::oneShotFastMs::timeType)to->getTimeout()); + + setReport(Report::Success); + + if (len == 0) + { + return 0; // conveniently avoids timeout for no requested data + } + + // There are two timeouts: + // - read (network, serial, ...) + // - write (network, serial, ...) + // However + // - getTimeout() is for reading only + // - there is no getOutputTimeout() api + // So we use getTimeout() for both, + // (also when inputCanTimeout() is false) + + if (hasPeekBufferAPI()) + { + return SendGenericPeekBuffer(to, len, readUntilChar, mainTimeoutMs); + } + + if (readUntilChar >= 0) + { + return SendGenericRegularUntil(to, len, readUntilChar, mainTimeoutMs); + } + + return SendGenericRegular(to, len, mainTimeoutMs); +} + size_t Stream::sendGeneric(Print* to, const ssize_t len, const int readUntilChar, const esp8266::polledTimeout::oneShotFastMs::timeType timeoutMs) { + // "neverExpires (default, impossible)" is translated to default timeout + esp8266::polledTimeout::oneShotFastMs::timeType inputTimeoutMs + = timeoutMs >= esp8266::polledTimeout::oneShotFastMs::neverExpires ? getTimeout() + : timeoutMs; + setReport(Report::Success); if (len == 0) @@ -43,25 +88,23 @@ size_t Stream::sendGeneric(Print* to, const ssize_t len, const int readUntilChar if (hasPeekBufferAPI()) { - return SendGenericPeekBuffer(to, len, readUntilChar, timeoutMs); + return SendGenericPeekBuffer(to, len, readUntilChar, inputTimeoutMs); } if (readUntilChar >= 0) { - return SendGenericRegularUntil(to, len, readUntilChar, timeoutMs); + return SendGenericRegularUntil(to, len, readUntilChar, inputTimeoutMs); } - return SendGenericRegular(to, len, timeoutMs); + return SendGenericRegular(to, len, inputTimeoutMs); } size_t Stream::SendGenericPeekBuffer(Print* to, const ssize_t len, const int readUntilChar, const esp8266::polledTimeout::oneShotFastMs::timeType timeoutMs) { - // "neverExpires (default, impossible)" is translated to default timeout - esp8266::polledTimeout::oneShotFastMs timedOut( - timeoutMs >= esp8266::polledTimeout::oneShotFastMs::neverExpires ? getTimeout() - : timeoutMs); + esp8266::polledTimeout::oneShotFastMs timedOut(timeoutMs); + // len==-1 => maxLen=0 <=> until starvation const size_t maxLen = std::max((ssize_t)0, len); size_t written = 0; @@ -152,10 +195,8 @@ Stream::SendGenericRegularUntil(Print* to, const ssize_t len, const int readUnti // regular Stream API // no other choice than reading byte by byte - // "neverExpires (default, impossible)" is translated to default timeout - esp8266::polledTimeout::oneShotFastMs timedOut( - timeoutMs >= esp8266::polledTimeout::oneShotFastMs::neverExpires ? getTimeout() - : timeoutMs); + esp8266::polledTimeout::oneShotFastMs timedOut(timeoutMs); + // len==-1 => maxLen=0 <=> until starvation const size_t maxLen = std::max((ssize_t)0, len); size_t written = 0; @@ -231,10 +272,8 @@ size_t Stream::SendGenericRegular(Print* to, const ssize_t len, // regular Stream API // use an intermediary buffer - // "neverExpires (default, impossible)" is translated to default timeout - esp8266::polledTimeout::oneShotFastMs timedOut( - timeoutMs >= esp8266::polledTimeout::oneShotFastMs::neverExpires ? getTimeout() - : timeoutMs); + esp8266::polledTimeout::oneShotFastMs timedOut(timeoutMs); + // len==-1 => maxLen=0 <=> until starvation const size_t maxLen = std::max((ssize_t)0, len); size_t written = 0; diff --git a/cores/esp8266/StreamString.h b/cores/esp8266/StreamString.h index 2331a3c51a..dced5aee80 100644 --- a/cores/esp8266/StreamString.h +++ b/cores/esp8266/StreamString.h @@ -29,7 +29,7 @@ #include "WString.h" /////////////////////////////////////////////////////////////// -// S2Stream points to a String and makes it a Stream +// S2Stream ("String to Stream") points to a String and makes it a Stream // (it is also the helper for StreamString) class S2Stream: public Stream @@ -184,19 +184,18 @@ class S2Stream: public Stream return peekPointer < 0 ? string->length() : string->length() - peekPointer; } - // calling setConsume() will consume bytes as the stream is read - // (enabled by default) + // calling setConsume() will make the string consumed as the stream is read. + // (default behaviour) void setConsume() { peekPointer = -1; } - // Reading this stream will mark the string as read without consuming - // (not enabled by default) - // Calling resetPointer() resets the read state and allows rereading. - void resetPointer(int pointer = 0) + // Calling resetPointer() resets the read cursor and allows rereading. + // (this is the opposite of default mode set by setConsume()) + void resetPointer(size_t pointer = 0) { - peekPointer = pointer; + peekPointer = std::min(pointer, (size_t)string->length()); } protected: @@ -204,6 +203,7 @@ class S2Stream: public Stream int peekPointer; // -1:String is consumed / >=0:resettable pointer }; +/////////////////////////////////////////////////////////////// // StreamString is a S2Stream holding the String class StreamString: public String, public S2Stream diff --git a/cores/esp8266/TZ.h b/cores/esp8266/TZ.h index ea53c363a8..478abb16c0 100644 --- a/cores/esp8266/TZ.h +++ b/cores/esp8266/TZ.h @@ -1,22 +1,16 @@ +// ! ! ! DO NOT EDIT, AUTOMATICALLY GENERATED ! ! ! +// File created 2024-02-05 00:00:00.000000+00:00 +// Based on IANA database 2023d +// Re-run /tools/tools/format_tzdata.py to update -// autogenerated from https://raw.githubusercontent.com/nayarsystems/posix_tz_db/master/zones.csv -// by script /tools/TZupdate.sh -// Mon Jul 26 20:04:37 UTC 2021 -// -// This database is autogenerated from IANA timezone database -// https://raw.githubusercontent.com/nayarsystems/posix_tz_db/master/zones.csv -// (using https://www.iana.org/time-zones) -// and can be updated on demand in this repository -// or by yourself using the above script - -#ifndef TZDB_H -#define TZDB_H +#pragma once #define TZ_Africa_Abidjan PSTR("GMT0") #define TZ_Africa_Accra PSTR("GMT0") #define TZ_Africa_Addis_Ababa PSTR("EAT-3") #define TZ_Africa_Algiers PSTR("CET-1") #define TZ_Africa_Asmara PSTR("EAT-3") +#define TZ_Africa_Asmera PSTR("EAT-3") #define TZ_Africa_Bamako PSTR("GMT0") #define TZ_Africa_Bangui PSTR("WAT-1") #define TZ_Africa_Banjul PSTR("GMT0") @@ -24,7 +18,7 @@ #define TZ_Africa_Blantyre PSTR("CAT-2") #define TZ_Africa_Brazzaville PSTR("WAT-1") #define TZ_Africa_Bujumbura PSTR("CAT-2") -#define TZ_Africa_Cairo PSTR("EET-2") +#define TZ_Africa_Cairo PSTR("EET-2EEST,M4.5.5/0,M10.5.4/24") #define TZ_Africa_Casablanca PSTR("<+01>-1") #define TZ_Africa_Ceuta PSTR("CET-1CEST,M3.5.0,M10.5.0/3") #define TZ_Africa_Conakry PSTR("GMT0") @@ -37,7 +31,7 @@ #define TZ_Africa_Gaborone PSTR("CAT-2") #define TZ_Africa_Harare PSTR("CAT-2") #define TZ_Africa_Johannesburg PSTR("SAST-2") -#define TZ_Africa_Juba PSTR("EAT-3") +#define TZ_Africa_Juba PSTR("CAT-2") #define TZ_Africa_Kampala PSTR("EAT-3") #define TZ_Africa_Khartoum PSTR("CAT-2") #define TZ_Africa_Kigali PSTR("CAT-2") @@ -61,6 +55,7 @@ #define TZ_Africa_Ouagadougou PSTR("GMT0") #define TZ_Africa_PortomNovo PSTR("WAT-1") #define TZ_Africa_Sao_Tome PSTR("GMT0") +#define TZ_Africa_Timbuktu PSTR("GMT0") #define TZ_Africa_Tripoli PSTR("EET-2") #define TZ_Africa_Tunis PSTR("CET-1") #define TZ_Africa_Windhoek PSTR("CAT-2") @@ -71,6 +66,7 @@ #define TZ_America_Araguaina PSTR("<-03>3") #define TZ_America_Argentina_Buenos_Aires PSTR("<-03>3") #define TZ_America_Argentina_Catamarca PSTR("<-03>3") +#define TZ_America_Argentina_ComodRivadavia PSTR("<-03>3") #define TZ_America_Argentina_Cordoba PSTR("<-03>3") #define TZ_America_Argentina_Jujuy PSTR("<-03>3") #define TZ_America_Argentina_La_Rioja PSTR("<-03>3") @@ -84,8 +80,9 @@ #define TZ_America_Aruba PSTR("AST4") #define TZ_America_Asuncion PSTR("<-04>4<-03>,M10.1.0/0,M3.4.0/0") #define TZ_America_Atikokan PSTR("EST5") +#define TZ_America_Atka PSTR("HST10HDT,M3.2.0,M11.1.0") #define TZ_America_Bahia PSTR("<-03>3") -#define TZ_America_Bahia_Banderas PSTR("CST6CDT,M4.1.0,M10.5.0") +#define TZ_America_Bahia_Banderas PSTR("CST6") #define TZ_America_Barbados PSTR("AST4") #define TZ_America_Belem PSTR("<-03>3") #define TZ_America_Belize PSTR("CST6") @@ -93,14 +90,19 @@ #define TZ_America_Boa_Vista PSTR("<-04>4") #define TZ_America_Bogota PSTR("<-05>5") #define TZ_America_Boise PSTR("MST7MDT,M3.2.0,M11.1.0") +#define TZ_America_Buenos_Aires PSTR("<-03>3") #define TZ_America_Cambridge_Bay PSTR("MST7MDT,M3.2.0,M11.1.0") #define TZ_America_Campo_Grande PSTR("<-04>4") #define TZ_America_Cancun PSTR("EST5") #define TZ_America_Caracas PSTR("<-04>4") +#define TZ_America_Catamarca PSTR("<-03>3") #define TZ_America_Cayenne PSTR("<-03>3") #define TZ_America_Cayman PSTR("EST5") #define TZ_America_Chicago PSTR("CST6CDT,M3.2.0,M11.1.0") -#define TZ_America_Chihuahua PSTR("MST7MDT,M4.1.0,M10.5.0") +#define TZ_America_Chihuahua PSTR("CST6") +#define TZ_America_Ciudad_Juarez PSTR("MST7MDT,M3.2.0,M11.1.0") +#define TZ_America_Coral_Harbour PSTR("EST5") +#define TZ_America_Cordoba PSTR("<-03>3") #define TZ_America_Costa_Rica PSTR("CST6") #define TZ_America_Creston PSTR("MST7") #define TZ_America_Cuiaba PSTR("<-04>4") @@ -114,10 +116,12 @@ #define TZ_America_Edmonton PSTR("MST7MDT,M3.2.0,M11.1.0") #define TZ_America_Eirunepe PSTR("<-05>5") #define TZ_America_El_Salvador PSTR("CST6") -#define TZ_America_Fortaleza PSTR("<-03>3") +#define TZ_America_Ensenada PSTR("PST8PDT,M3.2.0,M11.1.0") #define TZ_America_Fort_Nelson PSTR("MST7") +#define TZ_America_Fort_Wayne PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_America_Fortaleza PSTR("<-03>3") #define TZ_America_Glace_Bay PSTR("AST4ADT,M3.2.0,M11.1.0") -#define TZ_America_Godthab PSTR("<-03>3<-02>,M3.5.0/-2,M10.5.0/-1") +#define TZ_America_Godthab PSTR("<-02>2<-01>,M3.5.0/-1,M10.5.0/0") #define TZ_America_Goose_Bay PSTR("AST4ADT,M3.2.0,M11.1.0") #define TZ_America_Grand_Turk PSTR("EST5EDT,M3.2.0,M11.1.0") #define TZ_America_Grenada PSTR("AST4") @@ -136,16 +140,20 @@ #define TZ_America_Indiana_Vevay PSTR("EST5EDT,M3.2.0,M11.1.0") #define TZ_America_Indiana_Vincennes PSTR("EST5EDT,M3.2.0,M11.1.0") #define TZ_America_Indiana_Winamac PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_America_Indianapolis PSTR("EST5EDT,M3.2.0,M11.1.0") #define TZ_America_Inuvik PSTR("MST7MDT,M3.2.0,M11.1.0") #define TZ_America_Iqaluit PSTR("EST5EDT,M3.2.0,M11.1.0") #define TZ_America_Jamaica PSTR("EST5") +#define TZ_America_Jujuy PSTR("<-03>3") #define TZ_America_Juneau PSTR("AKST9AKDT,M3.2.0,M11.1.0") #define TZ_America_Kentucky_Louisville PSTR("EST5EDT,M3.2.0,M11.1.0") #define TZ_America_Kentucky_Monticello PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_America_Knox_IN PSTR("CST6CDT,M3.2.0,M11.1.0") #define TZ_America_Kralendijk PSTR("AST4") #define TZ_America_La_Paz PSTR("<-04>4") #define TZ_America_Lima PSTR("<-05>5") #define TZ_America_Los_Angeles PSTR("PST8PDT,M3.2.0,M11.1.0") +#define TZ_America_Louisville PSTR("EST5EDT,M3.2.0,M11.1.0") #define TZ_America_Lower_Princes PSTR("AST4") #define TZ_America_Maceio PSTR("<-03>3") #define TZ_America_Managua PSTR("CST6") @@ -153,14 +161,15 @@ #define TZ_America_Marigot PSTR("AST4") #define TZ_America_Martinique PSTR("AST4") #define TZ_America_Matamoros PSTR("CST6CDT,M3.2.0,M11.1.0") -#define TZ_America_Mazatlan PSTR("MST7MDT,M4.1.0,M10.5.0") +#define TZ_America_Mazatlan PSTR("MST7") +#define TZ_America_Mendoza PSTR("<-03>3") #define TZ_America_Menominee PSTR("CST6CDT,M3.2.0,M11.1.0") -#define TZ_America_Merida PSTR("CST6CDT,M4.1.0,M10.5.0") +#define TZ_America_Merida PSTR("CST6") #define TZ_America_Metlakatla PSTR("AKST9AKDT,M3.2.0,M11.1.0") -#define TZ_America_Mexico_City PSTR("CST6CDT,M4.1.0,M10.5.0") +#define TZ_America_Mexico_City PSTR("CST6") #define TZ_America_Miquelon PSTR("<-03>3<-02>,M3.2.0,M11.1.0") #define TZ_America_Moncton PSTR("AST4ADT,M3.2.0,M11.1.0") -#define TZ_America_Monterrey PSTR("CST6CDT,M4.1.0,M10.5.0") +#define TZ_America_Monterrey PSTR("CST6") #define TZ_America_Montevideo PSTR("<-03>3") #define TZ_America_Montreal PSTR("EST5EDT,M3.2.0,M11.1.0") #define TZ_America_Montserrat PSTR("AST4") @@ -172,14 +181,15 @@ #define TZ_America_North_Dakota_Beulah PSTR("CST6CDT,M3.2.0,M11.1.0") #define TZ_America_North_Dakota_Center PSTR("CST6CDT,M3.2.0,M11.1.0") #define TZ_America_North_Dakota_New_Salem PSTR("CST6CDT,M3.2.0,M11.1.0") -#define TZ_America_Nuuk PSTR("<-03>3<-02>,M3.5.0/-2,M10.5.0/-1") -#define TZ_America_Ojinaga PSTR("MST7MDT,M3.2.0,M11.1.0") +#define TZ_America_Nuuk PSTR("<-02>2<-01>,M3.5.0/-1,M10.5.0/0") +#define TZ_America_Ojinaga PSTR("CST6CDT,M3.2.0,M11.1.0") #define TZ_America_Panama PSTR("EST5") #define TZ_America_Pangnirtung PSTR("EST5EDT,M3.2.0,M11.1.0") #define TZ_America_Paramaribo PSTR("<-03>3") #define TZ_America_Phoenix PSTR("MST7") #define TZ_America_PortmaumPrince PSTR("EST5EDT,M3.2.0,M11.1.0") #define TZ_America_Port_of_Spain PSTR("AST4") +#define TZ_America_Porto_Acre PSTR("<-05>5") #define TZ_America_Porto_Velho PSTR("<-04>4") #define TZ_America_Puerto_Rico PSTR("AST4") #define TZ_America_Punta_Arenas PSTR("<-03>3") @@ -189,11 +199,14 @@ #define TZ_America_Regina PSTR("CST6") #define TZ_America_Resolute PSTR("CST6CDT,M3.2.0,M11.1.0") #define TZ_America_Rio_Branco PSTR("<-05>5") +#define TZ_America_Rosario PSTR("<-03>3") +#define TZ_America_Santa_Isabel PSTR("PST8PDT,M3.2.0,M11.1.0") #define TZ_America_Santarem PSTR("<-03>3") #define TZ_America_Santiago PSTR("<-04>4<-03>,M9.1.6/24,M4.1.6/24") #define TZ_America_Santo_Domingo PSTR("AST4") #define TZ_America_Sao_Paulo PSTR("<-03>3") -#define TZ_America_Scoresbysund PSTR("<-01>1<+00>,M3.5.0/0,M10.5.0/1") +#define TZ_America_Scoresbysund PSTR("<-02>2<-01>,M3.5.0/-1,M10.5.0/0") +#define TZ_America_Shiprock PSTR("MST7MDT,M3.2.0,M11.1.0") #define TZ_America_Sitka PSTR("AKST9AKDT,M3.2.0,M11.1.0") #define TZ_America_St_Barthelemy PSTR("AST4") #define TZ_America_St_Johns PSTR("NST3:30NDT,M3.2.0,M11.1.0") @@ -209,11 +222,12 @@ #define TZ_America_Toronto PSTR("EST5EDT,M3.2.0,M11.1.0") #define TZ_America_Tortola PSTR("AST4") #define TZ_America_Vancouver PSTR("PST8PDT,M3.2.0,M11.1.0") +#define TZ_America_Virgin PSTR("AST4") #define TZ_America_Whitehorse PSTR("MST7") #define TZ_America_Winnipeg PSTR("CST6CDT,M3.2.0,M11.1.0") #define TZ_America_Yakutat PSTR("AKST9AKDT,M3.2.0,M11.1.0") #define TZ_America_Yellowknife PSTR("MST7MDT,M3.2.0,M11.1.0") -#define TZ_Antarctica_Casey PSTR("<+11>-11") +#define TZ_Antarctica_Casey PSTR("<+08>-8") #define TZ_Antarctica_Davis PSTR("<+07>-7") #define TZ_Antarctica_DumontDUrville PSTR("<+10>-10") #define TZ_Antarctica_Macquarie PSTR("AEST-10AEDT,M10.1.0,M4.1.0/3") @@ -221,17 +235,19 @@ #define TZ_Antarctica_McMurdo PSTR("NZST-12NZDT,M9.5.0,M4.1.0/3") #define TZ_Antarctica_Palmer PSTR("<-03>3") #define TZ_Antarctica_Rothera PSTR("<-03>3") +#define TZ_Antarctica_South_Pole PSTR("NZST-12NZDT,M9.5.0,M4.1.0/3") #define TZ_Antarctica_Syowa PSTR("<+03>-3") #define TZ_Antarctica_Troll PSTR("<+00>0<+02>-2,M3.5.0/1,M10.5.0/3") -#define TZ_Antarctica_Vostok PSTR("<+06>-6") +#define TZ_Antarctica_Vostok PSTR("<+05>-5") #define TZ_Arctic_Longyearbyen PSTR("CET-1CEST,M3.5.0,M10.5.0/3") #define TZ_Asia_Aden PSTR("<+03>-3") #define TZ_Asia_Almaty PSTR("<+06>-6") -#define TZ_Asia_Amman PSTR("EET-2EEST,M3.5.4/24,M10.5.5/1") +#define TZ_Asia_Amman PSTR("<+03>-3") #define TZ_Asia_Anadyr PSTR("<+12>-12") #define TZ_Asia_Aqtau PSTR("<+05>-5") #define TZ_Asia_Aqtobe PSTR("<+05>-5") #define TZ_Asia_Ashgabat PSTR("<+05>-5") +#define TZ_Asia_Ashkhabad PSTR("<+05>-5") #define TZ_Asia_Atyrau PSTR("<+05>-5") #define TZ_Asia_Baghdad PSTR("<+03>-3") #define TZ_Asia_Bahrain PSTR("<+03>-3") @@ -241,34 +257,43 @@ #define TZ_Asia_Beirut PSTR("EET-2EEST,M3.5.0/0,M10.5.0/0") #define TZ_Asia_Bishkek PSTR("<+06>-6") #define TZ_Asia_Brunei PSTR("<+08>-8") +#define TZ_Asia_Calcutta PSTR("IST-5:30") #define TZ_Asia_Chita PSTR("<+09>-9") #define TZ_Asia_Choibalsan PSTR("<+08>-8") +#define TZ_Asia_Chongqing PSTR("CST-8") +#define TZ_Asia_Chungking PSTR("CST-8") #define TZ_Asia_Colombo PSTR("<+0530>-5:30") -#define TZ_Asia_Damascus PSTR("EET-2EEST,M3.5.5/0,M10.5.5/0") +#define TZ_Asia_Dacca PSTR("<+06>-6") +#define TZ_Asia_Damascus PSTR("<+03>-3") #define TZ_Asia_Dhaka PSTR("<+06>-6") #define TZ_Asia_Dili PSTR("<+09>-9") #define TZ_Asia_Dubai PSTR("<+04>-4") #define TZ_Asia_Dushanbe PSTR("<+05>-5") #define TZ_Asia_Famagusta PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") -#define TZ_Asia_Gaza PSTR("EET-2EEST,M3.4.4/48,M10.4.4/49") -#define TZ_Asia_Hebron PSTR("EET-2EEST,M3.4.4/48,M10.4.4/49") +#define TZ_Asia_Gaza PSTR("EET-2EEST,M3.4.4/50,M10.4.4/50") +#define TZ_Asia_Harbin PSTR("CST-8") +#define TZ_Asia_Hebron PSTR("EET-2EEST,M3.4.4/50,M10.4.4/50") #define TZ_Asia_Ho_Chi_Minh PSTR("<+07>-7") #define TZ_Asia_Hong_Kong PSTR("HKT-8") #define TZ_Asia_Hovd PSTR("<+07>-7") #define TZ_Asia_Irkutsk PSTR("<+08>-8") +#define TZ_Asia_Istanbul PSTR("<+03>-3") #define TZ_Asia_Jakarta PSTR("WIB-7") #define TZ_Asia_Jayapura PSTR("WIT-9") #define TZ_Asia_Jerusalem PSTR("IST-2IDT,M3.4.4/26,M10.5.0") #define TZ_Asia_Kabul PSTR("<+0430>-4:30") #define TZ_Asia_Kamchatka PSTR("<+12>-12") #define TZ_Asia_Karachi PSTR("PKT-5") +#define TZ_Asia_Kashgar PSTR("<+06>-6") #define TZ_Asia_Kathmandu PSTR("<+0545>-5:45") +#define TZ_Asia_Katmandu PSTR("<+0545>-5:45") #define TZ_Asia_Khandyga PSTR("<+09>-9") #define TZ_Asia_Kolkata PSTR("IST-5:30") #define TZ_Asia_Krasnoyarsk PSTR("<+07>-7") #define TZ_Asia_Kuala_Lumpur PSTR("<+08>-8") #define TZ_Asia_Kuching PSTR("<+08>-8") #define TZ_Asia_Kuwait PSTR("<+03>-3") +#define TZ_Asia_Macao PSTR("CST-8") #define TZ_Asia_Macau PSTR("CST-8") #define TZ_Asia_Magadan PSTR("<+11>-11") #define TZ_Asia_Makassar PSTR("WITA-8") @@ -283,8 +308,11 @@ #define TZ_Asia_Pontianak PSTR("WIB-7") #define TZ_Asia_Pyongyang PSTR("KST-9") #define TZ_Asia_Qatar PSTR("<+03>-3") +#define TZ_Asia_Qostanay PSTR("<+06>-6") #define TZ_Asia_Qyzylorda PSTR("<+05>-5") +#define TZ_Asia_Rangoon PSTR("<+0630>-6:30") #define TZ_Asia_Riyadh PSTR("<+03>-3") +#define TZ_Asia_Saigon PSTR("<+07>-7") #define TZ_Asia_Sakhalin PSTR("<+11>-11") #define TZ_Asia_Samarkand PSTR("<+05>-5") #define TZ_Asia_Seoul PSTR("KST-9") @@ -294,11 +322,15 @@ #define TZ_Asia_Taipei PSTR("CST-8") #define TZ_Asia_Tashkent PSTR("<+05>-5") #define TZ_Asia_Tbilisi PSTR("<+04>-4") -#define TZ_Asia_Tehran PSTR("<+0330>-3:30<+0430>,J79/24,J263/24") +#define TZ_Asia_Tehran PSTR("<+0330>-3:30") +#define TZ_Asia_Tel_Aviv PSTR("IST-2IDT,M3.4.4/26,M10.5.0") +#define TZ_Asia_Thimbu PSTR("<+06>-6") #define TZ_Asia_Thimphu PSTR("<+06>-6") #define TZ_Asia_Tokyo PSTR("JST-9") #define TZ_Asia_Tomsk PSTR("<+07>-7") +#define TZ_Asia_Ujung_Pandang PSTR("WITA-8") #define TZ_Asia_Ulaanbaatar PSTR("<+08>-8") +#define TZ_Asia_Ulan_Bator PSTR("<+08>-8") #define TZ_Asia_Urumqi PSTR("<+06>-6") #define TZ_Asia_UstmNera PSTR("<+10>-10") #define TZ_Asia_Vientiane PSTR("<+07>-7") @@ -311,28 +343,99 @@ #define TZ_Atlantic_Bermuda PSTR("AST4ADT,M3.2.0,M11.1.0") #define TZ_Atlantic_Canary PSTR("WET0WEST,M3.5.0/1,M10.5.0") #define TZ_Atlantic_Cape_Verde PSTR("<-01>1") +#define TZ_Atlantic_Faeroe PSTR("WET0WEST,M3.5.0/1,M10.5.0") #define TZ_Atlantic_Faroe PSTR("WET0WEST,M3.5.0/1,M10.5.0") +#define TZ_Atlantic_Jan_Mayen PSTR("CET-1CEST,M3.5.0,M10.5.0/3") #define TZ_Atlantic_Madeira PSTR("WET0WEST,M3.5.0/1,M10.5.0") #define TZ_Atlantic_Reykjavik PSTR("GMT0") #define TZ_Atlantic_South_Georgia PSTR("<-02>2") -#define TZ_Atlantic_Stanley PSTR("<-03>3") #define TZ_Atlantic_St_Helena PSTR("GMT0") +#define TZ_Atlantic_Stanley PSTR("<-03>3") +#define TZ_Australia_ACT PSTR("AEST-10AEDT,M10.1.0,M4.1.0/3") #define TZ_Australia_Adelaide PSTR("ACST-9:30ACDT,M10.1.0,M4.1.0/3") #define TZ_Australia_Brisbane PSTR("AEST-10") #define TZ_Australia_Broken_Hill PSTR("ACST-9:30ACDT,M10.1.0,M4.1.0/3") +#define TZ_Australia_Canberra PSTR("AEST-10AEDT,M10.1.0,M4.1.0/3") #define TZ_Australia_Currie PSTR("AEST-10AEDT,M10.1.0,M4.1.0/3") #define TZ_Australia_Darwin PSTR("ACST-9:30") #define TZ_Australia_Eucla PSTR("<+0845>-8:45") #define TZ_Australia_Hobart PSTR("AEST-10AEDT,M10.1.0,M4.1.0/3") +#define TZ_Australia_LHI PSTR("<+1030>-10:30<+11>-11,M10.1.0,M4.1.0") #define TZ_Australia_Lindeman PSTR("AEST-10") #define TZ_Australia_Lord_Howe PSTR("<+1030>-10:30<+11>-11,M10.1.0,M4.1.0") #define TZ_Australia_Melbourne PSTR("AEST-10AEDT,M10.1.0,M4.1.0/3") +#define TZ_Australia_NSW PSTR("AEST-10AEDT,M10.1.0,M4.1.0/3") +#define TZ_Australia_North PSTR("ACST-9:30") #define TZ_Australia_Perth PSTR("AWST-8") +#define TZ_Australia_Queensland PSTR("AEST-10") +#define TZ_Australia_South PSTR("ACST-9:30ACDT,M10.1.0,M4.1.0/3") #define TZ_Australia_Sydney PSTR("AEST-10AEDT,M10.1.0,M4.1.0/3") +#define TZ_Australia_Tasmania PSTR("AEST-10AEDT,M10.1.0,M4.1.0/3") +#define TZ_Australia_Victoria PSTR("AEST-10AEDT,M10.1.0,M4.1.0/3") +#define TZ_Australia_West PSTR("AWST-8") +#define TZ_Australia_Yancowinna PSTR("ACST-9:30ACDT,M10.1.0,M4.1.0/3") +#define TZ_Brazil_Acre PSTR("<-05>5") +#define TZ_Brazil_DeNoronha PSTR("<-02>2") +#define TZ_Brazil_East PSTR("<-03>3") +#define TZ_Brazil_West PSTR("<-04>4") +#define TZ_CET PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_CST6CDT PSTR("CST6CDT,M3.2.0,M11.1.0") +#define TZ_Canada_Atlantic PSTR("AST4ADT,M3.2.0,M11.1.0") +#define TZ_Canada_Central PSTR("CST6CDT,M3.2.0,M11.1.0") +#define TZ_Canada_Eastern PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_Canada_Mountain PSTR("MST7MDT,M3.2.0,M11.1.0") +#define TZ_Canada_Newfoundland PSTR("NST3:30NDT,M3.2.0,M11.1.0") +#define TZ_Canada_Pacific PSTR("PST8PDT,M3.2.0,M11.1.0") +#define TZ_Canada_Saskatchewan PSTR("CST6") +#define TZ_Canada_Yukon PSTR("MST7") +#define TZ_Chile_Continental PSTR("<-04>4<-03>,M9.1.6/24,M4.1.6/24") +#define TZ_Chile_EasterIsland PSTR("<-06>6<-05>,M9.1.6/22,M4.1.6/22") +#define TZ_Cuba PSTR("CST5CDT,M3.2.0/0,M11.1.0/1") +#define TZ_EET PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") +#define TZ_EST PSTR("EST5") +#define TZ_EST5EDT PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_Egypt PSTR("EET-2EEST,M4.5.5/0,M10.5.4/24") +#define TZ_Eire PSTR("IST-1GMT0,M10.5.0,M3.5.0/1") +#define TZ_Etc_GMT PSTR("GMT0") +#define TZ_Etc_GMTp0 PSTR("GMT0") +#define TZ_Etc_GMTp1 PSTR("<-01>1") +#define TZ_Etc_GMTp10 PSTR("<-10>10") +#define TZ_Etc_GMTp11 PSTR("<-11>11") +#define TZ_Etc_GMTp12 PSTR("<-12>12") +#define TZ_Etc_GMTp2 PSTR("<-02>2") +#define TZ_Etc_GMTp3 PSTR("<-03>3") +#define TZ_Etc_GMTp4 PSTR("<-04>4") +#define TZ_Etc_GMTp5 PSTR("<-05>5") +#define TZ_Etc_GMTp6 PSTR("<-06>6") +#define TZ_Etc_GMTp7 PSTR("<-07>7") +#define TZ_Etc_GMTp8 PSTR("<-08>8") +#define TZ_Etc_GMTp9 PSTR("<-09>9") +#define TZ_Etc_GMTm0 PSTR("GMT0") +#define TZ_Etc_GMTm1 PSTR("<+01>-1") +#define TZ_Etc_GMTm10 PSTR("<+10>-10") +#define TZ_Etc_GMTm11 PSTR("<+11>-11") +#define TZ_Etc_GMTm12 PSTR("<+12>-12") +#define TZ_Etc_GMTm13 PSTR("<+13>-13") +#define TZ_Etc_GMTm14 PSTR("<+14>-14") +#define TZ_Etc_GMTm2 PSTR("<+02>-2") +#define TZ_Etc_GMTm3 PSTR("<+03>-3") +#define TZ_Etc_GMTm4 PSTR("<+04>-4") +#define TZ_Etc_GMTm5 PSTR("<+05>-5") +#define TZ_Etc_GMTm6 PSTR("<+06>-6") +#define TZ_Etc_GMTm7 PSTR("<+07>-7") +#define TZ_Etc_GMTm8 PSTR("<+08>-8") +#define TZ_Etc_GMTm9 PSTR("<+09>-9") +#define TZ_Etc_GMT0 PSTR("GMT0") +#define TZ_Etc_Greenwich PSTR("GMT0") +#define TZ_Etc_UCT PSTR("UTC0") +#define TZ_Etc_UTC PSTR("UTC0") +#define TZ_Etc_Universal PSTR("UTC0") +#define TZ_Etc_Zulu PSTR("UTC0") #define TZ_Europe_Amsterdam PSTR("CET-1CEST,M3.5.0,M10.5.0/3") #define TZ_Europe_Andorra PSTR("CET-1CEST,M3.5.0,M10.5.0/3") #define TZ_Europe_Astrakhan PSTR("<+04>-4") #define TZ_Europe_Athens PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") +#define TZ_Europe_Belfast PSTR("GMT0BST,M3.5.0/1,M10.5.0") #define TZ_Europe_Belgrade PSTR("CET-1CEST,M3.5.0,M10.5.0/3") #define TZ_Europe_Berlin PSTR("CET-1CEST,M3.5.0,M10.5.0/3") #define TZ_Europe_Bratislava PSTR("CET-1CEST,M3.5.0,M10.5.0/3") @@ -351,7 +454,8 @@ #define TZ_Europe_Jersey PSTR("GMT0BST,M3.5.0/1,M10.5.0") #define TZ_Europe_Kaliningrad PSTR("EET-2") #define TZ_Europe_Kiev PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") -#define TZ_Europe_Kirov PSTR("<+03>-3") +#define TZ_Europe_Kirov PSTR("MSK-3") +#define TZ_Europe_Kyiv PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") #define TZ_Europe_Lisbon PSTR("WET0WEST,M3.5.0/1,M10.5.0") #define TZ_Europe_Ljubljana PSTR("CET-1CEST,M3.5.0,M10.5.0/3") #define TZ_Europe_London PSTR("GMT0BST,M3.5.0/1,M10.5.0") @@ -362,6 +466,7 @@ #define TZ_Europe_Minsk PSTR("<+03>-3") #define TZ_Europe_Monaco PSTR("CET-1CEST,M3.5.0,M10.5.0/3") #define TZ_Europe_Moscow PSTR("MSK-3") +#define TZ_Europe_Nicosia PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") #define TZ_Europe_Oslo PSTR("CET-1CEST,M3.5.0,M10.5.0/3") #define TZ_Europe_Paris PSTR("CET-1CEST,M3.5.0,M10.5.0/3") #define TZ_Europe_Podgorica PSTR("CET-1CEST,M3.5.0,M10.5.0/3") @@ -378,17 +483,31 @@ #define TZ_Europe_Stockholm PSTR("CET-1CEST,M3.5.0,M10.5.0/3") #define TZ_Europe_Tallinn PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") #define TZ_Europe_Tirane PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Tiraspol PSTR("EET-2EEST,M3.5.0,M10.5.0/3") #define TZ_Europe_Ulyanovsk PSTR("<+04>-4") #define TZ_Europe_Uzhgorod PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") +#define TZ_Europe_Uzhhorod PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") #define TZ_Europe_Vaduz PSTR("CET-1CEST,M3.5.0,M10.5.0/3") #define TZ_Europe_Vatican PSTR("CET-1CEST,M3.5.0,M10.5.0/3") #define TZ_Europe_Vienna PSTR("CET-1CEST,M3.5.0,M10.5.0/3") #define TZ_Europe_Vilnius PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") -#define TZ_Europe_Volgograd PSTR("<+03>-3") +#define TZ_Europe_Volgograd PSTR("MSK-3") #define TZ_Europe_Warsaw PSTR("CET-1CEST,M3.5.0,M10.5.0/3") #define TZ_Europe_Zagreb PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Europe_Zaporizhzhia PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") #define TZ_Europe_Zaporozhye PSTR("EET-2EEST,M3.5.0/3,M10.5.0/4") #define TZ_Europe_Zurich PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Factory PSTR("<-00>0") +#define TZ_GB PSTR("GMT0BST,M3.5.0/1,M10.5.0") +#define TZ_GBmEire PSTR("GMT0BST,M3.5.0/1,M10.5.0") +#define TZ_GMT PSTR("GMT0") +#define TZ_GMTp0 PSTR("GMT0") +#define TZ_GMTm0 PSTR("GMT0") +#define TZ_GMT0 PSTR("GMT0") +#define TZ_Greenwich PSTR("GMT0") +#define TZ_HST PSTR("HST10") +#define TZ_Hongkong PSTR("HKT-8") +#define TZ_Iceland PSTR("GMT0") #define TZ_Indian_Antananarivo PSTR("EAT-3") #define TZ_Indian_Chagos PSTR("<+06>-6") #define TZ_Indian_Christmas PSTR("<+07>-7") @@ -400,7 +519,24 @@ #define TZ_Indian_Mauritius PSTR("<+04>-4") #define TZ_Indian_Mayotte PSTR("EAT-3") #define TZ_Indian_Reunion PSTR("<+04>-4") -#define TZ_Pacific_Apia PSTR("<+13>-13<+14>,M9.5.0/3,M4.1.0/4") +#define TZ_Iran PSTR("<+0330>-3:30") +#define TZ_Israel PSTR("IST-2IDT,M3.4.4/26,M10.5.0") +#define TZ_Jamaica PSTR("EST5") +#define TZ_Japan PSTR("JST-9") +#define TZ_Kwajalein PSTR("<+12>-12") +#define TZ_Libya PSTR("EET-2") +#define TZ_MET PSTR("MET-1MEST,M3.5.0,M10.5.0/3") +#define TZ_MST PSTR("MST7") +#define TZ_MST7MDT PSTR("MST7MDT,M3.2.0,M11.1.0") +#define TZ_Mexico_BajaNorte PSTR("PST8PDT,M3.2.0,M11.1.0") +#define TZ_Mexico_BajaSur PSTR("MST7") +#define TZ_Mexico_General PSTR("CST6") +#define TZ_NZ PSTR("NZST-12NZDT,M9.5.0,M4.1.0/3") +#define TZ_NZmCHAT PSTR("<+1245>-12:45<+1345>,M9.5.0/2:45,M4.1.0/3:45") +#define TZ_Navajo PSTR("MST7MDT,M3.2.0,M11.1.0") +#define TZ_PRC PSTR("CST-8") +#define TZ_PST8PDT PSTR("PST8PDT,M3.2.0,M11.1.0") +#define TZ_Pacific_Apia PSTR("<+13>-13") #define TZ_Pacific_Auckland PSTR("NZST-12NZDT,M9.5.0,M4.1.0/3") #define TZ_Pacific_Bougainville PSTR("<+11>-11") #define TZ_Pacific_Chatham PSTR("<+1245>-12:45<+1345>,M9.5.0/2:45,M4.1.0/3:45") @@ -409,13 +545,15 @@ #define TZ_Pacific_Efate PSTR("<+11>-11") #define TZ_Pacific_Enderbury PSTR("<+13>-13") #define TZ_Pacific_Fakaofo PSTR("<+13>-13") -#define TZ_Pacific_Fiji PSTR("<+12>-12<+13>,M11.2.0,M1.2.3/99") +#define TZ_Pacific_Fiji PSTR("<+12>-12") #define TZ_Pacific_Funafuti PSTR("<+12>-12") #define TZ_Pacific_Galapagos PSTR("<-06>6") #define TZ_Pacific_Gambier PSTR("<-09>9") #define TZ_Pacific_Guadalcanal PSTR("<+11>-11") #define TZ_Pacific_Guam PSTR("ChST-10") #define TZ_Pacific_Honolulu PSTR("HST10") +#define TZ_Pacific_Johnston PSTR("HST10") +#define TZ_Pacific_Kanton PSTR("<+13>-13") #define TZ_Pacific_Kiritimati PSTR("<+14>-14") #define TZ_Pacific_Kosrae PSTR("<+11>-11") #define TZ_Pacific_Kwajalein PSTR("<+12>-12") @@ -430,48 +568,39 @@ #define TZ_Pacific_Palau PSTR("<+09>-9") #define TZ_Pacific_Pitcairn PSTR("<-08>8") #define TZ_Pacific_Pohnpei PSTR("<+11>-11") +#define TZ_Pacific_Ponape PSTR("<+11>-11") #define TZ_Pacific_Port_Moresby PSTR("<+10>-10") #define TZ_Pacific_Rarotonga PSTR("<-10>10") #define TZ_Pacific_Saipan PSTR("ChST-10") +#define TZ_Pacific_Samoa PSTR("SST11") #define TZ_Pacific_Tahiti PSTR("<-10>10") #define TZ_Pacific_Tarawa PSTR("<+12>-12") #define TZ_Pacific_Tongatapu PSTR("<+13>-13") +#define TZ_Pacific_Truk PSTR("<+10>-10") #define TZ_Pacific_Wake PSTR("<+12>-12") #define TZ_Pacific_Wallis PSTR("<+12>-12") -#define TZ_Etc_GMT PSTR("GMT0") -#define TZ_Etc_GMTm0 PSTR("GMT0") -#define TZ_Etc_GMTm1 PSTR("<+01>-1") -#define TZ_Etc_GMTm2 PSTR("<+02>-2") -#define TZ_Etc_GMTm3 PSTR("<+03>-3") -#define TZ_Etc_GMTm4 PSTR("<+04>-4") -#define TZ_Etc_GMTm5 PSTR("<+05>-5") -#define TZ_Etc_GMTm6 PSTR("<+06>-6") -#define TZ_Etc_GMTm7 PSTR("<+07>-7") -#define TZ_Etc_GMTm8 PSTR("<+08>-8") -#define TZ_Etc_GMTm9 PSTR("<+09>-9") -#define TZ_Etc_GMTm10 PSTR("<+10>-10") -#define TZ_Etc_GMTm11 PSTR("<+11>-11") -#define TZ_Etc_GMTm12 PSTR("<+12>-12") -#define TZ_Etc_GMTm13 PSTR("<+13>-13") -#define TZ_Etc_GMTm14 PSTR("<+14>-14") -#define TZ_Etc_GMT0 PSTR("GMT0") -#define TZ_Etc_GMTp0 PSTR("GMT0") -#define TZ_Etc_GMTp1 PSTR("<-01>1") -#define TZ_Etc_GMTp2 PSTR("<-02>2") -#define TZ_Etc_GMTp3 PSTR("<-03>3") -#define TZ_Etc_GMTp4 PSTR("<-04>4") -#define TZ_Etc_GMTp5 PSTR("<-05>5") -#define TZ_Etc_GMTp6 PSTR("<-06>6") -#define TZ_Etc_GMTp7 PSTR("<-07>7") -#define TZ_Etc_GMTp8 PSTR("<-08>8") -#define TZ_Etc_GMTp9 PSTR("<-09>9") -#define TZ_Etc_GMTp10 PSTR("<-10>10") -#define TZ_Etc_GMTp11 PSTR("<-11>11") -#define TZ_Etc_GMTp12 PSTR("<-12>12") -#define TZ_Etc_UCT PSTR("UTC0") -#define TZ_Etc_UTC PSTR("UTC0") -#define TZ_Etc_Greenwich PSTR("GMT0") -#define TZ_Etc_Universal PSTR("UTC0") -#define TZ_Etc_Zulu PSTR("UTC0") - -#endif // TZDB_H +#define TZ_Pacific_Yap PSTR("<+10>-10") +#define TZ_Poland PSTR("CET-1CEST,M3.5.0,M10.5.0/3") +#define TZ_Portugal PSTR("WET0WEST,M3.5.0/1,M10.5.0") +#define TZ_ROC PSTR("CST-8") +#define TZ_ROK PSTR("KST-9") +#define TZ_Singapore PSTR("<+08>-8") +#define TZ_Turkey PSTR("<+03>-3") +#define TZ_UCT PSTR("UTC0") +#define TZ_US_Alaska PSTR("AKST9AKDT,M3.2.0,M11.1.0") +#define TZ_US_Aleutian PSTR("HST10HDT,M3.2.0,M11.1.0") +#define TZ_US_Arizona PSTR("MST7") +#define TZ_US_Central PSTR("CST6CDT,M3.2.0,M11.1.0") +#define TZ_US_EastmIndiana PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_US_Eastern PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_US_Hawaii PSTR("HST10") +#define TZ_US_IndianamStarke PSTR("CST6CDT,M3.2.0,M11.1.0") +#define TZ_US_Michigan PSTR("EST5EDT,M3.2.0,M11.1.0") +#define TZ_US_Mountain PSTR("MST7MDT,M3.2.0,M11.1.0") +#define TZ_US_Pacific PSTR("PST8PDT,M3.2.0,M11.1.0") +#define TZ_US_Samoa PSTR("SST11") +#define TZ_UTC PSTR("UTC0") +#define TZ_Universal PSTR("UTC0") +#define TZ_WmSU PSTR("MSK-3") +#define TZ_WET PSTR("WET0WEST,M3.5.0/1,M10.5.0") +#define TZ_Zulu PSTR("UTC0") diff --git a/cores/esp8266/Udp.h b/cores/esp8266/Udp.h index 6c8ee4b385..37f2fb922b 100644 --- a/cores/esp8266/Udp.h +++ b/cores/esp8266/Udp.h @@ -43,6 +43,7 @@ class UDP: public Stream { public: virtual ~UDP() {}; virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure virtual void stop() =0; // Finish with the UDP socket // Sending UDP packets diff --git a/cores/esp8266/Updater.cpp b/cores/esp8266/Updater.cpp index c194c1d23f..ef79a5cbf3 100644 --- a/cores/esp8266/Updater.cpp +++ b/cores/esp8266/Updater.cpp @@ -1,9 +1,12 @@ +#include #include "Updater.h" #include "eboot_command.h" #include #include #include "StackThunk.h" +#include + //#define DEBUG_UPDATER Serial #include @@ -41,21 +44,22 @@ UpdaterClass::~UpdaterClass() #endif } -UpdaterClass& UpdaterClass::onProgress(THandlerFunction_Progress fn) { - _progress_callback = fn; - return *this; -} - -void UpdaterClass::_reset() { - if (_buffer) +void UpdaterClass::_reset(bool callback) { + if (_buffer) { delete[] _buffer; - _buffer = 0; + } + + _buffer = nullptr; _bufferLen = 0; _startAddress = 0; _currentAddress = 0; _size = 0; _command = U_FLASH; + if (callback && _end_callback) { + _end_callback(); + } + if(_ledPin != -1) { digitalWrite(_ledPin, !_ledOn); // off } @@ -66,6 +70,7 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) { #ifdef DEBUG_UPDATER DEBUG_UPDATER.println(F("[begin] already running")); #endif + _setError(UPDATE_ERROR_RUNNING_ALREADY); return false; } @@ -82,7 +87,7 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) { _setError(UPDATE_ERROR_BOOTSTRAP); return false; } - + #ifdef DEBUG_UPDATER if (command == U_FS) { DEBUG_UPDATER.println(F("[begin] Update Filesystem.")); @@ -129,7 +134,7 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) { //make sure that the size of both sketches is less than the total space (updateEndAddress) if(updateStartAddress < currentSketchSize) { - _setError(UPDATE_ERROR_SPACE); + _setError(UPDATE_ERROR_SPACE); return false; } } @@ -158,6 +163,7 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) { #ifdef DEBUG_UPDATER DEBUG_UPDATER.println(F("[begin] Unknown update command.")); #endif + _setError(UPDATE_ERROR_UNKNOWN_COMMAND); return false; } @@ -170,7 +176,13 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) { } else { _bufferSize = 256; } - _buffer = new uint8_t[_bufferSize]; + _buffer = new (std::nothrow) uint8_t[_bufferSize]; + if (!_buffer) { + _setError(UPDATE_ERROR_OOM); + _reset(false); + return false; + } + _command = command; #ifdef DEBUG_UPDATER @@ -182,6 +194,11 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) { if (!_verify) { _md5.begin(); } + + if (_start_callback) { + _start_callback(); + } + return true; } @@ -224,71 +241,87 @@ bool UpdaterClass::end(bool evenIfRemaining){ } if (_verify) { + // If expectedSigLen is non-zero, we expect the last four bytes of the buffer to + // contain a matching length field, preceded by the bytes of the signature itself. + // But if expectedSigLen is zero, we expect neither a signature nor a length field; + static constexpr uint32_t SigSize = sizeof(uint32_t); const uint32_t expectedSigLen = _verify->length(); - // If expectedSigLen is non-zero, we expect the last four bytes of the buffer to - // contain a matching length field, preceded by the bytes of the signature itself. - // But if expectedSigLen is zero, we expect neither a signature nor a length field; + const uint32_t sigLenAddr = _startAddress + _size - SigSize; uint32_t sigLen = 0; +#ifdef DEBUG_UPDATER + DEBUG_UPDATER.printf_P(PSTR("[Updater] expected sigLen: %u\n"), expectedSigLen); +#endif if (expectedSigLen > 0) { - ESP.flashRead(_startAddress + _size - sizeof(uint32_t), &sigLen, sizeof(uint32_t)); - } + ESP.flashRead(sigLenAddr, &sigLen, SigSize); #ifdef DEBUG_UPDATER - DEBUG_UPDATER.printf_P(PSTR("[Updater] sigLen: %d\n"), sigLen); + DEBUG_UPDATER.printf_P(PSTR("[Updater] sigLen from flash: %u\n"), sigLen); #endif + } + if (sigLen != expectedSigLen) { _setError(UPDATE_ERROR_SIGN); _reset(); return false; } - int binSize = _size; + auto binSize = _size; if (expectedSigLen > 0) { - _size -= (sigLen + sizeof(uint32_t) /* The siglen word */); - } - _hash->begin(); + if (binSize < (sigLen + SigSize)) { + _setError(UPDATE_ERROR_SIGN); + _reset(); + return false; + } + binSize -= (sigLen + SigSize); #ifdef DEBUG_UPDATER - DEBUG_UPDATER.printf_P(PSTR("[Updater] Adjusted binsize: %d\n"), binSize); + DEBUG_UPDATER.printf_P(PSTR("[Updater] Adjusted size (without the signature and sigLen): %zu\n"), binSize); #endif - // Calculate the MD5 and hash using proper size - uint8_t buff[128] __attribute__((aligned(4))); - for(int i = 0; i < binSize; i += sizeof(buff)) { - ESP.flashRead(_startAddress + i, (uint32_t *)buff, sizeof(buff)); - size_t read = std::min((int)sizeof(buff), binSize - i); - _hash->add(buff, read); + } + + // Calculate hash of the payload, 128 bytes at a time + alignas(alignof(uint32_t)) uint8_t buff[128]; + + _hash->begin(); + for (uint32_t offset = 0; offset < binSize; offset += sizeof(buff)) { + auto len = std::min(sizeof(buff), binSize - offset); + ESP.flashRead(_startAddress + offset, buff, len); + _hash->add(buff, len); } _hash->end(); + #ifdef DEBUG_UPDATER - unsigned char *ret = (unsigned char *)_hash->hash(); - DEBUG_UPDATER.printf_P(PSTR("[Updater] Computed Hash:")); - for (int i=0; i<_hash->len(); i++) DEBUG_UPDATER.printf(" %02x", ret[i]); - DEBUG_UPDATER.printf("\n"); + auto debugByteArray = [](const char *name, const unsigned char *hash, int len) { + DEBUG_UPDATER.printf_P("[Updater] %s:", name); + for (int i = 0; i < len; ++i) { + DEBUG_UPDATER.printf(" %02x", hash[i]); + } + DEBUG_UPDATER.printf("\n"); + }; + debugByteArray(PSTR("Computed Hash"), + reinterpret_cast(_hash->hash()), + _hash->len()); #endif - uint8_t *sig = nullptr; // Safe to free if we don't actually malloc + std::unique_ptr sig; if (expectedSigLen > 0) { - sig = (uint8_t*)malloc(sigLen); + const uint32_t sigAddr = _startAddress + binSize; + sig.reset(new (std::nothrow) uint8_t[sigLen]); if (!sig) { - _setError(UPDATE_ERROR_SIGN); + _setError(UPDATE_ERROR_OOM); _reset(); return false; } - ESP.flashRead(_startAddress + binSize, sig, sigLen); + ESP.flashRead(sigAddr, sig.get(), sigLen); #ifdef DEBUG_UPDATER - DEBUG_UPDATER.printf_P(PSTR("[Updater] Received Signature:")); - for (size_t i=0; iverify(_hash, (void *)sig, sigLen)) { - free(sig); + if (!_verify->verify(_hash, sig.get(), sigLen)) { _setError(UPDATE_ERROR_SIGN); _reset(); return false; } - free(sig); + _size = binSize; // Adjust size to remove signature, not part of bin payload #ifdef DEBUG_UPDATER @@ -301,7 +334,7 @@ bool UpdaterClass::end(bool evenIfRemaining){ return false; } #ifdef DEBUG_UPDATER - else DEBUG_UPDATER.printf_P(PSTR("MD5 Success: %s\n"), _target_md5.c_str()); + else DEBUG_UPDATER.printf_P(PSTR("[Updater] MD5 Success: %s\n"), _target_md5.c_str()); #endif } @@ -373,7 +406,7 @@ bool UpdaterClass::_writeBuffer(){ modifyFlashMode = true; } } - + if (eraseResult) { if(!_async) yield(); writeResult = ESP.flashWrite(_currentAddress, _buffer, _bufferLen); @@ -457,7 +490,7 @@ bool UpdaterClass::_verifyEnd() { uint8_t buf[4] __attribute__((aligned(4))); if(!ESP.flashRead(_startAddress, (uint32_t *) &buf[0], 4)) { _currentAddress = (_startAddress); - _setError(UPDATE_ERROR_READ); + _setError(UPDATE_ERROR_READ); return false; } @@ -469,7 +502,7 @@ bool UpdaterClass::_verifyEnd() { return true; } else if (buf[0] != 0xE9) { _currentAddress = (_startAddress); - _setError(UPDATE_ERROR_MAGIC_BYTE); + _setError(UPDATE_ERROR_MAGIC_BYTE); return false; } @@ -481,7 +514,7 @@ bool UpdaterClass::_verifyEnd() { // check if new bin fits to SPI flash if(bin_flash_size > ESP.getFlashChipRealSize()) { _currentAddress = (_startAddress); - _setError(UPDATE_ERROR_NEW_FLASH_CONFIG); + _setError(UPDATE_ERROR_NEW_FLASH_CONFIG); return false; } #endif @@ -555,45 +588,85 @@ size_t UpdaterClass::writeStream(Stream &data, uint16_t streamTimeout) { void UpdaterClass::_setError(int error){ _error = error; + if (_error_callback) { + _error_callback(error); + } #ifdef DEBUG_UPDATER printError(DEBUG_UPDATER); #endif _reset(); // Any error condition invalidates the entire update, so clear partial status } -void UpdaterClass::printError(Print &out){ - out.printf_P(PSTR("ERROR[%u]: "), _error); - if(_error == UPDATE_ERROR_OK){ - out.println(F("No Error")); - } else if(_error == UPDATE_ERROR_WRITE){ - out.println(F("Flash Write Failed")); - } else if(_error == UPDATE_ERROR_ERASE){ - out.println(F("Flash Erase Failed")); - } else if(_error == UPDATE_ERROR_READ){ - out.println(F("Flash Read Failed")); - } else if(_error == UPDATE_ERROR_SPACE){ - out.println(F("Not Enough Space")); - } else if(_error == UPDATE_ERROR_SIZE){ - out.println(F("Bad Size Given")); - } else if(_error == UPDATE_ERROR_STREAM){ - out.println(F("Stream Read Timeout")); - } else if(_error == UPDATE_ERROR_NO_DATA){ - out.println(F("No data supplied")); - } else if(_error == UPDATE_ERROR_MD5){ - out.printf_P(PSTR("MD5 Failed: expected:%s, calculated:%s\n"), _target_md5.c_str(), _md5.toString().c_str()); - } else if(_error == UPDATE_ERROR_SIGN){ - out.println(F("Signature verification failed")); - } else if(_error == UPDATE_ERROR_FLASH_CONFIG){ - out.printf_P(PSTR("Flash config wrong real: %d IDE: %d\n"), ESP.getFlashChipRealSize(), ESP.getFlashChipSize()); - } else if(_error == UPDATE_ERROR_NEW_FLASH_CONFIG){ - out.printf_P(PSTR("new Flash config wrong real: %d\n"), ESP.getFlashChipRealSize()); - } else if(_error == UPDATE_ERROR_MAGIC_BYTE){ - out.println(F("Magic byte is wrong, not 0xE9")); - } else if (_error == UPDATE_ERROR_BOOTSTRAP){ - out.println(F("Invalid bootstrapping state, reset ESP8266 before updating")); - } else { - out.println(F("UNKNOWN")); +String UpdaterClass::getErrorString() const { + String out; + + switch (_error) { + case UPDATE_ERROR_OK: + out = F("No Error"); + break; + case UPDATE_ERROR_WRITE: + out = F("Flash Write Failed"); + break; + case UPDATE_ERROR_ERASE: + out = F("Flash Erase Failed"); + break; + case UPDATE_ERROR_READ: + out = F("Flash Read Failed"); + break; + case UPDATE_ERROR_SPACE: + out = F("Not Enough Space"); + break; + case UPDATE_ERROR_SIZE: + out = F("Bad Size Given"); + break; + case UPDATE_ERROR_STREAM: + out = F("Stream Read Timeout"); + break; + case UPDATE_ERROR_MD5: + out += F("MD5 verification failed: "); + out += F("expected: ") + _target_md5; + out += F(", calculated: ") + _md5.toString(); + break; + case UPDATE_ERROR_FLASH_CONFIG: + out += F("Flash config wrong: "); + out += F("real: ") + String(ESP.getFlashChipRealSize(), 10); + out += F(", SDK: ") + String(ESP.getFlashChipSize(), 10); + break; + case UPDATE_ERROR_NEW_FLASH_CONFIG: + out += F("new Flash config wrong, real size: "); + out += String(ESP.getFlashChipRealSize(), 10); + break; + case UPDATE_ERROR_MAGIC_BYTE: + out = F("Magic byte is not 0xE9"); + break; + case UPDATE_ERROR_BOOTSTRAP: + out = F("Invalid bootstrapping state, reset ESP8266 before updating"); + break; + case UPDATE_ERROR_SIGN: + out = F("Signature verification failed"); + break; + case UPDATE_ERROR_NO_DATA: + out = F("No data supplied"); + break; + case UPDATE_ERROR_OOM: + out = F("Out of memory"); + break; + case UPDATE_ERROR_RUNNING_ALREADY: + out = F("Update already running"); + break; + case UPDATE_ERROR_UNKNOWN_COMMAND: + out = F("Unknown update command"); + break; + default: + out = F("UNKNOWN"); + break; } + + return out; +} + +void UpdaterClass::printError(Print &out){ + out.printf_P(PSTR("ERROR[%hhu]: %s\n"), _error, getErrorString().c_str()); } UpdaterClass Update; diff --git a/cores/esp8266/Updater.h b/cores/esp8266/Updater.h index 911ddf7784..7ee1d28311 100644 --- a/cores/esp8266/Updater.h +++ b/cores/esp8266/Updater.h @@ -20,6 +20,9 @@ #define UPDATE_ERROR_BOOTSTRAP (11) #define UPDATE_ERROR_SIGN (12) #define UPDATE_ERROR_NO_DATA (13) +#define UPDATE_ERROR_OOM (14) +#define UPDATE_ERROR_RUNNING_ALREADY (15) +#define UPDATE_ERROR_UNKNOWN_COMMAND (16) #define U_FLASH 0 #define U_FS 100 @@ -51,8 +54,10 @@ class UpdaterVerifyClass { class UpdaterClass { public: - typedef std::function THandlerFunction_Progress; - + using THandlerFunction_Progress = std::function; + using THandlerFunction_Error = std::function; + using THandlerFunction = std::function; + UpdaterClass(); ~UpdaterClass(); @@ -66,7 +71,7 @@ class UpdaterClass { bool begin(size_t size, int command = U_FLASH, int ledPin = -1, uint8_t ledOn = LOW); /* - Run Updater from asynchronous callbacs + Run Updater from asynchronous callbacks */ void runAsync(bool async){ _async = async; } @@ -97,6 +102,11 @@ class UpdaterClass { */ bool end(bool evenIfRemaining = false); + /* + Gets the last error description as string + */ + String getErrorString() const; + /* Prints the last error to an output stream */ @@ -120,7 +130,34 @@ class UpdaterClass { /* This callback will be called when Updater is receiving data */ - UpdaterClass& onProgress(THandlerFunction_Progress fn); + UpdaterClass& onProgress(THandlerFunction_Progress fn) { + _progress_callback = std::move(fn); + return *this; + } + + /* + This callback will be called when Updater ends + */ + UpdaterClass& onError(THandlerFunction_Error fn) { + _error_callback = std::move(fn); + return *this; + } + + /* + This callback will be called when Updater begins + */ + UpdaterClass& onStart(THandlerFunction fn) { + _start_callback = std::move(fn); + return *this; + } + + /* + This callback will be called when Updater ends + */ + UpdaterClass& onEnd(THandlerFunction fn) { + _end_callback = std::move(fn); + return *this; + } //Helpers uint8_t getError(){ return _error; } @@ -175,13 +212,13 @@ class UpdaterClass { } private: - void _reset(); + void _reset(bool callback = true); bool _writeBuffer(); bool _verifyHeader(uint8_t data); bool _verifyEnd(); - void _setError(int error); + void _setError(int error); bool _async = false; uint8_t _error = 0; @@ -202,8 +239,12 @@ class UpdaterClass { // Optional signed binary verification UpdaterHashClass *_hash = nullptr; UpdaterVerifyClass *_verify = nullptr; - // Optional progress callback function + + // Optional lifetime callback functions THandlerFunction_Progress _progress_callback = nullptr; + THandlerFunction_Error _error_callback = nullptr; + THandlerFunction _start_callback = nullptr; + THandlerFunction _end_callback = nullptr; }; extern UpdaterClass Update; diff --git a/cores/esp8266/WString.cpp b/cores/esp8266/WString.cpp index 331b2a5409..1e608c3c92 100644 --- a/cores/esp8266/WString.cpp +++ b/cores/esp8266/WString.cpp @@ -197,6 +197,15 @@ bool String::reserve(unsigned int size) { return false; } +#ifdef DEBUG_ESP_PORT +static void identifyString (const String& badOne) +{ + DEBUG_ESP_PORT.printf("[String] '%." STR(OOM_STRING_BORDER_DISPLAY) "s ... %." STR(OOM_STRING_BORDER_DISPLAY) "s': ", + badOne.c_str(), + badOne.length() > OOM_STRING_BORDER_DISPLAY? badOne.c_str() + std::max((int)badOne.length() - OOM_STRING_BORDER_DISPLAY, OOM_STRING_BORDER_DISPLAY): ""); +} +#endif + bool String::changeBuffer(unsigned int maxStrLen) { // Can we use SSO here to avoid allocation? if (maxStrLen < sizeof(sso.buff) - 1) { @@ -218,16 +227,19 @@ bool String::changeBuffer(unsigned int maxStrLen) { } // Fallthrough to normal allocator size_t newSize = (maxStrLen + 16) & (~0xf); -#ifdef DEBUG_ESP_OOM +#ifdef DEBUG_ESP_PORT if (!isSSO() && capacity() >= OOM_STRING_THRESHOLD_REALLOC_WARN && maxStrLen > capacity()) { // warn when badly re-allocating - DEBUGV("[String] Reallocating large String(%d -> %d bytes) '%." STR(OOM_STRING_BORDER_DISPLAY) "s ... %." STR(OOM_STRING_BORDER_DISPLAY) "s'\n", - len(), maxStrLen, c_str(), - len() > OOM_STRING_BORDER_DISPLAY? c_str() + std::max((int)len() - OOM_STRING_BORDER_DISPLAY, OOM_STRING_BORDER_DISPLAY): ""); + identifyString(*this); + DEBUG_ESP_PORT.printf("Reallocating large String(%d -> %d bytes)\n", len(), maxStrLen); } #endif // Make sure we can fit newsize in the buffer if (newSize > CAPACITY_MAX) { +#ifdef DEBUG_ESP_PORT + identifyString(*this); + DEBUG_ESP_PORT.printf("Maximum capacity reached (" STR(CAPACITY_MAX) ")\n"); +#endif return false; } uint16_t oldLen = len(); @@ -247,6 +259,10 @@ bool String::changeBuffer(unsigned int maxStrLen) { setBuffer(newbuffer); return true; } +#ifdef DEBUG_ESP_PORT + identifyString(*this); + DEBUG_ESP_PORT.printf("OOM: %d -> %zu bytes\n", isSSO() ? 0: capacity(), newSize); +#endif return false; } @@ -804,7 +820,7 @@ void String::replace(const String &find, const String &replace) { if (size == len()) return; if (size > capacity() && !changeBuffer(size)) - return; // XXX: tell user! + return; int index = len() - 1; while (index >= 0 && (index = lastIndexOf(find, index)) >= 0) { readFrom = wbuffer() + index + find.len(); diff --git a/cores/esp8266/WString.h b/cores/esp8266/WString.h index 47a9177534..1a2aebb298 100644 --- a/cores/esp8266/WString.h +++ b/cores/esp8266/WString.h @@ -33,7 +33,7 @@ #include #include -// an abstract class used as a means to proide a unique pointer type +// an abstract class used as a means to provide a unique pointer type // but really has no body class __FlashStringHelper; #define FPSTR(pstr_pointer) (reinterpret_cast(pstr_pointer)) @@ -204,7 +204,7 @@ class String { bool concat(double num); // if there's not enough memory for the concatenated value, the string - // will be left unchanged (but this isn't signalled in any way) + // will be left unchanged (but this isn't signaled in any way) template String &operator +=(const T &rhs) { concat(rhs); @@ -343,7 +343,7 @@ class String { char *wbuffer() { return const_cast(buffer()); } // Writable version of buffer // concatenation is done via non-member functions - // make sure we still have access to internal methods, since we optimize based on capacity of both sides and want to manipulate internal buffers directly + // make sure we still have access to internal methods, since we optimize based on the capacity of both sides and want to manipulate internal buffers directly friend String operator +(const String &lhs, String &&rhs); friend String operator +(String &&lhs, String &&rhs); friend String operator +(char lhs, String &&rhs); diff --git a/cores/esp8266/cont.S b/cores/esp8266/cont.S index 4832b39170..ee049d46f5 100644 --- a/cores/esp8266/cont.S +++ b/cores/esp8266/cont.S @@ -26,8 +26,14 @@ cont_suspend: /* a1: sp */ /* a2: void* cont_ctx */ - /* adjust stack and save registers */ + /* adjust stack */ addi a1, a1, -24 + + /* make sure that a1 points after cont_ctx.stack[] */ + addi a4, a2, 32 + bltu a1, a4, cont_overflow + + /* save registers */ s32i a12, a1, 0 s32i a13, a1, 4 s32i a14, a1, 8 @@ -47,6 +53,11 @@ cont_suspend: l32i a1, a2, 4 jx a0 +cont_overflow: + mov.n a3, a1 + movi a4, __stack_overflow + jx a4 + cont_continue: l32i a12, a1, 0 l32i a13, a1, 4 @@ -113,7 +124,7 @@ cont_run: bnez a4, cont_resume /* else */ /* set new stack*/ - l32i a1, a2, 16; + l32i a1, a2, 16 /* goto pfn */ movi a2, cont_wrapper jx a2 @@ -121,12 +132,15 @@ cont_run: cont_resume: /* a1 <- cont_ctx.sp_suspend */ l32i a1, a2, 12 + /* make sure that a1 points after cont_ctx.stack[] */ + addi a5, a2, 32 + bltu a1, a5, cont_overflow /* reset yield flag, 0 -> cont_ctx.pc_suspend */ movi a3, 0 s32i a3, a2, 8 /* jump to saved cont_ctx.pc_suspend */ movi a0, cont_ret - jx a4 + jx a4 cont_norm: /* calculate pointer to cont_ctx.struct_start from sp */ diff --git a/cores/esp8266/cont.h b/cores/esp8266/cont.h index 6932416b68..4c9578851b 100644 --- a/cores/esp8266/cont.h +++ b/cores/esp8266/cont.h @@ -22,11 +22,16 @@ #define CONT_H_ #include +#include #ifndef CONT_STACKSIZE #define CONT_STACKSIZE 4096 #endif +#ifndef CONT_STACKGUARD +#define CONT_STACKGUARD 0xfeefeffe +#endif + #ifdef __cplusplus extern "C" { #endif @@ -62,9 +67,11 @@ void cont_run(cont_t*, void (*pfn)(void)); // execution state (registers and stack) void cont_suspend(cont_t*); -// Check guard bytes around the stack. Return 0 in case everything is ok, -// return 1 if guard bytes were overwritten. -int cont_check(cont_t* cont); +// Check that cont resume state is valid. Immediately panics on failure. +void cont_check_overflow(cont_t*); + +// Check guard bytes around the stack. Immediately panics on failure. +void cont_check_guard(cont_t*); // Go through stack and check how many bytes are most probably still unchanged // and thus weren't used by the user code. i.e. that stack space is free. (high water mark) @@ -79,7 +86,6 @@ bool cont_can_suspend(cont_t* cont); // free, running the routine, then checking the max free void cont_repaint_stack(cont_t *cont); - #ifdef __cplusplus } #endif diff --git a/cores/esp8266/cont_util.cpp b/cores/esp8266/cont_util.cpp index fd72ee5d18..6c49a38fcf 100644 --- a/cores/esp8266/cont_util.cpp +++ b/cores/esp8266/cont_util.cpp @@ -18,34 +18,50 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "cont.h" +#include + #include #include -#include "ets_sys.h" -extern "C" { +#include "core_esp8266_features.h" +#include "debug.h" + +#include "cont.h" + +extern "C" +{ -#define CONT_STACKGUARD 0xfeefeffe +static constexpr uint32_t CONT_STACKSIZE_U32 { sizeof(cont_t::stack) / sizeof(*cont_t::stack) }; void cont_init(cont_t* cont) { memset(cont, 0, sizeof(cont_t)); cont->stack_guard1 = CONT_STACKGUARD; cont->stack_guard2 = CONT_STACKGUARD; - cont->stack_end = cont->stack + (sizeof(cont->stack) / 4); + cont->stack_end = &cont->stack[0] + CONT_STACKSIZE_U32; cont->struct_start = (unsigned*) cont; // fill stack with magic values to check high water mark - for(int pos = 0; pos < (int)(sizeof(cont->stack) / 4); pos++) + for(int pos = 0; pos < (int)(CONT_STACKSIZE_U32); pos++) { cont->stack[pos] = CONT_STACKGUARD; } } -int IRAM_ATTR cont_check(cont_t* cont) { - if(cont->stack_guard1 != CONT_STACKGUARD || cont->stack_guard2 != CONT_STACKGUARD) return 1; +void IRAM_ATTR cont_check_guard(cont_t* cont) { + if ((cont->stack_guard1 != CONT_STACKGUARD) + || (cont->stack_guard2 != CONT_STACKGUARD)) + { + __stack_chk_fail(); + __builtin_unreachable(); + } +} - return 0; +void IRAM_ATTR cont_check_overflow(cont_t* cont) { + if (cont->sp_suspend && (cont->sp_suspend < &cont->stack[0])) { + __stack_overflow(cont, cont->sp_suspend); + __builtin_unreachable(); + } } // No need for this to be in IRAM, not expected to be IRQ called diff --git a/cores/esp8266/core_esp8266_features.cpp b/cores/esp8266/core_esp8266_features.cpp index 383f3c2d8c..fa51ad8431 100644 --- a/cores/esp8266/core_esp8266_features.cpp +++ b/cores/esp8266/core_esp8266_features.cpp @@ -38,13 +38,13 @@ void precache(void *f, uint32_t bytes) { // page (ie 1 word in 8) for this to work. #define CACHE_PAGE_SIZE 32 - uint32_t a0; - __asm__("mov.n %0, a0" : "=r"(a0)); - uint32_t lines = (bytes/CACHE_PAGE_SIZE)+2; - volatile uint32_t *p = (uint32_t*)((f ? (uint32_t)f : a0) & ~0x03); - uint32_t x; - for (uint32_t i=0; i // malloc() +#include // bool #include // size_t #include +#include // malloc() #ifndef __STRINGIFY #define __STRINGIFY(a) #a @@ -118,6 +117,7 @@ int esp_get_cpu_freq_mhz() #else inline int esp_get_cpu_freq_mhz() { + uint8_t system_get_cpu_freq(void); return system_get_cpu_freq(); } #endif @@ -129,7 +129,7 @@ void enablePhaseLockedWaveform(void); // Determine when the sketch runs on ESP8285 #if !defined(CORE_MOCK) -bool __attribute__((const, nothrow)) esp_is_8285(); +bool esp_is_8285() __attribute__((const, nothrow)); #else inline bool esp_is_8285() { diff --git a/cores/esp8266/core_esp8266_flash_quirks.cpp b/cores/esp8266/core_esp8266_flash_quirks.cpp index 7128fcfe2d..2ae3a39050 100644 --- a/cores/esp8266/core_esp8266_flash_quirks.cpp +++ b/cores/esp8266/core_esp8266_flash_quirks.cpp @@ -66,12 +66,13 @@ void initFlashQuirks() { newSR3=SR3; if (get_flash_mhz()>26) { // >26Mhz? // Set the output drive to 100% + // These definitions are for the XM25QH32B part. On a XM25QH32C + // part, the XM25QH32B's 100% is C's 25% driver strength. newSR3 &= ~(SPI_FLASH_SR3_XMC_DRV_MASK << SPI_FLASH_SR3_XMC_DRV_S); newSR3 |= (SPI_FLASH_SR3_XMC_DRV_100 << SPI_FLASH_SR3_XMC_DRV_S); } if (newSR3 != SR3) { // only write if changed - if (SPI0Command(SPI_FLASH_CMD_WEVSR,NULL,0,0)==SPI_RESULT_OK) // write enable volatile SR - SPI0Command(SPI_FLASH_CMD_WSR3,&newSR3,8,0); // write to SR3 + SPI0Command(SPI_FLASH_CMD_WSR3,&newSR3,8,0,SPI_FLASH_CMD_WEVSR); // write to SR3, use write enable volatile prefix SPI0Command(SPI_FLASH_CMD_WRDI,NULL,0,0); // write disable - probably not needed } } diff --git a/cores/esp8266/core_esp8266_main.cpp b/cores/esp8266/core_esp8266_main.cpp index 430808f19d..d7f14b02c8 100644 --- a/cores/esp8266/core_esp8266_main.cpp +++ b/cores/esp8266/core_esp8266_main.cpp @@ -22,6 +22,10 @@ //This may be used to change user task stack size: //#define CONT_STACKSIZE 4096 + +#include +#include + #include #include "Schedule.h" extern "C" { @@ -163,12 +167,25 @@ extern "C" void __esp_delay(unsigned long ms) { extern "C" void esp_delay(unsigned long ms) __attribute__((weak, alias("__esp_delay"))); bool esp_try_delay(const uint32_t start_ms, const uint32_t timeout_ms, const uint32_t intvl_ms) { + if (!timeout_ms) { + esp_yield(); + return true; + } + uint32_t expired = millis() - start_ms; if (expired >= timeout_ms) { - return true; + return true; // expired } - esp_delay(std::min((timeout_ms - expired), intvl_ms)); - return false; + + // compute greatest chunked delay with respect to scheduled recurrent functions + uint32_t grain_ms = std::gcd(intvl_ms, compute_scheduled_recurrent_grain()); + + // recurrent scheduled functions will be called from esp_delay()->esp_suspend() + esp_delay(grain_ms > 0 ? + std::min((timeout_ms - expired), grain_ms): + (timeout_ms - expired)); + + return false; // expiration must be checked again } extern "C" void __yield() { @@ -245,21 +262,21 @@ static void loop_wrapper() { } loop(); loop_end(); + cont_check_guard(g_pcont); if (serialEventRun) { serialEventRun(); } esp_schedule(); } +extern "C" void __stack_chk_fail(void); + static void loop_task(os_event_t *events) { (void) events; s_cycles_at_resume = ESP.getCycleCount(); ESP.resetHeap(); cont_run(g_pcont, &loop_wrapper); ESP.setDramHeap(); - if (cont_check(g_pcont) != 0) { - panic(); - } } extern "C" { @@ -400,16 +417,250 @@ extern "C" void __disableWiFiAtBootTime (void) #if FLASH_MAP_SUPPORT #include "flash_hal.h" -extern "C" void flashinit (void); +extern "C" const char *flashinit (void); uint32_t __flashindex; #endif +#if (NONOSDK >= (0x30000)) +#undef ETS_PRINTF +#define ETS_PRINTF(...) ets_uart_printf(__VA_ARGS__) +extern "C" uint8_t uart_rx_one_char_block(); + +#if ! FLASH_MAP_SUPPORT +#include "flash_hal.h" +#endif + +extern "C" void user_rf_pre_init(); + +extern "C" void ICACHE_FLASH_ATTR user_pre_init(void) +{ + const char *flash_map_str = NULL; + const char *chip_sz_str = NULL; + const char *table_regist_str = NULL; + [[maybe_unused]] uint32_t ld_config_chip_size = 0; + uint32_t flash_size = 0; + uint32_t phy_data = 0; + uint32_t rf_cal = 0; + uint32_t system_parameter = 0; + [[maybe_unused]] const partition_item_t *_at_partition_table = NULL; + size_t _at_partition_table_sz = 0; + + do { + #if FLASH_MAP_SUPPORT + flash_map_str = flashinit(); + if (flash_map_str) { + continue; + } + #endif + + // For SDKs 3.0.0 and later, place phy_data readonly overlay on top of + // the EEPROM address. For older SDKs without a system partition, RF_CAL + // and PHY_DATA shared the same flash segment. + // + // For the Arduino ESP8266 core, the sectors for "EEPROM = size - + // 0x5000", "RF_CAL = size - 0x4000", and "SYSTEM_PARAMETER = size - + // 0x3000" are positioned in the last five sectors of flash memory. + // PHY_INIT_DATA is special. It is a one time read of 128 bytes of data + // that is provided by a spoofed flash read. + #if FLASH_MAP_SUPPORT + flash_size = __flashdesc[__flashindex].flash_size_kb * 1024u; + #else + // flashchip->chip_size is updated by the SDK. The size is based on the + // value patched into the .bin header by esptool. + // system_get_flash_size_map() returns that patched value. + flash_size = flashchip->chip_size; + #endif + + // For all configurations, place RF_CAL and system_parameter in the + // last 4 sectors of the flash chip. + rf_cal = flash_size - 0x4000u; + system_parameter = flash_size - 0x3000u; + + // The system_partition_table_regist will not allow partitions to + // overlap. EEPROM_start is a good choice for phy_data overlay. The SDK + // does not need to know about EEPROM_start. So we can omit it from the + // table. The real EEPROM access is after user_init() begins long after + // the PHY_DATA read. So it should be safe from conflicts. + phy_data = EEPROM_start - 0x40200000u; + + // For SDKs 3.0 builds, "sdk3_begin_phy_data_spoof and + // user_rf_cal_sector_set" starts and stops the spoofing logic in + // `core_esp8266_phy.cpp`. + extern void sdk3_begin_phy_data_spoof(); + sdk3_begin_phy_data_spoof(); + + ld_config_chip_size = phy_data + 4096 * 5; + + // -DALLOW_SMALL_FLASH_SIZE=1 + // Allows for small flash-size builds targeted for multiple devices, + // commonly IoT, of varying flash sizes. + #if !defined(FLASH_MAP_SUPPORT) && !defined(ALLOW_SMALL_FLASH_SIZE) + // Note, system_partition_table_regist will only catch when the build + // flash size value set by the Arduino IDE Tools menu is larger than + // the firmware image value detected and updated on the fly by esptool. + if (flashchip->chip_size != ld_config_chip_size) { + // Stop to avoid possible stored flash data corruption. This + // mismatch will not occur with flash size selection "Mapping + // defined by Hardware and Sketch". + chip_sz_str = PSTR("Flash size mismatch, check that the build setting matches the device.\n"); + continue; + } + #elif defined(ALLOW_SMALL_FLASH_SIZE) && !defined(FLASH_MAP_SUPPORT) + // Note, while EEPROM is confined to a smaller flash size, we are still + // placing RF_CAL and SYSTEM_PARAMETER at the end of flash. To prevent + // this, esptool or its equal needs to not update the flash size in the + // .bin image. + #endif + + #if FLASH_MAP_SUPPORT && defined(DEBUG_ESP_PORT) + // I don't think this will ever fail. Everything traces back to the results of spi_flash_get_id() + if (flash_size != flashchip->chip_size) { + chip_sz_str = PSTR("Flash size mismatch, check that the build setting matches the device.\n"); + continue; + } + #endif + + // All the examples I find, show the partition table in the global address space. + static const partition_item_t at_partition_table[] = + { + { SYSTEM_PARTITION_PHY_DATA, phy_data, 0x1000 }, // type 5 + { SYSTEM_PARTITION_RF_CAL, rf_cal, 0x1000 }, // type 4 + { SYSTEM_PARTITION_SYSTEM_PARAMETER, system_parameter, 0x3000 }, // type 6 + }; + _at_partition_table = at_partition_table; + _at_partition_table_sz = std::size(at_partition_table); + // SDK 3.0's `system_partition_table_regist` is FOTA-centric. It will report + // on BOOT, OTA1, and OTA2 being missing. We are Non-FOTA. I don't see + // anything we can do about this. Other than maybe turning off os_print. + if (!system_partition_table_regist(at_partition_table, _at_partition_table_sz, system_get_flash_size_map())) { + table_regist_str = PSTR("System partition table registration failed!\n"); + continue; + } + } while(false); + + if (chip_sz_str || flash_map_str || table_regist_str) { + // user_pre_init() is called very early in the SDK startup. When called, + // the PLL CPU clock calibration hasn't not run. Since we are failing, the + // calibration will never complete. And the process will repeat over and + // over. The effective data rate will always be 74880 bps. If we had a + // successful boot, the effective data rate would be 115200 on a restart + // or HWDT. This hack relies on the CPU clock calibration never having + // completed. This assumes we are starting from a hard reset. + + // A possible exception would be a soft reset after flashing. In which + // case the message will not be readable until after a hard reset or + // power cycle. + + // After flashing, the Arduino Serial Monitor needs a moment to + // reconnect. This also allows time for the FIFO to clear and the host + // serial port to clear any framing errors. + ets_delay_us(200u * 1000u); // For an uncalibrated CPU Clock, this is close enough. + + #if !defined(F_CRYSTAL) + #define F_CRYSTAL 26000000 + #endif + // For print messages to be readable, the UART clock rate is based on the + // precalibration rate. + if (F_CRYSTAL != 40000000) { + uart_div_modify(0, F_CRYSTAL * 2 / 115200); + ets_delay_us(150); + } + do { + ETS_PRINTF("\n\n"); + // Because SDK v3.0.x always has a non-32-bit wide exception handler + // installed, we can use PROGMEM strings with Boot ROM print functions. +#if defined(DEBUG_ESP_CORE) || defined(DEBUG_ESP_PORT) // DEBUG_ESP_CORE => verbose + #if FLASH_MAP_SUPPORT + if (flash_map_str) { + ETS_PRINTF(flash_map_str); + #if defined(DEBUG_ESP_CORE) + size_t num = __flashindex; // On failure __flashindex is the size of __flashdesc[]; :/ + ETS_PRINTF(PSTR("Table of __flashdesc[%u].flash_size_kb entries converted to bytes:\n"), num); + for (size_t i = 0; i < num; i++) { + uint32_t size = __flashdesc[i].flash_size_kb << 10; + ETS_PRINTF(PSTR(" [%02u] 0x%08X %8u\n"), i, size, size); + } + #endif + ETS_PRINTF(PSTR("Reference info:\n")); + uint32_t flash_chip_size = 1 << ((spi_flash_get_id() >> 16) & 0xff); + ETS_PRINTF(PSTR(" %-24s 0x%08X %8u\n"), PSTR("fn(spi_flash_get_id())"), flash_chip_size, flash_chip_size); + ETS_PRINTF(PSTR(" %-24s 0x%08X %8u\n"), PSTR("bin_chip_size"), flashchip->chip_size, flashchip->chip_size); + } else + #endif + if (chip_sz_str) { + ETS_PRINTF(chip_sz_str); + } else + if (table_regist_str) { + ETS_PRINTF(table_regist_str); + // (printing now works) repeat ...regist error messages + system_partition_table_regist(_at_partition_table, _at_partition_table_sz, system_get_flash_size_map()); + } + if (chip_sz_str || table_regist_str) { + ETS_PRINTF(PSTR("Reference info:\n")); + #if FLASH_MAP_SUPPORT + ETS_PRINTF(PSTR(" %-24s 0x%08X %8u\n"), PSTR("fn(...ex].flash_size_kb)"), flash_size, flash_size); + uint32_t flash_chip_size = 1 << ((spi_flash_get_id() >> 16) & 0xff); + ETS_PRINTF(PSTR(" %-24s 0x%08X %8u\n"), PSTR("fn(spi_flash_get_id())"), flash_chip_size, flash_chip_size); + ETS_PRINTF(PSTR(" %-24s 0x%08X %8u\n"), PSTR("bin_chip_size"), flashchip->chip_size, flashchip->chip_size); + #else + ETS_PRINTF(PSTR(" %-24s 0x%08X %8u\n"), PSTR("config_flash_size"), ld_config_chip_size, ld_config_chip_size); + ETS_PRINTF(PSTR(" %-24s 0x%08X %8u\n"), PSTR("bin_chip_size"), flashchip->chip_size, flashchip->chip_size); + #endif + #if defined(DEBUG_ESP_CORE) + ETS_PRINTF(PSTR(" %-24s 0x%08X\n"), PSTR("PHY_DATA"), phy_data); + ETS_PRINTF(PSTR(" %-24s 0x%08X\n"), PSTR("RF_CAL"), rf_cal); + ETS_PRINTF(PSTR(" %-24s 0x%08X\n"), PSTR("SYSTEM_PARAMETER"), system_parameter); + ETS_PRINTF(PSTR(" %-24s 0x%08X\n"), PSTR("EEPROM_start"), EEPROM_start); + ETS_PRINTF(PSTR(" %-24s 0x%08X\n"), PSTR("FS_start"), FS_start); + ETS_PRINTF(PSTR(" %-24s 0x%08X\n"), PSTR("FS_end"), FS_end); + ETS_PRINTF(PSTR(" %-24s 0x%08X\n"), PSTR("FS_page"), FS_page); + ETS_PRINTF(PSTR(" %-24s 0x%08X\n"), PSTR("FS_block"), FS_block); + #endif + } +#else + if (flash_map_str) { + ETS_PRINTF(flash_map_str); + } else + if (chip_sz_str) { + ETS_PRINTF(chip_sz_str); + } else + if (table_regist_str) { + ETS_PRINTF(table_regist_str); + } +#endif + uart_rx_one_char_block(); // Someone said hello - repeat message + } while(true); + } + /* + The function user_rf_pre_init() is no longer called from SDK 3.0 and up. + The SDK manual and release notes skipped this detail. The 2023 ESP-FAQ + hints at the change with "* Call system_phy_set_powerup_option(3) in + function user_pre_init or user_rf_pre_init" + https://docs.espressif.com/_/downloads/espressif-esp-faq/en/latest/pdf/#page=14 + + Add call to user_rf_pre_init(), so we can still perform early calls like + system_phy_set_rfoption(rf_mode), system_phy_set_powerup_option(2), etc. + + Placement, should this be at the beginning or end of user_pre_init()? + By the end, we have registered the PHY_DATA partition; however, PHY_DATA + read occurs after return and before user_init() is called. + */ + user_rf_pre_init(); +} +#endif // #if (NONOSDK >= (0x30000)) + extern "C" void user_init(void) { + struct rst_info *rtc_info_ptr = system_get_rst_info(); memcpy((void *) &resetInfo, (void *) rtc_info_ptr, sizeof(resetInfo)); uart_div_modify(0, UART_CLK_FREQ / (115200)); +#if FLASH_MAP_SUPPORT && (NONOSDK < (0x30000)) + const char *err_msg = flashinit(); + if (err_msg) __panic_func(err_msg, 0, NULL); +#endif + init(); // in core_esp8266_wiring.c, inits hw regs and sdk timer initVariant(); @@ -426,15 +677,12 @@ extern "C" void user_init(void) { install_vm_exception_handler(); #endif -#if defined(NON32XFER_HANDLER) || defined(MMU_IRAM_HEAP) +#if defined(NON32XFER_HANDLER) || (defined(MMU_IRAM_HEAP) && (NONOSDK < (0x30000))) install_non32xfer_exception_handler(); #endif #if defined(MMU_IRAM_HEAP) umm_init_iram(); -#endif -#if FLASH_MAP_SUPPORT - flashinit(); #endif preinit(); // Prior to C++ Dynamic Init (not related to above init() ). Meant to be user redefinable. __disableWiFiAtBootTime(); // default weak function disables WiFi diff --git a/cores/esp8266/core_esp8266_non32xfer.cpp b/cores/esp8266/core_esp8266_non32xfer.cpp index 5047e8de5a..eaf2323c96 100644 --- a/cores/esp8266/core_esp8266_non32xfer.cpp +++ b/cores/esp8266/core_esp8266_non32xfer.cpp @@ -26,10 +26,14 @@ * Code taken directly from @pvvx's public domain code in * https://github.com/pvvx/esp8266web/blob/master/app/sdklib/system/app_main.c * + * In Espressif versions NONOSDK v3.0.0+ a similar feature was added + * load_non_32_wide_handler. Theirs is always loaded. Add weak attribute to + * theirs so we can choose by adding an alias to ours. * */ #include +#include #define VERIFY_C_ASM_EXCEPTION_FRAME_STRUCTURE #include #include @@ -58,10 +62,13 @@ extern "C" { #define EXCCAUSE_LOAD_STORE_ERROR 3 /* Non 32-bit read/write error */ +#if (defined(NON32XFER_HANDLER) || defined(MMU_IRAM_HEAP)) && (NONOSDK < (0x30000)) static fn_c_exception_handler_t old_c_handler = NULL; +#endif +#if defined(NON32XFER_HANDLER) || (defined(MMU_IRAM_HEAP) && (NONOSDK < (0x30000))) static -IRAM_ATTR void non32xfer_exception_handler(struct __exception_frame *ef, int cause) +IRAM_ATTR void non32xfer_exception_handler(struct __exception_frame *ef, [[maybe_unused]] int cause) { do { uint32_t insn, excvaddr; @@ -138,6 +145,7 @@ IRAM_ATTR void non32xfer_exception_handler(struct __exception_frame *ef, int cau } while(false); /* Fail request, die */ +#if (NONOSDK < (0x30000)) /* The old handler points to the SDK. Be alert for HWDT when Calling with INTLEVEL != 0. I cannot create it any more. I thought I saw this as a @@ -148,16 +156,23 @@ IRAM_ATTR void non32xfer_exception_handler(struct __exception_frame *ef, int cau old_c_handler(ef, cause); return; } - +#endif /* Calling _xtos_unhandled_exception(ef, cause) in the Boot ROM, gets us a hardware wdt. Use panic instead as a fall back. It will produce a stack trace. */ +#if defined(DEBUG_ESP_PORT) || defined(DEBUG_ESP_MMU) panic(); +#else + // For non-debug builds, save on resources + abort(); +#endif } +#endif // #if defined(NON32XFER_HANDLER) || (defined(MMU_IRAM_HEAP) && (NONOSDK < (0x30000))) +#if (defined(NON32XFER_HANDLER) || defined(MMU_IRAM_HEAP)) && (NONOSDK < (0x30000)) /* To operate reliably, this module requires the new `_xtos_set_exception_handler` from `exc-sethandler.cpp` and @@ -174,5 +189,17 @@ void install_non32xfer_exception_handler(void) { non32xfer_exception_handler); } } +#else +// For v3.0.x SDKs, no need for install - call_user_start will do the job. +// Need this for build dependencies +void install_non32xfer_exception_handler(void) __attribute__((weak)); +void install_non32xfer_exception_handler(void) {} +#endif + +#if defined(NON32XFER_HANDLER) +// For SDKs 3.0.x, we made load_non_32_wide_handler in +// libmain.c:user_exceptions.o a weak symbol allowing this override to work. +extern void load_non_32_wide_handler(struct __exception_frame *ef, int cause) __attribute__((alias("non32xfer_exception_handler"))); +#endif }; diff --git a/cores/esp8266/core_esp8266_noniso.cpp b/cores/esp8266/core_esp8266_noniso.cpp index f15fdc0860..fb5d8f573a 100644 --- a/cores/esp8266/core_esp8266_noniso.cpp +++ b/cores/esp8266/core_esp8266_noniso.cpp @@ -28,19 +28,12 @@ #include #include #include + #include "stdlib_noniso.h" extern "C" { -char* ltoa(long value, char* result, int base) { - return itoa((int)value, result, base); -} - -char* ultoa(unsigned long value, char* result, int base) { - return utoa((unsigned int)value, result, base); -} - -char * dtostrf(double number, signed char width, unsigned char prec, char *s) { +char* dtostrf(double number, signed char width, unsigned char prec, char *s) noexcept { bool negative = false; if (isnan(number)) { @@ -125,7 +118,7 @@ char * dtostrf(double number, signed char width, unsigned char prec, char *s) { */ const char* strrstr(const char*__restrict p_pcString, - const char*__restrict p_pcPattern) + const char*__restrict p_pcPattern) noexcept { const char* pcResult = 0; @@ -149,4 +142,4 @@ const char* strrstr(const char*__restrict p_pcString, return pcResult; } -}; +} // extern "C" diff --git a/cores/esp8266/core_esp8266_phy.cpp b/cores/esp8266/core_esp8266_phy.cpp index f06a698bf7..4657bb0081 100644 --- a/cores/esp8266/core_esp8266_phy.cpp +++ b/cores/esp8266/core_esp8266_phy.cpp @@ -303,12 +303,26 @@ extern int __real_spi_flash_read(uint32_t addr, uint32_t* dst, size_t size); extern int IRAM_ATTR __wrap_spi_flash_read(uint32_t addr, uint32_t* dst, size_t size); extern int __get_adc_mode(); +/* + Verified that the wide filtering of all 128 byte flash reads during + spoof_init_data continues to be safe for SDK 3.0.5 + From start call to user_pre_init() to stop call with user_rf_pre_init(). + + flash read count during spoof_init_data 4 + flash read 0x00000 8 // system_get_flash_size_map() + flash read 0x00000 4 // system_partition_table_regist() + flash read 0xFB000 128 // PHY_DATA (EEPROM address space) + flash read 0xFC000 628 // RC_CAL + */ extern int IRAM_ATTR __wrap_spi_flash_read(uint32_t addr, uint32_t* dst, size_t size) { if (!spoof_init_data || size != 128) { return __real_spi_flash_read(addr, dst, size); } +#if (NONOSDK >= (0x30000)) + spoof_init_data = false; +#endif memcpy(dst, phy_init_data, sizeof(phy_init_data)); ((uint8_t*)dst)[107] = __get_adc_mode(); return 0; @@ -329,23 +343,29 @@ extern int __get_adc_mode(void) extern void __run_user_rf_pre_init(void) __attribute__((weak)); extern void __run_user_rf_pre_init(void) { - return; // default do noting + return; // default do nothing } +#if (NONOSDK >= (0x30000)) +void sdk3_begin_phy_data_spoof(void) +{ + spoof_init_data = true; +} +#else uint32_t user_rf_cal_sector_set(void) { spoof_init_data = true; return flashchip->chip_size/SPI_FLASH_SEC_SIZE - 4; } +#endif void user_rf_pre_init() { // *((volatile uint32_t*) 0x60000710) = 0; +#if (NONOSDK < (0x30000)) spoof_init_data = false; - volatile uint32_t* rtc_reg = (volatile uint32_t*) 0x60001000; - rtc_reg[30] = 0; +#endif - system_set_os_print(0); int rf_mode = __get_rf_mode(); if (rf_mode >= 0) { system_phy_set_rfoption(rf_mode); diff --git a/cores/esp8266/core_esp8266_postmortem.cpp b/cores/esp8266/core_esp8266_postmortem.cpp index 2279401b54..95844534e8 100644 --- a/cores/esp8266/core_esp8266_postmortem.cpp +++ b/cores/esp8266/core_esp8266_postmortem.cpp @@ -42,10 +42,13 @@ static int s_panic_line = 0; static const char* s_panic_func = 0; static const char* s_panic_what = 0; +// Our wiring for abort() and C++ exceptions static bool s_abort_called = false; static const char* s_unhandled_exception = NULL; -static uint32_t s_stacksmash_addr = 0; +// Common way to notify about where the stack smashing happened +// (but, **only** if caller uses our handler function) +static uint32_t s_stack_chk_addr = 0; void abort() __attribute__((noreturn)); static void uart_write_char_d(char c); @@ -56,6 +59,7 @@ static void print_stack(uint32_t start, uint32_t end); // using numbers different from "REASON_" in user_interface.h (=0..6) enum rst_reason_sw { + REASON_USER_STACK_OVERFLOW = 252, REASON_USER_STACK_SMASH = 253, REASON_USER_SWEXCEPTION_RST = 254 }; @@ -96,7 +100,9 @@ static void ets_printf_P(const char *str, ...) { } static void cut_here() { - ets_putc('\n'); + // https://tinyurl.com/8266dcdr => https://arduino-esp8266.readthedocs.io/en/latest/faq/a02-my-esp-crashes.html#exception + ets_printf_P(PSTR("\nTo make this dump useful, DECODE IT - https://tinyurl.com/8266dcdr\n")); + for (auto i = 0; i < 15; i++ ) { ets_putc('-'); } @@ -107,10 +113,30 @@ static void cut_here() { ets_putc('\n'); } -void __wrap_system_restart_local() { - register uint32_t sp asm("a1"); - uint32_t sp_dump = sp; +static inline bool is_pc_valid(uint32_t pc) { + return pc >= XCHAL_INSTRAM0_VADDR && pc < (XCHAL_INSTROM0_VADDR + XCHAL_INSTROM0_SIZE); +} +/* + Add some assembly to grab the stack pointer and pass it as an argument before + it grows for the target function. Should stabilize the stack offsets, used to + find the relevant stack content for dumping. +*/ +extern "C" void __wrap_system_restart_local(void); +asm( + ".section .text.__wrap_system_restart_local,\"ax\",@progbits\n\t" + ".literal_position\n\t" + ".align 4\n\t" + ".global __wrap_system_restart_local\n\t" + ".type __wrap_system_restart_local, @function\n\t" + "\n" +"__wrap_system_restart_local:\n\t" + "mov a2, a1\n\t" + "j.l postmortem_report, a3\n\t" + ".size __wrap_system_restart_local, .-__wrap_system_restart_local\n\t" +); + +static void postmortem_report(uint32_t sp_dump) { struct rst_info rst_info; memset(&rst_info, 0, sizeof(rst_info)); if (s_user_reset_reason == REASON_DEFAULT_RST) @@ -137,6 +163,9 @@ void __wrap_system_restart_local() { } ets_putc('\n'); } + else if (s_panic_file) { + ets_printf_P(PSTR("\nPanic %S\n"), s_panic_file); + } else if (s_unhandled_exception) { ets_printf_P(PSTR("\nUnhandled C++ exception: %S\n"), s_unhandled_exception); } @@ -146,38 +175,75 @@ void __wrap_system_restart_local() { else if (rst_info.reason == REASON_EXCEPTION_RST) { // The GCC divide routine in ROM jumps to the address below and executes ILL (00 00 00) on div-by-zero // In that case, print the exception as (6) which is IntegerDivZero - bool div_zero = (rst_info.exccause == 0) && (rst_info.epc1 == 0x4000dce5); + uint32_t epc1 = rst_info.epc1; + uint32_t exccause = rst_info.exccause; + bool div_zero = (exccause == 0) && (epc1 == 0x4000dce5u); + if (div_zero) { + exccause = 6; + // In place of the detached 'ILL' instruction., redirect attention + // back to the code that called the ROM divide function. + __asm__ __volatile__("rsr.excsave1 %0\n\t" : "=r"(epc1) :: "memory"); + } ets_printf_P(PSTR("\nException (%d):\nepc1=0x%08x epc2=0x%08x epc3=0x%08x excvaddr=0x%08x depc=0x%08x\n"), - div_zero ? 6 : rst_info.exccause, rst_info.epc1, rst_info.epc2, rst_info.epc3, rst_info.excvaddr, rst_info.depc); + exccause, epc1, rst_info.epc2, rst_info.epc3, rst_info.excvaddr, rst_info.depc); } else if (rst_info.reason == REASON_SOFT_WDT_RST) { - ets_printf_P(PSTR("\nSoft WDT reset\n")); + ets_printf_P(PSTR("\nSoft WDT reset")); + const uint8_t infinite_loop[] = { 0x06, 0xff, 0xff }; // loop: j loop + if (is_pc_valid(rst_info.epc1) && 0 == memcmp_P(infinite_loop, (PGM_VOID_P)rst_info.epc1, 3u)) { + // The SDK is riddled with these. They are usually preceded by an ets_printf. + ets_printf_P(PSTR(" - deliberate infinite loop detected")); + } + ets_putc('\n'); + ets_printf_P(PSTR("\nException (%d):\nepc1=0x%08x epc2=0x%08x epc3=0x%08x excvaddr=0x%08x depc=0x%08x\n"), + rst_info.exccause, /* Address executing at time of Soft WDT level-1 interrupt */ rst_info.epc1, 0, 0, 0, 0); } else if (rst_info.reason == REASON_USER_STACK_SMASH) { - ets_printf_P(PSTR("\nStack overflow detected.\n")); - ets_printf_P(PSTR("\nException (%d):\nepc1=0x%08x epc2=0x%08x epc3=0x%08x excvaddr=0x%08x depc=0x%08x\n"), - 5 /* Alloca exception, closest thing to stack fault*/, s_stacksmash_addr, 0, 0, 0, 0); - } + ets_printf_P(PSTR("\nStack smashing detected at 0x%08x\n"), s_stack_chk_addr); + } + else if (rst_info.reason == REASON_USER_STACK_OVERFLOW) { + ets_printf_P(PSTR("\nStack overflow detected\n")); + } else { ets_printf_P(PSTR("\nGeneric Reset\n")); } - uint32_t cont_stack_start = (uint32_t) &(g_pcont->stack); - uint32_t cont_stack_end = (uint32_t) g_pcont->stack_end; - uint32_t stack_end; + uint32_t cont_stack_start; + if (rst_info.reason == REASON_USER_STACK_SMASH) { + cont_stack_start = s_stack_chk_addr; + } else { + cont_stack_start = (uint32_t) (&g_pcont->stack[0]); + } + + uint32_t cont_stack_end = cont_stack_start + CONT_STACKSIZE; // amount of stack taken by interrupt or exception handler // and everything up to __wrap_system_restart_local - // (determined empirically, might break) + // ~(determined empirically, might break)~ uint32_t offset = 0; if (rst_info.reason == REASON_SOFT_WDT_RST) { - offset = 0x1a0; + // Stack Tally + // 256 User Exception vector handler reserves stack space + // directed to _xtos_l1int_handler function in Boot ROM + // 48 wDev_ProcessFiq - its address appears in a vector table at 0x3FFFC27C + // 16 ?unnamed? - index into a table, pull out pointer, and call if non-zero + // appears near near wDev_ProcessFiq + // 32 pp_soft_wdt_feed_local - gather the specifics and call __wrap_system_restart_local + offset = 32 + 16 + 48 + 256; } else if (rst_info.reason == REASON_EXCEPTION_RST) { - offset = 0x190; + // Stack Tally + // 256 Exception vector reserves stack space + // filled in by "C" wrapper handler + // 16 Handler level 1 - enable icache + // 64 Handler level 2 - exception report + offset = 64 + 16 + 256; } else if (rst_info.reason == REASON_WDT_RST) { - offset = 0x10; + offset = 16; + } + else if (rst_info.reason == REASON_USER_SWEXCEPTION_RST) { + offset = 16; } ets_printf_P(PSTR("\n>>>stack>>>\n")); @@ -190,15 +256,21 @@ void __wrap_system_restart_local() { sp_dump = stack_thunk_get_cont_sp(); } - if (sp_dump > cont_stack_start && sp_dump < cont_stack_end) { + uint32_t stack_end; + + // above and inside of cont, dump from the sp to the bottom of the stack + if ((rst_info.reason == REASON_USER_STACK_OVERFLOW) + || ((sp_dump > cont_stack_start) && (sp_dump < cont_stack_end))) + { ets_printf_P(PSTR("\nctx: cont\n")); stack_end = cont_stack_end; } + // in system, reposition to a known address + // it's actually 0x3ffffff0, but the stuff below ets_run + // is likely not really relevant to the crash else { ets_printf_P(PSTR("\nctx: sys\n")); stack_end = 0x3fffffb0; - // it's actually 0x3ffffff0, but the stuff below ets_run - // is likely not really relevant to the crash } ets_printf_P(PSTR("sp: %08x end: %08x offset: %04x\n"), sp_dump, stack_end, offset); @@ -237,11 +309,20 @@ static void print_stack(uint32_t start, uint32_t end) { for (uint32_t pos = start; pos < end; pos += 0x10) { uint32_t* values = (uint32_t*)(pos); + // avoid printing irrelevant data + if ((values[0] == CONT_STACKGUARD) + && (values[0] == values[1]) + && (values[1] == values[2]) + && (values[2] == values[3])) + { + continue; + } + // rough indicator: stack frames usually have SP saved as the second word - bool looksLikeStackFrame = (values[2] == pos + 0x10); + const bool looksLikeStackFrame = (values[2] == pos + 0x10); ets_printf_P(PSTR("%08x: %08x %08x %08x %08x %c\n"), - pos, values[0], values[1], values[2], values[3], (looksLikeStackFrame)?'<':' '); + pos, values[0], values[1], values[2], values[3], (looksLikeStackFrame) ? '<' : ' '); } } @@ -274,8 +355,9 @@ static void raise_exception() { s_user_reset_reason = REASON_USER_SWEXCEPTION_RST; ets_printf_P(PSTR("\nUser exception (panic/abort/assert)")); - __wrap_system_restart_local(); - + uint32_t sp; + __asm__ __volatile__ ("mov %0, a1\n\t" : "=r"(sp) :: "memory"); + postmortem_report(sp); while (1); // never reached, needed to satisfy "noreturn" attribute } @@ -310,17 +392,28 @@ void __panic_func(const char* file, int line, const char* func) { uintptr_t __stack_chk_guard = 0x08675309 ^ RANDOM_REG32; void __stack_chk_fail(void) { s_user_reset_reason = REASON_USER_STACK_SMASH; - ets_printf_P(PSTR("\nPANIC: Stack overrun")); - - s_stacksmash_addr = (uint32_t)__builtin_return_address(0); + s_stack_chk_addr = (uint32_t)__builtin_return_address(0); if (gdb_present()) __asm__ __volatile__ ("syscall"); // triggers GDB when enabled - __wrap_system_restart_local(); + uint32_t sp; + __asm__ __volatile__ ("mov %0, a1\n\t" : "=r"(sp) :: "memory"); + postmortem_report(sp); - while (1); // never reached, needed to satisfy "noreturn" attribute + __builtin_unreachable(); // never reached, needed to satisfy "noreturn" attribute } +void __stack_overflow(cont_t* cont, uint32_t* sp) { + s_user_reset_reason = REASON_USER_STACK_OVERFLOW; + s_stack_chk_addr = (uint32_t)&cont->stack[0]; -}; + if (gdb_present()) + __asm__ __volatile__ ("syscall"); // triggers GDB when enabled + + postmortem_report((uint32_t)sp); + + __builtin_unreachable(); // never reached, needed to satisfy "noreturn" attribute +} + +} // extern "C" diff --git a/cores/esp8266/core_esp8266_spi_utils.cpp b/cores/esp8266/core_esp8266_spi_utils.cpp index 5f2ea25f92..cd5e153c27 100644 --- a/cores/esp8266/core_esp8266_spi_utils.cpp +++ b/cores/esp8266/core_esp8266_spi_utils.cpp @@ -32,6 +32,7 @@ #include "core_esp8266_features.h" #include "spi_utils.h" +#include "spi_flash_defs.h" extern "C" uint32_t Wait_SPI_Idle(SpiFlashChip *fc); @@ -51,12 +52,12 @@ namespace experimental { static SpiOpResult PRECACHE_ATTR _SPICommand(volatile uint32_t spiIfNum, uint32_t spic,uint32_t spiu,uint32_t spiu1,uint32_t spiu2, - uint32_t *data,uint32_t writeWords,uint32_t readWords) + uint32_t *data,uint32_t writeWords,uint32_t readWords, uint32_t pre_cmd) { if (spiIfNum>1) return SPI_RESULT_ERR; - // force SPI register access via base+offset. + // force SPI register access via base+offset. // Prevents loading individual address constants from flash. uint32_t *spibase = (uint32_t*)(spiIfNum ? &(SPI1CMD) : &(SPI0CMD)); #define SPIREG(reg) (*((volatile uint32_t *)(spibase+(&(reg) - &(SPI0CMD))))) @@ -65,6 +66,7 @@ _SPICommand(volatile uint32_t spiIfNum, // Everything defined here must be volatile or the optimizer can // treat them as constants, resulting in the flash reads we're // trying to avoid + SpiFlashOpResult (* volatile SPI_write_enablep)(SpiFlashChip *) = SPI_write_enable; uint32_t (* volatile Wait_SPI_Idlep)(SpiFlashChip *) = Wait_SPI_Idle; volatile SpiFlashChip *fchip=flashchip; volatile uint32_t spicmdusr=SPICMDUSR; @@ -77,15 +79,30 @@ _SPICommand(volatile uint32_t spiIfNum, PRECACHE_START(); Wait_SPI_Idlep((SpiFlashChip *)fchip); } - + // preserve essential controller state such as incoming/outgoing // data lengths and IO mode. uint32_t oldSPI0U = SPIREG(SPI0U); uint32_t oldSPI0U2= SPIREG(SPI0U2); uint32_t oldSPI0C = SPIREG(SPI0C); - //SPI0S &= ~(SPISE|SPISBE|SPISSE|SPISCD); SPIREG(SPI0C) = spic; + + if (SPI_FLASH_CMD_WREN == pre_cmd) { + // See SPI_write_enable comments in esp8266_undocumented.h + SPI_write_enablep((SpiFlashChip *)fchip); + } else + if (pre_cmd) { + // Send prefix cmd w/o data - sends 8 bits. eg. Volatile SR Write Enable, 0x50 + SPIREG(SPI0U) = (spiu & ~(SPIUMOSI|SPIUMISO)); + SPIREG(SPI0U1) = 0; + SPIREG(SPI0U2) = (spiu2 & ~0xFFFFu) | pre_cmd; + + SPIREG(SPI0CMD) = spicmdusr; //Send cmd + while ((SPIREG(SPI0CMD) & spicmdusr)); + } + + //SPI0S &= ~(SPISE|SPISBE|SPISSE|SPISCD); SPIREG(SPI0U) = spiu; SPIREG(SPI0U1)= spiu1; SPIREG(SPI0U2)= spiu2; @@ -117,11 +134,22 @@ _SPICommand(volatile uint32_t spiIfNum, SPIREG(SPI0U) = oldSPI0U; SPIREG(SPI0U2)= oldSPI0U2; SPIREG(SPI0C) = oldSPI0C; - - PRECACHE_END(); + if (!spiIfNum) { + // w/o a call to Wait_SPI_Idlep, 'Exception 0' or other exceptions (saw + // 28) may occur later after returning to iCache code. This issue was + // observed with non-volatile status register writes. + // + // My guess is: Returning too soon to uncached iCache executable space. An + // iCache read may not complete properly because the Flash or SPI + // interface is still busy with the last write operation. In such a case, + // I expect new reads from iROM to result in zeros. This would explain + // the Exception 0 for code, and Exception 20, 28, and 29 where a literal + // was misread as 0 and then used as a pointer. + Wait_SPI_Idlep((SpiFlashChip *)fchip); xt_wsr_ps(saved_ps); } + PRECACHE_END(); return (timeout>0 ? SPI_RESULT_OK : SPI_RESULT_TIMEOUT); } @@ -139,12 +167,37 @@ _SPICommand(volatile uint32_t spiIfNum, * miso_bits * Number of bits to read from the SPI bus after the outgoing * data has been sent. + * pre_cmd + * A few SPI Flash commands require enable commands to immediately preceed + * them. Since two calls to SPI0Command from ICACHE memory most likely would + * be separated by SPI Flash read request for iCache, use this option to + * supply a prefix command, 8-bits w/o read or write data. + * + * Case in point from the GD25Q32E datasheet: "The Write Enable for Volatile + * Status Register command must be issued prior to a Write Status Register + * command and any other commands can’t be inserted between them." * * Note: This code has only been tested with SPI bus 0, but should work * equally well with other buses. The ESP8266 has bus 0 and 1, * newer chips may have more one day. + * + * Supplemental Notes: + * + * SPI Bus wire view: Think of *data as an array of bytes, byte[0] goes out + * first with the most significant bit shifted out first and so on. When + * thinking of the data as an array of 32bit-words, the least significant byte + * of the first 32bit-word goes out first on the SPI bus with the most + * significant bit of that byte shifted out first onto the wire. + * + * When presenting a 3 or 4-byte address, the byte order will need to be + * reversed. Don't overthink it. For a 3-byte address, view *data as a byte + * array and set the first 3-bytes to the address. eg. byteData[0] MSB, + * byteData[1] middle, and byteData[2] LSB. + * + * When sending a fractional byte, fill in the most significant bit positions + * of the byte first. */ -SpiOpResult SPI0Command(uint8_t cmd, uint32_t *data, uint32_t mosi_bits, uint32_t miso_bits) { +SpiOpResult SPI0Command(uint8_t cmd, uint32_t *data, uint32_t mosi_bits, uint32_t miso_bits, uint32_t pre_cmd) { if (mosi_bits>(64*8)) return SPI_RESULT_ERR; if (miso_bits>(64*8)) @@ -159,8 +212,16 @@ SpiOpResult SPI0Command(uint8_t cmd, uint32_t *data, uint32_t mosi_bits, uint32_ if (miso_bits % 32 != 0) miso_words++; + // Use SPI_CS_SETUP to add time for #CS to settle (ringing) before SPI CLK + // begins. The BootROM does not do this; however, RTOS SDK and NONOS SDK do + // as part of flash init/configuration. + // + // One SPI bus clock cycle time inserted between #CS active and the 1st SPI + // bus clock cycle. The number of clock cycles is in SPI_CNTRL2 + // SPI_SETUP_TIME, which defaults to 1. + // // Select user defined command mode in the controller - uint32_t spiu=SPIUCOMMAND; //SPI_USR_COMMAND + uint32_t spiu=SPIUCOMMAND | SPIUCSSETUP; //SPI_USR_COMMAND | SPI_CS_SETUP // Set the command byte to send uint32_t spiu2 = ((7 & SPIMCOMMAND)<> (miso_bits % 8u)) & 0xFFu) << whole_byte_bits; + } + data[miso_bits/32u] &= mask; } } return rc; diff --git a/cores/esp8266/core_esp8266_vm.cpp b/cores/esp8266/core_esp8266_vm.cpp index 3a63d65f7a..00f50e3981 100644 --- a/cores/esp8266/core_esp8266_vm.cpp +++ b/cores/esp8266/core_esp8266_vm.cpp @@ -161,20 +161,21 @@ static struct cache_line *__vm_cache; // Always points to MRU (hence the line be constexpr int addrmask = ~(sizeof(__vm_cache[0].w)-1); // Helper to mask off bits present in cache entry - static void spi_init(spi_regs *spi1) { pinMode(sck, SPECIAL); pinMode(miso, SPECIAL); pinMode(mosi, SPECIAL); pinMode(cs, SPECIAL); - spi1->spi_cmd = 0; + // spi_ctrl appears to need setting before other SPI registers + spi1->spi_ctrl = 0; // MSB first + plain SPI mode + asm("" ::: "memory"); GPMUX &= ~(1 << 9); spi1->spi_clock = spi_clkval; - spi1->spi_ctrl = 0 ; // MSB first + plain SPI mode spi1->spi_ctrl1 = 0; // undocumented, clear for safety? spi1->spi_ctrl2 = 0; // No add'l delays on signals spi1->spi_user2 = 0; // No insn or insn_bits to set + spi1->spi_cmd = 0; } // Note: GCC optimization -O2 and -O3 tried and returned *slower* code than the default diff --git a/cores/esp8266/core_esp8266_wiring.cpp b/cores/esp8266/core_esp8266_wiring.cpp index 40a996d560..3054d39338 100644 --- a/cores/esp8266/core_esp8266_wiring.cpp +++ b/cores/esp8266/core_esp8266_wiring.cpp @@ -34,7 +34,9 @@ static uint32_t micros_overflow_count = 0; #define REPEAT 1 void __delay(unsigned long ms) { - esp_delay(ms); + // Use API letting recurrent scheduled functions run in background + // but stay blocked in delay until ms is expired. + esp_delay(ms, [](){ return true; }); } void delay(unsigned long ms) __attribute__ ((weak, alias("__delay"))); diff --git a/cores/esp8266/coredecls.h b/cores/esp8266/coredecls.h index 1e2776d71b..73af6d8cf1 100644 --- a/cores/esp8266/coredecls.h +++ b/cores/esp8266/coredecls.h @@ -1,6 +1,5 @@ -#ifndef __COREDECLS_H -#define __COREDECLS_H +#pragma once #include "core_esp8266_features.h" @@ -20,18 +19,20 @@ void esp_delay(unsigned long ms); void esp_schedule(); void esp_yield(); void tune_timeshift64 (uint64_t now_us); +bool sntp_set_timezone_in_seconds(int32_t timezone); + void disable_extra4k_at_link_time (void) __attribute__((noinline)); void enable_wifi_enterprise_patch(void) __attribute__((noinline)); -bool sntp_set_timezone_in_seconds(int32_t timezone); void __disableWiFiAtBootTime (void) __attribute__((noinline)); void __real_system_restart_local() __attribute__((noreturn)); -uint32_t sqrt32 (uint32_t n); -uint32_t crc32 (const void* data, size_t length, uint32_t crc = 0xffffffff); +uint32_t sqrt32(uint32_t n); #ifdef __cplusplus } +uint32_t crc32(const void* data, size_t length, uint32_t crc = 0xffffffff); + #include using BoolCB = std::function; @@ -53,14 +54,15 @@ inline void esp_suspend(T&& blocked) { // Try to delay until timeout_ms has expired since start_ms. // Returns true if timeout_ms has completely expired on entry. // Otherwise returns false after delaying for the relative -// remainder of timeout_ms, or an absolute intvl_ms, whichever is shorter. +// remainder of timeout_ms, or an absolute intvl_ms, whichever is shorter +// and possibly amended by recurrent scheduled functions timing grain. // The delay may be asynchronously cancelled, before that timeout is reached. bool esp_try_delay(const uint32_t start_ms, const uint32_t timeout_ms, const uint32_t intvl_ms); // This overload of esp_delay() delays for a duration of at most timeout_ms milliseconds. -// Whenever it is resumed, as well as every intvl_ms millisconds, it performs -// the blocked callback, and if that returns true, it keeps delaying for the remainder -// of the original timeout_ms period. +// Whenever it is resumed, as well as at most every intvl_ms millisconds and depending on +// recurrent scheduled functions, it performs the blocked callback, and if that returns true, +// it keeps delaying for the remainder of the original timeout_ms period. template inline void esp_delay(const uint32_t timeout_ms, T&& blocked, const uint32_t intvl_ms) { const auto start_ms = millis(); @@ -77,5 +79,3 @@ inline void esp_delay(const uint32_t timeout_ms, T&& blocked) { } #endif // __cplusplus - -#endif // __COREDECLS_H diff --git a/cores/esp8266/crc32.cpp b/cores/esp8266/crc32.cpp index c2fdf928e7..42de0c1b91 100644 --- a/cores/esp8266/crc32.cpp +++ b/cores/esp8266/crc32.cpp @@ -23,7 +23,7 @@ #include "pgmspace.h" // moved from core_esp8266_eboot_command.cpp -uint32_t crc32 (const void* data, size_t length, uint32_t crc /*= 0xffffffff*/) +uint32_t crc32 (const void* data, size_t length, uint32_t crc) { const uint8_t* ldata = (const uint8_t*)data; while (length--) diff --git a/cores/esp8266/debug.h b/cores/esp8266/debug.h index c6ea8230ef..437479748c 100644 --- a/cores/esp8266/debug.h +++ b/cores/esp8266/debug.h @@ -4,8 +4,15 @@ #include #include +#include "cont.h" + +#define _DEBUG_LEAF_FUNCTION(...) __asm__ __volatile__("" ::: "a0", "memory") + #ifdef DEBUG_ESP_CORE #define DEBUGV(fmt, ...) ::printf((PGM_P)PSTR(fmt), ##__VA_ARGS__) +#define DEBUG_LEAF_FUNCTION _DEBUG_LEAF_FUNCTION +#else +#define DEBUG_LEAF_FUNCTION(...) #endif #ifndef DEBUGV @@ -26,7 +33,8 @@ void hexdump(const void* mem, uint32_t len, uint8_t cols); extern "C" { #endif - + void __stack_chk_fail(void) __attribute__((noreturn)); + void __stack_overflow(cont_t*, uint32_t*) __attribute__((noreturn)); void __unhandled_exception(const char* str) __attribute__((noreturn)); void __panic_func(const char* file, int line, const char* func) __attribute__((noreturn)); #define panic() __panic_func(PSTR(__FILE__), __LINE__, __func__) diff --git a/cores/esp8266/esp8266_undocumented.h b/cores/esp8266/esp8266_undocumented.h index 5e68e53fa1..d7924333a8 100644 --- a/cores/esp8266/esp8266_undocumented.h +++ b/cores/esp8266/esp8266_undocumented.h @@ -241,6 +241,17 @@ extern fn_c_exception_handler_t _xtos_c_handler_table[XCHAL_EXCCAUSE_NUM]; extern fn_c_exception_handler_t _xtos_set_exception_handler(int cause, fn_c_exception_handler_t fn); #endif +/* + BootROM function that sends the SPI Flash "Write Enable" command, 0x06. + The function internally calls Wait_SPI_Idle before enabling. + Polls status register forever waiting for WEL bit to set. + This function always returns 0; however, most examples test for 0. + + Every function I find that needs WEL set, call this function. I suspect the + waiting for the WEL bit to set is a Flash chip anomaly workaround. +*/ +extern SpiFlashOpResult SPI_write_enable(SpiFlashChip *fc); + extern uint32_t Wait_SPI_Idle(SpiFlashChip *fc); extern void Cache_Read_Disable(); extern int32_t system_func1(uint32_t); diff --git a/cores/esp8266/esp_priv.h b/cores/esp8266/esp_priv.h index 305197e1c9..6e11208bd1 100644 --- a/cores/esp8266/esp_priv.h +++ b/cores/esp8266/esp_priv.h @@ -23,9 +23,8 @@ #if defined(CORE_MOCK) -constexpr bool __byteAddressable(const void* addr) +constexpr bool __byteAddressable(const void*) { - (void)addr; return true; } @@ -34,7 +33,7 @@ constexpr bool __byteAddressable(const void* addr) #include // returns true when addr can be used without "pgm_" functions or non32xfer service -constexpr bool __byteAddressable(const void* addr) +inline bool __byteAddressable(const void* addr) { return addr < (const void*)(XCHAL_DATARAM0_VADDR + XCHAL_DATARAM0_SIZE); } diff --git a/cores/esp8266/exc-sethandler.cpp b/cores/esp8266/exc-sethandler.cpp index b8f9d69a35..64a45b0307 100644 --- a/cores/esp8266/exc-sethandler.cpp +++ b/cores/esp8266/exc-sethandler.cpp @@ -39,8 +39,10 @@ * architecture, I am not convinced it can be done safely. * */ +#include // need NONOSDK -#if defined(NON32XFER_HANDLER) || defined(MMU_IRAM_HEAP) || defined(NEW_EXC_C_WRAPPER) || defined(MMU_EXTERNAL_HEAP) +#if defined(NON32XFER_HANDLER) || defined(MMU_IRAM_HEAP) || \ + defined(NEW_EXC_C_WRAPPER) || defined(MMU_EXTERNAL_HEAP) || (NONOSDK >= (0x30000)) /* * The original module source code came from: diff --git a/cores/esp8266/flash_hal.h b/cores/esp8266/flash_hal.h index effca0f965..061b1d0b08 100644 --- a/cores/esp8266/flash_hal.h +++ b/cores/esp8266/flash_hal.h @@ -33,21 +33,26 @@ extern "C" { #include extern uint32_t spi_flash_get_id (void); // -extern void flashinit(void); +extern const char *flashinit(void); extern uint32_t __flashindex; extern const flash_map_s __flashdesc[]; +#ifndef QUOTE +#define QUOTE(a) __STRINGIFY(a) +#endif + #define FLASH_MAP_SETUP_CONFIG(conf) FLASH_MAP_SETUP_CONFIG_ATTR(,conf) #define FLASH_MAP_SETUP_CONFIG_ATTR(attr, conf...) \ - const flash_map_s __flashdesc[] PROGMEM = conf; \ - void flashinit (void) attr; \ - void flashinit (void) \ + extern const flash_map_s __flashdesc[] PROGMEM attr = conf; \ + const char *flashinit (void) attr; \ + const char *flashinit (void) \ { \ uint32_t flash_chip_size_kb = 1 << (((spi_flash_get_id() >> 16) & 0xff) - 10); \ for (__flashindex = 0; __flashindex < sizeof(__flashdesc) / sizeof(__flashdesc[0]); __flashindex++) \ if (__flashdesc[__flashindex].flash_size_kb == flash_chip_size_kb) \ - return; \ - panic(); /* configuration not found */ \ + return NULL; \ + static const char fail_msg[] PROGMEM = __FILE__ ":" QUOTE(__LINE__) " flashinit: configuration not found"; \ + return fail_msg; /* configuration not found */ \ } #define EEPROM_start (__flashdesc[__flashindex].eeprom_start) diff --git a/cores/esp8266/hardware_reset.cpp b/cores/esp8266/hardware_reset.cpp new file mode 100644 index 0000000000..827b402a5a --- /dev/null +++ b/cores/esp8266/hardware_reset.cpp @@ -0,0 +1,119 @@ +/* + Make the reset look like an EXT_RST reset by: + * Set INTLEVEL to 15 blocking NMI Software WDT interference + * set "restart reason" to REASON_EXT_SYS_RST + * Config Hardware WDT for 1.6ms + * Disable Hardware WDT Level-1 interrupt option + * wait, ... + + Inspired by RTOS SDK hardware_restart in panic.c +*/ + +#include "Arduino.h" +#include +#include +#include "hardware_reset.h" + + +// Extracted from RTOS_SDK eagle_soc.h +/* + * ESPRSSIF MIT License + * + * Copyright (c) 2015 + * + * Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case, + * it is free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ +#define REG_WRITE(_r, _v) (*(volatile uint32_t *)(_r)) = (_v) +#define REG_READ(_r) (*(volatile uint32_t *)(_r)) + +//Watchdog reg {{ +#define PERIPHS_WDT_BASEADDR 0x60000900 + +#define WDT_CTL_ADDRESS 0 +#define WDT_OP_ADDRESS 0x4 +#define WDT_OP_ND_ADDRESS 0x8 +#define WDT_RST_ADDRESS 0x14 + +#define WDT_CTL_RSTLEN_MASK 0x38 +#define WDT_CTL_RSPMOD_MASK 0x6 +#define WDT_CTL_EN_MASK 0x1 + +#define WDT_CTL_RSTLEN_LSB 0x3 +#define WDT_CTL_RSPMOD_LSB 0x1 +#define WDT_CTL_EN_LSB 0 + +#define WDT_FEED_VALUE 0x73 + +#define WDT_REG_READ(_reg) REG_READ(PERIPHS_WDT_BASEADDR + _reg) +#define WDT_REG_WRITE(_reg, _val) REG_WRITE(PERIPHS_WDT_BASEADDR + _reg, _val) +#define CLEAR_WDT_REG_MASK(_reg, _mask) WDT_REG_WRITE(_reg, WDT_REG_READ(_reg) & (~_mask)) +#define SET_WDT_REG_MASK(_reg, _mask, _val) SET_PERI_REG_BITS((PERIPHS_WDT_BASEADDR + _reg), _mask, _val, 0) +#undef WDT_FEED +#define WDT_FEED() WDT_REG_WRITE(WDT_RST_ADDRESS, WDT_FEED_VALUE) +//}} + +// Inspired by RTOS SDK task_wdt.c and hardware_restart in panic.c + +// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +extern "C" { + void hardware_reset(void) { + volatile uint32_t* const rtc_mem = (volatile uint32_t *)0x60001100u; + + // Block NMI or Software WDT from disturbing out restart reason + xt_rsil(15); + + // An HWDT reason would imply a fault or bug, but this reset was requested. + // Set hint reason to EXT_RST. From empirical evidence, an HWDT looks a lot + // like an EXT_RST. The WDT registers are reset to zero like an EXT_RST; + // however, the PLL initialization is still set. We can still read the Boot + // ROM serial output messages. + // SDK restart reason/hint location + rtc_mem[0] = REASON_EXT_SYS_RST; + + // Disable WDT + CLEAR_WDT_REG_MASK(WDT_CTL_ADDRESS, WDT_CTL_EN_MASK); + + // Set Reset pulse to maximum + // Select Reset only - no level-1 interrupt + SET_WDT_REG_MASK(WDT_CTL_ADDRESS, + WDT_CTL_RSTLEN_MASK | WDT_CTL_RSPMOD_MASK, + (7 << WDT_CTL_RSTLEN_LSB) | (2 << WDT_CTL_RSPMOD_LSB)); + + // Set WDT Reset timer to 1.6 ms. + WDT_REG_WRITE(WDT_OP_ADDRESS, 1); // 2^n * 0.8ms, mask 0xf, n = 1 -> (2^1 = 2) * 0.8 * 0.001 = 0.0016 + + // Enable WDT + SET_WDT_REG_MASK(WDT_CTL_ADDRESS, WDT_CTL_EN_MASK, 1 << WDT_CTL_EN_LSB); + + while (true); + } +}; diff --git a/cores/esp8266/hardware_reset.h b/cores/esp8266/hardware_reset.h new file mode 100644 index 0000000000..38d798b815 --- /dev/null +++ b/cores/esp8266/hardware_reset.h @@ -0,0 +1,14 @@ +#ifndef HARDWARE_RESET_H +#define HARDWARE_RESET_H + +#ifdef __cplusplus +extern "C" { +#endif + +void hardware_reset(void) __attribute__((noreturn)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cores/esp8266/heap.cpp b/cores/esp8266/heap.cpp index 78011ed248..54db1ede4a 100644 --- a/cores/esp8266/heap.cpp +++ b/cores/esp8266/heap.cpp @@ -11,7 +11,7 @@ extern "C" size_t umm_umul_sat(const size_t a, const size_t b); extern "C" void z2EapFree(void *ptr, const char* file, int line) __attribute__((weak, alias("vPortFree"), nothrow)); // I don't understand all the compiler noise around this alias. // Adding "__attribute__ ((nothrow))" seems to resolve the issue. -// This may be relevant: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81824 +// This may be relevant: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81824 // Need FORCE_ALWAYS_INLINE to put HeapSelect class constructor/deconstructor in IRAM #define FORCE_ALWAYS_INLINE_HEAP_SELECT @@ -342,8 +342,10 @@ size_t IRAM_ATTR xPortWantedSizeAlign(size_t size) void system_show_malloc(void) { +#ifdef UMM_INFO HeapSelectDram ephemeral; umm_info(NULL, true); +#endif } /* @@ -354,25 +356,25 @@ void system_show_malloc(void) void* IRAM_ATTR pvPortMalloc(size_t size, const char* file, int line) { HeapSelectDram ephemeral; - return heap_pvPortMalloc(size, file, line);; + return heap_pvPortMalloc(size, file, line);; } void* IRAM_ATTR pvPortCalloc(size_t count, size_t size, const char* file, int line) { HeapSelectDram ephemeral; - return heap_pvPortCalloc(count, size, file, line); + return heap_pvPortCalloc(count, size, file, line); } void* IRAM_ATTR pvPortRealloc(void *ptr, size_t size, const char* file, int line) { HeapSelectDram ephemeral; - return heap_pvPortRealloc(ptr, size, file, line); + return heap_pvPortRealloc(ptr, size, file, line); } void* IRAM_ATTR pvPortZalloc(size_t size, const char* file, int line) { HeapSelectDram ephemeral; - return heap_pvPortZalloc(size, file, line); + return heap_pvPortZalloc(size, file, line); } void IRAM_ATTR vPortFree(void *ptr, const char* file, int line) @@ -382,7 +384,98 @@ void IRAM_ATTR vPortFree(void *ptr, const char* file, int line) // correct context. umm_malloc free internally determines the correct heap. HeapSelectDram ephemeral; #endif - return heap_vPortFree(ptr, file, line); + return heap_vPortFree(ptr, file, line); +} + +#if (NONOSDK >= (0x30000)) +//////////////////////////////////////////////////////////////////////////////// +/* + New for NON-OS SDK 3.0.0 and up + Needed for WPA2 Enterprise support. This was not present in SDK pre 3.0 + + The NON-OS SDK 3.0.x has breaking changes to pvPortMalloc. They added one more + argument for selecting a heap. To avoid breaking the build, I renamed their + breaking version to sdk3_pvPortMalloc. To complete the fix, the LIBS need to + be edited. + + Also in the release are low-level functions pvPortZallocIram and + pvPortCallocIram, which are not documented in the Espressif NONOS SDK manual. + No issues in providing replacements. For the non-Arduino ESP8266 applications, + pvPortZallocIram and pvPortCallocIram would have been selected through the + macros like os_malloc defined in `mem.h`. + + OOM - Implementation strategy - Native v3.0 SDK + * For functions `pvPortMalloc(,,,true);` and `pvPortMallocIram(,,,);` on a + failed IRAM alloc, try DRAM. + * For function `pvPortMalloc(,,,false);` use DRAM only - on fail, do not + try IRAM. + + WPA2 Enterprise connect crashing is fixed at v3.0.2 and up. +*/ +#ifdef UMM_HEAP_IRAM +void* IRAM_ATTR sdk3_pvPortMalloc(size_t size, const char* file, int line, bool iram) +{ + if (iram) { + HeapSelectIram ephemeral; + void* ret = heap_pvPortMalloc(size, file, line); + if (ret) return ret; + } + { + HeapSelectDram ephemeral; + return heap_pvPortMalloc(size, file, line); + } +} + +void* IRAM_ATTR pvPortCallocIram(size_t count, size_t size, const char* file, int line) +{ + { + HeapSelectIram ephemeral; + void* ret = heap_pvPortCalloc(count, size, file, line); + if (ret) return ret; + } + { + HeapSelectDram ephemeral; + return heap_pvPortCalloc(count, size, file, line); + } +} + +void* IRAM_ATTR pvPortZallocIram(size_t size, const char* file, int line) +{ + { + HeapSelectIram ephemeral; + void* ret = heap_pvPortZalloc(size, file, line); + if (ret) return ret; + } + { + HeapSelectDram ephemeral; + return heap_pvPortZalloc(size, file, line); + } } +#define CONFIG_IRAM_MEMORY 1 +#else +// For sdk3_pvPortMalloc, the bool argument is ignored and intentionally omitted. +extern "C" void* sdk3_pvPortMalloc(size_t size, const char* file, int line) __attribute__ ((alloc_size(1), malloc, nothrow, alias("pvPortMalloc"))); +extern "C" void* pvPortCallocIram(size_t count, size_t size, const char* file, int line) __attribute__((alloc_size(1, 2), malloc, nothrow, alias("pvPortCalloc"))); +extern "C" void* pvPortZallocIram(size_t size, const char* file, int line) __attribute__((alloc_size(1), malloc, nothrow, alias("pvPortZalloc"))); +#define CONFIG_IRAM_MEMORY 0 +#endif // #ifdef UMM_HEAP_IRAM + +/* + We do not need the function user_iram_memory_is_enabled(). + 1. It was used by mem_manager.o which was replaced with this custom heap + implementation. IRAM memory selection is handled differently for + Arduino ESP8266. + 2. In libmain.a, Cache_Read_Enable_New uses it for cache size. However, When + using IRAM for memory or running with 48K IRAM for code, we use a + replacement Cache_Read_Enable to correct the cache size ignoring + Cache_Read_Enable_New's selected value. + 3. Create a linker conflicts in the event the sketch author tries to control + IRAM heap through this method. +*/ +uint32 IRAM_ATTR user_iram_memory_is_enabled(void) +{ + return CONFIG_IRAM_MEMORY; +} +#endif // #if (NONOSDK >= (0x30000)) }; diff --git a/cores/esp8266/heap_api_debug.h b/cores/esp8266/heap_api_debug.h new file mode 100644 index 0000000000..62f7e7bad5 --- /dev/null +++ b/cores/esp8266/heap_api_debug.h @@ -0,0 +1,74 @@ +/* + * Issolated heap debug helper code from from umm_malloc/umm_malloc_cfg.h. + * Updated umm_malloc/umm_malloc.h and Arduino.h to reference. + * No #ifdef fenceing was used before. From its previous location, this content + * was reassert multiple times through Arduino.h. In case there are legacy + * projects that depend on the previous unfenced behavior, no fencing has been + * added. + */ + +/* + * *alloc redefinition - Included from Arduino.h for DEBUG_ESP_OOM support. + * + * It can also be directly include by the sketch for UMM_POISON_CHECK or + * UMM_POISON_CHECK_LITE builds to get more info about the caller when they + * report on a fail. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef DEBUG_ESP_OOM +#define MEMLEAK_DEBUG + +#include "umm_malloc/umm_malloc_cfg.h" + +#include +// Reuse pvPort* calls, since they already support passing location information. +// Specifically the debug version (heap_...) that does not force DRAM heap. +void *IRAM_ATTR heap_pvPortMalloc(size_t size, const char *file, int line); +void *IRAM_ATTR heap_pvPortCalloc(size_t count, size_t size, const char *file, int line); +void *IRAM_ATTR heap_pvPortRealloc(void *ptr, size_t size, const char *file, int line); +void *IRAM_ATTR heap_pvPortZalloc(size_t size, const char *file, int line); +void IRAM_ATTR heap_vPortFree(void *ptr, const char *file, int line); + +#define malloc(s) ({ static const char mem_debug_file[] PROGMEM STORE_ATTR = __FILE__; heap_pvPortMalloc(s, mem_debug_file, __LINE__); }) +#define calloc(n,s) ({ static const char mem_debug_file[] PROGMEM STORE_ATTR = __FILE__; heap_pvPortCalloc(n, s, mem_debug_file, __LINE__); }) +#define realloc(p,s) ({ static const char mem_debug_file[] PROGMEM STORE_ATTR = __FILE__; heap_pvPortRealloc(p, s, mem_debug_file, __LINE__); }) + +#if defined(UMM_POISON_CHECK) || defined(UMM_POISON_CHECK_LITE) +#define dbg_heap_free(p) ({ static const char mem_debug_file[] PROGMEM STORE_ATTR = __FILE__; heap_vPortFree(p, mem_debug_file, __LINE__); }) +#else +#define dbg_heap_free(p) free(p) +#endif + +#elif defined(UMM_POISON_CHECK) || defined(UMM_POISON_CHECK_LITE) // #elif for #ifdef DEBUG_ESP_OOM +#include +void *IRAM_ATTR heap_pvPortRealloc(void *ptr, size_t size, const char *file, int line); +#define realloc(p,s) ({ static const char mem_debug_file[] PROGMEM STORE_ATTR = __FILE__; heap_pvPortRealloc(p, s, mem_debug_file, __LINE__); }) + +void IRAM_ATTR heap_vPortFree(void *ptr, const char *file, int line); +// C - to be discussed +/* + Problem, I would like to report the file and line number with the umm poison + event as close as possible to the event. The #define method works for malloc, + calloc, and realloc those names are not as generic as free. A #define free + captures too much. Classes with methods called free are included :( + Inline functions would report the address of the inline function in the .h + not where they are called. + + Anybody know a trick to make this work? + + Create dbg_heap_free() as an alternative for free() when you need a little + more help in debugging the more challenging problems. +*/ +#define dbg_heap_free(p) ({ static const char mem_debug_file[] PROGMEM STORE_ATTR = __FILE__; heap_vPortFree(p, mem_debug_file, __LINE__); }) + +#else +#define dbg_heap_free(p) free(p) +#endif /* DEBUG_ESP_OOM */ + +#ifdef __cplusplus +} +#endif diff --git a/cores/esp8266/hwdt_app_entry.cpp b/cores/esp8266/hwdt_app_entry.cpp index 28b8914d90..0f0bee8d4e 100644 --- a/cores/esp8266/hwdt_app_entry.cpp +++ b/cores/esp8266/hwdt_app_entry.cpp @@ -277,6 +277,7 @@ #include #include #include +#include "umm_malloc/umm_malloc.h" #include "mmu_iram.h" extern "C" { diff --git a/cores/esp8266/mmu_iram.cpp b/cores/esp8266/mmu_iram.cpp index 9f1b05d455..0193241890 100644 --- a/cores/esp8266/mmu_iram.cpp +++ b/cores/esp8266/mmu_iram.cpp @@ -122,43 +122,15 @@ void IRAM_ATTR Cache_Read_Disable(void) { } #endif -/* - * Early adjustment for CPU crystal frequency, so debug printing will work. - * This should not be left enabled all the time in Cashe_Read..., I am concerned - * that there may be unknown interference with the NONOS SDK startup. - * - * Inspired by: - * https://github.com/pvvx/esp8266web/blob/2e25559bc489487747205db2ef171d48326b32d4/app/sdklib/system/app_main.c#L581-L591 - */ -extern "C" uint8_t rom_i2c_readReg(uint8_t block, uint8_t host_id, uint8_t reg_add); -extern "C" void rom_i2c_writeReg(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t data); - -extern "C" void IRAM_ATTR set_pll(void) -{ -#if !defined(F_CRYSTAL) -#define F_CRYSTAL 26000000 -#endif - if (F_CRYSTAL != 40000000) { - // At Boot ROM(-BIOS) start, it assumes a 40MHz crystal. - // If it is not, we assume a 26MHz crystal. - // There is no support for 24MHz crustal at this time. - if(rom_i2c_readReg(103,4,1) != 136) { // 8: 40MHz, 136: 26MHz - // Assume 26MHz crystal - // soc_param0: 0: 40MHz, 1: 26MHz, 2: 24MHz - // set 80MHz PLL CPU - rom_i2c_writeReg(103,4,1,136); - rom_i2c_writeReg(103,4,2,145); - } - } -} - //C This was used to probe at different stages of boot the state of the PLL //C register. I think we can get rid of this one. +extern "C" uint8_t rom_i2c_readReg(uint8_t block, uint8_t host_id, uint8_t reg_add); +extern "C" void rom_i2c_writeReg(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t data); extern "C" void IRAM_ATTR dbg_set_pll(void) { char r103_4_1 = rom_i2c_readReg(103,4,1); char r103_4_2 = rom_i2c_readReg(103,4,2); - set_pll(); + mmu_set_pll(); ets_uart_printf("\nrom_i2c_readReg(103,4,1) == %u\n", r103_4_1); ets_uart_printf( "rom_i2c_readReg(103,4,2) == %u\n", r103_4_2); } @@ -197,9 +169,70 @@ extern void Cache_Read_Enable(uint8_t map, uint8_t p, uint8_t v); #endif // #if (MMU_ICACHE_SIZE == 0x4000) /* - * This wrapper is for running code from IROM (flash) before the SDK starts. + * Early adjustment for CPU crystal frequency will allow early debug printing to + * be readable before the SDK initialization is complete. + * This should not be left enabled all the time in Cashe_Read..., I am concerned + * that there may be unknown interference with the NONOS SDK startup. + * It does low-level calls that could clash with the SDKs startup. + * + * Inspired by: + * https://github.com/pvvx/esp8266web/blob/2e25559bc489487747205db2ef171d48326b32d4/app/sdklib/system/app_main.c#L581-L591 + */ +extern "C" uint8_t rom_i2c_readReg(uint8_t block, uint8_t host_id, uint8_t reg_add); +extern "C" void rom_i2c_writeReg(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t data); + +extern "C" void IRAM_ATTR mmu_set_pll(void) +{ +#if !defined(F_CRYSTAL) +#define F_CRYSTAL 26000000 +#endif + if (F_CRYSTAL != 40000000) { + // At Boot ROM(-BIOS) start, it assumes a 40MHz crystal. + // If it is not, we assume a 26MHz crystal. + // There is no support for 24MHz crustal at this time. + if(rom_i2c_readReg(103,4,1) != 136) { // 8: 40MHz, 136: 26MHz + // Assume 26MHz crystal + // soc_param0: 0: 40MHz, 1: 26MHz, 2: 24MHz + // set 80MHz PLL CPU + rom_i2c_writeReg(103,4,1,136); + rom_i2c_writeReg(103,4,2,145); + } + } +} + +/* + * This wrapper is for running code early from IROM (flash) before the SDK + * starts. Since the NONOS SDK will do a full and proper flash device init for + * speed and mode, we only do a minimum to make ICACHE functional, keeping IRAM + * use to a minimum. After the SDK has started, this function is not needed and + * must not be called. */ void IRAM_ATTR mmu_wrap_irom_fn(void (*fn)(void)) { + // Cache Read must be disabled. This is always the case on entry when called + // from the right context. + // Cache_Read_Disable(); + + // The SPI_CS_SETUP parameter has been observed set by RTOS SDK and NONOS SDK + // as part of flash init/configuration. It may be necessary for some flash + // chips to perform correctly with ICACHE hardware access. Turning on and + // leaving it on should be okay. + // + // One SPI bus clock cycle time is inserted between #CS active and 1st SPI bus + // clock cycle. The number of clock cycles is in SPI_CNTRL2 SPI_SETUP_TIME, + // defaults to 1. + SPI0U |= SPIUCSSETUP; // SPI_CS_SETUP or BIT5 + + // phy_get_bb_evm is the key function, called from fix_cache_bug in the NONOS + // SDK. This addition resolves the PUYA Flash issue with exception 0, when + // early Cache_Read_Enable is used. + extern uint32_t phy_get_bb_evm(void); // undocumented + phy_get_bb_evm(); + + // For early Cache_Read_Enable, only do ICACHE_SIZE_16. With this option, + // Cache_Read_Disable will fully restore the original register states. With + // ICACHE_SIZE_32, one bit is missed when disabling. Leave the full access + // calls for the NONOS SDK. + // This only works with image slice 0, which is all we do presently. Cache_Read_Enable(0, 0, ICACHE_SIZE_16); fn(); Cache_Read_Disable(); diff --git a/cores/esp8266/mmu_iram.h b/cores/esp8266/mmu_iram.h index 121226bd4c..e80c5ec348 100644 --- a/cores/esp8266/mmu_iram.h +++ b/cores/esp8266/mmu_iram.h @@ -46,6 +46,19 @@ extern "C" { */ #endif +#if defined(DEV_DEBUG_PRINT) || defined(DEBUG_ESP_MMU) || defined(DEBUG_ESP_CORE) || defined(DEBUG_ESP_PORT) +/* + * Early adjustment for CPU crystal frequency will allow early debug printing to + * be readable before the SDK initialization is complete. + * + * It is unknown if there are any side effects with SDK startup, but a + * possibility. Out of an abundance of caution, limit the use of mmu_set_pll for + * handling printing in failure cases that finish with a reboot. Or for other + * rare debug contexts. + */ +extern void mmu_set_pll(void); +#endif + /* * DEV_DEBUG_PRINT: * Debug printing macros for printing before before, during, and after @@ -56,17 +69,17 @@ extern "C" { #define DEV_DEBUG_PRINT */ -#if defined(DEV_DEBUG_PRINT) || defined(DEBUG_ESP_MMU) +#if (defined(DEV_DEBUG_PRINT) || defined(DEBUG_ESP_MMU)) && !defined(HOST_MOCK) +// Errors follow when `#include ` is present when running CI HOST #include #define DBG_MMU_FLUSH(a) while((USS(a) >> USTXC) & 0xff) {} #if defined(DEV_DEBUG_PRINT) -extern void set_pll(void); extern void dbg_set_pll(void); #define DBG_MMU_PRINTF(fmt, ...) \ -set_pll(); \ +mmu_set_pll(); \ uart_buff_switch(0); \ ets_uart_printf(fmt, ##__VA_ARGS__); \ DBG_MMU_FLUSH(0) diff --git a/cores/esp8266/spi_utils.h b/cores/esp8266/spi_utils.h index bf0928f288..181554a55a 100644 --- a/cores/esp8266/spi_utils.h +++ b/cores/esp8266/spi_utils.h @@ -35,7 +35,7 @@ typedef enum { SPI_RESULT_TIMEOUT } SpiOpResult; -SpiOpResult SPI0Command(uint8_t cmd, uint32_t *data, uint32_t mosi_bits, uint32_t miso_bits); +SpiOpResult SPI0Command(uint8_t cmd, uint32_t *data, uint32_t mosi_bits, uint32_t miso_bits, uint32_t pre_cmd=0); } #ifdef __cplusplus diff --git a/cores/esp8266/stdlib_noniso.cpp b/cores/esp8266/stdlib_noniso.cpp index 693dfda850..4fed9b615d 100644 --- a/cores/esp8266/stdlib_noniso.cpp +++ b/cores/esp8266/stdlib_noniso.cpp @@ -21,11 +21,13 @@ #include "stdlib_noniso.h" +extern "C" { + // ulltoa() is slower than std::to_char() (1.6 times) // but is smaller by ~800B/flash and ~250B/rodata // ulltoa fills str backwards and can return a pointer different from str -char* ulltoa(unsigned long long val, char* str, int slen, unsigned int radix) +char* ulltoa(unsigned long long val, char* str, int slen, unsigned int radix) noexcept { str += --slen; *str = 0; @@ -39,7 +41,7 @@ char* ulltoa(unsigned long long val, char* str, int slen, unsigned int radix) } // lltoa fills str backwards and can return a pointer different from str -char* lltoa (long long val, char* str, int slen, unsigned int radix) +char* lltoa(long long val, char* str, int slen, unsigned int radix) noexcept { bool neg; if (val < 0) @@ -60,3 +62,13 @@ char* lltoa (long long val, char* str, int slen, unsigned int radix) } return ret; } + +char* ltoa(long value, char* result, int base) noexcept { + return itoa((int)value, result, base); +} + +char* ultoa(unsigned long value, char* result, int base) noexcept { + return utoa((unsigned int)value, result, base); +} + +} // extern "C" diff --git a/cores/esp8266/stdlib_noniso.h b/cores/esp8266/stdlib_noniso.h index f86f78befc..0c8c488ed1 100644 --- a/cores/esp8266/stdlib_noniso.h +++ b/cores/esp8266/stdlib_noniso.h @@ -22,38 +22,35 @@ #ifndef STDLIB_NONISO_H #define STDLIB_NONISO_H +#include + #ifdef __cplusplus -extern "C"{ +extern "C" { #endif -int atoi(const char *s); - -long atol(const char* s); - -double atof(const char* s); - -char* itoa (int val, char *s, int radix); - -char* ltoa (long val, char *s, int radix); +#ifdef __cplusplus +#define __STDLIB_NONISO_NOEXCEPT noexcept +#else +#define __STDLIB_NONISO_NOEXCEPT +#endif -char* lltoa (long long val, char* str, int slen, unsigned int radix); +char* ltoa (long val, char *s, int radix) __STDLIB_NONISO_NOEXCEPT; -char* utoa (unsigned int val, char *s, int radix); +char* lltoa (long long val, char* str, int slen, unsigned int radix) __STDLIB_NONISO_NOEXCEPT; -char* ultoa (unsigned long val, char *s, int radix); +char* ultoa (unsigned long val, char *s, int radix) __STDLIB_NONISO_NOEXCEPT; -char* ulltoa (unsigned long long val, char* str, int slen, unsigned int radix); +char* ulltoa (unsigned long long val, char* str, int slen, unsigned int radix) __STDLIB_NONISO_NOEXCEPT; -char* dtostrf (double val, signed char width, unsigned char prec, char *s); +char* dtostrf (double val, signed char width, unsigned char prec, char *s) __STDLIB_NONISO_NOEXCEPT; -void reverse(char* begin, char* end); +const char* strrstr (const char*__restrict p_pcString, + const char*__restrict p_pcPattern) __STDLIB_NONISO_NOEXCEPT; -const char* strrstr(const char*__restrict p_pcString, - const char*__restrict p_pcPattern); +#undef __STDLIB_NONISO_NOEXCEPT #ifdef __cplusplus } // extern "C" #endif - #endif diff --git a/cores/esp8266/umm_malloc/Notes.h b/cores/esp8266/umm_malloc/Notes.h index 33b2fc545a..5d076c4b67 100644 --- a/cores/esp8266/umm_malloc/Notes.h +++ b/cores/esp8266/umm_malloc/Notes.h @@ -276,4 +276,81 @@ Enhancement ideas: #endif ``` */ + +/* + Sep 26, 2022 + + History/Overview + + ESP.getFreeHeap() needs a function it can call for free Heap size. The legacy + method was the SDK function `system_get_free_heap_size()` which is in IRAM. + + `system_get_free_heap_size()` calls `xPortGetFreeHeapSize()` to get free heap + size. Our old legacy implementation used umm_info(), employing a + time-consuming method for getting free Heap size and runs with interrupts + blocked. + + Later we used a distributed method that maintained the free heap size with + each malloc API call that changed the Heap. (enabled by build option UMM_STATS + or UMM_STATS_FULL) We used an internally function `umm_free_heap_size_lw()` to + report free heap size. We satisfied the requirements for + `xPortGetFreeHeapSize()` with an alias to `umm_free_heap_size_lw()` + in replacement for the legacy umm_info() call wrapper. + + The upstream umm_malloc later implemented a similar method enabled by build + option UMM_INLINE_METRICS and introduced the function `umm_free_heap_size()`. + + The NONOS SDK alloc request must use the DRAM Heap. Need to Ensure DRAM Heap + results when multiple Heap support is enabled. Since the SDK uses portable + malloc calls pvPortMalloc, ... we leveraged that for a solution - force + pvPortMalloc, ... APIs to serve DRAM only. + + In an oversight, `xPortGetFreeHeapSize()` was left reporting the results for + the current heap selection via `umm_free_heap_size_lw()`. Thus, if an SDK + function like os_printf_plus were called when the current heap selection was + IRAM, it would get the results for the IRAM Heap. Then would receive DRAM with + an alloc request. However, when the free IRAM size is too small, it would + skip the Heap alloc request and use stack space. + + Solution + + The resolution is to rely on build UMM_STATS(default) or UMM_STATS_FULL for + free heap size information. When not available in the build, fallback to the + upstream umm_malloc's `umm_free_heap_size()` and require the build option + UMM_INLINE_METRICS. Otherwise, fail the build. + + Use function name `umm_free_heap_size_lw()` to support external request for + current heap size. When build options result in fallback using umm_info.c, + ensure UMM_INLINE_METRICS enabled and alias to `umm_free_heap_size()`. + + For the multiple Heap case, `xPortGetFreeHeapSize()` becomes a unique function + and reports only DRAM free heap size. Now `system_get_free_heap_size()` will + always report DRAM free Heap size. This might be a breaking change. + + Specifics: + + * Support `umm_free_heap_size_lw()` as an `extern`. + + * When the build options UMM_STATS/UMM_STATS_FULL are not used, fallback to + the upstream umm_malloc's `umm_free_heap_size()` function in umm_info.c + * require the UMM_INLINE_METRICS build option. + * assign `umm_free_heap_size_lw()` as an alias to `umm_free_heap_size()` + + * `xPortGetFreeHeapSize()` + * For single heap builds, alias to `umm_free_heap_size_lw()` + * For multiple Heaps builds, add a dedicated function that always reports + DRAM results. + + + April 22, 2023 + + The umm_poison logic runs outside the UMM_CRITICAL_* umbrella. When interrupt + routines do alloc calls, it is possible to interrupt an in-progress allocation + just before the poison is set, with a new alloc request resulting in a false + "poison check fail" against the in-progress allocation. The SDK does mallocs + from ISRs. SmartConfig can illustrate this issue. + + Move get_poisoned() within UMM_CRITICAL_* in umm_malloc() and umm_realloc(). + +*/ #endif diff --git a/cores/esp8266/umm_malloc/umm_info.c b/cores/esp8266/umm_malloc/umm_info.c index 4a95e994c3..c0ebb7948f 100644 --- a/cores/esp8266/umm_malloc/umm_info.c +++ b/cores/esp8266/umm_malloc/umm_info.c @@ -174,6 +174,14 @@ size_t umm_free_heap_size_core(umm_heap_context_t *_context) { return (size_t)_context->info.freeBlocks * sizeof(umm_block); } +/* + When used as the fallback option for supporting exported function + `umm_free_heap_size_lw()`, the build option UMM_INLINE_METRICS is required. + Otherwise, umm_info() would be used to complete the operation, which uses a + time-consuming method for getting free Heap and runs with interrupts off, + which can negatively impact WiFi operations. Also, it cannot support calls + from ISRs, `umm_info()` runs from flash. +*/ size_t umm_free_heap_size(void) { #ifndef UMM_INLINE_METRICS umm_info(NULL, false); diff --git a/cores/esp8266/umm_malloc/umm_local.c b/cores/esp8266/umm_malloc/umm_local.c index a28fd16d93..c08e2a27ca 100644 --- a/cores/esp8266/umm_malloc/umm_local.c +++ b/cores/esp8266/umm_malloc/umm_local.c @@ -142,8 +142,11 @@ void *umm_poison_realloc_fl(void *ptr, size_t size, const char *file, int line) add_poison_size(&size); ret = umm_realloc(ptr, size); - - ret = get_poisoned(ret, size); + /* + "get_poisoned" is now called from umm_realloc while still in a critical + section. Before umm_realloc returned, the pointer offset was adjusted to + the start of the requested buffer. + */ return ret; } @@ -161,35 +164,97 @@ void umm_poison_free_fl(void *ptr, const char *file, int line) { /* ------------------------------------------------------------------------ */ #if defined(UMM_STATS) || defined(UMM_STATS_FULL) || defined(UMM_INFO) +/* + For internal, mainly used by UMM_STATS_FULL; exported so external components + can perform Heap related calculations. +*/ size_t umm_block_size(void) { return sizeof(umm_block); } #endif +/* + Need to expose a function to support getting the current free heap size. + Export `size_t umm_free_heap_size_lw(void)` for this purpose. + Used by ESP.getFreeHeap(). + + For an expanded discussion see Notes.h, entry dated "Sep 26, 2022" +*/ #if defined(UMM_STATS) || defined(UMM_STATS_FULL) -// Keep complete call path in IRAM +/* + Default build option to support export. + + Keep complete call path in IRAM. +*/ size_t umm_free_heap_size_lw(void) { UMM_CHECK_INITIALIZED(); umm_heap_context_t *_context = umm_get_current_heap(); return (size_t)_context->UMM_FREE_BLOCKS * sizeof(umm_block); } -#endif +#elif defined(UMM_INLINE_METRICS) +/* + For the fallback option using `size_t umm_free_heap_size(void)`, we must have + the UMM_INLINE_METRICS build option enabled to support free heap size + reporting without the use of `umm_info()`. +*/ +size_t umm_free_heap_size_lw(void) __attribute__ ((alias("umm_free_heap_size"))); + +#else /* - I assume xPortGetFreeHeapSize needs to be in IRAM. Since - system_get_free_heap_size is in IRAM. Which would mean, umm_free_heap_size() - in flash, was not a safe alternative for returning the same information. + We require a resource to track and report free Heap size with low overhead. + For an expanded discussion see Notes.h, entry dated "Sep 26, 2022" */ +#error UMM_INLINE_METRICS, UMM_STATS, or UMM_STATS_FULL needs to be defined. +#endif + #if defined(UMM_STATS) || defined(UMM_STATS_FULL) -size_t xPortGetFreeHeapSize(void) __attribute__ ((alias("umm_free_heap_size_lw"))); +size_t umm_free_heap_size_core_lw(umm_heap_context_t *_context) { + return (size_t)_context->UMM_FREE_BLOCKS * sizeof(umm_block); +} + #elif defined(UMM_INFO) -#ifndef UMM_INLINE_METRICS -#warning "No ISR safe function available to implement xPortGetFreeHeapSize()" +// Backfill support for umm_free_heap_size_core_lw() +size_t umm_free_heap_size_core_lw(umm_heap_context_t *_context) __attribute__ ((alias("umm_free_heap_size_core"))); #endif + +/* + This API is called by `system_get_free_heap_size()` which is in IRAM. Driving + the assumption the callee may be in an ISR or Cache_Read_Disable state. Use + IRAM to ensure that the complete call chain is in IRAM. + + To satisfy this requirement, we need UMM_STATS... or UMM_INLINE_METRICS + defined. These support an always available without intense computation + free-Heap value. + + Like the other vPort... APIs used by the SDK, this must always report on the + DRAM Heap not the current Heap. +*/ +#if (UMM_NUM_HEAPS == 1) +// Reduce IRAM usage for the single Heap case +#if defined(UMM_STATS) || defined(UMM_STATS_FULL) +size_t xPortGetFreeHeapSize(void) __attribute__ ((alias("umm_free_heap_size_lw"))); +#else size_t xPortGetFreeHeapSize(void) __attribute__ ((alias("umm_free_heap_size"))); #endif +#else +size_t xPortGetFreeHeapSize(void) { + #if defined(UMM_STATS) || defined(UMM_STATS_FULL) || defined(UMM_INLINE_METRICS) + UMM_CHECK_INITIALIZED(); + umm_heap_context_t *_context = umm_get_heap_by_id(UMM_HEAP_DRAM); + + return umm_free_heap_size_core_lw(_context); + #else + // At this time, this build path is not reachable. In case things change, + // keep build check. + // Not in IRAM, umm_info() would have been used to complete this operation. + #error "No ISR safe function available to implement xPortGetFreeHeapSize()" + #endif +} +#endif + #if defined(UMM_STATS) || defined(UMM_STATS_FULL) void umm_print_stats(int force) { umm_heap_context_t *_context = umm_get_current_heap(); diff --git a/cores/esp8266/umm_malloc/umm_malloc.cpp b/cores/esp8266/umm_malloc/umm_malloc.cpp index 4a1bdfc76c..e130862cf7 100644 --- a/cores/esp8266/umm_malloc/umm_malloc.cpp +++ b/cores/esp8266/umm_malloc/umm_malloc.cpp @@ -909,6 +909,8 @@ void *umm_malloc(size_t size) { ptr = umm_malloc_core(_context, size); + ptr = POISON_CHECK_SET_POISON(ptr, size); + UMM_CRITICAL_EXIT(id_malloc); return ptr; @@ -926,7 +928,7 @@ void *umm_realloc(void *ptr, size_t size) { uint16_t c; - size_t curSize; + [[maybe_unused]] size_t curSize; UMM_CHECK_INITIALIZED(); @@ -1068,7 +1070,7 @@ void *umm_realloc(void *ptr, size_t size) { // Case 2 - block + next block fits EXACTLY } else if ((blockSize + nextBlockSize) == blocks) { DBGLOG_DEBUG("exact realloc using next block - %i\n", blocks); - umm_assimilate_up(c); + umm_assimilate_up(_context, c); STATS__FREE_BLOCKS_UPDATE(-nextBlockSize); blockSize += nextBlockSize; @@ -1087,8 +1089,10 @@ void *umm_realloc(void *ptr, size_t size) { STATS__FREE_BLOCKS_UPDATE(-prevBlockSize); STATS__FREE_BLOCKS_ISR_MIN(); blockSize += prevBlockSize; + // Fix new allocation such that poison checks from an ISR pass. + POISON_CHECK_SET_POISON_BLOCKS((void *)&UMM_DATA(c), blockSize); UMM_CRITICAL_SUSPEND(id_realloc); - memmove((void *)&UMM_DATA(c), ptr, curSize); + UMM_POISON_MEMMOVE((void *)&UMM_DATA(c), ptr, curSize); ptr = (void *)&UMM_DATA(c); UMM_CRITICAL_RESUME(id_realloc); // Case 5 - prev block + block + next block fits @@ -1108,8 +1112,9 @@ void *umm_realloc(void *ptr, size_t size) { #else blockSize += (prevBlockSize + nextBlockSize); #endif + POISON_CHECK_SET_POISON_BLOCKS((void *)&UMM_DATA(c), blockSize); UMM_CRITICAL_SUSPEND(id_realloc); - memmove((void *)&UMM_DATA(c), ptr, curSize); + UMM_POISON_MEMMOVE((void *)&UMM_DATA(c), ptr, curSize); ptr = (void *)&UMM_DATA(c); UMM_CRITICAL_RESUME(id_realloc); @@ -1119,8 +1124,9 @@ void *umm_realloc(void *ptr, size_t size) { void *oldptr = ptr; if ((ptr = umm_malloc_core(_context, size))) { DBGLOG_DEBUG("realloc %i to a bigger block %i, copy, and free the old\n", blockSize, blocks); + (void)POISON_CHECK_SET_POISON(ptr, size); UMM_CRITICAL_SUSPEND(id_realloc); - memcpy(ptr, oldptr, curSize); + UMM_POISON_MEMCPY(ptr, oldptr, curSize); UMM_CRITICAL_RESUME(id_realloc); umm_free_core(_context, oldptr); } else { @@ -1181,8 +1187,10 @@ void *umm_realloc(void *ptr, size_t size) { blockSize = blocks; #endif } + // Fix new allocation such that poison checks from an ISR pass. + POISON_CHECK_SET_POISON_BLOCKS((void *)&UMM_DATA(c), blockSize); UMM_CRITICAL_SUSPEND(id_realloc); - memmove((void *)&UMM_DATA(c), ptr, curSize); + UMM_POISON_MEMMOVE((void *)&UMM_DATA(c), ptr, curSize); ptr = (void *)&UMM_DATA(c); UMM_CRITICAL_RESUME(id_realloc); } else if (blockSize >= blocks) { // 2 @@ -1198,8 +1206,9 @@ void *umm_realloc(void *ptr, size_t size) { void *oldptr = ptr; if ((ptr = umm_malloc_core(_context, size))) { DBGLOG_DEBUG("realloc %d to a bigger block %d, copy, and free the old\n", blockSize, blocks); + (void)POISON_CHECK_SET_POISON(ptr, size); UMM_CRITICAL_SUSPEND(id_realloc); - memcpy(ptr, oldptr, curSize); + UMM_POISON_MEMCPY(ptr, oldptr, curSize); UMM_CRITICAL_RESUME(id_realloc); umm_free_core(_context, oldptr); } else { @@ -1223,8 +1232,9 @@ void *umm_realloc(void *ptr, size_t size) { void *oldptr = ptr; if ((ptr = umm_malloc_core(_context, size))) { DBGLOG_DEBUG("realloc %d to a bigger block %d, copy, and free the old\n", blockSize, blocks); + (void)POISON_CHECK_SET_POISON(ptr, size); UMM_CRITICAL_SUSPEND(id_realloc); - memcpy(ptr, oldptr, curSize); + UMM_POISON_MEMCPY(ptr, oldptr, curSize); UMM_CRITICAL_RESUME(id_realloc); umm_free_core(_context, oldptr); } else { @@ -1250,6 +1260,8 @@ void *umm_realloc(void *ptr, size_t size) { STATS__FREE_BLOCKS_MIN(); + ptr = POISON_CHECK_SET_POISON(ptr, size); + /* Release the critical section... */ UMM_CRITICAL_EXIT(id_realloc); @@ -1258,6 +1270,7 @@ void *umm_realloc(void *ptr, size_t size) { /* ------------------------------------------------------------------------ */ +#if !defined(UMM_POISON_CHECK) && !defined(UMM_POISON_CHECK_LITE) void *umm_calloc(size_t num, size_t item_size) { void *ret; @@ -1273,6 +1286,7 @@ void *umm_calloc(size_t num, size_t item_size) { return ret; } +#endif /* ------------------------------------------------------------------------ */ diff --git a/cores/esp8266/umm_malloc/umm_malloc.h b/cores/esp8266/umm_malloc/umm_malloc.h index d3e3ace561..2c3b22cf74 100644 --- a/cores/esp8266/umm_malloc/umm_malloc.h +++ b/cores/esp8266/umm_malloc/umm_malloc.h @@ -10,8 +10,10 @@ #include -// C This include is not in upstream +// C These includes are not in the upstream #include "umm_malloc_cfg.h" /* user-dependent */ +#include +#include #ifdef __cplusplus extern "C" { diff --git a/cores/esp8266/umm_malloc/umm_malloc_cfg.h b/cores/esp8266/umm_malloc/umm_malloc_cfg.h index 26c9c05563..bcc355f893 100644 --- a/cores/esp8266/umm_malloc/umm_malloc_cfg.h +++ b/cores/esp8266/umm_malloc/umm_malloc_cfg.h @@ -106,31 +106,6 @@ extern "C" { #include "umm_malloc_cfgport.h" #endif -#define UMM_BEST_FIT -#define UMM_INFO -// #define UMM_INLINE_METRICS -#define UMM_STATS - -/* - * To support API call, system_show_malloc(), -DUMM_INFO is required. - * - * For the ESP8266 we need an ISR safe function to call for implementing - * xPortGetFreeHeapSize(). We can get this with one of these options: - * 1) -DUMM_STATS or -DUMM_STATS_FULL - * 2) -DUMM_INLINE_METRICS (and implicitly includes -DUMM_INFO) - * - * If frequent calls are made to ESP.getHeapFragmentation(), - * -DUMM_INLINE_METRICS would reduce long periods of interrupts disabled caused - * by frequent calls to `umm_info()`. Instead, the computations get distributed - * across each malloc, realloc, and free. This appears to require an additional - * 116 bytes of IRAM vs using `UMM_STATS` with `UMM_INFO`. - * - * When both UMM_STATS and UMM_INLINE_METRICS are defined, macros and structures - * have been optimized to reduce duplications. - * - */ - - /* A couple of macros to make packing structures less compiler dependent */ #define UMM_H_ATTPACKPRE @@ -177,12 +152,22 @@ extern "C" { #define UMM_FRAGMENTATION_METRIC_REMOVE(c) #endif // UMM_INLINE_METRICS +struct UMM_HEAP_CONTEXT; +typedef struct UMM_HEAP_CONTEXT umm_heap_context_t; + +/* + Must always be defined. Core support for getting free Heap size. + When possible, access via ESP.getFreeHeap(); +*/ +extern size_t umm_free_heap_size_lw(void); +extern size_t umm_free_heap_size_core_lw(umm_heap_context_t *_context); + /* -------------------------------------------------------------------------- */ /* * -D UMM_INFO : * - * Enables a dup of the heap contents and a function to return the total + * Enables a dump of the heap contents and a function to return the total * heap size that is unallocated - note this is not the same as the largest * unallocated block on the heap! */ @@ -209,32 +194,23 @@ typedef struct UMM_HEAP_INFO_t { UMM_HEAP_INFO; // extern UMM_HEAP_INFO ummHeapInfo; -struct UMM_HEAP_CONTEXT; -typedef struct UMM_HEAP_CONTEXT umm_heap_context_t; - extern ICACHE_FLASH_ATTR void *umm_info(void *ptr, bool force); -#ifdef UMM_INLINE_METRICS -extern size_t umm_free_heap_size(void); -#else +#if defined(UMM_STATS) || defined(UMM_STATS_FULL) extern ICACHE_FLASH_ATTR size_t umm_free_heap_size(void); +extern ICACHE_FLASH_ATTR size_t umm_free_heap_size_core(umm_heap_context_t *_context); +#else +extern size_t umm_free_heap_size(void); +extern size_t umm_free_heap_size_core(umm_heap_context_t *_context); #endif + + // umm_max_block_size changed to umm_max_free_block_size in upstream. extern ICACHE_FLASH_ATTR size_t umm_max_block_size(void); extern ICACHE_FLASH_ATTR int umm_usage_metric(void); extern ICACHE_FLASH_ATTR int umm_fragmentation_metric(void); -extern ICACHE_FLASH_ATTR size_t umm_free_heap_size_core(umm_heap_context_t *_context); extern ICACHE_FLASH_ATTR size_t umm_max_block_size_core(umm_heap_context_t *_context); extern ICACHE_FLASH_ATTR int umm_usage_metric_core(umm_heap_context_t *_context); extern ICACHE_FLASH_ATTR int umm_fragmentation_metric_core(umm_heap_context_t *_context); -#else - #define umm_info(p,b) - #define umm_free_heap_size() (0) - #define umm_max_block_size() (0) - #define umm_fragmentation_metric() (0) - #define umm_usage_metric() (0) - #define umm_free_heap_size_core() (0) - #define umm_max_block_size_core() (0) - #define umm_fragmentation_metric_core() (0) #endif /* @@ -305,7 +281,6 @@ UMM_STATISTICS; #define STATS__OOM_UPDATE() _context->UMM_OOM_COUNT += 1 -extern size_t umm_free_heap_size_lw(void); extern size_t umm_get_oom_count(void); #else // not UMM_STATS or UMM_STATS_FULL @@ -643,6 +618,17 @@ extern bool umm_poison_check(void); // Local Additions to better report location in code of the caller. void *umm_poison_realloc_fl(void *ptr, size_t size, const char *file, int line); void umm_poison_free_fl(void *ptr, const char *file, int line); +#define POISON_CHECK_SET_POISON(p, s) get_poisoned(p, s) +#define POISON_CHECK_SET_POISON_BLOCKS(p, s) \ + do { \ + size_t super_size = (s * sizeof(umm_block)) - (sizeof(((umm_block *)0)->header)); \ + get_poisoned(p, super_size); \ + } while (false) +#define UMM_POISON_SKETCH_PTR(p) ((void *)((uintptr_t)p + sizeof(UMM_POISONED_BLOCK_LEN_TYPE) + UMM_POISON_SIZE_BEFORE)) +#define UMM_POISON_SKETCH_PTRSZ(p) (*(UMM_POISONED_BLOCK_LEN_TYPE *)p) +#define UMM_POISON_MEMMOVE(t, p, s) memmove(UMM_POISON_SKETCH_PTR(t), UMM_POISON_SKETCH_PTR(p), UMM_POISON_SKETCH_PTRSZ(p)) +#define UMM_POISON_MEMCPY(t, p, s) memcpy(UMM_POISON_SKETCH_PTR(t), UMM_POISON_SKETCH_PTR(p), UMM_POISON_SKETCH_PTRSZ(p)) + #if defined(UMM_POISON_CHECK_LITE) /* * We can safely do individual poison checks at free and realloc and stay @@ -662,9 +648,12 @@ void umm_poison_free_fl(void *ptr, const char *file, int line); #else #define POISON_CHECK() 1 #define POISON_CHECK_NEIGHBORS(c) do {} while (false) +#define POISON_CHECK_SET_POISON(p, s) (p) +#define POISON_CHECK_SET_POISON_BLOCKS(p, s) +#define UMM_POISON_MEMMOVE(t, p, s) memmove((t), (p), (s)) +#define UMM_POISON_MEMCPY(t, p, s) memcpy((t), (p), (s)) #endif - #if defined(UMM_POISON_CHECK) || defined(UMM_POISON_CHECK_LITE) /* * Overhead adjustments needed for free_blocks to express the number of bytes @@ -720,91 +709,9 @@ struct UMM_TIME_STATS_t { UMM_TIME_STAT id_no_tag; }; #endif -///////////////////////////////////////////////// -#ifdef DEBUG_ESP_OOM - -#define MEMLEAK_DEBUG - -// umm_*alloc are not renamed to *alloc -// Assumes umm_malloc.h has already been included. - -#define umm_zalloc(s) umm_calloc(1,s) - -void *malloc_loc(size_t s, const char *file, int line); -void *calloc_loc(size_t n, size_t s, const char *file, int line); -void *realloc_loc(void *p, size_t s, const char *file, int line); -// *alloc are macro calling *alloc_loc calling+checking umm_*alloc() -// they are defined at the bottom of this file - -///////////////////////////////////////////////// - -#elif defined(UMM_POISON_CHECK) -void *realloc_loc(void *p, size_t s, const char *file, int line); -void free_loc(void *p, const char *file, int line); -#else // !defined(ESP_DEBUG_OOM) -#endif - - - #ifdef __cplusplus } #endif #endif /* _UMM_MALLOC_CFG_H */ - -#ifdef __cplusplus -extern "C" { -#endif -#ifdef DEBUG_ESP_OOM -// this must be outside from "#ifndef _UMM_MALLOC_CFG_H" -// because Arduino.h's does #undef *alloc -// Arduino.h recall us to redefine them -#include -// Reuse pvPort* calls, since they already support passing location information. -// Specifically the debug version (heap_...) that does not force DRAM heap. -void *IRAM_ATTR heap_pvPortMalloc(size_t size, const char *file, int line); -void *IRAM_ATTR heap_pvPortCalloc(size_t count, size_t size, const char *file, int line); -void *IRAM_ATTR heap_pvPortRealloc(void *ptr, size_t size, const char *file, int line); -void *IRAM_ATTR heap_pvPortZalloc(size_t size, const char *file, int line); -void IRAM_ATTR heap_vPortFree(void *ptr, const char *file, int line); - -#define malloc(s) ({ static const char mem_debug_file[] PROGMEM STORE_ATTR = __FILE__; heap_pvPortMalloc(s, mem_debug_file, __LINE__); }) -#define calloc(n,s) ({ static const char mem_debug_file[] PROGMEM STORE_ATTR = __FILE__; heap_pvPortCalloc(n, s, mem_debug_file, __LINE__); }) -#define realloc(p,s) ({ static const char mem_debug_file[] PROGMEM STORE_ATTR = __FILE__; heap_pvPortRealloc(p, s, mem_debug_file, __LINE__); }) - -#if defined(UMM_POISON_CHECK) || defined(UMM_POISON_CHECK_LITE) -#define dbg_heap_free(p) ({ static const char mem_debug_file[] PROGMEM STORE_ATTR = __FILE__; heap_vPortFree(p, mem_debug_file, __LINE__); }) -#else -#define dbg_heap_free(p) free(p) -#endif - -#elif defined(UMM_POISON_CHECK) || defined(UMM_POISON_CHECK_LITE) // #elif for #ifdef DEBUG_ESP_OOM -#include -void *IRAM_ATTR heap_pvPortRealloc(void *ptr, size_t size, const char *file, int line); -#define realloc(p,s) ({ static const char mem_debug_file[] PROGMEM STORE_ATTR = __FILE__; heap_pvPortRealloc(p, s, mem_debug_file, __LINE__); }) - -void IRAM_ATTR heap_vPortFree(void *ptr, const char *file, int line); -// C - to be discussed -/* - Problem, I would like to report the file and line number with the umm poison - event as close as possible to the event. The #define method works for malloc, - calloc, and realloc those names are not as generic as free. A #define free - captures too much. Classes with methods called free are included :( - Inline functions would report the address of the inline function in the .h - not where they are called. - - Anybody know a trick to make this work? - - Create dbg_heap_free() as an alternative for free() when you need a little - more help in debugging the more challenging problems. -*/ -#define dbg_heap_free(p) ({ static const char mem_debug_file[] PROGMEM STORE_ATTR = __FILE__; heap_vPortFree(p, mem_debug_file, __LINE__); }) - -#else -#define dbg_heap_free(p) free(p) -#endif /* DEBUG_ESP_OOM */ - -#ifdef __cplusplus -} -#endif diff --git a/cores/esp8266/umm_malloc/umm_malloc_cfgport.h b/cores/esp8266/umm_malloc/umm_malloc_cfgport.h index 02db6fc66c..233671304f 100644 --- a/cores/esp8266/umm_malloc/umm_malloc_cfgport.h +++ b/cores/esp8266/umm_malloc/umm_malloc_cfgport.h @@ -1,13 +1,9 @@ -#ifndef _UMM_MALLOC_CFGPORT_H -#define _UMM_MALLOC_CFGPORT_H - -#ifndef _UMM_MALLOC_CFG_H -#error "This include file must be used with umm_malloc_cfg.h" -#endif - /* * Arduino ESP8266 core umm_malloc port config */ + +#ifdef _UMM_MALLOC_CFG_H +// Additional includes for "umm_malloc_cfg.h" only #include #include #include "../debug.h" @@ -18,9 +14,20 @@ #include #include "c_types.h" +#endif + + +#ifndef _UMM_MALLOC_CFGPORT_H +#define _UMM_MALLOC_CFGPORT_H /* - * -DUMM_INIT_USE_IRAM + * Between UMM_BEST_FIT or UMM_FIRST_FIT, UMM_BEST_FIT is the better option for + * reducing heap fragmentation. With no selection made, UMM_BEST_FIT is used. + * See umm_malloc_cfg.h for more information. + */ + +/* + * -DUMM_INIT_USE_ICACHE * * Historically, the umm_init() call path has been in IRAM. The umm_init() call * path is now in ICACHE (flash). Use the build option UMM_INIT_USE_IRAM to @@ -30,10 +37,16 @@ * app_entry_redefinable() in core_esp8266_app_entry_noextra4k.cpp for an * example of how to toggle between ICACHE and IRAM in your build. * - * The default is to use ICACHE. + * ~The default is to use ICACHE.~ + * For now revert default back to IRAM + * define UMM_INIT_USE_ICACHE to use ICACHE/IROM */ -// #define UMM_INIT_USE_IRAM 1 - +#ifdef UMM_INIT_USE_ICACHE +#undef UMM_INIT_USE_IRAM +#else +#undef UMM_INIT_USE_IRAM +#define UMM_INIT_USE_IRAM 1 +#endif /* * Start addresses and the size of the heap @@ -87,5 +100,120 @@ extern char _heap_start[]; #define UMM_HEAP_STACK_DEPTH 32 #endif +/* + * The NONOS SDK API requires function `umm_info()` for implementing + * `system_show_malloc()`. Build option `-DUMM_INFO` enables this support. + * + * Also, `-DUMM_INFO` is needed to support several EspClass methods. + * Partial EspClass method list: + * `uint32_t EspClass::getMaxFreeBlockSize()` + * `void EspClass::getHeapStats(uint32_t* hfree, uint32_t* hmax, uint8_t* hfrag)` + * `uint8_t EspClass::getHeapFragmentation()` + * + * The NONOS SDK API requires an ISR safe function to call for implementing + * `xPortGetFreeHeapSize()`. Use one of these options: + * 1) `-DUMM_STATS` or `-DUMM_STATS_FULL` + * 2) `-DUMM_INLINE_METRICS` (implicitly includes `-DUMM_INFO`) + * + * If frequent calls are made to `ESP.getHeapFragmentation()`, using build + * option `-DUMM_INLINE_METRICS` would reduce long periods of interrupts + * disabled caused by frequent calls to `umm_info().` Instead, the computations + * get distributed across each malloc, realloc, and free. Requires approximately + * 116 more bytes of IRAM when compared to the build option `-DUMM_STATS` with + * `-DUMM_INFO.` + * + * When both `-DUMM_STATS` and `-DUMM_INLINE_METRICS` are defined, macros and + * structures are optimized to reduce duplications. + * + * You can use `-DUMM_INFO` with `-DUMM_INLINE_METRICS` and drop + * `-DUMM_STATS(_FULL)` gaining back some IROM at the expense of IRAM. + * + * If you don't require the methods in EspClass that are dependent on functions + * from the `-DUMM_INFO` build option, you can use only `-DUMM_STATS` and save + * on IROM and a little IRAM. + * + */ +#if defined(UMM_STATS) || defined(UMM_STATS_FULL) || defined(UMM_INLINE_METRICS) || defined(UMM_INFO) +/* + User defined via build options eg. Sketch.ino.globals.h +*/ +#else +/* + Set expected/implicit defaults for complete support of EspClass methods. +*/ +#define UMM_INFO 1 +#define UMM_STATS 1 +#endif + +/* + For `-Dname`, gcc assigns a value of 1 and this works fine; however, + if `-Dname=0` is used, the intended results will not be obtained. + + Make value and valueless defines compliant with their usage in umm_malloc: + `#define name` => #define name 1 + `#define name 0` => #undef name +*/ +#if ((1 - UMM_BEST_FIT - 1) == 2) +// When UMM_BEST_FIT is defined w/o value, the computation becomes +// (1 - - 1) == 2 => (1 + 1) == 2 +#undef UMM_BEST_FIT +#define UMM_BEST_FIT 1 +#elif ((1 - UMM_BEST_FIT - 1) == 0) +#undef UMM_BEST_FIT +#endif +#if ((1 - UMM_FIRST_FIT - 1) == 2) +#undef UMM_FIRST_FIT +#define UMM_FIRST_FIT 1 +#elif ((1 - UMM_FIRST_FIT - 1) == 0) +#undef UMM_FIRST_FIT +#endif + +#if ((1 - UMM_INFO - 1) == 2) +#undef UMM_INFO +#define UMM_INFO 1 +#elif ((1 - UMM_INFO - 1) == 0) +#undef UMM_INFO +#endif +#if ((1 - UMM_INLINE_METRICS - 1) == 2) +#undef UMM_INLINE_METRICS +#define UMM_INLINE_METRICS 1 +#elif ((1 - UMM_INLINE_METRICS - 1) == 0) +#undef UMM_INLINE_METRICS +#endif + +#if ((1 - UMM_STATS - 1) == 2) +#undef UMM_STATS +#define UMM_STATS 1 +#elif ((1 - UMM_STATS - 1) == 0) +#undef UMM_STATS +#endif +#if ((1 - UMM_STATS_FULL - 1) == 2) +#undef UMM_STATS_FULL +#define UMM_STATS_FULL 1 +#elif ((1 - UMM_STATS_FULL - 1) == 0) +#undef UMM_STATS_FULL +#endif + + +#if defined(UMM_INLINE_METRICS) +// Dependent on UMM_INFO if missing enable. +#ifndef UMM_INFO +#define UMM_INFO 1 +#endif +#endif + +#if defined(UMM_STATS) || defined(UMM_STATS_FULL) +// We have support for free Heap size +#if defined(UMM_STATS) && defined(UMM_STATS_FULL) +#error "Build option conflict, specify either UMM_STATS or UMM_STATS_FULL." +#endif +#elif defined(UMM_INFO) +// ensure fallback support for free Heap size +#ifndef UMM_INLINE_METRICS +#define UMM_INLINE_METRICS 1 +#endif +#else +#error "Specify at least one of these build options: (UMM_STATS or UMM_STATS_FULL) and/or UMM_INFO and/or UMM_INLINE_METRICS" +#endif #endif diff --git a/cores/esp8266/umm_malloc/umm_poison.c b/cores/esp8266/umm_malloc/umm_poison.c index dc9d5322bf..ca41cabf4f 100644 --- a/cores/esp8266/umm_malloc/umm_poison.c +++ b/cores/esp8266/umm_malloc/umm_poison.c @@ -15,7 +15,7 @@ * If `s` is 0, returns 0. * If result overflows/wraps, return saturation value. */ -static void add_poison_size(size_t* s) { +static void add_poison_size(size_t *s) { if (*s == 0) { return; } @@ -163,8 +163,11 @@ void *umm_poison_malloc(size_t size) { add_poison_size(&size); ret = umm_malloc(size); - - ret = get_poisoned(ret, size); + /* + "get_poisoned" is now called from umm_malloc while still in a critical + section. Before umm_malloc returned, the pointer offset was adjusted to + the start of the requested buffer. + */ return ret; } @@ -177,17 +180,16 @@ void *umm_poison_calloc(size_t num, size_t item_size) { // Use saturated multiply. // Rely on umm_malloc to supply the fail response as needed. size_t size = umm_umul_sat(num, item_size); + size_t request_sz = size; add_poison_size(&size); ret = umm_malloc(size); if (NULL != ret) { - memset(ret, 0x00, size); + memset(ret, 0x00, request_sz); } - ret = get_poisoned(ret, size); - return ret; } @@ -200,8 +202,11 @@ void *umm_poison_realloc(void *ptr, size_t size) { add_poison_size(&size); ret = umm_realloc(ptr, size); - - ret = get_poisoned(ret, size); + /* + "get_poisoned" is now called from umm_realloc while still in a critical + section. Before umm_realloc returned, the pointer offset was adjusted to + the start of the requested buffer. + */ return ret; } diff --git a/cores/esp8266/wpa2_eap_patch.cpp b/cores/esp8266/wpa2_eap_patch.cpp index 4a49cb216c..268c65e7b2 100644 --- a/cores/esp8266/wpa2_eap_patch.cpp +++ b/cores/esp8266/wpa2_eap_patch.cpp @@ -5,12 +5,32 @@ * modules. * */ - #include #include #include #include "coredecls.h" +#if defined(NONOSDK22x_190703) || \ + defined(NONOSDK22x_191122) || \ + defined(NONOSDK22x_191105) || \ + defined(NONOSDK22x_191024) || \ + defined(NONOSDK22x_190313) || \ + defined(NONOSDK221) || \ + defined(NONOSDK305) + +// eap_peer_config_deinit() - For this list of SDKs there are no significant +// changes in the function. Just the line number reference for when vPortFree +// is called. When vPortFree is called, register a12 continues to hold a pointer +// to the struct StateMachine. Our cleanup routine should continue to work. +#if defined(NONOSDK305) + // At v3.0.5 Espressif moved `.text.eap_peer_config_deinit` to + // `eap_peer_config_deinit` then later in latest git they moved it + // back. For our linker script both are placed in flash. + #define SDK_LEAK_LINE 831 +#else + #define SDK_LEAK_LINE 799 +#endif + #ifdef DEBUG_WPA2_EAP_PATCH #include "esp8266_undocumented.h" #define DEBUG_PRINTF ets_uart_printf @@ -100,7 +120,7 @@ struct StateMachine { // size 200 bytes * same line. */ void patch_wpa2_eap_vPortFree_a12(void *ptr, const char* file, int line, void* a12) { - if (799 == line) { + if (SDK_LEAK_LINE == line) { // This caller is eap_peer_config_deinit() struct StateMachine* sm = (struct StateMachine*)a12; if (ptr == sm->config[0]) { @@ -126,21 +146,38 @@ void patch_wpa2_eap_vPortFree_a12(void *ptr, const char* file, int line, void* a } #endif } -#if 0 - // This is not needed because the call was NO-OPed in the library. This code - // snippit is just to show how a future memory free issue might be resolved. - else if (672 == line) { + +#if defined(NONOSDK300) || defined(NONOSDK301) + else if (682 == line) { // This caller is wpa2_sm_rx_eapol() // 1st of a double free // let the 2nd free handle it. return; } +#elif defined(NONOSDK302) || defined(NONOSDK303) || defined(NONOSDK304) || defined(NONOSDK305) + // It looks like double free is fixed. WPA2 Enterpise connections work + // without crashing. wpa2_sm_rx_eapol() has a few changes between NONOSDK301 + // and NONOSDK302. However, this set of releases still have memory leaks. +#else + // This is not needed because the call was NO-OPed in the library. + // Keep code snippit for reference. + // else if (672 == line) { + // // This caller is wpa2_sm_rx_eapol() + // // 1st of a double free + // // let the 2nd free handle it. + // return; + // } #endif vPortFree(ptr, file, line); } }; +#else +#error "Internal error: A new SDK has been added. This module must be updated." +#error " Need to test WPA2 Enterpise connectivity." +#endif + /* * This will minimize code space for non-wifi enterprise sketches which do not * need the patch and disable_extra4k_at_link_time(). diff --git a/doc/Makefile b/doc/Makefile index 36b4923488..61d3e40b3c 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -2,7 +2,7 @@ # # You can set these variables from the command line. -SPHINXOPTS = +SPHINXOPTS = --fail-on-warning --nitpicky SPHINXBUILD = sphinx-build SPHINXPROJ = ESP8266ArduinoCore SOURCEDIR = . @@ -17,4 +17,4 @@ help: # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/doc/Troubleshooting/stack_dump.rst b/doc/Troubleshooting/stack_dump.rst index c977fce56d..ef320392e7 100644 --- a/doc/Troubleshooting/stack_dump.rst +++ b/doc/Troubleshooting/stack_dump.rst @@ -12,42 +12,42 @@ Example: Exception (0): epc1=0x402103f4 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000 - ctx: sys + ctx: sys sp: 3ffffc10 end: 3fffffb0 offset: 01a0 >>>stack>>> - 3ffffdb0: 40223e00 3fff6f50 00000010 60000600 - 3ffffdc0: 00000001 4021f774 3fffc250 4000050c - 3ffffdd0: 400043d5 00000030 00000016 ffffffff - 3ffffde0: 400044ab 3fffc718 3ffffed0 08000000 - 3ffffdf0: 60000200 08000000 00000003 00000000 - 3ffffe00: 0000ffff 00000001 04000002 003fd000 - 3ffffe10: 3fff7188 000003fd 3fff2564 00000030 - 3ffffe20: 40101709 00000008 00000008 00000020 - 3ffffe30: c1948db3 394c5e70 7f2060f2 c6ba0c87 - 3ffffe40: 3fff7058 00000001 40238d41 3fff6ff0 - 3ffffe50: 3fff6f50 00000010 60000600 00000020 - 3ffffe60: 402301a8 3fff7098 3fff7014 40238c77 - 3ffffe70: 4022fb6c 40230ebe 3fff1a5b 3fff6f00 - 3ffffe80: 3ffffec8 00000010 40231061 3fff0f90 - 3ffffe90: 3fff6848 3ffed0c0 60000600 3fff6ae0 - 3ffffea0: 3fff0f90 3fff0f90 3fff6848 3fff6d40 - 3ffffeb0: 3fff28e8 40101233 d634fe1a fffeffff - 3ffffec0: 00000001 00000000 4022d5d6 3fff6848 - 3ffffed0: 00000002 4000410f 3fff2394 3fff6848 - 3ffffee0: 3fffc718 40004a3c 000003fd 3fff7188 - 3ffffef0: 3fffc718 40101510 00000378 3fff1a5b - 3fffff00: 000003fd 4021d2e7 00000378 000003ff - 3fffff10: 00001000 4021d37d 3fff2564 000003ff - 3fffff20: 000003fd 60000600 003fd000 3fff2564 - 3fffff30: ffffff00 55aa55aa 00000312 0000001c - 3fffff40: 0000001c 0000008a 0000006d 000003ff - 3fffff50: 4021d224 3ffecf90 00000000 3ffed0c0 - 3fffff60: 00000001 4021c2e9 00000003 3fff1238 - 3fffff70: 4021c071 3ffecf84 3ffecf30 0026a2b0 - 3fffff80: 4021c0b6 3fffdab0 00000000 3fffdcb0 - 3fffff90: 3ffecf40 3fffdab0 00000000 3fffdcc0 - 3fffffa0: 40000f49 40000f49 3fffdab0 40000f49 + 3ffffdb0: 40223e00 3fff6f50 00000010 60000600 + 3ffffdc0: 00000001 4021f774 3fffc250 4000050c + 3ffffdd0: 400043d5 00000030 00000016 ffffffff + 3ffffde0: 400044ab 3fffc718 3ffffed0 08000000 + 3ffffdf0: 60000200 08000000 00000003 00000000 + 3ffffe00: 0000ffff 00000001 04000002 003fd000 + 3ffffe10: 3fff7188 000003fd 3fff2564 00000030 + 3ffffe20: 40101709 00000008 00000008 00000020 + 3ffffe30: c1948db3 394c5e70 7f2060f2 c6ba0c87 + 3ffffe40: 3fff7058 00000001 40238d41 3fff6ff0 + 3ffffe50: 3fff6f50 00000010 60000600 00000020 + 3ffffe60: 402301a8 3fff7098 3fff7014 40238c77 + 3ffffe70: 4022fb6c 40230ebe 3fff1a5b 3fff6f00 + 3ffffe80: 3ffffec8 00000010 40231061 3fff0f90 + 3ffffe90: 3fff6848 3ffed0c0 60000600 3fff6ae0 + 3ffffea0: 3fff0f90 3fff0f90 3fff6848 3fff6d40 + 3ffffeb0: 3fff28e8 40101233 d634fe1a fffeffff + 3ffffec0: 00000001 00000000 4022d5d6 3fff6848 + 3ffffed0: 00000002 4000410f 3fff2394 3fff6848 + 3ffffee0: 3fffc718 40004a3c 000003fd 3fff7188 + 3ffffef0: 3fffc718 40101510 00000378 3fff1a5b + 3fffff00: 000003fd 4021d2e7 00000378 000003ff + 3fffff10: 00001000 4021d37d 3fff2564 000003ff + 3fffff20: 000003fd 60000600 003fd000 3fff2564 + 3fffff30: ffffff00 55aa55aa 00000312 0000001c + 3fffff40: 0000001c 0000008a 0000006d 000003ff + 3fffff50: 4021d224 3ffecf90 00000000 3ffed0c0 + 3fffff60: 00000001 4021c2e9 00000003 3fff1238 + 3fffff70: 4021c071 3ffecf84 3ffecf30 0026a2b0 + 3fffff80: 4021c0b6 3fffdab0 00000000 3fffdcb0 + 3fffff90: 3ffecf40 3fffdab0 00000000 3fffdcc0 + 3fffffa0: 40000f49 40000f49 3fffdab0 40000f49 <<`__ tool. +It's possible to decode the Stack to readable information. +You can get a copy and read about the `Esp Exception Decoder `__ tool. + +For a troubleshooting example using the Exception Decoder Tool, read `FAQ: My ESP Crashes <../faq/a02-my-esp-crashes.rst#exception-decoder>`__. .. figure:: ESP_Exception_Decoderp.png :alt: ESP Exception Decoder diff --git a/doc/boards.rst b/doc/boards.rst index 5721fab624..99421d86b9 100644 --- a/doc/boards.rst +++ b/doc/boards.rst @@ -39,25 +39,30 @@ Minimal Hardware Setup for Bootloading and Usage +-----------------+------------+------------------+ | GND | | GND | +-----------------+------------+------------------+ -| TX or GPIO2\* | | RX | +| TX or GPIO2 | | | +| [#tx_or_gpio2]_ | RX | | +-----------------+------------+------------------+ | RX | | TX | +-----------------+------------+------------------+ | GPIO0 | PullUp | DTR | +-----------------+------------+------------------+ -| Reset\* | PullUp | RTS | +| Reset | | | +| [#reset]_ | PullUp | RTS | +-----------------+------------+------------------+ -| GPIO15\* | PullDown | | +| GPIO15 | | | +| [#gpio15]_ | PullDown | | +-----------------+------------+------------------+ -| CH\_PD | PullUp | | +| CH\_PD | | | +| [#ch_pd]_ | PullUp | | +-----------------+------------+------------------+ -- Note -- GPIO15 is also named MTDO -- Reset is also named RSBT or REST (adding PullUp improves the +.. rubric:: Notes + +.. [#tx_or_gpio2] GPIO15 is also named MTDO +.. [#reset] Reset is also named RSBT or REST (adding PullUp improves the stability of the module) -- GPIO2 is alternative TX for the boot loader mode -- **Directly connecting a pin to VCC or GND is not a substitute for a +.. [#gpio15] GPIO2 is alternative TX for the boot loader mode +.. [#ch_pd] **Directly connecting a pin to VCC or GND is not a substitute for a PullUp or PullDown resistor, doing this can break upload management and the serial console, instability has also been noted in some cases.** @@ -88,15 +93,16 @@ ESPxx Hardware +---------------+------------+------------------+ | GPIO0 | | GND | +---------------+------------+------------------+ -| Reset | | RTS\* | +| Reset | | RTS [#rts]_ | +---------------+------------+------------------+ | GPIO15 | PullDown | | +---------------+------------+------------------+ | CH\_PD | PullUp | | +---------------+------------+------------------+ -- Note -- if no RTS is used a manual power toggle is needed +.. rubric:: Notes + +.. [#rts] if no RTS is used a manual power toggle is needed Minimal Hardware Setup for Running only ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -176,7 +182,11 @@ rst cause boot mode ~~~~~~~~~ -the first value respects the pin setup of the Pins 0, 2 and 15. +the first value respects the pin setup of the Pins 0, 2 and 15 + +.. code-block:: + + Number = (GPIO15 << 2) | (GPIO0 << 1) | GPIO2 +----------+----------+---------+---------+-------------+ | Number | GPIO15 | GPIO0 | GPIO2 | Mode | @@ -198,7 +208,6 @@ the first value respects the pin setup of the Pins 0, 2 and 15. | 7 | 3.3V | 3.3V | 3.3V | SDIO | +----------+----------+---------+---------+-------------+ -note: - number = ((GPIO15 << 2) \| (GPIO0 << 1) \| GPIO2); Generic ESP8285 Module ---------------------- @@ -262,6 +271,13 @@ ESPresso Lite 2.0 ESPresso Lite 2.0 is an Arduino-compatible Wi-Fi development board based on an earlier V1 (beta version). Re-designed together with Cytron Technologies, the newly-revised ESPresso Lite V2.0 features the auto-load/auto-program function, eliminating the previous need to reset the board manually before flashing a new program. It also feature two user programmable side buttons and a reset button. The special distinctive features of on-board pads for I2C sensor and actuator is retained. +Mercury 1.0 +----------- + +Based on ESP8266, Mercury is board developed by Ralio Technologies. Board supports on motor drivers and direct-connect feature for various endpoints. + +Product page: https://www.raliotech.com + Phoenix 1.0 ----------- @@ -351,6 +367,11 @@ LOLIN(WEMOS) D1 R2 & mini Product page: https://www.wemos.cc/ +LOLIN(WEMOS) D1 ESP-WROOM-02 +---------------------------- + +No real product pages. See: https://www.instructables.com/How-to-Use-Wemos-ESP-Wroom-02-D1-Mini-WiFi-Module-/ or https://www.arduino-tech.com/wemos-esp-wroom-02-mainboard-d1-mini-wifi-module-esp826618650-battery/ + LOLIN(WEMOS) D1 mini (clone) ---------------------------- @@ -408,14 +429,10 @@ ThaiEasyElec's ESPino ESPino by ThaiEasyElec using WROOM-02 module from Espressif Systems with 4 MB Flash. -We will update an English description soon. - Product page: -http://thaieasyelec.com/products/wireless-modules/wifi-modules/espino-wifi-development-board-detail.html -- Schematics: -www.thaieasyelec.com/downloads/ETEE052/ETEE052\_ESPino\_Schematic.pdf - -Dimensions: -http://thaieasyelec.com/downloads/ETEE052/ETEE052\_ESPino\_Dimension.pdf -- Pinouts: -http://thaieasyelec.com/downloads/ETEE052/ETEE052\_ESPino\_User\_Manual\_TH\_v1\_0\_20160204.pdf (Please see pg. 8) +* Product page (retired product): https://www.thaieasyelec.com/product/%E0%B8%A2%E0%B8%81%E0%B9%80%E0%B8%A5%E0%B8%B4%E0%B8%81%E0%B8%88%E0%B8%B3%E0%B8%AB%E0%B8%99%E0%B9%88%E0%B8%B2%E0%B8%A2-retired-espino-wifi-development-board/11000833173001086 +* Schematics: https://downloads.thaieasyelec.com/ETEE052/ETEE052\_ESPino\_Schematic.pdf +* Dimensions: https://downloads.thaieasyelec.com/ETEE052/ETEE052\_ESPino\_Dimension.pdf +* Pinouts (Please see pg.8): https://downloads.thaieasyelec.com/ETEE052/ETEE052\_ESPino\_User\_Manual\_TH\_v1\_0\_20160204.pdf WifInfo ------- diff --git a/doc/conf.py b/doc/conf.py index 3b05ae5617..0eef82bc24 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -66,12 +66,12 @@ # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = 'en' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] +exclude_patterns = ['_venv', '_build', 'Thumbs.db', '.DS_Store'] # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' @@ -162,11 +162,7 @@ # # on_rtd is whether we are on readthedocs.org env_readthedocs = os.environ.get('READTHEDOCS', None) -print(env_readthedocs) if not env_readthedocs: # only import and set the theme if we're building docs locally import sphinx_rtd_theme html_theme = 'sphinx_rtd_theme' - html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] - - diff --git a/doc/esp8266wifi/client-class.rst b/doc/esp8266wifi/client-class.rst index 11e412181e..19bc3e660f 100644 --- a/doc/esp8266wifi/client-class.rst +++ b/doc/esp8266wifi/client-class.rst @@ -29,6 +29,36 @@ Default input value 0 means that effective value is left at the discretion of th ``stop()`` returns ``false`` in case of an issue when closing the client (for instance a timed-out ``flush``). Depending on implementation, its parameter can be passed to ``flush()``. +abort +~~~~~ + +.. code:: cpp + + void abort(); + + +Originally proposed in `#8738 `__ +Unlike ``stop()``, immediately shuts down internal connection object. + +Under usual circumstances, we either enter ``CLOSE_WAIT`` or ``TIME_WAIT`` state. But, the connection object is not freed right away, and requires us to either +* wait until ``malloc()`` returns ``NULL`` when our TCP stack tries to allocate memory for a new connection +* manually call ``tcp_kill_timewait()`` to forcibly stop the 'oldest' connection + +This API frees up resources used by the connection. Consider using it instead of ``stop()`` if your application handles a lot of clients and frequently runs out of available heap memory. + +*Example:* + +.. code:: cpp + + # define MIN_HEAP_FREE 20000 // or whatever min available heap memory convienent for your application + auto client = server.accept(); + // ... do something with the client object ... + if (ESP.getFreeHeap() >= MIN_HEAP_FREE) { + client.stop(); + } else { + client.abort(); + } + setNoDelay ~~~~~~~~~~ diff --git a/doc/esp8266wifi/generic-class.rst b/doc/esp8266wifi/generic-class.rst index db844b08be..f722bff3af 100644 --- a/doc/esp8266wifi/generic-class.rst +++ b/doc/esp8266wifi/generic-class.rst @@ -227,7 +227,11 @@ Other Function Calls bool enableAP (bool enable) int hostByName (const char *aHostname, IPAddress &aResult) - appeared with SDK pre-V3: + +Also, when using NONOS SDK v3: + +.. code:: cpp + uint8_t getListenInterval (); bool isSleepLevelMax (); diff --git a/doc/esp8266wifi/generic-examples.rst b/doc/esp8266wifi/generic-examples.rst index bbac0cd839..98ccf6c47b 100644 --- a/doc/esp8266wifi/generic-examples.rst +++ b/doc/esp8266wifi/generic-examples.rst @@ -38,23 +38,39 @@ Register the Events To get events to work we need to complete just two steps: -1. Declare the event handler: +1. Declare the event handler in global scope. -``cpp WiFiEventHandler disconnectedEventHandler;`` +.. code-block:: cpp -2. Select particular event (in this case ``onStationModeDisconnected``) - and add the code to be executed when event is fired. + WiFiEventHandler disconnectedEventHandler; -``cpp disconnectedEventHandler = WiFi.onStationModeDisconnected([](const WiFiEventStationModeDisconnected& event) { Serial.println("Station disconnected"); });`` If this event is fired the code will print out information that station has been disconnected. +Alternatively, it can be declared as ``static`` in both function and global scopes. -That's it. It is all we need to do. + +2. Select particular event (in this case ``onStationModeDisconnected``). + When this event is fired the code will print out information that station has been disconnected: + +.. code-block:: cpp + + disconnectedEventHandler = WiFi.onStationModeDisconnected( + [](auto&& event) { + Serial.println("Station disconnected"); + }); + +3. Disable ``disconnectedEventHandler``, so the event is no longer handled by our callback: + +.. code-block:: cpp + + disconnectedEventHandler = nullptr; + +Take note that lifetime of the callback handler is up to the app. e.g. if ``onStationModeDisconnected`` is declared in the function scope, it would be discarded immediately after the function exits. The Code ~~~~~~~~ The complete code, including both methods discussed at the beginning, is provided below. -.. code:: cpp +.. code-block:: cpp #include diff --git a/doc/esp8266wifi/scan-class.rst b/doc/esp8266wifi/scan-class.rst index eb94de8aad..4629a97a94 100644 --- a/doc/esp8266wifi/scan-class.rst +++ b/doc/esp8266wifi/scan-class.rst @@ -236,3 +236,29 @@ The ``networkItem`` is a zero based index of network discovered during scan. All 6: UPC Wi-Free, Ch:11 (-79dBm) For code samples please refer to separate section with `examples `__ dedicated specifically to the Scan Class. + +getScanInfoByIndex +^^^^^^^^^^^^^^^^^^ + +Similar to the ``getNetworkInfo``, but instead returns a pointer to the Nth ``bss_info`` structure which is internally used by the NONOS SDK. + +.. code:: cpp + + WiFi.getScanInfoByIndex(networkItem) + +The ``networkItem`` is a zero based index of network discovered during scan. Function will return ``nullptr`` when ``networkItem`` is greater than the number of networks in the scan result or when there are no scan results available. + +.. code:: cpp + + auto n = WiFi.scanNetworks(false, true); + if (n <= 0) { + // scan failed or there are no results + return; + } + + for (int i = 0; i < n; i++) + const auto* info = WiFi.getScanInfoByIndex(i) + // ... use the raw data from the bss_info structure ... + } + +See ``tools/sdk/include/user_interface.h`` for all available fields and `examples `__. diff --git a/doc/esp8266wifi/scan-examples.rst b/doc/esp8266wifi/scan-examples.rst index 4ad4777507..d05d258f72 100644 --- a/doc/esp8266wifi/scan-examples.rst +++ b/doc/esp8266wifi/scan-examples.rst @@ -1,5 +1,11 @@ :orphan: +IDE example +^^^^^^^^^^^ + +- For the currently installed Core, see Arduino IDE > *Examples* > *ESP8266WiFi* > *WiFiScan*. +- For the latest development version, see `WiFiScan.ino `__. + Scan ~~~~ diff --git a/doc/esp8266wifi/server-class.rst b/doc/esp8266wifi/server-class.rst index 8b8bc0e6c1..8bcce99944 100644 --- a/doc/esp8266wifi/server-class.rst +++ b/doc/esp8266wifi/server-class.rst @@ -18,6 +18,11 @@ For most use cases the basic WiFiServer class of the ESP8266WiFi library is suit Methods and properties described further down are specific to ESP8266. They are not covered in `Arduino WiFi library `__ documentation. Before they are fully documented please refer to information below. +begin(port) +~~~~~~~~~~~ + +Additionally to ``begin()`` without parameter and a constructor with parameter ``port``, ESP8266WiFi library has ``begin(uint16_t port)`` and a constructor without parameters. If port is not specified with constructor and ``begin`` without parameter is used, the server is started on port 23. + accept ~~~~~~ diff --git a/doc/esp8266wifi/server-examples.rst b/doc/esp8266wifi/server-examples.rst index cbe5c1abf7..c10b5f7eba 100644 --- a/doc/esp8266wifi/server-examples.rst +++ b/doc/esp8266wifi/server-examples.rst @@ -16,7 +16,6 @@ Table of Contents - `The Page is Served <#the-page-is-served>`__ - `Get it Together <#put-it-together>`__ - `Get it Run <#get-it-run>`__ -- `What Else? <#what-else>`__ - `Conclusion <#conclusion>`__ The Object diff --git a/doc/esp8266wifi/soft-access-point-examples.rst b/doc/esp8266wifi/soft-access-point-examples.rst index c4cf39c6c2..2c9fee762c 100644 --- a/doc/esp8266wifi/soft-access-point-examples.rst +++ b/doc/esp8266wifi/soft-access-point-examples.rst @@ -79,7 +79,9 @@ Sketch is small so analysis shouldn't be difficult. In first line we are includi Setting up of the access point ``ESPsoftAP_01`` is done by executing: -``cpp boolean result = WiFi.softAP("ESPsoftAP_01", "pass-to-soft-AP");`` +.. code:: cpp + + boolean result = WiFi.softAP("ESPsoftAP_01", "pass-to-soft-AP"); If this operation is successful then ``result`` will be ``true`` or ``false`` if otherwise. Basing on that either ``Ready`` or ``Failed!`` will be printed out by the following ``if - else`` conditional statement. diff --git a/doc/esp8266wifi/station-class.rst b/doc/esp8266wifi/station-class.rst index 787de49684..06e072adc6 100644 --- a/doc/esp8266wifi/station-class.rst +++ b/doc/esp8266wifi/station-class.rst @@ -7,6 +7,8 @@ The number of features provided by ESP8266 in the station mode is far more exten Description of station class has been broken down into four parts. First discusses methods to establish connection to an access point. Second provides methods to manage connection like e.g. ``reconnect`` or ``isConnected``. Third covers properties to obtain information about connection like MAC or IP address. Finally the fourth section provides alternate methods to connect like e.g. Wi-Fi Protected Setup (WPS). +An effort to unify such network device class accross several Arduino core implementations has been made. Recommandations are located at `Arduino-Networking-API `__ and tested with `NetApiHelpers `__. Esp8266 Arduino core's station class is also following these guidelines. + Table of Contents ----------------- @@ -97,8 +99,12 @@ config Disable `DHCP `__ client (Dynamic Host Configuration Protocol) and set the IP configuration of station interface to user defined arbitrary values. The interface will be a static IP configuration instead of values provided by DHCP. +Note that to reenable DHCP, all three parameters (local_ip, gateway and subnet) as IPv4 ``0U`` (= 0.0.0.0) must be passed back to config() and re-connecting is needed. + .. code:: cpp + WiFi.config(local_ip, gateway, subnet) (for Arduino API portability, discouraged as chosen defaults may not match the local network configuration) + WiFi.config(local_ip, gateway, subnet, dns1) WiFi.config(local_ip, gateway, subnet, dns1, dns2) Function will return ``true`` if configuration change is applied successfully. If configuration can not be applied, because e.g. module is not in station or station + soft access point mode, then ``false`` will be returned. @@ -116,6 +122,21 @@ The following IP configuration may be provided: (like e.g. *www.google.co.uk*) and translate them for us to IP addresses +For Arduino networking API compatibility, the ESP8266WiFi library supports IPv4-only additional versions of the ``config`` function: + +.. code:: cpp + + WiFi.config(local_ip) (for Arduino API portability, discouraged as chosen defaults may not match the local network configuration) + WiFi.config(local_ip, dns) (for Arduino API portability, discouraged as chosen defaults may not match the local network configuration) + WiFi.config(local_ip, dns, gateway) (for Arduino API portability, discouraged as chosen defaults may not match the local network configuration) + WiFi.config(local_ip, dns, gateway, subnet) + +Versions where some of ``dns``, ``gateway`` and ``subnet`` parameters are not specified use a default value. Default ``subnet`` is 255.255.255.0. Default ``gateway`` and ``dns`` are derived from ``local_ip`` by changing the last number to 1. It is discouraged to use these default values as they may not apply to every network configuration. + +Reminder : To reenable DHCP you can use ``WiFi.config(0U, 0U, 0U);``. + +**Warning: The default values for dns, gateway and subnet may not match your router's settings.** Also please note, that ``config(local_ip, gateway)`` is not supported and ``WiFi.config(local_ip, gateway, subnet)`` doesn't set the DNS server IP. + *Example code:* .. code:: cpp @@ -157,8 +178,7 @@ The following IP configuration may be provided: . Connected, IP address: 192.168.1.22 -Please note that station with static IP configuration usually connects to the network faster. In the above example it took about 500ms (one dot `.` displayed). This is because obtaining of IP configuration by DHCP client takes time and in this case this step is skipped. If you pass all three parameter as 0.0.0.0 (local_ip, gateway and subnet), it will re enable DHCP. You need to re-connect the device to get new IPs. - +Please note that station with static IP configuration usually connects to the network faster. In the above example it took about 500ms (one dot `.` displayed). This is because obtaining of IP configuration by DHCP client takes time and in this case this step is skipped. Reminder: If you pass all three parameters as 0.0.0.0 (local_ip, gateway and subnet), it will re enable DHCP. You need to re-connect the device to get new IPs. Manage Connection ~~~~~~~~~~~~~~~~~ @@ -453,7 +473,7 @@ Function returns one of the following connection statuses: - ``WL_IDLE_STATUS`` when Wi-Fi is in process of changing between statuses - ``WL_DISCONNECTED`` if module is not configured in station mode -Returned value is type of ``wl_status_t`` defined in `wl\_definitions.h `__ +Returned value is type of ``wl_status_t`` defined in `wl\_definitions.h `__ *Example code:* @@ -491,7 +511,7 @@ Returned value is type of ``wl_status_t`` defined in `wl\_definitions.h `__ as follows: +Particular connection statuses 6 and 3 may be looked up in `wl\_definitions.h `__ as follows: :: diff --git a/doc/esp8266wifi/udp-class.rst b/doc/esp8266wifi/udp-class.rst index 5e02f7b3da..73a9086021 100644 --- a/doc/esp8266wifi/udp-class.rst +++ b/doc/esp8266wifi/udp-class.rst @@ -26,11 +26,11 @@ Multicast UDP .. code:: cpp - uint8_t beginMulticast (IPAddress interfaceAddr, IPAddress multicast, uint16_t port) + uint8_t beginMulticast (IPAddress multicast, uint16_t port) virtual int beginPacketMulticast (IPAddress multicastAddress, uint16_t port, IPAddress interfaceAddress, int ttl=1) IPAddress destinationIP () uint16_t localPort () -The ``WiFiUDP`` class supports sending and receiving multicast packets on STA interface. When sending a multicast packet, replace ``udp.beginPacket(addr, port)`` with ``udp.beginPacketMulticast(addr, port, WiFi.localIP())``. When listening to multicast packets, replace ``udp.begin(port)`` with ``udp.beginMulticast(WiFi.localIP(), multicast_ip_addr, port)``. You can use ``udp.destinationIP()`` to tell whether the packet received was sent to the multicast or unicast address. +The ``WiFiUDP`` class supports sending and receiving multicast packets on STA interface. When sending a multicast packet, replace ``udp.beginPacket(addr, port)`` with ``udp.beginPacketMulticast(addr, port, WiFi.localIP())``. When listening to multicast packets, replace ``udp.begin(port)`` with ``udp.beginMulticast(multicast_ip_addr, port)``. You can use ``udp.destinationIP()`` to tell whether the packet received was sent to the multicast or unicast address. For code samples please refer to separate section with `examples `__ dedicated specifically to the UDP Class. diff --git a/doc/faq/a01-espcomm_sync-failed.rst b/doc/faq/a01-espcomm_sync-failed.rst index df4d0aa177..d47a5d2eeb 100644 --- a/doc/faq/a01-espcomm_sync-failed.rst +++ b/doc/faq/a01-espcomm_sync-failed.rst @@ -9,7 +9,7 @@ I am getting "espcomm\_sync failed" error when trying to upload my ESP. How to r - `Reset Methods <#reset-methods>`__ - `Ck <#ck>`__ - `Nodemcu <#nodemcu>`__ -- `I'm Stuck <#im-stuck>`__ +- `I'm Stuck <#i-m-stuck>`__ - `Conclusion <#conclusion>`__ Introduction diff --git a/doc/faq/a02-my-esp-crashes.rst b/doc/faq/a02-my-esp-crashes.rst index 1fcc2cbaa8..ec6340e8c7 100644 --- a/doc/faq/a02-my-esp-crashes.rst +++ b/doc/faq/a02-my-esp-crashes.rst @@ -5,12 +5,13 @@ My ESP crashes running some code. How to troubleshoot it? - `Introduction <#introduction>`__ - `What ESP has to Say <#what-esp-has-to-say>`__ -- `Get Your H/W Right <#get-your-hw-right>`__ +- `Get Your H/W Right <#get-your-h-w-right>`__ - `Enable compilation warnings <#enable-compilation-warnings>`__ - `What is the Cause of Restart? <#what-is-the-cause-of-restart>`__ - `Exception <#exception>`__ - `Watchdog <#watchdog>`__ - `Exception Decoder <#exception-decoder>`__ +- `Improving Exception Decoder Results <#improving-exception-decoder-results>`__ - `Other Common Causes for Crashes <#other-causes-for-crashes>`__ - `If at the Wall, Enter an Issue Report <#if-at-the-wall-enter-an-issue-report>`__ @@ -147,8 +148,8 @@ table to understand what kind of issue it is. If you have no clues what it's about and where it happens, then use `Arduino ESP8266/ESP32 Exception Stack Trace Decoder `__ to find -out in which line of application it is triggered. Please refer to `Check -Where the Code Crashes <#check-where-the-code-crashes>`__ point below +out in which line of application it is triggered. Please refer to +`Exception decoder <#exception-decoder>`__ point below for a quick example how to do it. **NOTE:** When decoding exceptions be sure to include all lines between @@ -236,6 +237,7 @@ If you don't have any code for troubleshooting, use the example below: void loop(){} + Enable the Out-Of-Memory (*OOM*) debug option (in the *Tools > Debug Level* menu), compile/flash/upload this code to your ESP (Ctrl+U) and start Serial Monitor (Ctrl+Shift+M). You should shortly see ESP restarting every couple @@ -270,31 +272,92 @@ Decoder `__ you can track down where the module is crashing whenever you see the stack trace dropped. The same procedure applies to crashes caused by exceptions. - Note: To decode the exact line of code where the application + Note, to decode the exact line of code where the application crashed, you need to use ESP Exception Decoder in context of sketch you have just loaded to the module for diagnosis. Decoder is not able to correctly decode the stack trace dropped by some other application not compiled and loaded from your Arduino IDE. +Improving Exception Decoder Results +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Due to the limited resources on the device, our default compiler optimizations +focus on creating the smallest code size (``.bin`` file). The GCC compiler's +option ``-Os`` contains the base set of optimizations used. This set is fine for +release but not ideal for debugging. + +Our view of a crash is often the `Stack Dump <../Troubleshooting/stack_dump.rst>`__ +which gets copy/pasted into an Exception Decoder. +For some situations, the optimizer doesn't write caller return addresses to the +stack. When we crash, the list of functions called is missing. And when the +crash occurs in a leaf function, there is seldom if ever any evidence of who +called. + +With the ``-Os`` option, functions called once are inlined into the calling +function. A chain of these functions can optimize down to the calling function. +When the crash occurs in one of these chain functions, the actual location in +the source code is no longer available. + +When you select ``Debug Optimization: Lite`` on the Arduino IDE Tools menu, it +turns off ``optimize-sibling-calls``. Turning off this optimization allows more +caller addresses to be written to the stack, improving the results from the +Exception Decoder. Without this option, the callers involved in the crash may be +missing from the Decoder results. Because of the limited stack space, there is +the remote possibility that removing this optimization could lead to more +frequent stack overflows. You only want to do this in a debug setting. This +option does not help the chained function issue. + +When you select ``Debug Optimization: Optimum``, you get an even more complete +stack trace. For example, chained function calls may show up. This selection +uses the compiler option ``-Og``. GCC considers this the ideal optimization for +the "edit-compile-debug cycle" ... "producing debuggable code." You can read the +specifics at `GCC's Optimize Options `__ + +When global optimization creates build size issues or stack overflow issues, +select ``Debug Optimization: None``, and use a targeted approach with +``#pragma GCC optimize("Og")`` at the module level. Or, if you want to use a +different set of optimizations, you can set optimizations through build options. +Read more at `Global Build Options `__. + +For non-Arduino IDE build platforms, you may need to research how to add build +options. Some build platforms already use ``-Og`` for debug builds. + +A crash in a leaf function may not leave the caller's address on the stack. +The return address can stay in a register for the duration of the call. +Resulting in a crash report identifying the crashing function without a +trace of who called. You can encourage the compiler to save the caller's +return address by adding an inline assembly trick +``__asm__ __volatile__("" ::: "a0", "memory");`` at the beginning of the +function's body. Or instead, for a debug build conditional option, use the +macro ``DEBUG_LEAF_FUNCTION()`` from ``#include ``. For compiler +toolchain 3.2.0 and above, the ``-Og`` option is an alternative solution. + +In some cases, adding ``#pragma GCC optimize("Og,no-ipa-pure-const")`` to a +module as well as using ``DEBUG_LEAF_FUNCTION()`` in a leaf function were +needed to display a complete call chain. Or use +``#pragma GCC optimize("Os,no-inline,no-optimize-sibling-calls,no-ipa-pure-const")`` +if you require optimization ``-Os``. + + Other Causes for Crashes ~~~~~~~~~~~~~~~~~~~~~~~~ Interrupt Service Routines - By default, all functions are compiled into flash, which means that the - cache may kick in for that code. However, the cache currently can't be used - during hardware interrupts. That means that, if you use a hardware ISR, such as - attachInterrupt(gpio, myISR, CHANGE) for a GPIO change, the ISR must have the - IRAM_ATTR attribute declared. Not only that, but the entire function tree + By default, all functions are compiled into flash, which means that the + cache may kick in for that code. However, the cache currently can't be used + during hardware interrupts. That means that, if you use a hardware ISR, such as + attachInterrupt(gpio, myISR, CHANGE) for a GPIO change, the ISR must have the + IRAM_ATTR attribute declared. Not only that, but the entire function tree called from the ISR must also have the IRAM_ATTR declared. Be aware that every function that has this attribute reduces available memory. - In addition, it is not possible to execute delay() or yield() from an ISR, + In addition, it is not possible to execute delay() or yield() from an ISR, or do blocking operations, or operations that disable the interrupts, e.g.: read a DHT. Finally, an ISR has very high restrictions on timing for the executed code, meaning - that executed code should not take longer than a very few microseconds. It is + that executed code should not take longer than a very few microseconds. It is considered best practice to set a flag within the ISR, and then from within the loop() check and clear that flag, and execute code. @@ -303,7 +366,7 @@ Asynchronous Callbacks than ISRs, but some restrictions still apply. It is not possible to execute delay() or yield() from an asynchronous callback. Timing is not as tight as an ISR, but it should remain below a few milliseconds. This - is a guideline. The hard timing requirements depend on the WiFi configuration and + is a guideline. The hard timing requirements depend on the WiFi configuration and amount of traffic. In general, the CPU must not be hogged by the user code, as the longer it is away from servicing the WiFi stack, the more likely that memory corruption can happen. @@ -311,8 +374,8 @@ Asynchronous Callbacks Memory, memory, memory Running out of heap is the **most common cause for crashes**. Because the build process for the ESP leaves out exceptions (they use memory), memory allocations that fail will do - so silently. A typical example is when setting or concatenating a large String. If - allocation has failed internally, then the internal string copy can corrupt data, and + so silently. A typical example is when setting or concatenating a large String. If + allocation has failed internally, then the internal string copy can corrupt data, and the ESP will crash. In addition, doing many String concatenations in sequence, e.g.: using operator+() @@ -348,9 +411,9 @@ Memory, memory, memory * If you use std libs like std::vector, make sure to call its ::reserve() method before filling it. This allows allocating only once, which reduces mem fragmentation, and makes sure that there are no empty unused slots left over in the container at the end. Stack -   The amount of stack in the ESP is tiny at only 4KB. For normal development in large systems, it +   The amount of stack in the ESP is tiny at only 4KB. For normal development in large systems, it is good practice to use and abuse the stack, because it is faster for allocation/deallocation, the scope of the object is well defined, and deallocation automatically happens in reverse order as allocation, which means no mem fragmentation. However, with the tiny amount of stack available in the ESP, that practice is not really viable, at least not for big objects. - + * Large objects that have internally managed memory, such as String, std::string, std::vector, etc, are ok on the stack, because they internally allocate their buffers on the heap. * Large arrays on the stack, such as uint8_t buffer[2048] should be avoided on the stack and should be dynamically allocated instead (consider smart pointers). * Objects that have large data members, such as large arrays, should also be avoided on the stack, and should be dynamically allocated (consider smart pointers). @@ -392,7 +455,7 @@ or `esp8266 / Arduino `__ core, types and versions of O/S, you need to provide exact information on what your application is about. Only then, people willing to look into your issue may be able to compare it to a configuration they are familiar with. -If you are lucky, they may even attempt to reproduce your issue on their +If you are lucky, they may even attempt to reproduce your issue on their own equipment! This will be far more difficult if you provide only vague details, so somebody would need to ask you to find out what is really happening. diff --git a/doc/faq/a03-library-does-not-work.rst b/doc/faq/a03-library-does-not-work.rst index 8b9b2d6910..6597c1a1dc 100644 --- a/doc/faq/a03-library-does-not-work.rst +++ b/doc/faq/a03-library-does-not-work.rst @@ -7,7 +7,7 @@ This Arduino library doesn't work on ESP. How do I make it working? - `Identify the Issues <#identify-the-issues>`__ - `Fix it Yourself <#fix-it-yourself>`__ - `Compilation Errors <#compilation-errors>`__ -- `Exceptions / Watchdog Resets <#exceptions--watchdog-resets>`__ +- `Exceptions / Watchdog Resets <#exceptions-watchdog-resets>`__ - `Functionality Issues <#functionality-issues>`__ - `Conclusion <#conclusion>`__ diff --git a/doc/faq/a06-global-build-options.rst b/doc/faq/a06-global-build-options.rst index 49961e0628..3e86b88a58 100644 --- a/doc/faq/a06-global-build-options.rst +++ b/doc/faq/a06-global-build-options.rst @@ -1,3 +1,5 @@ +:orphan: + How to specify global build defines and options =============================================== @@ -179,10 +181,10 @@ their builds. There are two solutions to this issue: -1. Turn off the “Aggressively Cache Compiled core” feature, by setting +1. Do nothing, and rely on aggressive cache workaround built into the + script. +2. Turn off the “Aggressively Cache Compiled core” feature, by setting ``compiler.cache_core=false``. -2. Rely on the not ideal fail-safe, aggressive cache workaround built - into the script. Using “compiler.cache_core=false” --------------------------------- @@ -251,14 +253,10 @@ problem would be cleared after a reboot. Or you can manually cleanup the **Arduino command-line option overrides** -The script needs to know the working value of ``compiler.cache_core`` -that the Arduino IDE uses when building. This script can learn the state -through documented locations; however, the Arduino IDE has two -command-line options that can alter the results the Arduino IDE uses -internally. And, the Arduino IDE does not provide a means for a script -to learn the override value. +If you are building with ``compiler.cache_core=true`` no action is +needed. If ``false`` the script would benefit by knowing that. -These two command-line options are the problem: +When using either of these two command-line options: :: diff --git a/doc/faq/readme.rst b/doc/faq/readme.rst index 04ccd74880..cfd65eca90 100644 --- a/doc/faq/readme.rst +++ b/doc/faq/readme.rst @@ -187,7 +187,7 @@ regular API. Read more at `former WiFi persistent mode <../esp8266wifi/generic-class.rst#persistent>`__. -How to resolve "undefined reference to ``flashinit`'" error ? +How to resolve "undefined reference to ``flashinit``" error ? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Please read `flash layout <../filesystem.rst>`__ documentation entry. diff --git a/doc/filesystem.rst b/doc/filesystem.rst index 86375ad8e1..1dca7dc707 100644 --- a/doc/filesystem.rst +++ b/doc/filesystem.rst @@ -228,10 +228,16 @@ use esptool.py. *ESP8266LittleFS* is the equivalent tool for LittleFS. -- Download the 2.6.0 or later version of the tool: https://github.com/earlephilhower/arduino-esp8266littlefs-plugin/releases +For Arduino IDE 1.x: +- Download the latest plugin from: https://github.com/earlephilhower/arduino-esp8266littlefs-plugin/releases - Install as above - To upload a LittleFS filesystem use Tools > ESP8266 LittleFS Data Upload +For Arduino IDE 2.x: +- Download the latest plugin from: https://github.com/earlephilhower/arduino-littlefs-upload/releases +- Follow the manual installation instructions in: https://github.com/earlephilhower/arduino-littlefs-upload/blob/main/README.md +- To upload a LittleFS filesystem use `Ctrl`+`Shift`+`P` and then select the `Upload LittleFS to Pico/ESP8266` item + File system object (SPIFFS/LittleFS/SD/SDFS) -------------------------------------------- diff --git a/doc/gdb.rst b/doc/gdb.rst index 53e9f07fbb..79e221e844 100644 --- a/doc/gdb.rst +++ b/doc/gdb.rst @@ -380,4 +380,33 @@ breakpoint) command in GDB while debugging instead of the more common ``break`` command, since ``thb`` will remove the breakpoint once it is reached automatically and save you some trouble. +Because of the single hardware breakpoint limitation, you must pay careful +attention to the output from ``gdb`` when you set a breakpoint. If your +breakpoint expression matches multiple locations, as in this example: +.. code:: bash + + (gdb) break loop + Breakpoint 1 at 0x40202c84: loop. (2 locations) + +Then you will be unable to ``continue``: + +.. code:: bash + + (gdb) cont + Continuing. + Note: automatically using hardware breakpoints for read-only addresses. + Warning: + Cannot insert hardware breakpoint 1. + Could not insert hardware breakpoints: + You may have requested too many hardware breakpoints/watchpoints. + +You can resolve this situation by deleting the previous breakpoint and +using a more specific breakpoint expression: + +.. code:: bash + + (gdb) delete + Delete all breakpoints? (y or n) y + (gdb) break mysketch.ino:loop + Breakpoint 2 at 0x40202c84: file .../mysketch.ino, line 113. diff --git a/doc/ideoptions.rst b/doc/ideoptions.rst index f790d02fc0..25fd08defa 100644 --- a/doc/ideoptions.rst +++ b/doc/ideoptions.rst @@ -127,7 +127,31 @@ There are a number of options. - The last (``NoAssert - NDEBUG``) is even quieter than the first (some internal guards are skipped to save more flash). - The other ones may be used when asked by a maintainer or if you are a - developper trying to debug some issues. + developer trying to debug some issues. + +Debug Optimization +~~~~~~~~~~~~~~~~~~ + +Due to the limited resources on the device, our default compiler optimizations +focus on creating the smallest code size (``.bin`` file). That is fine for +release but not ideal for debugging. + +``Debug Optimization`` use to improve Exception Decoder results. + +- ``Lite`` impact on code size uses ``-fno-optimize-sibling-calls`` to alter + the ``-Os`` compiler option to place more caller addresses on the Stack. +- ``Optimum`` offers better quality stack content for the Exception Decoder at + the expense of a larger code size. It uses the ``-Og`` compiler option, which + turns off optimizations that can make debugging difficult while keeping + others. +- ``None`` no changes for debugging continue using ``-Os``. + +Take note some sketches may start working after changing the optimization. Or +fail less often. And it is also possible (not likely) that source code that +was working with ``-Os`` may break with ``-Og``. + +For more topic depth, read `Improving Exception Decoder Results `__ + lwIP variant ~~~~~~~~~~~~ @@ -219,13 +243,31 @@ Erase Flash - ``All Flash``: WiFi settings and Filesystems are erased. -Espressif Firmware +NONOS SDK Version ~~~~~~~~~~~~~~~~~~ -There are a number of available espressif firmwares. The first / default -choice is fine. Only try with others after reading on the issue tracker -that something has to be tried with them. Note that Espressif obsoleted -all of them at the time of writing. +Our Core is based on [Espressif NONOS SDK](https://github.com/espressif/ESP8266_NONOS_SDK). + +- **2.2.1+100 (190703)** (default) +- 2.2.1+119 (191122) +- 2.2.1+113 (191105) +- 2.2.1+111 (191024) +- 2.2.1+61 (190313) +- 2.2.1 (legacy) +- 3.0.5 (experimental) + +See our issue tracker in regards to default version selection. + +* `#6724 (comment) `__ +* `#6826 `__ + +Notice that 3.x.x is provided **as-is** and remains **experimental**. + +Floating Point operations +~~~~~~~~~~~~~~~~~~~~~~~~~ + +- ``in IROM``: This provides more free space in IRAM but disallows using floating operations inside ISRs. +- ``allowed in ISR``: Floats can be used in ISRs, cost is ~1KB IRAM when floats are used. SSL Support ~~~~~~~~~~~ diff --git a/doc/installing.rst b/doc/installing.rst index 8f04b90f05..34f76d7365 100644 --- a/doc/installing.rst +++ b/doc/installing.rst @@ -9,10 +9,9 @@ This is the suggested installation method for end users. Prerequisites ~~~~~~~~~~~~~ -- Arduino 1.6.8, get it from `Arduino - website `__. - Internet connection -- Python 3 interpreter (Mac/Linux only, Windows installation supplies its own) +- Arduino IDE 1.x or 2.x (https://www.arduino.cc/en/software) +- (macOS/Linux only) Python ≥3.7 (https://python.org) Instructions ~~~~~~~~~~~~ @@ -33,6 +32,7 @@ For more information on the Arduino Board Manager, see: - https://www.arduino.cc/en/guide/cores + Using git version ----------------- @@ -42,12 +42,12 @@ developers. Prerequisites ~~~~~~~~~~~~~ -- Arduino 1.6.8 (or newer, current working version is 1.8.5) -- git -- Python 3.x (https://python.org) -- terminal, console, or command prompt (depending on your OS) - Internet connection -- Uninstalling any core version installed via Board Manager +- Arduino IDE 1.x or 2.x (https://www.arduino.cc/en/software) +- git (https://git-scm.com) +- Python ≥3.7 (https://python.org) +- terminal, console, or command prompt (depending on your OS) +- **Uninstalling any core version installed via Board Manager** Instructions - Windows 10 ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -59,7 +59,7 @@ Instructions - Windows 10 - Install git for Windows (if not already; see https://git-scm.com/download/win) - Open a command prompt (cmd) and go to Arduino default directory. This is typically the - *sketchbook* directory (usually ``C:\users\{username}\Documents\Arduino`` where the environment variable ``%USERPROFILE%`` usually contains ``C:\users\{username}``) + *sketchbook* directory (usually ``C:\Users\{username}\Documents\Arduino`` where the environment variable ``%USERPROFILE%`` usually contains ``C:\Users\{username}``) - Clone this repository into hardware/esp8266com/esp8266 directory. @@ -101,14 +101,15 @@ Instructions - Windows 10 --- boards.txt --- LICENSE -- Initialize the submodules +- Initialize submodules to fetch external libraries .. code:: bash cd %USERPROFILE%\Documents\Arduino\hardware\esp8266com\esp8266 git submodule update --init - If error messages about missing files related to ``SoftwareSerial`` are encountered during the build process, it should be because this step was missed and is required. + Not doing this step would cause build failure when attempting to include ``SoftwareSerial.h``, ``Ethernet.h``, etc. + See our `.gitmodules file `__ for the full list. - Download binary tools @@ -181,14 +182,16 @@ Instructions - Other OS --- boards.txt --- LICENSE -- Initialize the submodules +- Initialize submodules to fetch external libraries .. code:: bash cd esp8266 git submodule update --init - - If error messages about missing files related to ``SoftwareSerial`` are encountered during the build process, it should be because this step was missed and is required. + + + Not doing this step would cause build failure when attempting to include ``SoftwareSerial.h``, ``Ethernet.h``, etc. + See our `.gitmodules file `__ for the full list. - Download binary tools @@ -197,9 +200,10 @@ Instructions - Other OS cd tools python3 get.py - If you get an error message stating that python3 is not found, you will need to install it (most modern UNIX-like OSes provide Python 3 as - part of the default install). To install you will need to use ``sudo yum install python3``, ``sudo apt install python3``, or ``brew install python3`` - as appropriate. On the Mac you may get an error message like: + + If you get an error message stating that python3 is not found, you will need to install it (most modern UNIX-like OSes provide Python 3 as + part of the default install). To install you will need to use ``sudo yum install python3``, ``sudo apt install python3``, or ``brew install python3`` + as appropriate. On the Mac you may get an error message like: .. code:: bash @@ -214,7 +218,8 @@ Instructions - Other OS self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056) - This is because Homebrew on the Mac does not always install the required SSL certificates by default. Install them manually (adjust the Python 3.7 as needed) with: + + This is because Homebrew on the Mac does not always install the required SSL certificates by default. Install them manually (adjust the Python 3.7 as needed) with: .. code:: bash @@ -231,6 +236,44 @@ Instructions - Other OS git status git pull +Maintaining +~~~~~~~~~~~ + +To keep up with the development branch + +.. code:: bash + + git switch --recurse-submodules --discard-changes master + git pull --recurse-submodules + cd tools + python3 get.py + +Pull requests +~~~~~~~~~~~~~ + +To test not yet merged Pull Request, first you have to find its ID number. This is the sequence of digits right after the pull request title. + +Open terminal and cd into the directory where the repository was previously cloned. For example, 12345 is the Pull Request ID + +.. code:: bash + + git fetch origin pull/12345/head + git switch --detach --recurse-submodules --discard-changes FETCH_HEAD + +When Pull Request updates packaged tools, make sure to also fetch their latest versions. + +.. code:: bash + + cd tools + python3 get.py + +To go back to using the development branch + +.. code:: bash + + git switch --recurse-submodules --discard-changes master + git pull --recurse-submodules + Using PlatformIO ---------------- @@ -245,5 +288,6 @@ BeagleBone, CubieBoard). - `PlatformIO IDE `__ - `PlatformIO Core `__ (command line tool) - `Advanced usage `__ - custom settings, uploading to LittleFS, Over-the-Air (OTA), staging version +- `Using Arduino Framework Staging Version `__ - install development version of the Core - `Integration with Cloud and Standalone IDEs `__ - Cloud9, Codeanywhere, Eclipse Che (Codenvy), Atom, CLion, Eclipse, Emacs, NetBeans, Qt Creator, Sublime Text, VIM, Visual Studio, and VSCode - `Project Examples `__ diff --git a/doc/mmu.rst b/doc/mmu.rst index 9c3ec48acb..27ea4d4d7d 100644 --- a/doc/mmu.rst +++ b/doc/mmu.rst @@ -76,19 +76,28 @@ The Arduino IDE Tools menu option, ``MMU`` has the following selections: MMU related build defines and possible values. These values change as indicated with the menu options above: -+-------------------------+--------------+--------------+------------------------------------+------------------------------+ -| ``#define`` | balanced | IRAM | shared (IRAM and Heap) | not shared (IRAM and Heap) | -+=========================+==============+==============+====================================+==============================+ -| ``MMU_IRAM_SIZE`` | ``0x8000`` | ``0xC000`` | ``0xC000`` | ``0x8000`` | -+-------------------------+--------------+--------------+------------------------------------+------------------------------+ -| ``MMU_ICACHE_SIZE`` | ``0x8000`` | ``0x4000`` | ``0x4000`` | ``0x4000`` | -+-------------------------+--------------+--------------+------------------------------------+------------------------------+ -| ``MMU_IRAM_HEAP`` | -- | -- | defined, enables\ ``umm_malloc`` | -- | -+-------------------------+--------------+--------------+------------------------------------+------------------------------+ -| ``MMU_SEC_HEAP`` | -- | \*\* | \*\* | ``0x40108000`` | -+-------------------------+--------------+--------------+------------------------------------+------------------------------+ -| ``MMU_SEC_HEAP_SIZE`` | -- | \*\* | \*\* | ``0x4000`` | -+-------------------------+--------------+--------------+------------------------------------+------------------------------+ ++-------------+------------+------------+-------------+-------------+ +| ``#define`` | balanced | IRAM | shared | not shared | +| | | | (IRAM and | (IRAM and | +| | | | Heap) | Heap) | ++=============+============+============+=============+=============+ +| ``MMU_ | ``0x8000`` | ``0xC000`` | ``0xC000`` | ``0x8000`` | +| IRAM_SIZE`` | | | | | ++-------------+------------+------------+-------------+-------------+ +| ``MMU_IC | ``0x8000`` | ``0x4000`` | ``0x4000`` | ``0x4000`` | +| ACHE_SIZE`` | | | | | ++-------------+------------+------------+-------------+-------------+ +| ``MMU_ | – | – | defined, | – | +| IRAM_HEAP`` | | | e | | +| | | | nables\ ``u | | +| | | | mm_malloc`` | | ++-------------+------------+------------+-------------+-------------+ +| ``MMU | – | \*\* | \*\* | ``0 | +| _SEC_HEAP`` | | | | x40108000`` | ++-------------+------------+------------+-------------+-------------+ +| ``MMU_SEC_ | – | \*\* | \*\* | ``0x4000`` | +| HEAP_SIZE`` | | | | | ++-------------+------------+------------+-------------+-------------+ \*\* This define is to an inline function that calculates the value, based on unused code space, requires ``#include ``. @@ -112,8 +121,8 @@ The Arduino IDE Tools menu option, ``Non-32-Bit Access`` has the following selec option ``16KB cache + 48KB IRAM and 2nd Heap (shared)``. IRAM, unlike DRAM, must be accessed as aligned full 32-bit words, no -byte or short access. The pgm\_read macros are an option; however, the -store operation remains an issue. For a block copy, ets\_memcpy appears +byte or short access. The pgm_read macros are an option; however, the +store operation remains an issue. For a block copy, ets_memcpy appears to work well as long as the byte count is rounded up to be evenly divided by 4, and source and destination addresses are 4 bytes aligned. @@ -125,6 +134,11 @@ over-optimization. To get a sense of how memory access time is effected, see examples ``MMU48K`` and ``irammem`` in ``ESP8266``. +NON-OS SDK v3.0.0 and above have builtin support for Non-32-Bit Access. +Selecting ``Byte/Word access to IRAM/PROGMEM`` will override the builtin +version with ours. However, there is no known reason to do this other +than debugging. + Miscellaneous ------------- @@ -133,41 +147,43 @@ For calls to ``umm_malloc`` with interrupts disabled. - ``malloc`` will always allocate from the ``DRAM`` heap when called with interrupts disabled. -- ``realloc`` with a NULL pointer will use ``malloc`` and return a - ``DRAM`` heap allocation. Note, calling ``realloc`` with interrupts - disabled is **not** officially supported. You are on your own if you - do this. + + - ``realloc`` with a NULL pointer will use ``malloc`` and return a + ``DRAM`` heap allocation. Note, calling ``realloc`` with + interrupts disabled is **not** officially supported. You are on + your own if you do this. + - If you must use IRAM memory in your ISR, allocate the memory in your init code. To reduce the time spent in the ISR, avoid non32-bit access that would trigger the exception handler. For short or byte access, consider using the inline functions described in section - "Performance Functions" below. + “Performance Functions” below. How to Select Heap ~~~~~~~~~~~~~~~~~~ The ``MMU`` selection ``16KB cache + 48KB IRAM and 2nd Heap (shared)`` allows you to use the standard heap API function calls (``malloc``, -``calloc``, ``free``, ... ). to allocate memory from DRAM or IRAM. This +``calloc``, ``free``, … ). to allocate memory from DRAM or IRAM. This selection can be made by instantiating the class ``HeapSelectIram`` or ``HeapSelectDram``. The usage is similar to that of the ``InterruptLock`` class. The default/initial heap source is DRAM. The class is in ``umm_malloc/umm_heap_select.h``. -:: - - ... - char *bufferDram; - bufferDram = (char *)malloc(33); - char *bufferIram; - { - HeapSelectIram ephemeral; - bufferIram = (char *)malloc(33); - } - ... - free(bufferIram); - free(bufferDram); - ... +.. code:: cpp + + ... + char *bufferDram; + bufferDram = (char *)malloc(33); + char *bufferIram; + { + HeapSelectIram ephemeral; + bufferIram = (char *)malloc(33); + } + ... + free(bufferIram); + free(bufferDram); + ... ``free`` will always return memory to the correct heap. There is no need for tracking and selecting before freeing. @@ -182,8 +198,9 @@ Classes: - ``umm_get_current_heap_id()`` - ``umm_set_heap_by_id( ID value )`` - Possible ID values -- ``UMM_HEAP_DRAM`` -- ``UMM_HEAP_IRAM`` + + - ``UMM_HEAP_DRAM`` + - ``UMM_HEAP_IRAM`` Also, an alternate stack select method API is available. This is not as easy as the class method; however, for some small set of cases, it may @@ -201,9 +218,9 @@ a pointer: .. code:: cpp - bool mmu_is_iram(const void *addr); - bool mmu_is_dram(const void *addr); - bool mmu_is_icache(const void *addr); + bool mmu_is_iram(const void *addr); + bool mmu_is_dram(const void *addr); + bool mmu_is_icache(const void *addr); Performance Functions ~~~~~~~~~~~~~~~~~~~~~ @@ -213,23 +230,23 @@ exception handler reducing execution time and stack use, it comes at the cost of increased code size. These are an alternative to the ``pgm_read`` macros for reading from -IRAM. When compiled with 'Debug Level: core' range checks are performed +IRAM. When compiled with ‘Debug Level: core’ range checks are performed on the pointer value to make sure you are reading from the address range of IRAM, DRAM, or ICACHE. .. code:: cpp - uint8_t mmu_get_uint8(const void *p8); - uint16_t mmu_get_uint16(const uint16_t *p16); - int16_t mmu_get_int16(const int16_t *p16); + uint8_t mmu_get_uint8(const void *p8); + uint16_t mmu_get_uint16(const uint16_t *p16); + int16_t mmu_get_int16(const int16_t *p16); While these functions are intended for writing to IRAM, they will work -with DRAM. When compiled with 'Debug Level: core', range checks are +with DRAM. When compiled with ‘Debug Level: core’, range checks are performed on the pointer value to make sure you are writing to the address range of IRAM or DRAM. .. code:: cpp - uint8_t mmu_set_uint8(void *p8, const uint8_t val); - uint16_t mmu_set_uint16(uint16_t *p16, const uint16_t val); - int16_t mmu_set_int16(int16_t *p16, const int16_t val); + uint8_t mmu_set_uint8(void *p8, const uint8_t val); + uint16_t mmu_set_uint16(uint16_t *p16, const uint16_t val); + int16_t mmu_set_int16(int16_t *p16, const int16_t val); diff --git a/doc/ota_updates/readme.rst b/doc/ota_updates/readme.rst index 53ce8c2707..de351fe3f2 100755 --- a/doc/ota_updates/readme.rst +++ b/doc/ota_updates/readme.rst @@ -216,7 +216,7 @@ Requirements Application Example ~~~~~~~~~~~~~~~~~~~ -Instructions below show configuration of OTA on a NodeMCU 1.0 (ESP-12E Module) board. You can use any other board that meets the `requirements <#basic-requirements>`__ described above. This instruction is valid for all operating systems supported by the Arduino IDE. Screen captures have been made on Windows 7 and you may see small differences (like name of the serial port), if you are using Linux or MacOS. +Instructions below show configuration of OTA on a NodeMCU 1.0 (ESP-12E Module) board. You can use any other board that meets the `requirements <#ota-basic-requirements>`__ described above. This instruction is valid for all operating systems supported by the Arduino IDE. Screen captures have been made on Windows 7 and you may see small differences (like name of the serial port), if you are using Linux or MacOS. 1. Before you begin, please make sure that you have the following software installed: @@ -336,7 +336,7 @@ Select COM port and baud rate on external terminal program as if you were using :alt: Termite settings -Then run OTA from IDE and look what is displayed on terminal. Successful `ArduinoOTA <#arduinoota>`__ process using BasicOTA.ino sketch looks like below (IP address depends on your network configuration): +Then run OTA from IDE and look what is displayed on terminal. Successful `ArduinoOTA <#arduino-ide>`__ process using BasicOTA.ino sketch looks like below (IP address depends on your network configuration): .. figure:: a-ota-external-serial-terminal-output.png :alt: OTA upload successful - output on an external serial terminal @@ -407,7 +407,7 @@ The sample implementation provided below has been done using: ``ESP8266HTTPUpdateServer`` library, - NodeMCU 1.0 (ESP-12E Module). -You can use another module if it meets previously described `requirements <#basic-requirements>`__. +You can use another module if it meets previously described `requirements <#ota-basic-requirements>`__. 1. Before you begin, please make sure that you have the following software installed: @@ -501,7 +501,7 @@ In case OTA update fails dead after entering modifications in your sketch, you c HTTP Server ----------- -``ESPhttpUpdate`` class can check for updates and download a binary file from HTTP web server. It is possible to download updates from every IP or domain address on the network or Internet. +``ESP8266HTTPUpdate`` class can check for updates and download a binary file from HTTP web server. It is possible to download updates from every IP or domain address on the network or Internet. Note that by default this class closes all other connections except the one used by the update, this is because the update method blocks. This means that if there's another application receiving data then TCP packets will build up in the buffer leading to out of memory errors causing the OTA update to fail. There's also a limited number of receive buffers available and all may be used up by other applications. @@ -523,6 +523,8 @@ Simple updater downloads the file every time the function is called. .. code:: cpp + #include + WiFiClient client; ESPhttpUpdate.update(client, "192.168.0.2", 80, "/arduino.bin"); @@ -535,6 +537,8 @@ The server-side script can respond as follows: - response code 200, and send the .. code:: cpp + #include + WiFiClient client; t_httpUpdate_return ret = ESPhttpUpdate.update(client, "192.168.0.2", 80, "/esp/update/arduino.php", "optional current version string here"); switch(ret) { @@ -588,34 +592,42 @@ With this information the script now can check if an update is needed. It is als "DOOR-7-g14f53a19", - "18:FE:AA:AA:AA:BB" => "TEMP-1.0.0" - ); - - if(!isset($db[$_SERVER['x-ESP8266-STA-MAC']])) { - header($_SERVER["SERVER_PROTOCOL"].' 500 ESP MAC not configured for updates', true, 500); + + $db_string = '{ + "18:FE:AA:AA:AA:AA": {"file": "DOOR-7-g14f53a19.bin", "version": 1}, + "18:FE:AA:AA:AA:BB": {"file": "TEMP-1.0.0".bin", "version": 1}}'; + // $db_string = file_get_contents("arduino-db.json"); + $db = json_decode($db_string, true); + $mode = $headers['x-ESP8266-mode']; + $mac = $headers['x-ESP8266-STA-MAC']; + + if (!isset($db[$mac])) { + header($_SERVER["SERVER_PROTOCOL"].' 404 ESP MAC not configured for updates', true, 404); + echo "MAC ".$mac." not configured for updates\n"; + exit(); } - - $localBinary = "./bin/".$db[$_SERVER['x-ESP8266-STA-MAC']].".bin"; - - // Check if version has been set and does not match, if not, check if - // MD5 hash between local binary and ESP8266 binary do not match if not. - // then no update has been found. - if((!check_header('x-ESP8266-sdk-version') && $db[$_SERVER['x-ESP8266-STA-MAC']] != $_SERVER['x-ESP8266-version']) - || $_SERVER["x-ESP8266-sketch-md5"] != md5_file($localBinary)) { - sendFile($localBinary); + + $localBinary = $db[$mac]['file']; + $localVersion = $db[$mac]['version']; + + if (!is_readable($localBinary)) { + header($_SERVER["SERVER_PROTOCOL"].' 404 File not found', true, 404); + echo "File ".$localBinary." not found\n"; + exit(); + } + + if ($mode == 'sketch') { + // Check if version has been set and does not match, if not, check if + // MD5 hash between local binary and ESP8266 binary do not match if not. + // then no update has been found. + if ((check_header('x-ESP8266-version') && $headers['x-ESP8266-version'] != $localVersion)) { + // || $headers["x-ESP8266-sketch-md5"] != md5_file($localBinary)) { + sendFile($localBinary, $localVersion); + } else { + header($_SERVER["SERVER_PROTOCOL"].' 304 Not Modified', true, 304); + echo "File ".$localBinary." not modified\n"; + } + } else if ($mode == 'version') { + header($_SERVER["SERVER_PROTOCOL"].' 200 OK', true, 200); + header('x-MD5: '.md5_file($localBinary), true); + header('x-version: '.$localVersion, true); } else { - header($_SERVER["SERVER_PROTOCOL"].' 304 Not Modified', true, 304); + header($_SERVER["SERVER_PROTOCOL"].' 404 Mode not supported', true, 404); + echo "mode: ".$mode." not supported\n"; + exit(); } - - header($_SERVER["SERVER_PROTOCOL"].' 500 no version for ESP MAC', true, 500); + ?> Stream Interface ---------------- @@ -668,9 +702,29 @@ Updater class Updater is in the Core and deals with writing the firmware to the flash, checking its integrity and telling the bootloader (eboot) to load the new firmware on the next boot. -**Note:** The bootloader command will be stored into the first 128 bytes of user RTC memory, then it will be retrieved by eboot on boot. That means that user data present there will be lost `(per discussion in #5330) `__. +The following `Updater ; + void onProgress(THandlerFunction_Progress); // current and total number of bytes + + using THandlerFunction_Error = std::function; + void onStart(THandlerFunction_Error); // error code + + using THandlerFunction = std::function; + void onEnd(THandlerFunction); + void onError(THandlerFunction); + +Using RTC memory +~~~~~~~~~~~~~~~~ + +The bootloader command will be stored into the first 128 bytes of user RTC memory, then it will be retrieved by eboot on boot. That means that user data present there will be lost `(per discussion in #5330) `__. + +Flash mode and size +~~~~~~~~~~~~~~~~~~~ -**Note:** For uncompressed firmware images, the Updater will change the flash mode bits if they differ from the flash mode the device is currently running at. This ensures that the flash mode is not changed to an incompatible mode when the device is in a remote or hard to access area. Compressed images are not modified, thus changing the flash mode in this instance could result in damage to the ESP8266 and/or flash memory chip or your device no longer be accessible via OTA, and requiring re-flashing via a serial connection `(per discussion in #7307) `__. +For uncompressed firmware images, the Updater will change the flash mode bits if they differ from the flash mode the device is currently running at. This ensures that the flash mode is not changed to an incompatible mode when the device is in a remote or hard to access area. Compressed images are not modified, thus changing the flash mode in this instance could result in damage to the ESP8266 and/or flash memory chip or your device no longer be accessible via OTA, and requiring re-flashing via a serial connection `(per discussion in #7307) `__. Update process - memory view ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/reference.rst b/doc/reference.rst index 792e867a47..e06dfd8a3d 100644 --- a/doc/reference.rst +++ b/doc/reference.rst @@ -27,15 +27,22 @@ and have several limitations: or use a scheduled function (which will be called outside of the interrupt context when it is safe) to do long-running work. -* Memory operations can be dangerous and should be avoided in interrupts. - Calls to ``new`` or ``malloc`` should be minimized because they may require - a long running time if memory is fragmented. Calls to ``realloc`` and - ``free`` must NEVER be called. Using any routines or objects which call - ``free`` or ``realloc`` themselves is also forbidden for the same reason. - This means that ``String``, ``std::string``, ``std::vector`` and other - classes which use contiguous memory that may be resized must be used with - extreme care (ensuring strings aren't changed, vector elements aren't - added, etc.). +* Heap API operations can be dangerous and should be avoided in interrupts. + Calls to ``malloc`` should be minimized because they may require a long + running time if memory is fragmented. Calls to ``realloc`` and ``free`` + must NEVER be called. Using any routines or objects which call ``free`` or + ``realloc`` themselves is also forbidden for the same reason. This means + that ``String``, ``std::string``, ``std::vector`` and other classes which + use contiguous memory that may be resized must be used with extreme care + (ensuring strings aren't changed, vector elements aren't added, etc.). + The underlying problem, an allocation address could be actively in use at + the instant of an interrupt. Upon return, the address actively in use may + be invalid after an ISR uses ``realloc`` or ``free`` against the same + allocation. + +* The C++ ``new`` and ``delete`` operators must NEVER be used in an ISR. Their + call path is not in IRAM. Using any routines or objects that use the ``new`` + or ``delete`` operator is also forbidden. Digital IO ---------- diff --git a/doc/requirements.txt b/doc/requirements.txt index 8d90d8f59a..6b2684762d 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,10 +1,8 @@ # Requirements file for pip # list of Python packages used in documentation build -sphinx -sphinx-rtd-theme -breathe -nbsphinx -docutils<0.17 -testresources -#at the time of writing, requirement is pygments<3,>=2.4.1 -pygments>=2.4.1 +sphinx>=8.1.2,<9.0.0 +sphinx-rtd-theme>=3.0.2,<4.0.0 +breathe>=4.36.0,<5.0.0 +nbsphinx>=0.9.7,<1.0.0 +testresources>=2.0.1,<3.0.0 +pygments>=2.19.1,<3.0.0 diff --git a/libraries/ArduinoOTA/ArduinoOTA.cpp b/libraries/ArduinoOTA/ArduinoOTA.cpp index 109bbb4959..4ee31e3751 100644 --- a/libraries/ArduinoOTA/ArduinoOTA.cpp +++ b/libraries/ArduinoOTA/ArduinoOTA.cpp @@ -3,6 +3,7 @@ #endif #include #include +#include #include "ArduinoOTA.h" #include "MD5Builder.h" #include "StreamString.h" @@ -24,10 +25,11 @@ extern "C" { #include #endif -#ifdef DEBUG_ESP_OTA -#ifdef DEBUG_ESP_PORT +#if defined(DEBUG_ESP_OTA) && defined(DEBUG_ESP_PORT) #define OTA_DEBUG DEBUG_ESP_PORT -#endif +#define OTA_DEBUG_PRINTF(fmt, ...) OTA_DEBUG.printf_P(PSTR(fmt), ##__VA_ARGS__) +#else +#define OTA_DEBUG_PRINTF(...) #endif ArduinoOTAClass::ArduinoOTAClass() @@ -93,6 +95,10 @@ void ArduinoOTAClass::setRebootOnSuccess(bool reboot){ _rebootOnSuccess = reboot; } +void ArduinoOTAClass::setEraseConfig(ota_erase_cfg_t eraseConfig){ + _eraseConfig = eraseConfig; +} + void ArduinoOTAClass::begin(bool useMDNS) { if (_initialized) return; @@ -119,7 +125,7 @@ void ArduinoOTAClass::begin(bool useMDNS) { if(!_udp_ota->listen(IP_ADDR_ANY, _port)) return; _udp_ota->onRx(std::bind(&ArduinoOTAClass::_onRx, this)); - + #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS) if(_useMDNS) { MDNS.begin(_hostname.c_str()); @@ -133,9 +139,7 @@ void ArduinoOTAClass::begin(bool useMDNS) { #endif _initialized = true; _state = OTA_IDLE; -#ifdef OTA_DEBUG - OTA_DEBUG.printf("OTA server at: %s.local:%u\n", _hostname.c_str(), _port); -#endif + OTA_DEBUG_PRINTF("OTA server at: %s.local:%u\n", _hostname.c_str(), _port); } int ArduinoOTAClass::parseInt(){ @@ -243,13 +247,11 @@ void ArduinoOTAClass::_runUpdate() { IPAddress ota_ip = _ota_ip; if (!Update.begin(_size, _cmd)) { -#ifdef OTA_DEBUG - OTA_DEBUG.println("Update Begin Error"); -#endif + OTA_DEBUG_PRINTF("Update Begin Error\n"); if (_error_callback) { _error_callback(OTA_BEGIN_ERROR); } - + StreamString ss; Update.printError(ss); _udp_ota->append("ERR: ", 5); @@ -275,9 +277,7 @@ void ArduinoOTAClass::_runUpdate() { WiFiClient client; if (!client.connect(_ota_ip, _ota_port)) { -#ifdef OTA_DEBUG - OTA_DEBUG.printf("Connect Failed\n"); -#endif + OTA_DEBUG_PRINTF("Connect Failed\n"); _udp_ota->listen(IP_ADDR_ANY, _port); if (_error_callback) { _error_callback(OTA_CONNECT_ERROR); @@ -293,9 +293,7 @@ void ArduinoOTAClass::_runUpdate() { while (!client.available() && waited--) delay(1); if (!waited){ -#ifdef OTA_DEBUG - OTA_DEBUG.printf("Receive Failed\n"); -#endif + OTA_DEBUG_PRINTF("Receive Failed\n"); _udp_ota->listen(IP_ADDR_ANY, _port); if (_error_callback) { _error_callback(OTA_RECEIVE_ERROR); @@ -320,18 +318,31 @@ void ArduinoOTAClass::_runUpdate() { client.flush(); delay(1000); client.stop(); -#ifdef OTA_DEBUG - OTA_DEBUG.printf("Update Success\n"); -#endif + OTA_DEBUG_PRINTF("Update Success\n"); if (_end_callback) { _end_callback(); } if(_rebootOnSuccess){ -#ifdef OTA_DEBUG - OTA_DEBUG.printf("Rebooting...\n"); -#endif + OTA_DEBUG_PRINTF("Rebooting...\n"); //let serial/network finish tasks that might be given in _end_callback delay(100); + if (OTA_ERASE_CFG_NO != _eraseConfig) { + eraseConfigAndReset(); // returns on failure + if (_error_callback) { + _error_callback(OTA_ERASE_SETTINGS_ERROR); + } + if (OTA_ERASE_CFG_ABORT_ON_ERROR == _eraseConfig) { + eboot_command_clear(); + return; + } +#ifdef OTA_DEBUG + else if (OTA_ERASE_CFG_IGNORE_ERROR == _eraseConfig) { + // Fallthrough and restart + } else { + panic(); + } +#endif + } ESP.restart(); } } else { @@ -348,19 +359,33 @@ void ArduinoOTAClass::_runUpdate() { } void ArduinoOTAClass::end() { + if (!_initialized) + return; + _initialized = false; - _udp_ota->unref(); - _udp_ota = 0; + if(_udp_ota){ + _udp_ota->unref(); + _udp_ota = 0; + } #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS) if(_useMDNS){ MDNS.end(); } #endif _state = OTA_IDLE; - #ifdef OTA_DEBUG - OTA_DEBUG.printf("OTA server stopped.\n"); - #endif + OTA_DEBUG_PRINTF("OTA server stopped.\n"); } + +void ArduinoOTAClass::eraseConfigAndReset() { + OTA_DEBUG_PRINTF("Erase Config and Hard Reset ...\n"); + if (WiFi.mode(WIFI_OFF)) { + ESP.eraseConfigAndReset(); // No return testing - Only returns on failure + OTA_DEBUG_PRINTF(" ESP.eraseConfigAndReset() failed!\n"); + } else { + OTA_DEBUG_PRINTF(" WiFi.mode(WIFI_OFF) Timeout!\n"); + } +} + //this needs to be called in the loop() void ArduinoOTAClass::handle() { if (_state == OTA_RUNUPDATE) { diff --git a/libraries/ArduinoOTA/ArduinoOTA.h b/libraries/ArduinoOTA/ArduinoOTA.h index d1a81a316e..d3d93b9b36 100644 --- a/libraries/ArduinoOTA/ArduinoOTA.h +++ b/libraries/ArduinoOTA/ArduinoOTA.h @@ -18,9 +18,16 @@ typedef enum { OTA_BEGIN_ERROR, OTA_CONNECT_ERROR, OTA_RECEIVE_ERROR, - OTA_END_ERROR + OTA_END_ERROR, + OTA_ERASE_SETTINGS_ERROR } ota_error_t; +typedef enum { + OTA_ERASE_CFG_NO = 0, + OTA_ERASE_CFG_IGNORE_ERROR, + OTA_ERASE_CFG_ABORT_ON_ERROR +} ota_erase_cfg_t; + class ArduinoOTAClass { public: @@ -47,6 +54,10 @@ class ArduinoOTAClass //Sets if the device should be rebooted after successful update. Default true void setRebootOnSuccess(bool reboot); + //Sets flag to erase WiFi Settings at reboot/reset. "eraseConfig" selects to + //abort erase on failure or ignore error and erase. + void setEraseConfig(ota_erase_cfg_t eraseConfig = OTA_ERASE_CFG_ABORT_ON_ERROR); + //This callback will be called when OTA connection has begun void onStart(THandlerFunction fn); @@ -64,6 +75,11 @@ class ArduinoOTAClass //Ends the ArduinoOTA service void end(); + + //Has the effect of the "+ WiFi Settings" in the Arduino IDE Tools "Erase + //Flash" selection. Only returns on erase flash failure. + void eraseConfigAndReset(); + //Call this in loop() to run the service. Also calls MDNS.update() when begin() or begin(true) is used. void handle(); @@ -84,6 +100,7 @@ class ArduinoOTAClass bool _initialized = false; bool _rebootOnSuccess = true; bool _useMDNS = true; + ota_erase_cfg_t _eraseConfig = OTA_ERASE_CFG_NO; ota_state_t _state = OTA_IDLE; int _size = 0; int _cmd = 0; diff --git a/libraries/ArduinoOTA/examples/OTAEraseConfig/OTAEraseConfig.ino b/libraries/ArduinoOTA/examples/OTAEraseConfig/OTAEraseConfig.ino new file mode 100644 index 0000000000..85a0797d47 --- /dev/null +++ b/libraries/ArduinoOTA/examples/OTAEraseConfig/OTAEraseConfig.ino @@ -0,0 +1,106 @@ +/* + This example is a variation on BasicOTA. + + As is, this example will "always" erase WiFi Settings and reset after a + successful update. You can make this conditional. +*/ +#include +#include +#include +#include + +#ifndef STASSID +#define STASSID "your-ssid" +#define STAPSK "your-password" +#endif + +const char* ssid = STASSID; +const char* password = STAPSK; + +void setup() { + Serial.begin(115200); + Serial.println("Booting"); + Serial.println(String("Reset Reason: ") + ESP.getResetReason()); + + WiFi.mode(WIFI_STA); + WiFi.begin(ssid, password); + while (WiFi.waitForConnectResult() != WL_CONNECTED) { + Serial.println("Connection Failed! Rebooting..."); + delay(5000); + ESP.restart(); + } + + // Port defaults to 8266 + // ArduinoOTA.setPort(8266); + + // Hostname defaults to esp8266-[ChipID] + // ArduinoOTA.setHostname("myesp8266"); + + // No authentication by default + // ArduinoOTA.setPassword("admin"); + + // Password can be set with it's md5 value as well + // MD5(admin) = 21232f297a57a5a743894a0e4a801fc3 + // ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3"); + + ArduinoOTA.onStart([]() { + String type; + if (ArduinoOTA.getCommand() == U_FLASH) { + type = "sketch"; + } else { // U_FS + type = "filesystem"; + } + + // NOTE: if updating FS this would be the place to unmount FS using FS.end() + Serial.println("Start updating " + type); + }); + ArduinoOTA.onEnd([]() { + Serial.println("\nEnd"); + /* + By calling "ArduinoOTA.setEraseConfig(ArduinoOTA::OTA_ERASE_CFG_ABORT_ON_ERROR)," + this example will erase the "WiFi Settings" as part of an OTA update. When + erasing WiFi Settings fails, the OTA Update aborts, and eboot will not + copy the new ".bin" in place. + + Without the call to "ArduinoOTA.setEraseConfig" legacy behavior, the + system restarts without touching the WiFi Settings. + + Options for "setEraseConfig" to handle eraseConfig failures: + OTA_ERASE_CFG_NO - Do not erase WiFi Settings + OTA_ERASE_CFG_IGNORE_ERROR - Ignore the error and continue with update ".bin" copy + OTA_ERASE_CFG_ABORT_ON_ERROR - Cancel flash update copy at reboot + + To meet unique requirements, you can make the call below conditional. + Also, this call could be enabled before ArduinoOTA.onEnd() and canceled + here with "ArduinoOTA.setEraseConfig(OTA_ERASE_CFG_NO)." + */ + ArduinoOTA.setEraseConfig(OTA_ERASE_CFG_ABORT_ON_ERROR); + }); + ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { + Serial.printf("Progress: %u%%\r", (progress / (total / 100))); + }); + ArduinoOTA.onError([](ota_error_t error) { + Serial.printf("Error[%u]: ", error); + if (error == OTA_AUTH_ERROR) { + Serial.println("Auth Failed"); + } else if (error == OTA_BEGIN_ERROR) { + Serial.println("Begin Failed"); + } else if (error == OTA_CONNECT_ERROR) { + Serial.println("Connect Failed"); + } else if (error == OTA_RECEIVE_ERROR) { + Serial.println("Receive Failed"); + } else if (error == OTA_END_ERROR) { + Serial.println("End Failed"); + } else if (error == OTA_ERASE_SETTINGS_ERROR) { + Serial.println("Erase WiFi Settings Failed"); + } + }); + ArduinoOTA.begin(); + Serial.println("Ready"); + Serial.print("IP address: "); + Serial.println(WiFi.localIP()); +} + +void loop() { + ArduinoOTA.handle(); +} diff --git a/libraries/ArduinoOTA/examples/OTASdkCheck/OTASdkCheck.ino b/libraries/ArduinoOTA/examples/OTASdkCheck/OTASdkCheck.ino new file mode 100644 index 0000000000..1965321bda --- /dev/null +++ b/libraries/ArduinoOTA/examples/OTASdkCheck/OTASdkCheck.ino @@ -0,0 +1,162 @@ +/* + This example is a variation on BasicOTA. + + Logic added to look for a change in SDK Version. If changed, erase the WiFi + Settings and Reset the system. + + Added extra debug printing to aid in cutting through the confusion of the + multiple reboots. +*/ + +#include +#include +#include +#include +#include + +// You can control the extra debug printing here. To turn off, change 1 to 0. +#if 1 +#ifdef DEBUG_ESP_PORT +#define CONSOLE DEBUG_ESP_PORT +#else +#define CONSOLE Serial +#endif +#define DEBUG_PRINTF(fmt, ...) CONSOLE.printf_P(PSTR(fmt), ##__VA_ARGS__) +#else +#define DEBUG_PRINTF(...) +#endif + +#ifndef STASSID +#define STASSID "your-ssid" +#define STAPSK "your-password" +#endif + +const char* ssid = STASSID; +const char* password = STAPSK; + +struct YourEEPROMData { + // list of parameters you need to keep + // ... + + // To efficiently save and compare SDK version strings, we use their computed + // CRC32 value. + uint32_t sdkCrc; +}; + +bool checkSdkCrc() { + auto reason = ESP.getResetInfoPtr()->reason; + // In this example, the OTA update does a software restart. As coded, SDK + // version checks are only performed after a hard reset. Change the lines + // below at your discretion. + // + // Boot loop guard + // Limit crash loops erasing flash. Only run at Power On or Hardware Reset. + if (REASON_DEFAULT_RST != reason && REASON_EXT_SYS_RST != reason) { + DEBUG_PRINTF(" Boot loop guard - SDK version not checked. To perform check, do a hardware reset.\r\n"); + return true; + } + + const char* sdkVerStr = ESP.getSdkVersion(); + uint32_t sdkVersionCrc = crc32(sdkVerStr, strlen(sdkVerStr)); + + uint32_t savedSdkVersionCrc; + EEPROM.begin((sizeof(struct YourEEPROMData) + 3) & ~3); + EEPROM.get(offsetof(struct YourEEPROMData, sdkCrc), savedSdkVersionCrc); + + DEBUG_PRINTF(" Current SDK Verison: %s CRC(0x%08X)\r\n", sdkVerStr, sdkVersionCrc); + DEBUG_PRINTF(" Previous saved SDK CRC(0x%08X)\r\n", savedSdkVersionCrc); + if (sdkVersionCrc == savedSdkVersionCrc) { + return EEPROM.end(); + } + + DEBUG_PRINTF(" Handle wew SDK Version\r\n"); + // Remember new SDK CRC + EEPROM.put(offsetof(struct YourEEPROMData, sdkCrc), sdkVersionCrc); + if (EEPROM.commit() && EEPROM.end()) { + // Erase WiFi Settings and Reset + DEBUG_PRINTF(" EEPROM update successful. New SDK CRC saved.\r\n"); + DEBUG_PRINTF(" Erase config and reset: ...\r\n"); + ArduinoOTA.eraseConfigAndReset(); // Only returns on fail + DEBUG_PRINTF(" ArduinoOTA.eraseConfigAndReset() failed!\r\n"); + + } else { + DEBUG_PRINTF(" EEPROM.commit() or EEPROM.end() failed!\r\n"); + } + + return false; +} + +void setup() { + Serial.begin(115200); + Serial.println("Booting"); + // It is normal for resets generated by "ArduinoOTA.eraseConfigAndReset()" + // to be reported as "External System". + Serial.println(String("Reset Reason: ") + ESP.getResetReason()); + Serial.println("Check for changes in SDK Version:"); + if (checkSdkCrc()) { + Serial.println(" SDK version has not changed."); + } else { + Serial.println(" SDK version changed and update to saved details failed."); + } + + WiFi.mode(WIFI_STA); + WiFi.begin(ssid, password); + while (WiFi.waitForConnectResult() != WL_CONNECTED) { + Serial.println("Connection Failed! Rebooting..."); + delay(5000); + ESP.restart(); + } + + // Port defaults to 8266 + // ArduinoOTA.setPort(8266); + + // Hostname defaults to esp8266-[ChipID] + // ArduinoOTA.setHostname("myesp8266"); + + // No authentication by default + // ArduinoOTA.setPassword("admin"); + + // Password can be set with it's md5 value as well + // MD5(admin) = 21232f297a57a5a743894a0e4a801fc3 + // ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3"); + + ArduinoOTA.onStart([]() { + String type; + if (ArduinoOTA.getCommand() == U_FLASH) { + type = "sketch"; + } else { // U_FS + type = "filesystem"; + } + + // NOTE: if updating FS this would be the place to unmount FS using FS.end() + Serial.println("Start updating " + type); + }); + ArduinoOTA.onEnd([]() { + Serial.println("\nEnd"); + }); + ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { + Serial.printf("Progress: %u%%\r", (progress / (total / 100))); + }); + ArduinoOTA.onError([](ota_error_t error) { + Serial.printf("Error[%u]: ", error); + if (error == OTA_AUTH_ERROR) { + Serial.println("Auth Failed"); + } else if (error == OTA_BEGIN_ERROR) { + Serial.println("Begin Failed"); + } else if (error == OTA_CONNECT_ERROR) { + Serial.println("Connect Failed"); + } else if (error == OTA_RECEIVE_ERROR) { + Serial.println("Receive Failed"); + } else if (error == OTA_END_ERROR) { + Serial.println("End Failed"); + } + }); + ArduinoOTA.begin(); + Serial.println("Ready"); + Serial.print("IP address: "); + Serial.println(WiFi.localIP()); +} + +void loop() { + ArduinoOTA.handle(); +} diff --git a/libraries/DNSServer/examples/CaptivePortalAdvanced/CaptivePortalAdvanced.ino b/libraries/DNSServer/examples/CaptivePortalAdvanced/CaptivePortalAdvanced.ino index 55222fbc7b..1aef1afd20 100644 --- a/libraries/DNSServer/examples/CaptivePortalAdvanced/CaptivePortalAdvanced.ino +++ b/libraries/DNSServer/examples/CaptivePortalAdvanced/CaptivePortalAdvanced.ino @@ -4,6 +4,7 @@ #include #include #include +#include /* This example serves a "hello world" on a WLAN and a SoftAP at the same time. @@ -74,8 +75,8 @@ void setup() { server.on("/", handleRoot); server.on("/wifi", handleWifi); server.on("/wifisave", handleWifiSave); - server.on("/generate_204", handleRoot); // Android captive portal. Maybe not needed. Might be handled by notFound handler. - server.on("/fwlink", handleRoot); // Microsoft captive portal. Maybe not needed. Might be handled by notFound handler. + server.on(UriGlob("/generate_204*"), handleRoot); // Android captive portal. Handle "/generate_204_"-like requests. Might be handled by notFound handler. + server.on("/fwlink", handleRoot); // Microsoft captive portal. Maybe not needed. Might be handled by notFound handler. server.onNotFound(handleNotFound); server.begin(); // Web server start Serial.println("HTTP server started"); diff --git a/libraries/DNSServer/examples/CaptivePortalAdvanced/handleHttp.ino b/libraries/DNSServer/examples/CaptivePortalAdvanced/handleHttp.ino index aec2556a48..c7380017d1 100644 --- a/libraries/DNSServer/examples/CaptivePortalAdvanced/handleHttp.ino +++ b/libraries/DNSServer/examples/CaptivePortalAdvanced/handleHttp.ino @@ -27,9 +27,7 @@ void handleRoot() { boolean captivePortal() { if (!isIp(server.hostHeader()) && server.hostHeader() != (String(myHostname) + ".local")) { Serial.println("Request redirected to captive portal"); - server.sendHeader("Location", String("http://") + toStringIp(server.client().localIP()), true); - server.send(302, "text/plain", ""); // Empty content inhibits Content-length header so we have to close the socket ourselves. - server.client().stop(); // Stop is needed because we sent no content length + server.redirect(String("http://") + toStringIp(server.client().localIP())); return true; } return false; @@ -91,12 +89,7 @@ void handleWifiSave() { Serial.println("wifi save"); server.arg("n").toCharArray(ssid, sizeof(ssid) - 1); server.arg("p").toCharArray(password, sizeof(password) - 1); - server.sendHeader("Location", "wifi", true); - server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate"); - server.sendHeader("Pragma", "no-cache"); - server.sendHeader("Expires", "-1"); - server.send(302, "text/plain", ""); // Empty content inhibits Content-length header so we have to close the socket ourselves. - server.client().stop(); // Stop is needed because we sent no content length + server.redirect("wifi"); saveCredentials(); connect = strlen(ssid) > 0; // Request WLAN connect with new credentials if there is a SSID } diff --git a/libraries/DNSServer/examples/NAPTCaptivePortal/NAPTCaptivePortal.ino b/libraries/DNSServer/examples/NAPTCaptivePortal/NAPTCaptivePortal.ino index 1fa46291bb..2f238ee922 100644 --- a/libraries/DNSServer/examples/NAPTCaptivePortal/NAPTCaptivePortal.ino +++ b/libraries/DNSServer/examples/NAPTCaptivePortal/NAPTCaptivePortal.ino @@ -80,6 +80,8 @@ #include #include +#include "WifiHttp.h" + #define NAPT 1000 #define NAPT_PORT 10 diff --git a/libraries/DNSServer/examples/NAPTCaptivePortal/PortalRedirectHttp.ino b/libraries/DNSServer/examples/NAPTCaptivePortal/PortalRedirectHttp.ino index 286490772d..5de12229a5 100644 --- a/libraries/DNSServer/examples/NAPTCaptivePortal/PortalRedirectHttp.ino +++ b/libraries/DNSServer/examples/NAPTCaptivePortal/PortalRedirectHttp.ino @@ -36,13 +36,11 @@ void sendPortalRedirect(String path, String targetName) { If the "Location" header element works the HTML stuff is never seen. */ // https://tools.ietf.org/html/rfc7231#section-6.4.3 - server.sendHeader("Location", path, true); - addNoCacheHeader(); String reply = FPSTR(portalRedirectHTML); reply.reserve(reply.length() + 2 * path.length() + 80); reply.replace("{t}", targetName); reply.replace("{1}", path); - server.send(302, "text/html", reply); + server.redirect(path, reply); } #endif // LWIP_FEATURES && !LWIP_IPV6 diff --git a/libraries/DNSServer/examples/NAPTCaptivePortal/WifiHttp.ino b/libraries/DNSServer/examples/NAPTCaptivePortal/WifiHttp.h similarity index 99% rename from libraries/DNSServer/examples/NAPTCaptivePortal/WifiHttp.ino rename to libraries/DNSServer/examples/NAPTCaptivePortal/WifiHttp.h index f042327762..c3a222a492 100644 --- a/libraries/DNSServer/examples/NAPTCaptivePortal/WifiHttp.ino +++ b/libraries/DNSServer/examples/NAPTCaptivePortal/WifiHttp.h @@ -11,6 +11,10 @@ // code there till it is correct then copy/paste back here. Then, you can move // comment boarders around until the C code is back in place. +#pragma once + +#include + #ifdef DEBUG_VIEW static const char configHead[] PROGMEM = R"EOF( 8----->8------>8------ - -EOF diff --git a/tools/boards.txt.py b/tools/boards.txt.py index 89efe7f6ca..0ccfa8f4d9 100755 --- a/tools/boards.txt.py +++ b/tools/boards.txt.py @@ -112,25 +112,30 @@ '+-----------------+------------+------------------+', '| GND | | GND |', '+-----------------+------------+------------------+', - '| TX or GPIO2\* | | RX |', + '| TX or GPIO2 | | |', + '| [#tx_or_gpio2]_ | RX | |', '+-----------------+------------+------------------+', '| RX | | TX |', '+-----------------+------------+------------------+', '| GPIO0 | PullUp | DTR |', '+-----------------+------------+------------------+', - '| Reset\* | PullUp | RTS |', + '| Reset | | |', + '| [#reset]_ | PullUp | RTS |', '+-----------------+------------+------------------+', - '| GPIO15\* | PullDown | |', + '| GPIO15 | | |', + '| [#gpio15]_ | PullDown | |', '+-----------------+------------+------------------+', - '| CH\_PD | PullUp | |', + '| CH\\_PD | | |', + '| [#ch_pd]_ | PullUp | |', '+-----------------+------------+------------------+', '', - '- Note', - '- GPIO15 is also named MTDO', - '- Reset is also named RSBT or REST (adding PullUp improves the', + '.. rubric:: Notes', + '', + '.. [#tx_or_gpio2] GPIO15 is also named MTDO', + '.. [#reset] Reset is also named RSBT or REST (adding PullUp improves the', ' stability of the module)', - '- GPIO2 is alternative TX for the boot loader mode', - '- **Directly connecting a pin to VCC or GND is not a substitute for a', + '.. [#gpio15] GPIO2 is alternative TX for the boot loader mode', + '.. [#ch_pd] **Directly connecting a pin to VCC or GND is not a substitute for a', ' PullUp or PullDown resistor, doing this can break upload management', ' and the serial console, instability has also been noted in some', ' cases.**', @@ -161,15 +166,16 @@ '+---------------+------------+------------------+', '| GPIO0 | | GND |', '+---------------+------------+------------------+', - '| Reset | | RTS\* |', + '| Reset | | RTS [#rts]_ |', '+---------------+------------+------------------+', '| GPIO15 | PullDown | |', '+---------------+------------+------------------+', - '| CH\_PD | PullUp | |', + '| CH\\_PD | PullUp | |', '+---------------+------------+------------------+', '', - '- Note', - '- if no RTS is used a manual power toggle is needed', + '.. rubric:: Notes', + '', + '.. [#rts] if no RTS is used a manual power toggle is needed', '', 'Minimal Hardware Setup for Running only', '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~', @@ -187,7 +193,7 @@ '+----------+------------+----------------+', '| GPIO15 | PullDown | |', '+----------+------------+----------------+', - '| CH\_PD | PullUp | |', + '| CH\\_PD | PullUp | |', '+----------+------------+----------------+', '', 'Minimal', @@ -249,7 +255,11 @@ 'boot mode', '~~~~~~~~~', '', - 'the first value respects the pin setup of the Pins 0, 2 and 15.', + 'the first value respects the pin setup of the Pins 0, 2 and 15', + '', + '.. code-block::', + '', + ' Number = (GPIO15 << 2) | (GPIO0 << 1) | GPIO2', '', '+----------+----------+---------+---------+-------------+', '| Number | GPIO15 | GPIO0 | GPIO2 | Mode |', @@ -271,7 +281,6 @@ '| 7 | 3.3V | 3.3V | 3.3V | SDIO |', '+----------+----------+---------+---------+-------------+', '', - 'note: - number = ((GPIO15 << 2) \| (GPIO0 << 1) \| GPIO2);', ], }), ( 'esp8285', { @@ -436,6 +445,23 @@ ], 'desc': [ 'ESPresso Lite 2.0 is an Arduino-compatible Wi-Fi development board based on an earlier V1 (beta version). Re-designed together with Cytron Technologies, the newly-revised ESPresso Lite V2.0 features the auto-load/auto-program function, eliminating the previous need to reset the board manually before flashing a new program. It also feature two user programmable side buttons and a reset button. The special distinctive features of on-board pads for I2C sensor and actuator is retained.', ] }), +( 'mercury1', { + 'name': 'Mercury 1.0', + 'opts': { + '.build.board': 'mercury', + '.build.variant': 'mercury_v1', + }, + 'macro': [ + 'resetmethod_nodemcu', + 'flashmode_dio', + 'flashfreq_40', + '4M', + ], + 'desc': [ 'Based on ESP8266, Mercury is board developed by Ralio Technologies. Board supports on motor drivers and direct-connect feature for various endpoints.', + '', + 'Product page: https://www.raliotech.com', + ], + }), ( 'phoenix_v1', { 'name': 'Phoenix 1.0', 'opts': { @@ -621,6 +647,21 @@ 'serial': '921', 'desc': [ 'Product page: https://www.wemos.cc/' ], }), + ( 'd1_wroom_02', { + 'name': 'LOLIN(WEMOS) D1 ESP-WROOM-02', + 'opts': { + '.build.board': 'ESP8266_WEMOS_D1WROOM02', + '.build.variant': 'd1_mini', + }, + 'macro': [ + 'resetmethod_nodemcu', + 'flashmode_dio', + 'flashfreq_26', + '2M', + ], + 'serial': '921', + 'desc': [ 'No real product pages. See: https://www.instructables.com/How-to-Use-Wemos-ESP-Wroom-02-D1-Mini-WiFi-Module-/ or https://www.arduino-tech.com/wemos-esp-wroom-02-mainboard-d1-mini-wifi-module-esp826618650-battery/ ' ], + }), ( 'd1_mini_clone', { 'name': 'LOLIN(WEMOS) D1 mini (clone)', 'opts': { @@ -741,14 +782,10 @@ ], 'desc': [ 'ESPino by ThaiEasyElec using WROOM-02 module from Espressif Systems with 4 MB Flash.', '', - 'We will update an English description soon. - Product page:', - 'http://thaieasyelec.com/products/wireless-modules/wifi-modules/espino-wifi-development-board-detail.html', - '- Schematics:', - 'www.thaieasyelec.com/downloads/ETEE052/ETEE052\_ESPino\_Schematic.pdf -', - 'Dimensions:', - 'http://thaieasyelec.com/downloads/ETEE052/ETEE052\_ESPino\_Dimension.pdf', - '- Pinouts:', - 'http://thaieasyelec.com/downloads/ETEE052/ETEE052\_ESPino\_User\_Manual\_TH\_v1\_0\_20160204.pdf (Please see pg. 8)', + '* Product page (retired product): https://www.thaieasyelec.com/product/%E0%B8%A2%E0%B8%81%E0%B9%80%E0%B8%A5%E0%B8%B4%E0%B8%81%E0%B8%88%E0%B8%B3%E0%B8%AB%E0%B8%99%E0%B9%88%E0%B8%B2%E0%B8%A2-retired-espino-wifi-development-board/11000833173001086', + '* Schematics: https://downloads.thaieasyelec.com/ETEE052/ETEE052\\_ESPino\\_Schematic.pdf', + '* Dimensions: https://downloads.thaieasyelec.com/ETEE052/ETEE052\\_ESPino\\_Dimension.pdf', + '* Pinouts (Please see pg.8): https://downloads.thaieasyelec.com/ETEE052/ETEE052\\_ESPino\\_User\\_Manual\\_TH\\_v1\\_0\\_20160204.pdf', ], }), ( 'wifinfo', { @@ -1030,6 +1067,7 @@ ( '.build.core', 'esp8266' ), ( '.build.variant', 'generic' ), ( '.build.spiffs_pagesize', '256' ), + ( '.build.debug_optim', '' ), ( '.build.debug_port', '' ), ( '.build.debug_level', '' ), ]), @@ -1085,6 +1123,10 @@ ( '.menu.FlashFreq.26.build.flash_freq', '26' ), ]), + 'flashfreq_26': collections.OrderedDict([ + ( '.build.flash_freq', '26' ), + ]), + 'flashfreq_40': collections.OrderedDict([ ( '.build.flash_freq', '40' ), ]), @@ -1341,6 +1383,12 @@ def all_debug (): ( '.menu.dbg.Serial1.build.debug_port', '-DDEBUG_ESP_PORT=Serial1' ), ( '.menu.lvl.None____', 'None' ), ( '.menu.lvl.None____.build.debug_level', '' ), + ( '.menu.optim.Smallest', 'None' ), + ( '.menu.optim.Smallest.build.debug_optim', '-Os' ), + ( '.menu.optim.Lite', 'Lite' ), + ( '.menu.optim.Lite.build.debug_optim', '-Os -fno-optimize-sibling-calls' ), + ( '.menu.optim.Full', 'Optimum' ), + ( '.menu.optim.Full.build.debug_optim', '-Og' ), ]) for optlist in options: @@ -1600,13 +1648,13 @@ def all_flash_map (): print("generated: flash map config file (in cores/esp8266/FlashMap.h)") return { - 'autoflash': { - '.menu.eesz.autoflash': 'Mapping defined by Hardware and Sketch', - '.menu.eesz.autoflash.build.flash_size': '16M', - '.menu.eesz.autoflash.build.flash_ld': 'eagle.flash.auto.ld', - '.menu.eesz.autoflash.build.extra_flags': '-DFLASH_MAP_SUPPORT=1', - '.menu.eesz.autoflash.upload.maximum_size': '1044464', - }, + 'autoflash': collections.OrderedDict([ + ('.menu.eesz.autoflash', 'Mapping defined by Hardware and Sketch'), + ('.menu.eesz.autoflash.build.flash_size', '16M'), + ('.menu.eesz.autoflash.build.flash_ld', 'eagle.flash.auto.ld'), + ('.menu.eesz.autoflash.build.extra_flags', '-DFLASH_MAP_SUPPORT=1'), + ('.menu.eesz.autoflash.upload.maximum_size', '1044464') + ]), '512K': f512, '1M': f1m, '2M': f2m, @@ -1649,8 +1697,19 @@ def sdk (): ('.menu.sdk.nonosdk_190313.build.sdk', 'NONOSDK22x_190313'), ('.menu.sdk.nonosdk221', 'nonos-sdk 2.2.1 (legacy)'), ('.menu.sdk.nonosdk221.build.sdk', 'NONOSDK221'), - ('.menu.sdk.nonosdk3v0', 'nonos-sdk pre-3 (180626 known issues)'), - ('.menu.sdk.nonosdk3v0.build.sdk', 'NONOSDK3V0'), + ('.menu.sdk.nonosdk305', 'nonos-sdk 3.0.5 (experimental)'), + ('.menu.sdk.nonosdk305.build.sdk', 'NONOSDK305'), + ]) + } + +################################################################ + +def float_in_iram (): + return { 'iramfloat': collections.OrderedDict([ + ('.menu.iramfloat.no', 'in IROM'), + ('.menu.iramfloat.no.build.iramfloat', '-DFP_IN_IROM'), + ('.menu.iramfloat.yes', 'allowed in ISR'), + ('.menu.iramfloat.yes.build.iramfloat', '-DFP_IN_IRAM'), ]) } @@ -1683,6 +1742,7 @@ def all_boards (): macros.update(led('led', led_default, range(0,led_max+1))) macros.update(led('led216', 2, { 16 })) macros.update(sdk()) + macros.update(float_in_iram()) if boardfilteropt or excludeboards: print('#') @@ -1721,12 +1781,14 @@ def all_boards (): print('menu.ResetMethod=Reset Method') print('menu.dbg=Debug port') print('menu.lvl=Debug Level') + print('menu.optim=Debug Optimization') print('menu.ip=lwIP Variant') print('menu.vt=VTables') print('menu.exception=C++ Exceptions') print('menu.stacksmash=Stack Protection') print('menu.wipe=Erase Flash') - print('menu.sdk=Espressif FW') + print('menu.sdk=NONOS SDK Version') + print('menu.iramfloat=Floating Point operations') print('menu.ssl=SSL Support') print('menu.mmu=MMU') print('menu.non32xfer=Non-32-Bit Access') @@ -1764,6 +1826,7 @@ def all_boards (): macrolist += speeds[default_speed] macrolist += [ 'autoflash' ] + macrolist += [ 'iramfloat' ] for block in macrolist: for optname in macros[block]: diff --git a/tools/build.py b/tools/build.py index 378c4a9f9d..dd494ef747 100755 --- a/tools/build.py +++ b/tools/build.py @@ -30,34 +30,25 @@ import shutil -# Arduino-builder needs forward-slash paths for passed in params or it cannot -# launch the needed toolset. -def windowsize_paths(l): - """Convert forward-slash paths to backslash paths referenced from C:""" - out = [] - for i in l: - if i.startswith('/'): - i = 'C:' + i - out += [i.replace('/', '\\')] - return out - -def compile(tmp_dir, sketch, cache, tools_dir, hardware_dir, ide_path, f, args): +def compile(tmp_dir, sketch, cache, ide_path, f, args): cmd = [] - cmd += [ide_path + '/arduino-builder'] + cmd += [os.path.join(ide_path, 'arduino-builder')] cmd += ['-compile', '-logger=human'] cmd += ['-build-path', tmp_dir] - cmd += ['-tools', ide_path + '/tools-builder'] if cache != "": cmd += ['-build-cache', cache ] - if args.library_path: - for lib_dir in args.library_path: - cmd += ['-libraries', lib_dir] - cmd += ['-hardware', ide_path + '/hardware'] - if args.hardware_dir: - for hw_dir in args.hardware_dir: - cmd += ['-hardware', hw_dir] - else: - cmd += ['-hardware', hardware_dir] + + cmd += ['-tools', os.path.join(ide_path, 'tools-builder')] + cmd += ['-hardware', os.path.join(ide_path, 'hardware')] + + flag_paths = [ + ['-tools', args.tool_path], + ['-libraries', args.library_path], + ['-hardware', args.hardware_path]] + for flag, paths in flag_paths: + for path in paths or []: + cmd += [flag, path] + # Debug=Serial,DebugLevel=Core____ fqbn = '-fqbn=esp8266com:esp8266:{board_name}:' \ 'xtal={cpu_freq},' \ @@ -72,16 +63,13 @@ def compile(tmp_dir, sketch, cache, tools_dir, hardware_dir, ide_path, f, args): if args.waveform_phase: fqbn += ',waveform=phase' cmd += [fqbn] - cmd += ['-built-in-libraries', ide_path + '/libraries'] + cmd += ['-built-in-libraries', os.path.join(ide_path, 'libraries')] cmd += ['-ide-version=10802'] cmd += ['-warnings={warnings}'.format(**vars(args))] if args.verbose: cmd += ['-verbose'] cmd += [sketch] - if platform.system() == "Windows": - cmd = windowsize_paths(cmd) - if args.verbose: print('Building: ' + " ".join(cmd), file=f) @@ -95,12 +83,14 @@ def parse_args(): action='store_true') parser.add_argument('-i', '--ide_path', help='Arduino IDE path') parser.add_argument('-p', '--build_path', help='Build directory') - parser.add_argument('-l', '--library_path', help='Additional library path', + parser.add_argument('-t', '--tool_path', help='Additional tool path', action='append') - parser.add_argument('-d', '--hardware_dir', help='Additional hardware path', + parser.add_argument('-d', '--hardware_path', help='Additional hardware path', + action='append') + parser.add_argument('-l', '--library_path', help='Additional library path', action='append') parser.add_argument('-b', '--board_name', help='Board name', default='generic') - parser.add_argument('-s', '--flash_size', help='Flash size', default='512K64', + parser.add_argument('-s', '--flash_size', help='Flash size', default='4M1M', choices=['512K0', '512K64', '1M512', '4M1M', '4M3M']) parser.add_argument('-f', '--cpu_freq', help='CPU frequency', default=80, choices=[80, 160], type=int) @@ -112,7 +102,7 @@ def parse_args(): default='none', choices=['none', 'all', 'more']) parser.add_argument('-o', '--output_binary', help='File name for output binary') parser.add_argument('-k', '--keep', action='store_true', - help='Don\'t delete temporary build directory') + help="Don't delete temporary build directory") parser.add_argument('--flash_freq', help='Flash frequency', default=40, type=int, choices=[40, 80]) parser.add_argument('--debug_port', help='Debug port', @@ -121,6 +111,9 @@ def parse_args(): help='Select waveform locked on phase') parser.add_argument('--debug_level', help='Debug level') parser.add_argument('--build_cache', help='Build directory to cache core.a', default='') + parser.add_argument('--log', nargs='?', help='Redirect output to a file', + type=argparse.FileType('w'), + default=sys.stdout) parser.add_argument('sketch_path', help='Sketch file path') return parser.parse_args() @@ -128,25 +121,17 @@ def main(): args = parse_args() ide_path = args.ide_path - if not ide_path: - ide_path = os.environ.get('ARDUINO_IDE_PATH') - if not ide_path: - print("Please specify Arduino IDE path via --ide_path option" - "or ARDUINO_IDE_PATH environment variable.", file=sys.stderr) - return 2 - sketch_path = args.sketch_path tmp_dir = args.build_path + created_tmp_dir = False if not tmp_dir: tmp_dir = tempfile.mkdtemp() created_tmp_dir = True - tools_dir = os.path.dirname(os.path.realpath(__file__)) + '/../tools' - # this is not the correct hardware folder to add. - hardware_dir = os.path.dirname(os.path.realpath(__file__)) + '/../cores' + file = os.path.realpath(__file__) - output_name = tmp_dir + '/' + os.path.basename(sketch_path) + '.bin' + output_name = os.path.join(tmp_dir, f'{os.path.basename(sketch_path)}.bin') if args.verbose: print("Sketch: ", sketch_path) @@ -154,12 +139,7 @@ def main(): print("Cache dir: ", args.build_cache) print("Output: ", output_name) - if args.verbose: - f = sys.stdout - else: - f = open(tmp_dir + '/build.log', 'w') - - res = compile(tmp_dir, sketch_path, args.build_cache, tools_dir, hardware_dir, ide_path, f, args) + res = compile(tmp_dir, sketch_path, args.build_cache, ide_path, args.log, args) if res != 0: return res diff --git a/tools/cert.py b/tools/cert.py index 7498d5ee62..f319ef0f30 100755 --- a/tools/cert.py +++ b/tools/cert.py @@ -41,8 +41,8 @@ def printData(data, showPub = True): name = re.sub('[^a-zA-Z0-9_]', '_', cn) print('// CN: {} => name: {}'.format(cn, name)) - print('// not valid before:', xcert.not_valid_before) - print('// not valid after: ', xcert.not_valid_after) + print('// not valid before:', xcert.not_valid_before_utc) + print('// not valid after: ', xcert.not_valid_after_utc) if showPub: @@ -114,7 +114,7 @@ def main(): print() print('// this file is autogenerated - any modification will be overwritten') print('// unused symbols will not be linked in the final binary') - print('// generated on {}'.format(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))) + print('// generated on {}'.format(datetime.datetime.now(datetime.UTC).strftime("%Y-%m-%d %H:%M:%S"))) print('// by {}'.format(sys.argv)) print() print('#pragma once') diff --git a/tools/decoder.py b/tools/decoder.py new file mode 100755 index 0000000000..b1f1706767 --- /dev/null +++ b/tools/decoder.py @@ -0,0 +1,222 @@ +#!/usr/bin/env python3 + +# Baseline code from https://github.com/me-no-dev/EspExceptionDecoder by Hristo Gochkov (@me-no-dev) +# - https://github.com/me-no-dev/EspExceptionDecoder/blob/master/src/EspExceptionDecoder.java +# Stack line detection from https://github.com/platformio/platform-espressif8266/ monitor exception filter by Vojtěch Boček (@Tasssadar) +# - https://github.com/platformio/platform-espressif8266/commits?author=Tasssadar + +import os +import argparse +import sys +import re +import subprocess +import shutil + +# https://github.com/me-no-dev/EspExceptionDecoder/blob/349d17e4c9896306e2c00b4932be3ba510cad208/src/EspExceptionDecoder.java#L59-L90 +EXCEPTION_CODES = ( + "Illegal instruction", + "SYSCALL instruction", + "InstructionFetchError: Processor internal physical address or data error during " + "instruction fetch", + "LoadStoreError: Processor internal physical address or data error during load or store", + "Level1Interrupt: Level-1 interrupt as indicated by set level-1 bits in " + "the INTERRUPT register", + "Alloca: MOVSP instruction, if caller's registers are not in the register file", + "IntegerDivideByZero: QUOS, QUOU, REMS, or REMU divisor operand is zero", + "reserved", + "Privileged: Attempt to execute a privileged operation when CRING ? 0", + "LoadStoreAlignmentCause: Load or store to an unaligned address", + "reserved", + "reserved", + "InstrPIFDataError: PIF data error during instruction fetch", + "LoadStorePIFDataError: Synchronous PIF data error during LoadStore access", + "InstrPIFAddrError: PIF address error during instruction fetch", + "LoadStorePIFAddrError: Synchronous PIF address error during LoadStore access", + "InstTLBMiss: Error during Instruction TLB refill", + "InstTLBMultiHit: Multiple instruction TLB entries matched", + "InstFetchPrivilege: An instruction fetch referenced a virtual address at a ring level " + "less than CRING", + "reserved", + "InstFetchProhibited: An instruction fetch referenced a page mapped with an attribute " + "that does not permit instruction fetch", + "reserved", + "reserved", + "reserved", + "LoadStoreTLBMiss: Error during TLB refill for a load or store", + "LoadStoreTLBMultiHit: Multiple TLB entries matched for a load or store", + "LoadStorePrivilege: A load or store referenced a virtual address at a ring level " + "less than CRING", + "reserved", + "LoadProhibited: A load referenced a page mapped with an attribute that does not " + "permit loads", + "StoreProhibited: A store referenced a page mapped with an attribute that does not " + "permit stores", +) + + +# similar to java version, which used `list` and re-formatted it +# instead, simply use an already short-format `info line` +# TODO `info symbol`? revert to `list`? +def addresses_gdb(gdb, elf, addresses): + cmd = [gdb, "--batch"] + for address in addresses: + if not address.startswith("0x"): + address = f"0x{address}" + cmd.extend(["--ex", f"info line *{address}"]) + cmd.append(elf) + + with subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True) as proc: + for line in proc.stdout.readlines(): + if "No line number" in line: + continue + yield line.strip() + + +# original approach using addr2line, which is pretty enough already +def addresses_addr2line(addr2line, elf, addresses): + cmd = [ + addr2line, + "--addresses", + "--inlines", + "--functions", + "--pretty-print", + "--demangle", + "--exe", + elf, + ] + + for address in addresses: + if not address.startswith("0x"): + address = f"0x{address}" + cmd.append(address) + + with subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True) as proc: + for line in proc.stdout.readlines(): + if "??:0" in line: + continue + yield line.strip() + + +def decode_lines(format_addresses, elf, lines): + ANY_ADDR_RE = re.compile(r"0x[0-9a-fA-F]{8}|[0-9a-fA-F]{8}") + HEX_ADDR_RE = re.compile(r"0x[0-9a-f]{8}") + + MEM_ERR_LINE_RE = re.compile(r"^(Stack|last failed alloc call)") + + STACK_LINE_RE = re.compile(r"^[0-9a-f]{8}:\s\s+") + + IGNORE_FIRMWARE_RE = re.compile(r"^(epc1=0x........, |Fatal exception )") + + CUT_HERE_STRING = "CUT HERE FOR EXCEPTION DECODER" + DECODE_IT = "DECODE IT" + EXCEPTION_STRING = "Exception (" + EPC_STRING = "epc1=" + + # either print everything as-is, or cache current string and dump after stack contents end + last_stack = None + stack_addresses = {} + + in_stack = False + + def print_all_addresses(addresses): + for ctx, addrs in addresses.items(): + print() + print(ctx) + for formatted in format_addresses(elf, addrs): + print(formatted) + return dict() + + def format_address(address): + return "\n".join(format_addresses(elf, [address])) + + for line in lines: + # ctx could happen multiple times. for the 2nd one, reset list + # ctx: bearssl *or* ctx: cont *or* ctx: sys *or* ctx: whatever + if in_stack and "ctx:" in line: + stack_addresses = print_all_addresses(stack_addresses) + last_stack = line.strip() + # 3fffffb0: feefeffe feefeffe 3ffe85d8 401004ed + elif IGNORE_FIRMWARE_RE.match(line): + continue + elif in_stack and STACK_LINE_RE.match(line): + _, addrs = line.split(":") + addrs = ANY_ADDR_RE.findall(addrs) + stack_addresses.setdefault(last_stack, []) + stack_addresses[last_stack].extend(addrs) + # epc1=0xfffefefe epc2=0xfefefefe epc3=0xefefefef excvaddr=0xfefefefe depc=0xfefefefe + elif EPC_STRING in line: + pairs = line.split() + for pair in pairs: + name, addr = pair.split("=") + if name in ["epc1", "excvaddr"]: + output = format_address(addr) + if output: + print(f"{name}={output}") + # Exception (123): + # Other reasons coming before the guard shown as-is + elif EXCEPTION_STRING in line: + number = line.strip()[len(EXCEPTION_STRING) : -2] + print(f"Exception ({number}) - {EXCEPTION_CODES[int(number)]}") + # stack smashing detected at + # last failed alloc call: ()[@] + elif MEM_ERR_LINE_RE.match(line): + for addr in ANY_ADDR_RE.findall(line): + line = line.replace(addr, format_address(addr)) + print() + print(line.strip()) + # postmortem guards our actual stack dump values with these + elif ">>>stack>>>" in line: + in_stack = True + # ignore + elif "<<> 24) & 255 return raw + def add_crc(out): with open(out, "rb") as binfile: raw = bytearray(binfile.read()) @@ -141,15 +185,16 @@ def add_crc(out): with open(out, "wb") as binfile: binfile.write(raw) + def gzip_bin(mode, out): import gzip firmware_path = out - gzip_path = firmware_path + '.gz' - orig_path = firmware_path + '.orig' + gzip_path = f"{firmware_path}.gz" + orig_path = f"{firmware_path}.orig" if os.path.exists(gzip_path): os.remove(gzip_path) - print('GZipping firmware ' + firmware_path) + print(f'GZipping firmware {firmware_path}') with open(firmware_path, 'rb') as firmware_file, \ gzip.open(gzip_path, 'wb') as dest: data = firmware_file.read() @@ -162,10 +207,11 @@ def gzip_bin(mode, out): if mode == "PIO": if os.path.exists(orig_path): os.remove(orig_path) - print('Moving original firmware to ' + orig_path) + print(f'Moving original firmware to {orig_path}') os.rename(firmware_path, orig_path) os.rename(gzip_path, firmware_path) + def main(): parser = argparse.ArgumentParser(description='Create a BIN file from eboot.elf and Arduino sketch.elf for upload by esptool.py') parser.add_argument('-e', '--eboot', action='store', required=True, help='Path to the Arduino eboot.elf bootloader') @@ -179,8 +225,7 @@ def main(): args = parser.parse_args() - print('Creating BIN file "{out}" using "{eboot}" and "{app}"'.format( - out=args.out, eboot=args.eboot, app=args.app)) + print(f'Creating BIN file "{args.out}" using "{args.eboot}" and "{args.app}"') with open(args.out, "wb") as out: def wrapper(**kwargs): diff --git a/tools/format_tzdata.py b/tools/format_tzdata.py new file mode 100755 index 0000000000..609a9218bf --- /dev/null +++ b/tools/format_tzdata.py @@ -0,0 +1,173 @@ +#!/usr/bin/env python3 + +# this script refreshes world timezone definitions in +# cores/esp8266/TZ.h +# +# use the file output argument or stdout redirect to overwrite the target file + +import argparse +import contextlib +import datetime +import mmap +import os +import pathlib +import re +import sys +import pathlib + +from importlib import resources + +import tzdata # https://tzdata.readthedocs.io/en/latest/ + + +def known_alias(entry): + swaps = { + "Europe/Zaporozhye": "Europe/Zaporizhzhia", + "Europe/Uzhgorod": "Europe/Uzhhorod", + } + + return swaps.get(entry) + + +def fix_name(name): + swaps = [["-", "m"], ["+", "p"], ["/", "_"]] + + for lhs, rhs in swaps: + name = name.replace(lhs, rhs) + + return name + + +def utc_alias(zone): + return zone in ( + "Universal", + "UTC", + "UCT", + "Zulu", + "GMT", + "GMT+0", + "GMT-0", + "GMT0", + "Greenwich", + ) + + +def tzdata_resource_from_name(name): + pair = name.rsplit("/", 1) + if len(pair) == 1: + return resources.files("tzdata.zoneinfo") / pair[0] + + return resources.files(f'tzdata.zoneinfo.{pair[0].replace("/", ".")}') / pair[1] + + +def make_zones_list(f): + return [zone.strip() for zone in f.readlines()] + + +def make_zones(args): + out = [] + + for zone in make_zones_list(args.zones): + if args.root: + target = args.root / zone + else: + target = tzdata_resource_from_name(zone) + + with target.open("rb") as f: + magic = f.read(4) + if magic != b"TZif": + continue + + m = mmap.mmap(f.fileno(), 0, prot=mmap.PROT_READ) + newline = m.rfind(b"\n", 0, len(m) - 1) + if newline < 0: + continue + + m.seek(newline + 1) + tz = m.readline().strip() + tz = tz.decode("ascii") + + if alias := known_alias(zone): + out.append([alias, tz]) + + out.append([zone, tz]) + + out.sort(key=lambda x: x[0]) + return out + + +def markdown(zones): + utcs = [] + rows = [] + + for name, value in zones: + if utc_alias(name): + utcs.append(name) + continue + + rows.append(f"|{name}|`{value}`|") + + print("|Name|Value|") + print("|---|---|") + for name in utcs: + print(f"|{name}|UTC0|") + + last = "" + for row in rows: + prefix, _, _ = row.partition("/") + if last != prefix: + last = prefix + print("|||") + print(row) + print() + print("---") + print() + print(f"*Generated with *{tzdata.IANA_VERSION=} {tzdata.__version__=}*") + + +def header(zones): + print("// ! ! ! DO NOT EDIT, AUTOMATICALLY GENERATED ! ! !") + print(f"// File created {datetime.datetime.now(tz=datetime.timezone.utc)}") + print(f"// Based on IANA database {tzdata.IANA_VERSION}") + print(f"// Re-run /tools/{sys.argv[0]} to update") + print() + print("#pragma once") + print() + for name, value in zones: + print(f'#define TZ_{fix_name(name)}\tPSTR("{value}")') + + +if __name__ == "__main__": + parser = argparse.ArgumentParser( + formatter_class=argparse.ArgumentDefaultsHelpFormatter, + ) + parser.add_argument( + "--output", + type=argparse.FileType("w", encoding="utf-8"), + default=sys.stdout, + ) + parser.add_argument( + "--format", + default="header", + choices=["header", "markdown"], + ) + parser.add_argument( + "--zones", + type=argparse.FileType("r", encoding="utf-8"), + help="Zone names file, one per line", + default=os.path.join(os.path.dirname(tzdata.__file__), "zones"), + ) + parser.add_argument( + "--root", + help="Where do we get raw zoneinfo files from", + type=pathlib.Path, + ) + + args = parser.parse_args() + zones = make_zones(args) + + with contextlib.redirect_stdout(args.output): + if args.format == "markdown": + markdown(zones) + elif args.format == "header": + header(zones) diff --git a/tools/mkbuildoptglobals.py b/tools/mkbuildoptglobals.py index 23a9e940e1..62a3373aee 100644 --- a/tools/mkbuildoptglobals.py +++ b/tools/mkbuildoptglobals.py @@ -81,7 +81,7 @@ build.opt.fqfn={build.path}/core/build.opt mkbuildoptglobals.extra_flags= -recipe.hooks.prebuild.2.pattern="{runtime.tools.python3.path}/python3" "{runtime.tools.mkbuildoptglobals}" "{runtime.ide.path}" {runtime.ide.version} "{build.path}" "{build.opt.fqfn}" "{globals.h.source.fqfn}" "{commonhfile.fqfn}" {mkbuildoptglobals.extra_flags} +recipe.hooks.prebuild.2.pattern="{runtime.tools.python3.path}/python3" -I "{runtime.tools.mkbuildoptglobals}" "{runtime.ide.path}" {runtime.ide.version} "{build.path}" "{build.opt.fqfn}" "{globals.h.source.fqfn}" "{commonhfile.fqfn}" {mkbuildoptglobals.extra_flags} compiler.cpreprocessor.flags=-D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ -D_GNU_SOURCE -DESP8266 @{build.opt.path} "-I{compiler.sdk.path}/include" "-I{compiler.sdk.path}/{build.lwip_include}" "-I{compiler.libc.path}/include" "-I{build.path}/core" """ @@ -183,13 +183,24 @@ """ import argparse -from shutil import copyfile import glob +import locale import os import platform import sys import textwrap import time +import traceback + +from shutil import copyfile + + +# Stay in sync with our bundled version +PYTHON_REQUIRES = (3, 7) + +if sys.version_info < PYTHON_REQUIRES: + raise SystemExit(f"{__file__}\nMinimal supported version of Python is {PYTHON_REQUIRES[0]}.{PYTHON_REQUIRES[1]}") + # Need to work on signature line used for match to avoid conflicts with # existing embedded documentation methods. @@ -201,6 +212,7 @@ err_print_flag = False msg_print_buf = "" debug_enabled = False +default_encoding = None # Issues trying to address through buffered printing # 1. Arduino IDE 2.0 RC5 does not show stderr text in color. Text printed does @@ -295,16 +307,16 @@ def copy_create_build_file(source_fqfn, build_target_fqfn): pass return True # file changed - def add_include_line(build_opt_fqfn, include_fqfn): + global default_encoding if not os.path.exists(include_fqfn): # If file is missing, we need an place holder - with open(include_fqfn, 'w', encoding="utf-8"): + with open(include_fqfn, 'w', encoding=default_encoding): pass - print("add_include_line: Created " + include_fqfn) - with open(build_opt_fqfn, 'a', encoding="utf-8") as build_opt: - build_opt.write('-include "' + include_fqfn.replace('\\', '\\\\') + '"\n') + print_msg("add_include_line: Created " + include_fqfn) + with open(build_opt_fqfn, 'a', encoding=default_encoding) as build_opt: + build_opt.write('-include "' + include_fqfn.replace('\\', '\\\\') + '"\n') def extract_create_build_opt_file(globals_h_fqfn, file_name, build_opt_fqfn): """ @@ -313,8 +325,9 @@ def extract_create_build_opt_file(globals_h_fqfn, file_name, build_opt_fqfn): copy of Sketch.ino.globals.h. """ global build_opt_signature + global default_encoding - build_opt = open(build_opt_fqfn, 'w', encoding="utf-8") + build_opt = open(build_opt_fqfn, 'w', encoding=default_encoding) if not os.path.exists(globals_h_fqfn) or (0 == os.path.getsize(globals_h_fqfn)): build_opt.close() return False @@ -416,68 +429,6 @@ def discover_1st_time_run(build_path): return 0 == count -def find_preferences_txt(runtime_ide_path): - """ - Check for perferences.txt in well-known locations. Most OSs have two - possibilities. When "portable" is present, it takes priority. Otherwise, the - remaining path wins. However, Windows has two. Depending on the install - source, the APP store or website download, both may appear and create an - ambiguous result. - - Return two item list - Two non "None" items indicate an ambiguous state. - - OS Path list for Arduino IDE 1.6.0 and newer - from: https://www.arduino.cc/en/hacking/preferences - """ - platform_name = platform.system() - if "Linux" == platform_name: - # Test for portable 1ST - # /portable/preferences.txt (when used in portable mode) - # For more on portable mode see https://docs.arduino.cc/software/ide-v1/tutorials/PortableIDE - fqfn = os.path.normpath(runtime_ide_path + "/portable/preferences.txt") - # Linux - verified with Arduino IDE 1.8.19 - if os.path.exists(fqfn): - return [fqfn, None] - fqfn = os.path.expanduser("~/.arduino15/preferences.txt") - # Linux - verified with Arduino IDE 1.8.18 and 2.0 RC5 64bit and AppImage - if os.path.exists(fqfn): - return [fqfn, None] - elif "Windows" == platform_name: - fqfn = os.path.normpath(runtime_ide_path + "\portable\preferences.txt") - # verified on Windows 10 with Arduino IDE 1.8.19 - if os.path.exists(fqfn): - return [fqfn, None] - # It is never simple. Arduino from the Windows APP store or the download - # Windows 8 and up option will save "preferences.txt" in one location. - # The downloaded Windows 7 (and up version) will put "preferences.txt" - # in a different location. When both are present due to various possible - # scenarios, use the more modern. - fqfn = os.path.expanduser("~\Documents\ArduinoData\preferences.txt") - # Path for "Windows app" - verified on Windows 10 with Arduino IDE 1.8.19 from APP store - fqfn2 = os.path.expanduser("~\AppData\local\Arduino15\preferences.txt") - # Path for Windows 7 and up - verified on Windows 10 with Arduino IDE 1.8.19 - if os.path.exists(fqfn): - if os.path.exists(fqfn2): - print_err("Multiple 'preferences.txt' files found:") - print_err(" " + fqfn) - print_err(" " + fqfn2) - return [fqfn, None] - else: - return [fqfn, fqfn2] - elif os.path.exists(fqfn2): - return [fqfn2, None] - elif "Darwin" == platform_name: - # Portable is not compatable with Mac OS X - # see https://docs.arduino.cc/software/ide-v1/tutorials/PortableIDE - fqfn = os.path.expanduser("~/Library/Arduino15/preferences.txt") - # Mac OS X - unverified - if os.path.exists(fqfn): - return [fqfn, None] - - print_err("File preferences.txt not found on " + platform_name) - return [None, None] - - def get_preferences_txt(file_fqfn, key): # Get Key Value, key is allowed to be missing. # We assume file file_fqfn exists @@ -505,40 +456,28 @@ def check_preferences_txt(runtime_ide_path, preferences_file): else: print_err(f"Override preferences file '{preferences_file}' not found.") - elif runtime_ide_path != None: - # For a particular install, search the expected locations for platform.txt - # This should never fail. - file_fqfn = find_preferences_txt(runtime_ide_path) - if file_fqfn[0] != None: - print_msg(f"Using preferences from '{file_fqfn[0]}'") - val0 = get_preferences_txt(file_fqfn[0], key) - val1 = val0 - if file_fqfn[1] != None: - val1 = get_preferences_txt(file_fqfn[1], key) - if val0 == val1: # We can safely ignore that there were two preferences.txt files - return val0 - else: - print_err(f"Found too many preferences.txt files with different values for '{key}'") - raise UserWarning - else: - # Something is wrong with the installation or our understanding of the installation. - print_err("'preferences.txt' file missing from well known locations.") - - return None - + # Referencing the preferences.txt for an indication of shared "core.a" + # caching is unreliable. There are too many places reference.txt can be + # stored and no hints of which the Arduino build might be using. Unless + # directed otherwise, assume "core.a" caching true. + print_msg(f"Assume aggressive 'core.a' caching enabled.") + return True def touch(fname, times=None): with open(fname, "ab") as file: - os.utime(file.fileno(), times) + file.close(); + os.utime(fname, times) def synchronous_touch(globals_h_fqfn, commonhfile_fqfn): global debug_enabled # touch both files with the same timestamp touch(globals_h_fqfn) with open(globals_h_fqfn, "rb") as file: - ts = os.stat(file.fileno()) - with open(commonhfile_fqfn, "ab") as file2: - os.utime(file2.fileno(), ns=(ts.st_atime_ns, ts.st_mtime_ns)) + file.close() + with open(commonhfile_fqfn, "ab") as file2: + file2.close() + ts = os.stat(globals_h_fqfn) + os.utime(commonhfile_fqfn, ns=(ts.st_atime_ns, ts.st_mtime_ns)) if debug_enabled: print_dbg("After synchronous_touch") @@ -552,12 +491,8 @@ def synchronous_touch(globals_h_fqfn, commonhfile_fqfn): def determine_cache_state(args, runtime_ide_path, source_globals_h_fqfn): global docs_url print_dbg(f"runtime_ide_version: {args.runtime_ide_version}") - if args.runtime_ide_version < 10802: # CI also has version 10607 -- and args.runtime_ide_version != 10607: - # Aggresive core caching - not implemented before version 1.8.2 - # Note, Arduino IDE 2.0 rc5 has version 1.6.7 and has aggressive caching. - print_dbg(f"Old version ({args.runtime_ide_version}) of Arduino IDE no aggressive caching option") - return False - elif args.cache_core != None: + + if args.cache_core != None: print_msg(f"Preferences override, this prebuild script assumes the 'compiler.cache_core' parameter is set to {args.cache_core}") print_msg(f"To change, modify 'mkbuildoptglobals.extra_flags=(--cache_core | --no_cache_core)' in 'platform.local.txt'") return args.cache_core @@ -591,19 +526,7 @@ def determine_cache_state(args, runtime_ide_path, source_globals_h_fqfn): preferences_fqfn = os.path.expanduser(preferences_fqfn) print_dbg(f"determine_cache_state: preferences_fqfn: {preferences_fqfn}") - try: - caching_enabled = check_preferences_txt(ide_path, preferences_fqfn) - except UserWarning: - if os.path.exists(source_globals_h_fqfn): - caching_enabled = None - print_err(f" runtime_ide_version: {args.runtime_ide_version}") - print_err(f" This must be resolved to use '{globals_name}'") - print_err(f" Read more at {docs_url}") - else: - # We can quietly ignore the problem because we are not needed. - caching_enabled = True - - return caching_enabled + return check_preferences_txt(ide_path, preferences_fqfn) """ @@ -695,12 +618,63 @@ def parse_args(): # ref nargs='*'', https://stackoverflow.com/a/4480202 # ref no '--n' parameter, https://stackoverflow.com/a/21998252 + +# retrieve *system* encoding, not the one used by python internally +if sys.version_info >= (3, 11): + def get_encoding(): + return locale.getencoding() +else: + def get_encoding(): + return locale.getdefaultlocale()[1] + + +def show_value(desc, value): + print_dbg(f'{desc:<40} {value}') + return + +def locale_dbg(): + show_value("get_encoding()", get_encoding()) + show_value("locale.getdefaultlocale()", locale.getdefaultlocale()) + show_value('sys.getfilesystemencoding()', sys.getfilesystemencoding()) + show_value("sys.getdefaultencoding()", sys.getdefaultencoding()) + show_value("locale.getpreferredencoding(False)", locale.getpreferredencoding(False)) + try: + show_value("locale.getpreferredencoding()", locale.getpreferredencoding()) + except: + pass + show_value("sys.stdout.encoding", sys.stdout.encoding) + + # use current setting + show_value("locale.setlocale(locale.LC_ALL, None)", locale.setlocale(locale.LC_ALL, None)) + try: + show_value("locale.getencoding()", locale.getencoding()) + except: + pass + show_value("locale.getlocale()", locale.getlocale()) + + # use user setting + show_value("locale.setlocale(locale.LC_ALL, '')", locale.setlocale(locale.LC_ALL, '')) + # show_value("locale.getencoding()", locale.getencoding()) + show_value("locale.getlocale()", locale.getlocale()) + return + + def main(): global build_opt_signature global docs_url global debug_enabled + global default_encoding num_include_lines = 1 + # Given that GCC will handle lines from an @file as if they were on + # the command line. I assume that the contents of @file need to be encoded + # to match that of the shell running GCC runs. I am not 100% sure this API + # gives me that, but it appears to work. + # + # However, elsewhere when dealing with source code we continue to use 'utf-8', + # ref. https://gcc.gnu.org/onlinedocs/cpp/Character-sets.html + default_encoding = get_encoding() + args = parse_args() debug_enabled = args.debug runtime_ide_path = os.path.normpath(args.runtime_ide_path) @@ -713,6 +687,11 @@ def main(): build_path_core, build_opt_name = os.path.split(build_opt_fqfn) globals_h_fqfn = os.path.join(build_path_core, globals_name) + if debug_enabled: + locale_dbg() + + print_msg(f'default_encoding: {default_encoding}') + print_dbg(f"runtime_ide_path: {runtime_ide_path}") print_dbg(f"runtime_ide_version: {args.runtime_ide_version}") print_dbg(f"build_path: {build_path}") @@ -741,13 +720,14 @@ def main(): print_dbg("First run since Arduino IDE started.") use_aggressive_caching_workaround = determine_cache_state(args, runtime_ide_path, source_globals_h_fqfn) - if use_aggressive_caching_workaround == None: - # Specific rrror messages already buffered - handle_error(1) print_dbg(f"first_time: {first_time}") print_dbg(f"use_aggressive_caching_workaround: {use_aggressive_caching_workaround}") + if not os.path.exists(build_path_core): + os.makedirs(build_path_core) + print_msg("Clean build, created dir " + build_path_core) + if first_time or \ not use_aggressive_caching_workaround or \ not os.path.exists(commonhfile_fqfn): @@ -760,10 +740,6 @@ def main(): touch(commonhfile_fqfn) print_err(f"Neutralized future timestamp on build file: {commonhfile_fqfn}") - if not os.path.exists(build_path_core): - os.makedirs(build_path_core) - print_msg("Clean build, created dir " + build_path_core) - if os.path.exists(source_globals_h_fqfn): print_msg("Using global include from " + source_globals_h_fqfn) @@ -843,4 +819,10 @@ def main(): handle_error(0) # commit print buffer if __name__ == '__main__': - sys.exit(main()) + rc = 1 + try: + rc = main() + except: + print_err(traceback.format_exc()) + handle_error(0) + sys.exit(rc) diff --git a/tools/platformio-build.py b/tools/platformio-build.py index 37cb728b88..20fe8c77fb 100644 --- a/tools/platformio-build.py +++ b/tools/platformio-build.py @@ -173,51 +173,43 @@ def scons_patched_match_splitext(path, suffixes=None): ) ) -flatten_cppdefines = env.Flatten(env['CPPDEFINES']) - # # SDK # -if "PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3" in flatten_cppdefines: - env.Append( - CPPDEFINES=[("NONOSDK3V0", 1)], - LIBPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lib", "NONOSDK3V0")] - ) -elif "PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK221" in flatten_cppdefines: - #(previous default) - env.Append( - CPPDEFINES=[("NONOSDK221", 1)], - LIBPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lib", "NONOSDK221")] - ) -elif "PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x_190313" in flatten_cppdefines: - env.Append( - CPPDEFINES=[("NONOSDK22x_190313", 1)], - LIBPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lib", "NONOSDK22x_190313")] - ) -elif "PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x_191024" in flatten_cppdefines: - env.Append( - CPPDEFINES=[("NONOSDK22x_191024", 1)], - LIBPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lib", "NONOSDK22x_191024")] - ) -elif "PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x_191105" in flatten_cppdefines: - env.Append( - CPPDEFINES=[("NONOSDK22x_191105", 1)], - LIBPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lib", "NONOSDK22x_191105")] - ) -elif "PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x_191122" in flatten_cppdefines: - env.Append( - CPPDEFINES=[("NONOSDK22x_191122", 1)], - LIBPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lib", "NONOSDK22x_191122")] - ) -else: #(default) if "PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x_190703" in flatten_cppdefines: - env.Append( - CPPDEFINES=[("NONOSDK22x_190703", 1)], - LIBPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lib", "NONOSDK22x_190703")] - ) +NONOSDK_VERSIONS = ( + ("SDK22x_190703", "NONOSDK22x_190703"), + ("SDK221", "NONOSDK221"), + ("SDK22x_190313", "NONOSDK22x_190313"), + ("SDK22x_191024", "NONOSDK22x_191024"), + ("SDK22x_191105", "NONOSDK22x_191105"), + ("SDK22x_191122", "NONOSDK22x_191122"), + ("SDK305", "NONOSDK305"), +) +nonosdk_version = NONOSDK_VERSIONS[0] + +NONOSDK_PREFIX = "PIO_FRAMEWORK_ARDUINO_ESPRESSIF_" +for define in env["CPPDEFINES"]: + if isinstance(define, (tuple, list)): + define, *_ = define + if define.startswith(NONOSDK_PREFIX): + for version in NONOSDK_VERSIONS: + name, _ = version + if define.endswith(name): + nonosdk_version = version + +NONOSDK_LIBPATH=join(FRAMEWORK_DIR, "tools", "sdk", "lib", nonosdk_version[1]) +assert isdir(NONOSDK_LIBPATH) + +env.Append( + CPPDEFINES=[(nonosdk_version[1], 1)], + LIBPATH=[NONOSDK_LIBPATH], +) # # lwIP # +flatten_cppdefines = env.Flatten(env["CPPDEFINES"]) + lwip_lib = None if "PIO_FRAMEWORK_ARDUINO_LWIP2_IPV6_LOW_MEMORY" in flatten_cppdefines: env.Append( @@ -283,17 +275,23 @@ def scons_patched_match_splitext(path, suffixes=None): # current_vtables = None -fp_in_irom = "" +current_fp = None for d in flatten_cppdefines: if str(d).startswith("VTABLES_IN_"): current_vtables = d - if str(d) == "FP_IN_IROM": - fp_in_irom = "-DFP_IN_IROM" + if str(d).startswith("FP_IN_"): + current_fp = d + if not current_vtables: current_vtables = "VTABLES_IN_FLASH" env.Append(CPPDEFINES=[current_vtables]) assert current_vtables +if not current_fp: + current_fp = "FP_IN_IROM" + env.Append(CPPDEFINES=[current_fp]) +assert current_fp + # # MMU # @@ -338,7 +336,7 @@ def scons_patched_match_splitext(path, suffixes=None): for flag in env["CPPDEFINES"]: define = flag if isinstance(flag, (tuple, list)): - define, _ = flag + define, *_ = flag if define.startswith("MMU_"): mmu_flags.append(flag) # PIO_FRAMEWORK_ARDUINO_MMU_CACHE32_IRAM32 (default) @@ -371,9 +369,10 @@ def scons_patched_match_splitext(path, suffixes=None): join("$BUILD_DIR", "ld", "local.eagle.app.v6.common.ld"), join(FRAMEWORK_DIR, "tools", "sdk", "ld", "eagle.app.v6.common.ld.h"), env.VerboseAction( - "$CC -CC -E -P -D%s %s %s $SOURCE -o $TARGET" + "$CC -CC -E -P -D%s -D%s %s $SOURCE -o $TARGET" % ( current_vtables, + current_fp, # String representation of MMU flags " ".join( [ @@ -381,7 +380,6 @@ def scons_patched_match_splitext(path, suffixes=None): for f in mmu_flags ] ), - fp_in_irom, ), "Generating LD script $TARGET", ), diff --git a/tools/sdk/include/bearssl/bearssl_git.h b/tools/sdk/include/bearssl/bearssl_git.h index abdd61ac02..37fe2a0d36 100644 --- a/tools/sdk/include/bearssl/bearssl_git.h +++ b/tools/sdk/include/bearssl/bearssl_git.h @@ -1,2 +1,2 @@ // Do not edit -- Automatically generated by tools/sdk/ssl/bearssl/Makefile -#define BEARSSL_GIT b024386 +#define BEARSSL_GIT 5166f2b diff --git a/tools/sdk/include/ets_sys.h b/tools/sdk/include/ets_sys.h index 7908f127c3..a199469e0d 100644 --- a/tools/sdk/include/ets_sys.h +++ b/tools/sdk/include/ets_sys.h @@ -208,7 +208,6 @@ void *ets_memset(void *s, int c, size_t n); void ets_timer_arm_new(ETSTimer *a, int b, int c, int isMstimer); void ets_timer_setfn(ETSTimer *t, ETSTimerFunc *fn, void *parg); void ets_timer_disarm(ETSTimer *a); -int atoi(const char *nptr); int ets_strncmp(const char *s1, const char *s2, int len); int ets_strcmp(const char *s1, const char *s2); int ets_strlen(const char *s); diff --git a/tools/sdk/include/user_interface.h b/tools/sdk/include/user_interface.h index 696583d2ba..1d057417b8 100644 --- a/tools/sdk/include/user_interface.h +++ b/tools/sdk/include/user_interface.h @@ -25,6 +25,12 @@ #ifndef __USER_INTERFACE_H__ #define __USER_INTERFACE_H__ +#if defined(NONOSDK305) +#define NONOSDK (0x30500) +#else +#define NONOSDK (0x22100) +#endif + #include "os_type.h" #ifdef LWIP_OPEN_SRC @@ -249,13 +255,19 @@ typedef struct { struct station_config { uint8 ssid[32]; uint8 password[64]; +#if (NONOSDK >= (0x30200)) + uint8 channel; +#endif uint8 bssid_set; // Note: If bssid_set is 1, station will just connect to the router // with both ssid[] and bssid[] matched. Please check about this. uint8 bssid[6]; wifi_fast_scan_threshold_t threshold; -#ifdef NONOSDK3V0 +#if (NONOSDK >= (0x30000)) bool open_and_wep_mode_disable; // Can connect to open/wep router by default. #endif +#if (NONOSDK >= (0x30200)) + bool all_channel_scan; +#endif }; bool wifi_station_get_config(struct station_config *config); @@ -438,7 +450,7 @@ typedef enum { MODEM_SLEEP_T } sleep_type_t; -#ifdef NONOSDK3V0 +#if (NONOSDK >= (0x30000)) typedef enum { MIN_SLEEP_T, @@ -771,6 +783,70 @@ bool wifi_set_country(wifi_country_t *country); */ bool wifi_get_country(wifi_country_t *country); +#if (NONOSDK >= (0x30000)) + +typedef enum { + SYSTEM_PARTITION_INVALID = 0, + SYSTEM_PARTITION_BOOTLOADER, /* user can't modify this partition address, but can modify size */ + SYSTEM_PARTITION_OTA_1, /* user can't modify this partition address, but can modify size */ + SYSTEM_PARTITION_OTA_2, /* user can't modify this partition address, but can modify size */ + SYSTEM_PARTITION_RF_CAL, /* user must define this partition */ + SYSTEM_PARTITION_PHY_DATA, /* user must define this partition */ + SYSTEM_PARTITION_SYSTEM_PARAMETER, /* user must define this partition */ + SYSTEM_PARTITION_AT_PARAMETER, + SYSTEM_PARTITION_SSL_CLIENT_CERT_PRIVKEY, + SYSTEM_PARTITION_SSL_CLIENT_CA, + SYSTEM_PARTITION_SSL_SERVER_CERT_PRIVKEY, + SYSTEM_PARTITION_SSL_SERVER_CA, + SYSTEM_PARTITION_WPA2_ENTERPRISE_CERT_PRIVKEY, + SYSTEM_PARTITION_WPA2_ENTERPRISE_CA, + + SYSTEM_PARTITION_CUSTOMER_BEGIN = 100, /* user can define partition after here */ + SYSTEM_PARTITION_MAX +} partition_type_t; + +typedef struct { + partition_type_t type; /* the partition type */ + uint32_t addr; /* the partition address */ + uint32_t size; /* the partition size */ +} partition_item_t; + +/** + * @brief regist partition table information, user MUST call it in user_pre_init() + * + * @param partition_table: the partition table + * @param partition_num: the partition number in partition table + * @param map: the flash map + * + * @return true : succeed + * @return false : fail + */ +bool system_partition_table_regist( + const partition_item_t* partition_table, + uint32_t partition_num, + uint32_t map + ); + +/** + * @brief get ota partition size + * + * @return the size of ota partition + */ +uint32_t system_partition_get_ota_partition_size(void); + +/** + * @brief get partition information + * + * @param type: the partition type + * @param partition_item: the point to store partition information + * + * @return true : succeed + * @return false : fail + */ +bool system_partition_get_item(partition_type_t type, partition_item_t* partition_item); + +#endif + #ifdef __cplusplus } #endif diff --git a/tools/sdk/ld/eagle.app.v6.common.ld.h b/tools/sdk/ld/eagle.app.v6.common.ld.h index 77c834ae19..e6b415c50b 100644 --- a/tools/sdk/ld/eagle.app.v6.common.ld.h +++ b/tools/sdk/ld/eagle.app.v6.common.ld.h @@ -138,10 +138,20 @@ SECTIONS *(.text.app_entry*) /* The main startup code */ - *(.text.gdbstub*, .text.gdb_init) /* Any GDB hooks */ + *(.text.gdbstub* .text.gdb_init) /* Any GDB hooks */ /* all functional callers are placed in IRAM (including SPI/IRQ callbacks/etc) here */ *(.text._ZNKSt8functionIF*EE*) /* std::function::operator()() const */ + +#ifdef FP_IN_IRAM + *libgcc.a:*f2.o(.literal .text) + *libgcc.a:*f3.o(.literal .text) + *libgcc.a:*fsi.o(.literal .text) + *libgcc.a:*fdi.o(.literal .text) + *libgcc.a:*ifs.o(.literal .text) + *libgcc.a:*idf.o(.literal .text) +#endif + } >iram1_0_seg :iram1_0_phdr .irom0.text : ALIGN(4) @@ -155,13 +165,31 @@ SECTIONS LONG(0x00000000); *(.ver_number) - *.c.o(.literal*, .text*) - *.cpp.o(EXCLUDE_FILE (umm_malloc.cpp.o) .literal*, EXCLUDE_FILE (umm_malloc.cpp.o) .text*) - *.cc.o(.literal*, .text*) + *.c.o(.literal* .text*) + *.cpp.o(EXCLUDE_FILE (umm_malloc.cpp.o) .literal* EXCLUDE_FILE (umm_malloc.cpp.o) .text*) + *.cc.o(.literal* .text*) #ifdef VTABLES_IN_FLASH *(.rodata._ZTV*) /* C++ vtables */ #endif + . = ALIGN(4); /* this table MUST be 4-byte aligned */ + /* C++ constructor and destructor tables, properly ordered: */ + __init_array_start = ABSOLUTE(.); + KEEP (*crtbegin.o(.ctors)) + KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + __init_array_end = ABSOLUTE(.); + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + . = ALIGN(4); /* this table MUST be 4-byte aligned */ + _bss_table_start = ABSOLUTE(.); + LONG(_bss_start) + LONG(_bss_end) + _bss_table_end = ABSOLUTE(.); + *libgcc.a:unwind-dw2.o(.literal .text .rodata .literal.* .text.* .rodata.*) *libgcc.a:unwind-dw2-fde.o(.literal .text .rodata .literal.* .text.* .rodata.*) @@ -220,7 +248,7 @@ SECTIONS *(.rodata._ZZ*__func__) /* std::* exception strings, in their own section to allow string coalescing */ - *(.irom.exceptiontext, .rodata.exceptiontext) + *(.irom.exceptiontext .rodata.exceptiontext) *(.rodata.*__exception_what__*) /* G++ seems to throw out templatized section attributes */ /* c++ typeof IDs, etc. */ diff --git a/tools/sdk/ld/eagle.app.v6.common.ld.vtables.h b/tools/sdk/ld/eagle.app.v6.common.ld.vtables.h index 6649e08a25..f837e12d41 100644 --- a/tools/sdk/ld/eagle.app.v6.common.ld.vtables.h +++ b/tools/sdk/ld/eagle.app.v6.common.ld.vtables.h @@ -12,18 +12,7 @@ *(.gnu.linkonce.e.*) *(.gnu.version_r) *(.eh_frame) - . = (. + 3) & ~ 3; - /* C++ constructor and destructor tables, properly ordered: */ - __init_array_start = ABSOLUTE(.); - KEEP (*crtbegin.o(.ctors)) - KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) - KEEP (*(SORT(.ctors.*))) - KEEP (*(.ctors)) - __init_array_end = ABSOLUTE(.); - KEEP (*crtbegin.o(.dtors)) - KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) - KEEP (*(SORT(.dtors.*))) - KEEP (*(.dtors)) + . = ALIGN(4); /* C++ exception handlers table: */ __XT_EXCEPTION_DESCS__ = ABSOLUTE(.); *(.xt_except_desc) @@ -32,11 +21,6 @@ *(.xt_except_desc_end) *(.dynamic) *(.gnu.version_d) - . = ALIGN(4); /* this table MUST be 4-byte aligned */ - _bss_table_start = ABSOLUTE(.); - LONG(_bss_start) - LONG(_bss_end) - _bss_table_end = ABSOLUTE(.); _rodata_end = ABSOLUTE(.); } >dram0_0_seg :dram0_0_phdr diff --git a/tools/sdk/lib/NONOSDK305/commitlog.txt b/tools/sdk/lib/NONOSDK305/commitlog.txt new file mode 100644 index 0000000000..ebad3fedf1 --- /dev/null +++ b/tools/sdk/lib/NONOSDK305/commitlog.txt @@ -0,0 +1,147 @@ + feat: Update sdk version header file 3.0.5 + feat(core): update core version to b29dcd3 + feat: Update sdk version header file 3.0.4 + fix: It sometimes crashes after disable sntp + fix: Sometimes the parameter is missing because of power down when erasing or writing the flash + +commit 7b5b35da98ad9ee2de7afc63277d4933027ae91c +Merge: bd63c1f 26bedd0 +Author: Xu Chun Guang +Date: Fri Oct 15 11:40:39 2021 +0000 + + Merge branch 'feature/update_at_bin' into 'release/v3.0.5' + + feat: Update at bin to 1.7.5 + + See merge request sdk/ESP8266_NONOS_SDK!296 + +commit 26bedd0c7afd8a090670fb352f1f8a811b4f1839 +Author: Xu Chun Guang +Date: Fri Oct 15 18:06:49 2021 +0800 + + feat: Update at bin to 1.7.5 + +commit 38d251e1decafb56bae94e67f62ec425c6e5fe64 +Author: Xu Chun Guang +Date: Fri Oct 15 18:04:52 2021 +0800 + + feat: Update sdk version header file 3.0.5 + +commit bd63c1f81aae4bfb1b569e880a24fa73be81c713 +Merge: b1c14cd dae389b +Author: Xu Chun Guang +Date: Sat Oct 9 03:57:00 2021 +0000 + + Merge branch 'feature/update_core_v3.0.5' into 'release/v3.0.5' + + feat(core): update core version to b29dcd3 + + See merge request sdk/ESP8266_NONOS_SDK!293 + +commit dae389b804ad7c796d4dd62fab9ec346208507ac +Author: Chen Wu +Date: Sat Oct 9 11:37:28 2021 +0800 + + feat(core): update core version to b29dcd3 + +commit b1c14cdb08e2f39b654933f887b4f997b291982f +Merge: 5677e37 43dfa5a +Author: Xu Chun Guang +Date: Wed May 27 16:56:15 2020 +0800 + + Merge branch 'feature/update_at_bin' into 'master' + + feat: Update at bin to 1.7.4.0 + + See merge request sdk/ESP8266_NONOS_SDK!283 + +commit 43dfa5a7f919c3537929c1e36822118414da7d7f +Author: Xu Chun Guang +Date: Wed May 27 10:22:50 2020 +0800 + + feat: Update at bin to 1.7.4.0 + +commit 5677e379adf43032c8c05dde7816854409f9a8e8 +Merge: 8c0e419 9fbceb4 +Author: Xu Chun Guang +Date: Wed May 27 09:52:55 2020 +0800 + + Merge branch 'feature/update_sdk_version_h' into 'master' + + feat: Update sdk version header file 3.0.4 + + See merge request sdk/ESP8266_NONOS_SDK!282 + +commit 9fbceb4bc837521a09a790ee8db6dd1166e55498 +Author: Xu Chun Guang +Date: Wed May 27 09:50:30 2020 +0800 + + feat: Update sdk version header file 3.0.4 + +commit 8c0e419de1173347c4b9d073a2d891d3575c018a +Merge: f537843 13e436f +Author: Xu Chun Guang +Date: Tue May 26 15:35:24 2020 +0800 + + Merge branch 'bugfix/N8266-67' into 'master' + + fix: It sometimes crashes after disable sntp + + See merge request sdk/ESP8266_NONOS_SDK!281 + +commit 13e436f6214993e1f322c24f20a431fef8a123ca +Author: Xu Chun Guang +Date: Tue May 26 10:55:57 2020 +0800 + + feat: Update lwip lib to 5623f48f + +commit 5623f48f5e2dd1f45c25b9f2cad2314924a3cb00 +Author: Xu Chun Guang +Date: Tue May 26 10:52:30 2020 +0800 + + fix: It sometimes crashes after disable sntp + +commit f5378436fde39c0693df25efb51174b56f79dcc2 +Merge: c2ddeca da9767c +Author: Xu Chun Guang +Date: Fri May 22 17:45:10 2020 +0800 + + Merge branch 'bugfix/parameter_missing' into 'master' + + fix: Sometimes the parameter is missing because of power down when erasing or writing the flash + + See merge request sdk/ESP8266_NONOS_SDK!280 + +commit da9767c316e0e0dca9c00d91fbdac44ada62b29c +Author: Xu Chun Guang +Date: Fri May 22 17:26:39 2020 +0800 + + fix: Sometimes the parameter is missing because of power down when erasing or writing the flash + +commit c2ddeca67fe849a0a243ee50a28f8c81b8bba59a +Merge: b2831d5 613a042 +Author: Xu Chun Guang +Date: Tue May 12 11:17:23 2020 +0800 + + Merge branch 'feature/compatible_with_16M_512_512_in_at_nano' into 'master' + + feat: Compatible with 16M 512 512 in at nano + + See merge request sdk/ESP8266_NONOS_SDK!279 + +commit 613a042bc35823e7a48b0870a6562008f34009a9 +Author: Xu Chun Guang +Date: Tue May 12 10:06:16 2020 +0800 + + feat: Compatible with 16M 512 512 in at nano + +commit b2831d57b3c51e421bf35fc902d177ea57ba6e13 +Merge: b77cb8c 369b9bc +Author: Xu Chun Guang +Date: Mon May 11 20:04:36 2020 +0800 + + Merge branch 'bugfix/workaround_ota' into 'master' + + Bugfix/workaround ota + + See merge request sdk/ESP8266_NONOS_SDK!277 diff --git a/tools/sdk/lib/NONOSDK3V0/libairkiss.a b/tools/sdk/lib/NONOSDK305/libairkiss.a similarity index 72% rename from tools/sdk/lib/NONOSDK3V0/libairkiss.a rename to tools/sdk/lib/NONOSDK305/libairkiss.a index cfdcc84234..60415e5242 100644 Binary files a/tools/sdk/lib/NONOSDK3V0/libairkiss.a and b/tools/sdk/lib/NONOSDK305/libairkiss.a differ diff --git a/tools/sdk/lib/NONOSDK305/libcrypto.a b/tools/sdk/lib/NONOSDK305/libcrypto.a new file mode 100644 index 0000000000..cbb94e7552 Binary files /dev/null and b/tools/sdk/lib/NONOSDK305/libcrypto.a differ diff --git a/tools/sdk/lib/NONOSDK305/libespnow.a b/tools/sdk/lib/NONOSDK305/libespnow.a new file mode 100644 index 0000000000..2d3f7a8d2b Binary files /dev/null and b/tools/sdk/lib/NONOSDK305/libespnow.a differ diff --git a/tools/sdk/lib/NONOSDK305/libmain.a b/tools/sdk/lib/NONOSDK305/libmain.a new file mode 100644 index 0000000000..699b5b4b14 Binary files /dev/null and b/tools/sdk/lib/NONOSDK305/libmain.a differ diff --git a/tools/sdk/lib/NONOSDK305/libnet80211.a b/tools/sdk/lib/NONOSDK305/libnet80211.a new file mode 100644 index 0000000000..1edb9e5dda Binary files /dev/null and b/tools/sdk/lib/NONOSDK305/libnet80211.a differ diff --git a/tools/sdk/lib/NONOSDK305/libphy.a b/tools/sdk/lib/NONOSDK305/libphy.a new file mode 100644 index 0000000000..9bdb6d6448 Binary files /dev/null and b/tools/sdk/lib/NONOSDK305/libphy.a differ diff --git a/tools/sdk/lib/NONOSDK305/libpp.a b/tools/sdk/lib/NONOSDK305/libpp.a new file mode 100644 index 0000000000..e5c86d681c Binary files /dev/null and b/tools/sdk/lib/NONOSDK305/libpp.a differ diff --git a/tools/sdk/lib/NONOSDK305/libsmartconfig.a b/tools/sdk/lib/NONOSDK305/libsmartconfig.a new file mode 100644 index 0000000000..d6d593e87f Binary files /dev/null and b/tools/sdk/lib/NONOSDK305/libsmartconfig.a differ diff --git a/tools/sdk/lib/NONOSDK305/libwpa.a b/tools/sdk/lib/NONOSDK305/libwpa.a new file mode 100644 index 0000000000..18b5efc3f5 Binary files /dev/null and b/tools/sdk/lib/NONOSDK305/libwpa.a differ diff --git a/tools/sdk/lib/NONOSDK305/libwpa2.a b/tools/sdk/lib/NONOSDK305/libwpa2.a new file mode 100644 index 0000000000..a3a7a4210c Binary files /dev/null and b/tools/sdk/lib/NONOSDK305/libwpa2.a differ diff --git a/tools/sdk/lib/NONOSDK305/libwps.a b/tools/sdk/lib/NONOSDK305/libwps.a new file mode 100644 index 0000000000..fe821a418d Binary files /dev/null and b/tools/sdk/lib/NONOSDK305/libwps.a differ diff --git a/tools/sdk/lib/NONOSDK305/version b/tools/sdk/lib/NONOSDK305/version new file mode 100644 index 0000000000..7a5f16731d --- /dev/null +++ b/tools/sdk/lib/NONOSDK305/version @@ -0,0 +1 @@ +v3.0.5-g7b5b35d (shows as SDK:3.0.5(b29dcd3) in debug mode) \ No newline at end of file diff --git a/tools/sdk/lib/NONOSDK3V0/libcrypto.a b/tools/sdk/lib/NONOSDK3V0/libcrypto.a deleted file mode 100644 index d0aea338e8..0000000000 Binary files a/tools/sdk/lib/NONOSDK3V0/libcrypto.a and /dev/null differ diff --git a/tools/sdk/lib/NONOSDK3V0/libespnow.a b/tools/sdk/lib/NONOSDK3V0/libespnow.a deleted file mode 100644 index 2ed7994e1d..0000000000 Binary files a/tools/sdk/lib/NONOSDK3V0/libespnow.a and /dev/null differ diff --git a/tools/sdk/lib/NONOSDK3V0/libmain.a b/tools/sdk/lib/NONOSDK3V0/libmain.a deleted file mode 100644 index fb5242f1be..0000000000 Binary files a/tools/sdk/lib/NONOSDK3V0/libmain.a and /dev/null differ diff --git a/tools/sdk/lib/NONOSDK3V0/libnet80211.a b/tools/sdk/lib/NONOSDK3V0/libnet80211.a deleted file mode 100644 index 576304be26..0000000000 Binary files a/tools/sdk/lib/NONOSDK3V0/libnet80211.a and /dev/null differ diff --git a/tools/sdk/lib/NONOSDK3V0/libphy.a b/tools/sdk/lib/NONOSDK3V0/libphy.a deleted file mode 100644 index dfd469518e..0000000000 Binary files a/tools/sdk/lib/NONOSDK3V0/libphy.a and /dev/null differ diff --git a/tools/sdk/lib/NONOSDK3V0/libpp.a b/tools/sdk/lib/NONOSDK3V0/libpp.a deleted file mode 100644 index fbf3e85636..0000000000 Binary files a/tools/sdk/lib/NONOSDK3V0/libpp.a and /dev/null differ diff --git a/tools/sdk/lib/NONOSDK3V0/libsmartconfig.a b/tools/sdk/lib/NONOSDK3V0/libsmartconfig.a deleted file mode 100644 index 34598d36a6..0000000000 Binary files a/tools/sdk/lib/NONOSDK3V0/libsmartconfig.a and /dev/null differ diff --git a/tools/sdk/lib/NONOSDK3V0/libwpa.a b/tools/sdk/lib/NONOSDK3V0/libwpa.a deleted file mode 100644 index 3a58113a1a..0000000000 Binary files a/tools/sdk/lib/NONOSDK3V0/libwpa.a and /dev/null differ diff --git a/tools/sdk/lib/NONOSDK3V0/libwpa2.a b/tools/sdk/lib/NONOSDK3V0/libwpa2.a deleted file mode 100644 index 0826b45e7f..0000000000 Binary files a/tools/sdk/lib/NONOSDK3V0/libwpa2.a and /dev/null differ diff --git a/tools/sdk/lib/NONOSDK3V0/libwps.a b/tools/sdk/lib/NONOSDK3V0/libwps.a deleted file mode 100644 index 1f6b365e3a..0000000000 Binary files a/tools/sdk/lib/NONOSDK3V0/libwps.a and /dev/null differ diff --git a/tools/sdk/lib/NONOSDK3V0/version b/tools/sdk/lib/NONOSDK3V0/version deleted file mode 100644 index 06e014650a..0000000000 --- a/tools/sdk/lib/NONOSDK3V0/version +++ /dev/null @@ -1 +0,0 @@ -v2.2.0-28-g89920dc \ No newline at end of file diff --git a/tools/sdk/lib/README.md b/tools/sdk/lib/README.md index 6b92d04307..6e30c9a58d 100644 --- a/tools/sdk/lib/README.md +++ b/tools/sdk/lib/README.md @@ -1,8 +1,20 @@ +## Adding a new SDK library + +- Create a directory for the new SDK. +- Copy .a files from SDK `lib` directory to the new directory +- Add the new SDK directory to those supported in `eval_fix_sdks.sh` and `fix_sdk_libs.sh`. +- To support WPA2 Enterprise connections, some patches are reguired review `wpa2_eap_patch.cpp` and `eval_fix_sdks.sh` for details. +- Use `./eval_fix_sdks.sh --analyze` to aid in finding relevant differences. + - Also, you can compare two SDKs with something like `./eval_fix_sdks.sh --analyze "NONOSDK305\nNONOSDK306"` +- Apply updates to `fix_sdk_libs.sh` and `wpa2_eap_patch.cpp`. You can run `./eval_fix_sdks.sh --patch` to do a batch run of `fix_sdk_libs.sh` against each SDK. +- If you used this section, you can skip _Updating SDK libraries_. + ## Updating SDK libraries - Copy .a files from SDK `lib` directory to this directory - Run `fix_sdk_libs.sh` + ## Updating libstdc++ After building gcc using crosstool-NG, get compiled libstdc++ and remove some objects: @@ -17,4 +29,3 @@ xtensa-lx106-elf-ar d libstdc++.a del_opv.o xtensa-lx106-elf-ar d libstdc++.a new_op.o xtensa-lx106-elf-ar d libstdc++.a new_opv.o ``` - diff --git a/tools/sdk/lib/eval_fix_sdks.sh b/tools/sdk/lib/eval_fix_sdks.sh index 217157d325..389ee31650 100755 --- a/tools/sdk/lib/eval_fix_sdks.sh +++ b/tools/sdk/lib/eval_fix_sdks.sh @@ -1,6 +1,13 @@ #!/bin/bash # set -e +single_sdk="${2}" +if [[ -n "$single_sdk" ]]; then + if [[ "NONOSDK" != "${single_sdk:0:7}" ]]; then + single_sdk="" + fi +fi + add_path_ifexist() { if [[ -d $1 ]]; then export PATH=$( realpath $1 ):$PATH @@ -24,6 +31,10 @@ EOF } list_sdks() { + if [[ -n "$single_sdk" ]]; then + echo -e "$single_sdk" + return + fi cat < -#if !defined(__INT8) -#define __INT8 -#endif -#if !defined(__INT16) -#define __INT16 -#endif -#if !defined(__INT32) -#define __INT32 "l" -#endif - #endif // GLUE_H diff --git a/tools/sdk/lwip2/include/gluedebug.h b/tools/sdk/lwip2/include/gluedebug.h index f7a1917799..9358878b15 100644 --- a/tools/sdk/lwip2/include/gluedebug.h +++ b/tools/sdk/lwip2/include/gluedebug.h @@ -9,11 +9,9 @@ // this is needed separately from lwipopts.h // because it is shared by both sides of glue -#define UNDEBUG 1 // 0 or 1 (1: uassert removed) +#define UNDEBUG 1 // 0 or 1 (1: uassert removed = saves flash) #define UDEBUG 0 // 0 or 1 (glue debug) -#define UDUMP 0 // 0 or 1 (glue / dump packet) -#define UDEBUGINDEX 0 // 0 or 1 (show debug line number) -#define UDEBUGSTORE 0 // 0 or 1 (store debug into buffer until doprint_allow=1=serial-available) +#define UDUMP 0 // 0 or 1 (glue: dump packet) #define ULWIPDEBUG 0 // 0 or 1 (trigger lwip debug) #define ULWIPASSERT 0 // 0 or 1 (trigger lwip self-check, 0 saves flash) @@ -24,8 +22,6 @@ #define STRING_IN_FLASH 0 // *print("fmt is stored in flash") #endif -#define ROTBUFLEN_BIT 11 // (UDEBUGSTORE=1) doprint()'s buffer: 11=2048B - #if ULWIPDEBUG //#define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT) #define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH) @@ -45,17 +41,11 @@ extern void (*phy_capture) (int netif_idx, const char* data, size_t len, int out } #endif - ///////////////////////////////////////////////////////////////////////////// #if ARDUINO #include #endif -#if UDEBUG && UDEBUGSTORE -#warning use 'doprint_allow=1' right after Serial is enabled -extern int doprint_allow; -#endif - // print definitions: // uprint(): always used by glue, defined as doprint() in debug mode or nothing() // os_printf(): can be redefined as doprint() @@ -65,41 +55,21 @@ extern int doprint_allow; #if STRING_IN_FLASH && !defined(USE_OPTIMIZE_PRINTF) #define USE_OPTIMIZE_PRINTF // at least used in arduino/esp8266 #endif -// os_printf_plus() missing in osapi.h (fixed in arduino's sdk-2.1): -//extern int os_printf_plus (const char * format, ...) __attribute__ ((format (printf, 1, 2))); #include // os_printf* definitions + ICACHE_RODATA_ATTR -#if UDEBUG && (UDEBUGINDEX || UDEBUGSTORE) -// doprint() is used - -#undef os_printf -#define os_printf(x...) do { doprint(x); } while (0) - -#if STRING_IN_FLASH - -#define doprint(fmt, ...) \ - do { \ - static const char flash_str[] ICACHE_RODATA_ATTR STORE_ATTR = fmt; \ - doprint_minus(flash_str, ##__VA_ARGS__); \ - } while(0) - -#else // !STRING_IN_FLASH - -#define doprint(fmt, ...) doprint_minus(fmt, ##__VA_ARGS__) - -#endif // !STRING_IN_FLASH - -int doprint_minus (const char* format, ...) __attribute__ ((format (printf, 1, 2))); // format in flash - -#else // !( UDEBUG && (UDEBUGINDEX || UDEBUGSTORE) ) - -#define doprint(x...) do { os_printf(x); } while (0) - -#endif // !( UDEBUG && (UDEBUGINDEX || UDEBUGSTORE) ) +#if defined(ARDUINO) +// os_printf() does not understand ("%hhx",0x12345678) => "78") and prints 'h' instead +// now hacking/using ::printf() from updated and patched esp-quick-toolchain-by-Earle +#include +#undef os_printf +#undef os_printf_plus +#define os_printf printf +#define os_printf_plus printf +#endif #if UDEBUG -#define uprint(x...) do { doprint(x); } while (0) +#define uprint(x...) do { os_printf(x); } while (0) #else #define uprint(x...) do { (void)0; } while (0) #endif @@ -127,7 +97,7 @@ do { if ((assertion) == 0) { \ #define ualwaysassert(assertion...) udoassert(assertion) -#define uerror(x...) do { doprint(x); } while (0) +#define uerror(x...) do { os_printf(x); } while (0) #define uhalt() do { *((int*)0) = 0; /* this triggers gdb */ } while (0) #define nl() do { uprint("\n"); } while (0) diff --git a/tools/sdk/lwip2/include/lwip-git-hash.h b/tools/sdk/lwip2/include/lwip-git-hash.h index f5e25bf234..c8a92967ba 100644 --- a/tools/sdk/lwip2/include/lwip-git-hash.h +++ b/tools/sdk/lwip2/include/lwip-git-hash.h @@ -1,5 +1,5 @@ // generated by makefiles/make-lwip2-hash #ifndef LWIP_HASH_H #define LWIP_HASH_H -#define LWIP_HASH_STR "STABLE-2_1_3_RELEASE/glue:1.2-63-gb5def38" +#define LWIP_HASH_STR "STABLE-2_1_3_RELEASE/glue:1.2-70-g4087efd" #endif // LWIP_HASH_H diff --git a/tools/sdk/lwip2/include/lwipopts.h b/tools/sdk/lwip2/include/lwipopts.h index 508245e6c0..1f05c83f9f 100644 --- a/tools/sdk/lwip2/include/lwipopts.h +++ b/tools/sdk/lwip2/include/lwipopts.h @@ -3,11 +3,10 @@ #define __CUSTOM_EXTRA_DEFINES__ #endif - #ifndef MYLWIPOPTS_H #define MYLWIPOPTS_H -// opt.h version lwip-2.1.0rc1 for esp8266 +/* opt.h version lwip-2.1.3 for esp8266 */ /** * @file @@ -996,7 +995,7 @@ #if !LWIP_IPV4 /* disable AUTOIP when IPv4 is disabled */ #undef LWIP_AUTOIP -#define LWIP_AUTOIP 0 +#define LWIP_AUTOIP 0 #endif /* !LWIP_IPV4 */ /** @@ -1564,7 +1563,7 @@ * LWIP_PBUF_REF_T: Refcount type in pbuf. * Default width of u8_t can be increased if 255 refs are not enough for you. */ -#ifndef LWIP_PBUF_REF_T +#if !defined LWIP_PBUF_REF_T || defined __DOXYGEN__ #define LWIP_PBUF_REF_T u8_t #endif @@ -2447,7 +2446,7 @@ * LWIP_IPV6_FORWARD==1: Forward IPv6 packets across netifs */ #if !defined LWIP_IPV6_FORWARD || defined __DOXYGEN__ -#define LWIP_IPV6_FORWARD 0 // 0 +#define LWIP_IPV6_FORWARD 0 #endif /** @@ -2683,7 +2682,7 @@ * servers to the DNS module. */ #if !defined LWIP_ND6_RDNSS_MAX_DNS_SERVERS || defined __DOXYGEN__ -#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS 0 // 0 +#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS 0 #endif /** * @} @@ -2722,7 +2721,7 @@ * void dhcp6_set_ntp_servers(u8_t num_ntp_servers, ip_addr_t* ntp_server_addrs); */ #if !defined LWIP_DHCP6_GET_NTP_SRV || defined __DOXYGEN__ -#define LWIP_DHCP6_GET_NTP_SRV 1 // with 1: dhcp6_set_ntp_servers() must be implemented +#define LWIP_DHCP6_GET_NTP_SRV 1 #endif /** @@ -3509,9 +3508,6 @@ #if !defined DHCP6_DEBUG || defined __DOXYGEN__ #define DHCP6_DEBUG LWIP_DBG_OFF #endif -/** - * @} - */ /** * NAPT_DEBUG: Enable debugging for NAPT. @@ -3520,6 +3516,10 @@ #define NAPT_DEBUG LWIP_DBG_OFF #endif +/** + * @} + */ + /** * LWIP_TESTMODE: Changes to make unit test possible */ @@ -3566,9 +3566,13 @@ #define PPPOS_SUPPORT IP_NAPT // because we don't have proxyarp yet #define PPP_SUPPORT PPPOS_SUPPORT #define PPP_SERVER 1 -#define PPP_DEBUG ULWIPDEBUG #define PRINTPKT_SUPPORT ULWIPDEBUG +#if ULWIPDEBUG +#define PPP_DEBUG LWIP_DBG_ON +#define PING_DEBUG LWIP_DBG_ON +#endif + #ifdef __cplusplus extern "C" { #endif @@ -3710,4 +3714,4 @@ void tcp_kill_timewait (void); } // extern "C" #endif -#endif // MYLWIPOPTS_H +#endif /* MYLWIPOPTS_H */ diff --git a/tools/sdk/ssl/bearssl b/tools/sdk/ssl/bearssl index b024386d46..5166f2bb03 160000 --- a/tools/sdk/ssl/bearssl +++ b/tools/sdk/ssl/bearssl @@ -1 +1 @@ -Subproject commit b024386d461abd1b7b9be3117e2516b7541f1201 +Subproject commit 5166f2bb03fb03597b0f2c8c7fbcf01616df67c9 diff --git a/tools/signing.py b/tools/signing.py index 40405288c9..9274bb537a 100755 --- a/tools/signing.py +++ b/tools/signing.py @@ -4,6 +4,7 @@ import argparse import hashlib import os +import struct import subprocess import sys @@ -30,7 +31,7 @@ def sign_and_write(data, priv_key, out_file): with open(out_file, "wb") as out: out.write(data) out.write(signout) - out.write(b'\x00\x01\x00\x00') + out.write(struct.pack("= (3, 11): + def get_encoding(): + return locale.getencoding() +else: + def get_encoding(): + return locale.getdefaultlocale()[1] + + def get_segment_sizes(elf, path, mmu): iram_size = 0 iheap_size = 0 @@ -73,7 +84,7 @@ def get_segment_sizes(elf, path, mmu): ) cmd = [os.path.join(path, "xtensa-lx106-elf-size"), "-A", elf] - with subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True) as proc: + with subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True, encoding=get_encoding()) as proc: lines = proc.stdout.readlines() for line in lines: words = line.split() diff --git a/tools/upload.py b/tools/upload.py index aee6add8f1..760d4dbbef 100755 --- a/tools/upload.py +++ b/tools/upload.py @@ -65,7 +65,7 @@ try: esptool.main(cmdline) -except esptool.FatalError as e: +except Exception as e: sys.stderr.write('\nA fatal esptool.py error occurred: %s' % e) finally: if erase_file: diff --git a/libraries/ESP8266WiFi/examples/BearSSL_Server/DO-NOT-USE-THESE-CERTS-IN-YOUR-OWN-APPS b/tools/warnings/default-cflags similarity index 100% rename from libraries/ESP8266WiFi/examples/BearSSL_Server/DO-NOT-USE-THESE-CERTS-IN-YOUR-OWN-APPS rename to tools/warnings/default-cflags diff --git a/tools/warnings/default-g++ b/tools/warnings/default-cppflags similarity index 100% rename from tools/warnings/default-g++ rename to tools/warnings/default-cppflags diff --git a/tools/warnings/default-gcc b/tools/warnings/default-gcc deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tools/warnings/extra-g++ b/tools/warnings/extra-cflags similarity index 100% rename from tools/warnings/extra-g++ rename to tools/warnings/extra-cflags diff --git a/tools/warnings/extra-gcc b/tools/warnings/extra-cppflags similarity index 100% rename from tools/warnings/extra-gcc rename to tools/warnings/extra-cppflags diff --git a/tools/warnings/more-g++ b/tools/warnings/more-cflags similarity index 100% rename from tools/warnings/more-g++ rename to tools/warnings/more-cflags diff --git a/tools/warnings/more-gcc b/tools/warnings/more-cppflags similarity index 100% rename from tools/warnings/more-gcc rename to tools/warnings/more-cppflags diff --git a/tools/warnings/none-gcc b/tools/warnings/none-cflags similarity index 100% rename from tools/warnings/none-gcc rename to tools/warnings/none-cflags diff --git a/tools/warnings/none-g++ b/tools/warnings/none-cppflags similarity index 100% rename from tools/warnings/none-g++ rename to tools/warnings/none-cppflags diff --git a/variants/mercury_v1/pins_arduino.h b/variants/mercury_v1/pins_arduino.h new file mode 100644 index 0000000000..747afb5913 --- /dev/null +++ b/variants/mercury_v1/pins_arduino.h @@ -0,0 +1,71 @@ +/* + pins_arduino.h - Pin definition functions for Arduino + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2007 David A. Mellis + Modified for ESP8266 platform by Ivan Grokhotkov, 2014-2015. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $ +*/ + +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include "../generic/common.h" + +#define LED_BUILTIN 0 +#define BUILTIN_LED LED_BUILTIN + +#define A0 (17) + +static const uint8_t D0 = 0; +static const uint8_t D1 = 12; +static const uint8_t D2 = 4; +static const uint8_t D3 = 16; +static const uint8_t D4 = 5; +static const uint8_t D5 = 13; +static const uint8_t D6 = 15; +static const uint8_t D7 = 2; +static const uint8_t D8 = 14; +static const uint8_t D9 = 9; +static const uint8_t D10 = 10; + +#define PIN_WIRE_SDA (2) +#define PIN_WIRE_SCL (14) + +// Brushed DC Motors +#define MOTOR_1_DIR (16) +#define MOTOR_1_PWM (12) +#define MOTOR_2_DIR (5) +#define MOTOR_2_PWM (4) + +//Ultrasonic Sensor +static const uint8_t USST = D7; +static const uint8_t USSE = D8; + +//Servo +static const uint8_t SERVO1 = D4; +static const uint8_t SERVO2 = D6; +static const uint8_t SERVO3 = D3; +static const uint8_t SERVO4 = D5; + +//IR +static const uint8_t IR1 = D9; +static const uint8_t IR2 = D10; + +#endif /* Pins_Arduino_h */