Compare commits
257 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7c28eeea4 | ||
|
|
113b2fc31d | ||
|
|
86924d8785 | ||
|
|
219415174e | ||
|
|
8999cb9091 | ||
|
|
8337ac121e | ||
|
|
d332315e7a | ||
|
|
882f58bae4 | ||
|
|
2c86a36fe0 | ||
|
|
b984519546 | ||
|
|
7b0f6b22c1 | ||
|
|
3b8a4f1b60 | ||
|
|
edd2c0542b | ||
|
|
dbc905dca3 | ||
|
|
461e4c6df0 | ||
|
|
85a687fc56 | ||
|
|
c5361a4738 | ||
|
|
42c18859f3 | ||
|
|
1ba6834391 | ||
|
|
376a4db4cb | ||
|
|
775e06b259 | ||
|
|
3ba3c2a2be | ||
|
|
76ad89e2f1 | ||
|
|
2a7f1b52a0 | ||
|
|
bd75b54dce | ||
|
|
070f2afd66 | ||
|
|
0e84e08a18 | ||
|
|
4c1ab20ba4 | ||
|
|
63ac7b365d | ||
|
|
c51bf0b7db | ||
|
|
201db4668e | ||
|
|
250e67ab1f | ||
|
|
2e30d34021 | ||
|
|
2882eaa0c2 | ||
|
|
8faffedddc | ||
|
|
5260930919 | ||
|
|
24832d3277 | ||
|
|
8f338a6b30 | ||
|
|
3d3f3700a8 | ||
|
|
eae64d34e2 | ||
|
|
a27e76bfa7 | ||
|
|
b050662a5c | ||
|
|
f69b4bea4f | ||
|
|
4e3b081c60 | ||
|
|
a2de77ce30 | ||
|
|
5de98ed56c | ||
|
|
ff8ac6036c | ||
|
|
c3f12ab247 | ||
|
|
dfcb36361e | ||
|
|
c4a3e9e2ee | ||
|
|
fd1afea1bc | ||
|
|
65cf460691 | ||
|
|
046f7df7d1 | ||
|
|
8323bafd4c | ||
|
|
6b92aac1da | ||
|
|
3113b387c3 | ||
|
|
6d2b653f61 | ||
|
|
47daefe675 | ||
|
|
e8c18f4e66 | ||
|
|
76a82768fe | ||
|
|
8be5aeab59 | ||
|
|
fbfd96ecdb | ||
|
|
dee20c859c | ||
|
|
ce0a88147b | ||
|
|
7f62f1e965 | ||
|
|
b51501fb21 | ||
|
|
72ab64461c | ||
|
|
26b393e059 | ||
|
|
bc328657aa | ||
|
|
c579219427 | ||
|
|
3413d70210 | ||
|
|
8bbc7e13fb | ||
|
|
f1ecb312c7 | ||
|
|
3407891e9c | ||
|
|
8f447a4a72 | ||
|
|
8ace11e462 | ||
|
|
949dfe7266 | ||
|
|
f0d490aef9 | ||
|
|
bdedae981a | ||
|
|
9e0750c9d3 | ||
|
|
9a3e512b1b | ||
|
|
861e741030 | ||
|
|
a3e7e21d45 | ||
|
|
86db2fcf61 | ||
|
|
fcd72e013a | ||
|
|
2450f8c64b | ||
|
|
676a9b1686 | ||
|
|
b10db63c74 | ||
|
|
4b25ef7516 | ||
|
|
de0d19cda6 | ||
|
|
c55386af0e | ||
|
|
33fe1c7a54 | ||
|
|
bf6d05e92a | ||
|
|
b6113d8d2b | ||
|
|
bc31154035 | ||
|
|
edfe0329bf | ||
|
|
1e11dd776a | ||
|
|
028526d22d | ||
|
|
7ac2d854f2 | ||
|
|
279c81e431 | ||
|
|
4e319b40ed | ||
|
|
d082b39980 | ||
|
|
277402f577 | ||
|
|
9e95c507b1 | ||
|
|
7440fc6f46 | ||
|
|
a24028f674 | ||
|
|
00913b013f | ||
|
|
447d08d613 | ||
|
|
d4f7736b2d | ||
|
|
60f72fffdf | ||
|
|
77af9c1cba | ||
|
|
1b2414337f | ||
|
|
d41f1f2a4d | ||
|
|
f9967ff990 | ||
|
|
db0ab41ea4 | ||
|
|
da95cc30d3 | ||
|
|
6b3001573e | ||
|
|
b85f6f8c3f | ||
|
|
d036ac9fba | ||
|
|
f63a114371 | ||
|
|
8cb59661ac | ||
|
|
fc1da609f2 | ||
|
|
c6566323fd | ||
|
|
30e1533ad9 | ||
|
|
71dfea1904 | ||
|
|
4fa7457423 | ||
|
|
9583bb35f5 | ||
|
|
e806c4db3a | ||
|
|
665ab22de5 | ||
|
|
ec4e946643 | ||
|
|
9e4bbe3e36 | ||
|
|
1172c1a852 | ||
|
|
8a4392bb22 | ||
|
|
a79a2d60d3 | ||
|
|
9553ff66a3 | ||
|
|
79c6f05291 | ||
|
|
3e691de24a | ||
|
|
303def49cb | ||
|
|
18653781d5 | ||
|
|
2a75bdbeda | ||
|
|
4a6926eb6c | ||
|
|
3dc4007fa7 | ||
|
|
9c3833d66c | ||
|
|
41966f33c2 | ||
|
|
50fea2a8f0 | ||
|
|
05cb7f7947 | ||
|
|
5b6b80e3cd | ||
|
|
2c59af8399 | ||
|
|
b404f9fa42 | ||
|
|
8dc8340ce4 | ||
|
|
30f08a145e | ||
|
|
d3d140fa60 | ||
|
|
5f8e687e68 | ||
|
|
fab640901d | ||
|
|
9a053fb6ff | ||
|
|
24e4b0b376 | ||
|
|
b8eee999e2 | ||
|
|
7fe9a114b7 | ||
|
|
05b2fb4fcb | ||
|
|
830d8762cd | ||
|
|
3f81666369 | ||
|
|
d40f4003b5 | ||
|
|
1585e425ce | ||
|
|
bbc7613079 | ||
|
|
ec54745174 | ||
|
|
a29453de12 | ||
|
|
db5bf4fc46 | ||
|
|
9495e3418c | ||
|
|
83573a743b | ||
|
|
f5dcd82747 | ||
|
|
070ec2f48f | ||
|
|
96c7fdc02c | ||
|
|
dfde2d8a62 | ||
|
|
a3f57114da | ||
|
|
904af10914 | ||
|
|
9b5013a694 | ||
|
|
922adfd3d4 | ||
|
|
362144033b | ||
|
|
caf9a579d3 | ||
|
|
cb40fdcdbe | ||
|
|
ef15e754c9 | ||
|
|
d55568c146 | ||
|
|
e134863db1 | ||
|
|
c37ae51dd3 | ||
|
|
4fc2ff43c1 | ||
|
|
607f13d935 | ||
|
|
44c1a3f695 | ||
|
|
d30decfbc8 | ||
|
|
705b2f794e | ||
|
|
4958690d9e | ||
|
|
d7749d3a24 | ||
|
|
73e07a594f | ||
|
|
755c2ef400 | ||
|
|
3f588e970a | ||
|
|
3264807e77 | ||
|
|
01225d4648 | ||
|
|
48aa809c98 | ||
|
|
4a722d4069 | ||
|
|
07aca2a0e7 | ||
|
|
10000d9b6c | ||
|
|
f0e247f31e | ||
|
|
593dec5e88 | ||
|
|
c45b86c993 | ||
|
|
02f01f2199 | ||
|
|
88b1adc2d6 | ||
|
|
a0a0e6775b | ||
|
|
4096253694 | ||
|
|
33ba44ebda | ||
|
|
9b4cf2a92b | ||
|
|
e6b915d8e3 | ||
|
|
bb73fb5f55 | ||
|
|
10c5945afb | ||
|
|
0bd613d556 | ||
|
|
aae2f65b9e | ||
|
|
d02197474e | ||
|
|
41b37e9c24 | ||
|
|
b03400fac2 | ||
|
|
3e808f7b6b | ||
|
|
1e3a8971fb | ||
|
|
d8c0105b97 | ||
|
|
b3689cbac8 | ||
|
|
1b5d6472f7 | ||
|
|
e9511c507a | ||
|
|
365f64ded5 | ||
|
|
3601fa63d8 | ||
|
|
5d00ddf516 | ||
|
|
0051453cad | ||
|
|
7920ea2dda | ||
|
|
9416e45a75 | ||
|
|
98a65c81af | ||
|
|
8e1f06e79b | ||
|
|
58a09f453d | ||
|
|
7dc69982b6 | ||
|
|
46e4041ed8 | ||
|
|
0e129130b1 | ||
|
|
33c9868f90 | ||
|
|
fb04b1830e | ||
|
|
9509194bd0 | ||
|
|
60322a243a | ||
|
|
4ed7067537 | ||
|
|
69086e8fba | ||
|
|
a4b63bb037 | ||
|
|
5ffb2f6619 | ||
|
|
41eaf9b9e4 | ||
|
|
28bb777399 | ||
|
|
f375a35cc8 | ||
|
|
1d41d84083 | ||
|
|
357be177fc | ||
|
|
23c3335de8 | ||
|
|
963b164783 | ||
|
|
0c22a02641 | ||
|
|
10cb5c2c76 | ||
|
|
6d36c9ef7b | ||
|
|
aed97a5e92 | ||
|
|
b6008fc9bb | ||
|
|
f9359679ad | ||
|
|
052d7be1a9 |
3
.github/FUNDING.yml
vendored
Normal file
3
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
ko_fi: kuba2k2
|
||||
custom:
|
||||
- "https://paypal.me/kuba2k2"
|
||||
25
.github/workflows/docs.yml
vendored
25
.github/workflows/docs.yml
vendored
@@ -13,10 +13,33 @@ jobs:
|
||||
- name: Checkout main
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.10'
|
||||
|
||||
- name: Install docs dependencies
|
||||
run: pip install -U ltchiptool boardgen
|
||||
|
||||
- name: Generate docs and static JSON files
|
||||
run: |
|
||||
mkdir -p site/
|
||||
boardgen ltci
|
||||
python docs/scripts/update_docs.py
|
||||
python docs/scripts/prepare_doxygen.py
|
||||
python docs/scripts/build_json.py
|
||||
cp *.json site/
|
||||
|
||||
- name: Set custom domain
|
||||
run: |
|
||||
mkdir -p site/
|
||||
echo docs.libretiny.eu > site/CNAME
|
||||
|
||||
- name: Deploy docs
|
||||
uses: mhausenblas/mkdocs-deploy-gh-pages@master
|
||||
uses: libretiny-eu/mkdocs-deploy-gh-pages@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
CONFIG_FILE: mkdocs.yml
|
||||
EXTRA_PACKAGES: build-base doxygen
|
||||
REQUIREMENTS: docs/requirements.txt
|
||||
CUSTOM_DOMAIN: docs.libretiny.eu
|
||||
|
||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -256,6 +256,11 @@ cython_debug/
|
||||
# mkdocs
|
||||
xml/
|
||||
ltapi/
|
||||
ltambz/
|
||||
hashChanges.yaml
|
||||
.piopm
|
||||
|
||||
# board files
|
||||
docs/status/supported_*.md
|
||||
docs/status/unsupported_boards_*.md
|
||||
boards/**/*.svg
|
||||
boards/**/*.md
|
||||
|
||||
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -1,2 +0,0 @@
|
||||
[submodule "tools/boardgen"]
|
||||
url = https://github.com/kuba2k2/boardgen
|
||||
36
README.md
36
README.md
@@ -1,42 +1,45 @@
|
||||
# LibreTuya
|
||||
# LibreTiny
|
||||
|
||||
<div align="center" markdown>
|
||||
|
||||
[](https://kuba2k2.github.io/libretuya/)
|
||||

|
||||
[](https://kuba2k2.github.io/libretiny/)
|
||||

|
||||
|
||||
[](.clang-format)
|
||||
[](https://github.com/psf/black)
|
||||
|
||||
[](https://discord.gg/SyGCB9Xwtf)
|
||||
[](https://registry.platformio.org/platforms/kuba2k2/libretuya)
|
||||
[](https://registry.platformio.org/platforms/kuba2k2/libretiny)
|
||||
|
||||

|
||||

|
||||
|
||||
</div>
|
||||
|
||||
## LibreTuya is now LibreTiny! 🎉
|
||||
|
||||
We have [renamed the project](https://github.com/kuba2k2/libretiny/issues/92) to LibreTiny, also marking the very first v1.0.0 release, along with a huge structure refactor. While some care has been taken to ensure that things don't break, you may still need to update some references in your code to use the new name.
|
||||
|
||||
---
|
||||
|
||||
PlatformIO development platform for IoT modules manufactured by Tuya Inc.
|
||||
|
||||
The main goal of this project is to provide a usable build environment for IoT developers. While also providing vendor SDKs as PlatformIO cores,
|
||||
the project focuses on developing working Arduino-compatible cores for supported families. The cores are inspired by Espressif's official core for ESP32,
|
||||
which should make it easier to port/run existing ESP apps on Tuya IoT (and 3-rd party) modules.
|
||||
which should make it easier to port/run existing ESP apps on less-common, unsupported IoT modules.
|
||||
|
||||
LibreTuya also provides a common interface for all family implementations. The interface is based on ESP32 official libraries.
|
||||
**There's an [ESPHome port](https://docs.libretiny.eu/docs/projects/esphome/) based on LibreTiny, which supports BK7231 and RTL8710B chips.**
|
||||
|
||||
**Note:** this project is work-in-progress.
|
||||
|
||||
## Usage
|
||||
|
||||
1. [Install PlatformIO](https://platformio.org/platformio-ide)
|
||||
2. `platformio platform install https://github.com/kuba2k2/libretuya`
|
||||
2. `platformio platform install -f https://github.com/kuba2k2/libretiny`
|
||||
3. Create a project, build it and upload!
|
||||
4. See the [docs](https://kuba2k2.github.io/libretuya/) for any questions/problems.
|
||||
|
||||
## Board List
|
||||
|
||||
See [Boards & CPU list](https://kuba2k2.github.io/libretuya/docs/supported/).
|
||||
4. See the [docs](https://docs.libretiny.eu/) for any questions/problems.
|
||||
|
||||
<!--
|
||||
## Arduino Core support status
|
||||
|
||||
Note: this list will probably change with each functionality update.
|
||||
@@ -44,7 +47,7 @@ Note: this list will probably change with each functionality update.
|
||||
| `realtek-ambz` | `beken-72xx`
|
||||
--------------------|----------------|-------------
|
||||
Core functions | ✔️ | ✔️
|
||||
GPIO/PWM/IRQ | ✔️/✔️/✔️ | ❓/✔️/❌
|
||||
GPIO/PWM/IRQ | ✔️/✔️/✔️ | ✔️/✔️/✔️
|
||||
Analog input (ADC) | ✔️ | ✔️
|
||||
Serial | ✔️ | ✔️
|
||||
Serial (extra) | 0, 1, 2 | 1, 2
|
||||
@@ -61,11 +64,11 @@ TCP Server | ✔️ | ✔️
|
||||
IPv6 | ❌ | ❌
|
||||
HTTP Client (SSL) | ✔️ (✔️) | ❓
|
||||
HTTP Server | ✔️ | ✔️
|
||||
NVS / Preferences | ❌ | ❌
|
||||
NVS / Preferences | ✔️ | ✔️
|
||||
SPIFFS | ❌ | ❌
|
||||
BLE | - | ❌
|
||||
NTP | ❌ | ❌
|
||||
OTA | ✔️ | ❌
|
||||
NTP | ✔️ | ✔️
|
||||
OTA | ✔️ | ✔️
|
||||
MDNS | ✔️ | ✔️
|
||||
MQTT | ✅ | ❌
|
||||
SD | ❌ | ❌
|
||||
@@ -84,6 +87,7 @@ Names:
|
||||
- Core functions - stuff like delay(), millis(), yield(), etc.
|
||||
- **CORE LIBRARIES** - included normally in all Arduino cores
|
||||
- **OTHER LIBRARIES** - included in ESP32 core or downloadable
|
||||
-->
|
||||
|
||||
## License
|
||||
|
||||
|
||||
87
SUMMARY.md
87
SUMMARY.md
@@ -1,55 +1,56 @@
|
||||
* [Home](README.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
|
||||
* [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)
|
||||
* [Wiring custom methods](ltapi/_libre_tuya_custom_8h.md)
|
||||
* [Logger](ltapi/lt__logger_8h.md)
|
||||
* [Chip & family IDs](ltapi/_chip_type_8h_source.md)
|
||||
* [POSIX utilities](ltapi/lt__posix__api_8h.md)
|
||||
* Common API
|
||||
* [FS](ltapi/classfs_1_1_f_s.md)
|
||||
* [Preferences](ltapi/class_i_preferences.md)
|
||||
* [](SUMMARY.md)
|
||||
* [😊 Getting started](docs/getting-started/README.md)
|
||||
* [➡️ Info on accessing GPIOs](docs/getting-started/gpio.md)
|
||||
* [💡 ESPHome setup guide](docs/projects/esphome.md)
|
||||
* [📲 Flashing/dumping guide](docs/flashing/)
|
||||
* [🔌 How to connect the chip in download mode?](docs/flashing/chip-connection/)
|
||||
* [💻 Supported chips](docs/status/supported.md)
|
||||
* [All boards](boards/)
|
||||
* [](SUMMARY.md)
|
||||
* 🍪 Chip family docs & info
|
||||
* [Beken BK72xx](docs/platform/beken-72xx/README.md)
|
||||
* [Realtek Ameba - info](docs/platform/realtek-amb/README.md)
|
||||
* [Realtek AmebaZ](docs/platform/realtek-ambz/README.md)
|
||||
* [Debugging](docs/platform/realtek-ambz/debugging.md)
|
||||
* [Exception decoder](docs/platform/realtek-ambz/exception-decoder.md)
|
||||
* [🔧 LT Configuration](docs/dev/config.md)
|
||||
* 🧑 Programmer's manual
|
||||
* [⚠️ Migration guide](docs/dev/migration_v1.0.0.md)
|
||||
* [🔋 PlatformIO Examples](examples/)
|
||||
* [📖 LibreTiny API](docs/dev/lt-api.md)
|
||||
* [C API](ltapi/dir_c7e317b16142bccc961a83c0babf0065.md)
|
||||
* [C++ API](ltapi/dir_930634efd5dc4a957bbb6e685a3ccda1.md)
|
||||
* 📚 Arduino Libraries
|
||||
* [SoftwareSerial](ltapi/class_software_serial.md)
|
||||
* [WiFi API](ltapi/class_wi_fi_class.md)
|
||||
* [TCP Client](ltapi/class_i_wi_fi_client.md)
|
||||
* [SSL Client](ltapi/class_i_wi_fi_client_secure.md)
|
||||
* [TCP Server](ltapi/class_i_wi_fi_server.md)
|
||||
* [LibreTuya libraries](docs/libs-built-in.md)
|
||||
* [base64](ltapi/classbase64.md)
|
||||
* [WiFi](ltapi/class_wi_fi_class.md)
|
||||
* [](SUMMARY.md)
|
||||
* [Flash](ltapi/class_flash_class.md)
|
||||
* [HTTPClient](ltapi/class_h_t_t_p_client.md)
|
||||
* [IPv6Address](ltapi/classarduino_1_1_i_pv6_address.md)
|
||||
* [MD5](ltapi/libraries_2common_2_m_d5_2_m_d5_8h.md)
|
||||
* [mDNS](ltapi/classm_d_n_s.md)
|
||||
* NetUtils
|
||||
* [ssl/MbedTLSClient](ltapi/class_mbed_t_l_s_client.md)
|
||||
* [IPv6Address](ltapi/classarduino_1_1_i_pv6_address.md)
|
||||
* [LwIPRxBuffer](ltapi/class_lw_i_p_rx_buffer.md)
|
||||
* [Update](ltapi/class_update_class.md)
|
||||
* [WiFiClient](ltapi/class_i_wi_fi_client.md)
|
||||
* [WiFiClientSecure](ltapi/class_i_wi_fi_client_secure.md)
|
||||
* [WiFiServer](ltapi/class_i_wi_fi_server.md)
|
||||
* [WiFiUDP](ltapi/class_i_wi_fi_u_d_p.md)
|
||||
* [](SUMMARY.md)
|
||||
* [HTTPClient](ltapi/class_h_t_t_p_client.md)
|
||||
* [StreamString](ltapi/class_stream_string.md)
|
||||
* [WebServer](ltapi/class_web_server.md)
|
||||
* [WiFiMulti](ltapi/class_wi_fi_multi.md)
|
||||
* [Third party libraries](docs/libs-3rd-party.md)
|
||||
* [](SUMMARY.md)
|
||||
* [External compatible libraries](docs/dev/libs-3rd-party.md)
|
||||
* Full documentation
|
||||
* [Classes](ltapi/classes.md)
|
||||
* [Functions](ltapi/functions.md)
|
||||
* [Macros](ltapi/macros.md)
|
||||
* [File list](ltapi/files.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
|
||||
* [Realtek - notes](docs/platform/realtek/README.md)
|
||||
* [Beken 72xx - notes](docs/platform/beken-72xx/README.md)
|
||||
* Realtek AmebaZ Series
|
||||
* C library
|
||||
* [Built-in functions](docs/platform/realtek-ambz/stdlib.md)
|
||||
* [Memory management](docs/platform/realtek-ambz/memory-management.md)
|
||||
* [Debugging](docs/platform/realtek/debugging.md)
|
||||
* [Exception decoder](docs/platform/realtek/exception-decoder.md)
|
||||
* [All supported boards](boards/)
|
||||
* [📓 TODO](TODO.md)
|
||||
* [🔗 Resources](docs/resources.md)
|
||||
* 👷 Contributor's manual (WIP)
|
||||
* [📁 Project structure](docs/dev/project-structure.md)
|
||||
* [✈️ OTA format](docs/dev/ota/README.md)
|
||||
* [uf2ota.py tool](docs/dev/ota/uf2ota.md)
|
||||
* [uf2ota.h library](docs/dev/ota/library.md)
|
||||
* [📓 TODO](docs/TODO.md)
|
||||
* [](SUMMARY.md)
|
||||
* [🔗 Resources](docs/resources/)
|
||||
|
||||
46
TODO.md
46
TODO.md
@@ -1,46 +0,0 @@
|
||||
# TODO list
|
||||
|
||||
## General
|
||||
|
||||
### New families
|
||||
|
||||
- BL602
|
||||
- RTL8710A
|
||||
- RTL8720C
|
||||
- RTL8720D
|
||||
- W600 and/or W800
|
||||
- LN8825
|
||||
- host-native family
|
||||
|
||||
### Tools
|
||||
|
||||
- move all UF2 assembling/uploading/processing tools (as well as `uf2ota` C library) to a separate repository, possibly rewriting parts of it again. Make these tools CLI-usable
|
||||
- write OpenOCD flashers, using uf2ota library + FAL for partitions (same repo as above)
|
||||
|
||||
### Serial
|
||||
|
||||
- configuration of RX/TX pins
|
||||
- SoftwareSerial library - receiving + Beken family
|
||||
|
||||
### Other
|
||||
|
||||
- watchdog API
|
||||
- `Preferences` library
|
||||
- test/fix IPv6 on different families
|
||||
- what is `PowerManagement` at all? probably useless -> remove
|
||||
|
||||
## BK7231
|
||||
|
||||
- WiFi events
|
||||
- implement OTA
|
||||
- fix WiFi on BK7231N, test other functionality
|
||||
- add generic board definition
|
||||
- fix SSL (mbedTLS)
|
||||
- I2C (Wire)
|
||||
- SPI
|
||||
- BLE
|
||||
|
||||
## RTL8710B
|
||||
|
||||
- add generic board definition
|
||||
- rewrite most of Wiring (it was copied from `ambd_arduino`, and is ugly)
|
||||
@@ -1,30 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-14. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "WCharacterFixup.h"
|
||||
#endif
|
||||
|
||||
#include <api/ArduinoAPI.h>
|
||||
#include <core/LibreTuyaAPI.h>
|
||||
|
||||
// Include family-specific code
|
||||
#include "WVariant.h"
|
||||
// Include board variant
|
||||
#include "variant.h"
|
||||
|
||||
// Choose the main UART output port
|
||||
#ifndef LT_UART_DEFAULT_PORT
|
||||
#if defined(PIN_SERIAL2_TX)
|
||||
#define LT_UART_DEFAULT_PORT 2
|
||||
#else
|
||||
#define LT_UART_DEFAULT_PORT 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Define available serial ports
|
||||
#ifdef __cplusplus
|
||||
#include "SerialClass.h"
|
||||
#include <core/SerialExtern.h>
|
||||
#endif
|
||||
@@ -1,134 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-19. */
|
||||
|
||||
#include <LibreTuyaAPI.h>
|
||||
|
||||
// can't include <flash.h> as it collides with <Flash.h> on Windows -_-
|
||||
#define REG_FLASH_BASE 0x00803000
|
||||
#define REG_FLASH_OPERATE_SW (REG_FLASH_BASE + 0 * 4)
|
||||
#define REG_FLASH_RDID (REG_FLASH_BASE + 4 * 4)
|
||||
#define FLASH_BUSY_SW (0x01UL << 31)
|
||||
#define FLASH_WP_VALUE (0x01UL << 30)
|
||||
#define FLASH_OP_SW (0x01UL << 29)
|
||||
#define FLASH_OP_TYPE_POS 24
|
||||
#define FLASH_OP_RDID 20
|
||||
|
||||
extern "C" {
|
||||
|
||||
#include <flash_pub.h>
|
||||
#include <param_config.h>
|
||||
#include <sys_ctrl.h>
|
||||
#include <sys_rtos.h>
|
||||
#include <wlan_ui_pub.h>
|
||||
|
||||
extern uint8_t system_mac[];
|
||||
|
||||
} // extern "C"
|
||||
|
||||
void LibreTuya::restart() {
|
||||
bk_reboot();
|
||||
}
|
||||
|
||||
/* CPU-related */
|
||||
|
||||
ChipType LibreTuya::getChipType() {
|
||||
uint8_t chipId = *(uint8_t *)(SCTRL_CHIP_ID);
|
||||
return CHIP_TYPE_ENUM(FAMILY, chipId);
|
||||
}
|
||||
|
||||
const char *LibreTuya::getChipModel() {
|
||||
return STRINGIFY_MACRO(MCU);
|
||||
}
|
||||
|
||||
uint32_t LibreTuya::getChipId() {
|
||||
uint8_t mac[6];
|
||||
cfg_load_mac(mac); // force loading MAC from TLV (ignore user-set WiFi MAC)
|
||||
return (mac[3]) | (mac[4] << 8) | (mac[5] << 16);
|
||||
}
|
||||
|
||||
uint8_t LibreTuya::getChipCores() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *LibreTuya::getChipCoreType() {
|
||||
return "ARM968E-S";
|
||||
}
|
||||
|
||||
uint32_t LibreTuya::getCpuFreq() {
|
||||
return configCPU_CLOCK_HZ;
|
||||
}
|
||||
|
||||
uint32_t LibreTuya::getCycleCount() {
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Flash memory utilities */
|
||||
|
||||
FlashId LibreTuya::getFlashChipId() {
|
||||
uint32_t data = (FLASH_OP_RDID << FLASH_OP_TYPE_POS) | FLASH_OP_SW | FLASH_WP_VALUE;
|
||||
REG_WRITE(REG_FLASH_OPERATE_SW, data);
|
||||
while (REG_READ(REG_FLASH_OPERATE_SW) & FLASH_BUSY_SW) {}
|
||||
FlashId id = {
|
||||
.manufacturerId = REG_RD8(REG_FLASH_RDID, 2),
|
||||
.chipId = REG_RD8(REG_FLASH_RDID, 1),
|
||||
.chipSizeId = REG_RD8(REG_FLASH_RDID, 0),
|
||||
};
|
||||
return id;
|
||||
}
|
||||
|
||||
/* Memory management */
|
||||
|
||||
uint32_t LibreTuya::getRamSize() {
|
||||
return 256 * 1024;
|
||||
}
|
||||
|
||||
uint32_t LibreTuya::getHeapSize() {
|
||||
#if configDYNAMIC_HEAP_SIZE
|
||||
extern unsigned char _empty_ram;
|
||||
#if CFG_SOC_NAME == SOC_BK7231N
|
||||
return (0x00400000 + 192 * 1024) - (uint32_t)(&_empty_ram);
|
||||
#else
|
||||
return (0x00400000 + 256 * 1024) - (uint32_t)(&_empty_ram);
|
||||
#endif
|
||||
#else
|
||||
return configTOTAL_HEAP_SIZE;
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t LibreTuya::getFreeHeap() {
|
||||
return xPortGetFreeHeapSize();
|
||||
}
|
||||
|
||||
uint32_t LibreTuya::getMinFreeHeap() {
|
||||
return xPortGetMinimumEverFreeHeapSize();
|
||||
}
|
||||
|
||||
uint32_t LibreTuya::getMaxAllocHeap() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* OTA-related */
|
||||
|
||||
uint8_t LibreTuya::otaGetStoredIndex() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool LibreTuya::otaSupportsDual() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LibreTuya::otaHasImage1() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LibreTuya::otaHasImage2() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LibreTuya::otaSwitch(bool force) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Global instance */
|
||||
|
||||
LibreTuya LT;
|
||||
@@ -1,21 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-18. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "sdk_extern.h"
|
||||
#include "sdk_mem.h"
|
||||
|
||||
// allow BDK use its own delay() and let Arduino code use delayMilliseconds()
|
||||
void delayMilliseconds(unsigned long);
|
||||
#define delay delayMilliseconds
|
||||
|
||||
// from fixups/arch_main.c
|
||||
extern unsigned char __bk_rf_is_init;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
@@ -1,30 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-18. */
|
||||
|
||||
#pragma once
|
||||
|
||||
// for printf() etc (they are wrapped anyway)
|
||||
#include <stdio.h>
|
||||
|
||||
// most stuff is here
|
||||
#include <include.h>
|
||||
// for os_printf
|
||||
#include <uart_pub.h>
|
||||
// for GPIO names
|
||||
#include <gpio_pub.h>
|
||||
|
||||
// conflict with stl_algobase.h
|
||||
#undef min
|
||||
#undef max
|
||||
|
||||
// include printf() wrapper disable methods
|
||||
#include <printf_port.h>
|
||||
|
||||
// make non-SDK code call the proper printf()
|
||||
#undef bk_printf
|
||||
#undef os_printf
|
||||
#undef warning_prf
|
||||
#undef fatal_prf
|
||||
#define bk_printf printf
|
||||
#define os_printf printf
|
||||
#define warning_prf printf
|
||||
#define fatal_prf printf
|
||||
@@ -1,20 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-18. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
// Beken SDK is actually pretty good, in terms of declaring
|
||||
// stdlib functions properly! So no need for any #define hell.
|
||||
#include <mem_pub.h>
|
||||
|
||||
// All the MemMang functions are in stdlib, just wrapped
|
||||
// during linking.
|
||||
#include <stdlib.h>
|
||||
// for memcpy etc.
|
||||
#include <string.h>
|
||||
|
||||
// ...except zalloc, which is apparently not in the stdlib
|
||||
#define zalloc os_zalloc
|
||||
|
||||
#define LT_HEAP_FUNC xPortGetFreeHeapSize
|
||||
@@ -1,32 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-19. */
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <rtos_pub.h>
|
||||
#include <sys_rtos.h>
|
||||
|
||||
void delayMilliseconds(unsigned long ms) {
|
||||
rtos_delay_milliseconds(ms);
|
||||
}
|
||||
|
||||
void delayMicroseconds(unsigned int us) {
|
||||
// TODO implement this properly
|
||||
us /= 10;
|
||||
volatile uint32_t i, j;
|
||||
for (i = 0; i < us; i++) {
|
||||
for (j = 0; j < 100; j++) {}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long millis() {
|
||||
return xTaskGetTickCount() * portTICK_PERIOD_MS;
|
||||
}
|
||||
|
||||
unsigned long micros() {
|
||||
// TODO implement this properly
|
||||
return millis() * 1000;
|
||||
}
|
||||
|
||||
void yield() {
|
||||
vTaskDelay(1);
|
||||
taskYIELD();
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-26. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <api/WiFi/WiFi.h>
|
||||
|
||||
#include "WiFiClient.h"
|
||||
#include "WiFiClientSecure.h"
|
||||
#include "WiFiServer.h"
|
||||
@@ -1,8 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-27. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <api/WiFi/WiFi.h>
|
||||
#include <lwip/LwIPClient.h>
|
||||
|
||||
typedef LwIPClient WiFiClient;
|
||||
@@ -1,8 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-05-04. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <api/WiFi/WiFi.h>
|
||||
#include <ssl/MbedTLSClient.h>
|
||||
|
||||
typedef MbedTLSClient WiFiClientSecure;
|
||||
@@ -1,21 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-26. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
#include <FreeRTOS.h>
|
||||
#include <semphr.h>
|
||||
|
||||
} // extern "C"
|
||||
|
||||
typedef struct {
|
||||
void *configSta;
|
||||
void *configAp;
|
||||
unsigned long scannedAt;
|
||||
SemaphoreHandle_t scanSem;
|
||||
void *statusIp;
|
||||
void *statusLink;
|
||||
} WiFiData;
|
||||
@@ -1,93 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-26. */
|
||||
|
||||
#include "WiFiPriv.h"
|
||||
|
||||
bool WiFiClass::modePriv(WiFiMode mode, WiFiModeAction sta, WiFiModeAction ap) {
|
||||
__wrap_bk_printf_disable();
|
||||
startWifiTask();
|
||||
|
||||
if (mode && !data.statusIp) {
|
||||
data.configSta = zalloc(sizeof(network_InitTypeDef_st));
|
||||
data.configAp = zalloc(sizeof(network_InitTypeDef_ap_st));
|
||||
data.statusIp = malloc(sizeof(IPStatusTypedef));
|
||||
data.statusLink = malloc(sizeof(LinkStatusTypeDef));
|
||||
STA_CFG->dhcp_mode = DHCP_CLIENT;
|
||||
}
|
||||
|
||||
if (!__bk_rf_is_init) {
|
||||
LT_D_WG("Initializing func&app");
|
||||
func_init_extended();
|
||||
app_pre_start();
|
||||
// wait for the init_thread to finish its job
|
||||
while (xTaskGetHandle("init_thread")) {
|
||||
LT_V_WG("Waiting for init_thread");
|
||||
delay(10);
|
||||
}
|
||||
LT_D_WG("Success");
|
||||
__bk_rf_is_init = true;
|
||||
}
|
||||
|
||||
LT_HEAP_I();
|
||||
|
||||
if (sta == WLMODE_ENABLE) {
|
||||
LT_D_WG("Enabling STA");
|
||||
bk_wlan_sta_init(NULL);
|
||||
wifiEventSendArduino(ARDUINO_EVENT_WIFI_STA_START);
|
||||
} else if (sta == WLMODE_DISABLE) {
|
||||
LT_D_WG("Disabling STA");
|
||||
bk_wlan_stop(BK_STATION);
|
||||
wifiEventSendArduino(ARDUINO_EVENT_WIFI_STA_STOP);
|
||||
}
|
||||
|
||||
LT_HEAP_I();
|
||||
|
||||
if (ap == WLMODE_ENABLE) {
|
||||
LT_D_WG("Enabling AP");
|
||||
bk_wlan_ap_init(NULL);
|
||||
wifiEventSendArduino(ARDUINO_EVENT_WIFI_AP_START);
|
||||
} else if (ap == WLMODE_DISABLE) {
|
||||
LT_D_WG("Disabling AP");
|
||||
bk_wlan_stop(BK_SOFT_AP);
|
||||
wifiEventSendArduino(ARDUINO_EVENT_WIFI_AP_STOP);
|
||||
}
|
||||
|
||||
if (!mode) {
|
||||
free(data.configSta);
|
||||
free(data.configAp);
|
||||
free(data.statusIp);
|
||||
free(data.statusLink);
|
||||
data.configSta = NULL;
|
||||
data.configAp = NULL;
|
||||
data.statusIp = NULL;
|
||||
data.statusLink = NULL;
|
||||
}
|
||||
|
||||
LT_HEAP_I();
|
||||
|
||||
__wrap_bk_printf_enable();
|
||||
return true;
|
||||
}
|
||||
|
||||
WiFiMode WiFiClass::getMode() {
|
||||
if (!g_wlan_general_param)
|
||||
return WIFI_MODE_NULL;
|
||||
uint8_t role = g_wlan_general_param->role;
|
||||
// change 1->2, 2->1
|
||||
return (WiFiMode)(role + (role == 1) - (role == 2));
|
||||
}
|
||||
|
||||
WiFiStatus WiFiClass::status() {
|
||||
rw_evt_type status = mhdr_get_station_status();
|
||||
if (status == RW_EVT_STA_CONNECTED && STA_CFG->dhcp_mode == DHCP_DISABLE)
|
||||
status = RW_EVT_STA_GOT_IP;
|
||||
return eventTypeToStatus(status);
|
||||
}
|
||||
|
||||
IPAddress WiFiClass::hostByName(const char *hostname) {
|
||||
ip_addr_t ip;
|
||||
int ret = netconn_gethostbyname(hostname, &ip);
|
||||
if (ret == ERR_OK) {
|
||||
return ip.addr;
|
||||
}
|
||||
return IPAddress();
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-26. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <api/WiFi/WiFi.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
#include <lwip/api.h>
|
||||
#include <lwip/ip_addr.h>
|
||||
#include <lwip/netif.h>
|
||||
// port/net.h
|
||||
#include <net.h>
|
||||
|
||||
#include <FreeRTOS.h>
|
||||
#include <semphr.h>
|
||||
|
||||
#include <common.h>
|
||||
#include <config.h>
|
||||
#include <main_none.h>
|
||||
#include <param_config.h>
|
||||
#include <rw_msg_rx.h>
|
||||
#include <wlan_ui_pub.h>
|
||||
#include <wpa_supplicant_i.h>
|
||||
|
||||
extern void func_init_extended();
|
||||
extern void app_pre_start();
|
||||
extern void bk_wlan_ap_init(network_InitTypeDef_st *inNetworkInitPara);
|
||||
|
||||
// func/hostapd-2.5/wpa_supplicant/main_supplicant.c
|
||||
extern struct wpa_ssid_value *wpas_connect_ssid;
|
||||
|
||||
// app/param_config.c
|
||||
extern general_param_t *g_wlan_general_param;
|
||||
extern ap_param_t *g_ap_param_ptr;
|
||||
extern sta_param_t *g_sta_param_ptr;
|
||||
extern uint8_t system_mac[6];
|
||||
|
||||
// WiFi.cpp
|
||||
WiFiStatus eventTypeToStatus(uint8_t type);
|
||||
WiFiAuthMode securityTypeToAuthMode(uint8_t type);
|
||||
|
||||
// WiFiEvents.cpp
|
||||
extern void wifiEventSendArduino(EventId event);
|
||||
extern void startWifiTask();
|
||||
extern void wifiEventHandler(rw_evt_type event);
|
||||
|
||||
#define RW_EVT_ARDUINO (1 << 7)
|
||||
|
||||
#define IP_FMT "%u.%u.%u.%u"
|
||||
|
||||
#define STA_CFG ((network_InitTypeDef_st *)data.configSta)
|
||||
#define AP_CFG ((network_InitTypeDef_ap_st *)data.configAp)
|
||||
#define IP_STATUS ((IPStatusTypedef *)data.statusIp)
|
||||
#define LINK_STATUS ((LinkStatusTypeDef *)data.statusLink)
|
||||
|
||||
} // extern "C"
|
||||
@@ -1,8 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-27. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <api/WiFi/WiFi.h>
|
||||
#include <lwip/LwIPServer.h>
|
||||
|
||||
typedef LwIPServer WiFiServer;
|
||||
@@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <api/Udp.h>
|
||||
|
||||
class IWiFiUDP : public UDP {
|
||||
public:
|
||||
uint8_t beginMulticast(IPAddress ip, uint16_t port);
|
||||
int beginMulticastPacket();
|
||||
int beginPacket();
|
||||
};
|
||||
@@ -1,53 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-19. */
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <api/HardwareSerial.h>
|
||||
|
||||
using namespace arduino;
|
||||
|
||||
extern "C" {
|
||||
#include <fal.h>
|
||||
fal_partition_t fal_root_part = NULL;
|
||||
}
|
||||
|
||||
// Arduino framework initialization.
|
||||
// May be redefined by family files.
|
||||
void initArduino() __attribute__((weak));
|
||||
|
||||
// Weak empty variant initialization function.
|
||||
// May be redefined by variant files.
|
||||
void initVariant() __attribute__((weak));
|
||||
|
||||
// Initialize C library
|
||||
extern "C" void __libc_init_array(void);
|
||||
|
||||
void main_task(const void *arg) {
|
||||
setup();
|
||||
|
||||
for (;;) {
|
||||
loop();
|
||||
if (serialEventRun)
|
||||
serialEventRun();
|
||||
yield();
|
||||
}
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
// print a startup banner
|
||||
LT_BANNER();
|
||||
// initialize Arduino framework
|
||||
initArduino();
|
||||
// initialize C library
|
||||
__libc_init_array();
|
||||
// optionally initialize per-variant code
|
||||
initVariant();
|
||||
// initialize FAL
|
||||
fal_init();
|
||||
// provide root partition
|
||||
fal_root_part = (fal_partition_t)fal_partition_find("root");
|
||||
// start the main task and OS kernel
|
||||
startMainTask();
|
||||
|
||||
while (1) {}
|
||||
return 0;
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-05-28. */
|
||||
|
||||
#define CHIP_TYPE(family, chip_id) (((family >> 24) << 8) | chip_id)
|
||||
#define CHIP_TYPE_ENUM(family, chip_id) (ChipType) CHIP_TYPE(family, chip_id)
|
||||
|
||||
enum ChipFamily {
|
||||
// used in UF2 Family ID
|
||||
F_RTL8710A = 0x9FFFD543, // Realtek Ameba1
|
||||
F_RTL8710B = 0x22E0D6FC, // Realtek AmebaZ (realtek-ambz)
|
||||
F_RTL8720C = 0xE08F7564, // Realtek AmebaZ2
|
||||
F_RTL8720D = 0x3379CFE2, // Realtek AmebaD
|
||||
F_BK7231T = 0x675A40B0, // Beken 7231T
|
||||
F_BK7231N = 0x7B3EF230, // Beken 7231N
|
||||
F_BL602 = 0xDE1270B7, // Boufallo 602
|
||||
F_XR809 = 0x51E903A8, // Xradiotech 809
|
||||
F_NATIVE = 0xDEADBEEF, // Host-native
|
||||
};
|
||||
|
||||
enum ChipType {
|
||||
// Realtek AmebaZ
|
||||
// IDs copied from rtl8710b_efuse.h
|
||||
RTL8710BL = CHIP_TYPE(F_RTL8710B, 0xE0), // ???
|
||||
RTL8710BN = CHIP_TYPE(F_RTL8710B, 0xFF), // CHIPID_8710BN / QFN32
|
||||
RTL8710BU = CHIP_TYPE(F_RTL8710B, 0xFE), // CHIPID_8710BU / QFN48
|
||||
RTL8710BX = CHIP_TYPE(F_RTL8710B, 0xF6), // found on an actual RTL8710BX
|
||||
RTL8710L0 = CHIP_TYPE(F_RTL8710B, 0xFB), // CHIPID_8710BN_L0 / QFN32
|
||||
RTL8711BN = CHIP_TYPE(F_RTL8710B, 0xFD), // CHIPID_8711BN / QFN48
|
||||
RTL8711BU = CHIP_TYPE(F_RTL8710B, 0xFC), // CHIPID_8711BG / QFN68
|
||||
// Beken 72XX
|
||||
BK7231T = CHIP_TYPE(F_BK7231T, 0x1A), // *SCTRL_CHIP_ID = 0x7231a
|
||||
BK7231N = CHIP_TYPE(F_BK7231N, 0x1C), // *SCTRL_CHIP_ID = 0x7231c
|
||||
};
|
||||
@@ -1,63 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-04-29. */
|
||||
|
||||
#include "LibreTuyaAPI.h"
|
||||
|
||||
String ipToString(const IPAddress &ip) {
|
||||
char szRet[16];
|
||||
sprintf(szRet, "%hhu.%hhu.%hhu.%hhu", ip[0], ip[1], ip[2], ip[3]);
|
||||
return String(szRet);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Generate random bytes using rand().
|
||||
*
|
||||
* @param buf destination pointer
|
||||
* @param len how many bytes to generate
|
||||
*/
|
||||
void lt_rand_bytes(uint8_t *buf, size_t len) {
|
||||
int *data = (int *)buf;
|
||||
size_t i;
|
||||
for (i = 0; len >= sizeof(int); len -= sizeof(int)) {
|
||||
data[i++] = rand();
|
||||
}
|
||||
if (len) {
|
||||
int rem = rand();
|
||||
unsigned char *pRem = (unsigned char *)&rem;
|
||||
memcpy(buf + i * sizeof(int), pRem, len);
|
||||
}
|
||||
}
|
||||
|
||||
#undef putchar
|
||||
|
||||
/**
|
||||
* @brief Print data pointed to by buf in hexdump-like format (hex+ASCII).
|
||||
*
|
||||
* @param buf source pointer
|
||||
* @param len how many bytes to print
|
||||
* @param offset increment printed offset by this value
|
||||
* @param width how many bytes on a line
|
||||
*/
|
||||
void hexdump(uint8_t *buf, size_t len, uint32_t offset, uint8_t width) {
|
||||
uint16_t pos = 0;
|
||||
while (pos < len) {
|
||||
// print hex offset
|
||||
printf("%06x ", offset + pos);
|
||||
// calculate current line width
|
||||
uint8_t lineWidth = min(width, len - pos);
|
||||
// print hexadecimal representation
|
||||
for (uint8_t i = 0; i < lineWidth; i++) {
|
||||
if (i % 8 == 0) {
|
||||
printf(" ");
|
||||
}
|
||||
printf("%02x ", buf[pos + i]);
|
||||
}
|
||||
// print ascii representation
|
||||
printf(" |");
|
||||
for (uint8_t i = 0; i < lineWidth; i++) {
|
||||
char c = buf[pos + i];
|
||||
putchar((c >= 0x20 && c <= 0x7f) ? c : '.');
|
||||
}
|
||||
puts("|\r");
|
||||
pos += lineWidth;
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-04-28. */
|
||||
|
||||
#pragma once
|
||||
|
||||
// C standard libraries
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// LibreTuya version macros
|
||||
#ifndef LT_VERSION
|
||||
#define LT_VERSION 1.0.0
|
||||
#endif
|
||||
#ifndef LT_BOARD
|
||||
#define LT_BOARD unknown
|
||||
#endif
|
||||
#define STRINGIFY(x) #x
|
||||
#define STRINGIFY_MACRO(x) STRINGIFY(x)
|
||||
#define LT_VERSION_STR STRINGIFY_MACRO(LT_VERSION)
|
||||
#define LT_BOARD_STR STRINGIFY_MACRO(LT_BOARD)
|
||||
|
||||
// Includes
|
||||
#include "LibreTuyaClass.h" // global LT class
|
||||
#include "LibreTuyaCompat.h" // compatibility methods
|
||||
#include "LibreTuyaConfig.h" // configuration macros
|
||||
#include "LibreTuyaCustom.h" // family-defined methods (Wiring custom)
|
||||
#include <Arduino.h>
|
||||
|
||||
// C includes
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
#include "lt_logger.h"
|
||||
#include "lt_posix_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
// Functional macros
|
||||
#define LT_BANNER() \
|
||||
LT_LOG( \
|
||||
LT_LEVEL_INFO, \
|
||||
__FUNCTION__, \
|
||||
__LINE__, \
|
||||
"LibreTuya v" LT_VERSION_STR " on " LT_BOARD_STR ", compiled at " __DATE__ " " __TIME__ \
|
||||
)
|
||||
|
||||
void lt_rand_bytes(uint8_t *buf, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
String ipToString(const IPAddress &ip);
|
||||
void hexdump(uint8_t *buf, size_t len, uint32_t offset = 0, uint8_t width = 16);
|
||||
#else
|
||||
void hexdump(uint8_t *buf, size_t len, uint32_t offset, uint8_t width);
|
||||
#endif
|
||||
@@ -1,132 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-06. */
|
||||
|
||||
#include "LibreTuyaClass.h"
|
||||
|
||||
/**
|
||||
* @brief Get LibreTuya version string.
|
||||
*/
|
||||
const char *LibreTuya::getVersion() {
|
||||
return LT_VERSION_STR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get board name.
|
||||
*/
|
||||
const char *LibreTuya::getBoard() {
|
||||
return LT_BOARD_STR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get CPU family ID.
|
||||
*/
|
||||
ChipFamily LibreTuya::getChipFamily() {
|
||||
return FAMILY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get CPU family name as string.
|
||||
*/
|
||||
const char *LibreTuya::getChipFamilyName() {
|
||||
return STRINGIFY_MACRO(FAMILY) + 2;
|
||||
}
|
||||
|
||||
static char *deviceName = NULL;
|
||||
|
||||
/**
|
||||
* @brief Get device friendly name in format "LT-<board>-<chip id>".
|
||||
* Can be used as hostname.
|
||||
*/
|
||||
const char *LibreTuya::getDeviceName() {
|
||||
if (deviceName)
|
||||
return deviceName;
|
||||
uint32_t chipId = getChipId();
|
||||
uint8_t *id = (uint8_t *)&chipId;
|
||||
|
||||
const char *board = getBoard();
|
||||
uint8_t boardLen = strlen(board);
|
||||
deviceName = (char *)malloc(3 + boardLen + 1 + 6 + 1);
|
||||
|
||||
sprintf(deviceName, "LT-%s-%02x%02x%02x", board, id[0], id[1], id[2]);
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get CPU frequency in MHz.
|
||||
*/
|
||||
uint32_t LibreTuya::getCpuFreqMHz() {
|
||||
return getCpuFreq() / 1000000;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get flash chip total size.
|
||||
* The default implementation uses the least significant
|
||||
* byte of the chip ID to determine the size.
|
||||
*/
|
||||
__attribute__((weak)) uint32_t LibreTuya::getFlashChipSize() {
|
||||
FlashId id = getFlashChipId();
|
||||
if (id.chipSizeId >= 0x14 && id.chipSizeId <= 0x19) {
|
||||
return (1 << id.chipSizeId);
|
||||
}
|
||||
#ifdef FLASH_LENGTH
|
||||
return FLASH_LENGTH;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static uint8_t otaRunningIndex = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the currently running firmware OTA index.
|
||||
*/
|
||||
uint8_t LibreTuya::otaGetRunning() {
|
||||
if (otaRunningIndex)
|
||||
return otaRunningIndex;
|
||||
// otaRunningIndex will be correct even after switchOta()
|
||||
return otaRunningIndex = otaGetStoredIndex();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the OTA index for updated firmware.
|
||||
*
|
||||
* Note: returns 1 for chips without dual-OTA.
|
||||
*/
|
||||
uint8_t LibreTuya::otaGetTarget() {
|
||||
if (!otaSupportsDual())
|
||||
return 1;
|
||||
return otaGetRunning() ^ 0b11;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Perform OTA rollback.
|
||||
*
|
||||
* @return false if no second image to run, writing failed or dual-OTA not supported
|
||||
*/
|
||||
bool LibreTuya::otaRollback() {
|
||||
if (!otaCanRollback())
|
||||
return false;
|
||||
if (otaGetRunning() != otaGetStoredIndex())
|
||||
// force switching back to current image
|
||||
return otaSwitch(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if OTA rollback is supported and available (there is another image to run).
|
||||
* @return false if no second image to run or dual-OTA not supported
|
||||
*/
|
||||
bool LibreTuya::otaCanRollback() {
|
||||
if (!otaSupportsDual())
|
||||
return false;
|
||||
if (otaGetRunning() == otaGetStoredIndex())
|
||||
return true;
|
||||
if (otaGetRunning() == 1 && otaHasImage1())
|
||||
return true;
|
||||
if (otaGetRunning() == 2 && otaHasImage2())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
__attribute__((weak)) void LibreTuya::gpioRecover() {
|
||||
// nop by default
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-06. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "LibreTuyaAPI.h"
|
||||
#include <core/ChipType.h>
|
||||
|
||||
/**
|
||||
* @brief Flash chip ID structure.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t manufacturerId;
|
||||
uint8_t chipId;
|
||||
uint8_t chipSizeId;
|
||||
} FlashId;
|
||||
|
||||
/**
|
||||
* @brief Main LibreTuya API class.
|
||||
*
|
||||
* This class contains all functions common amongst all families.
|
||||
* Implementations of these methods may vary between families.
|
||||
*
|
||||
* The class is accessible using the `LT` global object (defined by the family).
|
||||
*/
|
||||
class LibreTuya {
|
||||
public: /* Common methods - note: these are documented in LibreTuyaAPI.cpp */
|
||||
const char *getVersion();
|
||||
const char *getBoard();
|
||||
ChipFamily getChipFamily();
|
||||
const char *getChipFamilyName();
|
||||
const char *getDeviceName();
|
||||
uint32_t getCpuFreqMHz();
|
||||
uint32_t getFlashChipSize();
|
||||
uint8_t otaGetRunning();
|
||||
uint8_t otaGetTarget();
|
||||
bool otaRollback();
|
||||
bool otaCanRollback();
|
||||
|
||||
public: /* Family-defined methods */
|
||||
/**
|
||||
* @brief Reboot the CPU.
|
||||
*/
|
||||
void restart();
|
||||
/**
|
||||
* @brief Reconfigure GPIO pins used for debugging
|
||||
* (SWD/JTAG), so that they can be used as normal I/O.
|
||||
*/
|
||||
void gpioRecover();
|
||||
|
||||
public: /* CPU-related */
|
||||
/**
|
||||
* @brief Get CPU model ID.
|
||||
*/
|
||||
ChipType getChipType();
|
||||
/**
|
||||
* @brief Get CPU model name as string.
|
||||
*/
|
||||
const char *getChipModel();
|
||||
/**
|
||||
* @brief Get CPU unique ID. This may be based on MAC, eFuse, etc.
|
||||
* Note: the number should be 24-bit (with most significant byte being zero).
|
||||
*/
|
||||
uint32_t getChipId();
|
||||
/**
|
||||
* @brief Get CPU core count.
|
||||
*/
|
||||
uint8_t getChipCores();
|
||||
/**
|
||||
* @brief Get CPU core type name as string.
|
||||
*/
|
||||
const char *getChipCoreType();
|
||||
/**
|
||||
* @brief Get CPU frequency in Hz.
|
||||
*/
|
||||
uint32_t getCpuFreq();
|
||||
/**
|
||||
* @brief Get CPU cycle count.
|
||||
*/
|
||||
uint32_t getCycleCount();
|
||||
|
||||
public: /* Flash memory utilities */
|
||||
/**
|
||||
* @brief Read flash chip ID and return a FlashId struct.
|
||||
*/
|
||||
FlashId getFlashChipId();
|
||||
|
||||
public: /* Memory management */
|
||||
/**
|
||||
* @brief Get total RAM size.
|
||||
*/
|
||||
uint32_t getRamSize();
|
||||
/**
|
||||
* @brief Get total heap size.
|
||||
*/
|
||||
uint32_t getHeapSize();
|
||||
/**
|
||||
* @brief Get free heap size.
|
||||
*/
|
||||
uint32_t getFreeHeap();
|
||||
/**
|
||||
* @brief Get lowest level of free heap memory.
|
||||
*/
|
||||
uint32_t getMinFreeHeap();
|
||||
/**
|
||||
* @brief Get largest block of heap that can be allocated at once.
|
||||
*/
|
||||
uint32_t getMaxAllocHeap();
|
||||
|
||||
public: /* OTA-related */
|
||||
/**
|
||||
* @brief Read the currently active OTA index, i.e. the one that will boot upon restart.
|
||||
*/
|
||||
uint8_t otaGetStoredIndex();
|
||||
/**
|
||||
* @brief Check if the chip supports dual-OTA.
|
||||
*/
|
||||
bool otaSupportsDual();
|
||||
/**
|
||||
* @brief Check if OTA1 image is valid.
|
||||
*/
|
||||
bool otaHasImage1();
|
||||
/**
|
||||
* @brief Check if OTA2 image is valid.
|
||||
*/
|
||||
bool otaHasImage2();
|
||||
/**
|
||||
* @brief Try to switch OTA index to the other image.
|
||||
*
|
||||
* Note: should return true for chips without dual-OTA. Should return false if one of two images is not valid.
|
||||
*
|
||||
* @param force switch even if other image already marked as active
|
||||
* @return false if writing failed; true otherwise
|
||||
*/
|
||||
bool otaSwitch(bool force = false);
|
||||
};
|
||||
|
||||
extern LibreTuya LT;
|
||||
extern LibreTuya ESP;
|
||||
|
||||
#endif
|
||||
@@ -1,33 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-04. */
|
||||
|
||||
#include "LibreTuyaCompat.h"
|
||||
|
||||
#if LT_HAS_FREERTOS
|
||||
BaseType_t xTaskCreateUniversal(
|
||||
TaskFunction_t pxTaskCode,
|
||||
const char *const pcName,
|
||||
const uint32_t usStackDepth,
|
||||
void *const pvParameters,
|
||||
UBaseType_t uxPriority,
|
||||
TaskHandle_t *const pxCreatedTask,
|
||||
const BaseType_t xCoreID
|
||||
) {
|
||||
// #ifndef CONFIG_FREERTOS_UNICORE
|
||||
// if (xCoreID >= 0 && xCoreID < 2) {
|
||||
// return xTaskCreatePinnedToCore(
|
||||
// pxTaskCode,
|
||||
// pcName,
|
||||
// usStackDepth,
|
||||
// pvParameters,
|
||||
// uxPriority,
|
||||
// pxCreatedTask,
|
||||
// xCoreID
|
||||
// );
|
||||
// } else {
|
||||
// #endif
|
||||
return xTaskCreate(pxTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask);
|
||||
// #ifndef CONFIG_FREERTOS_UNICORE
|
||||
// }
|
||||
// #endif
|
||||
}
|
||||
#endif
|
||||
@@ -1,25 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-07-04. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#ifdef HAS_SERIAL_CLASS // failsafe for circular inclusion
|
||||
|
||||
#ifdef PIN_SERIAL0_TX
|
||||
extern SerialClass Serial0;
|
||||
#endif
|
||||
|
||||
#ifdef PIN_SERIAL1_TX
|
||||
extern SerialClass Serial1;
|
||||
#endif
|
||||
|
||||
#ifdef PIN_SERIAL2_TX
|
||||
extern SerialClass Serial2;
|
||||
#endif
|
||||
|
||||
#define SerialN(x) Serial##x
|
||||
#define SerialM(x) SerialN(x)
|
||||
#define Serial SerialM(LT_UART_DEFAULT_SERIAL)
|
||||
|
||||
#endif
|
||||
@@ -1,30 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-04-24. */
|
||||
|
||||
#include "Flash.h"
|
||||
|
||||
extern "C" {
|
||||
#include <fal.h>
|
||||
}
|
||||
|
||||
// Global Flash object.
|
||||
FlashClass Flash;
|
||||
|
||||
FlashId FlashClass::getChipId() {
|
||||
return LT.getFlashChipId();
|
||||
}
|
||||
|
||||
uint32_t FlashClass::getSize() {
|
||||
return LT.getFlashChipSize();
|
||||
}
|
||||
|
||||
bool FlashClass::eraseSector(uint32_t offset) {
|
||||
return fal_partition_erase(fal_root_part, offset, 1) >= 0;
|
||||
}
|
||||
|
||||
bool FlashClass::readBlock(uint32_t offset, uint8_t *data, size_t size) {
|
||||
return fal_partition_read(fal_root_part, offset, data, size) >= 0;
|
||||
}
|
||||
|
||||
bool FlashClass::writeBlock(uint32_t offset, uint8_t *data, size_t size) {
|
||||
return fal_partition_write(fal_root_part, offset, data, size) >= 0;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-04-24. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
class FlashClass {
|
||||
public:
|
||||
FlashId getChipId();
|
||||
uint32_t getSize();
|
||||
|
||||
bool eraseSector(uint32_t offset);
|
||||
bool readBlock(uint32_t offset, uint8_t *data, size_t size);
|
||||
bool writeBlock(uint32_t offset, uint8_t *data, size_t size);
|
||||
};
|
||||
|
||||
extern FlashClass Flash;
|
||||
@@ -1,7 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-04-29. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <time.h>
|
||||
|
||||
extern char *strptime(const char *buf, const char *fmt, struct tm *tm);
|
||||
@@ -1,28 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-03. */
|
||||
|
||||
#if LT_ARD_HAS_MD5
|
||||
|
||||
#include "MD5.h"
|
||||
|
||||
#if LT_MD5_USE_POLARSSL
|
||||
|
||||
extern "C" {
|
||||
|
||||
void MD5Init(LT_MD5_CTX_T *context) {
|
||||
md5_init(context);
|
||||
md5_starts(context);
|
||||
}
|
||||
|
||||
void MD5Update(LT_MD5_CTX_T *context, const unsigned char *buf, unsigned len) {
|
||||
md5_update(context, buf, len);
|
||||
}
|
||||
|
||||
void MD5Final(unsigned char digest[16], LT_MD5_CTX_T *context) {
|
||||
md5_finish(context, digest);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
#endif // LT_MD5_USE_POLARSSL
|
||||
|
||||
#endif // LT_ARD_HAS_MD5
|
||||
@@ -1,14 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-03. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <polarssl/md5.h>
|
||||
#define LT_MD5_CTX_T md5_context
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
@@ -1,32 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-05-29. */
|
||||
|
||||
#include "uf2priv.h"
|
||||
|
||||
uf2_err_t uf2_binpatch(uint8_t *data, const uint8_t *binpatch, uint8_t binpatch_len) {
|
||||
const uint8_t *binpatch_end = binpatch + binpatch_len;
|
||||
// +2 to make sure opcode and length is present
|
||||
while ((binpatch + 2) < binpatch_end) {
|
||||
uf2_opcode_t opcode = binpatch[0];
|
||||
uint8_t len = binpatch[1];
|
||||
switch (opcode) {
|
||||
case UF2_OPC_DIFF32:
|
||||
uf2_binpatch_diff32(data, binpatch + 1);
|
||||
break;
|
||||
}
|
||||
// advance by opcode + length + data
|
||||
binpatch += len + 2;
|
||||
}
|
||||
return UF2_ERR_OK;
|
||||
}
|
||||
|
||||
void uf2_binpatch_diff32(uint8_t *data, const uint8_t *patch) {
|
||||
uint8_t num_offs = patch[0] - 4; // read offset count
|
||||
uint32_t diff = *((uint32_t *)(patch + 1)); // read diff value
|
||||
patch += 5; // skip num_offs and diff value
|
||||
for (uint8_t i = 0; i < num_offs; i++) {
|
||||
// patch the data
|
||||
uint8_t offs = patch[i];
|
||||
uint32_t *value = (uint32_t *)(data + offs);
|
||||
*(value) += diff;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-05-29. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "uf2types.h"
|
||||
|
||||
/**
|
||||
* @brief Apply binary patch to data.
|
||||
*
|
||||
* @param data input data
|
||||
* @param data_len input data length
|
||||
* @param binpatch binary patch data
|
||||
* @param binpatch_len binary patch data length
|
||||
* @return uf2_err_t error code
|
||||
*/
|
||||
uf2_err_t uf2_binpatch(uint8_t *data, const uint8_t *binpatch, uint8_t binpatch_len);
|
||||
|
||||
/**
|
||||
* Apply DIFF32 binary patch.
|
||||
*
|
||||
* @param data input data
|
||||
* @param len input data length
|
||||
* @param patch patch data, incl. length byte
|
||||
* @return uf2_err_t error code
|
||||
*/
|
||||
void uf2_binpatch_diff32(uint8_t *data, const uint8_t *patch);
|
||||
@@ -1,100 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-05-29. */
|
||||
|
||||
#include "uf2priv.h"
|
||||
|
||||
uf2_ota_t *uf2_ctx_init(uint8_t ota_idx, uint32_t family_id) {
|
||||
uf2_ota_t *ctx = (uf2_ota_t *)zalloc(sizeof(uf2_ota_t));
|
||||
ctx->ota_idx = ota_idx;
|
||||
ctx->family_id = family_id;
|
||||
return ctx;
|
||||
}
|
||||
|
||||
uf2_info_t *uf2_info_init() {
|
||||
uf2_info_t *info = (uf2_info_t *)zalloc(sizeof(uf2_info_t));
|
||||
return info;
|
||||
}
|
||||
|
||||
void uf2_info_free(uf2_info_t *info) {
|
||||
if (!info)
|
||||
return;
|
||||
free(info->fw_name);
|
||||
free(info->fw_version);
|
||||
free(info->lt_version);
|
||||
free(info->board);
|
||||
free(info);
|
||||
}
|
||||
|
||||
uf2_err_t uf2_check_block(uf2_ota_t *ctx, uf2_block_t *block) {
|
||||
if (block->magic1 != UF2_MAGIC_1)
|
||||
return UF2_ERR_MAGIC;
|
||||
if (block->magic2 != UF2_MAGIC_2)
|
||||
return UF2_ERR_MAGIC;
|
||||
if (block->magic3 != UF2_MAGIC_3)
|
||||
return UF2_ERR_MAGIC;
|
||||
if (block->file_container)
|
||||
// ignore file containers, for now
|
||||
return UF2_ERR_IGNORE;
|
||||
if (!block->has_family_id || block->file_size != ctx->family_id)
|
||||
// require family_id
|
||||
return UF2_ERR_FAMILY;
|
||||
return UF2_ERR_OK;
|
||||
}
|
||||
|
||||
uf2_err_t uf2_parse_header(uf2_ota_t *ctx, uf2_block_t *block, uf2_info_t *info) {
|
||||
if (!block->has_tags || block->file_container || block->len)
|
||||
// header must have tags and no data
|
||||
return UF2_ERR_NOT_HEADER;
|
||||
|
||||
uf2_err_t err = uf2_parse_block(ctx, block, info);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if ((ctx->ota_idx == 1 && !ctx->has_ota1) || !ctx->has_ota2)
|
||||
return UF2_ERR_OTA_WRONG;
|
||||
return UF2_ERR_OK;
|
||||
}
|
||||
|
||||
uf2_err_t uf2_write(uf2_ota_t *ctx, uf2_block_t *block) {
|
||||
if (ctx->seq == 0)
|
||||
return uf2_parse_header(ctx, block, NULL);
|
||||
if (block->not_main_flash || !block->len)
|
||||
// ignore blocks not meant for flashing
|
||||
return UF2_ERR_IGNORE;
|
||||
|
||||
uf2_err_t err = uf2_parse_block(ctx, block, NULL);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (!ctx->part1 && !ctx->part2)
|
||||
// no partitions set at all
|
||||
return UF2_ERR_PART_UNSET;
|
||||
|
||||
fal_partition_t part = uf2_get_target_part(ctx);
|
||||
if (!part)
|
||||
// image is not for current OTA scheme
|
||||
return UF2_ERR_IGNORE;
|
||||
|
||||
if (ctx->ota_idx == 2 && ctx->binpatch_len) {
|
||||
// apply binpatch
|
||||
err = uf2_binpatch(block->data, ctx->binpatch, ctx->binpatch_len);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
int ret;
|
||||
// erase sectors if needed
|
||||
if (!uf2_is_erased(ctx, block->addr, block->len)) {
|
||||
ret = fal_partition_erase(part, block->addr, block->len);
|
||||
if (ret < 0)
|
||||
return UF2_ERR_ERASE_FAILED;
|
||||
ctx->erased_offset = block->addr;
|
||||
ctx->erased_length = ret;
|
||||
}
|
||||
// write data to flash
|
||||
ret = fal_partition_write(part, block->addr, block->data, block->len);
|
||||
if (ret < 0)
|
||||
return UF2_ERR_WRITE_FAILED;
|
||||
if (ret != block->len)
|
||||
return UF2_ERR_WRITE_LENGTH;
|
||||
return UF2_ERR_OK;
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-05-28. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
#include "uf2types.h"
|
||||
|
||||
/**
|
||||
* @brief Create an UF2 OTA context.
|
||||
*
|
||||
* @param ota_idx target OTA index
|
||||
* @param family_id expected family ID
|
||||
* @return uf2_ota_t* heap-allocated structure
|
||||
*/
|
||||
uf2_ota_t *uf2_ctx_init(uint8_t ota_idx, uint32_t family_id);
|
||||
|
||||
/**
|
||||
* @brief Create an UF2 Info structure.
|
||||
*
|
||||
* @return uf2_info_t* heap-allocated structure
|
||||
*/
|
||||
uf2_info_t *uf2_info_init();
|
||||
|
||||
/**
|
||||
* @brief Free values in the info structure AND the structure itself.
|
||||
*
|
||||
* @param info structure to free; may be NULL
|
||||
*/
|
||||
void uf2_info_free(uf2_info_t *info);
|
||||
|
||||
/**
|
||||
* @brief Check if block is valid.
|
||||
*
|
||||
* @param ctx context
|
||||
* @param block block to check
|
||||
* @return uf2_err_t error code; UF2_ERR_OK and UF2_ERR_IGNORE denote valid blocks
|
||||
*/
|
||||
uf2_err_t uf2_check_block(uf2_ota_t *ctx, uf2_block_t *block);
|
||||
|
||||
/**
|
||||
* @brief Parse header block (LibreTuya UF2 first block).
|
||||
*
|
||||
* Note: caller should call uf2_check_block() first.
|
||||
*
|
||||
* @param ctx context
|
||||
* @param block block to parse
|
||||
* @param info structure to write firmware info, NULL if not used
|
||||
* @return uf2_err_t error code
|
||||
*/
|
||||
uf2_err_t uf2_parse_header(uf2_ota_t *ctx, uf2_block_t *block, uf2_info_t *info);
|
||||
|
||||
/**
|
||||
* @brief Write the block to flash memory.
|
||||
*
|
||||
* Note: caller should call uf2_check_block() first.
|
||||
*
|
||||
* @param ctx context
|
||||
* @param block block to write
|
||||
* @return uf2_err_t error code
|
||||
*/
|
||||
uf2_err_t uf2_write(uf2_ota_t *ctx, uf2_block_t *block);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
@@ -1,146 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-05-29. */
|
||||
|
||||
#include "uf2priv.h"
|
||||
|
||||
uf2_err_t uf2_parse_block(uf2_ota_t *ctx, uf2_block_t *block, uf2_info_t *info) {
|
||||
if (block->block_seq != ctx->seq)
|
||||
// sequence number must match
|
||||
return UF2_ERR_SEQ_MISMATCH;
|
||||
ctx->seq++; // increment sequence number after checking it
|
||||
|
||||
if (!block->has_tags)
|
||||
// no tags in this block, no further processing needed
|
||||
return UF2_ERR_OK;
|
||||
|
||||
if (block->len > (476 - 4 - 4))
|
||||
// at least one tag + last tag must fit
|
||||
return UF2_ERR_DATA_TOO_LONG;
|
||||
|
||||
uint8_t *tags_start = block->data + block->len;
|
||||
uint8_t tags_len = 476 - block->len;
|
||||
uint8_t tags_pos = 0;
|
||||
if (block->has_md5)
|
||||
tags_len -= 24;
|
||||
|
||||
ctx->binpatch_len = 0; // binpatch applies to one block only
|
||||
char *part1 = NULL;
|
||||
char *part2 = NULL;
|
||||
|
||||
uf2_tag_type_t type;
|
||||
while (tags_pos < tags_len) {
|
||||
uint8_t len = uf2_read_tag(tags_start + tags_pos, &type);
|
||||
if (!len)
|
||||
break;
|
||||
tags_pos += 4; // skip tag header
|
||||
uint8_t *tag = tags_start + tags_pos;
|
||||
|
||||
char **str_dest = NULL; // char* to copy the tag into
|
||||
|
||||
switch (type) {
|
||||
case UF2_TAG_OTA_VERSION:
|
||||
if (tag[0] != 1)
|
||||
return UF2_ERR_OTA_VER;
|
||||
break;
|
||||
case UF2_TAG_FIRMWARE:
|
||||
if (info)
|
||||
str_dest = &(info->fw_name);
|
||||
break;
|
||||
case UF2_TAG_VERSION:
|
||||
if (info)
|
||||
str_dest = &(info->fw_version);
|
||||
break;
|
||||
case UF2_TAG_LT_VERSION:
|
||||
if (info)
|
||||
str_dest = &(info->lt_version);
|
||||
break;
|
||||
case UF2_TAG_BOARD:
|
||||
if (info)
|
||||
str_dest = &(info->board);
|
||||
break;
|
||||
case UF2_TAG_HAS_OTA1:
|
||||
ctx->has_ota1 = tag[0];
|
||||
break;
|
||||
case UF2_TAG_HAS_OTA2:
|
||||
ctx->has_ota2 = tag[0];
|
||||
break;
|
||||
case UF2_TAG_PART_1:
|
||||
str_dest = &(part1);
|
||||
break;
|
||||
case UF2_TAG_PART_2:
|
||||
str_dest = &(part2);
|
||||
break;
|
||||
case UF2_TAG_BINPATCH:
|
||||
ctx->binpatch = tag;
|
||||
ctx->binpatch_len = len;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (str_dest) {
|
||||
*str_dest = (char *)zalloc(len + 1);
|
||||
memcpy(*str_dest, tag, len);
|
||||
}
|
||||
// align position to 4 bytes
|
||||
tags_pos += (((len - 1) / 4) + 1) * 4;
|
||||
}
|
||||
|
||||
if (part1 && part2) {
|
||||
// update current target partition
|
||||
uf2_err_t err = uf2_update_parts(ctx, part1, part2);
|
||||
if (err)
|
||||
return err;
|
||||
} else if (part1 || part2) {
|
||||
// only none or both partitions can be specified
|
||||
return UF2_ERR_PART_ONE;
|
||||
}
|
||||
|
||||
return UF2_ERR_OK;
|
||||
}
|
||||
|
||||
uint8_t uf2_read_tag(const uint8_t *data, uf2_tag_type_t *type) {
|
||||
uint8_t len = data[0];
|
||||
if (!len)
|
||||
return 0;
|
||||
uint32_t tag_type = *((uint32_t *)data);
|
||||
if (!tag_type)
|
||||
return 0;
|
||||
*type = tag_type >> 8; // remove tag length byte
|
||||
return len - 4;
|
||||
}
|
||||
|
||||
uf2_err_t uf2_update_parts(uf2_ota_t *ctx, char *part1, char *part2) {
|
||||
// reset both target partitions
|
||||
ctx->part1 = NULL;
|
||||
ctx->part2 = NULL;
|
||||
// reset offsets as they probably don't apply to this partition
|
||||
ctx->erased_offset = 0;
|
||||
ctx->erased_length = 0;
|
||||
|
||||
if (part1[0]) {
|
||||
ctx->part1 = (fal_partition_t)fal_partition_find(part1);
|
||||
if (!ctx->part1)
|
||||
return UF2_ERR_PART_404;
|
||||
}
|
||||
if (part2[0]) {
|
||||
ctx->part2 = (fal_partition_t)fal_partition_find(part2);
|
||||
if (!ctx->part2)
|
||||
return UF2_ERR_PART_404;
|
||||
}
|
||||
|
||||
return UF2_ERR_OK;
|
||||
}
|
||||
|
||||
fal_partition_t uf2_get_target_part(uf2_ota_t *ctx) {
|
||||
if (ctx->ota_idx == 1)
|
||||
return ctx->part1;
|
||||
if (ctx->ota_idx == 2)
|
||||
return ctx->part2;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool uf2_is_erased(uf2_ota_t *ctx, uint32_t offset, uint32_t length) {
|
||||
uint32_t erased_end = ctx->erased_offset + ctx->erased_length;
|
||||
uint32_t end = offset + length;
|
||||
return (offset >= ctx->erased_offset) && (end <= erased_end);
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-05-28. */
|
||||
|
||||
#pragma once
|
||||
|
||||
// include family stdlib APIs
|
||||
#include <WVariant.h>
|
||||
|
||||
#include "uf2binpatch.h"
|
||||
#include "uf2types.h"
|
||||
|
||||
/**
|
||||
* @brief Parse a block and extract information from tags.
|
||||
*
|
||||
* @param ctx context
|
||||
* @param block block to parse
|
||||
* @param info structure to write firmware info, NULL if not used
|
||||
* @return uf2_err_t error code
|
||||
*/
|
||||
uf2_err_t uf2_parse_block(uf2_ota_t *ctx, uf2_block_t *block, uf2_info_t *info);
|
||||
|
||||
/**
|
||||
* @brief Parse a tag.
|
||||
*
|
||||
* @param data pointer to tag header beginning
|
||||
* @param type [out] parsed tag type
|
||||
* @return uint8_t parsed tag data length (excl. header); 0 if invalid/last tag
|
||||
*/
|
||||
uint8_t uf2_read_tag(const uint8_t *data, uf2_tag_type_t *type);
|
||||
|
||||
/**
|
||||
* @brief Update destination partitions in context.
|
||||
*
|
||||
* Partition names cannot be NULL.
|
||||
*
|
||||
* Returns UF2_ERR_IGNORE if specified partitions don't match the
|
||||
* current OTA index.
|
||||
*
|
||||
* @param ctx context
|
||||
* @param part1 partition 1 name or empty string
|
||||
* @param part2 partition 2 name or empty string
|
||||
* @return uf2_err_t error code
|
||||
*/
|
||||
uf2_err_t uf2_update_parts(uf2_ota_t *ctx, char *part1, char *part2);
|
||||
|
||||
/**
|
||||
* @brief Get target flashing partition, depending on OTA index.
|
||||
*
|
||||
* @param ctx context
|
||||
* @return fal_partition_t target partition or NULL if not set
|
||||
*/
|
||||
fal_partition_t uf2_get_target_part(uf2_ota_t *ctx);
|
||||
|
||||
/**
|
||||
* Check if specified flash memory region was already erased during update.
|
||||
*
|
||||
* @param ctx context
|
||||
* @param offset offset to check
|
||||
* @param length length to check
|
||||
* @return bool true/false
|
||||
*/
|
||||
bool uf2_is_erased(uf2_ota_t *ctx, uint32_t offset, uint32_t length);
|
||||
@@ -1,104 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-05-28. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <fal.h>
|
||||
|
||||
#define UF2_MAGIC_1 0x0A324655
|
||||
#define UF2_MAGIC_2 0x9E5D5157
|
||||
#define UF2_MAGIC_3 0x0AB16F30
|
||||
|
||||
#define UF2_BLOCK_SIZE sizeof(uf2_block_t)
|
||||
|
||||
typedef struct __attribute__((packed)) {
|
||||
// 32 byte header
|
||||
uint32_t magic1;
|
||||
uint32_t magic2;
|
||||
|
||||
// flags split as bitfields
|
||||
bool not_main_flash : 1;
|
||||
uint16_t dummy1 : 11;
|
||||
bool file_container : 1;
|
||||
bool has_family_id : 1;
|
||||
bool has_md5 : 1;
|
||||
bool has_tags : 1;
|
||||
uint16_t dummy2 : 16;
|
||||
|
||||
uint32_t addr;
|
||||
uint32_t len;
|
||||
uint32_t block_seq;
|
||||
uint32_t block_count;
|
||||
uint32_t file_size; // or familyID;
|
||||
uint8_t data[476];
|
||||
uint32_t magic3;
|
||||
} uf2_block_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t seq; // current block sequence number
|
||||
|
||||
uint8_t *binpatch; // current block's binpatch (if any) -> pointer inside block->data
|
||||
uint8_t binpatch_len; // binpatch length
|
||||
|
||||
bool has_ota1; // image has any data for OTA1
|
||||
bool has_ota2; // image has any data for OTA2
|
||||
|
||||
uint8_t ota_idx; // target OTA index
|
||||
uint32_t family_id; // expected family ID
|
||||
|
||||
uint32_t erased_offset; // offset of region erased during update
|
||||
uint32_t erased_length; // length of erased region
|
||||
|
||||
fal_partition_t part1; // OTA1 target partition
|
||||
fal_partition_t part2; // OTA2 target partition
|
||||
} uf2_ota_t;
|
||||
|
||||
typedef struct {
|
||||
char *fw_name;
|
||||
char *fw_version;
|
||||
char *lt_version;
|
||||
char *board;
|
||||
} uf2_info_t;
|
||||
|
||||
typedef enum {
|
||||
UF2_TAG_VERSION = 0x9FC7BC, // version of firmware file - UTF8 semver string
|
||||
UF2_TAG_PAGE_SIZE = 0x0BE9F7, // page size of target device (32 bit unsigned number)
|
||||
UF2_TAG_SHA2 = 0xB46DB0, // SHA-2 checksum of firmware (can be of various size)
|
||||
UF2_TAG_DEVICE = 0x650D9D, // description of device (UTF8)
|
||||
UF2_TAG_DEVICE_ID = 0xC8A729, // device type identifier
|
||||
// LibreTuya custom, tags
|
||||
UF2_TAG_OTA_VERSION = 0x5D57D0, // format version
|
||||
UF2_TAG_BOARD = 0xCA25C8, // board name (lowercase code)
|
||||
UF2_TAG_FIRMWARE = 0x00DE43, // firmware description / name
|
||||
UF2_TAG_BUILD_DATE = 0x822F30, // build date/time as Unix timestamp
|
||||
UF2_TAG_LT_VERSION = 0x59563D, // LT version (semver)
|
||||
UF2_TAG_PART_1 = 0x805946, // OTA1 partition name
|
||||
UF2_TAG_PART_2 = 0xA1E4D7, // OTA2 partition name
|
||||
UF2_TAG_HAS_OTA1 = 0xBBD965, // image has any data for OTA1
|
||||
UF2_TAG_HAS_OTA2 = 0x92280E, // image has any data for OTA2
|
||||
UF2_TAG_BINPATCH = 0xB948DE, // binary patch to convert OTA1->OTA2
|
||||
} uf2_tag_type_t;
|
||||
|
||||
typedef enum {
|
||||
UF2_OPC_DIFF32 = 0xFE,
|
||||
} uf2_opcode_t;
|
||||
|
||||
typedef enum {
|
||||
UF2_ERR_OK = 0,
|
||||
UF2_ERR_IGNORE, // block should be ignored
|
||||
UF2_ERR_MAGIC, // wrong magic numbers
|
||||
UF2_ERR_FAMILY, // family ID mismatched
|
||||
UF2_ERR_NOT_HEADER, // block is not a header
|
||||
UF2_ERR_OTA_VER, // unknown/invalid OTA format version
|
||||
UF2_ERR_OTA_WRONG, // no data for current OTA index
|
||||
UF2_ERR_PART_404, // no partition with that name
|
||||
UF2_ERR_PART_ONE, // only one partition tag in a block
|
||||
UF2_ERR_PART_UNSET, // image broken - attempted to write without target partition
|
||||
UF2_ERR_DATA_TOO_LONG, // data too long - tags won't fit
|
||||
UF2_ERR_SEQ_MISMATCH, // sequence number mismatched
|
||||
UF2_ERR_ERASE_FAILED, // erasing flash failed
|
||||
UF2_ERR_WRITE_FAILED, // writing to flash failed
|
||||
UF2_ERR_WRITE_LENGTH, // wrote fewer data than requested
|
||||
} uf2_err_t;
|
||||
@@ -1,154 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-05-23. */
|
||||
|
||||
#ifdef LT_HAS_LWIP2
|
||||
|
||||
#include "mDNS.h"
|
||||
|
||||
extern "C" {
|
||||
#include <lwip/apps/mdns.h>
|
||||
#include <lwip/netif.h>
|
||||
}
|
||||
|
||||
static u8_t mdns_netif_client_id = 0; // TODO fix this
|
||||
|
||||
struct mdns_domain {
|
||||
/* Encoded domain name */
|
||||
u8_t name[256];
|
||||
/* Total length of domain name, including zero */
|
||||
u16_t length;
|
||||
/* Set if compression of this domain is not allowed */
|
||||
u8_t skip_compression;
|
||||
};
|
||||
|
||||
/** Description of a service */
|
||||
struct mdns_service {
|
||||
/** TXT record to answer with */
|
||||
struct mdns_domain txtdata;
|
||||
/** Name of service, like 'myweb' */
|
||||
char name[MDNS_LABEL_MAXLEN + 1];
|
||||
/** Type of service, like '_http' */
|
||||
char service[MDNS_LABEL_MAXLEN + 1];
|
||||
/** Callback function and userdata
|
||||
* to update txtdata buffer */
|
||||
service_get_txt_fn_t txt_fn;
|
||||
void *txt_userdata;
|
||||
/** TTL in seconds of SRV/TXT replies */
|
||||
u32_t dns_ttl;
|
||||
/** Protocol, TCP or UDP */
|
||||
u16_t proto;
|
||||
/** Port of the service */
|
||||
u16_t port;
|
||||
};
|
||||
|
||||
/** Description of a host/netif */
|
||||
struct mdns_host {
|
||||
/** Hostname */
|
||||
char name[MDNS_LABEL_MAXLEN + 1];
|
||||
/** Pointer to services */
|
||||
struct mdns_service *services[MDNS_MAX_SERVICES];
|
||||
/** TTL in seconds of A/AAAA/PTR replies */
|
||||
u32_t dns_ttl;
|
||||
};
|
||||
|
||||
static String mdnsInstanceName = "default_instance";
|
||||
|
||||
mDNS::mDNS() {}
|
||||
|
||||
mDNS::~mDNS() {}
|
||||
|
||||
bool mDNS::begin(const char *hostname) {
|
||||
mdns_resp_init();
|
||||
struct netif *netif = netif_list;
|
||||
uint8_t enabled = 0;
|
||||
while (netif != NULL) {
|
||||
// TODO: detect mdns_netif_client_id by checking netif_get_client_data()
|
||||
// and finding the requested hostname in struct mdns_host
|
||||
if (netif_is_up(netif) && mdns_resp_add_netif(netif, hostname, 255) == ERR_OK) {
|
||||
enabled++;
|
||||
}
|
||||
netif = netif->next;
|
||||
}
|
||||
return enabled > 0;
|
||||
}
|
||||
|
||||
void mDNS::end() {
|
||||
struct netif *netif = netif_list;
|
||||
while (netif != NULL) {
|
||||
if (netif_is_up(netif))
|
||||
mdns_resp_remove_netif(netif);
|
||||
netif = netif->next;
|
||||
}
|
||||
}
|
||||
|
||||
void mDNS::setInstanceName(String name) {
|
||||
mdnsInstanceName = name;
|
||||
}
|
||||
|
||||
bool mDNS::addService(char *service, char *proto, uint16_t port) {
|
||||
char _service[strlen(service) + 2];
|
||||
char _proto[strlen(proto) + 2];
|
||||
_service[0] = '_';
|
||||
_proto[0] = '_';
|
||||
// prepend names with _
|
||||
strcpy(_service + 1, service + (service[0] == '_'));
|
||||
strcpy(_proto + 1, proto + (proto[0] == '_'));
|
||||
|
||||
mdns_sd_proto protocol = DNSSD_PROTO_UDP;
|
||||
if (strncmp(_proto + 1, "tcp", 3) == 0)
|
||||
protocol = DNSSD_PROTO_TCP;
|
||||
|
||||
struct netif *netif = netif_list;
|
||||
while (netif != NULL) {
|
||||
if (netif_is_up(netif)) {
|
||||
mdns_resp_add_service(netif, mdnsInstanceName.c_str(), service, protocol, port, 255, NULL, NULL);
|
||||
}
|
||||
netif = netif->next;
|
||||
}
|
||||
}
|
||||
|
||||
bool mDNS::addServiceTxt(char *name, char *proto, char *key, char *value) {
|
||||
char _name[strlen(name) + 2];
|
||||
char _proto[strlen(proto) + 2];
|
||||
_name[0] = '_';
|
||||
_proto[0] = '_';
|
||||
// prepend names with _
|
||||
strcpy(_name + 1, name + (name[0] == '_'));
|
||||
strcpy(_proto + 1, proto + (proto[0] == '_'));
|
||||
|
||||
mdns_sd_proto protocol = DNSSD_PROTO_UDP;
|
||||
if (strncmp(_proto + 1, "tcp", 3) == 0)
|
||||
protocol = DNSSD_PROTO_TCP;
|
||||
|
||||
struct netif *netif = netif_list;
|
||||
struct mdns_host *mdns;
|
||||
struct mdns_service *service;
|
||||
|
||||
uint8_t txt_len = strlen(key) + strlen(value) + 1;
|
||||
char *txt = (char *)malloc(txt_len + 1);
|
||||
sprintf(txt, "%s=%s", key, value);
|
||||
|
||||
while (netif != NULL) {
|
||||
if (netif_is_up(netif)) {
|
||||
mdns = (struct mdns_host *)netif_get_client_data(netif, mdns_netif_client_id);
|
||||
|
||||
for (uint8_t i = 0; i < MDNS_MAX_SERVICES; i++) {
|
||||
service = mdns->services[i];
|
||||
if (service == NULL)
|
||||
continue;
|
||||
if (strcmp(service->service, _name) || service->proto != protocol)
|
||||
continue;
|
||||
if (mdns_resp_add_service_txtitem(service, txt, txt_len) != ERR_OK) {
|
||||
free(txt);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
netif = netif->next;
|
||||
}
|
||||
free(txt);
|
||||
return true;
|
||||
}
|
||||
|
||||
MDNSResponder MDNS;
|
||||
|
||||
#endif
|
||||
@@ -1,34 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-04-23. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "WCharacterFixup.h"
|
||||
#endif
|
||||
|
||||
#define PinMode PinModeArduino // this conflicts with SDK enum
|
||||
#include <api/ArduinoAPI.h>
|
||||
#include <core/LibreTuyaAPI.h>
|
||||
#undef PinMode
|
||||
|
||||
// Include family-specific code
|
||||
#include "WVariant.h"
|
||||
// Include board variant
|
||||
#include "variant.h"
|
||||
|
||||
// Choose the main UART output port
|
||||
#ifndef LT_UART_DEFAULT_PORT
|
||||
#if defined(PIN_SERIAL2_TX)
|
||||
#define LT_UART_DEFAULT_PORT 2
|
||||
#elif defined(PIN_SERIAL0_TX)
|
||||
#define LT_UART_DEFAULT_PORT 0
|
||||
#else
|
||||
#define LT_UART_DEFAULT_PORT 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Define available serial ports
|
||||
#ifdef __cplusplus
|
||||
#include "SerialClass.h"
|
||||
#include <core/SerialExtern.h>
|
||||
#endif
|
||||
@@ -1,170 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-05-28. */
|
||||
|
||||
#include <LibreTuyaAPI.h>
|
||||
|
||||
extern "C" {
|
||||
#include <flash_api.h>
|
||||
#include <rtl8710b.h>
|
||||
#include <sys_api.h>
|
||||
}
|
||||
|
||||
void LibreTuya::restart() {
|
||||
sys_reset();
|
||||
}
|
||||
|
||||
void LibreTuya::gpioRecover() {
|
||||
// PA14 and PA15 are apparently unusable with SWD enabled
|
||||
sys_jtag_off();
|
||||
Pinmux_Config(PA_14, PINMUX_FUNCTION_GPIO);
|
||||
Pinmux_Config(PA_15, PINMUX_FUNCTION_GPIO);
|
||||
}
|
||||
|
||||
/* CPU-related */
|
||||
|
||||
ChipType LibreTuya::getChipType() {
|
||||
uint8_t chipId;
|
||||
EFUSE_OneByteReadROM(9902, 0xF8, &chipId, L25EOUTVOLTAGE);
|
||||
return CHIP_TYPE_ENUM(F_RTL8710B, chipId);
|
||||
}
|
||||
|
||||
const char *LibreTuya::getChipModel() {
|
||||
return STRINGIFY_MACRO(MCU);
|
||||
}
|
||||
|
||||
uint32_t LibreTuya::getChipId() {
|
||||
uint32_t chipId = 0;
|
||||
uint8_t *id = (uint8_t *)&chipId;
|
||||
// 9902 was extracted from ROM disassembly, probably not needed
|
||||
/* EFUSE_OneByteReadROM(9902, 0x3B, id + 0, L25EOUTVOLTAGE);
|
||||
EFUSE_OneByteReadROM(9902, 0x3C, id + 1, L25EOUTVOLTAGE);
|
||||
EFUSE_OneByteReadROM(9902, 0x3D, id + 2, L25EOUTVOLTAGE); */
|
||||
// new method, based on EFUSE logical map
|
||||
uint8_t *efuse = (uint8_t *)malloc(512);
|
||||
// TODO do what EFUSE_LogicalMapRead() does, and read only the used data
|
||||
EFUSE_LogicalMap_Read(efuse);
|
||||
memcpy(id, efuse + 0x11A + 3, 3);
|
||||
free(efuse);
|
||||
return chipId;
|
||||
}
|
||||
|
||||
uint8_t LibreTuya::getChipCores() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *LibreTuya::getChipCoreType() {
|
||||
return "ARM Cortex-M4F";
|
||||
}
|
||||
|
||||
uint32_t LibreTuya::getCpuFreq() {
|
||||
return CPU_ClkGet(false);
|
||||
}
|
||||
|
||||
uint32_t LibreTuya::getCycleCount() {
|
||||
return microsecondsToClockCycles(micros());
|
||||
}
|
||||
|
||||
/* Flash memory utilities */
|
||||
|
||||
FlashId LibreTuya::getFlashChipId() {
|
||||
FlashId id;
|
||||
uint8_t idBytes[3];
|
||||
flash_read_id(NULL, idBytes, 3);
|
||||
id.manufacturerId = idBytes[0];
|
||||
id.chipId = idBytes[1];
|
||||
id.chipSizeId = idBytes[2];
|
||||
return id;
|
||||
}
|
||||
|
||||
/* Memory management */
|
||||
|
||||
uint32_t LibreTuya::getRamSize() {
|
||||
return 256 * 1024;
|
||||
}
|
||||
|
||||
uint32_t LibreTuya::getHeapSize() {
|
||||
return configTOTAL_HEAP_SIZE;
|
||||
}
|
||||
|
||||
uint32_t LibreTuya::getFreeHeap() {
|
||||
return xPortGetFreeHeapSize();
|
||||
}
|
||||
|
||||
uint32_t LibreTuya::getMinFreeHeap() {
|
||||
return xPortGetMinimumEverFreeHeapSize();
|
||||
}
|
||||
|
||||
uint32_t LibreTuya::getMaxAllocHeap() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* OTA-related */
|
||||
|
||||
uint8_t LibreTuya::otaGetStoredIndex() {
|
||||
uint32_t *otaAddress = (uint32_t *)0x8009000;
|
||||
if (*otaAddress == 0xFFFFFFFF)
|
||||
return 1;
|
||||
uint32_t otaCounter = *((uint32_t *)0x8009004);
|
||||
// even count of zero-bits means OTA1, odd count means OTA2
|
||||
// this allows to switch OTA images by simply clearing next bits,
|
||||
// without needing to erase the flash
|
||||
uint8_t count = 0;
|
||||
for (uint8_t i = 0; i < 32; i++) {
|
||||
if ((otaCounter & (1 << i)) == 0)
|
||||
count++;
|
||||
}
|
||||
return 1 + (count % 2);
|
||||
}
|
||||
|
||||
bool LibreTuya::otaSupportsDual() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LibreTuya::otaHasImage1() {
|
||||
uint8_t *ota1Addr = (uint8_t *)(SPI_FLASH_BASE + FLASH_OTA1_OFFSET);
|
||||
return memcmp(ota1Addr, "81958711", 8) == 0;
|
||||
}
|
||||
|
||||
bool LibreTuya::otaHasImage2() {
|
||||
uint8_t *ota2Addr = (uint8_t *)(SPI_FLASH_BASE + FLASH_OTA2_OFFSET);
|
||||
return memcmp(ota2Addr, "81958711", 8) == 0;
|
||||
}
|
||||
|
||||
bool LibreTuya::otaSwitch(bool force) {
|
||||
if (!force && otaGetRunning() != otaGetStoredIndex())
|
||||
// OTA has already been switched
|
||||
return true;
|
||||
// this function does:
|
||||
// - read OTA1 firmware magic from 0xB000
|
||||
// - read OTA2 address from 0x9000
|
||||
// - read OTA2 firmware magic from that address
|
||||
// - read current OTA switch value from 0x9004
|
||||
// - reset OTA switch to 0xFFFFFFFF if it's 0x0
|
||||
// - check first non-zero bit of OTA switch
|
||||
// - write OTA switch with first non-zero bit cleared
|
||||
// sys_clear_ota_signature();
|
||||
// ok, this function is broken (crashes with HardFault)
|
||||
|
||||
if (!otaHasImage1() || !otaHasImage2())
|
||||
return false;
|
||||
|
||||
uint32_t value = HAL_READ32(SPI_FLASH_BASE, FLASH_SYSTEM_OFFSET + 4);
|
||||
if (value == 0) {
|
||||
// TODO does this work at all?
|
||||
FLASH_EreaseDwordsXIP(FLASH_SYSTEM_OFFSET + 4, 1);
|
||||
}
|
||||
uint8_t i;
|
||||
// find first non-zero bit
|
||||
for (i = 0; i < 32; i++) {
|
||||
if (value & (1 << i))
|
||||
break;
|
||||
}
|
||||
// clear the bit
|
||||
value &= ~(1 << i);
|
||||
// write OTA switch to flash
|
||||
flash_write_word(NULL, FLASH_SYSTEM_OFFSET + 4, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Global instance */
|
||||
|
||||
LibreTuya LT;
|
||||
@@ -1,36 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "sdk_extern.h"
|
||||
#include "sdk_mem.h"
|
||||
#include "sdk_os.h"
|
||||
|
||||
#define DEFAULT 1
|
||||
#define EXTERNAL 0
|
||||
|
||||
#define round(x) ((x) >= 0 ? (long)((x) + 0.5) : (long)((x)-0.5))
|
||||
|
||||
// Additional Wiring functions
|
||||
extern uint32_t digitalPinToPort(uint32_t pinNumber);
|
||||
extern uint32_t digitalPinToBitMask(uint32_t pinNumber);
|
||||
extern void analogOutputInit(void);
|
||||
extern void wait_for_debug();
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" uint32_t SystemCoreClock;
|
||||
#else
|
||||
extern uint32_t SystemCoreClock;
|
||||
#endif
|
||||
#define clockCyclesPerMicrosecond() (SystemCoreClock / 1000000L)
|
||||
#define clockCyclesToMicroseconds(a) (a * 1000L / (SystemCoreClock / 1000L))
|
||||
#define microsecondsToClockCycles(a) (a * (SystemCoreClock / 1000000L))
|
||||
|
||||
#define interrupts() vPortClearInterruptMask(0)
|
||||
#define noInterrupts() ulPortSetInterruptMask()
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
@@ -1,37 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-19. */
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
#include <cmsis_os.h>
|
||||
|
||||
extern uint32_t GlobalDebugEnable;
|
||||
extern uint16_t GlobalDebugLevel;
|
||||
extern uint8_t GlobalPrivateLog;
|
||||
extern uint8_t lt_uart_port;
|
||||
|
||||
} // extern "C"
|
||||
|
||||
osThreadId main_tid = 0;
|
||||
|
||||
void initArduino() {
|
||||
// make the SDK less verbose by default
|
||||
GlobalDebugEnable = 0;
|
||||
GlobalPrivateLog = 0;
|
||||
lt_uart_port = LT_UART_DEFAULT_PORT;
|
||||
}
|
||||
|
||||
bool startMainTask() {
|
||||
osThreadDef(main_task, osPriorityRealtime, 1, 4096 * 4);
|
||||
main_tid = osThreadCreate(osThread(main_task), NULL);
|
||||
osKernelStart();
|
||||
return true;
|
||||
}
|
||||
|
||||
void wait_for_debug() {
|
||||
while (((CoreDebug->DHCSR) & CoreDebug_DHCSR_C_DEBUGEN_Msk) == 0) {
|
||||
asm("nop");
|
||||
}
|
||||
delay(1000);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-05-06. */
|
||||
|
||||
#include "sdk_mem.h"
|
||||
|
||||
#include <Arduino.h> // for memset
|
||||
|
||||
void *pvPortZalloc(size_t size) {
|
||||
void *pvReturn = pvPortMalloc(size);
|
||||
if (pvReturn)
|
||||
memset(pvReturn, 0, size);
|
||||
return pvReturn;
|
||||
}
|
||||
|
||||
void *pvPortCalloc(size_t nmemb, size_t size) {
|
||||
return pvPortZalloc(nmemb * size);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-05-06. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
// provide extern functions directly, as callers
|
||||
// generally don't expect needing to include malloc()
|
||||
extern void *pvPortMalloc(size_t xWantedSize);
|
||||
extern void *pvPortZalloc(size_t size);
|
||||
extern void *pvPortCalloc(size_t nmemb, size_t size);
|
||||
extern void *pvPortReAlloc(void *pv, size_t xWantedSize);
|
||||
extern void vPortFree(void *pv);
|
||||
|
||||
#define malloc pvPortMalloc
|
||||
#define zalloc pvPortZalloc
|
||||
#define calloc pvPortCalloc
|
||||
#define realloc pvPortReAlloc
|
||||
#define free vPortFree
|
||||
|
||||
#define LT_HEAP_FUNC xPortGetFreeHeapSize
|
||||
@@ -1,110 +0,0 @@
|
||||
#include "sdk_os.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <cmsis_os.h>
|
||||
|
||||
uint32_t os_thread_create(void (*task)(const void *argument), void *argument, int priority, uint32_t stack_size) {
|
||||
|
||||
osThreadDef_t thread_def;
|
||||
|
||||
thread_def.pthread = task;
|
||||
thread_def.tpriority = (osPriority)priority;
|
||||
// the underlying freertos implementation on cmsis os divide stack size by 4
|
||||
thread_def.stacksize = stack_size * 4;
|
||||
thread_def.name = "ARDUINO";
|
||||
|
||||
return (uint32_t)osThreadCreate(&thread_def, argument);
|
||||
}
|
||||
|
||||
uint32_t os_thread_get_id(void) {
|
||||
return osThreadGetId();
|
||||
}
|
||||
|
||||
uint32_t os_thread_terminate(uint32_t thread_id) {
|
||||
return (uint32_t)osThreadTerminate(thread_id);
|
||||
}
|
||||
|
||||
uint32_t os_thread_yield(void) {
|
||||
return (uint32_t)osThreadYield();
|
||||
}
|
||||
|
||||
uint32_t os_thread_set_priority(uint32_t thread_id, int priority) {
|
||||
return (uint32_t)osThreadSetPriority(thread_id, (osPriority)priority);
|
||||
}
|
||||
|
||||
int os_thread_get_priority(uint32_t thread_id) {
|
||||
return (int)osThreadGetPriority(thread_id);
|
||||
}
|
||||
|
||||
int32_t os_signal_set(uint32_t thread_id, int32_t signals) {
|
||||
return osSignalSet(thread_id, signals);
|
||||
}
|
||||
|
||||
int32_t os_signal_clear(uint32_t thread_id, int32_t signals) {
|
||||
return osSignalClear(thread_id, signals);
|
||||
}
|
||||
|
||||
os_event_t os_signal_wait(int32_t signals, uint32_t millisec) {
|
||||
|
||||
osEvent evt;
|
||||
os_event_t ret;
|
||||
|
||||
evt = osSignalWait(signals, millisec);
|
||||
ret.status = (uint32_t)evt.status;
|
||||
ret.value.signals = evt.value.signals;
|
||||
ret.def.message_id = evt.def.message_id;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
typedef void (*os_ptimer)(const void *argument);
|
||||
|
||||
uint32_t os_timer_create(void (*callback)(const void *argument), uint8_t isPeriodic, void *argument) {
|
||||
|
||||
osTimerDef_t *pTimerDef;
|
||||
|
||||
pTimerDef = (osTimerDef_t *)malloc(sizeof(osTimerDef_t));
|
||||
pTimerDef->ptimer = callback;
|
||||
pTimerDef->custom = (struct os_timer_custom *)malloc(sizeof(struct os_timer_custom));
|
||||
|
||||
return osTimerCreate(pTimerDef, (isPeriodic ? osTimerPeriodic : osTimerOnce), argument);
|
||||
}
|
||||
|
||||
uint32_t os_timer_start(uint32_t timer_id, uint32_t millisec) {
|
||||
return osTimerStart(timer_id, millisec);
|
||||
}
|
||||
|
||||
uint32_t os_timer_stop(uint32_t timer_id) {
|
||||
return osTimerStop(timer_id);
|
||||
}
|
||||
|
||||
uint32_t os_timer_delete(uint32_t timer_id) {
|
||||
|
||||
osTimerDef_t *pTimerDef;
|
||||
|
||||
pTimerDef = (osTimerDef_t *)pvTimerGetTimerID(timer_id);
|
||||
free(pTimerDef->custom);
|
||||
free(pTimerDef);
|
||||
|
||||
return osTimerDelete(timer_id);
|
||||
}
|
||||
|
||||
uint32_t os_semaphore_create(int32_t count) {
|
||||
return (uint32_t)osSemaphoreCreate(NULL, count);
|
||||
}
|
||||
|
||||
int32_t os_semaphore_wait(uint32_t semaphore_id, uint32_t millisec) {
|
||||
if (osSemaphoreWait((osSemaphoreId)semaphore_id, millisec) == 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t os_semaphore_release(uint32_t semaphore_id) {
|
||||
return (uint32_t)osSemaphoreRelease((osSemaphoreId)semaphore_id);
|
||||
}
|
||||
|
||||
uint32_t os_semaphore_delete(uint32_t semaphore_id) {
|
||||
return (uint32_t)osSemaphoreDelete((osSemaphoreId)semaphore_id);
|
||||
}
|
||||
@@ -1,302 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @defgroup os_status os_status
|
||||
* Redefinition from enum osStatus
|
||||
* @{
|
||||
*/
|
||||
/** function completed; no error or event occurred. */
|
||||
#define OS_OK 0x00
|
||||
/** function completed; signal event occurred. */
|
||||
#define OS_EVENT_SIGNAL 0x08
|
||||
/** function completed; message event occurred. */
|
||||
#define OS_EVENT_MESSAGE 0x10
|
||||
/** function completed; mail event occurred. */
|
||||
#define OS_EVENT_MAIL 0x20
|
||||
/** function completed; timeout occurred. */
|
||||
#define OS_EVENT_TIMEOUT 0x40
|
||||
/** parameter error: a mandatory parameter was missing or specified an incorrect object. */
|
||||
#define OS_ERROR_PARAMETER 0x80
|
||||
/** resource not available: a specified resource was not available. */
|
||||
#define OS_ERROR_RESOURCE 0x81
|
||||
/** resource not available within given time: a specified resource was not available within the timeout period. */
|
||||
#define OS_ERROR_TIMEOUT_RESOURCE 0xC1
|
||||
/** not allowed in ISR context: the function cannot be called from interrupt service routines. */
|
||||
#define OS_ERROR_ISR 0x82
|
||||
/** function called multiple times from ISR with same object. */
|
||||
#define OS_ERROR_ISR_RECURSIVE 0x83
|
||||
/** system cannot determine priority or thread has illegal priority. */
|
||||
#define OS_ERROR_PRIORITY 0x84
|
||||
/** system is out of memory: it was impossible to allocate or reserve memory for the operation. */
|
||||
#define OS_ERROR_NO_MEMORY 0x85
|
||||
/** value of a parameter is out of range. */
|
||||
#define OS_ERROR_VALUE 0x86
|
||||
/** unspecified RTOS error: run-time error but no other error message fits. */
|
||||
#define OS_ERROR_OS 0xFF
|
||||
/** @} */ // end of group os_status
|
||||
|
||||
/**
|
||||
* @defgroup os_priority os_priority
|
||||
* Redefinition from enum osPriority
|
||||
* @{
|
||||
*/
|
||||
/** priority: idle (lowest) */
|
||||
#define OS_PRIORITY_IDLE (-3)
|
||||
/** priority: low */
|
||||
#define OS_PRIORITY_LOW (-2)
|
||||
/** priority: below normal */
|
||||
#define OS_PRIORITY_BELOW_NORMAL (-1)
|
||||
/** priority: normal (default) */
|
||||
#define OS_PRIORITY_NORMAL (0)
|
||||
/** priority: above normal */
|
||||
#define OS_PRIORITY_ABOVENORMAL (+1)
|
||||
/** priority: high */
|
||||
#define OS_PRIORITY_HIGH (+2)
|
||||
/** priority: realtime (highest) */
|
||||
#define OS_PRIORITY_REALTIME (+3)
|
||||
/** @} */ // end of group os_priority
|
||||
|
||||
#ifndef DEFAULT_STACK_SIZE
|
||||
/**
|
||||
* @ingroup wiring_os
|
||||
* @brief default stack size
|
||||
*
|
||||
* It is suggest that thread is assigned stack size more than DEFAULT_STACK_SIZE
|
||||
*/
|
||||
#define DEFAULT_STACK_SIZE 512
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup wiring_os
|
||||
* @struct os_event_t
|
||||
* Redefine osEvent in cmsis_os.h
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t status; ///< status code: event or error information
|
||||
|
||||
union {
|
||||
uint32_t v; ///< message as 32-bit value
|
||||
void *p; ///< message or mail as void pointer
|
||||
int32_t signals; ///< signal flags
|
||||
} value; ///< event value
|
||||
|
||||
union {
|
||||
void *mail_id; ///< mail id obtained by osMailCreate
|
||||
void *message_id; ///< message id obtained by osMessageCreate
|
||||
} def; ///< event definition
|
||||
} os_event_t;
|
||||
|
||||
/**
|
||||
* @defgroup thread_management thread_management
|
||||
* Thread management include create, get thread id, terminate, yield, and set/get priority
|
||||
**/
|
||||
|
||||
/**
|
||||
* @ingroup thread_management
|
||||
* @brief Create a thread and add it to Active Threads and set it to state READY.
|
||||
*
|
||||
* @param[in] task Function pointer which is the thread body. It should not run into the end of function unless
|
||||
* os_thread_terminate is invoked
|
||||
* @param[in] argument the data pointer which brings to task
|
||||
* @param[in] priority The underlying os is FreeRTOS. It executes tasks with highest priority which are not in idle
|
||||
* state.\n If there are more than 2 tasks to be executed, then they share the time slice.
|
||||
* @param[in] stack_size The stack_size is used as memory heap only for this task. \n
|
||||
* The local variables and call stacks would occupy this heap. Please make sure the the stack_size is big enough to
|
||||
* avoid curroption
|
||||
* @return The thread id which is used in thread operation and signaling.
|
||||
*/
|
||||
extern uint32_t os_thread_create(void (*task)(const void *argument), void *argument, int priority, uint32_t stack_size);
|
||||
|
||||
/**
|
||||
* @ingroup thread_management
|
||||
* @brief Return the thread ID of the current running thread.
|
||||
*
|
||||
* @return Current thread id which calls os_thread_get_id
|
||||
*/
|
||||
extern uint32_t os_thread_get_id(void);
|
||||
|
||||
/**
|
||||
* @ingroup thread_management
|
||||
* @brief Terminate execution of a thread and remove it from Active Threads.
|
||||
*
|
||||
* Thread should not ended without terminate first
|
||||
*
|
||||
* @param[in] thread_id Terminate the thread with specific thread_id
|
||||
* @return os_status code
|
||||
*/
|
||||
extern uint32_t os_thread_terminate(uint32_t thread_id);
|
||||
|
||||
/**
|
||||
* @ingroup thread_management
|
||||
* @brief Pass control to next thread that is in state \b READY.
|
||||
*
|
||||
* By default the minimal execution unit is 1 millisecond. In a scenario that if a thread with smaller want to handout
|
||||
* execution right to a thread with higher priority immediately without waiting for the ending of current 1 millisecond,
|
||||
* then invoke os_thread_yield can transfer exection right to OS's idle task and check which is the next execution
|
||||
* thread.
|
||||
*
|
||||
* @return os_status code
|
||||
*/
|
||||
extern uint32_t os_thread_yield(void);
|
||||
|
||||
/**
|
||||
* @ingroup thread_management
|
||||
* @brief Change priority of an active thread.
|
||||
*
|
||||
* @param[in] thread_id The target thread with the thread id to be changed
|
||||
* @param[in] priority The updated priority
|
||||
* @return os_status code
|
||||
*/
|
||||
extern uint32_t os_thread_set_priority(uint32_t thread_id, int priority);
|
||||
|
||||
/**
|
||||
* @ingroup thread_management
|
||||
* @brief Get current priority of an active thread.
|
||||
*
|
||||
* @param[in] thread_id The target thread with the thread id to be searched
|
||||
* @return os_priority
|
||||
*/
|
||||
extern int os_thread_get_priority(uint32_t thread_id);
|
||||
|
||||
/**
|
||||
* @defgroup signal_management signal_management
|
||||
* Signaling between threads include set, clear, and wait
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup signal_management
|
||||
* @brief Set the specified Signal Flags of an active thread.
|
||||
*
|
||||
* @param[in] thread_id Send signal to a thread with the thread id
|
||||
* @param[in] signals the signals to be send
|
||||
* @return os_status code
|
||||
*/
|
||||
extern int32_t os_signal_set(uint32_t thread_id, int32_t signals);
|
||||
|
||||
/**
|
||||
* @ingroup signal_management
|
||||
* @brief Clear the specified Signal Flags of an active thread.
|
||||
*
|
||||
* @param[in] thread_id Clear signal to a thread with the thread id
|
||||
* @param[in] signals The signals to be clear
|
||||
* @return os_status code
|
||||
*/
|
||||
extern int32_t os_signal_clear(uint32_t thread_id, int32_t signals);
|
||||
|
||||
/**
|
||||
* @ingroup signal_management
|
||||
* @brief Wait for one or more Signal Flags to become signaled for the current \b RUNNING thread.
|
||||
*
|
||||
* @param[in] signals the signals to be wait
|
||||
* @param[in] millisec the timeout value if no signal comes in. Fill in 0xFFFFFFFF for infinite wait.
|
||||
* @return os_status code
|
||||
*/
|
||||
extern os_event_t os_signal_wait(int32_t signals, uint32_t millisec);
|
||||
|
||||
/**
|
||||
* @defgroup timer_management timer_management
|
||||
* Software timer management include create, start, stop, delete.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup timer_management
|
||||
* @brief specify timer type that invoke only once
|
||||
*/
|
||||
#define OS_TIMER_ONCE (0)
|
||||
|
||||
/**
|
||||
* @ingroup timer_management
|
||||
* @brief specify timer type that invoke periodically
|
||||
*/
|
||||
#define OS_TIMER_PERIODIC (1)
|
||||
|
||||
/**
|
||||
* @ingroup timer_management
|
||||
* @brief Create a timer.
|
||||
*
|
||||
* @param[in] callback The function to be invoke when timer timeout
|
||||
* @param[in] isPeriodic \b OS_TIMER_ONCE or \b OS_TIMER_PERIODIC
|
||||
* @param[in] argument The argument that is bring into callback function
|
||||
* @return timer id
|
||||
*/
|
||||
extern uint32_t os_timer_create(void (*callback)(const void *argument), uint8_t isPeriodic, void *argument);
|
||||
|
||||
/**
|
||||
* @ingroup timer_management
|
||||
* @brief Start or restart a timer.
|
||||
*
|
||||
* @param[in] timer_id The timer id obtained from by os_timer_create
|
||||
* @param[in] millisec The delays after timer starts
|
||||
* @return os_status code
|
||||
*/
|
||||
extern uint32_t os_timer_start(uint32_t timer_id, uint32_t millisec);
|
||||
|
||||
/**
|
||||
* @ingroup timer_management
|
||||
* @brief Stop the timer.
|
||||
*
|
||||
* @param[in] timer_id The timer id obtained from by os_timer_create
|
||||
* @return os_status code
|
||||
*/
|
||||
extern uint32_t os_timer_stop(uint32_t timer_id);
|
||||
|
||||
/**
|
||||
* @ingroup timer_management
|
||||
* @brief Delete a timer that was created by os_timer_create
|
||||
*
|
||||
* @param[in] timer_id The timer id obtained from by os_timer_create
|
||||
* @return os_status code
|
||||
*/
|
||||
extern uint32_t os_timer_delete(uint32_t timer_id);
|
||||
|
||||
/**
|
||||
* @defgroup semaphore_management semaphore_management
|
||||
* Semaphore API between threads include create, wait, release, delete.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup semaphore_management
|
||||
* @brief Create and Initialize a Semaphore object used for managing resources
|
||||
*
|
||||
* @param[in] count The number of available resources
|
||||
* @return semaphore ID
|
||||
*/
|
||||
extern uint32_t os_semaphore_create(int32_t count);
|
||||
|
||||
/**
|
||||
* @ingroup semaphore_management
|
||||
* @brief Wait until a Semaphore token becomes available
|
||||
*
|
||||
* @param[in] semaphore_id semaphore id obtained from os_semaphore_create
|
||||
* @param[in] millisec timeout value
|
||||
* @return os_status code
|
||||
*/
|
||||
extern int32_t os_semaphore_wait(uint32_t semaphore_id, uint32_t millisec);
|
||||
|
||||
/**
|
||||
* @ingroup semaphore_management
|
||||
* @brief Release a Semaphore token
|
||||
*
|
||||
* @param[in] semaphore_id semaphore id obtained from os_semaphore_create
|
||||
* @return os_status code
|
||||
*/
|
||||
extern uint32_t os_semaphore_release(uint32_t semaphore_id);
|
||||
|
||||
/**
|
||||
* @ingroup semaphore_management
|
||||
* @brief Delete a Semaphore that was created by os_semaphore_create.
|
||||
*
|
||||
* @param[in] semaphore_id semaphore id obtained from os_semaphore_create
|
||||
* @return os_status code
|
||||
*/
|
||||
extern uint32_t os_semaphore_delete(uint32_t semaphore_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,5 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-03. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#define LT_MD5_USE_POLARSSL 1
|
||||
@@ -1,58 +0,0 @@
|
||||
#include "PowerManagement.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#include <freertos_pmu.h>
|
||||
#include <sleep_ex_api.h>
|
||||
#include <sys_api.h>
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BOARD_RTL8195A)
|
||||
#define SAVE_LOCK_PIN 18
|
||||
#elif defined(BOARD_RTL8710)
|
||||
#define SAVE_LOCK_PIN 7 // PB_1
|
||||
#else
|
||||
#define SAVE_LOCK_PIN 18
|
||||
#endif
|
||||
|
||||
bool PowerManagementClass::reservePLL = true;
|
||||
|
||||
void PowerManagementClass::sleep(uint32_t bitflg) {
|
||||
if (!safeLock()) {
|
||||
pmu_release_wakelock(bitflg);
|
||||
}
|
||||
}
|
||||
|
||||
void PowerManagementClass::sleep(void) {
|
||||
if (!safeLock()) {
|
||||
pmu_release_wakelock(BIT(PMU_OS));
|
||||
}
|
||||
}
|
||||
|
||||
void PowerManagementClass::active(uint32_t bitflg) {
|
||||
pmu_acquire_wakelock(bitflg);
|
||||
}
|
||||
|
||||
void PowerManagementClass::active(void) {
|
||||
pmu_acquire_wakelock(BIT(PMU_OS));
|
||||
}
|
||||
|
||||
void PowerManagementClass::deepsleep(uint32_t duration_ms) {
|
||||
if (!safeLock()) {
|
||||
deepsleep_ex(DSLEEP_WAKEUP_BY_TIMER, duration_ms);
|
||||
}
|
||||
}
|
||||
|
||||
bool PowerManagementClass::safeLock() {
|
||||
pinMode(SAVE_LOCK_PIN, INPUT_PULLUP);
|
||||
return (digitalRead(SAVE_LOCK_PIN) == 1) ? false : true;
|
||||
}
|
||||
|
||||
void PowerManagementClass::softReset() {
|
||||
sys_reset();
|
||||
}
|
||||
|
||||
PowerManagementClass PowerManagement;
|
||||
@@ -1,73 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
/**
|
||||
* @class PowerManagementClass PowerManagement.h
|
||||
* @brief Power management in Ameba
|
||||
*/
|
||||
class PowerManagementClass {
|
||||
public:
|
||||
/**
|
||||
* @brief Allow OS automatically save power while idle
|
||||
*
|
||||
* As OS consider it would idle for more than 2s, it will invoke system suspend.
|
||||
* If wlan is associated with AP, than it will under asslociated idle state.
|
||||
*/
|
||||
static void sleep(void);
|
||||
static void sleep(uint32_t bitflg);
|
||||
|
||||
/**
|
||||
* @brief Disallow OS automatically save power while idle
|
||||
*/
|
||||
static void active(void);
|
||||
static void active(uint32_t bitflg);
|
||||
|
||||
/**
|
||||
* @brief Reserved PLL while sleep
|
||||
*
|
||||
* Reserve PLL would keep FIFO of peripherals (Ex. UART) but cost more power (around 5mA).
|
||||
* If we don't reserve PLL, it saves more power but we might missing data because FIFO is turned of this way.
|
||||
*
|
||||
* @param[in] reserve true for reserved, false for non-reserved
|
||||
*/
|
||||
static void setPllReserved(bool reserve);
|
||||
|
||||
/**
|
||||
* @brief Enter deepsleep immediately
|
||||
*
|
||||
* Invoke deepsleep would make system enter deepsleep state immediately.
|
||||
* It's the state that saves most power.
|
||||
* As it wakeup from deepsleep, the system would behave just like reboot.
|
||||
*
|
||||
* @param[in] duration_ms wakeup after specific time in unit of millisecond
|
||||
*/
|
||||
static void deepsleep(uint32_t duration_ms);
|
||||
|
||||
/**
|
||||
* @brief Check if system is allowed enter any power save state
|
||||
*
|
||||
* The pin 18 (GPIOE_5) is designed as safe lock.
|
||||
* If pin 18 is HIGH, then we prevent Ameba enter any power save state.\n\n
|
||||
* Under any power save state, we are not able to flash image to Ameba.
|
||||
* Thus if user misuse deepsleep and make Ameba enter deepsleep immediately after boot up,
|
||||
* then he would find it's hard to flash image.
|
||||
* In this case, he can pull up pin 18.
|
||||
*
|
||||
* @return true if system not allowed enter any power save state, and false vise versa
|
||||
*/
|
||||
static bool safeLock();
|
||||
|
||||
/**
|
||||
* @brief Reboot system
|
||||
*
|
||||
* Reboot system in soft way. Some registers is not powered off in this case, but mostly we could regard this as
|
||||
* reboot.
|
||||
*/
|
||||
static void softReset();
|
||||
|
||||
private:
|
||||
static bool reservePLL;
|
||||
};
|
||||
|
||||
extern PowerManagementClass PowerManagement;
|
||||
@@ -1,5 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-07-03. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <api/SoftwareSerial.h>
|
||||
@@ -1,10 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-04-25. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <api/WiFi/WiFi.h>
|
||||
|
||||
#include "WiFiClient.h"
|
||||
#include "WiFiClientSecure.h"
|
||||
#include "WiFiServer.h"
|
||||
@@ -1,8 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-27. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <api/WiFi/WiFi.h>
|
||||
#include <lwip/LwIPClient.h>
|
||||
|
||||
typedef LwIPClient WiFiClient;
|
||||
@@ -1,8 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-05-04. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <api/WiFi/WiFi.h>
|
||||
#include <ssl/MbedTLSClient.h>
|
||||
|
||||
typedef MbedTLSClient WiFiClientSecure;
|
||||
@@ -1,18 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-23. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
#include <FreeRTOS.h>
|
||||
#include <semphr.h>
|
||||
|
||||
} // extern "C"
|
||||
|
||||
typedef struct {
|
||||
bool initialized;
|
||||
bool sleep;
|
||||
SemaphoreHandle_t scanSem;
|
||||
} WiFiData;
|
||||
@@ -1,107 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-04-25. */
|
||||
|
||||
#include "WiFiPriv.h"
|
||||
|
||||
int32_t WiFiClass::channel() {
|
||||
int channel = 0;
|
||||
wifi_get_channel(&channel);
|
||||
return channel;
|
||||
}
|
||||
|
||||
bool WiFiClass::modePriv(WiFiMode mode, WiFiModeAction sta, WiFiModeAction ap) {
|
||||
__wrap_rtl_printf_disable();
|
||||
__wrap_DiagPrintf_disable();
|
||||
startWifiTask();
|
||||
|
||||
if (!data.initialized) {
|
||||
// initialize wifi first
|
||||
LT_I("Initializing LwIP");
|
||||
LwIP_Init();
|
||||
reset_wifi_struct();
|
||||
data.initialized = true;
|
||||
}
|
||||
LT_HEAP_I();
|
||||
if (getMode()) {
|
||||
// stop wifi to change mode
|
||||
LT_D_WG("Stopping WiFi to change mode");
|
||||
if (wifi_off() != RTW_SUCCESS)
|
||||
goto error;
|
||||
vTaskDelay(20);
|
||||
if (mode == WIFI_MODE_NULL)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (wifi_on((rtw_mode_t)mode) != RTW_SUCCESS) {
|
||||
LT_E("Error while changing mode(%u)", mode);
|
||||
goto error;
|
||||
}
|
||||
|
||||
// send STA start/stop events and AP stop event (start is handled in softAP())
|
||||
if (sta == WLMODE_ENABLE) {
|
||||
wifi_indication(WIFI_EVENT_CONNECT, NULL, ARDUINO_EVENT_WIFI_STA_START, -2);
|
||||
} else if (sta == WLMODE_DISABLE) {
|
||||
wifi_indication(WIFI_EVENT_CONNECT, NULL, ARDUINO_EVENT_WIFI_STA_STOP, -2);
|
||||
}
|
||||
if (ap == WLMODE_DISABLE) {
|
||||
wifi_indication(WIFI_EVENT_CONNECT, NULL, ARDUINO_EVENT_WIFI_AP_STOP, -2);
|
||||
}
|
||||
|
||||
LT_HEAP_I();
|
||||
__wrap_rtl_printf_enable();
|
||||
__wrap_DiagPrintf_enable();
|
||||
return true;
|
||||
|
||||
error:
|
||||
__wrap_rtl_printf_enable();
|
||||
__wrap_DiagPrintf_enable();
|
||||
return false;
|
||||
}
|
||||
|
||||
WiFiMode WiFiClass::getMode() {
|
||||
if (!data.initialized)
|
||||
return WIFI_MODE_NULL;
|
||||
return (WiFiMode)wifi_mode;
|
||||
}
|
||||
|
||||
WiFiStatus WiFiClass::status() {
|
||||
if (wifi_is_connected_to_ap() == 0) {
|
||||
return WL_CONNECTED;
|
||||
} else {
|
||||
return WL_DISCONNECTED;
|
||||
}
|
||||
}
|
||||
|
||||
bool WiFiClass::setSleep(bool enable) {
|
||||
LT_D_WG("WiFi sleep mode %u", enable);
|
||||
if (enable)
|
||||
if (wifi_enable_powersave() != RTW_SUCCESS)
|
||||
return false;
|
||||
else if (wifi_disable_powersave() != RTW_SUCCESS)
|
||||
return false;
|
||||
data.sleep = enable;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WiFiClass::getSleep() {
|
||||
return data.sleep;
|
||||
}
|
||||
|
||||
bool WiFiClass::setTxPower(int power) {
|
||||
return false; // wifi_set_txpower(power) == RTW_SUCCESS;
|
||||
}
|
||||
|
||||
int WiFiClass::getTxPower() {
|
||||
return 0;
|
||||
int power = 0;
|
||||
wifi_get_txpower(&power);
|
||||
return power;
|
||||
}
|
||||
|
||||
IPAddress WiFiClass::hostByName(const char *hostname) {
|
||||
ip_addr_t ip;
|
||||
int ret = netconn_gethostbyname(hostname, &ip);
|
||||
if (ret == ERR_OK) {
|
||||
return ip.addr;
|
||||
}
|
||||
return IPAddress();
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-04-25. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <api/WiFi/WiFi.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
// copy defines from PIO builder (for IDE to understand)
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#define LWIP_NETIF_HOSTNAME 1
|
||||
#define LWIP_SO_RCVBUF 1
|
||||
|
||||
#include <FreeRTOS.h>
|
||||
#include <autoconf.h>
|
||||
#include <dhcp/dhcps.h>
|
||||
#include <lwip/api.h>
|
||||
#include <lwip/dns.h>
|
||||
#include <lwip/err.h>
|
||||
#include <lwip_netconf.h>
|
||||
#include <semphr.h>
|
||||
#include <wifi_conf.h>
|
||||
#include <wifi_constants.h>
|
||||
#include <wifi_structures.h>
|
||||
|
||||
extern struct netif xnetif[NET_IF_NUM];
|
||||
|
||||
} // extern "C"
|
||||
|
||||
// WiFi.cpp
|
||||
extern rtw_network_info_t wifi;
|
||||
extern rtw_ap_info_t ap;
|
||||
extern rtw_wifi_setting_t wifi_setting;
|
||||
extern unsigned char sta_password[65];
|
||||
extern unsigned char ap_password[65];
|
||||
extern void reset_wifi_struct(void);
|
||||
extern rtw_mode_t wifi_mode;
|
||||
extern WiFiAuthMode securityTypeToAuthMode(uint8_t type);
|
||||
// WiFiEvents.cpp
|
||||
extern void startWifiTask();
|
||||
extern void handleRtwEvent(uint16_t event, char *data, int len, int flags);
|
||||
|
||||
#define NETIF_RTW_STA &xnetif[RTW_STA_INTERFACE]
|
||||
#define NETIF_RTW_AP (wifi_mode == WIFI_MODE_APSTA ? &xnetif[RTW_AP_INTERFACE] : NETIF_RTW_STA)
|
||||
|
||||
#define NETNAME_STA WLAN0_NAME
|
||||
#define NETNAME_AP (wifi_mode == WIFI_MODE_APSTA ? WLAN1_NAME : WLAN0_NAME)
|
||||
@@ -1,8 +0,0 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-27. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <api/WiFi/WiFi.h>
|
||||
#include <lwip/LwIPServer.h>
|
||||
|
||||
typedef LwIPServer WiFiServer;
|
||||
@@ -1,7 +0,0 @@
|
||||
<!-- This file is auto-generated -->
|
||||
|
||||
- [BW12](../boards/bw12/README.md)
|
||||
- [CB2S Wi-Fi Module](../boards/cb2s/README.md)
|
||||
- [WB2L Wi-Fi Module](../boards/wb2l/README.md)
|
||||
- [WR3 Wi-Fi Module](../boards/wr3/README.md)
|
||||
- [Generic - Host-native](../boards/generic-native/README.md)
|
||||
@@ -1,24 +1,6 @@
|
||||
{
|
||||
"build": {
|
||||
"bkcrypt_coeffs": "510fb093a3cbeadc5993a17ec7adeb03",
|
||||
"bkboot_version": "1.0.1-bk7231n",
|
||||
"bkrbl_size_app": "0x107800"
|
||||
},
|
||||
"flash": {
|
||||
"bootloader": "0x000000+0x11000",
|
||||
"app": "0x011000+0x119000",
|
||||
"download": "0x12A000+0xA6000",
|
||||
"tlv": "0x1D0000+0x1000",
|
||||
"net": "0x1D1000+0x2000",
|
||||
"kvs": "0x1D3000+0x8000",
|
||||
"userdata": "0x1DB000+0x25000"
|
||||
},
|
||||
"upload": {
|
||||
"maximum_size": 1083136
|
||||
},
|
||||
"doc": {
|
||||
"extra": [
|
||||
"Bootloader and app partitions contain CRC16 sums every 32 bytes. That results in the actual flash offsets/sizes not aligned to sector boundaries. To simplify calculations, the values shown in the table (extracted from bootloader's partition table) were aligned to 4096 bytes."
|
||||
]
|
||||
"bkboot_version": "1.0.1-bk7231n"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,28 @@
|
||||
{
|
||||
"build": {
|
||||
"family": "BK7231N",
|
||||
"ldscript_sdk": "bk7231n_bsp.ld",
|
||||
"ldscript_arduino": "bk7231n_bsp.ld"
|
||||
"ldscript": "bk7231n_bsp.ld",
|
||||
"bkboot_version": "1.0.1-bk7231n",
|
||||
"bkoffset_app": "0x10000",
|
||||
"bkrbl_size_app": "0x108700"
|
||||
},
|
||||
"flash": {
|
||||
"bootloader": "0x000000+0x11000",
|
||||
"app": "0x011000+0x119000",
|
||||
"download": "0x12A000+0xA6000",
|
||||
"calibration": "0x1D0000+0x1000",
|
||||
"net": "0x1D1000+0x1000",
|
||||
"tlv": "0x1D2000+0x1000",
|
||||
"kvs": "0x1D3000+0x8000",
|
||||
"userdata": "0x1DB000+0x25000"
|
||||
},
|
||||
"upload": {
|
||||
"maximum_size": 1083136,
|
||||
"speed": 460800
|
||||
},
|
||||
"connectivity": [
|
||||
"ble"
|
||||
],
|
||||
"doc": {
|
||||
"params": {
|
||||
"extra": {
|
||||
|
||||
@@ -1,24 +1,6 @@
|
||||
{
|
||||
"build": {
|
||||
"bkcrypt_coeffs": "510fb093a3cbeadc5993a17ec7adeb03",
|
||||
"bkboot_version": "1.0.5-bk7231s",
|
||||
"bkrbl_size_app": "0x107800"
|
||||
},
|
||||
"flash": {
|
||||
"bootloader": "0x000000+0x11000",
|
||||
"app": "0x011000+0x121000",
|
||||
"download": "0x132000+0xA6000",
|
||||
"kvs": "0x1D8000+0x8000",
|
||||
"tlv": "0x1E0000+0x1000",
|
||||
"net": "0x1E1000+0x2000",
|
||||
"userdata": "0x1E3000+0x1D000"
|
||||
},
|
||||
"upload": {
|
||||
"maximum_size": 1083136
|
||||
},
|
||||
"doc": {
|
||||
"extra": [
|
||||
"Bootloader and app partitions contain CRC16 sums every 32 bytes. That results in the actual flash offsets/sizes not aligned to sector boundaries. To simplify calculations, the values shown in the table (extracted from bootloader's partition table) were aligned to 4096 bytes."
|
||||
]
|
||||
"bkboot_version": "1.0.5-bk7231s"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"build": {
|
||||
"family": "BK7231T",
|
||||
"ldscript_sdk": "bk7231_bsp.ld",
|
||||
"ldscript_arduino": "bk7231_bsp.ld"
|
||||
},
|
||||
"upload": {
|
||||
"speed": 921600
|
||||
},
|
||||
"doc": {
|
||||
"params": {
|
||||
"extra": {
|
||||
"Bluetooth": "BLE v4.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
boards/_base/beken-7231u.json
Normal file
33
boards/_base/beken-7231u.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"build": {
|
||||
"family": "BK7231U",
|
||||
"ldscript": "bk7231_bsp.ld",
|
||||
"bkboot_version": "1.0.8-bk7231u",
|
||||
"bkoffset_app": "0x10000",
|
||||
"bkrbl_size_app": "0x108700"
|
||||
},
|
||||
"flash": {
|
||||
"bootloader": "0x000000+0x11000",
|
||||
"app": "0x011000+0x121000",
|
||||
"download": "0x132000+0xA6000",
|
||||
"kvs": "0x1D8000+0x8000",
|
||||
"calibration": "0x1E0000+0x1000",
|
||||
"tlv": "0x1E1000+0x1000",
|
||||
"net": "0x1E2000+0x1000",
|
||||
"userdata": "0x1E3000+0x1D000"
|
||||
},
|
||||
"upload": {
|
||||
"maximum_size": 1083136,
|
||||
"speed": 921600
|
||||
},
|
||||
"connectivity": [
|
||||
"ble"
|
||||
],
|
||||
"doc": {
|
||||
"params": {
|
||||
"extra": {
|
||||
"Bluetooth": "BLE v4.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
40
boards/_base/beken-7252.json
Normal file
40
boards/_base/beken-7252.json
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"build": {
|
||||
"family": "BK7251",
|
||||
"f_cpu": "180000000L",
|
||||
"ldscript": "bk7231_bsp.ld",
|
||||
"bkboot_version": "0.1.3-bk7252",
|
||||
"bkoffset_app": "0x10000",
|
||||
"bkrbl_size_app": "0x1A0000"
|
||||
},
|
||||
"flash": {
|
||||
"bootloader": "0x000000+0x11000",
|
||||
"app": "0x011000+0x1BA000",
|
||||
"filesystem": "0x1CB000+0x119000",
|
||||
"kvs": "0x2E4000+0x8000",
|
||||
"download": "0x2EC000+0x112000",
|
||||
"calibration": "0x3FE000+0x1000",
|
||||
"tlv": "0x3FF000+0x1000"
|
||||
},
|
||||
"debug": {
|
||||
"gdb_init": [
|
||||
"mem 0x200000 0x400000 ro"
|
||||
]
|
||||
},
|
||||
"upload": {
|
||||
"maximum_ram_size": 524288,
|
||||
"flash_size": 4194304,
|
||||
"maximum_size": 1703936,
|
||||
"speed": 921600
|
||||
},
|
||||
"connectivity": [
|
||||
"ble"
|
||||
],
|
||||
"doc": {
|
||||
"params": {
|
||||
"extra": {
|
||||
"Bluetooth": "BLE v5.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,16 @@
|
||||
{
|
||||
"build": {
|
||||
"f_cpu": "120000000L",
|
||||
"prefix": "arm-none-eabi-"
|
||||
"prefix": "arm-none-eabi-",
|
||||
"bkota": {
|
||||
"encryption": "aes256",
|
||||
"compression": "gzip",
|
||||
"key": "0123456789ABCDEF0123456789ABCDEF",
|
||||
"iv": "0123456789ABCDEF"
|
||||
}
|
||||
},
|
||||
"connectivity": [
|
||||
"wifi",
|
||||
"ble"
|
||||
"wifi"
|
||||
],
|
||||
"debug": {
|
||||
"protocol": "openocd",
|
||||
@@ -17,10 +22,6 @@
|
||||
"mem 0x000000 0x200000 ro"
|
||||
]
|
||||
},
|
||||
"frameworks": [
|
||||
"beken-72xx-sdk",
|
||||
"beken-72xx-arduino"
|
||||
],
|
||||
"upload": {
|
||||
"maximum_ram_size": 262144,
|
||||
"flash_size": 2097152,
|
||||
@@ -41,8 +42,10 @@
|
||||
},
|
||||
"links": {
|
||||
"General info": "../../docs/platform/beken-72xx/README.md",
|
||||
"Flashing (Tuya manual)": "https://developer.tuya.com/en/docs/iot/burn-and-authorize-wb-series-modules?id=Ka78f4pttsytd",
|
||||
"BkWriter v1.6.0": "https://images.tuyacn.com/smart/bk_writer1.60/bk_writer1.60.exe"
|
||||
}
|
||||
"Flashing guide": "../../docs/platform/beken-72xx/flashing.md"
|
||||
},
|
||||
"extra": [
|
||||
"Bootloader and app partitions contain CRC16 sums every 32 bytes. That results in the actual flash offsets/sizes not aligned to sector boundaries. To simplify calculations, the values shown in the table (extracted from bootloader's partition table) were aligned to 4096 bytes."
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
7
boards/_base/generic.json
Normal file
7
boards/_base/generic.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"pcb": {
|
||||
"symbol": "GENERIC",
|
||||
"templates": [],
|
||||
"vars": {}
|
||||
}
|
||||
}
|
||||
186
boards/_base/ic/bk7231-qfn40.json
Normal file
186
boards/_base/ic/bk7231-qfn40.json
Normal file
@@ -0,0 +1,186 @@
|
||||
{
|
||||
"pcb": {
|
||||
"ic": {
|
||||
"10": {
|
||||
"C_NAME": "GPIO25",
|
||||
"GPIO": "P25",
|
||||
"IRQ": null,
|
||||
"USB": "DP"
|
||||
},
|
||||
"11": {
|
||||
"C_NAME": "GPIO33",
|
||||
"GPIO": "P33",
|
||||
"IRQ": null,
|
||||
"DVP": "PD1"
|
||||
},
|
||||
"12": {
|
||||
"C_NAME": "GPIO32",
|
||||
"GPIO": "P32",
|
||||
"IRQ": null,
|
||||
"DVP": "PD0"
|
||||
},
|
||||
"13": {
|
||||
"C_NAME": "GPIO29",
|
||||
"GPIO": "P29",
|
||||
"IRQ": null,
|
||||
"DVP": "PCLK"
|
||||
},
|
||||
"14": {
|
||||
"C_NAME": "GPIO27",
|
||||
"GPIO": "P27",
|
||||
"IRQ": null,
|
||||
"DVP": "MCLK"
|
||||
},
|
||||
"15": {
|
||||
"C_NAME": "GPIO30",
|
||||
"GPIO": "P30",
|
||||
"IRQ": null,
|
||||
"DVP": "HSYNC"
|
||||
},
|
||||
"16": {
|
||||
"C_NAME": "GPIO31",
|
||||
"GPIO": "P31",
|
||||
"IRQ": null,
|
||||
"DVP": "VSYNC"
|
||||
},
|
||||
"17": {
|
||||
"C_NAME": "GPIO34",
|
||||
"GPIO": "P34",
|
||||
"IRQ": null,
|
||||
"DVP": "PD2"
|
||||
},
|
||||
"18": {
|
||||
"C_NAME": "GPIO35",
|
||||
"GPIO": "P35",
|
||||
"IRQ": null,
|
||||
"DVP": "PD3"
|
||||
},
|
||||
"19": {
|
||||
"C_NAME": "GPIO36",
|
||||
"GPIO": "P36",
|
||||
"IRQ": null,
|
||||
"DVP": "PD4"
|
||||
},
|
||||
"20": {
|
||||
"C_NAME": "GPIO37",
|
||||
"GPIO": "P37",
|
||||
"IRQ": null,
|
||||
"DVP": "PD5"
|
||||
},
|
||||
"21": {
|
||||
"C_NAME": "GPIO38",
|
||||
"GPIO": "P38",
|
||||
"IRQ": null,
|
||||
"DVP": "PD6"
|
||||
},
|
||||
"22": {
|
||||
"C_NAME": "GPIO39",
|
||||
"GPIO": "P39",
|
||||
"IRQ": null,
|
||||
"DVP": "PD7"
|
||||
},
|
||||
"23": {
|
||||
"C_NAME": "GPIO14",
|
||||
"GPIO": "P14",
|
||||
"IRQ": null,
|
||||
"SD": "CLK",
|
||||
"SPI": "SCK"
|
||||
},
|
||||
"24": {
|
||||
"C_NAME": "GPIO16",
|
||||
"GPIO": "P16",
|
||||
"IRQ": null,
|
||||
"SD": "D0",
|
||||
"SPI": "MOSI"
|
||||
},
|
||||
"25": {
|
||||
"C_NAME": "GPIO15",
|
||||
"GPIO": "P15",
|
||||
"IRQ": null,
|
||||
"SD": "CMD",
|
||||
"SPI": "CS"
|
||||
},
|
||||
"26": {
|
||||
"C_NAME": "GPIO17",
|
||||
"GPIO": "P17",
|
||||
"IRQ": null,
|
||||
"SD": "D1",
|
||||
"SPI": "MISO"
|
||||
},
|
||||
"27": {
|
||||
"C_NAME": "GPIO23",
|
||||
"GPIO": "P23",
|
||||
"IRQ": null,
|
||||
"ADC": 3,
|
||||
"JTAG": "TDO",
|
||||
"FLASH": "FSO"
|
||||
},
|
||||
"28": {
|
||||
"C_NAME": "GPIO22",
|
||||
"GPIO": "P22",
|
||||
"IRQ": null,
|
||||
"JTAG": "TDI",
|
||||
"FLASH": "FSI"
|
||||
},
|
||||
"29": {
|
||||
"C_NAME": "GPIO21",
|
||||
"GPIO": "P21",
|
||||
"IRQ": null,
|
||||
"I2C": "1_SDA",
|
||||
"JTAG": "TMS",
|
||||
"I2S": "MCLK",
|
||||
"FLASH": "^FCS"
|
||||
},
|
||||
"30": {
|
||||
"C_NAME": "GPIO20",
|
||||
"GPIO": "P20",
|
||||
"IRQ": null,
|
||||
"I2C": "1_SCL",
|
||||
"JTAG": "TCK",
|
||||
"FLASH": "FSCK"
|
||||
},
|
||||
"31": {
|
||||
"IO": "I",
|
||||
"CTRL": "CEN"
|
||||
},
|
||||
"32": {
|
||||
"C_NAME": "GPIO8",
|
||||
"GPIO": "P8",
|
||||
"IRQ": null,
|
||||
"PWM": 2
|
||||
},
|
||||
"33": {
|
||||
"C_NAME": "GPIO9",
|
||||
"GPIO": "P9",
|
||||
"IRQ": null,
|
||||
"PWM": 3
|
||||
},
|
||||
"34": {
|
||||
"C_NAME": "GPIO10",
|
||||
"GPIO": "P10",
|
||||
"IRQ": null,
|
||||
"UART": "1_RX"
|
||||
},
|
||||
"35": {
|
||||
"C_NAME": "GPIO11",
|
||||
"GPIO": "P11",
|
||||
"IRQ": null,
|
||||
"UART": "1_TX"
|
||||
},
|
||||
"36": {
|
||||
"C_NAME": "GPIO1",
|
||||
"GPIO": "P1",
|
||||
"IRQ": null,
|
||||
"UART": "2_RX",
|
||||
"I2C": "2_SDA"
|
||||
},
|
||||
"37": {
|
||||
"C_NAME": "GPIO0",
|
||||
"GPIO": "P0",
|
||||
"IRQ": null,
|
||||
"UART": "2_TX",
|
||||
"I2C": "2_SCL"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
259
boards/_base/ic/bk7252-qfn68.json
Normal file
259
boards/_base/ic/bk7252-qfn68.json
Normal file
@@ -0,0 +1,259 @@
|
||||
{
|
||||
"pcb": {
|
||||
"ic": {
|
||||
"13": {
|
||||
"C_NAME": "GPIO28",
|
||||
"GPIO": "P28",
|
||||
"IRQ": null,
|
||||
"USB": "DN"
|
||||
},
|
||||
"14": {
|
||||
"C_NAME": "GPIO25",
|
||||
"GPIO": "P25",
|
||||
"IRQ": null,
|
||||
"USB": "DP"
|
||||
},
|
||||
"16": {
|
||||
"C_NAME": "GPIO12",
|
||||
"GPIO": "P12",
|
||||
"IRQ": null,
|
||||
"ADC": 6,
|
||||
"UART": "1_CTS"
|
||||
},
|
||||
"17": {
|
||||
"C_NAME": "GPIO13",
|
||||
"GPIO": "P13",
|
||||
"IRQ": null,
|
||||
"ADC": 7,
|
||||
"UART": "1_RTS"
|
||||
},
|
||||
"18": {
|
||||
"C_NAME": "GPIO33",
|
||||
"GPIO": "P33",
|
||||
"IRQ": null,
|
||||
"DVP": "PD1"
|
||||
},
|
||||
"19": {
|
||||
"C_NAME": "GPIO32",
|
||||
"GPIO": "P32",
|
||||
"IRQ": null,
|
||||
"DVP": "PD0"
|
||||
},
|
||||
"20": {
|
||||
"C_NAME": "GPIO29",
|
||||
"GPIO": "P29",
|
||||
"IRQ": null,
|
||||
"DVP": "PCLK"
|
||||
},
|
||||
"21": {
|
||||
"C_NAME": "GPIO27",
|
||||
"GPIO": "P27",
|
||||
"IRQ": null,
|
||||
"DVP": "MCLK"
|
||||
},
|
||||
"22": {
|
||||
"C_NAME": "GPIO30",
|
||||
"GPIO": "P30",
|
||||
"IRQ": null,
|
||||
"DVP": "HSYNC"
|
||||
},
|
||||
"23": {
|
||||
"C_NAME": "GPIO31",
|
||||
"GPIO": "P31",
|
||||
"IRQ": null,
|
||||
"DVP": "VSYNC"
|
||||
},
|
||||
"24": {
|
||||
"C_NAME": "GPIO34",
|
||||
"GPIO": "P34",
|
||||
"IRQ": null,
|
||||
"DVP": "PD2"
|
||||
},
|
||||
"25": {
|
||||
"C_NAME": "GPIO35",
|
||||
"GPIO": "P35",
|
||||
"IRQ": null,
|
||||
"DVP": "PD3"
|
||||
},
|
||||
"26": {
|
||||
"C_NAME": "GPIO36",
|
||||
"GPIO": "P36",
|
||||
"IRQ": null,
|
||||
"DVP": "PD4"
|
||||
},
|
||||
"27": {
|
||||
"C_NAME": "GPIO37",
|
||||
"GPIO": "P37",
|
||||
"IRQ": null,
|
||||
"DVP": "PD5"
|
||||
},
|
||||
"28": {
|
||||
"C_NAME": "GPIO38",
|
||||
"GPIO": "P38",
|
||||
"IRQ": null,
|
||||
"DVP": "PD6"
|
||||
},
|
||||
"29": {
|
||||
"C_NAME": "GPIO39",
|
||||
"GPIO": "P39",
|
||||
"IRQ": null,
|
||||
"DVP": "PD7"
|
||||
},
|
||||
"30": {
|
||||
"C_NAME": "GPIO19",
|
||||
"GPIO": "P19",
|
||||
"IRQ": null,
|
||||
"SD": "D1"
|
||||
},
|
||||
"31": {
|
||||
"C_NAME": "GPIO17",
|
||||
"GPIO": "P17",
|
||||
"IRQ": null,
|
||||
"SD": "D1",
|
||||
"SPI": "MISO"
|
||||
},
|
||||
"32": {
|
||||
"C_NAME": "GPIO14",
|
||||
"GPIO": "P14",
|
||||
"IRQ": null,
|
||||
"SD": "CLK",
|
||||
"SPI": "SCK"
|
||||
},
|
||||
"33": {
|
||||
"C_NAME": "GPIO16",
|
||||
"GPIO": "P16",
|
||||
"IRQ": null,
|
||||
"SD": "D0",
|
||||
"SPI": "MOSI"
|
||||
},
|
||||
"34": {
|
||||
"C_NAME": "GPIO15",
|
||||
"GPIO": "P15",
|
||||
"IRQ": null,
|
||||
"SD": "CMD",
|
||||
"SPI": "CS"
|
||||
},
|
||||
"35": {
|
||||
"C_NAME": "GPIO18",
|
||||
"GPIO": "P18",
|
||||
"IRQ": null,
|
||||
"SD": "D2"
|
||||
},
|
||||
"36": {
|
||||
"C_NAME": "GPIO24",
|
||||
"GPIO": "P24",
|
||||
"IRQ": null,
|
||||
"PWM": 4
|
||||
},
|
||||
"37": {
|
||||
"C_NAME": "GPIO26",
|
||||
"GPIO": "P26",
|
||||
"IRQ": null,
|
||||
"PWM": 5,
|
||||
"IRDA": null
|
||||
},
|
||||
"38": {
|
||||
"C_NAME": "GPIO23",
|
||||
"GPIO": "P23",
|
||||
"IRQ": null,
|
||||
"ADC": 3,
|
||||
"JTAG": "TDO",
|
||||
"FLASH": "FSO"
|
||||
},
|
||||
"39": {
|
||||
"C_NAME": "GPIO22",
|
||||
"GPIO": "P22",
|
||||
"IRQ": null,
|
||||
"JTAG": "TDI",
|
||||
"FLASH": "FSI"
|
||||
},
|
||||
"40": {
|
||||
"C_NAME": "GPIO21",
|
||||
"GPIO": "P21",
|
||||
"IRQ": null,
|
||||
"I2C": "1_SDA",
|
||||
"JTAG": "TMS",
|
||||
"I2S": "MCLK",
|
||||
"FLASH": "^FCS"
|
||||
},
|
||||
"41": {
|
||||
"C_NAME": "GPIO20",
|
||||
"GPIO": "P20",
|
||||
"IRQ": null,
|
||||
"I2C": "1_SCL",
|
||||
"JTAG": "TCK",
|
||||
"FLASH": "FSCK"
|
||||
},
|
||||
"43": {
|
||||
"IO": "I",
|
||||
"CTRL": "CEN"
|
||||
},
|
||||
"45": {
|
||||
"C_NAME": "GPIO5",
|
||||
"GPIO": "P5",
|
||||
"IRQ": null,
|
||||
"ADC": 2,
|
||||
"I2S": "DOUT"
|
||||
},
|
||||
"46": {
|
||||
"C_NAME": "GPIO3",
|
||||
"GPIO": "P3",
|
||||
"IRQ": null,
|
||||
"ADC": 5,
|
||||
"I2S": "WS"
|
||||
},
|
||||
"47": {
|
||||
"C_NAME": "GPIO4",
|
||||
"GPIO": "P4",
|
||||
"IRQ": null,
|
||||
"ADC": 1,
|
||||
"I2S": "DIN"
|
||||
},
|
||||
"48": {
|
||||
"C_NAME": "GPIO2",
|
||||
"GPIO": "P2",
|
||||
"IRQ": null,
|
||||
"ADC": 4,
|
||||
"I2S": "SCK"
|
||||
},
|
||||
"49": {
|
||||
"C_NAME": "GPIO6",
|
||||
"GPIO": "P6",
|
||||
"IRQ": null,
|
||||
"PWM": 0
|
||||
},
|
||||
"50": {
|
||||
"C_NAME": "GPIO7",
|
||||
"GPIO": "P7",
|
||||
"IRQ": null,
|
||||
"PWM": 1
|
||||
},
|
||||
"62": {
|
||||
"C_NAME": "GPIO10",
|
||||
"GPIO": "P10",
|
||||
"IRQ": null,
|
||||
"UART": "1_RX"
|
||||
},
|
||||
"63": {
|
||||
"C_NAME": "GPIO11",
|
||||
"GPIO": "P11",
|
||||
"IRQ": null,
|
||||
"UART": "1_TX"
|
||||
},
|
||||
"64": {
|
||||
"C_NAME": "GPIO1",
|
||||
"GPIO": "P1",
|
||||
"IRQ": null,
|
||||
"UART": "2_RX",
|
||||
"I2C": "2_SDA"
|
||||
},
|
||||
"65": {
|
||||
"C_NAME": "GPIO0",
|
||||
"GPIO": "P0",
|
||||
"IRQ": null,
|
||||
"UART": "2_TX",
|
||||
"I2C": "2_SCL"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,6 +92,7 @@
|
||||
},
|
||||
"27": {
|
||||
"C_NAME": "AD_2",
|
||||
"GPIONUM": 41,
|
||||
"IO": "I",
|
||||
"ADC": 2
|
||||
},
|
||||
186
boards/_base/ic/rtl8720cf.json
Normal file
186
boards/_base/ic/rtl8720cf.json
Normal file
@@ -0,0 +1,186 @@
|
||||
{
|
||||
"pcb": {
|
||||
"ic": {
|
||||
"1": {
|
||||
"C_NAME": "PIN_A20",
|
||||
"GPIO": "PA20",
|
||||
"IRQ": null,
|
||||
"SD": "D1",
|
||||
"SPI":
|
||||
"0_MISO"
|
||||
,
|
||||
"UART": "2_RTS",
|
||||
"I2C": "0_SDA",
|
||||
"PWM": 0
|
||||
},
|
||||
"3": {
|
||||
"C_NAME": "PIN_A23",
|
||||
"GPIO": "PA23",
|
||||
"IRQ": null,
|
||||
"PWM": 7
|
||||
},
|
||||
"14": {
|
||||
"IO": "I",
|
||||
"CTRL": "CEN"
|
||||
},
|
||||
"15": {
|
||||
"C_NAME": "PIN_A0",
|
||||
"GPIO": "PA00",
|
||||
"IRQ": null,
|
||||
"JTAG": "TCK",
|
||||
"UART": "1_RX",
|
||||
"PWM": 0,
|
||||
"SWD": "CLK"
|
||||
},
|
||||
"16": {
|
||||
"C_NAME": "PIN_A1",
|
||||
"GPIO": "PA01",
|
||||
"IRQ": null,
|
||||
"JTAG": "TMS",
|
||||
"UART": "1_TX",
|
||||
"PWM": 1,
|
||||
"SWD": "DIO"
|
||||
},
|
||||
"18": {
|
||||
"C_NAME": "PIN_A2",
|
||||
"GPIO": "PA02",
|
||||
"IRQ": null,
|
||||
"JTAG": "TDO",
|
||||
"UART": "1_RX",
|
||||
"SPI": "0_CS",
|
||||
"I2C": "0_SCL",
|
||||
"PWM": 2
|
||||
},
|
||||
"19": {
|
||||
"C_NAME": "PIN_A3",
|
||||
"GPIO": "PA03",
|
||||
"IRQ": null,
|
||||
"JTAG": "TDI",
|
||||
"UART": "1_TX",
|
||||
"SPI": "0_SCK",
|
||||
"I2C": "0_SDA",
|
||||
"PWM": 3
|
||||
},
|
||||
"20": {
|
||||
"C_NAME": "PIN_A4",
|
||||
"GPIO": "PA04",
|
||||
"IRQ": null,
|
||||
"JTAG": "tRST",
|
||||
"UART": "1_CTS",
|
||||
"SPI": "0_MOSI",
|
||||
"PWM": 4
|
||||
},
|
||||
"21": {
|
||||
"C_NAME": "PIN_A7",
|
||||
"GPIO": "PA07",
|
||||
"IRQ": null,
|
||||
"FLASH": "^FCS",
|
||||
"SPI": "0_CS"
|
||||
},
|
||||
"22": {
|
||||
"C_NAME": "PIN_A8",
|
||||
"GPIO": "PA08",
|
||||
"IRQ": null,
|
||||
"FLASH": "FSCK",
|
||||
"SPI": "0_SCK"
|
||||
},
|
||||
"23": {
|
||||
"C_NAME": "PIN_A9",
|
||||
"GPIO": "PA09",
|
||||
"IRQ": null,
|
||||
"FLASH": "FD2",
|
||||
"SPI": "0_MOSI",
|
||||
"UART": "0_RTS"
|
||||
},
|
||||
"24": {
|
||||
"C_NAME": "PIN_A10",
|
||||
"GPIO": "PA10",
|
||||
"IRQ": null,
|
||||
"FLASH": "FD1",
|
||||
"SPI": "0_MISO",
|
||||
"UART": "0_CTS"
|
||||
},
|
||||
"25": {
|
||||
"C_NAME": "PIN_A11",
|
||||
"GPIO": "PA11",
|
||||
"IRQ": null,
|
||||
"FLASH": "FD0",
|
||||
"UART": "0_TX",
|
||||
"I2C": "0_SCL",
|
||||
"PWM": 0
|
||||
},
|
||||
"26": {
|
||||
"C_NAME": "PIN_A12",
|
||||
"GPIO": "PA12",
|
||||
"IRQ": null,
|
||||
"FLASH": "FD3",
|
||||
"UART": "0_RX",
|
||||
"I2C": "0_SDA",
|
||||
"PWM": 1
|
||||
},
|
||||
"30": {
|
||||
"IO": "I",
|
||||
"C_NAME": "VBAT_IN"
|
||||
},
|
||||
"33": {
|
||||
"C_NAME": "PIN_A13",
|
||||
"GPIO": "PA13",
|
||||
"IRQ": null,
|
||||
"UART": "0_RX",
|
||||
"PWM": 7
|
||||
},
|
||||
"34": {
|
||||
"C_NAME": "PIN_A14",
|
||||
"GPIO": "PA14",
|
||||
"IRQ": null,
|
||||
"SD": "INT",
|
||||
"UART": "0_TX",
|
||||
"PWM": 2
|
||||
},
|
||||
"36": {
|
||||
"C_NAME": "PIN_A15",
|
||||
"GPIO": "PA15",
|
||||
"IRQ": null,
|
||||
"SD": "D2",
|
||||
"SPI": "0_CS",
|
||||
"UART": "2_RX",
|
||||
"I2C": "0_SCL",
|
||||
"PWM": 3
|
||||
},
|
||||
"37": {
|
||||
"C_NAME": "PIN_A16",
|
||||
"GPIO": "PA16",
|
||||
"IRQ": null,
|
||||
"SD": "D3",
|
||||
"SPI": "0_SCK",
|
||||
"UART": "2_TX",
|
||||
"I2C": "0_SDA",
|
||||
"PWM": 4
|
||||
},
|
||||
"38": {
|
||||
"C_NAME": "PIN_A17",
|
||||
"GPIO": "PA17",
|
||||
"IRQ": null,
|
||||
"SD": "CMD",
|
||||
"PWM": 5
|
||||
},
|
||||
"39": {
|
||||
"C_NAME": "PIN_A18",
|
||||
"GPIO": "PA18",
|
||||
"IRQ": null,
|
||||
"SD": "CLK",
|
||||
"PWM": 6
|
||||
},
|
||||
"40": {
|
||||
"C_NAME": "PIN_A19",
|
||||
"GPIO": "PA19",
|
||||
"IRQ": null,
|
||||
"SD": "D0",
|
||||
"SPI": "0_MOSI",
|
||||
"UART": "2_CTS",
|
||||
"I2C": "0_SCL",
|
||||
"PWM": 7
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
79
boards/_base/pcb/bw15.json
Normal file
79
boards/_base/pcb/bw15.json
Normal file
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"pcb": {
|
||||
"templates": [
|
||||
"esp12s",
|
||||
"esp12s-shield",
|
||||
"rf-16mm-type1"
|
||||
],
|
||||
"vars": {
|
||||
"MASK_PRESET": "mask_black",
|
||||
"TRACE_COLOR": "#FAFD9D",
|
||||
"SILK_COLOR": "white",
|
||||
"PINTYPE_VERT": "pin_vert_2mm_cast_nohole"
|
||||
},
|
||||
"pinout_hidden": "I2S,TRIG,WAKE,CTS,RTS,SD",
|
||||
"pinout": {
|
||||
"1": {
|
||||
"IC": 38,
|
||||
"ARD": "D0"
|
||||
},
|
||||
"2": {
|
||||
"IC": 39,
|
||||
"ARD": "D1"
|
||||
},
|
||||
"3": {
|
||||
"IC": 14
|
||||
},
|
||||
"4": {
|
||||
"IC": 18,
|
||||
"ARD": "D2"
|
||||
},
|
||||
"5": {
|
||||
"IC": 36,
|
||||
"ARD": "D3"
|
||||
},
|
||||
"6": {
|
||||
"IC": 20,
|
||||
"ARD": "D4"
|
||||
},
|
||||
"7": {
|
||||
"IC": 40,
|
||||
"ARD": "D5"
|
||||
},
|
||||
"8": {
|
||||
"PWR": 3.3
|
||||
},
|
||||
"9": {
|
||||
"GND": null
|
||||
},
|
||||
"10": {
|
||||
"IC": 1,
|
||||
"ARD": "D6"
|
||||
},
|
||||
"11": {
|
||||
"IC": 37,
|
||||
"ARD": "D7"
|
||||
},
|
||||
"12": {
|
||||
"IC": 15,
|
||||
"ARD": "D8"
|
||||
},
|
||||
"13": {
|
||||
"IC": 19,
|
||||
"ARD": "D9"
|
||||
},
|
||||
"14": {
|
||||
"IC": 16,
|
||||
"ARD": "D10"
|
||||
},
|
||||
"15": {
|
||||
"IC": 33,
|
||||
"ARD": "D11"
|
||||
},
|
||||
"16": {
|
||||
"IC": 34,
|
||||
"ARD": "D12"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
boards/_base/pcb/cb2l-test.json
Normal file
120
boards/_base/pcb/cb2l-test.json
Normal file
@@ -0,0 +1,120 @@
|
||||
{
|
||||
"pcb": {
|
||||
"scale": 11,
|
||||
"test_pads": {
|
||||
"TRST": "cb2l.back.rst.anchor",
|
||||
"TRX1": "cb2l.back.u1_rxd.anchor",
|
||||
"TTX1": "cb2l.back.u1_txd.anchor",
|
||||
"TTX2": "cb2l.back.u2_txd.anchor",
|
||||
"TGND": "cb2l.back.gnd.anchor",
|
||||
"TCSN": "cb2l.back.f_csn.anchor"
|
||||
},
|
||||
"back": [
|
||||
{
|
||||
"type": "rect",
|
||||
"pos": "0,0",
|
||||
"size": "15,17.3",
|
||||
"preset": "${MASK_PRESET}"
|
||||
},
|
||||
{
|
||||
"name": "pins_horz7_2mm_0.7mm",
|
||||
"pos": "1.15,17.3",
|
||||
"vars": {
|
||||
"PINTYPE": "${PINTYPE_HORZ}",
|
||||
"PINDIR": "down"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "test_pad_1mm",
|
||||
"pos": "1.5,7.5"
|
||||
},
|
||||
{
|
||||
"name": "label_line_2mm_down",
|
||||
"pos": "0.4,4.7",
|
||||
"vars": {
|
||||
"DIR": "right",
|
||||
"W": 0.2,
|
||||
"H": 2.7
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "u1_rxd.anchor",
|
||||
"type": "rect",
|
||||
"pos": "0.9,5.0",
|
||||
"size": "0,0",
|
||||
"label_dir": "left",
|
||||
"label_size": 2
|
||||
},
|
||||
{
|
||||
"name": "test_pad_1mm",
|
||||
"pos": "2.2,5.9"
|
||||
},
|
||||
{
|
||||
"id": "u2_txd",
|
||||
"name": "label_line_2mm_up",
|
||||
"pos": "2.2,5.1",
|
||||
"vars": {
|
||||
"DIR": "left",
|
||||
"W": 1.5,
|
||||
"H": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "test_pad_1mm",
|
||||
"pos": "4.0,5.9"
|
||||
},
|
||||
{
|
||||
"id": "u1_txd",
|
||||
"name": "label_line_2mm_up",
|
||||
"pos": "4.0,5.1",
|
||||
"vars": {
|
||||
"DIR": "left",
|
||||
"W": 3.3,
|
||||
"H": 4
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "test_pad_1mm",
|
||||
"pos": "9.2,5.9"
|
||||
},
|
||||
{
|
||||
"id": "gnd",
|
||||
"name": "label_line_2mm_up",
|
||||
"pos": "9.2,5.1",
|
||||
"vars": {
|
||||
"DIR": "left",
|
||||
"W": 8.5,
|
||||
"H": 6
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "test_pad_1mm",
|
||||
"pos": "2.2,10.7"
|
||||
},
|
||||
{
|
||||
"id": "rst",
|
||||
"name": "label_line_2mm_up",
|
||||
"pos": "2.2,9.9",
|
||||
"vars": {
|
||||
"DIR": "left",
|
||||
"W": 1.5,
|
||||
"H": 1.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "test_pad_1mm",
|
||||
"pos": "2.2,12.0"
|
||||
},
|
||||
{
|
||||
"id": "f_csn",
|
||||
"name": "label_line_2mm_down",
|
||||
"pos": "2.2,12.8",
|
||||
"vars": {
|
||||
"DIR": "left",
|
||||
"W": 1.5,
|
||||
"H": 1.0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
66
boards/_base/pcb/cb2l.json
Normal file
66
boards/_base/pcb/cb2l.json
Normal file
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"pcb": {
|
||||
"templates": [
|
||||
"tuya2l",
|
||||
"rf-15mm-type1",
|
||||
"tuya2l-shield"
|
||||
],
|
||||
"vars": {
|
||||
"MASK_PRESET": "mask_white",
|
||||
"TRACE_COLOR": "#E0E0E0",
|
||||
"SILK_COLOR": "black",
|
||||
"PINTYPE_HORZ": "pin_horz_2mm_cast_hole"
|
||||
},
|
||||
"pinout_hidden": "I2S,I2C,JTAG,FLASH",
|
||||
"pinout": {
|
||||
"1": {
|
||||
"IC": 24,
|
||||
"ARD": "D0"
|
||||
},
|
||||
"2": {
|
||||
"IC": 23,
|
||||
"ARD": "D1"
|
||||
},
|
||||
"3": {
|
||||
"IC": 22,
|
||||
"ARD": "D2"
|
||||
},
|
||||
"4": {
|
||||
"IC": 15,
|
||||
"ARD": "D3"
|
||||
},
|
||||
"5": {
|
||||
"IC": 16,
|
||||
"ARD": "D4"
|
||||
},
|
||||
"6": {
|
||||
"GND": null
|
||||
},
|
||||
"7": {
|
||||
"PWR": 3.3
|
||||
},
|
||||
"TGND": {
|
||||
"GND": null
|
||||
},
|
||||
"TRST": {
|
||||
"CTRL": "CEN"
|
||||
},
|
||||
"TRX1": {
|
||||
"IC": 26,
|
||||
"ARD": "D5"
|
||||
},
|
||||
"TTX2": {
|
||||
"IC": 29,
|
||||
"ARD": "D6"
|
||||
},
|
||||
"TTX1": {
|
||||
"IC": 27,
|
||||
"ARD": "D7"
|
||||
},
|
||||
"TCSN": {
|
||||
"IC": 19,
|
||||
"ARD": "D8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,7 @@
|
||||
"vars": {
|
||||
"MASK_PRESET": "mask_blue_light",
|
||||
"TRACE_COLOR": "#58839B",
|
||||
"SILK_COLOR": "white",
|
||||
"PINTYPE_HORZ": "pin_horz_2mm_cast_hole"
|
||||
"SILK_COLOR": "white"
|
||||
},
|
||||
"pinout_hidden": "I2S,JTAG,FLASH",
|
||||
"pinout": {
|
||||
|
||||
83
boards/_base/pcb/cb3l.json
Normal file
83
boards/_base/pcb/cb3l.json
Normal file
@@ -0,0 +1,83 @@
|
||||
{
|
||||
"pcb": {
|
||||
"templates": [
|
||||
"esp12s",
|
||||
"esp12e-shield",
|
||||
"tuya-16x24",
|
||||
"rf-16mm-type1"
|
||||
],
|
||||
"vars": {
|
||||
"MASK_PRESET": "mask_blue_light",
|
||||
"TRACE_COLOR": "#58839B",
|
||||
"SILK_COLOR": "white",
|
||||
"PINTYPE_VERT": "pin_vert_2mm_cast_hole",
|
||||
"PINTYPE_HORZ": "pin_horz_2mm_cast_hole"
|
||||
},
|
||||
"pinout_hidden": "I2S,SD,SPI,I2C,JTAG,FLASH",
|
||||
"pinout": {
|
||||
"1": {
|
||||
"IC": 21
|
||||
},
|
||||
"2": {
|
||||
"IC": 17,
|
||||
"ARD": [
|
||||
"D0",
|
||||
"A0"
|
||||
]
|
||||
},
|
||||
"3": {
|
||||
"IC": 21
|
||||
},
|
||||
"4": {
|
||||
"IC": 11,
|
||||
"ARD": "D1"
|
||||
},
|
||||
"5": {
|
||||
"IC": 15,
|
||||
"ARD": "D2"
|
||||
},
|
||||
"6": {
|
||||
"IC": 16,
|
||||
"ARD": "D3"
|
||||
},
|
||||
"7": {
|
||||
"IC": 22,
|
||||
"ARD": "D4"
|
||||
},
|
||||
"8": {
|
||||
"PWR": 3.3
|
||||
},
|
||||
"9": {
|
||||
"GND": null
|
||||
},
|
||||
"10": {
|
||||
"IC": 25,
|
||||
"ARD": "D5"
|
||||
},
|
||||
"11": {
|
||||
"IC": 29,
|
||||
"ARD": "D6"
|
||||
},
|
||||
"12": {
|
||||
"IC": 19,
|
||||
"ARD": "D7"
|
||||
},
|
||||
"13": {
|
||||
"IC": 24,
|
||||
"ARD": "D8"
|
||||
},
|
||||
"14": {
|
||||
"IC": 23,
|
||||
"ARD": "D9"
|
||||
},
|
||||
"15": {
|
||||
"IC": 26,
|
||||
"ARD": "D10"
|
||||
},
|
||||
"16": {
|
||||
"IC": 27,
|
||||
"ARD": "D11"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
108
boards/_base/pcb/cb3s.json
Normal file
108
boards/_base/pcb/cb3s.json
Normal file
@@ -0,0 +1,108 @@
|
||||
{
|
||||
"pcb": {
|
||||
"templates": [
|
||||
"esp12e-22",
|
||||
"esp12e-shield-nohole",
|
||||
"tuya-16x24",
|
||||
"rf-16mm-type1"
|
||||
],
|
||||
"vars": {
|
||||
"MASK_PRESET": "mask_blue_light",
|
||||
"TRACE_COLOR": "#58839B",
|
||||
"SILK_COLOR": "white",
|
||||
"PINTYPE_VERT": "pin_vert_2mm_cast_nohole",
|
||||
"PINTYPE_HORZ": "pin_horz_2mm_cast_nohole"
|
||||
},
|
||||
"pinout_hidden": "I2S,SD,SPI,SCL2",
|
||||
"pinout": {
|
||||
"1": {
|
||||
"IC": 21
|
||||
},
|
||||
"2": {
|
||||
"IC": 17,
|
||||
"ARD": [
|
||||
"D0",
|
||||
"A0"
|
||||
]
|
||||
},
|
||||
"3": {
|
||||
"IC": 21
|
||||
},
|
||||
"4": {
|
||||
"IC": 11,
|
||||
"ARD": "D1"
|
||||
},
|
||||
"5": {
|
||||
"IC": 15,
|
||||
"ARD": "D2"
|
||||
},
|
||||
"6": {
|
||||
"IC": 16,
|
||||
"ARD": "D3"
|
||||
},
|
||||
"7": {
|
||||
"IC": 22,
|
||||
"ARD": "D4"
|
||||
},
|
||||
"8": {
|
||||
"PWR": 3.3
|
||||
},
|
||||
"9": {
|
||||
"GND": null
|
||||
},
|
||||
"10": {
|
||||
"IC": 25,
|
||||
"ARD": "D5"
|
||||
},
|
||||
"11": {
|
||||
"IC": 29,
|
||||
"ARD": "D6"
|
||||
},
|
||||
"12": {
|
||||
"IC": 19,
|
||||
"ARD": "D7"
|
||||
},
|
||||
"13": {
|
||||
"IC": 24,
|
||||
"ARD": "D8"
|
||||
},
|
||||
"14": {
|
||||
"IC": 23,
|
||||
"ARD": "D9"
|
||||
},
|
||||
"15": {
|
||||
"IC": 26,
|
||||
"ARD": "D10"
|
||||
},
|
||||
"16": {
|
||||
"IC": 27,
|
||||
"ARD": "D11"
|
||||
},
|
||||
"17": {
|
||||
"IC": 17,
|
||||
"ARD": [
|
||||
"D0",
|
||||
"A0"
|
||||
]
|
||||
},
|
||||
"18": {
|
||||
"IC": 18,
|
||||
"ARD": "D12"
|
||||
},
|
||||
"19": {
|
||||
"IC": 19,
|
||||
"ARD": "D7"
|
||||
},
|
||||
"20": {
|
||||
"IC": 20,
|
||||
"ARD": "D13"
|
||||
},
|
||||
"21": {
|
||||
"NC": null
|
||||
},
|
||||
"22": {
|
||||
"NC": null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
106
boards/_base/pcb/cb3se.json
Normal file
106
boards/_base/pcb/cb3se.json
Normal file
@@ -0,0 +1,106 @@
|
||||
{
|
||||
"pcb": {
|
||||
"templates": [
|
||||
"esp12e-22",
|
||||
"esp12e-shield-nohole",
|
||||
"tuya-16x24",
|
||||
"rf-16mm-type1"
|
||||
],
|
||||
"vars": {
|
||||
"MASK_PRESET": "mask_blue_light",
|
||||
"TRACE_COLOR": "#58839B",
|
||||
"SILK_COLOR": "white",
|
||||
"PINTYPE_VERT": "pin_vert_2mm_cast_nohole",
|
||||
"PINTYPE_HORZ": "pin_horz_2mm_cast_nohole"
|
||||
},
|
||||
"pinout_hidden": "I2S,SD,JTAG,FLASH,SCL1",
|
||||
"pinout": {
|
||||
"1": {
|
||||
"IC": 21
|
||||
},
|
||||
"2": {
|
||||
"IC": 17,
|
||||
"ARD": [
|
||||
"D0",
|
||||
"A0"
|
||||
]
|
||||
},
|
||||
"3": {
|
||||
"IC": 21
|
||||
},
|
||||
"4": {
|
||||
"IC": 11,
|
||||
"ARD": "D1"
|
||||
},
|
||||
"5": {
|
||||
"IC": 15,
|
||||
"ARD": "D2"
|
||||
},
|
||||
"6": {
|
||||
"IC": 16,
|
||||
"ARD": "D3"
|
||||
},
|
||||
"7": {
|
||||
"IC": 22,
|
||||
"ARD": "D4"
|
||||
},
|
||||
"8": {
|
||||
"PWR": 3.3
|
||||
},
|
||||
"9": {
|
||||
"GND": null
|
||||
},
|
||||
"10": {
|
||||
"IC": 25,
|
||||
"ARD": "D5"
|
||||
},
|
||||
"11": {
|
||||
"IC": 29,
|
||||
"ARD": "D6"
|
||||
},
|
||||
"12": {
|
||||
"IC": 28,
|
||||
"ARD": "D7"
|
||||
},
|
||||
"13": {
|
||||
"IC": 24,
|
||||
"ARD": "D8"
|
||||
},
|
||||
"14": {
|
||||
"IC": 23,
|
||||
"ARD": "D9"
|
||||
},
|
||||
"15": {
|
||||
"IC": 26,
|
||||
"ARD": "D10"
|
||||
},
|
||||
"16": {
|
||||
"IC": 27,
|
||||
"ARD": "D11"
|
||||
},
|
||||
"17": {
|
||||
"IC": 13,
|
||||
"ARD": "D12"
|
||||
},
|
||||
"18": {
|
||||
"IC": 18,
|
||||
"ARD": "D13"
|
||||
},
|
||||
"19": {
|
||||
"GND": null
|
||||
},
|
||||
"20": {
|
||||
"IC": 20,
|
||||
"ARD": "D14"
|
||||
},
|
||||
"21": {
|
||||
"IC": 14,
|
||||
"ARD": "D15"
|
||||
},
|
||||
"22": {
|
||||
"IC": 12,
|
||||
"ARD": "D16"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
102
boards/_base/pcb/lsc-lma35.json
Normal file
102
boards/_base/pcb/lsc-lma35.json
Normal file
@@ -0,0 +1,102 @@
|
||||
{
|
||||
"pcb": {
|
||||
"templates": [
|
||||
"custom-20x24-22",
|
||||
"rf-20mm-type1"
|
||||
],
|
||||
"vars": {
|
||||
"MASK_PRESET": "mask_blue_light",
|
||||
"TRACE_COLOR": "#58839B",
|
||||
"SILK_COLOR": "white",
|
||||
"PINTYPE_VERT": "pin_vert_2mm_cast_nohole",
|
||||
"PINTYPE_HORZ": "pin_horz_2mm_cast_nohole"
|
||||
},
|
||||
"pinout_hidden": "I2S,JTAG,FLASH,SD,SPI,SDA1",
|
||||
"pinout": {
|
||||
"1": {
|
||||
"PWR": 3.3
|
||||
},
|
||||
"2": {
|
||||
"IC": 15,
|
||||
"ARD": "D0"
|
||||
},
|
||||
"3": {
|
||||
"IC": 11,
|
||||
"ARD": "D1"
|
||||
},
|
||||
"4": {
|
||||
"IC": 12,
|
||||
"ARD": "D2"
|
||||
},
|
||||
"5": {
|
||||
"IC": 16,
|
||||
"ARD": "D3"
|
||||
},
|
||||
"6": {
|
||||
"GND": null
|
||||
},
|
||||
"7": {
|
||||
"IC": 18,
|
||||
"ARD": "D4"
|
||||
},
|
||||
"8": {
|
||||
"IC": 29,
|
||||
"ARD": "D5"
|
||||
},
|
||||
"9": {
|
||||
"IC": 17,
|
||||
"ARD": [
|
||||
"D6",
|
||||
"A0"
|
||||
]
|
||||
},
|
||||
"10": {
|
||||
"CTRL": "?"
|
||||
},
|
||||
"11": {
|
||||
"GND": null
|
||||
},
|
||||
"12": {
|
||||
"IC": 24,
|
||||
"ARD": "D7"
|
||||
},
|
||||
"13": {
|
||||
"IC": 25,
|
||||
"ARD": "D8"
|
||||
},
|
||||
"14": {
|
||||
"GND": null
|
||||
},
|
||||
"15": {
|
||||
"IC": 19,
|
||||
"ARD": "D9"
|
||||
},
|
||||
"16": {
|
||||
"IC": 22,
|
||||
"ARD": "D10"
|
||||
},
|
||||
"17": {
|
||||
"IC": 23,
|
||||
"ARD": "D11"
|
||||
},
|
||||
"18": {
|
||||
"IC": 26,
|
||||
"ARD": "D12"
|
||||
},
|
||||
"19": {
|
||||
"GND": null
|
||||
},
|
||||
"20": {
|
||||
"IC": 27,
|
||||
"ARD": "D13"
|
||||
},
|
||||
"21": {
|
||||
"CTRL": "?"
|
||||
},
|
||||
"22": {
|
||||
"IC": 28,
|
||||
"ARD": "D14"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
158
boards/_base/pcb/wb2s-test.json
Normal file
158
boards/_base/pcb/wb2s-test.json
Normal file
@@ -0,0 +1,158 @@
|
||||
{
|
||||
"pcb": {
|
||||
"test_pads": {
|
||||
"TRST": "wb2s.back.cen.anchor",
|
||||
"TRX2": "wb2s.back.2rx.anchor",
|
||||
"TTX2": "wb2s.back.2tx.anchor",
|
||||
"TGND": "wb2s.back.gnd.anchor",
|
||||
"TSCK": "wb2s.back.sck.anchor",
|
||||
"TCSN": "wb2s.back.csn.anchor",
|
||||
"TSI": "wb2s.back.si.anchor",
|
||||
"TSO": "wb2s.back.adc_so.anchor",
|
||||
"TPWM3": "wb2s.back.pwm3.anchor",
|
||||
"TVCC": "wb2s.back.vbat.anchor"
|
||||
},
|
||||
"back": [
|
||||
{
|
||||
"name": "test_pad_1mm",
|
||||
"pos": "2.6,6.2"
|
||||
},
|
||||
{
|
||||
"id": "sck",
|
||||
"name": "label_line_2mm_up",
|
||||
"pos": "2.6,5.4",
|
||||
"vars": {
|
||||
"DIR": "left",
|
||||
"W": 1.3,
|
||||
"H": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "test_pad_1mm",
|
||||
"pos": "4.6,6.2"
|
||||
},
|
||||
{
|
||||
"id": "pwm3",
|
||||
"name": "label_line_2mm_up",
|
||||
"pos": "4.6,5.4",
|
||||
"vars": {
|
||||
"DIR": "left",
|
||||
"W": 3.3,
|
||||
"H": 4
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "test_pad_1mm",
|
||||
"pos": "7.0,6.2"
|
||||
},
|
||||
{
|
||||
"id": "2rx",
|
||||
"name": "label_line_2mm_up",
|
||||
"pos": "7.0,5.4",
|
||||
"vars": {
|
||||
"DIR": "right",
|
||||
"W": 2,
|
||||
"H": 4
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "test_pad_1mm",
|
||||
"pos": "9.0,6.2"
|
||||
},
|
||||
{
|
||||
"id": "2tx",
|
||||
"name": "label_line_2mm_up",
|
||||
"pos": "9.0,5.4",
|
||||
"vars": {
|
||||
"DIR": "right",
|
||||
"W": 0,
|
||||
"H": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "test_pad_1mm",
|
||||
"pos": "3.0,8.3"
|
||||
},
|
||||
{
|
||||
"id": "csn",
|
||||
"name": "label_line_2mm_up",
|
||||
"pos": "2.2,8.4",
|
||||
"vars": {
|
||||
"DIR": "left",
|
||||
"W": 0.9,
|
||||
"H": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "test_pad_1mm",
|
||||
"pos": "5.2,8.8"
|
||||
},
|
||||
{
|
||||
"id": "si",
|
||||
"name": "label_line_2mm_up",
|
||||
"pos": "6.0,8.9",
|
||||
"vars": {
|
||||
"DIR": "right",
|
||||
"W": 3,
|
||||
"H": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "test_pad_1mm",
|
||||
"pos": "2.1,11.6"
|
||||
},
|
||||
{
|
||||
"id": "adc_so",
|
||||
"name": "label_line_2mm_up",
|
||||
"pos": "1.3,11.7",
|
||||
"vars": {
|
||||
"DIR": "left",
|
||||
"W": 0,
|
||||
"H": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "test_pad_1mm",
|
||||
"pos": "4.3,11.6"
|
||||
},
|
||||
{
|
||||
"id": "cen",
|
||||
"name": "label_line_2mm_up",
|
||||
"pos": "5.1,11.7",
|
||||
"vars": {
|
||||
"DIR": "right",
|
||||
"W": 3.9,
|
||||
"H": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "test_pad_1mm",
|
||||
"pos": "2.5,14.5"
|
||||
},
|
||||
{
|
||||
"id": "vbat",
|
||||
"name": "label_line_2mm_up",
|
||||
"pos": "1.7,14.6",
|
||||
"vars": {
|
||||
"DIR": "left",
|
||||
"W": 0.4,
|
||||
"H": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "test_pad_1mm",
|
||||
"pos": "4.8,14.5"
|
||||
},
|
||||
{
|
||||
"id": "gnd",
|
||||
"name": "label_line_2mm_up",
|
||||
"pos": "5.6,14.6",
|
||||
"vars": {
|
||||
"DIR": "right",
|
||||
"W": 3.4,
|
||||
"H": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
102
boards/_base/pcb/wb2s.json
Normal file
102
boards/_base/pcb/wb2s.json
Normal file
@@ -0,0 +1,102 @@
|
||||
{
|
||||
"pcb": {
|
||||
"scale": 10.5,
|
||||
"templates": [
|
||||
"tuya2",
|
||||
"rf-15mm-type1",
|
||||
"tuya2-shield"
|
||||
],
|
||||
"vars": {
|
||||
"MASK_PRESET": "mask_blue_light",
|
||||
"TRACE_COLOR": "#58839B",
|
||||
"SILK_COLOR": "white"
|
||||
},
|
||||
"pinout_hidden": "I2S,FLASH",
|
||||
"pinout": {
|
||||
"1": {
|
||||
"PWR": 3.3
|
||||
},
|
||||
"2": {
|
||||
"IC": 24,
|
||||
"ARD": "D0"
|
||||
},
|
||||
"3": {
|
||||
"GND": null
|
||||
},
|
||||
"4": {
|
||||
"IC": 23,
|
||||
"ARD": "D1"
|
||||
},
|
||||
"5": {
|
||||
"IC": 26,
|
||||
"ARD": "D4"
|
||||
},
|
||||
"6": {
|
||||
"IC": 22,
|
||||
"ARD": "D2"
|
||||
},
|
||||
"7": {
|
||||
"IC": 27,
|
||||
"ARD": "D5"
|
||||
},
|
||||
"8": {
|
||||
"IC": 17,
|
||||
"ARD": [
|
||||
"D3",
|
||||
"A0"
|
||||
]
|
||||
},
|
||||
"9": {
|
||||
"IC": 16,
|
||||
"ARD": "D6"
|
||||
},
|
||||
"10": {
|
||||
"IC": 21
|
||||
},
|
||||
"11": {
|
||||
"IC": 15,
|
||||
"ARD": "D7"
|
||||
},
|
||||
"TSCK": {
|
||||
"IC": 20,
|
||||
"ARD": "D8"
|
||||
},
|
||||
"TPWM3": {
|
||||
"IC": 25,
|
||||
"ARD": "D9"
|
||||
},
|
||||
"TRX2": {
|
||||
"IC": 28,
|
||||
"ARD": "D10"
|
||||
},
|
||||
"TTX2": {
|
||||
"IC": 29,
|
||||
"ARD": "D11"
|
||||
},
|
||||
"TCSN": {
|
||||
"IC": 19,
|
||||
"ARD": "D12"
|
||||
},
|
||||
"TSI": {
|
||||
"IC": 18,
|
||||
"ARD": "D13"
|
||||
},
|
||||
"TSO": {
|
||||
"IC": 17,
|
||||
"ARD": [
|
||||
"D3",
|
||||
"A0"
|
||||
]
|
||||
},
|
||||
"TRST": {
|
||||
"CTRL": "^RST"
|
||||
},
|
||||
"TVCC": {
|
||||
"PWR": 3.3
|
||||
},
|
||||
"TGND": {
|
||||
"GND": null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
106
boards/_base/pcb/wb3l.json
Normal file
106
boards/_base/pcb/wb3l.json
Normal file
@@ -0,0 +1,106 @@
|
||||
{
|
||||
"pcb": {
|
||||
"templates": [
|
||||
"esp12e-21",
|
||||
"esp12e-shield-nohole",
|
||||
"tuya-16x24",
|
||||
"rf-16mm-type1"
|
||||
],
|
||||
"vars": {
|
||||
"MASK_PRESET": "mask_white",
|
||||
"TRACE_COLOR": "#E0E0E0",
|
||||
"SILK_COLOR": "black",
|
||||
"PINTYPE_VERT": "pin_vert_2mm_cast_nohole",
|
||||
"PINTYPE_HORZ": "pin_horz_2mm_cast_nohole"
|
||||
},
|
||||
"pinout_hidden": "I2S,SD,SPI",
|
||||
"pinout": {
|
||||
"1": {
|
||||
"NC": null
|
||||
},
|
||||
"2": {
|
||||
"IC": 17,
|
||||
"ARD": [
|
||||
"D0",
|
||||
"A0"
|
||||
]
|
||||
},
|
||||
"3": {
|
||||
"IC": 21
|
||||
},
|
||||
"4": {
|
||||
"IC": 11,
|
||||
"ARD": "D1"
|
||||
},
|
||||
"5": {
|
||||
"IC": 15,
|
||||
"ARD": "D2"
|
||||
},
|
||||
"6": {
|
||||
"IC": 16,
|
||||
"ARD": "D3"
|
||||
},
|
||||
"7": {
|
||||
"IC": 22,
|
||||
"ARD": "D4"
|
||||
},
|
||||
"8": {
|
||||
"PWR": 3.3
|
||||
},
|
||||
"9": {
|
||||
"GND": null
|
||||
},
|
||||
"10": {
|
||||
"IC": 25,
|
||||
"ARD": "D5"
|
||||
},
|
||||
"11": {
|
||||
"IC": 29,
|
||||
"ARD": "D6"
|
||||
},
|
||||
"12": {
|
||||
"IC": 12,
|
||||
"ARD": "D7"
|
||||
},
|
||||
"13": {
|
||||
"IC": 24,
|
||||
"ARD": "D8"
|
||||
},
|
||||
"14": {
|
||||
"IC": 23,
|
||||
"ARD": "D9"
|
||||
},
|
||||
"15": {
|
||||
"IC": 26,
|
||||
"ARD": "D10"
|
||||
},
|
||||
"16": {
|
||||
"IC": 27,
|
||||
"ARD": "D11"
|
||||
},
|
||||
"17": {
|
||||
"IC": 17,
|
||||
"ARD": [
|
||||
"D0",
|
||||
"A0"
|
||||
]
|
||||
},
|
||||
"18": {
|
||||
"IC": 18,
|
||||
"ARD": "D12"
|
||||
},
|
||||
"19": {
|
||||
"IC": 19,
|
||||
"ARD": "D13"
|
||||
},
|
||||
"20": {
|
||||
"IC": 20,
|
||||
"ARD": "D14"
|
||||
},
|
||||
"21": {
|
||||
"IC": 28,
|
||||
"ARD": "D15"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
108
boards/_base/pcb/wb3s.json
Normal file
108
boards/_base/pcb/wb3s.json
Normal file
@@ -0,0 +1,108 @@
|
||||
{
|
||||
"pcb": {
|
||||
"templates": [
|
||||
"esp12e-22",
|
||||
"esp12e-shield-nohole",
|
||||
"tuya-16x24",
|
||||
"rf-16mm-type1"
|
||||
],
|
||||
"vars": {
|
||||
"MASK_PRESET": "mask_blue_light",
|
||||
"TRACE_COLOR": "#58839B",
|
||||
"SILK_COLOR": "white",
|
||||
"PINTYPE_VERT": "pin_vert_2mm_cast_nohole",
|
||||
"PINTYPE_HORZ": "pin_horz_2mm_cast_nohole"
|
||||
},
|
||||
"pinout_hidden": "I2S,SD,SPI",
|
||||
"pinout": {
|
||||
"1": {
|
||||
"IC": 21
|
||||
},
|
||||
"2": {
|
||||
"IC": 17,
|
||||
"ARD": [
|
||||
"D0",
|
||||
"A0"
|
||||
]
|
||||
},
|
||||
"3": {
|
||||
"NC": null
|
||||
},
|
||||
"4": {
|
||||
"IC": 11,
|
||||
"ARD": "D1"
|
||||
},
|
||||
"5": {
|
||||
"IC": 15,
|
||||
"ARD": "D2"
|
||||
},
|
||||
"6": {
|
||||
"IC": 16,
|
||||
"ARD": "D3"
|
||||
},
|
||||
"7": {
|
||||
"IC": 22,
|
||||
"ARD": "D4"
|
||||
},
|
||||
"8": {
|
||||
"PWR": 3.3
|
||||
},
|
||||
"9": {
|
||||
"GND": null
|
||||
},
|
||||
"10": {
|
||||
"IC": 23,
|
||||
"ARD": "D5"
|
||||
},
|
||||
"11": {
|
||||
"IC": 29,
|
||||
"ARD": "D6"
|
||||
},
|
||||
"12": {
|
||||
"IC": 28,
|
||||
"ARD": "D7"
|
||||
},
|
||||
"13": {
|
||||
"IC": 25,
|
||||
"ARD": "D8"
|
||||
},
|
||||
"14": {
|
||||
"IC": 24,
|
||||
"ARD": "D9"
|
||||
},
|
||||
"15": {
|
||||
"IC": 26,
|
||||
"ARD": "D10"
|
||||
},
|
||||
"16": {
|
||||
"IC": 27,
|
||||
"ARD": "D11"
|
||||
},
|
||||
"17": {
|
||||
"IC": 17,
|
||||
"ARD": [
|
||||
"D0",
|
||||
"A0"
|
||||
]
|
||||
},
|
||||
"18": {
|
||||
"IC": 18,
|
||||
"ARD": "D12"
|
||||
},
|
||||
"19": {
|
||||
"IC": 19,
|
||||
"ARD": "D13"
|
||||
},
|
||||
"20": {
|
||||
"IC": 20,
|
||||
"ARD": "D14"
|
||||
},
|
||||
"21": {
|
||||
"NC": null
|
||||
},
|
||||
"22": {
|
||||
"NC": null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
14
boards/_base/pcb/wr2-base.json
Normal file
14
boards/_base/pcb/wr2-base.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"pcb": {
|
||||
"templates": [
|
||||
"tuya2",
|
||||
"rf-15mm-type1",
|
||||
"tuya2-shield"
|
||||
],
|
||||
"vars": {
|
||||
"MASK_PRESET": "mask_blue_light",
|
||||
"TRACE_COLOR": "#58839B",
|
||||
"SILK_COLOR": "white"
|
||||
}
|
||||
}
|
||||
}
|
||||
49
boards/_base/pcb/wr2.json
Normal file
49
boards/_base/pcb/wr2.json
Normal file
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"pcb": {
|
||||
"scale": 10.5,
|
||||
"pinout_hidden": "I2S,TRIG,WAKE,CTS,RTS,SD,SPI",
|
||||
"pinout": {
|
||||
"1": {
|
||||
"PWR": 3.3
|
||||
},
|
||||
"2": {
|
||||
"IC": 17,
|
||||
"ARD": "D0"
|
||||
},
|
||||
"3": {
|
||||
"GND": null
|
||||
},
|
||||
"4": {
|
||||
"IC": 16,
|
||||
"ARD": "D1"
|
||||
},
|
||||
"5": {
|
||||
"IC": 29,
|
||||
"ARD": "D4"
|
||||
},
|
||||
"6": {
|
||||
"IC": 28,
|
||||
"ARD": "D2"
|
||||
},
|
||||
"7": {
|
||||
"IC": 32,
|
||||
"ARD": "D5"
|
||||
},
|
||||
"8": {
|
||||
"IC": 27,
|
||||
"ARD": "A1"
|
||||
},
|
||||
"9": {
|
||||
"IC": 13,
|
||||
"ARD": "D6"
|
||||
},
|
||||
"10": {
|
||||
"IC": 12
|
||||
},
|
||||
"11": {
|
||||
"IC": 14,
|
||||
"ARD": "D7"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
52
boards/_base/pcb/wr2e.json
Normal file
52
boards/_base/pcb/wr2e.json
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"pcb": {
|
||||
"scale": 10.5,
|
||||
"pinout_hidden": "I2S,TRIG,WAKE,CTS,RTS,SD,SPI,SDA0",
|
||||
"pinout": {
|
||||
"1": {
|
||||
"PWR": 3.3
|
||||
},
|
||||
"2": {
|
||||
"IC": 17,
|
||||
"ARD": "D0"
|
||||
},
|
||||
"3": {
|
||||
"GND": null
|
||||
},
|
||||
"4": {
|
||||
"IC": 30,
|
||||
"ARD": [
|
||||
"D1",
|
||||
"A0"
|
||||
]
|
||||
},
|
||||
"5": {
|
||||
"IC": 29,
|
||||
"ARD": "D3"
|
||||
},
|
||||
"6": {
|
||||
"IC": 28,
|
||||
"ARD": "D2"
|
||||
},
|
||||
"7": {
|
||||
"IC": 32,
|
||||
"ARD": "D4"
|
||||
},
|
||||
"8": {
|
||||
"IC": 27,
|
||||
"ARD": "A1"
|
||||
},
|
||||
"9": {
|
||||
"IC": 13,
|
||||
"ARD": "D5"
|
||||
},
|
||||
"10": {
|
||||
"IC": 12
|
||||
},
|
||||
"11": {
|
||||
"IC": 14,
|
||||
"ARD": "D6"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
15
boards/_base/pcb/wr2l-base.json
Normal file
15
boards/_base/pcb/wr2l-base.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"pcb": {
|
||||
"templates": [
|
||||
"tuya2l",
|
||||
"rf-15mm-type1",
|
||||
"tuya2l-shield"
|
||||
],
|
||||
"vars": {
|
||||
"MASK_PRESET": "mask_blue_light",
|
||||
"TRACE_COLOR": "#58839B",
|
||||
"SILK_COLOR": "white",
|
||||
"PINTYPE_HORZ": "pin_horz_2mm_cast_hole"
|
||||
}
|
||||
}
|
||||
}
|
||||
36
boards/_base/pcb/wr2l.json
Normal file
36
boards/_base/pcb/wr2l.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"pcb": {
|
||||
"pinout_hidden": "I2S,TRIG,WAKE,CTS,RTS,SD,SPI,I2C",
|
||||
"pinout": {
|
||||
"1": {
|
||||
"IC": 14,
|
||||
"ARD": "D0"
|
||||
},
|
||||
"2": {
|
||||
"IC": 13,
|
||||
"ARD": "D1"
|
||||
},
|
||||
"3": {
|
||||
"IC": 28,
|
||||
"ARD": "D2"
|
||||
},
|
||||
"4": {
|
||||
"IC": 30,
|
||||
"ARD": [
|
||||
"D3",
|
||||
"A0"
|
||||
]
|
||||
},
|
||||
"5": {
|
||||
"IC": 17,
|
||||
"ARD": "D4"
|
||||
},
|
||||
"6": {
|
||||
"GND": null
|
||||
},
|
||||
"7": {
|
||||
"PWR": 3.3
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
boards/_base/pcb/wr2le.json
Normal file
33
boards/_base/pcb/wr2le.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"pcb": {
|
||||
"pinout_hidden": "I2S,TRIG,WAKE,CTS,RTS,SD,SPI,I2C",
|
||||
"pinout": {
|
||||
"1": {
|
||||
"IC": 14,
|
||||
"ARD": "D0"
|
||||
},
|
||||
"2": {
|
||||
"IC": 13,
|
||||
"ARD": "D1"
|
||||
},
|
||||
"3": {
|
||||
"IC": 28,
|
||||
"ARD": "D2"
|
||||
},
|
||||
"4": {
|
||||
"IC": 31,
|
||||
"ARD": "D3"
|
||||
},
|
||||
"5": {
|
||||
"IC": 17,
|
||||
"ARD": "D4"
|
||||
},
|
||||
"6": {
|
||||
"GND": null
|
||||
},
|
||||
"7": {
|
||||
"PWR": 3.3
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
16
boards/_base/pcb/wr3-base.json
Normal file
16
boards/_base/pcb/wr3-base.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"pcb": {
|
||||
"templates": [
|
||||
"esp12s",
|
||||
"esp12s-shield",
|
||||
"tuya-16x24",
|
||||
"rf-16mm-type1"
|
||||
],
|
||||
"vars": {
|
||||
"MASK_PRESET": "mask_black",
|
||||
"TRACE_COLOR": "#505050",
|
||||
"SILK_COLOR": "white",
|
||||
"PINTYPE_VERT": "pin_vert_2mm_cast_nohole"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,5 @@
|
||||
{
|
||||
"pcb": {
|
||||
"templates": [
|
||||
"esp12s",
|
||||
"esp12s-shield",
|
||||
"tuya-16x24",
|
||||
"rf-16mm-type1"
|
||||
],
|
||||
"vars": {
|
||||
"MASK_PRESET": "mask_black",
|
||||
"TRACE_COLOR": "#505050",
|
||||
"SILK_COLOR": "white",
|
||||
"PINTYPE_VERT": "pin_vert_2mm_cast_nohole"
|
||||
},
|
||||
"pinout_hidden": "I2S,TRIG,WAKE,CTS,RTS,SD",
|
||||
"pinout": {
|
||||
"1": {
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
{
|
||||
"pcb": {
|
||||
"templates": [
|
||||
"esp12s",
|
||||
"esp12s-shield",
|
||||
"tuya-16x24",
|
||||
"rf-16mm-type1"
|
||||
],
|
||||
"vars": {
|
||||
"MASK_PRESET": "mask_black",
|
||||
"TRACE_COLOR": "#505050",
|
||||
"SILK_COLOR": "white",
|
||||
"PINTYPE_VERT": "pin_vert_2mm_cast_nohole"
|
||||
"MASK_PRESET": "mask_blue_light",
|
||||
"TRACE_COLOR": "#58839B",
|
||||
"SILK_COLOR": "white"
|
||||
},
|
||||
"pinout_hidden": "I2S,TRIG,WAKE,CTS,RTS,SD",
|
||||
"pinout": {
|
||||
@@ -26,19 +19,19 @@
|
||||
},
|
||||
"4": {
|
||||
"IC": 2,
|
||||
"ARD": "D5"
|
||||
"ARD": "D0"
|
||||
},
|
||||
"5": {
|
||||
"IC": 13,
|
||||
"ARD": "D2"
|
||||
"ARD": "D1"
|
||||
},
|
||||
"6": {
|
||||
"IC": 14,
|
||||
"ARD": "D3"
|
||||
"ARD": "D2"
|
||||
},
|
||||
"7": {
|
||||
"IC": 31,
|
||||
"ARD": "D0"
|
||||
"ARD": "D3"
|
||||
},
|
||||
"8": {
|
||||
"PWR": 3.3
|
||||
@@ -52,12 +45,12 @@
|
||||
},
|
||||
"11": {
|
||||
"IC": 1,
|
||||
"ARD": "D6"
|
||||
"ARD": "D5"
|
||||
},
|
||||
"12": {
|
||||
"IC": 30,
|
||||
"ARD": [
|
||||
"D1",
|
||||
"D6",
|
||||
"A0"
|
||||
]
|
||||
},
|
||||
|
||||
16
boards/_base/pcb/wr3l-base.json
Normal file
16
boards/_base/pcb/wr3l-base.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"pcb": {
|
||||
"templates": [
|
||||
"esp12s",
|
||||
"esp12e-shield",
|
||||
"tuya-16x24",
|
||||
"rf-16mm-type1"
|
||||
],
|
||||
"vars": {
|
||||
"MASK_PRESET": "mask_white",
|
||||
"TRACE_COLOR": "#E0E0E0",
|
||||
"SILK_COLOR": "black",
|
||||
"PINTYPE_VERT": "pin_vert_2mm_cast_hole"
|
||||
}
|
||||
}
|
||||
}
|
||||
65
boards/_base/pcb/wr3n.json
Normal file
65
boards/_base/pcb/wr3n.json
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"pcb": {
|
||||
"pinout_hidden": "I2S,TRIG,WAKE,CTS,RTS,SD,SPI",
|
||||
"pinout": {
|
||||
"1": {
|
||||
"NC": null
|
||||
},
|
||||
"2": {
|
||||
"IC": 27,
|
||||
"ARD": "A1"
|
||||
},
|
||||
"3": {
|
||||
"IC": 12
|
||||
},
|
||||
"4": {
|
||||
"IC": 2,
|
||||
"ARD": "D0"
|
||||
},
|
||||
"5": {
|
||||
"IC": 13,
|
||||
"ARD": "D1"
|
||||
},
|
||||
"6": {
|
||||
"IC": 14,
|
||||
"ARD": "D2"
|
||||
},
|
||||
"7": {
|
||||
"IC": 16,
|
||||
"ARD": "D3"
|
||||
},
|
||||
"8": {
|
||||
"PWR": 3.3
|
||||
},
|
||||
"9": {
|
||||
"GND": null
|
||||
},
|
||||
"10": {
|
||||
"NC": null
|
||||
},
|
||||
"11": {
|
||||
"IC": 1,
|
||||
"ARD": "D4"
|
||||
},
|
||||
"12": {
|
||||
"NC": null
|
||||
},
|
||||
"13": {
|
||||
"IC": 28,
|
||||
"ARD": "D5"
|
||||
},
|
||||
"14": {
|
||||
"IC": 17,
|
||||
"ARD": "D6"
|
||||
},
|
||||
"15": {
|
||||
"IC": 29,
|
||||
"ARD": "D7"
|
||||
},
|
||||
"16": {
|
||||
"IC": 32,
|
||||
"ARD": "D8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,8 @@
|
||||
{
|
||||
"build": {
|
||||
"ldscript_sdk": "rlx8711B-symbol-v02-img2_xip1_2M_468k_cpp.ld",
|
||||
"ldscript_arduino": "rlx8711B-symbol-v02-img2_xip1_2M_468k_cpp.ld",
|
||||
"amb_boot_all": "boot_all_77F7.bin"
|
||||
},
|
||||
"flash": {
|
||||
"boot_xip": "0x000000+0x4000",
|
||||
"boot_ram": "0x004000+0x4000",
|
||||
"system": "0x009000+0x1000",
|
||||
"calibration": "0x00A000+0x1000",
|
||||
"ota1": "0x00B000+0x75000",
|
||||
"ota2": "0x080000+0x75000",
|
||||
"kvs": "0xF5000+0x6000",
|
||||
@@ -1,14 +1,8 @@
|
||||
{
|
||||
"build": {
|
||||
"ldscript_sdk": "rlx8711B-symbol-v02-img2_xip1_2M_cpp.ld",
|
||||
"ldscript_arduino": "rlx8711B-symbol-v02-img2_xip1_2M_cpp.ld",
|
||||
"amb_boot_all": "boot_all_77F7.bin"
|
||||
},
|
||||
"flash": {
|
||||
"boot_xip": "0x000000+0x4000",
|
||||
"boot_ram": "0x004000+0x4000",
|
||||
"system": "0x009000+0x1000",
|
||||
"calibration": "0x00A000+0x1000",
|
||||
"ota1": "0x00B000+0xC5000",
|
||||
"ota2": "0x0D0000+0xC5000",
|
||||
"kvs": "0x195000+0x6000",
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user