Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
376a4db4cb | ||
|
|
24832d3277 | ||
|
|
8f338a6b30 | ||
|
|
eae64d34e2 | ||
|
|
a27e76bfa7 | ||
|
|
a2de77ce30 | ||
|
|
5de98ed56c | ||
|
|
ff8ac6036c | ||
|
|
c4a3e9e2ee |
@@ -9,6 +9,8 @@ extern "C" {
|
||||
|
||||
extern int uart_print_port;
|
||||
|
||||
void __sync_synchronize(void) {}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
beken_thread_t mainThread;
|
||||
|
||||
@@ -45,6 +45,19 @@ void SerialClass::begin(unsigned long baudrate, uint16_t config) {
|
||||
// RUART_STOP_BIT_1 / RUART_STOP_BIT_2
|
||||
uint8_t stopBits = (config & SERIAL_STOP_BIT_MASK) == SERIAL_STOP_BIT_2;
|
||||
|
||||
switch ((uint32_t)data.uart) {
|
||||
case UART0_REG_BASE:
|
||||
RCC_PeriphClockCmd(APBPeriph_UART0, APBPeriph_UART0_CLOCK, ENABLE);
|
||||
break;
|
||||
case UART1_REG_BASE:
|
||||
RCC_PeriphClockCmd(APBPeriph_UART1, APBPeriph_UART1_CLOCK, ENABLE);
|
||||
break;
|
||||
}
|
||||
|
||||
Pinmux_Config(pinInfo(this->rx)->gpio, PINMUX_FUNCTION_UART);
|
||||
Pinmux_Config(pinInfo(this->tx)->gpio, PINMUX_FUNCTION_UART);
|
||||
PAD_PullCtrl(pinInfo(this->rx)->gpio, GPIO_PuPd_UP);
|
||||
|
||||
UART_InitTypeDef cfg;
|
||||
UART_StructInit(&cfg);
|
||||
cfg.WordLen = dataWidth;
|
||||
@@ -60,11 +73,12 @@ void SerialClass::begin(unsigned long baudrate, uint16_t config) {
|
||||
data.buf = new RingBuffer();
|
||||
}
|
||||
|
||||
Pinmux_Config(pinInfo(this->rx)->gpio, PINMUX_FUNCTION_UART);
|
||||
Pinmux_Config(pinInfo(this->tx)->gpio, PINMUX_FUNCTION_UART);
|
||||
|
||||
VECTOR_IrqUnRegister(this->irq);
|
||||
VECTOR_IrqRegister(callback, this->irq, (uint32_t)&data, 10);
|
||||
VECTOR_IrqEn(this->irq, 10);
|
||||
|
||||
UART_RxCmd((UART_TypeDef *)data.uart, ENABLE);
|
||||
UART_INTConfig((UART_TypeDef *)data.uart, RUART_IER_ERBI, ENABLE);
|
||||
}
|
||||
|
||||
void SerialClass::end() {
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
"f_cpu": "120000000L",
|
||||
"prefix": "arm-none-eabi-",
|
||||
"bkota": {
|
||||
"encryption": "none",
|
||||
"compression": "gzip"
|
||||
"encryption": "aes256",
|
||||
"compression": "gzip",
|
||||
"key": "0123456789ABCDEF0123456789ABCDEF",
|
||||
"iv": "0123456789ABCDEF"
|
||||
}
|
||||
},
|
||||
"connectivity": [
|
||||
|
||||
@@ -43,13 +43,16 @@ env.Append(
|
||||
"-mthumb",
|
||||
"-mthumb-interwork",
|
||||
"-g",
|
||||
"-O2",
|
||||
# anything higher, like -O2 or -Os, causes random issues
|
||||
# like bootlooping, missing (blank) strings, random lockups during boot
|
||||
"-O1",
|
||||
"-fdata-sections",
|
||||
"-ffunction-sections",
|
||||
"-fno-inline-functions",
|
||||
"-fno-strict-aliasing",
|
||||
"-fsigned-char",
|
||||
"-fno-delete-null-pointer-checks",
|
||||
"-Wno-comment",
|
||||
"-Werror=implicit-function-declaration",
|
||||
],
|
||||
CFLAGS=[
|
||||
"-std=gnu99",
|
||||
@@ -57,6 +60,7 @@ env.Append(
|
||||
"-Wall",
|
||||
"-Wno-format",
|
||||
"-Wno-unknown-pragmas",
|
||||
"-Werror=implicit-function-declaration",
|
||||
],
|
||||
CXXFLAGS=[
|
||||
"-std=gnu++11",
|
||||
@@ -64,6 +68,8 @@ env.Append(
|
||||
"-fno-exceptions",
|
||||
"-fno-rtti",
|
||||
"-Wno-literal-suffix",
|
||||
"-Wno-psabi",
|
||||
"-Wno-return-type",
|
||||
],
|
||||
CPPDEFINES=[
|
||||
# LibreTuya configuration
|
||||
@@ -364,6 +370,8 @@ env.AddLibrary(
|
||||
CCFLAGS=[
|
||||
"-Wno-unused-variable",
|
||||
"-Wno-implicit-function-declaration",
|
||||
"-Wno-incompatible-pointer-types",
|
||||
"-Wno-int-conversion",
|
||||
],
|
||||
CFLAGS=["-<-Wall>"],
|
||||
),
|
||||
|
||||
@@ -16,14 +16,16 @@ env.Append(
|
||||
"-mfpu=fpv4-sp-d16",
|
||||
"-g2",
|
||||
"-w",
|
||||
"-O2",
|
||||
"-Os",
|
||||
"-fdata-sections",
|
||||
"-ffunction-sections",
|
||||
"-fno-inline-functions",
|
||||
"-fmessage-length=0",
|
||||
"-fno-common",
|
||||
"-fno-short-enums",
|
||||
"-fomit-frame-pointer",
|
||||
"-fsigned-char",
|
||||
"-fno-delete-null-pointer-checks",
|
||||
],
|
||||
CFLAGS=[
|
||||
"-std=gnu99",
|
||||
@@ -35,6 +37,7 @@ env.Append(
|
||||
"-MMD",
|
||||
"-fno-exceptions",
|
||||
"-fno-rtti",
|
||||
"-Wno-psabi",
|
||||
],
|
||||
CPPDEFINES=[
|
||||
# LibreTuya configuration
|
||||
@@ -49,6 +52,7 @@ env.Append(
|
||||
("ERRNO", "1"), # for LwIP
|
||||
"MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED", # enable PSK in mbedTLS
|
||||
# "MBEDTLS_DEBUG_C",
|
||||
"MBED_PERIPHERALNAMES_H", # see fixups/cmsis.h
|
||||
],
|
||||
LINKFLAGS=[
|
||||
"-mcpu=cortex-m4",
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/kuba2k2/platformio-libretuya"
|
||||
},
|
||||
"version": "0.12.6",
|
||||
"version": "0.13.0",
|
||||
"frameworks": {
|
||||
"arduino": {
|
||||
"title": "Generic Arduino framework",
|
||||
@@ -44,9 +44,7 @@
|
||||
"optional": true,
|
||||
"version": "https://github.com/libretuya/framework-realtek-amb1#v2022.06.21",
|
||||
"toolchains": {
|
||||
"x86_64": "gccarmnoneeabi@~1.50201.0",
|
||||
"arm": "gccarmnoneeabi@~1.50401.211104",
|
||||
"arm64": "gccarmnoneeabi@~1.50401.210715"
|
||||
"any": "gccarmnoneeabi@~1.100301.0"
|
||||
},
|
||||
"libraries": {
|
||||
"lwip": [
|
||||
@@ -59,9 +57,7 @@
|
||||
"optional": true,
|
||||
"version": "https://github.com/libretuya/framework-realtek-ambz2#v2022.11.17",
|
||||
"toolchains": {
|
||||
"x86_64": "gccarmnoneeabi@~1.100301.0",
|
||||
"arm": "gccarmnoneeabi@~1.100301.0",
|
||||
"arm64": "gccarmnoneeabi@~1.100301.0"
|
||||
"any": "gccarmnoneeabi@~1.100301.0"
|
||||
}
|
||||
},
|
||||
"framework-beken-bdk": {
|
||||
@@ -69,9 +65,7 @@
|
||||
"optional": true,
|
||||
"version": "https://github.com/libretuya/framework-beken-bdk#v2021.06.07",
|
||||
"toolchains": {
|
||||
"x86_64":"gccarmnoneeabi@~1.40804.0",
|
||||
"arm": "gccarmnoneeabi@~1.40803.0",
|
||||
"arm64": "gccarmnoneeabi@~1.40803.0"
|
||||
"any":"gccarmnoneeabi@~1.100301.0"
|
||||
},
|
||||
"libraries": {
|
||||
"lwip": [
|
||||
|
||||
46
platform.py
46
platform.py
@@ -17,7 +17,7 @@ from platformio.platform.base import PlatformBase
|
||||
from platformio.platform.board import PlatformBoardConfig
|
||||
from semantic_version import SimpleSpec, Version
|
||||
|
||||
LTCHIPTOOL_VERSION = "^3.0.0"
|
||||
LTCHIPTOOL_VERSION = "^3.0.2"
|
||||
|
||||
|
||||
# Install & import tools
|
||||
@@ -137,6 +137,33 @@ def find_pkg_root(self, path: str, spec: PackageSpec):
|
||||
return path
|
||||
|
||||
|
||||
def get_os_specifiers():
|
||||
system = platform.system().lower()
|
||||
arch = platform.machine().lower()
|
||||
if not arch: # issue #4353
|
||||
arch = "x86"
|
||||
bits = platform.architecture()[0]
|
||||
if "aarch64" in arch:
|
||||
arch = "arm"
|
||||
bits = 64
|
||||
elif "arm" in arch:
|
||||
arch = "arm"
|
||||
bits = 32
|
||||
elif "64" not in arch:
|
||||
arch = "x86"
|
||||
bits = 32
|
||||
else:
|
||||
arch = "x86"
|
||||
bits = 64
|
||||
return [
|
||||
f"{system}_{arch}_{bits}", # linux_x86_64
|
||||
f"{system}_{bits}", # linux_64
|
||||
system, # windows
|
||||
arch, # arm
|
||||
"any",
|
||||
]
|
||||
|
||||
|
||||
class LibretuyaPlatform(PlatformBase):
|
||||
boards_base: Dict[str, dict] = {}
|
||||
custom_opts: Dict[str, object] = {}
|
||||
@@ -176,12 +203,17 @@ class LibretuyaPlatform(PlatformBase):
|
||||
# set specific compiler versions
|
||||
if "toolchains" in package_obj:
|
||||
toolchains = package_obj["toolchains"]
|
||||
if "arm" in platform.machine():
|
||||
(toolchain, version) = toolchains["arm"].split("@")
|
||||
elif "aarch64" in platform.machine():
|
||||
(toolchain, version) = toolchains["arm64"].split("@")
|
||||
else:
|
||||
(toolchain, version) = toolchains["x86_64"].split("@")
|
||||
toolchain_version = None
|
||||
specifiers = get_os_specifiers()
|
||||
for spec in specifiers:
|
||||
toolchain_version = toolchains.get(spec)
|
||||
if toolchain_version:
|
||||
break
|
||||
if not toolchain_version:
|
||||
raise RuntimeError(
|
||||
f"Toolchain not found for the current platform: {specifiers}"
|
||||
)
|
||||
(toolchain, version) = toolchain_version.split("@")
|
||||
self.packages[f"toolchain-{toolchain}"]["version"] = version
|
||||
|
||||
# mark framework SDK as required
|
||||
|
||||
50
platform/realtek-ambz/fixups/cmsis.h
Normal file
50
platform/realtek-ambz/fixups/cmsis.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2023-03-12. */
|
||||
|
||||
// Fix for PeripheralNames.h producing errors on GCC newer than 5.x.x.
|
||||
// The struct pointer casts are replaced with register addresses, which fixes compilation.
|
||||
// On older versions, this change doesn't make any difference.
|
||||
// MBED_PERIPHERALNAMES_H is defined in the SDK builder, to eliminate PeripheralNames.h completely.
|
||||
|
||||
#include_next "cmsis.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
UART_0 = (int)UART0_REG_BASE,
|
||||
UART_1 = (int)UART1_REG_BASE,
|
||||
UART_2 = (int)UART2_REG_BASE,
|
||||
} UARTName;
|
||||
|
||||
typedef enum {
|
||||
ADC0_0 = 0,
|
||||
ADC0_1,
|
||||
ADC0_2,
|
||||
ADC0_3
|
||||
} ADCName;
|
||||
|
||||
typedef enum {
|
||||
SPI_0 = (int)SPI0_REG_BASE,
|
||||
SPI_1 = (int)SPI1_REG_BASE,
|
||||
} SPIName;
|
||||
|
||||
typedef enum {
|
||||
I2C_0 = (int)I2C0_REG_BASE,
|
||||
I2C_1 = (int)I2C1_REG_BASE,
|
||||
} I2CName;
|
||||
|
||||
typedef enum {
|
||||
PWM_0 = 1,
|
||||
PWM_1,
|
||||
PWM_2,
|
||||
PWM_3,
|
||||
PWM_4,
|
||||
PWM_5
|
||||
} PWMName;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
21
platform/realtek-ambz/fixups/machine/endian.h
Normal file
21
platform/realtek-ambz/fixups/machine/endian.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2023-03-12. */
|
||||
|
||||
#include_next <machine/endian.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
// GCC versions newer than 5.x.x specify the LITTLE_ENDIAN macro
|
||||
// as an alias to _LITTLE_ENDIAN (which in turn holds the actual numeric value).
|
||||
// Realtek's rtl8711b_crypto.h redefines _LITTLE_ENDIAN as a macro without
|
||||
// any value, which makes comparisons like '#if BYTE_ORDER == LITTLE_ENDIAN' impossible.
|
||||
|
||||
#if __GNUC__ > 5
|
||||
#undef _LITTLE_ENDIAN
|
||||
#undef _BIG_ENDIAN
|
||||
#undef LITTLE_ENDIAN
|
||||
#undef BIG_ENDIAN
|
||||
#undef BYTE_ORDER
|
||||
#define LITTLE_ENDIAN 1234
|
||||
#define BIG_ENDIAN 4321
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#endif
|
||||
Reference in New Issue
Block a user