From 0d6fe8b8c057921ce414acd8897053d325910431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Sat, 23 Apr 2022 23:02:42 +0200 Subject: [PATCH] [core] Refactor structure --- README.md | 63 +++++++++++++++++- boards/wr3.json | 2 +- boards/wr3/bin/descript.ion | 1 - boards/wr3/ld/descript.ion | 5 -- builder/frameworks/realtek-ambz-arduino.py | 5 +- builder/frameworks/realtek-ambz-sdk.py | 11 ++- descript.ion | 6 ++ .../realtek-ambz/bin/boot_all_77F7.bin | Bin platform/realtek-ambz/bin/descript.ion | 1 + .../ld/export-rom_symbol_v01.txt | 0 .../ld/rlx8711B-symbol-v02-img2_xip1.ld | 0 .../ld/rlx8711B-symbol-v02-img2_xip1_2M.ld | 0 .../rlx8711B-symbol-v02-img2_xip1_2M_cpp.ld | 0 .../ld/rlx8711B-symbol-v02-img2_xip2.ld | 0 .../ld/rlx8711B-symbol-v02-img2_xip2_2M.ld | 0 .../rlx8711B-symbol-v02-img2_xip2_2M_cpp.ld | 0 16 files changed, 81 insertions(+), 13 deletions(-) delete mode 100644 boards/wr3/bin/descript.ion create mode 100644 descript.ion rename boards/wr3/bin/boot_all.bin => platform/realtek-ambz/bin/boot_all_77F7.bin (100%) create mode 100644 platform/realtek-ambz/bin/descript.ion rename {boards/wr3 => platform/realtek-ambz}/ld/export-rom_symbol_v01.txt (100%) rename {boards/wr3 => platform/realtek-ambz}/ld/rlx8711B-symbol-v02-img2_xip1.ld (100%) rename {boards/wr3 => platform/realtek-ambz}/ld/rlx8711B-symbol-v02-img2_xip1_2M.ld (100%) rename {boards/wr3 => platform/realtek-ambz}/ld/rlx8711B-symbol-v02-img2_xip1_2M_cpp.ld (100%) rename {boards/wr3 => platform/realtek-ambz}/ld/rlx8711B-symbol-v02-img2_xip2.ld (100%) rename {boards/wr3 => platform/realtek-ambz}/ld/rlx8711B-symbol-v02-img2_xip2_2M.ld (100%) rename {boards/wr3 => platform/realtek-ambz}/ld/rlx8711B-symbol-v02-img2_xip2_2M_cpp.ld (100%) diff --git a/README.md b/README.md index aa1859f..46fd7be 100644 --- a/README.md +++ b/README.md @@ -64,13 +64,43 @@ A (mostly) complete* list of Tuya wireless module boards. ** I/O count includes GPIOs, ADCs, PWM outputs and UART, but doesn't count CEN/RST and power pins. +## Project structure + +``` +arduino/ +├─ / Arduino Core for specific platform +│ ├─ cores/ Core files +│ ├─ libraries/ Supported built-in libraries +boards/ +├─ / Board-specific code +│ ├─ variant.cpp Arduino variant initialization +│ ├─ variant.h Arduino variant pin configs +├─ .json PlatformIO board description +builder/ +├─ frameworks/ Framework builders for PlatformIO +│ ├─ -sdk.py Vanilla SDK build system +│ ├─ -arduino.py Arduino Core build system +├─ main.py Main PlatformIO builder +fixups/ +├─ / Code fix-ups to replace SDK parts +platform/ +├─ / Other platform-specific files +│ ├─ bin/ Binary blobs (bootloaders, etc.) +│ ├─ ld/ Linker scripts +tools/ +├─ / Tools used during the build +platform.json PlatformIO manifest +platform.py Custom PlatformIO script + +``` + ## Platforms A list of platforms currently available in this project. Platform name | Supported MCU(s) | Arduino Core | Source SDK (PIO framework) ---------------|------------------------------------------------------------------------|--------------|-------------------------------------------------------------------------- -`realtek-ambz` | Realtek [AmebaZ](https://www.amebaiot.com/en/amebaz/) SoC (`RTL87xxB`) | ❌ | `framework-realtek-amb1` ([amb1_sdk](https://github.com/ambiot/amb1_sdk)) +`realtek-ambz` | Realtek [AmebaZ](https://www.amebaiot.com/en/amebaz/) SoC (`RTL87xxB`) | ✔️ | `framework-realtek-amb1` ([amb1_sdk](https://github.com/ambiot/amb1_sdk)) ### Realtek Ameba @@ -96,3 +126,34 @@ As such, there are numerous CPUs with the same numbers but different series, whi - and probably many more Different Ameba series are not compatible with each other. Apparently, there isn't a public SDK for AmebaZ that can support C++ properly (yet). + +## Arduino Core support status + +Note: this list will probably change with each functionality update. + +  | `realtek-ambz` +--|-- +Core functions|✔️ +GPIO/PWM/IRQ|✔️/❓/✔️ +Analog input|❓ +UART I/O|✔️ +Flash I/O|❓ +**LIBRARIES** +SPI|❌ +SPIFFS|❌ +Wire|❌ +BLE|- +Wi-Fi|❌ +HTTP|❌ +NTP|❌ +OTA|❌ +MDNS|❌ +MQTT|❌ +SD|❌ + +Legend: +- ✔️ working +- ❗ broken +- ❓ untested +- ❌ not implemented (yet?) +- \- not applicable diff --git a/boards/wr3.json b/boards/wr3.json index 4919f66..91643a6 100644 --- a/boards/wr3.json +++ b/boards/wr3.json @@ -8,7 +8,7 @@ "f_cpu": "125000000L", "amb_ota1_offset": "0x0800B000", "amb_ota2_offset": "0x080D0000", - "amb_boot_all": "boot_all.bin" + "amb_boot_all": "boot_all_77F7.bin" }, "frameworks": [ "realtek-ambz-sdk", diff --git a/boards/wr3/bin/descript.ion b/boards/wr3/bin/descript.ion deleted file mode 100644 index 983e07d..0000000 --- a/boards/wr3/bin/descript.ion +++ /dev/null @@ -1 +0,0 @@ -boot_all.bin tysdk_for_rtl8710bn diff --git a/boards/wr3/ld/descript.ion b/boards/wr3/ld/descript.ion index 3325fb3..2e8361d 100644 --- a/boards/wr3/ld/descript.ion +++ b/boards/wr3/ld/descript.ion @@ -1,8 +1,3 @@ -export-rom_symbol_v01.txt amb1_sdk -rlx8711B-symbol-v02-img2_xip1.ld amb1_sdk -rlx8711B-symbol-v02-img2_xip2.ld amb1_sdk -rlx8711B-symbol-v02-img2_xip2_2M.ld tysdk_for_rtl8710bn -rlx8711B-symbol-v02-img2_xip1_2M.ld tysdk_for_rtl8710bn rtl8710-symbol-v03-img2_arduino_arduino.ld amb1_arduino/rtl8710 export-rom_v03.txt amb1_arduino/rtl8710 export-rom_v04.txt RtlDuino/rtl8710 diff --git a/builder/frameworks/realtek-ambz-arduino.py b/builder/frameworks/realtek-ambz-arduino.py index d00ffa9..97ffe79 100644 --- a/builder/frameworks/realtek-ambz-arduino.py +++ b/builder/frameworks/realtek-ambz-arduino.py @@ -17,10 +17,12 @@ ldscript = board.get("build.ldscript_arduino") SDK_DIR = platform.get_package_dir("framework-realtek-amb1") BOARD_DIR = join(platform.get_dir(), "boards", variant) FIXUPS_DIR = join(platform.get_dir(), "fixups", "realtek-ambz") +PLATFORM_DIR = join(platform.get_dir(), "platform", "realtek-ambz") CORE_DIR = join(platform.get_dir(), "arduino", "realtek-ambz") assert isdir(SDK_DIR) assert isdir(env.subst(BOARD_DIR)) assert isdir(env.subst(FIXUPS_DIR)) +assert isdir(env.subst(PLATFORM_DIR)) assert isdir(env.subst(CORE_DIR)) # Flags @@ -75,7 +77,6 @@ env.Prepend( CPPPATH=[ # fmt: off # prepend these as the Arduino core is incorrectly picking some includes from SDK - join(BOARD_DIR), join(CORE_DIR, "cores", "arduino"), join(CORE_DIR, "cores", "arduino", "avr"), join(CORE_DIR, "cores", "arduino", "rtl8195a"), @@ -143,7 +144,7 @@ env.Append( ) env.Replace( LDSCRIPT_PATH=[ - join(BOARD_DIR, "ld", ldscript), + join(PLATFORM_DIR, "ld", ldscript), ], ) diff --git a/builder/frameworks/realtek-ambz-sdk.py b/builder/frameworks/realtek-ambz-sdk.py index 4a3267b..53bfb89 100644 --- a/builder/frameworks/realtek-ambz-sdk.py +++ b/builder/frameworks/realtek-ambz-sdk.py @@ -14,9 +14,11 @@ ldscript = board.get("build.ldscript_sdk") SDK_DIR = platform.get_package_dir("framework-realtek-amb1") BOARD_DIR = join(platform.get_dir(), "boards", variant) FIXUPS_DIR = join(platform.get_dir(), "fixups", "realtek-ambz") +PLATFORM_DIR = join(platform.get_dir(), "platform", "realtek-ambz") assert isdir(SDK_DIR) assert isdir(env.subst(BOARD_DIR)) assert isdir(env.subst(FIXUPS_DIR)) +assert isdir(env.subst(PLATFORM_DIR)) ota1_offset = board.get("build.amb_ota1_offset") ota2_offset = board.get("build.amb_ota2_offset") @@ -98,6 +100,9 @@ env.Replace( env.Append( CPPPATH=[ # fmt: off + join(BOARD_DIR), + join(FIXUPS_DIR), + join(PLATFORM_DIR), join(SDK_DIR, "project", "realtek_amebaz_va0_example", "inc"), join(SDK_DIR, "component", "os", "freertos"), join(SDK_DIR, "component", "os", "freertos", "freertos_v8.1.2", "Source", "include"), @@ -376,7 +381,7 @@ env.Append( join(SDK_DIR, "component", "soc", "realtek", "8711b", "misc", "bsp", "lib", "common", "GCC"), # fmt: on # linker script path - join(BOARD_DIR, "ld"), + join(PLATFORM_DIR, "ld"), ], LIBS=[ "_platform", @@ -396,7 +401,7 @@ env.Append( ) env.Replace( LDSCRIPT_PATH=[ - join(BOARD_DIR, "ld", ldscript), + join(PLATFORM_DIR, "ld", ldscript), ], ) @@ -554,7 +559,7 @@ target_boot = env.StaticLibrary( join("$BUILD_DIR", "boot_all"), env.BinToObj( join("$BUILD_DIR", "boot_all.o"), - join(BOARD_DIR, "bin", boot_all), + join(PLATFORM_DIR, "bin", boot_all), ), ) env.Prepend(LIBS=[target_sdk, target_boot]) diff --git a/descript.ion b/descript.ion new file mode 100644 index 0000000..3fd5d57 --- /dev/null +++ b/descript.ion @@ -0,0 +1,6 @@ +tools Firmware tools (i.e. flashers) +platform Platform files (blobs, linker scripts) +fixups Code fixups +builder PlatformIO builders +boards Board definitions +arduino Arduino cores diff --git a/boards/wr3/bin/boot_all.bin b/platform/realtek-ambz/bin/boot_all_77F7.bin similarity index 100% rename from boards/wr3/bin/boot_all.bin rename to platform/realtek-ambz/bin/boot_all_77F7.bin diff --git a/platform/realtek-ambz/bin/descript.ion b/platform/realtek-ambz/bin/descript.ion new file mode 100644 index 0000000..4074cb3 --- /dev/null +++ b/platform/realtek-ambz/bin/descript.ion @@ -0,0 +1 @@ +boot_all_77F7.bin tysdk_for_rtl8710bn diff --git a/boards/wr3/ld/export-rom_symbol_v01.txt b/platform/realtek-ambz/ld/export-rom_symbol_v01.txt similarity index 100% rename from boards/wr3/ld/export-rom_symbol_v01.txt rename to platform/realtek-ambz/ld/export-rom_symbol_v01.txt diff --git a/boards/wr3/ld/rlx8711B-symbol-v02-img2_xip1.ld b/platform/realtek-ambz/ld/rlx8711B-symbol-v02-img2_xip1.ld similarity index 100% rename from boards/wr3/ld/rlx8711B-symbol-v02-img2_xip1.ld rename to platform/realtek-ambz/ld/rlx8711B-symbol-v02-img2_xip1.ld diff --git a/boards/wr3/ld/rlx8711B-symbol-v02-img2_xip1_2M.ld b/platform/realtek-ambz/ld/rlx8711B-symbol-v02-img2_xip1_2M.ld similarity index 100% rename from boards/wr3/ld/rlx8711B-symbol-v02-img2_xip1_2M.ld rename to platform/realtek-ambz/ld/rlx8711B-symbol-v02-img2_xip1_2M.ld diff --git a/boards/wr3/ld/rlx8711B-symbol-v02-img2_xip1_2M_cpp.ld b/platform/realtek-ambz/ld/rlx8711B-symbol-v02-img2_xip1_2M_cpp.ld similarity index 100% rename from boards/wr3/ld/rlx8711B-symbol-v02-img2_xip1_2M_cpp.ld rename to platform/realtek-ambz/ld/rlx8711B-symbol-v02-img2_xip1_2M_cpp.ld diff --git a/boards/wr3/ld/rlx8711B-symbol-v02-img2_xip2.ld b/platform/realtek-ambz/ld/rlx8711B-symbol-v02-img2_xip2.ld similarity index 100% rename from boards/wr3/ld/rlx8711B-symbol-v02-img2_xip2.ld rename to platform/realtek-ambz/ld/rlx8711B-symbol-v02-img2_xip2.ld diff --git a/boards/wr3/ld/rlx8711B-symbol-v02-img2_xip2_2M.ld b/platform/realtek-ambz/ld/rlx8711B-symbol-v02-img2_xip2_2M.ld similarity index 100% rename from boards/wr3/ld/rlx8711B-symbol-v02-img2_xip2_2M.ld rename to platform/realtek-ambz/ld/rlx8711B-symbol-v02-img2_xip2_2M.ld diff --git a/boards/wr3/ld/rlx8711B-symbol-v02-img2_xip2_2M_cpp.ld b/platform/realtek-ambz/ld/rlx8711B-symbol-v02-img2_xip2_2M_cpp.ld similarity index 100% rename from boards/wr3/ld/rlx8711B-symbol-v02-img2_xip2_2M_cpp.ld rename to platform/realtek-ambz/ld/rlx8711B-symbol-v02-img2_xip2_2M_cpp.ld