[core] Refactor structure

This commit is contained in:
Kuba Szczodrzyński
2022-04-23 23:02:42 +02:00
parent bc8755fd06
commit 0d6fe8b8c0
16 changed files with 81 additions and 13 deletions

View File

@@ -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/
├─ <platform name>/ Arduino Core for specific platform
│ ├─ cores/ Core files
│ ├─ libraries/ Supported built-in libraries
boards/
├─ <board name>/ Board-specific code
│ ├─ variant.cpp Arduino variant initialization
│ ├─ variant.h Arduino variant pin configs
├─ <board name>.json PlatformIO board description
builder/
├─ frameworks/ Framework builders for PlatformIO
│ ├─ <platform name>-sdk.py Vanilla SDK build system
│ ├─ <platform name>-arduino.py Arduino Core build system
├─ main.py Main PlatformIO builder
fixups/
├─ <platform name>/ Code fix-ups to replace SDK parts
platform/
├─ <platform name>/ Other platform-specific files
│ ├─ bin/ Binary blobs (bootloaders, etc.)
│ ├─ ld/ Linker scripts
tools/
├─ <tool name>/ 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.
&nbsp; | `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

View File

@@ -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",

View File

@@ -1 +0,0 @@
boot_all.bin tysdk_for_rtl8710bn

View File

@@ -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

View File

@@ -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),
],
)

View File

@@ -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])

6
descript.ion Normal file
View File

@@ -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

View File

@@ -0,0 +1 @@
boot_all_77F7.bin tysdk_for_rtl8710bn