diff --git a/boards/_base/realtek-ambz2-2mb-large.json b/boards/_base/realtek-ambz2-2mb-large.json new file mode 100644 index 0000000..ce06c54 --- /dev/null +++ b/boards/_base/realtek-ambz2-2mb-large.json @@ -0,0 +1,12 @@ +{ + "flash": { + "ota1": "0x00C000+0xF8000", + "ota2": "0x104000+0xF8000", + "kvs": "0x1FC000+0x2000", + "userdata": "0x1FE000+0x2000" + }, + "upload": { + "flash_size": 2097152, + "maximum_size": 1015808 + } +} diff --git a/boards/_base/realtek-ambz2-8710.json b/boards/_base/realtek-ambz2-8710.json new file mode 100644 index 0000000..5d26240 --- /dev/null +++ b/boards/_base/realtek-ambz2-8710.json @@ -0,0 +1,12 @@ +{ + "connectivity": [ + "wifi" + ], + "doc": { + "params": { + "extra": { + "Wi-Fi": "802.11 b/g/n" + } + } + } +} diff --git a/boards/_base/realtek-ambz2-8720.json b/boards/_base/realtek-ambz2-8720.json new file mode 100644 index 0000000..eef930d --- /dev/null +++ b/boards/_base/realtek-ambz2-8720.json @@ -0,0 +1,14 @@ +{ + "connectivity": [ + "wifi", + "ble" + ], + "doc": { + "params": { + "extra": { + "Wi-Fi": "802.11 b/g/n", + "BLE": "v4.2" + } + } + } +} diff --git a/boards/_base/realtek-ambz2.json b/boards/_base/realtek-ambz2.json new file mode 100644 index 0000000..52b71db --- /dev/null +++ b/boards/_base/realtek-ambz2.json @@ -0,0 +1,35 @@ +{ + "build": { + "family": "RTL8720C", + "f_cpu": "100000000L", + "prefix": "arm-none-eabi-", + "ldscript_sdk": "rtl8710c_ram.ld", + "ldscript_arduino": "rtl8710c_ram.ld" + }, + "flash": { + "part_table": "0x000000+0x1000", + "system": "0x001000+0x1000", + "calibration": "0x002000+0x1000", + "boot": "0x004000+0x8000" + }, + "debug": { + "protocol": "openocd", + "protocols": [] + }, + "frameworks": [ + "realtek-ambz2-sdk" + ], + "upload": { + "maximum_ram_size": 262144 + }, + "doc": { + "params": { + "manufacturer": "Realtek", + "series": "AmebaZ2", + "voltage": "3.0V - 3.6V" + }, + "links": { + "General info": "../../docs/platform/realtek/README.md" + } + } +} diff --git a/builder/frameworks/realtek-ambz2-sdk.py b/builder/frameworks/realtek-ambz2-sdk.py new file mode 100644 index 0000000..0d80ea0 --- /dev/null +++ b/builder/frameworks/realtek-ambz2-sdk.py @@ -0,0 +1,477 @@ +# Copyright (c) Kuba Szczodrzyński 2022-07-20. + +from os.path import join + +from SCons.Script import Builder, DefaultEnvironment + +env = DefaultEnvironment() +board = env.BoardConfig() + +COMPONENT_DIR = join("$SDK_DIR", "component") + +# Flags +env.Append( + CCFLAGS=[ + "-march=armv8-m.main+dsp", + "-mthumb", + "-mcmse", + "-mfloat-abi=soft", + "-g", + "-gdwarf-3", + "-Os", + "-MMD", + "-fstack-usage", + "-fdata-sections", + "-ffunction-sections", + "-fmessage-length=0", + "-fno-common", + "-fno-short-enums", + "-fomit-frame-pointer", + "-fsigned-char", + ], + CFLAGS=[ + "-std=gnu99", + "-Wall", + "-Wpointer-arith", + "-Wundef", + "-Wno-write-strings", + "-Wno-maybe-uninitialized", + ], + CXXFLAGS=[ + "-std=c++11", + "-fno-exceptions", + "-fno-rtti", + "-fno-use-cxa-atexit", + ], + CPPDEFINES=[ + # LibreTuya configuration + ("LT_HAS_LWIP", "1"), + ("LT_HAS_LWIP2", "1"), + ("LT_HAS_FREERTOS", "1"), + ("LT_HAS_MBEDTLS", "1"), + # other options + "__thumb2__", + "CONFIG_PLATFORM_8710C", + ("__ARM_ARCH_8M_MAIN__", "1"), + ("CONFIG_BUILD_RAM", "1"), + "V8M_STKOVF", + ], + LINKFLAGS=[ + "-march=armv8-m.main+dsp", + "-mthumb", + "-mcmse", + "-mfloat-abi=soft", + "-g", + "--specs=nosys.specs", + "-nostartfiles", + "-nodefaultlibs", + "-nostdlib", + "-Os", + "-Wl,--gc-sections", + "-Wl,--warn-section-align", + "-Wl,--cref", + "-Wl,--build-id=none", + "-Wl,--use-blx", + "-Wl,-no-enum-size-warning", + # TODO fix wraps + "-Wl,-wrap,strcat", + "-Wl,-wrap,strchr", + "-Wl,-wrap,strcmp", + "-Wl,-wrap,strncmp", + "-Wl,-wrap,strnicmp", + "-Wl,-wrap,strcpy", + "-Wl,-wrap,strncpy", + "-Wl,-wrap,strlcpy", + "-Wl,-wrap,strlen", + "-Wl,-wrap,strnlen", + "-Wl,-wrap,strncat", + "-Wl,-wrap,strpbrk", + "-Wl,-wrap,strspn", + "-Wl,-wrap,strstr", + "-Wl,-wrap,strtok", + "-Wl,-wrap,strxfrm", + "-Wl,-wrap,strsep", + "-Wl,-wrap,strtod", + "-Wl,-wrap,strtof", + "-Wl,-wrap,strtold", + "-Wl,-wrap,strtoll", + "-Wl,-wrap,strtoul", + "-Wl,-wrap,strtoull", + "-Wl,-wrap,atoi", + "-Wl,-wrap,atoui", + "-Wl,-wrap,atol", + "-Wl,-wrap,atoul", + "-Wl,-wrap,atoull", + "-Wl,-wrap,atof", + "-Wl,-wrap,malloc", + "-Wl,-wrap,realloc", + "-Wl,-wrap,calloc", + "-Wl,-wrap,free", + "-Wl,-wrap,_malloc_r", + "-Wl,-wrap,_calloc_r", + "-Wl,-wrap,memcmp", + "-Wl,-wrap,memcpy", + "-Wl,-wrap,memmove", + "-Wl,-wrap,memset", + "-Wl,-wrap,printf", + "-Wl,-wrap,sprintf", + "-Wl,-wrap,puts", + "-Wl,-wrap,putc", + "-Wl,-wrap,putchar", + "-Wl,-wrap,snprintf", + "-Wl,-wrap,vsnprintf", + "-Wl,-wrap,aesccmp_construct_mic_iv", + "-Wl,-wrap,aesccmp_construct_mic_header1", + "-Wl,-wrap,aesccmp_construct_ctr_preload", + "-Wl,-wrap,rom_psk_CalcGTK", + "-Wl,-wrap,rom_psk_CalcPTK", + "-Wl,-wrap,aes_80211_encrypt", + "-Wl,-wrap,aes_80211_decrypt", + ], +) + +# Sources - from SDK project/realtek_amebaz2_v0_example/GCC-RELEASE/application.is.mk +# - without "utilities - example", "bluetooth - example" and "network - app - mqtt" +env.AddLibrary( + name="ambz2_sdk", + base_dir=COMPONENT_DIR, + srcs=[ + # libc api wrapper + "+", + # cmsis + "+", + "+", + # console + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + # utilities + "+", + "+", + "+", + # os + "+", + "+", + "+", + "+", + "+", + "+", + # os - freertos + "+", + # os - freertos - portable + "+", + "+", + # peripheral - api + "+", + # peripheral - hal + "+", + "+", + "+", + "+", + # peripheral - wlan + # "+", + # file_system - fatfs + "+", + "+", + "+", + "+", + "+", + "+", + # TODO remove this + "+", + "+", + ], + includes=[ + "+<$SDK_DIR/project/realtek_amebaz2_v0_example/inc>", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + ], + options=dict( + CCFLAGS=[ + "-Wno-int-conversion", + "-Wno-unused-label", + "-Wno-unused-but-set-variable", + "-Wno-undef", + "-Wno-pointer-sign", + "-Wno-parentheses", + "-Wno-implicit-function-declaration", + "-Wno-misleading-indentation", + # TODO remove this; only for example_wlan_fast_connect.c + "-Wno-format-truncation", + "-Wno-return-type", + ], + ), +) + +# Sources - network utilities +env.AddLibrary( + name="ambz2_net", + base_dir=COMPONENT_DIR, + srcs=[ + # network - api + "+", + # network - api - wifi + "+", + # network - api - wifi - rtw_wpa_supplicant + "+", + "+", + # network - app + "+", + "+", + "+", + "+", + "+", + "+", + # network - coap + "+", + # network - http + "+", + "+", + # network + "+", + "+", + # network - websocket + "+", + # network - mdns + "+", + # network - lwip - port + "+", + # network - ssl - ssl_ram_map + "+", + "+", + ], + includes=[ + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + ], + options=dict( + CCFLAGS=[ + "-Wno-pointer-sign", + "-Wno-unused-value", + "-Wno-format", + "-Wno-implicit-function-declaration", + "-Wno-unused-function", + "-Wno-parentheses", + "-Wno-incompatible-pointer-types", + "-Wno-array-bounds", + "-Wno-stringop-overflow", + ], + ), +) + +# Sources - Bluetooth support +env.AddLibrary( + name="ambz2_bluetooth", + base_dir=join(COMPONENT_DIR, "common", "bluetooth", "realtek", "sdk"), + srcs=[ + "+", + "+", + "+", + "+", + "+", + # "+", + # "+", + "+", + "+", + ], + includes=[ + "+<.>", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + ], + options=dict( + CCFLAGS=[ + "-Wno-unused-function", + "-Wno-unused-variable", + "-Wno-implicit-function-declaration", + ], + ), +) + + +# Sources - lwIP 2.0.2 +env.AddLibrary( + name="ambz2_lwip", + base_dir=join(COMPONENT_DIR, "common", "network", "lwip", "lwip_v2.0.2"), + srcs=[ + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + ], + includes=[ + "+", + "+", + "+", + "+", + ], +) + +# Sources - mbedTLS +env.AddLibrary( + name="ambz2_mbedtls", + base_dir=join(COMPONENT_DIR, "common", "network", "ssl", "mbedtls-2.4.0"), + srcs=[ + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + ], + includes=[ + "+", + ], +) + +# Libs & linker config +env.Append( + LIBPATH=[ + # fmt: off + join(COMPONENT_DIR, "soc", "realtek", "8710c", "misc", "bsp", "lib", "common", "GCC"), + join(COMPONENT_DIR, "soc", "realtek", "8710c", "fwlib", "lib", "lib"), + join(COMPONENT_DIR, "common", "bluetooth", "realtek", "sdk", "board", "amebaz2", "lib"), + join(COMPONENT_DIR, "soc", "realtek", "8710c", "misc", "bsp", "ROM"), + # fmt: on + ], + LIBS=[ + "_soc_is", + "_wlan", + "_http", + "_dct", + "_eap", + "_p2p", + "_websocket", + "_wps", + "m", + "c", + "nosys", + "gcc", + # SCons trims the .a suffix automatically + ":hal_pmc.a.a", + ":btgap.a.a", + ], +) + +# Misc options +env.Replace( + SIZEPROGREGEXP=r"^(?:\.ram\..*?|\.psram\.[cd].*?|\.data|\.xip[\._].*?)\s+([0-9]+).*", + SIZEDATAREGEXP=r"^(?:\.ram\..*?|\.data)\s+([0-9]+).*", + SIZECHECKCMD="$SIZETOOL -A -d $SOURCES", + SIZEPRINTCMD="$SIZETOOL -B -d $SOURCES", +) + +# Build all libraries +env.BuildLibraries() + +# Main firmware outputs and actions +env.Replace( + # TODO +) diff --git a/docs/resources.md b/docs/resources.md index 173f49c..d6f8527 100644 --- a/docs/resources.md +++ b/docs/resources.md @@ -50,5 +50,6 @@ UM0201 | [Ameba Common BT Application User Manual EN](https://raw.githubusercont   | Found elsewhere AN0400 | [Ameba-D Application Note_v3_watermark](https://files.seeedstudio.com/products/102110419/Basic%20documents/AN0400%20Ameba-D%20Application%20Note_v3_watermark.pdf) AN0500 | [Realtek Ameba-ZII application note](https://www.e-paper-display.com/99IOT/00015797-AN0500-Realtek-Ameba-ZII-application-note.en_233850.pdf) +  | [Realtek Ameba-ZII datasheet v0.8](https://www.e-paper-display.com/Ameba-Z_II_DataSheet_v0r8_RTL8720Cx_20190424%29.pdf) UM0114 | [Realtek Ameba-Z datasheet v3.4](https://adelectronicsru.files.wordpress.com/2018/10/um0114-realtek-ameba-z-data-sheet-v3-4.pdf)   | [Product pages / realtek.com](https://www.realtek.com/en/products/communications-network-ics/category/802-11b-g-n) diff --git a/docs/supported_chips.md b/docs/supported_chips.md index f532bcb..8548953 100644 --- a/docs/supported_chips.md +++ b/docs/supported_chips.md @@ -7,3 +7,4 @@ - NATIVE - RTL8710BN - RTL8710BX +- RTL8720CF diff --git a/docs/supported_families.md b/docs/supported_families.md index 4bc4697..132c737 100644 --- a/docs/supported_families.md +++ b/docs/supported_families.md @@ -1,13 +1,13 @@ -Title | Name (parent) | Code | Short name & ID | Arduino Core | Source SDK ---------------------------------------------------------------------|--------------------------------|----------------------|-------------------------|--------------|---------------------------------------------------------------------------------- -Realtek Ameba1 | `-` | `-` | `RTL8710A` (0x9FFFD543) | ❌ | - -[Realtek AmebaZ](https://www.amebaiot.com/en/amebaz/) | `realtek-ambz` (`realtek-amb`) | `ambz` (`amb`) | `RTL8710B` (0x22E0D6FC) | ✔️ | `framework-realtek-amb1` ([amb1_sdk](https://github.com/ambiot/amb1_sdk)) -Realtek AmebaZ2 | `-` | `-` | `RTL8720C` (0xE08F7564) | ❌ | - -Realtek AmebaD | `-` | `-` | `RTL8720D` (0x3379CFE2) | ❌ | - -[Beken 7231T](http://www.bekencorp.com/en/goods/detail/cid/7.html) | `beken-7231t` (`beken-72xx`) | `bk7231t` (`bk72xx`) | `BK7231T` (0x675A40B0) | ✔️ | `framework-beken-bdk` ([bdk_freertos](https://github.com/bekencorp/bdk_freertos)) -[Beken 7231N](http://www.bekencorp.com/en/goods/detail/cid/39.html) | `beken-7231n` (`beken-72xx`) | `bk7231n` (`bk72xx`) | `BK7231N` (0x7B3EF230) | ✔️ | `framework-beken-bdk` ([bdk_freertos](https://github.com/bekencorp/bdk_freertos)) -Boufallo 602 | `-` | `-` | `BL602` (0xDE1270B7) | ❌ | - -Xradiotech 809 | `-` | `-` | `XR809` (0x51E903A8) | ❌ | - -Native host architecture | `host-native` | `native` | `NATIVE` (0xDEADBEEF) | ❌ | - +Title | Name (parent) | Code | Short name & ID | Arduino Core | Source SDK +--------------------------------------------------------------------|---------------------------------|----------------------|-------------------------|--------------|---------------------------------------------------------------------------------- +Realtek Ameba1 | `-` | `-` | `RTL8710A` (0x9FFFD543) | ❌ | - +[Realtek AmebaZ](https://www.amebaiot.com/en/amebaz/) | `realtek-ambz` (`realtek-amb`) | `ambz` (`amb`) | `RTL8710B` (0x22E0D6FC) | ✔️ | `framework-realtek-amb1` ([amb1_sdk](https://github.com/ambiot/amb1_sdk)) +[Realtek AmebaZ2](https://www.amebaiot.com/en/amebaz2/) | `realtek-ambz2` (`realtek-amb`) | `ambz2` (`amb`) | `RTL8720C` (0xE08F7564) | ❌ | `framework-realtek-ambz2` ([ambz2_sdk](https://github.com/ambiot/ambz2_sdk)) +Realtek AmebaD | `-` | `-` | `RTL8720D` (0x3379CFE2) | ❌ | - +[Beken 7231T](http://www.bekencorp.com/en/goods/detail/cid/7.html) | `beken-7231t` (`beken-72xx`) | `bk7231t` (`bk72xx`) | `BK7231T` (0x675A40B0) | ✔️ | `framework-beken-bdk` ([bdk_freertos](https://github.com/bekencorp/bdk_freertos)) +[Beken 7231N](http://www.bekencorp.com/en/goods/detail/cid/39.html) | `beken-7231n` (`beken-72xx`) | `bk7231n` (`bk72xx`) | `BK7231N` (0x7B3EF230) | ✔️ | `framework-beken-bdk` ([bdk_freertos](https://github.com/bekencorp/bdk_freertos)) +Boufallo 602 | `-` | `-` | `BL602` (0xDE1270B7) | ❌ | - +Xradiotech 809 | `-` | `-` | `XR809` (0x51E903A8) | ❌ | - +Native host architecture | `host-native` | `native` | `NATIVE` (0xDEADBEEF) | ❌ | - diff --git a/families.json b/families.json index 6370126..55abe5d 100644 --- a/families.json +++ b/families.json @@ -23,7 +23,17 @@ { "id": "0xE08F7564", "short_name": "RTL8720C", - "description": "Realtek AmebaZ2" + "description": "Realtek AmebaZ2", + "name": "realtek-ambz2", + "parent": "realtek-amb", + "code": "ambz2", + "parent_code": "amb", + "url": "https://www.amebaiot.com/en/amebaz2/", + "sdk": "https://github.com/ambiot/ambz2_sdk", + "framework": "framework-realtek-ambz2", + "mcus": [ + "RTL8720CF" + ] }, { "id": "0x3379CFE2", diff --git a/platform.json b/platform.json index 2c82582..4731c2a 100644 --- a/platform.json +++ b/platform.json @@ -22,6 +22,11 @@ "package": "framework-realtek-amb1", "script": "builder/frameworks/realtek-ambz-arduino.py" }, + "realtek-ambz2-sdk": { + "tilte": "Realtek AmebaZ2 - SDK", + "package": "framework-realtek-ambz2", + "script": "builder/frameworks/realtek-ambz2-sdk.py" + }, "beken-72xx-sdk": { "title": "Beken 72XX - SDK", "package": "framework-beken-bdk", @@ -48,6 +53,15 @@ ] } }, + "framework-realtek-ambz2": { + "type": "framework", + "optional": true, + "version": "https://github.com/ambiot/ambz2_sdk", + "manifest": { + "description": "SDK for AmebaZ2" + }, + "toolchain": "gccarmnoneeabi@~1.100301.0" + }, "framework-beken-bdk": { "type": "framework", "optional": true, diff --git a/platform/realtek-ambz2/config/FreeRTOSConfig.h b/platform/realtek-ambz2/config/FreeRTOSConfig.h new file mode 100644 index 0000000..f1ca201 --- /dev/null +++ b/platform/realtek-ambz2/config/FreeRTOSConfig.h @@ -0,0 +1,299 @@ +/* + * FreeRTOS Kernel V10.2.0 + * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/****************************************************************************** + See http://www.freertos.org/a00110.html for an explanation of the + definitions contained in this file. +******************************************************************************/ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE + * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. + * http://www.freertos.org/a00110.html + *----------------------------------------------------------*/ + +#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) +#include +extern uint32_t SystemCoreClock; +#endif + +/* Cortex M33 port configuration. */ +#define configENABLE_MPU 0 + +#ifdef __ARMVFP__ + #define configENABLE_FPU 1 +#else + #define configENABLE_FPU 0 +#endif + +#if defined(CONFIG_BUILD_SECURE) || defined(CONFIG_BUILD_NONSECURE) +#define configENABLE_TRUSTZONE 1 +#else +#define configENABLE_TRUSTZONE 0 +#endif + +/* Constants related to the behaviour or the scheduler. */ +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 +#define configUSE_PREEMPTION 1 +#define configUSE_TIME_SLICING 1 +#define configTICK_RATE_HZ ( ( uint32_t ) 1000 ) +#define configMAX_PRIORITIES ( 11 ) +#define configIDLE_SHOULD_YIELD 1 +#define configUSE_16_BIT_TICKS 0 /* Only for 8 and 16-bit hardware. */ + +/* Constants that describe the hardware and memory usage. */ +#define configCPU_CLOCK_HZ ( SystemCoreClock ) +#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 70 ) //number of double word +#define configMINIMAL_SECURE_STACK_SIZE ( ( unsigned short ) configMINIMAL_STACK_SIZE*4 ) //number of byte +#define configMAX_TASK_NAME_LEN ( 10 ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 160 * 1024 ) ) +#define configAPPLICATION_ALLOCATED_HEAP 0 + +/* Constants that build features in or out. */ +#define configUSE_MUTEXES 1 +#define configUSE_APPLICATION_TASK_TAG 0 +#define configUSE_NEWLIB_REENTRANT 0 +#define configUSE_CO_ROUTINES 0 +#define configUSE_COUNTING_SEMAPHORES 1 +#define configUSE_RECURSIVE_MUTEXES 1 +#define configUSE_QUEUE_SETS 1 +#define configUSE_TASK_NOTIFICATIONS 1 +#define configUSE_TRACE_FACILITY 0 + +/* Constants that define which hook (callback) functions should be used. */ +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 0 +#define configUSE_MALLOC_FAILED_HOOK 1 +#define secureconfigUSE_MALLOC_FAILED_HOOK 1 + +/* Constants provided for debugging and optimisation assistance. */ +#define configCHECK_FOR_STACK_OVERFLOW 2 + +/* Software timer definitions. */ +#define configUSE_TIMERS 1 +#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) +#define configTIMER_QUEUE_LENGTH ( 10 + 32) +#define configTIMER_TASK_STACK_DEPTH ( 512 ) + +/* Set the following definitions to 1 to include the API function, or zero + * to exclude the API function. NOTE: Setting an INCLUDE_ parameter to 0 is + * only necessary if the linker does not automatically remove functions that are + * not referenced anyway. */ +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_pcTaskGetTaskName 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 0 +#define INCLUDE_xTaskGetIdleTaskHandle 0 +#define INCLUDE_eTaskGetState 1 +#define INCLUDE_xTaskResumeFromISR 0 +#define INCLUDE_xTaskGetCurrentTaskHandle 1 +#define INCLUDE_xTaskGetSchedulerState 1 +#define INCLUDE_xSemaphoreGetMutexHolder 1 +#define INCLUDE_xTimerPendFunctionCall 1 + +/* This demo makes use of one or more example stats formatting functions. These + * format the raw data provided by the uxTaskGetSystemState() function in to + * human readable ASCII form. See the notes in the implementation of vTaskList() + * within FreeRTOS/Source/tasks.c for limitations. */ +#define configUSE_STATS_FORMATTING_FUNCTIONS 1 + +/* Dimensions a buffer that can be used by the FreeRTOS+CLI command interpreter. + * See the FreeRTOS+CLI documentation for more information: + * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_CLI/ */ +#define configCOMMAND_INT_MAX_OUTPUT_SIZE 2048 + +/* Interrupt priority configuration follows...................... */ + +/* Use the system definition, if there is one. */ + +#ifdef __NVIC_PRIO_BITS + /* __NVIC_PRIO_BITS will be specified when CMSIS is being used. */ +#if __NVIC_PRIO_BITS != 3 + #error "__NVIC_PRIO_BITS is NOT correct for RTL8710C" +#endif + #define configPRIO_BITS __NVIC_PRIO_BITS +#else + #define configPRIO_BITS 3 /* 8 priority levels */ + //#error "__NVIC_PRIO_BITS must be defined!" +#endif + +/* The lowest interrupt priority that can be used in a call to a "set priority" + * function. */ +#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 7 + +/* The highest interrupt priority that can be used by any interrupt service + * routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT + * CALL INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A + * HIGHER PRIORITY THAN THIS! (higher priorities are lower numeric values). */ +#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 2 + +/* Interrupt priorities used by the kernel port layer itself. These are generic + * to all Cortex-M ports, and do not rely on any particular library functions. */ +#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << ( 8 - configPRIO_BITS ) ) + +/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! + * See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ +#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << ( 8 - configPRIO_BITS ) ) + + +/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS +standard names - or at least those used in the unmodified vector table. */ +#define vPortSVCHandler SVC_Handler +#define xPortPendSVHandler PendSV_Handler +#define xPortSysTickHandler SysTick_Handler + +/* The #ifdef guards against the file being included from IAR assembly files. */ +#if !defined(__IASMARM__) + +/* Constants related to the generation of run time stats. */ +#define configGENERATE_RUN_TIME_STATS 0 +#if configGENERATE_RUN_TIME_STATS +#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() +#define portGET_RUN_TIME_COUNTER_VALUE() xTickCount +#undef configUSE_TRACE_FACILITY +#define configUSE_TRACE_FACILITY 1 +#define portCONFIGURE_STATS_PEROID_VALUE 1000 //unit Ticks +#endif + +#include "diag.h" +#if defined(CONFIG_BUILD_SECURE) && (CONFIG_BUILD_SECURE == 1) +#define configASSERT(x) do { \ + if( (x) == 0 ) { \ + char *pcAssertTask = "ISR"; \ + if(__get_IPSR() == 0) \ + { \ + pcAssertTask = "TSK"; \ + } \ + dbg_printf("\n\r[%s]Assert(" #x ") failed on line %d in file %s\r\n", pcAssertTask, __LINE__, __FILE__); \ + __disable_irq(); for(;;);} \ + } while(0) +#else +#define configASSERT(x) do { \ + if( (x) == 0 ) { \ + char *pcAssertTask = "ISR"; \ + if( (__get_IPSR() == 0) && (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) ) \ + { \ + pcAssertTask = pcTaskGetName( NULL ); \ + } \ + dbg_printf("\n\r[%s]Assert(" #x ") failed on line %d in file %s\r\n", pcAssertTask, __LINE__, __FILE__); \ + taskDISABLE_INTERRUPTS(); for(;;);} \ + } while(0) +#endif +#define configPRINTF( x ) dbg_printf( x ) + +#endif /* __IASMARM__ */ + +/* use the low power tickless mode */ +#define configUSE_TICKLESS_IDLE 0 +#if defined(configUSE_TICKLESS_IDLE) && configUSE_TICKLESS_IDLE +#if !defined(__IASMARM__) || (__IASMARM__ != 1) +#if !defined(CONFIG_BUILD_SECURE) || (CONFIG_BUILD_SECURE == 0) +/* At least n further complete tick periods will pass before the kernel is due to transition an application task out of the Blocked state */ +#define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 2 +/* use realtek customized low power tickless mode */ +#define configUSE_CUSTOMIZED_TICKLESS_IDLE 0 +#if defined(configUSE_CUSTOMIZED_TICKLESS_IDLE) && configUSE_CUSTOMIZED_TICKLESS_IDLE +extern void freertos_pre_sleep_processing(unsigned int *expected_idle_time); +extern void freertos_post_sleep_processing(unsigned int *expected_idle_time); +extern int freertos_ready_to_sleep(void); +extern void freertos_suppress_ticks_and_sleep(unsigned int xExpectedIdleTime); + +/* configEXPECTED_IDLE_TIME_BEFORE_SLEEP is used for native tickless support +configEXPECTED_IDLE_TIME_BEFORE_CUSTOMIZED_SLEEP is used for realtek customized low power tickless mode +if xExpectedIdleTime < configEXPECTED_IDLE_TIME_BEFORE_CUSTOMIZED_SLEEP, system will go for native tickless mode +if xExpectedIdleTime >= configEXPECTED_IDLE_TIME_BEFORE_CUSTOMIZED_SLEEP, system will got for realtek customized tickless mode +In wlan usage, this value is suggested to use value less than 80 milliseconds */ +#define configEXPECTED_IDLE_TIME_BEFORE_CUSTOMIZED_SLEEP 2 +#if configEXPECTED_IDLE_TIME_BEFORE_CUSTOMIZED_SLEEP < configEXPECTED_IDLE_TIME_BEFORE_SLEEP + #error configEXPECTED_IDLE_TIME_BEFORE_CUSTOMIZED_SLEEP must not be less than configEXPECTED_IDLE_TIME_BEFORE_SLEEP +#endif + +/* Enable tickless power saving. */ +#define configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING( x ) do { \ + if (freertos_ready_to_sleep() == FALSE) {\ + x = 0;\ + }\ + } while(0) + +#define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) do { \ + freertos_suppress_ticks_and_sleep(xExpectedIdleTime); \ + } while(0) + +/* It's magic trick that let us can use our own sleep function */ +#define configPRE_SLEEP_PROCESSING( x ) do { \ + freertos_pre_sleep_processing((unsigned int *)&x); \ + } while(0) + +#define configPOST_SLEEP_PROCESSING( x ) do { \ + freertos_post_sleep_processing((unsigned int *)&x); \ + } while(0) + +/* It's magic trick that let us can enable/disable tickless dynamically */ +#define traceLOW_POWER_IDLE_BEGIN() do { + +#define traceLOW_POWER_IDLE_END() } while (0) + +/* It's FreeRTOS related feature but it's not included in FreeRTOS design. */ +#define configUSE_WAKELOCK_PMU 1 + +#undef configMINIMAL_STACK_SIZE +#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 192 ) +#endif //#if defined(configUSE_CUSTOMIZED_TICKLESS_IDLE) && configUSE_CUSTOMIZED_TICKLESS_IDLE +#endif // #if !defined(CONFIG_BUILD_SECURE) || (CONFIG_BUILD_SECURE == 0) +#endif // #if !defined(__IASMARM__) || (__IASMARM__ != 1) +#endif // #if defined(configUSE_TICKLESS_IDLE) && configUSE_TICKLESS_IDLE + +/* Add by Realtek to re-arrange the FreeRTOS priority*/ +#define PRIORITIE_OFFSET ( 4 ) + +#if defined(__ICCARM__) +/* Keep below compiler pragma, below 10.2.0 remove them from portmacro.h +which will generate compiler warnings. +*/ +/* Suppress warnings that are generated by the IAR tools, but cannot be fixed in +the source code because to do so would cause other compilers to generate +warnings. */ +#pragma diag_suppress=Pe191 +#pragma diag_suppress=Pa082 +#endif + +#if defined(ENABLE_AMAZON_COMMON) +#include "FreeRTOSConfig_Amazon.h" +#endif +#endif /* FREERTOS_CONFIG_H */ diff --git a/platform/realtek-ambz2/config/autoconf.h b/platform/realtek-ambz2/config/autoconf.h new file mode 100644 index 0000000..ad291e9 --- /dev/null +++ b/platform/realtek-ambz2/config/autoconf.h @@ -0,0 +1,5 @@ +/* Copyright (c) Kuba Szczodrzyński 2022-07-20. */ + +#pragma once + +#include_next "autoconf.h" diff --git a/platform/realtek-ambz2/config/lwipopts.h b/platform/realtek-ambz2/config/lwipopts.h new file mode 100644 index 0000000..3ee9dab --- /dev/null +++ b/platform/realtek-ambz2/config/lwipopts.h @@ -0,0 +1,5 @@ +/* Copyright (c) Kuba Szczodrzyński 2022-07-20. */ + +#pragma once + +#include_next "lwipopts.h" diff --git a/platform/realtek-ambz2/config/platform_opts.h b/platform/realtek-ambz2/config/platform_opts.h new file mode 100644 index 0000000..66e08cc --- /dev/null +++ b/platform/realtek-ambz2/config/platform_opts.h @@ -0,0 +1,406 @@ +/** + ****************************************************************************** + *This file contains general configurations for ameba platform + ****************************************************************************** + */ + +#ifndef __PLATFORM_OPTS_H__ +#define __PLATFORM_OPTS_H__ + +/*For MP mode setting*/ +#define SUPPORT_MP_MODE 1 + +/** + * For AT cmd Log service configurations + */ +#define SUPPORT_LOG_SERVICE 1 +#if SUPPORT_LOG_SERVICE +#define LOG_SERVICE_BUFLEN 100 // can't larger than UART_LOG_CMD_BUFLEN(127) +#define CONFIG_LOG_HISTORY 0 +#if CONFIG_LOG_HISTORY +#define LOG_HISTORY_LEN 5 +#endif +#define SUPPORT_INTERACTIVE_MODE 0 // on/off wifi_interactive_mode +#define CONFIG_LOG_SERVICE_LOCK 0 +#define CONFIG_ATCMD_MP 0 // support MP AT command +#define USE_MODE 1 // for test +#endif + +/** + * For interactive mode configurations, depends on log service + */ +#if defined(SUPPORT_INTERACTIVE_MODE) && SUPPORT_INTERACTIVE_MODE +#define CONFIG_INTERACTIVE_MODE 1 +#define CONFIG_INTERACTIVE_EXT 0 +#else +#define CONFIG_INTERACTIVE_MODE 0 +#define CONFIG_INTERACTIVE_EXT 0 +#endif + +/** + * For FreeRTOS tickless configurations + */ +#define FREERTOS_PMU_TICKLESS_PLL_RESERVED 0 // In sleep mode, 0: close PLL clock, 1: reserve PLL clock +#define FREERTOS_PMU_TICKLESS_SUSPEND_SDRAM 1 // In sleep mode, 1: suspend SDRAM, 0: no act + +/******************************************************************************/ + +/** + * For common flash usage + */ +#define FLASH_BAKEUP_SECTOR (0x3000) +#define FAST_RECONNECT_DATA (0x200000 - 0x1000) +#define BT_FTL_PHY_ADDR0 (0x200000 - 0x2000) +#define BT_FTL_PHY_ADDR1 (0x200000 - 0x3000) +#define BT_FTL_BKUP_ADDR (0x200000 - 0x4000) +#define UART_SETTING_SECTOR (0x200000 - 0x5000) +#define DCT_BEGIN_ADDR \ + (0x200000 - 0x29000) /*!< DCT begin address of flash, ex: 0x200000 = 2M, the default size of DCT is 24K; ; if \ + backup enabled, the size is 48k; if wear leveling enabled, the size is 144k*/ +#define FLASH_APP_BASE \ + (0x200000 - 0xA9000 \ + ) /*!< FATFS begin address, default size used is 512KB (can be adjusted based on user requirement)*/ +#define BT_WHITELIST_BASE_1 (0x200000 - 0xA000) +#define BT_WHITELIST_PAGE_SIZE (0x1000) +#define BT_WHITELIST_BASE_2 (BT_WHITELIST_BASE_1 + BT_WHITELIST_PAGE_SIZE) +/** + * For Wlan configurations + */ +#define CONFIG_WLAN 1 +#if CONFIG_WLAN +#define CONFIG_LWIP_LAYER 1 +#define CONFIG_INIT_NET 1 // init lwip layer when start up +#define CONFIG_WIFI_IND_USE_THREAD 0 // wifi indicate worker thread +#define CONFIG_ENABLE_AP_POLLING_CLIENT_ALIVE 0 // on or off AP POLLING CLIENT + +// on/off relative commands in log service +#define CONFIG_SSL_CLIENT 0 +#define CONFIG_OTA_UPDATE 1 +#define CONFIG_BSD_TCP 0 // NOTE : Enable CONFIG_BSD_TCP will increase about 11KB code size +#define CONFIG_AIRKISS 0 // on or off tencent airkiss +#define CONFIG_UART_SOCKET 0 +#define CONFIG_JD_SMART 0 // on or off for jdsmart +#define CONFIG_JOYLINK 0 // on or off for jdsmart2.0 +#define CONFIG_QQ_LINK 0 // on or off for qqlink +#define CONFIG_AIRKISS_CLOUD 0 // on or off for weixin hardware cloud +#define CONFIG_UART_YMODEM 0 // support uart ymodem upgrade or not +#define CONFIG_TRANSPORT 0 // on or off the at command for transport socket +#define CONFIG_ALINK 0 // on or off for alibaba alink +#define CONFIG_MIIO 0 // on or off for alibaba alink +#define CONFIG_RIC 0 // on or off for RICloud +#define CONFIG_LINKKIT_AWSS 0 // on or off for ali feiyan cloud + +/* For WPS and P2P */ +#define CONFIG_ENABLE_WPS 0 +#define CONFIG_ENABLE_P2P 0 +#if CONFIG_ENABLE_WPS +#define CONFIG_ENABLE_WPS_DISCOVERY 1 +#endif +#if CONFIG_ENABLE_P2P +#define CONFIG_ENABLE_WPS_AP 1 +#undef CONFIG_WIFI_IND_USE_THREAD +#define CONFIG_WIFI_IND_USE_THREAD 1 +#endif +#if (CONFIG_ENABLE_P2P && ((CONFIG_ENABLE_WPS_AP == 0) || (CONFIG_ENABLE_WPS == 0))) +#error "If CONFIG_ENABLE_P2P, need to define CONFIG_ENABLE_WPS_AP 1" +#endif + +/* For Simple Link */ +#define CONFIG_INCLUDE_SIMPLE_CONFIG 1 +#define CONFIG_INCLUDE_DPP_CONFIG 0 +/*For fast reconnection*/ +#ifdef PLATFORM_OHOS +#define CONFIG_EXAMPLE_WLAN_FAST_CONNECT 0 +#else +#define CONFIG_EXAMPLE_WLAN_FAST_CONNECT 1 +#endif +#if CONFIG_EXAMPLE_WLAN_FAST_CONNECT +#define CONFIG_FAST_DHCP 1 +#else +#define CONFIG_FAST_DHCP 0 +#endif + +/*For wowlan service settings*/ +#define CONFIG_WOWLAN_SERVICE 0 + +#define CONFIG_GAGENT 0 +/*Disable CONFIG_EXAMPLE_WLAN_FAST_CONNECT when CONFIG_GAGENT is enabled,because + reconnect to previous AP is not suitable when re-configuration. +*/ +#if CONFIG_GAGENT +#define CONFIG_EXAMPLE_WLAN_FAST_CONNECT 0 +#endif + +#endif // end of #if CONFIG_WLAN +/*******************************************************************************/ + +/* For SSL/TLS */ +#define CONFIG_USE_POLARSSL 0 // polarssl is no longer suppported for AmebaZ2 +#define CONFIG_USE_MBEDTLS 1 +#if ((CONFIG_USE_POLARSSL == 0) && (CONFIG_USE_MBEDTLS == 0)) || \ + ((CONFIG_USE_POLARSSL == 1) && (CONFIG_USE_MBEDTLS == 1)) +#undef CONFIG_USE_POLARSSL +#define CONFIG_USE_POLARSSL 1 +#undef CONFIG_USE_MBEDTLS +#define CONFIG_USE_MBEDTLS 0 +#endif +#define CONFIG_SSL_CLIENT_PRIVATE_IN_TZ 1 + +/* For LWIP configuration */ +#define CONFIG_LWIP_DHCP_COARSE_TIMER 60 + +/*Enable CONFIG_LWIP_DHCP_FINE_TIMEOUT if lease time is less than or equal to CONFIG_LWIP_DHCP_COARSE_TIMER + * replace dhcp_coarse_tmr with dhcp_fine_tmr to manage and check for lease timeout + */ +#define CONFIG_LWIP_DHCP_FINE_TIMEOUT 0 + +/** + * For Ethernet configurations + */ +#define CONFIG_ETHERNET 0 +#if CONFIG_ETHERNET + +#define CONFIG_LWIP_LAYER 1 +#define CONFIG_INIT_NET 1 // init lwip layer when start up + +// on/off relative commands in log service +#define CONFIG_SSL_CLIENT 0 +#define CONFIG_BSD_TCP 0 // NOTE : Enable CONFIG_BSD_TCP will increase about 11KB code size + +#endif + +/* For Azure Examples */ +#define CONFIG_USE_AZURE_EMBEDDED_C 1 +#if CONFIG_USE_AZURE_EMBEDDED_C +/* For Azure embedded iot examples*/ +#define CONFIG_EXAMPLE_AZURE 0 +#if CONFIG_EXAMPLE_AZURE +#undef WAIT_FOR_ACK +#define WAIT_FOR_ACK +#endif +#else +/* For Azure iot hub telemetry example*/ +#define CONFIG_EXAMPLE_AZURE_IOTHUB_TELEMETRY 0 +/* For Azure iot hub x509 example*/ +#define CONFIG_EXAMPLE_AZURE_IOTHUB_X509 0 +#endif + +/* for CoAP example*/ +#define CONFIG_EXAMPLE_COAP 0 + +/* for lib CoAP example*/ +#define CONFIG_EXAMPLE_COAP_SERVER 0 +#define CONFIG_EXAMPLE_COAP_CLIENT 0 + +/* For WIFI GET BEACON FRAME example */ +#define CONFIG_EXAMPLE_GET_BEACON_FRAME 0 + +/* For WIFI MAC MONITOR example */ +#define CONFIG_EXAMPLE_WIFI_MAC_MONITOR 0 + +/* For HTTP CLIENT example */ +#define CONFIG_EXAMPLE_HTTP_CLIENT 0 + +/* For MQTT example */ +#define CONFIG_EXAMPLE_MQTT 0 + +/* For multicast example */ +#define CONFIG_EXAMPLE_MCAST 0 + +/* For XML example */ +#define CONFIG_EXAMPLE_XML 0 + +/* For JSON example */ +#define CONFIG_EXAMPLE_CJSON 0 + +/* For socket select example */ +#define CONFIG_EXAMPLE_SOCKET_SELECT 0 + +/* For socket nonblocking connect example */ +#define CONFIG_EXAMPLE_NONBLOCK_CONNECT 0 + +/* For socket TCP bidirectional transmission example */ +#define CONFIG_EXAMPLE_SOCKET_TCP_TRX 0 + +/* For ssl download example */ +#define CONFIG_EXAMPLE_SSL_DOWNLOAD 0 + +/* For http download example */ +#define CONFIG_EXAMPLE_HTTP_DOWNLOAD 0 + +/* For httpc example */ +#define CONFIG_EXAMPLE_HTTPC 0 + +/* For Amazon ffs example */ +#define CONFIG_EXAMPLE_FFS 0 +#if CONFIG_EXAMPLE_FFS +#undef CONFIG_EXAMPLE_WLAN_FAST_CONNECT +#define CONFIG_EXAMPLE_WLAN_FAST_CONNECT 0 +#undef CONFIG_FAST_DHCP +#define CONFIG_FAST_DHCP 0 +#endif + +/* For httpd example */ +#define CONFIG_EXAMPLE_HTTPD 0 + +/* For tcp keepalive example */ +#define CONFIG_EXAMPLE_TCP_KEEPALIVE 0 + +/* For sntp show time example */ +#define CONFIG_EXAMPLE_SNTP_SHOWTIME 0 + +/* For websocket client example */ +#define CONFIG_EXAMPLE_WEBSOCKET_CLIENT 0 + +/* For DCT example*/ +#define CONFIG_EXAMPLE_DCT 0 + +/****************** For EAP method example *******************/ +#define CONFIG_EXAMPLE_EAP 0 + +// on/off specified eap method +#define CONFIG_ENABLE_PEAP 0 +#define CONFIG_ENABLE_TLS 0 +#define CONFIG_ENABLE_TTLS 0 + +// optional feature: whether to verify the cert of radius server +#define ENABLE_EAP_SSL_VERIFY_SERVER 0 + +#if CONFIG_ENABLE_PEAP || CONFIG_ENABLE_TLS || CONFIG_ENABLE_TTLS +#define CONFIG_ENABLE_EAP +#undef CONFIG_EXAMPLE_WLAN_FAST_CONNECT +#undef CONFIG_FAST_DHCP +#define CONFIG_EXAMPLE_WLAN_FAST_CONNECT 0 +#define CONFIG_FAST_DHCP 0 +#endif + +#if CONFIG_ENABLE_TLS +#define ENABLE_EAP_SSL_VERIFY_CLIENT 1 +#else +#define ENABLE_EAP_SSL_VERIFY_CLIENT 0 +#endif +/******************End of EAP configurations*******************/ + +/* For FATFS example*/ +#define CONFIG_EXAMPLE_FATFS 0 +#if CONFIG_EXAMPLE_FATFS +#define CONFIG_FATFS_EN 1 +#if CONFIG_FATFS_EN +// fatfs version +#define FATFS_R_10C +// fatfs disk interface +#define FATFS_DISK_USB 0 +#define FATFS_DISK_SD 0 +#define FATFS_DISK_FLASH 1 +#endif +#endif + +/* For iNIC host example*/ +#ifdef CONFIG_INIC_GSPI_HOST // this flag is defined in IAR project +#define CONFIG_EXAMPLE_INIC_GSPI_HOST 1 +#if CONFIG_EXAMPLE_INIC_GSPI_HOST + +#define CONFIG_INIC_HOST 1 + +#undef CONFIG_WLAN +#define CONFIG_WLAN 0 +#undef CONFIG_INCLUDE_SIMPLE_CONFIG +#define CONFIG_INCLUDE_SIMPLE_CONFIG 0 +#undef CONFIG_EXAMPLE_WLAN_FAST_CONNECT +#define CONFIG_EXAMPLE_WLAN_FAST_CONNECT 0 +#undef CONFIG_LWIP_LAYER +#define CONFIG_LWIP_LAYER 1 +#undef CONFIG_BSD_TCP +#define CONFIG_BSD_TCP 1 + +#endif +#endif + +/* For wifi scenarios example (Wi-Fi, WPS enrollee, P2P GO) */ +// also need to enable WPS and P2P +#define CONFIG_EXAMPLE_WLAN_SCENARIO 0 + +/* For broadcast example */ +#define CONFIG_EXAMPLE_BCAST 0 + +/* For high-load memory use case memory usage */ +#define CONFIG_EXAMPLE_HIGH_LOAD_MEMORY_USE 0 + +/* For rarp example */ +#define CONFIG_EXAMPLE_RARP 0 + +/* For ssl server example */ +#define CONFIG_EXAMPLE_SSL_SERVER 0 + +/*For secure boot example */ +#define CONFIG_EXAMPLE_SECURE_BOOT 0 + +/*For secure storage example */ +#define CONFIG_EXAMPLE_SECURE_STORAGE 0 + +/* For ota update http example */ +#define CONFIG_EXAMPLE_OTA_HTTP 0 + +/*For wifi roaming example*/ +#define CONFIG_EXAMPLE_WIFI_ROAMING 0 + +/* for tickless roaming */ +#define CONFIG_EXAMPLE_TICKLESS_WIFI_ROAMING 0 + +/*For ipv6 example*/ +#define CONFIG_EXAMPLE_IPV6 0 + +#if CONFIG_ENABLE_WPS +#define WPS_CONNECT_RETRY_COUNT 4 +#define WPS_CONNECT_RETRY_INTERVAL 5000 // in ms +#endif + +#define AUTO_RECONNECT_COUNT 8 +#define AUTO_RECONNECT_INTERVAL 5 // in sec + +/*For trust zone example */ +#define CONFIG_EXAMPLE_TRUST_ZONE 0 + +/* For Amazon FreeRTOS SDK example */ +#define CONFIG_EXAMPLE_AMAZON_FREERTOS 0 + +#define CONFIG_EXAMPLE_AMAZON_AFQP_TESTS 0 + +#if (defined(CONFIG_EXAMPLE_AMAZON_FREERTOS) && CONFIG_EXAMPLE_AMAZON_FREERTOS) || \ + (defined(CONFIG_EXAMPLE_AMAZON_AFQP_TESTS) && CONFIG_EXAMPLE_AMAZON_AFQP_TESTS) +#undef CONFIG_INCLUDE_SIMPLE_CONFIG +#undef CONFIG_EXAMPLE_WLAN_FAST_CONNECT +#undef CONFIG_FAST_DHCP +#define CONFIG_INCLUDE_SIMPLE_CONFIG 0 +#define CONFIG_EXAMPLE_WLAN_FAST_CONNECT 0 +#define CONFIG_FAST_DHCP 0 +#if defined(CONFIG_BUILD_SECURE) +#define ENABLE_AMAZON_COMMON +#endif +#if defined(CONFIG_BUILD_NONSECURE) && (CONFIG_SSL_CLIENT_PRIVATE_IN_TZ == 0) +#undef SUPPORT_LOG_SERVICE +#define SUPPORT_LOG_SERVICE 0 +#endif +#endif + +/* For UART Module AT command example */ +#define CONFIG_EXAMPLE_UART_ATCMD 0 +#if (defined(CONFIG_EXAMPLE_UART_ATCMD) && CONFIG_EXAMPLE_UART_ATCMD) +#define UART_SETTING_BACKUP_SECTOR (FLASH_BAKEUP_SECTOR) +#undef CONFIG_OTA_UPDATE +#define CONFIG_OTA_UPDATE 1 +#undef CONFIG_TRANSPORT +#define CONFIG_TRANSPORT 1 +#undef LOG_SERVICE_BUFLEN +#define LOG_SERVICE_BUFLEN 1600 +#undef CONFIG_LOG_SERVICE_LOCK +#define CONFIG_LOG_SERVICE_LOCK 1 +#undef CONFIG_EXAMPLE_WLAN_FAST_CONNECT +#define CONFIG_EXAMPLE_WLAN_FAST_CONNECT 0 +#endif + +#if (SUPPORT_MP_MODE && CONFIG_MIIO) +#define CONFIG_MIIO_MP 0 // miio mp test and rw private data +#endif + +#endif diff --git a/platform/realtek-ambz2/config/platform_opts_bt.h b/platform/realtek-ambz2/config/platform_opts_bt.h new file mode 100644 index 0000000..06d2278 --- /dev/null +++ b/platform/realtek-ambz2/config/platform_opts_bt.h @@ -0,0 +1,69 @@ +#ifndef __PLATFORM_OPTS_BT_H__ +#define __PLATFORM_OPTS_BT_H__ + +#define CONFIG_BT 0 + +#if CONFIG_BT +#define CONFIG_FTL_ENABLED +#define CONFIG_BT_CONFIG 0 +#define CONFIG_BT_AIRSYNC_CONFIG 0 +#define CONFIG_BT_PERIPHERAL 0 +#define CONFIG_BT_CENTRAL 0 +#define CONFIG_BT_SCATTERNET 0 +#define CONFIG_BT_BEACON 0 +#define CONFIG_BT_FUZZ_TEST 0 +#define CONFIG_BT_OTA_CENTRAL_CLIENT 0 +#define CONFIG_BT_DATATRANS 0 +#define CONFIG_BT_MESH_PROVISIONER 0 +#define CONFIG_BT_MESH_DEVICE 0 +#define CONFIG_BT_MESH_PROVISIONER_MULTIPLE_PROFILE 0 +#define CONFIG_BT_MESH_DEVICE_MULTIPLE_PROFILE 0 +#define CONFIG_BT_MESH_CENTRAL 0 +#define CONFIG_BT_MESH_PERIPHERAL 0 +#define CONFIG_BT_MESH_SCATTERNET 0 +#define CONFIG_BT_MESH_PROVISIONER_RTK_DEMO 0 +#define CONFIG_BT_MESH_DEVICE_RTK_DEMO 0 +#define CONFIG_BT_MESH_TEST 0 +#define CONFIG_BT_ONLY_WITHOUT_WLAN 0 +#endif // CONFIG_BT + +#if defined CONFIG_BT_SCATTERNET && CONFIG_BT_SCATTERNET +#undef CONFIG_BT_PERIPHERAL +#undef CONFIG_BT_CENTRAL +#define CONFIG_BT_PERIPHERAL 1 +#define CONFIG_BT_CENTRAL 1 +#endif + +#if defined CONFIG_BT_CENTRAL && CONFIG_BT_CENTRAL +#define CONFIG_BT_USER_COMMAND 0 +#define CONFIG_BT_WHITE_LIST_TO_FLASH 0 +#endif + +#if defined CONFIG_BT_OTA_CENTRAL_CLIENT && CONFIG_BT_OTA_CENTRAL_CLIENT +#define CONFIG_BT_OTA_CENTRAL_CLIENT_SPLIT 0 +#endif + +#if ((defined CONFIG_BT_MESH_PROVISIONER && CONFIG_BT_MESH_PROVISIONER) || (defined CONFIG_BT_MESH_DEVICE && CONFIG_BT_MESH_DEVICE) || (defined CONFIG_BT_MESH_PROVISIONER_MULTIPLE_PROFILE && CONFIG_BT_MESH_PROVISIONER_MULTIPLE_PROFILE) || (defined CONFIG_BT_MESH_DEVICE_MULTIPLE_PROFILE && CONFIG_BT_MESH_DEVICE_MULTIPLE_PROFILE)) +#define CONFIG_BT_MESH_USER_API 1 +#define CONFIG_BT_MESH_IDLE_CHECK 0 +#endif + +#if defined CONFIG_BT_MESH_PROVISIONER_RTK_DEMO && CONFIG_BT_MESH_PROVISIONER_RTK_DEMO +#undef CONFIG_BT_CONFIG +#define CONFIG_BT_CONFIG 1 +#endif + +#if ((defined CONFIG_BT_MESH_PROVISIONER && CONFIG_BT_MESH_PROVISIONER) && (defined CONFIG_BT_MESH_DEVICE && CONFIG_BT_MESH_DEVICE)) +#error "CONFIG_BT_MESH_PROVISIONER & CONFIG_BT_MESH_DEVICE can not open at the same time" +#endif + +#if ((defined CONFIG_BT_MESH_PROVISIONER_MULTIPLE_PROFILE && CONFIG_BT_MESH_PROVISIONER_MULTIPLE_PROFILE) && (defined CONFIG_BT_MESH_DEVICE_MULTIPLE_PROFILE && CONFIG_BT_MESH_DEVICE_MULTIPLE_PROFILE)) +#error \ + "CONFIG_BT_MESH_PROVISIONER_MULTIPLE_PROFILE & CONFIG_BT_MESH_DEVICE_MULTIPLE_PROFILE can not open at the same time" +#endif + +#if (((defined CONFIG_BT_MESH_CENTRAL && CONFIG_BT_MESH_CENTRAL) && (defined CONFIG_BT_MESH_PERIPHERAL && CONFIG_BT_MESH_PERIPHERAL)) || ((defined CONFIG_BT_MESH_CENTRAL && CONFIG_BT_MESH_CENTRAL) && (defined CONFIG_BT_MESH_SCATTERNET && CONFIG_BT_MESH_SCATTERNET)) || ((defined CONFIG_BT_MESH_PERIPHERAL && CONFIG_BT_MESH_PERIPHERAL) && (defined CONFIG_BT_MESH_SCATTERNET && CONFIG_BT_MESH_SCATTERNET)) || ((defined CONFIG_BT_MESH_CENTRAL && CONFIG_BT_MESH_CENTRAL) && (defined CONFIG_BT_MESH_PERIPHERAL && CONFIG_BT_MESH_PERIPHERAL) && (defined CONFIG_BT_MESH_SCATTERNET && CONFIG_BT_MESH_SCATTERNET))) +#error "Only one of CONFIG_BT_MESH_CENTRAL, CONFIG_BT_MESH_PERIPHERAL and CONFIG_BT_MESH_SCATTERNET can be enabled" +#endif + +#endif // __PLATFORM_OPTS_BT_H__ diff --git a/platform/realtek-ambz2/fixups/inc/time64.h b/platform/realtek-ambz2/fixups/inc/time64.h new file mode 100644 index 0000000..42c8797 --- /dev/null +++ b/platform/realtek-ambz2/fixups/inc/time64.h @@ -0,0 +1,8 @@ +/* Copyright (c) Kuba Szczodrzyński 2022-07-21. */ + +#pragma once + +#include_next "time64.h" + +// GCC 10.3.1 does not provide these structs by default +#include diff --git a/platform/realtek-ambz2/ld/rtl8710c_ram.ld b/platform/realtek-ambz2/ld/rtl8710c_ram.ld new file mode 100644 index 0000000..3977d81 --- /dev/null +++ b/platform/realtek-ambz2/ld/rtl8710c_ram.ld @@ -0,0 +1,364 @@ +/* Linker script to configure memory regions. */ + +/* LT changes: added .ARM.exidx section */ + +/* !! the include symbole may failed if the symbol file name is too long!! */ +INCLUDE "romsym_is.so" + +MEMORY +{ + /* The vector table, it must start with 256 bytes aligned address */ + VECTORS_RAM (rwx) : ORIGIN = 0x10000000, LENGTH = 0x100000A0 - 0x10000000 + + /* 0x100000A0 ~ 0x10000480 reserved for ROM code */ + + /* RAM functions entry table */ + RAM_FUN_TABLE (rwx) : ORIGIN = 0x10000480, LENGTH = 0x100004F0 - 0x10000480 + + /* RAM image Signature */ + RAM_IMG_SIGN (rwx) : ORIGIN = 0x100004F0, LENGTH = 0x10000500 - 0x100004F0 + + /* Internal RAM for program data & text */ + DTCM_RAM (wrx) : ORIGIN = 0x10000500, LENGTH = 0x1003FA00 - 0x10000500 + + /* 0x1003FE70 - 0x1003FA00 is reserved for ROM(NS) code */ + + /* External PSRAM for text, rodata & data */ + PSRAM (rwx) : ORIGIN = 0x60000000, LENGTH = 0x60400000 - 0x60000000 + BTRACE (rx) : ORIGIN = 0x00800000, LENGTH = 0x00C00000 - 0x00800000 /* Bluetooth Trace */ + /* Flash memory for XIP */ + /* XIP image must start with 64K(0x10000) aligned address */ + /* XIP Chiper section: TEXT/RODATA in this section can be encrypted (decrypt by SCE) */ + XIP_FLASH_C (rx) : ORIGIN = 0x9B000000, LENGTH = 0x9B800000 - 0x9B000000 + /* XIP Plantext section: RODATA in this section will not be encrypted */ + XIP_FLASH_P (rx) : ORIGIN = 0x9B800000, LENGTH = 0x9BFF0000 - 0x9B800000 +} + +/* Library configurations */ +GROUP(libgcc.a libc.a libm.a libnosys.a) + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + * __Vectors_End + * __Vectors_Size + */ +_start_addr = 0x1000; +ENTRY(_start_addr) +__eram_end__ = ORIGIN(PSRAM) + LENGTH(PSRAM); +__psram_start__ = ORIGIN(PSRAM); +__psram_end__ = ORIGIN(PSRAM) + LENGTH(PSRAM); + +SECTIONS +{ + .ram.vector : + { + . = ALIGN(256); + __ram_vector_start__ = .; + KEEP(*(.ram_vector_table)) + __ram_vector_end__ = .; + . = ALIGN(4); + } > VECTORS_RAM + + .ram.func.table : + { + . = ALIGN(32); + __ram_start_table_start__ = .; + KEEP(*(SORT(.start.ram.data*))) + __ram_start_table_end__ = .; + + } > RAM_FUN_TABLE + + .ram.img.signature : + { + __ram_img_signature__ = .; + KEEP(*(.start.ram.sign*)) + } > RAM_IMG_SIGN + + .psram.data : AT (__psram_etext) + { + . = ALIGN(16); + __psram_etext = .; + __psram_data_start__ = .; + + *(.psram.data*) + + __psram_data_end__ = .; + + } > PSRAM + + .bluetooth_trace.text : + { + __btrace_start__ = .; + *(.BTTRACE) + __btrace_end__ = .; + } > BTRACE + + .data : + { + . = ALIGN(16); + __etext = .; + __fw_img_start__ = .; + __data_start__ = .; + *(vtable) + *(.sram.data*) + *(.data*) + + . = ALIGN(4); + /* preinit data */ + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP(*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + + . = ALIGN(4); + /* init data */ + PROVIDE_HIDDEN (__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + + . = ALIGN(4); + /* finit data */ + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP(*(SORT(.fini_array.*))) + KEEP(*(.fini_array)) + PROVIDE_HIDDEN (__fini_array_end = .); + + KEEP(*(.jcr*)) + . = ALIGN(4); + /* All data end */ + __data_end__ = .; + } > DTCM_RAM + + .xip_c_reserved : + { + /* XIP image section must start with 64K aligned address, reserve 0x140 for image header */ + . += 0x140; + /* If the XIP is the 1st sub-image, then we should reserve 0xE0 bytes meore for OTA Sign. and 6 Public Key */ + /*. += 0xE0; */ + } > XIP_FLASH_C + + .xip_p_reserved : + { + /* XIP image section must start with 64K aligned address, reserve 0x140 for image header */ + . += 0x140; + /* If the XIP is the 1st sub-image, then we should reserve 0xE0 bytes meore for OTA Sign. and 6 Public Key */ + /*. += 0xE0; */ + } > XIP_FLASH_P + + .psram.code_text : + { + . = ALIGN(16); + __psram_code_text_start__ = .; + + *(.psram.text*) + + __psram_code_text_end__ = .; + } > PSRAM + + .psram.code_rodata : + { + . = ALIGN(16); + __psram_code_rodata_start__ = .; + + *(.psram.rodata*) + + . = ALIGN(4); + __psram_code_rodata_end__ = .; + } > PSRAM + + .psram.bss : + { + . = ALIGN(16); + __psram_bss_start__ = .; + + *(.psram.bss*) + + __psram_bss_end__ = .; + + . = ALIGN(32); + __eram_bss_end__ = .; + } > PSRAM + + .ram.code_text : + { + . = ALIGN(32); + __ram_entry_text_start__ = .; + *(.ram_entry_func.text*) + __ram_entry_text_end__ = .; + + . = ALIGN(32); + __ram_code_text_start__ = .; + + /* SPI flash controller related code should be located in SRAM, never locates them in XIP */ + *hal_spic*.o(.text*) + *hal_flash*.o(.text*) + + /* LPDDR controller related code should be located in SRAM, never locates them in LPDDR */ + *hal_lpcram*.o(.text*) + + *ram_start*.o(.text*) + *hal_power_mode*.o(.text*) + *hal_sys_ctrl*.o(.text*) + *rtl8710c_pinmux_patch*.o(.text*) + *hal_syson*.o(.text*) + *hal_pinmux*.o(.text*) + *hal_efuse*.o(.text*) + *sys_irq*.o(.text*) + + *(.lpddr.text*) + *(.sram.text*) + . = ALIGN(4); + __ram_code_text_end__ = .; + } > DTCM_RAM + + .ram.code_rodata : + { + . = ALIGN(16); + __ram_code_rodata_start__ = .; + + /* SPI flash controller related code should be located in SRAM, never locates them in XIP */ + *hal_spic*.o(.rodata*) + *hal_flash*.o(.rodata*) + + /* LPDDR controller related code should be located in SRAM, never locates them in LPDDR */ + *hal_lpcram*.o(.rodata*) + + *ram_start*.o(.rodata*) + *hal_power_mode*.o(.rodata*) + *hal_sys_ctrl*.o(.rodata*) + *rtl8710c_pinmux_patch*.o(.rodata*) + *hal_syson*.o(.rodata*) + *hal_pinmux*.o(.rodata*) + *hal_efuse*.o(.rodata*) + *sys_irq*.o(.rodata*) + + . = ALIGN(4); + __ram_code_rodata_end__ = .; + } > DTCM_RAM + + .xip.code_c : + { + /* For xip encrypted section ram image signature */ + KEEP(*(.xip.ram.sign.s)) + /* code and RO data in this section will be encrypted */ + . = ALIGN(16); + __xip_code_text_start__ = .; + + *(.xip.text*) + + *(.text*) + + /* put RO data sections need to be encrypted here */ + *(.xip.sec_rodata*) + + __xip_code_text_end__ = .; + } > XIP_FLASH_C + + .xip.code_p : + { + /* code and RO data in this section will NOT be encrypted */ + /* put DMA RO data here */ + __xip_code_rodata_start__ = .; + + *(.xip.rodata*) + + *(.rodata*) + *(.rodata.str1*) + + . = ALIGN(4); + __xip_code_rodata_end__ = .; + } > XIP_FLASH_P + + .ARM.exidx : + { + __exidx_start = .; + *(.ARM.exidx*) + *(.gnu.linkonce.armexidx.*) + __exidx_end = .; + } > XIP_FLASH_P + + .system_restore_data : + { + /* data in this section will not be initialed by ram_start() */ + /* some of them will be initialed by boot loader */ + . = ALIGN(32); + *(.sys_restore.bss*) + *(.ram.bss.noinit*) + } > DTCM_RAM + + .bss : + { + . = ALIGN(16); + __bss_start__ = .; + *(.sram.bss*) + *(.bss*) + *(COMMON) + } > DTCM_RAM + + .non_secure.bss : + { + . = ALIGN(16); + __ns_bss_start__ = .; + *(.nonsecure.bss*) + + . = ALIGN(4); + __ns_bss_end__ = .; + + . = ALIGN(32); + __bss_end__ = .; + } > DTCM_RAM + + .heap (COPY): + { + __HeapBase = .; + __end__ = .; + end = __end__; + KEEP(*(.heap*)) + __HeapLimit = .; + } > DTCM_RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + KEEP(*(.stack*)) + } > DTCM_RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(DTCM_RAM) + LENGTH(DTCM_RAM); + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + PROVIDE(__sram_end__ = __StackLimit); + + /* Check if data + heap + stack exceeds RAM limit */ + /* TODO: ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") */ +}