From b8965817f6c99205e5590a67fb3d3d9ac2b3f4d5 Mon Sep 17 00:00:00 2001
From: NonPIayerCharacter
<18557343+NonPIayerCharacter@users.noreply.github.com>
Date: Sun, 10 Aug 2025 18:08:33 +0300
Subject: [PATCH] bl602 deep sleep & ecr sdk update (#1743)
* bl602 deep sleep & ecr sdk update
* esp8266 disable wpa3
* platforms.md
---
.github/workflows/workflow.yaml | 2 +-
Makefile | 4 +-
docs/platforms.md | 54 +++++++++----------
bouffalo.mk => platforms/BL602/bouffalo.mk | 2 +-
platforms/BL602/pre_build.sh | 3 --
platforms/ECR6600/OpenBeken.mk | 4 +-
platforms/ESP8266/sdkconfig.defaults | 4 +-
sdk/OpenECR6600 | 2 +-
src/cmnds/cmd_main.c | 51 +++++++++++++++++-
.../hal/ecr6600/hal_main_ecr6600.c | 17 +++++-
src/hal/ecr6600/hal_wifi_ecr6600.c | 2 +
src/hal/espidf/hal_wifi_espidf.c | 4 +-
src/hal/realtek/hal_wifi_realtek.c | 4 +-
src/httpserver/http_fns.c | 23 +++++++-
src/new_pins.c | 28 ++++++++++
15 files changed, 158 insertions(+), 46 deletions(-)
rename bouffalo.mk => platforms/BL602/bouffalo.mk (71%)
rename platforms/ECR6600/main.c => src/hal/ecr6600/hal_main_ecr6600.c (84%)
diff --git a/.github/workflows/workflow.yaml b/.github/workflows/workflow.yaml
index e5806a84b..6cf468f43 100644
--- a/.github/workflows/workflow.yaml
+++ b/.github/workflows/workflow.yaml
@@ -324,7 +324,7 @@ jobs:
output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}.img
output/${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}${{ matrix.variant != 'default' && '_' || '' }}${{ matrix.variant != 'default' && matrix.variant || '' }}.factory.bin
if-no-files-found: warn
-
+
build_8266:
name: Build ESP8266
needs: refs
diff --git a/Makefile b/Makefile
index 9cbb4582e..eb1b7388a 100644
--- a/Makefile
+++ b/Makefile
@@ -112,7 +112,7 @@ sdk/OpenBL602/customer_app/bl602_sharedApp/bl602_sharedApp/shared:
#so only linking source and copying required file
@echo mkdir shared
mkdir sdk/OpenBL602/customer_app/bl602_sharedApp/bl602_sharedApp/shared
- cp ./bouffalo.mk sdk/OpenBL602/customer_app/bl602_sharedApp/bl602_sharedApp/shared
+ cp ./platforms/BL602/bouffalo.mk sdk/OpenBL602/customer_app/bl602_sharedApp/bl602_sharedApp/shared
@echo Create symlink for $(APP_NAME) into sdk folder
ln -s "$(shell pwd)/src/" "sdk/OpenBL602/customer_app/bl602_sharedApp/bl602_sharedApp/shared/src"
ln -s "$(shell pwd)/libraries/" "sdk/OpenBL602/customer_app/bl602_sharedApp/bl602_sharedApp/shared/libraries"
@@ -393,7 +393,7 @@ build-BK7231: $(SDK_PATH)/apps/$(APP_NAME)
rm $(SDK_PATH)/platforms/$(TARGET_PLATFORM)/toolchain/$(APPS_BUILD_PATH)/tools/generate/$(APP_NAME)_*.bin || /bin/true
OpenBL602: prebuild_OpenBL602 sdk/OpenBL602/customer_app/bl602_sharedApp/bl602_sharedApp/shared
- $(MAKE) -C sdk/OpenBL602/customer_app/bl602_sharedApp USER_SW_VER=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) CONFIG_CHIP_NAME=BL602 CONFIG_LINK_ROM=1 -j
+ $(MAKE) -C sdk/OpenBL602/customer_app/bl602_sharedApp USER_SW_VER=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) CONFIG_CHIP_NAME=BL602 CONFIG_LINK_ROM=1 -j $(shell nproc)
$(MAKE) -C sdk/OpenBL602/customer_app/bl602_sharedApp USER_SW_VER=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) CONFIG_CHIP_NAME=BL602 bins
mkdir -p output/$(APP_VERSION)
cp sdk/OpenBL602/customer_app/bl602_sharedApp/build_out/bl602_sharedApp.bin output/$(APP_VERSION)/OpenBL602_$(APP_VERSION).bin
diff --git a/docs/platforms.md b/docs/platforms.md
index 975399558..1f488443a 100644
--- a/docs/platforms.md
+++ b/docs/platforms.md
@@ -1,29 +1,29 @@
-| Platform | Family | Wi-Fi | WPA3 | OTA | GPIO | GPIO IRQ | UART | PWM | ADC | Deep sleep | WDT |
-|---------------------------------------------------------|-----------------|--------|------|--------|------|----------|------|------|-----|------------|-----|
-| BK7231T | Beken | ✅ | ✅¹² | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
-| BK7231N | Beken | ✅ | ✅¹² | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
-| BK7231S/BK7231U | Beken | ✅ | ✅ | ✅¹ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
-| BK7238 | Beken | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
-| BK7252 | Beken | ✅ | ✅ | ✅¹ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
-| BK7252N | Beken | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
-| XR809 | XRadio | ✅ | ❌ | ❌⁵ | ✅ | ✅ | ✅ | ✅⁸ | ✅ | ✅ | ✅ |
-| XR806 | XRadio | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅⁸ | ✅ | ✅ | ✅ |
-| XR872/XF16 | XRadio | ✅ | ✅ | ✅² | ✅ | ✅ | ✅ | ✅⁸ | ✅ | ✅ | ✅ |
-| BL602/LF686 | Bouffalo Lab | ✅ | ✅ | ✅⁴ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ |
-| W800/W801 | WinnerMicro | ✅ | ❌ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ❌ | ✅ |
-| W600/W601 | WinnerMicro | ✅ | ❌ | ✅ | ✅ | ✅ | ❓ | ✅ | ✅ | ❌ | ✅ |
-| LN882H | Lightning Semi | ✅ | ❌¹³ | ✅⁴ | ✅ | ✅ | ❌ | ✅ | ⚠️ | ❌ | ✅ |
-| ESP8285/ESP8266 | Espressif | ✅ | ❓ | ✅²'⁴ | ✅ | ✅ | ✅ | ✅⁷ | ❌ | ⚠️ | ❓⁹ |
-| ESP32
-C2
-C3
-C5
-C6
-C61
-S2
-S3 | Espressif | ✅ | ❓ | ✅⁴ | ✅ | ✅ | ✅ | ✅ | ❓ | ✅¹⁰ | ✅ |
-| TR6260 | Transa Semi | ✅ | ❌ | ⚠️³'⁴ | ✅ | ❌ | ❌ | ✅⁸ | ❌ | ❌ | ✅⁹ |
-| RTL8711AM (Ameba1) | Realtek | ✅ | ❓ | ✅⁴ | ✅ | ✅ | ✅ | ✅⁸ | ❌ | ❌ | ✅ |
-| RTL8710B (AmebaZ) | Realtek | ✅ | ✅ | ✅⁴ | ✅ | ✅ | ✅ | ✅⁸ | ❌ | ❌ | ✅ |
-| RTL8710C/RTL8720C (AmebaZ2) | Realtek | ✅ | ✅ | ✅⁴ | ✅ | ✅ | ✅ | ✅⁸ | ❌ | ❌ | ✅ |
-| RTL8720D (AmebaD)
RTL872xCSM/RTL8720CS (AmebaCS) | Realtek | ✅ | ✅ | ✅⁴ | ✅ | ✅ | ✅ | ✅⁸ | ❌ | ❌ | ✅ |
-| RTL8721DA/RTL8711DAF (AmebaDplus) | Realtek | ✅ | ✅ | ✅⁶ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ |
-| RTL8720E/RTL8710ECF (AmebaLite) | Realtek | ✅ | ✅ | ✅⁶ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ |
-| ECR6600 | ESWIN | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅⁸ | ⚠️ | ⚠️¹¹ | ✅ |
+| Platform | Family | Wi-Fi 5GHz | WPA3 | OTA | GPIO | GPIO IRQ | UART | PWM | ADC | Deep sleep | WDT | SPI LED |
+|---------------------------------------------------------|-----------------|------------|------|--------|------|----------|------|------|-----|------------|-----|---------|
+| BK7231T | Beken | ❌ | ✅¹² | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅¹² |
+| BK7231N | Beken | ❌ | ✅¹² | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
+| BK7231S/BK7231U | Beken | ❌ | ✅ | ✅¹ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
+| BK7238 | Beken | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
+| BK7252 | Beken | ❌ | ✅ | ✅¹ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
+| BK7252N | Beken | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
+| XR809 | XRadio | ❌ | ❌ | ❌⁵ | ✅ | ✅ | ✅ | ✅⁸ | ✅ | ✅ | ✅ | ❌ |
+| XR806 | XRadio | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅⁸ | ✅ | ✅ | ✅ | ❌ |
+| XR872/XF16 | XRadio | ❌ | ✅ | ✅² | ✅ | ✅ | ✅ | ✅⁸ | ✅ | ✅ | ✅ | ❌ |
+| BL602/LF686 | Bouffalo Lab | ❌ | ✅ | ✅⁴ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ |
+| W800/W801 | WinnerMicro | ❌ | ❌ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ |
+| W600/W601 | WinnerMicro | ❌ | ❌ | ✅ | ✅ | ✅ | ❓ | ✅ | ✅ | ❌ | ✅ | ❌ |
+| LN882H | Lightning Semi | ❌ | ✅ | ✅⁴ | ✅ | ✅ | ❌ | ✅ | ⚠️ | ❌ | ✅ | ✅ |
+| ESP8285/ESP8266 | Espressif | ❌ | ⚠️¹⁴ | ✅²'⁴ | ✅ | ✅ | ✅ | ✅⁷ | ❌ | ⚠️ | ❓⁹ | ❌ |
+| ESP32
-C2
-C3
-C5
-C6
-C61
-S2
-S3 | Espressif | ⚠️¹³ | ⚠️¹⁴ | ✅⁴ | ✅ | ✅ | ✅ | ✅ | ❓ | ✅¹⁰ | ✅ | ✅ |
+| TR6260 | Transa Semi | ❌ | ❌ | ⚠️³'⁴ | ✅ | ❌ | ❌ | ✅⁸ | ❌ | ❌ | ✅⁹ | ❌ |
+| RTL8711AM (Ameba1) | Realtek | ❌ | ⚠️ | ✅⁴ | ✅ | ✅ | ✅ | ✅⁸ | ❌ | ❌ | ✅ | ❌ |
+| RTL8710B (AmebaZ) | Realtek | ❌ | ✅ | ✅⁴ | ✅ | ✅ | ✅ | ✅⁸ | ❌ | ❌ | ✅ | ❌ |
+| RTL8710C/RTL8720C (AmebaZ2) | Realtek | ❌ | ✅ | ✅⁴ | ✅ | ✅ | ✅ | ✅⁸ | ❌ | ❌ | ✅ | ❌ |
+| RTL8720D (AmebaD)
RTL872xCSM/RTL8720CS (AmebaCS) | Realtek | ✅ | ✅ | ✅⁴ | ✅ | ✅ | ✅ | ✅⁸ | ❌ | ❌ | ✅ | ❌ |
+| RTL8721DA/RTL8711DAF (AmebaDplus) | Realtek | ✅ | ✅ | ✅⁶ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ❌ |
+| RTL8720E/RTL8710ECF (AmebaLite) | Realtek | ✅ | ✅ | ✅⁶ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ❌ |
+| ECR6600 | ESWIN | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅⁸ | ⚠️ | ⚠️¹¹ | ✅ | ❌ |
✅ - Works
❓ - Not tested
@@ -42,5 +42,5 @@
¹⁰ Timer sleep only, no GPIO wakeup
¹¹ After waking up device will refuse to connect to WiFi until power cycled
¹² Only in _ALT builds
-¹³ WPA3 supported if ln_wpa_sae_enable in hal_wifi_ln882h.c
-
+¹³ ESP32-C5 only
+¹⁴ Must be manually enabled (CONFIG_ESP8266_WIFI_ENABLE_WPA3_SAE/CONFIG_ESP_WIFI_ENABLE_WPA3_SAE to y in sdkconfig.defaults)
diff --git a/bouffalo.mk b/platforms/BL602/bouffalo.mk
similarity index 71%
rename from bouffalo.mk
rename to platforms/BL602/bouffalo.mk
index 013f55b0d..3340666e6 100644
--- a/bouffalo.mk
+++ b/platforms/BL602/bouffalo.mk
@@ -14,6 +14,6 @@ COMPONENT_SRCS :=
COMPONENT_OBJS := $(patsubst %.c,%.o, $(COMPONENT_SRCS))
COMPONENT_OBJS := $(patsubst %.S,%.o, $(COMPONENT_OBJS))
-COMPONENT_SRCDIRS := src/ src/jsmn src/httpserver/ src/httpclient/ src/cmnds/ src/logging/ src/hal/bl602/ src/mqtt/ src/i2c/ src/cJSON src/base64 src/driver src/devicegroups src/bitmessage src/littlefs src/hal/generic libraries/berry/src src/berry src/berry/modules
+COMPONENT_SRCDIRS := src/ src/jsmn src/httpserver src/httpclient src/cmnds src/logging src/hal/bl602 src/mqtt src/i2c src/cJSON src/base64 src/driver src/devicegroups src/bitmessage src/littlefs src/hal/generic libraries/berry/src src/berry src/berry/modules
COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive
diff --git a/platforms/BL602/pre_build.sh b/platforms/BL602/pre_build.sh
index 6edbc2149..67ba53a3f 100644
--- a/platforms/BL602/pre_build.sh
+++ b/platforms/BL602/pre_build.sh
@@ -2,7 +2,6 @@
# It allows you to make changes to the SDK, for example..
# For example, you can use changed files in the SDK for the automated build during the checks for a PR without changing the SDK itself:
# So your PR needs a modified define in the SDK, for example ? This script can make this change directly before the build.
-
#
#
# As an example you will find a script below which will copy all content of the "override"
@@ -27,7 +26,6 @@
#done
## restore IFS to whatever it was before ...
#IFS=$OFS
-
# you can also use all other commands to change files, like
# sed -i "s/#define FOO bar/#define FOO baz/" sdk/OpenBL602/components/bl602/bl602_std/file_to_change.c
# or, let's assume you made a local change to your SDK
@@ -38,4 +36,3 @@
# and then in pre_build.sh you apply this patch with:
#
# patch -p 1 -d sdk/OpenBL602 < platforms/BL602/my_change.diff
-
diff --git a/platforms/ECR6600/OpenBeken.mk b/platforms/ECR6600/OpenBeken.mk
index 674b270ed..2391c4a8c 100644
--- a/platforms/ECR6600/OpenBeken.mk
+++ b/platforms/ECR6600/OpenBeken.mk
@@ -7,11 +7,11 @@ INCPATHS += $(TOPDIR)/include/ota
INCPATHS += $(TOPDIR)/include
INCPATHS += $(TOPDIR)
-CSRCS = main.c
-CSRCS += hal/ecr6600/hal_adc_ecr6600.c
+CSRCS = hal/ecr6600/hal_adc_ecr6600.c
CSRCS += hal/ecr6600/hal_flashConfig_ecr6600.c
CSRCS += hal/ecr6600/hal_flashVars_ecr6600.c
CSRCS += hal/ecr6600/hal_generic_ecr6600.c
+CSRCS += hal/ecr6600/hal_main_ecr6600.c
CSRCS += hal/ecr6600/hal_pins_ecr6600.c
CSRCS += hal/ecr6600/hal_wifi_ecr6600.c
CSRCS += hal/ecr6600/hal_uart_ecr6600.c
diff --git a/platforms/ESP8266/sdkconfig.defaults b/platforms/ESP8266/sdkconfig.defaults
index 5f8b13131..364e89c43 100644
--- a/platforms/ESP8266/sdkconfig.defaults
+++ b/platforms/ESP8266/sdkconfig.defaults
@@ -7,7 +7,9 @@ CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE=y
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE=y
CONFIG_ESP_MAIN_TASK_STACK_SIZE=3072
-CONFIG_ESP_TIMER_TASK_STACK_SIZE=2560
+CONFIG_ESP_TIMER_TASK_STACK_SIZE=2048
+CONFIG_ESP8266_WIFI_ENABLE_WPA3_SAE=n
+#CONFIG_WIFI_PPT_TASKSTACK_SIZE=4096
CONFIG_VFS_SUPPORT_IO=n
CONFIG_MBEDTLS_SHA512_C=n
CONFIG_MBEDTLS_TLS_CLIENT_ONLY=y
diff --git a/sdk/OpenECR6600 b/sdk/OpenECR6600
index d8823b8a7..1aa42baa4 160000
--- a/sdk/OpenECR6600
+++ b/sdk/OpenECR6600
@@ -1 +1 @@
-Subproject commit d8823b8a756c5b8a5bbc519bd29fa981762aa6b1
+Subproject commit 1aa42baa4cbb0781c716f75da28b6371da81215c
diff --git a/src/cmnds/cmd_main.c b/src/cmnds/cmd_main.c
index e37d59cca..9915a4165 100644
--- a/src/cmnds/cmd_main.c
+++ b/src/cmnds/cmd_main.c
@@ -23,6 +23,8 @@ int cmd_uartInitIndex = 0;
#endif
#ifdef PLATFORM_BL602
#include
+#include "bl_flash.h"
+#include "bl602_hbn.h"
#elif PLATFORM_LN882H
#include
#include
@@ -64,6 +66,8 @@ int g_sleepfactor = 1;
#else
#define DEEP_SLEEP PM_MODE_HIBERNATION
#endif
+#elif PLATFORM_ECR6600
+#include "psm_system.h"
#endif
#define HASH_SIZE 128
@@ -294,6 +298,21 @@ static commandResult_t CMD_PowerSave(const void* context, const char* cmd, const
{
wlan_set_ps_mode(g_wlan_netif, 0);
}
+#elif PLATFORM_ECR6600
+ if (bOn)
+ {
+ psm_set_psm_enable(1);
+ PSM_SLEEP_SET(MODEM_SLEEP_EN);
+ if(bOn >= 2) PSM_SLEEP_SET(WFI_SLEEP_EN);
+ PSM_SLEEP_CLEAR(LIGHT_SLEEP_EN);
+ }
+ else
+ {
+ psm_sleep_mode_ena_op(true, 0);
+ psm_set_psm_enable(0);
+ psm_pwr_mgt_ctrl(0);
+ psm_sleep_mode_ena_op(true, 0);
+ }
#else
ADDLOG_INFO(LOG_FEATURE_CMD, "PowerSave is not implemented on this platform");
#endif
@@ -330,17 +349,45 @@ static commandResult_t CMD_DeepSleep(const void* context, const char* cmd, const
return CMD_RES_OK;
#elif defined(PLATFORM_W600)
#elif PLATFORM_ESPIDF
- esp_sleep_enable_timer_wakeup(timeMS * 1000);
+ esp_sleep_enable_timer_wakeup(timeMS * 1000000);
#if CONFIG_IDF_TARGET_ESP32
rtc_gpio_isolate(GPIO_NUM_12);
#endif
esp_deep_sleep_start();
#elif PLATFORM_ESP8266
esp_wifi_stop();
- esp_deep_sleep(timeMS * 1000);
+ esp_deep_sleep(timeMS * 1000000);
#elif PLATFORM_XRADIO
HAL_Wakeup_SetTimer_mS(timeMS * DS_MS_TO_S);
pm_enter_mode(DEEP_SLEEP);
+#elif PLATFORM_BL602
+ HBN_APP_CFG_Type cfg = {
+ .useXtal32k = 0,
+ .sleepTime = timeMS,
+ .gpioWakeupSrc = HBN_WAKEUP_GPIO_NONE,
+ .gpioTrigType = HBN_GPIO_INT_TRIGGER_ASYNC_FALLING_EDGE,
+ .flashCfg = bl_flash_get_flashCfg(),
+ .hbnLevel = HBN_LEVEL_1,
+ .ldoLevel = HBN_LDO_LEVEL_1P10V,
+ };
+ HBN_Mode_Enter(&cfg);
+#elif PLATFORM_ECR6600
+ //unsigned int sleep_time;
+ //if(timeMS < 1000)
+ //{
+ // sleep_time = 1;
+ //}
+ //else
+ //{
+ // sleep_time = (timeMS + 1000 - 1) / 1000;
+ //}
+ // not working
+ //psm_set_deep_sleep(sleep_time);
+ // not working
+ //psm_enter_sleep(DEEP_SLEEP);
+ // this works fine, but wifi will not receive anything after waking up, and only full power cycle will fix it up.
+ drv_rtc_set_alarm_relative(timeMS * 1000 * 33);
+ psm_enter_deep_sleep();
#endif
return CMD_RES_OK;
diff --git a/platforms/ECR6600/main.c b/src/hal/ecr6600/hal_main_ecr6600.c
similarity index 84%
rename from platforms/ECR6600/main.c
rename to src/hal/ecr6600/hal_main_ecr6600.c
index f8a02176e..6819e2847 100644
--- a/platforms/ECR6600/main.c
+++ b/src/hal/ecr6600/hal_main_ecr6600.c
@@ -1,3 +1,5 @@
+#if PLATFORM_ECR6600
+
#include "oshal.h"
#include "cli.h"
#include "flash.h"
@@ -79,11 +81,22 @@ int main(void)
wifi_main();
+ time_check_temp();
+ os_task_create("time_check_temp", SYSTEM_EVENT_LOOP_PRIORITY, 4096, time_check_temp, NULL);
+
// disabling this will crash when getting ip
psm_wifi_ble_init();
psm_boot_flag_dbg_op(true, 1);
-
+ extern volatile int rtc_task_handle;
+ extern void calculate_rtc_task();
+ rtc_task_handle = os_task_create("calculate_rtc_task", SYSTEM_EVENT_LOOP_PRIORITY, 4096, calculate_rtc_task, NULL);
+ if(rtc_task_handle)
+ {
+ os_printf(LM_OS, LL_INFO, "rtc calculate start!\r\n");
+ }
+ extern int health_mon_create_by_nv();
+ health_mon_create_by_nv();
//psm_wifi_ps_to_active();
//psm_sleep_mode_ena_op(true, 0);
//psm_set_psm_enable(0);
@@ -124,3 +137,5 @@ int main(void)
vTaskStartScheduler();
return 0;
}
+
+#endif
diff --git a/src/hal/ecr6600/hal_wifi_ecr6600.c b/src/hal/ecr6600/hal_wifi_ecr6600.c
index 8d1ac4119..7b3d52486 100644
--- a/src/hal/ecr6600/hal_wifi_ecr6600.c
+++ b/src/hal/ecr6600/hal_wifi_ecr6600.c
@@ -16,6 +16,7 @@
static void (*g_wifiStatusCallback)(int code) = NULL;
extern system_event_cb_t s_event_handler_cb;
uint8_t wmac[6] = { 0 };
+uint8_t g_enable_cmw = 0;
bool g_bStaticIP = false, mac_init = false;
@@ -201,6 +202,7 @@ void HAL_ConnectToWiFi(const char* oob_ssid, const char* connect_key, obkStaticI
IP_ADDR4(&if_ip.dns1, ip->dnsServerIpAddr[0], ip->dnsServerIpAddr[1], ip->dnsServerIpAddr[2], ip->dnsServerIpAddr[3]);
set_sta_ipconfig(&if_ip);
}
+ g_enable_cmw = 1;
wifi_set_status(STATION_IF, STA_STATUS_START);
struct netif* nif = NULL;
nif = get_netif_by_index(STATION_IF);
diff --git a/src/hal/espidf/hal_wifi_espidf.c b/src/hal/espidf/hal_wifi_espidf.c
index f05144133..9e01383ac 100644
--- a/src/hal/espidf/hal_wifi_espidf.c
+++ b/src/hal/espidf/hal_wifi_espidf.c
@@ -216,7 +216,9 @@ void HAL_ConnectToWiFi(const char* oob_ssid, const char* connect_key, obkStaticI
strncpy((char*)wifi_config.sta.ssid, (char*)oob_ssid, 32);
strncpy((char*)wifi_config.sta.password, (char*)connect_key, 64);
}
-
+#if CONFIG_ESP8266_WIFI_ENABLE_WPA3_SAE
+ wifi_config.pmf_cfg.capable = true;
+#endif
esp_wifi_set_mode(WIFI_MODE_STA);
esp_wifi_set_config(WIFI_IF_STA, &wifi_config);
diff --git a/src/hal/realtek/hal_wifi_realtek.c b/src/hal/realtek/hal_wifi_realtek.c
index a789ec601..a417913bd 100644
--- a/src/hal/realtek/hal_wifi_realtek.c
+++ b/src/hal/realtek/hal_wifi_realtek.c
@@ -315,8 +315,6 @@ void ConfigureSTA(obkStaticIP_t* ip)
struct ip_addr gw;
struct ip_addr dnsserver;
- wifi_config_autoreconnect(1, 2, 3);
-
if(ip->localIPAddr[0] == 0)
{
//dhcps_init(&xnetif[0]);
@@ -334,6 +332,8 @@ void ConfigureSTA(obkStaticIP_t* ip)
netif_set_addr(&xnetif[0], ip_2_ip4(&ipaddr), ip_2_ip4(&netmask), ip_2_ip4(&gw));
dns_setserver(0, &dnsserver);
}
+ if(!g_bStaticIP) wifi_config_autoreconnect(1, 2, 3);
+ else wifi_set_autoreconnect(0);
netif_set_hostname(&xnetif[0], CFG_GetDeviceName());
}
diff --git a/src/httpserver/http_fns.c b/src/httpserver/http_fns.c
index d9c868fd9..079d06a16 100644
--- a/src/httpserver/http_fns.c
+++ b/src/httpserver/http_fns.c
@@ -62,6 +62,8 @@
#include "tuya_hal_storge.h"
#include "BkDriverFlash.h"
#include "temp_detect_pub.h"
+#elif defined(PLATFORM_ECR6600)
+#include "hal_system.h"
#endif
#if (defined(PLATFORM_BK7231T) || defined(PLATFORM_BK7231N)) && !defined(PLATFORM_BEKEN_NEW)
@@ -948,6 +950,23 @@ typedef enum {
hprintf255(request, "Current fw: FW%i
", current_fw_idx);
#elif PLATFORM_RTL8710B || PLATFORM_RTL8720D
hprintf255(request, "Current fw: FW%i
", current_fw_idx + 1);
+#elif PLATFORM_ECR6600
+ RST_TYPE reset_type = hal_get_reset_type();
+ const char* s;
+ switch(reset_type)
+ {
+ case RST_TYPE_POWER_ON: s = "POWER_ON"; break;
+ case RST_TYPE_FATAL_EXCEPTION: s = "FATAL_EXCEPTION"; break;
+ case RST_TYPE_SOFTWARE_REBOOT: s = "SOFTWARE_REBOOT"; break;
+ case RST_TYPE_HARDWARE_REBOOT: s = "HARDWARE_REBOOT"; break;
+ case RST_TYPE_OTA: s = "OTA"; break;
+ case RST_TYPE_WAKEUP: s = "WAKEUP"; break;
+ case RST_TYPE_HARDWARE_WDT_TIMEOUT: s = "HARDWARE_WDT_TIMEOUT"; break;
+ case RST_TYPE_SOFTWARE_WDT_TIMEOUT: s = "SOFTWARE_WDT_TIMEOUT"; break;
+ case RST_TYPE_UNKOWN: s = "UNKNOWN"; break;
+ default: s = "ERROR"; break;
+ }
+ hprintf255(request, "Reboot reason: %i - %s
", reset_type, s);
#endif
#if ENABLE_MQTT
if (CFG_GetMQTTHost()[0] == 0) {
@@ -3192,10 +3211,10 @@ void OTA_RequestDownloadFromHTTP(const char* s) {
#elif PLATFORM_TR6260
#elif PLATFORM_REALTEK
#elif PLATFORM_ECR6600
- extern int http_client_download_file(const char* url, unsigned int len);
+ extern int http_client_download_file(const char* url);
extern int ota_done(bool reset);
delay_ms(100);
- int ret = http_client_download_file(s, strlen(s));
+ int ret = http_client_download_file(s);
if(ret != -1) ota_done(1);
else ota_done(0);
#elif PLATFORM_W600 || PLATFORM_W800
diff --git a/src/new_pins.c b/src/new_pins.c
index 306055595..338635aa3 100644
--- a/src/new_pins.c
+++ b/src/new_pins.c
@@ -35,6 +35,9 @@
#else
#define DEEP_SLEEP PM_MODE_HIBERNATION
#endif
+#elif PLATFORM_BL602
+#include "bl_flash.h"
+#include "bl602_hbn.h"
#endif
#ifdef PLATFORM_BEKEN_NEW
@@ -313,6 +316,31 @@ void PINS_BeginDeepSleepWithPinWakeUp(unsigned int wakeUpTime) {
// esp_sleep_enable_gpio_wakeup();
// esp_light_sleep_start();
//#endif
+#elif PLATFORM_BL602
+ uint8_t wkup = HBN_WAKEUP_GPIO_NONE;
+ HBN_GPIO_INT_Trigger_Type edge = HBN_GPIO_INT_TRIGGER_ASYNC_RISING_EDGE;
+ uint8_t g7 = (g_gpio_index_map[0] >> 7) & 1;
+ uint8_t g8 = (g_gpio_index_map[0] >> 8) & 1;
+ uint8_t gf7 = (g_gpio_edge_map[0] >> 7) & 1;
+ uint8_t gf8 = (g_gpio_edge_map[0] >> 8) & 1;
+ if(g7) wkup |= HBN_WAKEUP_GPIO_7;
+ if(g8) wkup |= HBN_WAKEUP_GPIO_8;
+ // only one edge setting
+ if(gf8) edge = HBN_GPIO_INT_TRIGGER_ASYNC_FALLING_EDGE;
+ if(gf7) edge = HBN_GPIO_INT_TRIGGER_ASYNC_FALLING_EDGE;
+
+ HBN_APP_CFG_Type cfg = {
+ .useXtal32k = 0,
+ .sleepTime = wakeUpTime,
+ .gpioWakeupSrc = wkup,
+ .gpioTrigType = edge,
+ .flashCfg = bl_flash_get_flashCfg(),
+ .hbnLevel = wakeUpTime > 0 ? HBN_LEVEL_1 : HBN_LEVEL_3,
+ .ldoLevel = HBN_LDO_LEVEL_1P10V,
+ };
+ HBN_Clear_IRQ(HBN_INT_GPIO7);
+ HBN_Clear_IRQ(HBN_INT_GPIO8);
+ HBN_Mode_Enter(&cfg);
#endif
}