[docs] Restructure documentation, clarify some parts

This commit is contained in:
Kuba Szczodrzyński
2022-07-31 13:05:24 +02:00
parent 98a65c81af
commit 9416e45a75
20 changed files with 178 additions and 127 deletions

View File

@@ -35,7 +35,7 @@ LibreTuya also provides a common interface for all family implementations. The i
## Board List
See [Boards & CPU list](https://kuba2k2.github.io/libretuya/docs/supported/).
See [Boards & CPU list](https://kuba2k2.github.io/libretuya/docs/status/supported/).
## Arduino Core support status

View File

@@ -1,10 +1,26 @@
* [Home](README.md)
* [Getting started](docs/getting-started.md)
* [💻 Boards & CPU list](docs/supported.md)
* [✔️ Implementation status](docs/implementation-status.md)
* [🔧 Configuration](docs/config.md)
* [📁 Project structure](docs/project-structure.md)
* 🔖 Code reference
* 😊 Getting started
* [Start here](docs/getting-started/README.md)
* [Uploading](docs/getting-started/uploading.md)
* [Options & config](docs/reference/config.md)
* [ESPHome port](docs/projects/esphome.md)
* [💻 Boards & CPU list](docs/status/supported.md)
* [✔️ Implementation status](docs/status/arduino.md)
* Supported chip families
* Beken BK72xx
* [General info](docs/platform/beken-72xx/README.md)
* [Flashing](docs/platform/beken-72xx/flashing.md)
* Realtek AmebaZ Series
* [General info](docs/platform/realtek/README.md)
* [Flashing (AmebaZ)](docs/platform/realtek-ambz/flashing.md)
* [Debugging](docs/platform/realtek/debugging.md)
* [Exception decoder](docs/platform/realtek/exception-decoder.md)
* C library
* [Built-in functions](docs/platform/realtek-ambz/stdlib.md)
* [Memory management](docs/platform/realtek-ambz/memory-management.md)
* [All supported boards](boards/)
* API & libraries
* [Options & config](docs/reference/config.md)
* [LibreTuya API](docs/reference/lt-api.md)
* [LT class reference](ltapi/class_libre_tuya.md)
* [Common methods](ltapi/_libre_tuya_a_p_i_8h.md)
@@ -38,22 +54,10 @@
* [Functions](ltapi/functions.md)
* [Macros](ltapi/macros.md)
* [File list](ltapi/files.md)
* [📁 Project structure](docs/reference/project-structure.md)
* [✈️ OTA format](docs/ota/README.md)
* [uf2ota.py tool](docs/ota/uf2ota.md)
* [uf2ota.h library](docs/ota/library.md)
* [uf2ota.h reference](ltapi/uf2ota_8h.md)
* Families
* Beken BK72xx
* [General info](docs/platform/beken-72xx/README.md)
* [Flashing](docs/platform/beken-72xx/flashing.md)
* Realtek AmebaZ Series
* [General info](docs/platform/realtek/README.md)
* [Flashing (AmebaZ)](docs/platform/realtek-ambz/flashing.md)
* [Debugging](docs/platform/realtek/debugging.md)
* [Exception decoder](docs/platform/realtek/exception-decoder.md)
* C library
* [Built-in functions](docs/platform/realtek-ambz/stdlib.md)
* [Memory management](docs/platform/realtek-ambz/memory-management.md)
* [All supported boards](boards/)
* [📓 TODO](TODO.md)
* [🔗 Resources](docs/resources.md)

View File

@@ -1,59 +0,0 @@
# Getting started
Using LibreTuya is simple, just like every other PlatformIO development platform.
## For your own projects
If you're developing your own embedded software, and want it to run on LibreTuya-supported chips, the installation is simple:
1. [Install PlatformIO](https://platformio.org/platformio-ide)
2. `platformio platform install https://github.com/kuba2k2/libretuya`
3. Create a project, build it and upload to the chip
## Community projects
LibreTuya was developed with popular community projects in mind. Currently, unofficial ESPHome port is available (the PR will hopefully be merged into upstream at some point).
### ESPHome
Because ESPHome does not natively support running on non-ESP chips, you need to use a fork of the project.
Assuming you have PlatformIO, git and Python installed:
1. Open a terminal/cmd.exe, create `esphome` directory and `cd` into it.
2. `git clone https://github.com/kuba2k2/libretuya-esphome -b platform/libretuya` (you need the `platform/libretuya` branch)
3. Go to [Boards & CPU list](https://kuba2k2.github.io/libretuya/docs/supported/) and choose your board name.
4. Create a YAML config file for your device. You can either:
- use `python -m esphome wizard yourdevice.yml` - type answers to the six questions the wizard asks
- if your board isn't available in the wizard yet, use the manual YAML method below
- write a config file manually:
```yaml
esphome:
name: yourdevice
libretuya:
board: wr3
logger:
api:
password: ""
ota:
password: ""
wifi:
ssid: "YourWiFiSSID"
password: "SecretPa$$w0rd"
ap:
ssid: "Yourdevice Fallback Hotspot"
password: "Dv2hZMGZRUvy"
```
5. Install LibreTuya: `platformio platform install https://github.com/kuba2k2/libretuya`. This step is necessary, as otherwise ESPHome will try to use a version from the registry, which is often outdated.
6. Edit the config file to use your installed LT version:
```yaml
libretuya:
board: wr3
framework:
version: latest
```
7. `python -m esphome compile yourdevice.yml`
8. The binary file, ready for uploading, is now in `.esphome/build/yourdevice/.pioenvs/yourdevice/`. Refer to your board README to find appropriate flashing instructions.

View File

@@ -0,0 +1,38 @@
# Getting started
Using LibreTuya is simple, just like every other PlatformIO development platform.
1. [Install PlatformIO](https://platformio.org/platformio-ide)
2. `platformio platform install https://github.com/kuba2k2/libretuya`
## Board selection
- Go to [Boards & CPU list](../status/supported.md).
- Find the board your device has (usually, the model number is written on the silkscreen).
- If your board isn't available yet, use one of the "Generic" boards that matches the CPU you have.
- Click on the board name. From the documentation page, note the board code.
- Use this code to create a PlatformIO project.
## GPIO usage
!!! important
This can be confusing at first, so make sure to read this part carefully to understand it.
Input/output pin numbers in Arduino code (i.e. `digitalWrite()`) use Arduino pin numbers - for example `D1`, `D3`. This is the same as simply `1` or `3`, but it cannot be confused with CPU GPIO numbers.
On the board pinout page, the purple blocks represent Arduino pins, while the dark red blocks refer to GPIO numbers.
Projects like ESPHome also use Arduino pin numbering.
## Develop your own project
If you're developing your own embedded software, and want it to run on LibreTuya-supported chips, create a project.
- use PlatformIO IDE (PIO Home -> Open -> New Project)
- run `pio project init` in your desired project directory
Next, read [Uploading](uploading.md) guide to run your project!
## Run community projects
LibreTuya was developed with popular community projects in mind. Currently, unofficial [ESPHome port](../projects/esphome.md) is available ([the PR](https://github.com/esphome/esphome/pull/3509) will hopefully be merged into upstream at some point).

View File

@@ -0,0 +1,6 @@
# Uploading
The uploading/flashing procedure is different for every chip family:
- BK72xx / BK7231 - [click here](../platform/beken-72xx/flashing.md)
- Realtek AmebaZ (RTL8710BN/BX) - [click here](../platform/realtek-ambz/flashing.md)

View File

@@ -29,7 +29,7 @@ For easier understanding, these update types will be referred to in this documen
## Custom family IDs
{%
include-markdown "../supported_families.md"
include-markdown "../status/supported_families.md"
%}
## Extension tags

View File

@@ -10,6 +10,14 @@ Downloading is done using UART. For best experience, you should have two USB<->U
If you're not using auto-reset, you'll have to reset the chip manually when upload starts (you have 10 seconds to do that).
- UART1 is used for uploading the code. This adapter will be used by PlatformIO.
- UART2 allows for log output. You can have a terminal session continuously open on this adapter.
!!! hint
If you only have a single adapter, or just want to use the UART1 (upload) port only, you can change the logging port.
Refer to [Options & config](../../reference/config.md) (`Serial output` section). Set `LT_UART_DEFAULT_PORT` to `1`, which will use UART1 for all output.
## Automatically - using PlatformIO (recommended)
LibreTuya has built-in firmware uploaders. Pressing `Upload` in PlatformIO IDE does all the work for you.
@@ -30,7 +38,7 @@ upload_port = COM96
## Manually - using `uf2upload`
{%
include-markdown "../../flashing-uf2ota.md"
include-markdown "../../ota/flashing.md"
%}
## Manually - using raw binaries/BkWriter

View File

@@ -3,7 +3,10 @@
- [Flashing (Tuya manual)](https://developer.tuya.com/en/docs/iot/burn-and-authorize-wr-series-modules?id=Ka789pjc581u8)
- [ImageTool (AmebaZ/AmebaD)](https://images.tuyacn.com/smart/Image_Tool/Image_Tool.zip)
Downloading is done using UART. It is required to put the chip into download mode, prior to flashing. This can be done by resetting the chip, while pulling UART2_TX to GND. If successful, the chip should print few garbage characters every second.
Downloading is done using UART2 (sometimes called Log_UART). Refer to your board documentation to find the correct pins.
!!! important
It is required to put the chip into download mode, prior to flashing. This can be done by resetting the chip, while pulling UART2_TX to GND. If successful, the chip should print few garbage characters every second.
## Automatically - using PlatformIO (recommended)
@@ -20,7 +23,7 @@ upload_port = COM60
## Manually - using `uf2upload`
{%
include-markdown "../../flashing-uf2ota.md"
include-markdown "../../ota/flashing.md"
%}
## Manually - using raw binaries/BkWriter

49
docs/projects/esphome.md Normal file
View File

@@ -0,0 +1,49 @@
# ESPHome
!!! note
Read [Getting started](../getting-started/README.md) first.
Because ESPHome does not natively support running on non-ESP chips, you need to use a fork of the project.
Assuming you have PlatformIO, git and Python installed:
1. Open a terminal/cmd.exe, create `esphome` directory and `cd` into it.
2. `git clone https://github.com/kuba2k2/libretuya-esphome -b platform/libretuya` (you need the `platform/libretuya` branch)
3. Go to [Boards & CPU list](https://kuba2k2.github.io/libretuya/docs/supported/), click on your board and remember your board code.
4. Create a YAML config file for your device. You can either:
- use `python -m esphome wizard yourdevice.yml` - type answers to the six questions the wizard asks
- if your board isn't available in the wizard yet, use the manual YAML method below
- write a config file manually:
```yaml
esphome:
name: yourdevice
libretuya:
board: wr3 # THIS IS YOUR BOARD CODE
framework:
version: latest
logger:
api:
password: ""
ota:
password: ""
wifi:
ssid: "YourWiFiSSID"
password: "SecretPa$$w0rd"
ap:
ssid: "Yourdevice Fallback Hotspot"
password: "Dv2hZMGZRUvy"
```
5. Compile and upload ESPHome:
- `python -m esphome compile yourdevice.yml` - this will only compile the code
- `python -m esphome upload yourdevice.yml` - this will upload the previously compiled code
- `python -m esphome run yourdevice.yml` - this will compile and upload the code
!!! info
If you want to flash manually:
The binary file, ready for uploading, will be in `.esphome/build/yourdevice/.pioenvs/yourdevice/`.
Refer to your board README to find appropriate flashing instructions.

View File

@@ -15,7 +15,7 @@ custom_fw_version = 1.2.0
## LibreTuya options
!!! note
See [LibreTuyaConfig.h](../ltapi/_libre_tuya_config_8h_source.md) for most options and their defaults.
See [LibreTuyaConfig.h](../../ltapi/_libre_tuya_config_8h_source.md) for most options and their defaults.
All options are configurable via C++ defines in PlatformIO project file. For example:
```ini

View File

@@ -1,7 +1,7 @@
# Implementation status
{%
include-markdown "../README.md"
include-markdown "../../README.md"
start="\n## Arduino Core support status\n"
end="\n## License\n"
%}

View File

@@ -26,7 +26,7 @@ A list of chip families currently supported by this project.
!!! note
The term *family* was chosen over *platform*, in order to reduce possible confusion between LibreTuya supported "platforms" and PlatformIO's "platform", as an entire package. *Family* is also more compatible with the UF2 term.
The following list corresponds to UF2 OTA format family names, and is also [available as JSON](../families.json). The IDs are also present in [ChipType.h](../ltapi/_chip_type_8h_source.md).
The following list corresponds to UF2 OTA format family names, and is also [available as JSON](../../families.json). The IDs are also present in [ChipType.h](../../ltapi/_chip_type_8h_source.md).
{%
include-markdown "supported_families.md"

View File

@@ -0,0 +1,32 @@
<!-- This file is auto-generated -->
Name | MCU | Flash | RAM | Pins* | Wi-Fi | BLE | ZigBee | Family name
--------------------------------------------------------------------------|-----------|-------|---------|-------------|-------|-----|--------|----------------
**Generic** | | | | | | | |
[BK7231N (Tuya QFN32)](../../boards/generic-bk7231n-qfn32-tuya/README.md) | BK7231N | 2 MiB | 256 KiB | 19 (19 I/O) | ✔️ | ✔️ | ❌ | `beken-7231n`
[BK7231T (Tuya QFN32)](../../boards/generic-bk7231t-qfn32-tuya/README.md) | BK7231T | 2 MiB | 256 KiB | 19 (19 I/O) | ✔️ | ✔️ | ❌ | `beken-7231t`
[RTL8710BN (2M/468k)](../../boards/generic-rtl8710bn-2mb-468k/README.md) | RTL8710BN | 2 MiB | 256 KiB | 18 (18 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
[RTL8710BN (2M/788k)](../../boards/generic-rtl8710bn-2mb-788k/README.md) | RTL8710BN | 2 MiB | 256 KiB | 18 (18 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
[RTL8720CF (2M/992k)](../../boards/generic-rtl8720cf-2mb-992k/README.md) | RTL8720CF | 2 MiB | 256 KiB | 20 (20 I/O) | ✔️ | ✔️ | ❌ | `realtek-ambz2`
**Ai-Thinker Co., Ltd.** | | | | | | | |
[BW12](../../boards/bw12/README.md) | RTL8710BX | 2 MiB | 256 KiB | 16 (12 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
[BW15](../../boards/bw15/README.md) | RTL8720CF | 2 MiB | 256 KiB | 16 (13 I/O) | ✔️ | ✔️ | ❌ | `realtek-ambz2`
**Tuya Inc.** | | | | | | | |
[CB2S](../../boards/cb2s/README.md) | BK7231N | 2 MiB | 256 KiB | 11 (8 I/O) | ✔️ | ✔️ | ❌ | `beken-7231n`
[WB2L](../../boards/wb2l/README.md) | BK7231T | 2 MiB | 256 KiB | 7 (5 I/O) | ✔️ | ✔️ | ❌ | `beken-7231t`
[WB2S](../../boards/wb2s/README.md) | BK7231T | 2 MiB | 256 KiB | 11 (8 I/O) | ✔️ | ✔️ | ❌ | `beken-7231t`
[WB3L](../../boards/wb3l/README.md) | BK7231T | 2 MiB | 256 KiB | 21 (17 I/O) | ✔️ | ✔️ | ❌ | `beken-7231t`
[WB3S](../../boards/wb3s/README.md) | BK7231T | 2 MiB | 256 KiB | 22 (16 I/O) | ✔️ | ✔️ | ❌ | `beken-7231t`
[WR2](../../boards/wr2/README.md) | RTL8710BN | 2 MiB | 256 KiB | 11 (8 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
[WR2E](../../boards/wr2e/README.md) | RTL8710BN | 2 MiB | 256 KiB | 11 (8 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
[WR3](../../boards/wr3/README.md) | RTL8710BN | 2 MiB | 256 KiB | 16 (12 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
[WR3E](../../boards/wr3e/README.md) | RTL8710BN | 2 MiB | 256 KiB | 16 (12 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
[WR3N](../../boards/wr3n/README.md) | RTL8710BN | 2 MiB | 256 KiB | 16 (10 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
[WR2L](../../boards/wr2l/README.md) | RTL8710BX | 2 MiB | 256 KiB | 7 (5 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
[WR2LE](../../boards/wr2le/README.md) | RTL8710BX | 2 MiB | 256 KiB | 7 (5 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
[WR3L](../../boards/wr3l/README.md) | RTL8710BX | 2 MiB | 256 KiB | 16 (12 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
[WR3LE](../../boards/wr3le/README.md) | RTL8710BX | 2 MiB | 256 KiB | 16 (12 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
**Unknown** | | | | | | | |
[LSC LMA35](../../boards/lsc-lma35/README.md) | BK7231N | 2 MiB | 256 KiB | 22 (15 I/O) | ✔️ | ✔️ | ❌ | `beken-7231n`
**N/A** | | | | | | | |
[Native](../../boards/generic-native/README.md) | NATIVE | 4 MiB | 4 MiB | - | ✔️ | ❌ | ❌ | `host-native`

View File

@@ -1,32 +0,0 @@
<!-- This file is auto-generated -->
Name | MCU | Flash | RAM | Pins* | Wi-Fi | BLE | ZigBee | Family name
-----------------------------------------------------------------------|-----------|-------|---------|-------------|-------|-----|--------|----------------
**Generic** | | | | | | | |
[BK7231N (Tuya QFN32)](../boards/generic-bk7231n-qfn32-tuya/README.md) | BK7231N | 2 MiB | 256 KiB | 19 (19 I/O) | ✔️ | ✔️ | ❌ | `beken-7231n`
[BK7231T (Tuya QFN32)](../boards/generic-bk7231t-qfn32-tuya/README.md) | BK7231T | 2 MiB | 256 KiB | 19 (19 I/O) | ✔️ | ✔️ | ❌ | `beken-7231t`
[RTL8710BN (2M/468k)](../boards/generic-rtl8710bn-2mb-468k/README.md) | RTL8710BN | 2 MiB | 256 KiB | 18 (18 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
[RTL8710BN (2M/788k)](../boards/generic-rtl8710bn-2mb-788k/README.md) | RTL8710BN | 2 MiB | 256 KiB | 18 (18 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
[RTL8720CF (2M/992k)](../boards/generic-rtl8720cf-2mb-992k/README.md) | RTL8720CF | 2 MiB | 256 KiB | 20 (20 I/O) | ✔️ | ✔️ | ❌ | `realtek-ambz2`
**Ai-Thinker Co., Ltd.** | | | | | | | |
[BW12](../boards/bw12/README.md) | RTL8710BX | 2 MiB | 256 KiB | 16 (12 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
[BW15](../boards/bw15/README.md) | RTL8720CF | 2 MiB | 256 KiB | 16 (13 I/O) | ✔️ | ✔️ | ❌ | `realtek-ambz2`
**Tuya Inc.** | | | | | | | |
[CB2S](../boards/cb2s/README.md) | BK7231N | 2 MiB | 256 KiB | 11 (8 I/O) | ✔️ | ✔️ | ❌ | `beken-7231n`
[WB2L](../boards/wb2l/README.md) | BK7231T | 2 MiB | 256 KiB | 7 (5 I/O) | ✔️ | ✔️ | ❌ | `beken-7231t`
[WB2S](../boards/wb2s/README.md) | BK7231T | 2 MiB | 256 KiB | 11 (8 I/O) | ✔️ | ✔️ | ❌ | `beken-7231t`
[WB3L](../boards/wb3l/README.md) | BK7231T | 2 MiB | 256 KiB | 21 (17 I/O) | ✔️ | ✔️ | ❌ | `beken-7231t`
[WB3S](../boards/wb3s/README.md) | BK7231T | 2 MiB | 256 KiB | 22 (16 I/O) | ✔️ | ✔️ | ❌ | `beken-7231t`
[WR2](../boards/wr2/README.md) | RTL8710BN | 2 MiB | 256 KiB | 11 (8 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
[WR2E](../boards/wr2e/README.md) | RTL8710BN | 2 MiB | 256 KiB | 11 (8 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
[WR3](../boards/wr3/README.md) | RTL8710BN | 2 MiB | 256 KiB | 16 (12 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
[WR3E](../boards/wr3e/README.md) | RTL8710BN | 2 MiB | 256 KiB | 16 (12 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
[WR3N](../boards/wr3n/README.md) | RTL8710BN | 2 MiB | 256 KiB | 16 (10 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
[WR2L](../boards/wr2l/README.md) | RTL8710BX | 2 MiB | 256 KiB | 7 (5 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
[WR2LE](../boards/wr2le/README.md) | RTL8710BX | 2 MiB | 256 KiB | 7 (5 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
[WR3L](../boards/wr3l/README.md) | RTL8710BX | 2 MiB | 256 KiB | 16 (12 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
[WR3LE](../boards/wr3le/README.md) | RTL8710BX | 2 MiB | 256 KiB | 16 (12 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz`
**Unknown** | | | | | | | |
[LSC LMA35](../boards/lsc-lma35/README.md) | BK7231N | 2 MiB | 256 KiB | 22 (15 I/O) | ✔️ | ✔️ | ❌ | `beken-7231n`
**N/A** | | | | | | | |
[Native](../boards/generic-native/README.md) | NATIVE | 4 MiB | 4 MiB | - | ✔️ | ❌ | ❌ | `host-native`

View File

@@ -20,6 +20,8 @@ from tools.util.platform import (
get_family,
)
OUTPUT = join(dirname(__file__), "status")
def load_boards() -> Dict[str, dict]:
return {board: get_board_manifest(board) for board in get_board_list()}
@@ -126,13 +128,13 @@ def get_board_symbol(board_name: str, board: dict) -> str:
def write_chips(mcus: List[str]):
md = Markdown(dirname(__file__), "supported_chips")
md = Markdown(OUTPUT, "supported_chips")
md.add_list(*mcus)
md.write()
def write_boards(boards: List[Tuple[str, dict]]):
md = Markdown(dirname(__file__), "supported_boards")
md = Markdown(OUTPUT, "supported_boards")
header = [
"Name",
"MCU",
@@ -164,7 +166,7 @@ def write_boards(boards: List[Tuple[str, dict]]):
pins = f"{pins_total} ({pins_io} I/O)"
# format row values
symbol = get_board_symbol(board_name, board)
board_url = f"[{symbol}](../boards/{board_name}/README.md)"
board_url = f"[{symbol}](../../boards/{board_name}/README.md)"
row = [
board_url,
get(board, "build.mcu").upper(),
@@ -186,7 +188,7 @@ def write_unsupported_boards(
name: str,
supported: List[str],
):
md = Markdown(dirname(__file__), name)
md = Markdown(OUTPUT, name)
header = [
"Name",
"MCU",
@@ -223,7 +225,7 @@ def write_unsupported_boards(
def write_families():
md = Markdown(dirname(__file__), "supported_families")
md = Markdown(OUTPUT, "supported_families")
header = [
"Title",
"Name (parent)",