diff --git a/boards/generic-native.json b/boards/generic-native.json deleted file mode 100644 index 00dfd6e..0000000 --- a/boards/generic-native.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "build": { - "family": "NATIVE", - "mcu": "native", - "f_cpu": "1000000000L", - "variant": "generic-native" - }, - "flash": { - "bootloader": "0x000000+0x10000", - "system": "0x010000+0x10000", - "ota1": "0x020000+0x100000", - "ota2": "0x120000+0x100000", - "download": "0x220000+0x100000", - "kvs": "0x320000+0x40000", - "userdata": "0x360000+0xA0000" - }, - "connectivity": [ - "wifi" - ], - "frameworks": [ - "host-native-sdk", - "host-native-arduino" - ], - "upload": { - "maximum_ram_size": 4194304, - "flash_size": 4194304, - "maximum_size": 1048576 - }, - "doc": { - "params": { - "manufacturer": "N/A", - "series": "N/A", - "voltage": "5V" - }, - "extra": [ - "## Description", - "`generic-native` is a dummy board using the `host-native` family, which also serves as a template for building new families, as well as for testing flash-related modules (i.e. Fat FS, OTA, etc)." - ] - }, - "name": "Generic - Host-native", - "vendor": "N/A", - "url": "https://kuba2k2.github.io/libretuya/", - "symbol": "Native" -} diff --git a/boards/generic-native/README.md b/boards/generic-native/README.md deleted file mode 100644 index 48a61a4..0000000 --- a/boards/generic-native/README.md +++ /dev/null @@ -1,58 +0,0 @@ -# Generic - Host-native - -*by N/A* - -[Product page](https://kuba2k2.github.io/libretuya/) - -Parameter | Value --------------|----------------- -Board code | `generic-native` -MCU | NATIVE -Manufacturer | N/A -Series | N/A -Frequency | 1 GHz -Flash size | 4 MiB -RAM size | 4 MiB -Voltage | 5V - -## Usage - -**Board code:** `generic-native` - -In `platformio.ini`: - -```ini -[env:generic-native] -platform = libretuya -board = generic-native -framework = arduino -``` - -In ESPHome YAML: - -```yaml -libretuya: - board: generic-native - framework: - version: dev -``` - -## Flash memory map - -Flash size: 4 MiB / 4,194,304 B / 0x400000 - -Hex values are in bytes. - -Name | Start | Length | End -----------------|----------|-------------------|--------- -Bootloader | 0x000000 | 64 KiB / 0x10000 | 0x010000 -System Data | 0x010000 | 64 KiB / 0x10000 | 0x020000 -OTA1 Image | 0x020000 | 1 MiB / 0x100000 | 0x120000 -OTA2 Image | 0x120000 | 1 MiB / 0x100000 | 0x220000 -OTA Image | 0x220000 | 1 MiB / 0x100000 | 0x320000 -Key-Value Store | 0x320000 | 256 KiB / 0x40000 | 0x360000 -User Data | 0x360000 | 640 KiB / 0xA0000 | 0x400000 - -## Description - -`generic-native` is a dummy board using the `host-native` family, which also serves as a template for building new families, as well as for testing flash-related modules (i.e. Fat FS, OTA, etc). diff --git a/boards/generic-native/pins_arduino.h b/boards/generic-native/pins_arduino.h deleted file mode 100644 index 1de3ade..0000000 --- a/boards/generic-native/pins_arduino.h +++ /dev/null @@ -1 +0,0 @@ -#include "variant.h" diff --git a/boards/generic-native/variant.h b/boards/generic-native/variant.h deleted file mode 100644 index 4c3b6cd..0000000 --- a/boards/generic-native/variant.h +++ /dev/null @@ -1,7 +0,0 @@ -/* This file was auto-generated from generic-native.json using boardgen */ - -#pragma once - -#include - -// clang-format off diff --git a/docs/update_docs.py b/docs/update_docs.py index db90bfd..328a219 100644 --- a/docs/update_docs.py +++ b/docs/update_docs.py @@ -1,7 +1,7 @@ # Copyright (c) Kuba Szczodrzyński 2022-05-31. import sys -from os.path import dirname, join +from os.path import dirname, isfile, join sys.path.append(join(dirname(__file__), "..")) @@ -23,10 +23,10 @@ def load_chip_type_h() -> str: join( dirname(__file__), "..", - "arduino", - "libretuya", - "core", - "ChipType.h", + "cores", + "common", + "base", + "lt_chip.h", ) ) code = re.sub(r"//.+", "", code) @@ -57,7 +57,7 @@ def get_family_mcus() -> Set[str]: def get_family_names() -> Set[str]: - return set(family.short_name for family in Family.get_all()) + return set(family.short_name for family in Family.get_all() if family.is_chip) def get_board_mcus(boards: List[Board]) -> Set[str]: @@ -70,8 +70,8 @@ def get_board_mcus(boards: List[Board]) -> Set[str]: def get_enum_keys(code: str, name: str) -> Set[str]: code = code.replace("\t", " ") - code = code.partition(f"enum {name}")[2] - code = code.partition(";")[0] + code = code.partition(f"{name};")[0] + code = code.rpartition("{")[2] code = code.strip().strip("{}").strip() code = [line.strip().strip(",").strip() for line in code.split("\n")] code = filter(None, code) @@ -218,36 +218,51 @@ def write_families(): rows = [] for family in Family.get_all(): + # TODO update the table to support parent-child relationship + if not family.is_chip: + continue + docs = None + for f in family.inheritance: + readme = join(dirname(__file__), "platform", f.name, "README.md") + if isfile(readme): + docs = f"../{f.name}/" row = [ # Title "[{}]({})".format( family.description, - family.url, + docs, ) - if family.url + if docs else family.description, # Name (parent) - f"`{family.name or '-'}`" - if not family.parent - else f"`{family.name}` (`{family.parent}`)", + family.is_supported + and ( + f"`{family.name}`" + if not family.parent + else f"`{family.name}` (`{family.parent_name}`)" + ) + or "`-`", # Code - f"`{family.code or '-'}`" - if not family.parent - else f"`{family.code}` (`{family.parent_code}`)", + family.is_supported + and ( + f"`{family.code}`" + if not family.parent + else f"`{family.code}` (`{family.parent_code}`)" + ) + or "`-`", # Short name & ID "`{}` (0x{:X})".format( family.short_name, family.id, ), # Arduino Core - "✔️" if family.has_arduino_core else "❌", + "✔️" if family.is_supported and family.has_arduino_core else "❌", # Source SDK - "`{}` ([{}]({}))".format( - family.framework, - family.sdk_name, - family.sdk, + "[`{}`]({})".format( + family.target_package, + f"https://github.com/libretuya/{family.target_package}", ) - if family.sdk + if family.target_package else "-", ] rows.append(row) diff --git a/families.json b/families.json index 01ae01f..ef4358d 100644 --- a/families.json +++ b/families.json @@ -1,117 +1,112 @@ -[ - { +{ + "$schema": "./families.schema.json", + "realtek-amb": { + "parent": null, + "code": "amb", + "description": "Realtek Ameba" + }, + "realtek-amb1": { + "parent": "realtek-amb", + "code": "amb1", + "description": "Realtek Ameba1", "id": "0x9FFFD543", "short_name": "RTL8710A", - "description": "Realtek Ameba1" + "mcus": [] }, - { - "id": "0x22E0D6FC", - "short_name": "RTL8710B", - "description": "Realtek AmebaZ", - "parent_description": "Realtek Ameba", - "name": "realtek-ambz", + "realtek-ambz": { "parent": "realtek-amb", "code": "ambz", - "parent_code": "amb", - "url": "https://www.amebaiot.com/en/amebaz/", - "sdk": "https://github.com/ambiot/amb1_sdk", - "framework": "framework-realtek-amb1", + "description": "Realtek AmebaZ", + "id": "0x22E0D6FC", + "short_name": "RTL8710B", "mcus": [ "RTL8710BN", "RTL8710BX" ] }, - { - "id": "0xE08F7564", - "short_name": "RTL8720C", - "description": "Realtek AmebaZ2", - "parent_description": "Realtek Ameba", - "name": "realtek-ambz2", + "realtek-ambz2": { "parent": "realtek-amb", "code": "ambz2", - "parent_code": "amb", - "url": "https://www.amebaiot.com/en/amebaz2/", - "sdk": "https://github.com/ambiot/ambz2_sdk", - "framework": "framework-realtek-ambz2", + "description": "Realtek AmebaZ2", + "id": "0xE08F7564", + "short_name": "RTL8720C", "mcus": [ "RTL8720CF" ] }, - { + "realtek-ambd": { + "parent": "realtek-amb", + "code": "ambd", + "description": "Realtek AmebaD", "id": "0x3379CFE2", "short_name": "RTL8720D", - "description": "Realtek AmebaD" + "mcus": [] }, - { + "beken-72xx": { + "parent": null, + "code": "bk72xx", + "description": "Beken 72xx" + }, + "beken-72xx-gen1": { + "parent": "beken-72xx", + "code": "bk72xxgen1", + "description": "Beken 72xx (ARM)" + }, + "beken-72xx-gen2": { + "parent": "beken-72xx", + "code": "bk72xxgen2", + "description": "Beken 72xx (RISC-V & ARM)" + }, + "beken-7231u": { + "parent": "beken-72xx-gen1", + "code": "bk7231u", + "description": "Beken 7231U/7231T", "id": "0x675A40B0", "short_name": "BK7231U", - "description": "Beken 7231U/7231T", - "parent_description": "Beken 72xx", - "name": "beken-7231u", - "parent": "beken-72xx", - "code": "bk7231u", - "parent_code": "bk72xx", - "url": "http://www.bekencorp.com/en/goods/detail/cid/13.html", - "sdk": "https://github.com/bekencorp/bdk_freertos", - "framework": "framework-beken-bdk", "mcus": [ "BK7231T", "BK7231S", "BK7231U" ] }, - { + "beken-7231n": { + "parent": "beken-72xx-gen1", + "description": "Beken 7231N", + "code": "bk7231n", "id": "0x7B3EF230", "short_name": "BK7231N", - "description": "Beken 7231N", - "parent_description": "Beken 72xx", - "name": "beken-7231n", - "parent": "beken-72xx", - "code": "bk7231n", - "parent_code": "bk72xx", - "url": "http://www.bekencorp.com/en/goods/detail/cid/39.html", - "sdk": "https://github.com/bekencorp/bdk_freertos", - "framework": "framework-beken-bdk", "mcus": [ "BK7231N", "BL2028N" ] }, - { + "beken-7251": { + "parent": "beken-72xx-gen1", + "code": "bk7251", + "description": "Beken 7251/7252", "id": "0x6A82CC42", "short_name": "BK7251", - "description": "Beken 7251/7252", - "parent_description": "Beken 72xx", - "name": "beken-7251", - "parent": "beken-72xx", - "code": "bk7251", - "parent_code": "bk72xx", - "url": "http://www.bekencorp.com/en/goods/detail/cid/21.html", - "sdk": "https://github.com/bekencorp/bdk_freertos", - "framework": "framework-beken-bdk", "mcus": [ "BK7251", "BK7252" ] }, - { + "boufallo-bl678": { + "parent": null, + "code": "bl678", + "description": "Boufallo BL6xx/BL7xx/BL8xx" + }, + "boufallo-bl60x": { + "parent": "boufallo-bl678", + "code": "bl60x", + "description": "Boufallo BL602/BL604", "id": "0xDE1270B7", - "short_name": "BL602", - "description": "Boufallo 602" + "short_name": "BL60X", + "mcus": [] }, - { - "id": "0x51E903A8", - "short_name": "XR809", - "description": "Xradiotech 809" - }, - { - "id": "0xDEADBEEF", - "short_name": "NATIVE", - "description": "Native host architecture", - "name": "host-native", - "code": "native", - "mcus": [ - "NATIVE" - ] + "winnermicro-iot": { + "parent": null, + "code": "wmiot", + "description": "WinnerMicro W60x/W800x" } -] +} diff --git a/families.schema.json b/families.schema.json new file mode 100644 index 0000000..16f332a --- /dev/null +++ b/families.schema.json @@ -0,0 +1,50 @@ +{ + "type": "object", + "properties": { + "$schema": { + "type": "string" + } + }, + "patternProperties": { + "^[a-z0-9-]+$": { + "properties": { + "parent": { + "type": [ + "string", + "null" + ], + "pattern": "^[a-z0-9-]+$" + }, + "code": { + "type": "string", + "pattern": "^[a-z0-9]+$" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string", + "pattern": "^0x[0-9A-F]{8}$" + }, + "short_name": { + "type": "string", + "pattern": "^[A-Z0-9]+$" + }, + "mcus": { + "type": "array", + "items": { + "type": "string", + "pattern": "^[A-Z0-9]+$" + } + } + }, + "additionalProperties": false, + "required": [ + "parent", + "code", + "description" + ] + } + }, + "additionalProperties": false +}