ESP8266 RTOS SDK

repository·master·Indexed 25 days ago

https://github.com/espressif/esp8266_rtos_sdk

A software development kit for developing applications on the ESP8266 microcontroller using a FreeRTOS framework. It includes esptool.py for flashing binary data, reading flash contents, erasing memory, and converting ELF files to binary images, as well as documentation on configuring flash modes, sizes, and troubleshooting bootloader connections.

Tokens
56.8K
Snippets
164
Records
389
Agent score
85%

What's inside ESP8266 RTOS SDK

  1. Overview of the Virtual Filesystem (VFS) component

    master

    The Virtual Filesystem (VFS) component provides a unified interface for drivers that perform operations on file-like objects. This includes real filesystems (like FAT or SPIFFS) and device drivers that implement a file-like interface.

    By using VFS, standard C library functions such as fopen and fprintf can interact with various FS drivers. Each driver is associated with a path prefix (mount point). When a file is opened via a path, the VFS component identifies the correct driver based on the prefix and forwards the call.

  2. Overview of the Wear Levelling component

    master

    The Wear Levelling component helps prevent premature failure of SPI flash by distributing erase/write cycles evenly across all sectors. It provides APIs for data reading, writing, erasing, and memory mapping on external SPI flash.

    It can work in conjunction with the FAT file system. The component supports different sector sizes and operational modes to balance performance and data safety:

    • Standard Mode (FAT integration): Uses 4096-byte sectors (standard flash sector size). This offers the best performance but consumes more RAM.
    • Performance Mode (512-byte sectors): Data is first saved in RAM, the sector is erased, and then data is written back to flash. Warning: If power is lost during the erase/write cycle, the entire 4096-byte sector's data will be lost.
    • Safe Mode (512-byte sectors): Data is first saved to an empty sector in flash, then the target sector is erased and data is moved back. This allows for data recovery if power is lost.

    Default Settings:

    • Sector size: 512 bytes
    • Mode: Performance mode

    Settings can be modified via the configuration menu.

  3. Overview of libsodium

    master

    libsodium is a portable, cross-compilable software library designed for easy-to-use cryptographic operations. It is a fork of NaCl with a compatible API and provides core operations for:

    • Encryption and decryption
    • Digital signatures
    • Password hashing
    • Other core cryptographic tools

    It is designed to be used as a foundation for building higher-level cryptographic applications.

  4. Overview of ESP8266 SPI Demo Modes

    master

    The ESP8266 SPI driver provides two performance modes for use as an SPI slave. Because the ESP8266 lacks DMA, it is limited to a maximum of 64 bytes per transmission.

    • normal_performance: Designed for standard SPI speed requirements. It provides easy-to-use SPI slave APIs, but performance is lower because the software schedules between tasks and interrupts during data transfer.
    • high_performance: Designed for high-speed SPI requirements. Data transmission and reception are handled entirely within interrupts. For optimal results, the host MCU (SPI master) should also handle SPI transmission within an interrupt to avoid performance degradation caused by software task scheduling.
  5. Understand the OpenSSL API wrapper in ESP8266_RTOS_SDK

    master

    The OpenSSL component in this SDK is not a standalone OpenSSL implementation. It serves as a wrapper for applications that use the OpenSSL API, delegating the actual cryptographic work to the mbedTLS library.

    Requirements:

    • To compile code using these APIs, you must have the mbedtls library and its header files available.

    Limitations:

    • Only the OpenSSL APIs explicitly documented in this component are supported. Calling undocumented OpenSSL functions will result in compilation errors (linking failures) or runtime errors.
  6. Understand Wear Levelling memory organization

    master

    The WLC divides the memory defined by start_addr and full_mem_size into three distinct regions:

    1. Configuration: Stores configuration information. This region can be used to recover the WLC from a memory dump.
    2. Data: The region where user data is actually stored.
    3. States: Stores internal WLC state information. This region contains two copies of the state to prevent data loss if a power failure occurs during a state write. If one copy is corrupted, the WLC recovers from the other and overwrites the broken copy.
  7. Understand the ESP8266 RTOS SDK Support Policy

    master

    The ESP8266 RTOS SDK follows a specific support lifecycle for its major and minor releases. Understanding these periods helps in planning upgrades and ensuring security compliance.

    Standard Releases

    Most major and minor releases (e.g., V3.0, V3.1) are supported for 18 months after their initial stable release date. During this time, the team provides bug fixes and security fixes via the GitHub release branches.

    Long Term Support (LTS) Releases

    Certain releases are designated as Long Term Support (LTS). These releases are supported for 30 months (2.5 years) after their initial stable release date. LTS versions are identified by an (LTS) tag in the release name (e.g., ESP8266 RTOS SDK Release v3.4 (LTS)).

    End of Life (EOL) and Pre-releases

    • End of Life (EOL): Once a support period expires, the release becomes EOL. The SDK team does not provide bug fixes or security patches for EOL releases.
    • Pre-release versions: Beta, preview, -rc, and -dev versions are not covered by any support period. Features marked as "Preview" within a release are also excluded from the support period.
  8. Understand Protocomm packet structures via Protobuf files

    master

    Protocomm uses Google Protobuf to define language, transport, and architecture-agnostic protocol communication packets. The packet structures are defined across the following files:

    • constants.proto: Defines the Status structure used to convey the success or failure of a single protocomm transaction.
    • sec0.proto: Defines the Security0 Command and Response packet structures.
    • sec1.proto: Defines the Security1 Command and Response packet structures.
    • session.proto: Defines the protocomm transaction packets for session establishment (contains a Security packet as a payload).
  9. Role of the Handshake Pin in SPI Communication

    master

    The Handshake pin is critical for ensuring data integrity and managing asynchronous transfers between the MCU and ESP8266. It serves two primary functions:

    1. ESP8266 Notification: When the ESP8266 is ready to receive or send data, it pulls this pin high. This triggers a GPIO interrupt on the MCU, prompting the MCU to perform the necessary SPI read/write.
    2. MCU Synchronization: When the MCU finishes sending a data chunk, it must wait for a GPIO interrupt triggered by the ESP8266. The ESP8266 pulls the pin high after it has successfully extracted the data from the SPI register, allowing the MCU to proceed with the next transaction.
  10. Understand ESP8266_RTOS_SDK Build System Concepts

    master

    The build system is based on a component-based architecture. Key concepts include:

    • Project: A directory containing files and configuration to build a single executable (app), including a partition table, data/filesystem partitions, and a bootloader.
    • Project Configuration: Managed via a sdkconfig file in the project root. This is customized using make menuconfig.
    • App: The executable output. A project typically builds two apps: a "project app" (your firmware) and a "bootloader app" (the initial program that launches the project app).
    • Components: Modular pieces of code compiled into static libraries (.a files). They can be provided by the SDK, the project itself, or external directories.
    • IDF_PATH: An environment variable pointing to the ESP8266_RTOS_SDK directory. The SDK is decoupled from your project via this path.
    • Toolchain: The compilation toolchain is not part of the project and should be in your system PATH or configured via the compiler prefix in the project configuration.
  11. Understand the FreeRTOS kernel structure

    master

    The FreeRTOS kernel within the ESP8266 RTOS SDK is organized into common core components and hardware-specific portable layers:

    • Core Kernel Components: Located in FreeRTOS/Source, the kernel is primarily contained within list.c, queue.c, and tasks.c.
    • Optional Co-routines: croutine.c provides optional co-routine functionality, typically reserved for extremely memory-constrained systems.
    • Hardware/Compiler Portability: Files specific to the microcontroller or compiler are located in FreeRTOS/Source/Portable.
    • Kernel Headers: All real-time kernel header files are located in FreeRTOS/Source/include.
  12. SPIFFS Features and Limitations

    master

    SPIFFS (SPI Flash File System) is designed for SPI NOR flash devices on embedded targets with small RAM footprints.

    Key Features:

    • Low RAM usage using statically sized buffers.
    • POSIX-like API (open, close, read, write, seek, stat, etc.).
    • Static wear leveling and built-in consistency checks.
    • Highly configurable.

    Limitations:

    • No Directory Support: It produces a flat file structure. A path like tmp/myfile.txt is treated as a single filename rather than a file in a directory.
    • Non-Realtime: Write operation latency can vary significantly.
    • Scalability: Not intended for devices larger than ~128MB due to RAM constraints.
    • No Bad Block Management: Does not currently detect or handle bad blocks.
    • Configuration-Specific: Each configuration requires its own binary.