From 1585e425ce7da4cfe1709efb24567b8703c87f87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Sun, 11 Sep 2022 16:20:48 +0200 Subject: [PATCH] [boards] Add CB2L board --- boards/SUMMARY.md | 1 + boards/_base/pcb/cb2l-test.json | 120 ++++++++++ boards/_base/pcb/cb2l.json | 66 ++++++ boards/cb2l.json | 20 ++ boards/cb2l/README.md | 72 ++++++ boards/cb2l/pinout_cb2l.svg | 258 +++++++++++++++++++++ boards/cb2l/pins_arduino.h | 1 + boards/cb2l/variant.cpp | 30 +++ boards/cb2l/variant.h | 27 +++ docs/status/supported_boards.md | 1 + docs/status/unsupported_boards_tuya_all.md | 1 - 11 files changed, 596 insertions(+), 1 deletion(-) create mode 100644 boards/_base/pcb/cb2l-test.json create mode 100644 boards/_base/pcb/cb2l.json create mode 100644 boards/cb2l.json create mode 100644 boards/cb2l/README.md create mode 100644 boards/cb2l/pinout_cb2l.svg create mode 100644 boards/cb2l/pins_arduino.h create mode 100644 boards/cb2l/variant.cpp create mode 100644 boards/cb2l/variant.h diff --git a/boards/SUMMARY.md b/boards/SUMMARY.md index 41ade8a..46d9ed1 100644 --- a/boards/SUMMARY.md +++ b/boards/SUMMARY.md @@ -7,6 +7,7 @@ - [Generic - RTL8720CF (2M/992k)](../boards/generic-rtl8720cf-2mb-992k/README.md) - [BW12](../boards/bw12/README.md) - [BW15](../boards/bw15/README.md) +- [CB2L](../boards/cb2l/README.md) - [CB2S](../boards/cb2s/README.md) - [CB3L](../boards/cb3l/README.md) - [CB3S](../boards/cb3s/README.md) diff --git a/boards/_base/pcb/cb2l-test.json b/boards/_base/pcb/cb2l-test.json new file mode 100644 index 0000000..1b08e49 --- /dev/null +++ b/boards/_base/pcb/cb2l-test.json @@ -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 + } + } + ] + } +} diff --git a/boards/_base/pcb/cb2l.json b/boards/_base/pcb/cb2l.json new file mode 100644 index 0000000..e351231 --- /dev/null +++ b/boards/_base/pcb/cb2l.json @@ -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" + } + } + } +} diff --git a/boards/cb2l.json b/boards/cb2l.json new file mode 100644 index 0000000..3dd3175 --- /dev/null +++ b/boards/cb2l.json @@ -0,0 +1,20 @@ +{ + "_base": [ + "beken-72xx", + "beken-7231n", + "beken-7231n-tuya", + "pcb/ic-bk7231-qfn32", + "pcb/cb2l", + "pcb/cb2l-test" + ], + "build": { + "mcu": "bk7231n", + "variant": "cb2l" + }, + "name": "CB2L Wi-Fi Module", + "url": "https://developer.tuya.com/en/docs/iot/cb2l-module-datasheet?id=Kai2eku1m3pyl", + "vendor": "Tuya Inc.", + "pcb": { + "symbol": "CB2L" + } +} diff --git a/boards/cb2l/README.md b/boards/cb2l/README.md new file mode 100644 index 0000000..0944593 --- /dev/null +++ b/boards/cb2l/README.md @@ -0,0 +1,72 @@ +# CB2L Wi-Fi Module + +*by Tuya Inc.* + +[Product page](https://developer.tuya.com/en/docs/iot/cb2l-module-datasheet?id=Kai2eku1m3pyl) + +- [General info](../../docs/platform/beken-72xx/README.md) +- [Flashing guide](../../docs/platform/beken-72xx/flashing.md) +- [BkWriter v1.6.0](https://images.tuyacn.com/smart/bk_writer1.60/bk_writer1.60.exe) + +Parameter | Value +-------------|------------------------- +Board code | `cb2l` +MCU | BK7231N +Manufacturer | Beken +Series | BK72XX +Frequency | 120 MHz +Flash size | 2 MiB +RAM size | 256 KiB +Voltage | 3.0V - 3.6V +I/O | 9x GPIO, 5x PWM, 2x UART +Wi-Fi | 802.11 b/g/n +Bluetooth | BLE v5.1 + +## Usage + +**Board code:** `cb2l` + +In `platformio.ini`: + +```ini +[env:cb2l] +platform = libretuya +board = cb2l +framework = arduino +``` + +## Pinout + +![Pinout](pinout_cb2l.svg) + +## Arduino Core pin mapping + +No. | Pin | UART | I²C | SPI | PWM | Other +----|-----|----------|----------|-----|------|------ +D0 | P8 | | | | PWM2 | +D1 | P7 | | | | PWM1 | +D2 | P6 | | | | PWM0 | +D3 | P26 | | | | PWM5 | +D4 | P24 | | | | PWM4 | +D5 | P10 | UART1_RX | | | | +D6 | P0 | UART2_TX | I2C2_SCL | | | +D7 | P11 | UART1_TX | | | | +D8 | P21 | | I2C1_SDA | | | TMS + +## Flash memory map + +Flash size: 2 MiB / 2,097,152 B / 0x200000 + +Hex values are in bytes. + +Name | Start | Length | End +----------------|----------|--------------------|--------- +Bootloader | 0x000000 | 68 KiB / 0x11000 | 0x011000 +App Image | 0x011000 | 1.1 MiB / 0x119000 | 0x12A000 +OTA Image | 0x12A000 | 664 KiB / 0xA6000 | 0x1D0000 +TLV Store | 0x1D0000 | 4 KiB / 0x1000 | 0x1D1000 +Network Data | 0x1D1000 | 8 KiB / 0x2000 | 0x1D3000 +Key-Value Store | 0x1D3000 | 32 KiB / 0x8000 | 0x1DB000 +User Data | 0x1DB000 | 148 KiB / 0x25000 | 0x200000 + +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. diff --git a/boards/cb2l/pinout_cb2l.svg b/boards/cb2l/pinout_cb2l.svg new file mode 100644 index 0000000..f41a95e --- /dev/null +++ b/boards/cb2l/pinout_cb2l.svg @@ -0,0 +1,258 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CB2L + + + + + + + + + + + + + + + + + + + + + + P8 + + + + D0 + + + + PWM2 + + + + + P7 + + + + D1 + + + + PWM1 + + + + + P6 + + + + D2 + + + + PWM0 + + + + + P26 + + + + D3 + + + + IRDA + + + + PWM5 + + + + + P24 + + + + D4 + + + + PWM4 + + + + + GND + + + + + 3V3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + GND + + + + + CEN + + + + + P10 + + + + D5 + + + + RX1 + + + + + P0 + + + + D6 + + + + TX2 + + + + + P11 + + + + D7 + + + + TX1 + + + + + P21 + + + + D8 + diff --git a/boards/cb2l/pins_arduino.h b/boards/cb2l/pins_arduino.h new file mode 100644 index 0000000..1de3ade --- /dev/null +++ b/boards/cb2l/pins_arduino.h @@ -0,0 +1 @@ +#include "variant.h" diff --git a/boards/cb2l/variant.cpp b/boards/cb2l/variant.cpp new file mode 100644 index 0000000..d67162b --- /dev/null +++ b/boards/cb2l/variant.cpp @@ -0,0 +1,30 @@ +/* This file was auto-generated from cb2l.json using boardgen */ + +#include + +extern "C" { + +// clang-format off +PinInfo pinTable[PINS_COUNT] = { + // D0: P8, PWM2 + {GPIO8, PIN_GPIO | PIN_IRQ | PIN_PWM, PIN_NONE, 0}, + // D1: P7, PWM1 + {GPIO7, PIN_GPIO | PIN_IRQ | PIN_PWM, PIN_NONE, 0}, + // D2: P6, PWM0 + {GPIO6, PIN_GPIO | PIN_IRQ | PIN_PWM, PIN_NONE, 0}, + // D3: P26, PWM5, IRDA + {GPIO26, PIN_GPIO | PIN_IRQ | PIN_PWM, PIN_NONE, 0}, + // D4: P24, PWM4 + {GPIO24, PIN_GPIO | PIN_IRQ | PIN_PWM, PIN_NONE, 0}, + // D5: P10, UART1_RX + {GPIO10, PIN_GPIO | PIN_IRQ | PIN_UART, PIN_NONE, 0}, + // D6: P0, UART2_TX, I2C2_SCL + {GPIO0, PIN_GPIO | PIN_IRQ | PIN_I2C | PIN_UART, PIN_NONE, 0}, + // D7: P11, UART1_TX + {GPIO11, PIN_GPIO | PIN_IRQ | PIN_UART, PIN_NONE, 0}, + // D8: P21, I2C1_SDA, TMS, MCLK, ^FCS + {GPIO21, PIN_GPIO | PIN_IRQ | PIN_I2C | PIN_I2S | PIN_JTAG, PIN_NONE, 0}, +}; +// clang-format on + +} // extern "C" diff --git a/boards/cb2l/variant.h b/boards/cb2l/variant.h new file mode 100644 index 0000000..2fdb827 --- /dev/null +++ b/boards/cb2l/variant.h @@ -0,0 +1,27 @@ +/* This file was auto-generated from cb2l.json using boardgen */ + +#pragma once + +#include + +// clang-format off + +// Pins +// ---- +#define PINS_COUNT 9 +#define NUM_DIGITAL_PINS 9 +#define NUM_ANALOG_OUTPUTS 0 + +// SPI Interfaces +// -------------- +#define SPI_INTERFACES_COUNT 0 + +// Wire Interfaces +// --------------- +#define WIRE_INTERFACES_COUNT 0 + +// Serial ports +// ------------ +#define SERIAL_INTERFACES_COUNT 1 +#define PIN_SERIAL1_RX 5u // GPIO10 +#define PIN_SERIAL1_TX 7u // GPIO11 diff --git a/docs/status/supported_boards.md b/docs/status/supported_boards.md index f53bfa3..92b39cc 100644 --- a/docs/status/supported_boards.md +++ b/docs/status/supported_boards.md @@ -12,6 +12,7 @@ Name | MCU [BW12](../../boards/bw12/README.md) | RTL8710BX | 2 MiB | 256 KiB | 16 (12 I/O) | ✔️ | ❌ | ❌ | `realtek-ambz` [BW15](../../boards/bw15/README.md) | RTL8720CF | 2 MiB | 256 KiB | 16 (13 I/O) | ✔️ | ✔️ | ❌ | `realtek-ambz2` **Tuya Inc.** | | | | | | | | +[CB2L](../../boards/cb2l/README.md) | BK7231N | 2 MiB | 256 KiB | 7 (5 I/O) | ✔️ | ✔️ | ❌ | `beken-7231n` [CB2S](../../boards/cb2s/README.md) | BK7231N | 2 MiB | 256 KiB | 11 (8 I/O) | ✔️ | ✔️ | ❌ | `beken-7231n` [CB3L](../../boards/cb3l/README.md) | BK7231N | 2 MiB | 256 KiB | 16 (12 I/O) | ✔️ | ✔️ | ❌ | `beken-7231n` [CB3S](../../boards/cb3s/README.md) | BK7231N | 2 MiB | 256 KiB | 22 (16 I/O) | ✔️ | ✔️ | ❌ | `beken-7231n` diff --git a/docs/status/unsupported_boards_tuya_all.md b/docs/status/unsupported_boards_tuya_all.md index 261b186..fe61c1b 100644 --- a/docs/status/unsupported_boards_tuya_all.md +++ b/docs/status/unsupported_boards_tuya_all.md @@ -9,7 +9,6 @@ AXY3S | ECR6600 | 2 MiB | 512 KiB | 22 | ✔️ | ✔️ | ❌ AXYU | ECR6600 | 2 MiB | 512 KiB | 21 | ✔️ | ✔️ | ❌ **CB Series** | | | | | | | CB1S | BK7231N | 2 MiB | 256 KiB | 18 | ✔️ | ✔️ | ❌ -CB2L | BK7231N | 2 MiB | 256 KiB | 7 | ✔️ | ✔️ | ❌ CB8P | BK7231N | 2 MiB | 256 KiB | 10 | ✔️ | ✔️ | ❌ CBLC5 | BK7231N | 2 MiB | 256 KiB | 15 | ✔️ | ✔️ | ❌ CBLC9 | BK7231N | 2 MiB | 256 KiB | 8 | ✔️ | ✔️ | ❌