diff --git a/examples/contact-sensor-app/bouffalolab/README.md b/examples/contact-sensor-app/bouffalolab/README.md index ed91f98488f326..e202406ae56453 100644 --- a/examples/contact-sensor-app/bouffalolab/README.md +++ b/examples/contact-sensor-app/bouffalolab/README.md @@ -72,7 +72,8 @@ Mac OS. ## Build CHIP Lighting App example -The following steps take examples for BL602 develop board `BL602-IoT-Matter-V1`, BL706 develop board `XT-ZB6-DevKit` and BL704L EVB board `BL704L-EVB` +The following steps take examples for BL602 develop board `BL602-IoT-Matter-V1`, +BL706 develop board `XT-ZB6-DevKit` and BL704L EVB board `BL704L-EVB` - Build lighting app with UART baudrate 2000000 @@ -125,7 +126,8 @@ The following steps take examples for BL602 develop board `BL602-IoT-Matter-V1`, - Type following command for image download. Please set serial port accordingly, here we use /dev/ttyACM0 as a serial port example. - - `bl602-iot-matter-v1` and `bl704l-evb` without additional build options + - `bl602-iot-matter-v1` and `bl704l-evb` without additional build + options ```shell ./out/bouffalolab-bl602-iot-matter-v1-light/chip-bl602-lighting-example.flash.py --port /dev/ttyACM0 diff --git a/examples/contact-sensor-app/bouffalolab/bl702l/BUILD.gn b/examples/contact-sensor-app/bouffalolab/bl702l/BUILD.gn index e98e15266afd6f..7a9a5c7abd8761 100644 --- a/examples/contact-sensor-app/bouffalolab/bl702l/BUILD.gn +++ b/examples/contact-sensor-app/bouffalolab/bl702l/BUILD.gn @@ -139,8 +139,8 @@ bouffalolab_executable("contact_sensor_app") { ] deps = [ - ":sdk", ":bouffalolab_contact_sensor", + ":sdk", "${chip_root}/examples/providers:device_info_provider", "${chip_root}/src/lib", "${chip_root}/src/platform/logging:default", @@ -153,7 +153,8 @@ bouffalolab_executable("contact_sensor_app") { "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils", ] - assert(chip_openthread_ftd == false, "Only Thread MTD support on contact sensor application.") + assert(chip_openthread_ftd == false, + "Only Thread MTD support on contact sensor application.") defines += [ "CHIP_DEVICE_CONFIG_THREAD_FTD=0" ] deps += [ "${openthread_root}:libopenthread-mtd" ] if (chip_build_libshell) { diff --git a/examples/contact-sensor-app/bouffalolab/bl702l/CHIPProjectConfig.h b/examples/contact-sensor-app/bouffalolab/bl702l/CHIPProjectConfig.h index 4f014560863a1b..9cce9e85b9aafe 100644 --- a/examples/contact-sensor-app/bouffalolab/bl702l/CHIPProjectConfig.h +++ b/examples/contact-sensor-app/bouffalolab/bl702l/CHIPProjectConfig.h @@ -115,4 +115,4 @@ #define CHIP_BLE_DEVICE_NAME "ContactSensor" -// #define CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL chip::System::Clock::Milliseconds32(1000) \ No newline at end of file +// #define CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL chip::System::Clock::Milliseconds32(1000) diff --git a/examples/contact-sensor-app/bouffalolab/bl702l/FreeRTOSConfig.h b/examples/contact-sensor-app/bouffalolab/bl702l/FreeRTOSConfig.h index 892dc70c4a7ca7..5f0447acf49367 100644 --- a/examples/contact-sensor-app/bouffalolab/bl702l/FreeRTOSConfig.h +++ b/examples/contact-sensor-app/bouffalolab/bl702l/FreeRTOSConfig.h @@ -159,12 +159,14 @@ to exclude the API function. */ /* Normal assert() semantics without relying on the provision of an assert.h header file. */ #ifdef __cplusplus -extern "C" void vAssertCalled( void ); +extern "C" void vAssertCalled(void); #else -extern void vAssertCalled( void ); +extern void vAssertCalled(void); #endif -#define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled() +#define configASSERT(x) \ + if ((x) == 0) \ + vAssertCalled() /* Overwrite some of the stack sizes allocated to various test and demo tasks. Like all task stack sizes, the value is the number of words, not bytes. */ diff --git a/examples/contact-sensor-app/bouffalolab/bl702l/app_pds.cpp b/examples/contact-sensor-app/bouffalolab/bl702l/app_pds.cpp index 18f41c9417cc55..e3ed09ae6393c1 100644 --- a/examples/contact-sensor-app/bouffalolab/bl702l/app_pds.cpp +++ b/examples/contact-sensor-app/bouffalolab/bl702l/app_pds.cpp @@ -4,129 +4,49 @@ extern "C" { #include #include +#include #include #include -#include #include -#include #include +#include #include #include -#include #include #include -#include -#include #include +#include +#include +#include } #define PDS_TOLERANCE_TIME_32768CYCLE (164) #define PDS_MIN_TIME_32768CYCLE (PDS_WARMUP_LATENCY_CNT + 33) -#define PDS_SLEEP_MAX_MS 3600000 - -btble_app_conf_t app_pds_conf = -{ - .print_enable = 0,//1: enable uart print in library; 0: disable uart print in library - .gpio_irq_restore = 1, //1: restore gpio irq after pds wakeup; 0: do not restore gpio irq after pds wakeup - .gpio_num = 2, //3, - .gpio_index = {CHIP_RESET_PIN, CHIP_CONTACT_PIN}, - .pull_type = {INPUT_PULL_DOWN, INPUT_PULL_DOWN}, - .trigger_type = {HOSAL_IRQ_TRIG_SYNC_FALLING_RISING_EDGE, HOSAL_IRQ_TRIG_SYNC_FALLING_RISING_EDGE}, +#define PDS_SLEEP_MAX_MS 3600000 + +btble_app_conf_t app_pds_conf = { + .print_enable = 0, // 1: enable uart print in library; 0: disable uart print in library + .gpio_irq_restore = 1, // 1: restore gpio irq after pds wakeup; 0: do not restore gpio irq after pds wakeup + .gpio_num = 2, // 3, + .gpio_index = { CHIP_RESET_PIN, CHIP_CONTACT_PIN }, + .pull_type = { INPUT_PULL_DOWN, INPUT_PULL_DOWN }, + .trigger_type = { HOSAL_IRQ_TRIG_SYNC_FALLING_RISING_EDGE, HOSAL_IRQ_TRIG_SYNC_FALLING_RISING_EDGE }, }; static uint32_t low_power_pds_lmac154_backup[72]; -static hosal_gpio_dev_t gpio_key = { .port = CHIP_RESET_PIN, .config = INPUT_PULL_DOWN, .priv = NULL }; -static hosal_gpio_dev_t gpio_contact = { .port = CHIP_CONTACT_PIN, .config = INPUT_PULL_DOWN, .priv = NULL }; +static hosal_gpio_dev_t gpio_key = { .port = CHIP_RESET_PIN, .config = INPUT_PULL_DOWN, .priv = NULL }; +static hosal_gpio_dev_t gpio_contact = { .port = CHIP_CONTACT_PIN, .config = INPUT_PULL_DOWN, .priv = NULL }; static hosal_gpio_irq_handler_t app_pds_irq_handler = NULL; -static int app_pds_wakeup_source = -1; -static uint32_t app_pds_wakeup_pin = -1; +static int app_pds_wakeup_source = -1; +static uint32_t app_pds_wakeup_pin = -1; extern "C" void btble_pds_fastboot_done_callback(void); -uint64_t wakeup_time = 0; +uint64_t wakeup_time = 0; uint64_t sleep_calling_time = 0; -uint64_t sleep_time = 0; - -// extern "C" void vApplicationSleep( TickType_t xExpectedIdleTime ) -// { -// eSleepModeStatus eSleepStatus; -// uint32_t xExpectedSleepTime = xExpectedIdleTime; -// uint32_t sleepCycles; -// uint32_t sleepTime; - -// eSleepStatus = eTaskConfirmSleepModeStatus(); -// if(eSleepStatus == eAbortSleep){ -// return; -// } - -// if(xExpectedIdleTime > PDS_SLEEP_MAX_MS) -// xExpectedIdleTime = PDS_SLEEP_MAX_MS; - -// extern int ble_connection_number(void); -// if (OT_DEVICE_ROLE_CHILD != otThreadGetDeviceRole(otrGetInstance()) || ble_connection_number() || false == otr_isStackIdle()) { -// return; -// } - -// bl_rtc_process_xtal_cnt_32k(); - -// bl_pds_set_psram_retention(1); -// lmac154_sleepStoreRegs(low_power_pds_lmac154_backup); - -// sleepCycles = bl_rtc_ms_to_counter(xExpectedIdleTime); -// if(sleepCycles < PDS_TOLERANCE_TIME_32768CYCLE + PDS_MIN_TIME_32768CYCLE){ -// return; -// } - -// sleepTime = hal_pds_enter_with_time_compensation(31, sleepCycles); - -// RomDriver_AON_Power_On_XTAL(); -// RomDriver_HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_XTAL); - -// if (lmac154_isDisabled()) { - -// lmac154_sleepRestoreRegs(low_power_pds_lmac154_backup); -// lmac154_disableRx(); - -// zb_timer_cfg(bl_rtc_get_counter() * (32768 >> LMAC154_US_PER_SYMBOL_BITS)); - -// zb_timer_restore_events(true); - -// // bl_irq_register(M154_IRQn, lmac154_get2015InterruptHandler()); -// bl_irq_enable(M154_IRQn); -// } -// bl_sec_init(); - -// extern hosal_uart_dev_t uart_stdio; -// bl_uart_init(uart_stdio.config.uart_id, uart_stdio.config.tx_pin, uart_stdio.config.rx_pin, -// uart_stdio.config.cts_pin, uart_stdio.config.rts_pin, uart_stdio.config.baud_rate); - -// extern BaseType_t TrapNetCounter, *pTrapNetCounter; -// if (app_pds_wakeup_source == PDS_WAKEUP_BY_RTC) { -// extern void * pxCurrentTCB; -// ChipLogProgress(NotSpecified, "wakeup source: rtc. %lu vs %lu ms @ %lu\r\n", -// xExpectedSleepTime, sleepTime, (uint32_t)bl_rtc_get_timestamp_ms()); - -// ChipLogProgress(NotSpecified, "application_sleep; %lu, %lu, %lu\r\n", (uint32_t)sleep_calling_time, (uint32_t)sleep_time, (uint32_t)wakeup_time); - -// } else if(app_pds_wakeup_source == PDS_WAKEUP_BY_GPIO) { - -// if (((1 << CHIP_RESET_PIN) & app_pds_wakeup_pin) && app_pds_irq_handler) { -// app_pds_irq_handler(&gpio_key); -// } - -// if (((1 << CHIP_CONTACT_PIN) & app_pds_wakeup_pin) && app_pds_irq_handler) { -// app_pds_irq_handler(&gpio_contact); -// } - -// printf("[%lu] wakeup source: gpio -> 0x%08lX. %lu vs %lu ms.\r\n", -// app_pds_wakeup_pin, xExpectedSleepTime, sleepTime, (uint32_t)bl_rtc_get_timestamp_ms()); -// } - -// app_pds_wakeup_source = -1; -// app_pds_wakeup_pin = -1; -// } +uint64_t sleep_time = 0; extern "C" void vApplicationSleep(TickType_t xExpectedIdleTime) { @@ -137,36 +57,41 @@ extern "C" void vApplicationSleep(TickType_t xExpectedIdleTime) btble_vApplicationSleepExt(xExpectedIdleTime); extern BaseType_t TrapNetCounter, *pTrapNetCounter; - if (app_pds_wakeup_source == PDS_WAKEUP_BY_RTC) { + if (app_pds_wakeup_source == PDS_WAKEUP_BY_RTC) + { extern void * pxCurrentTCB; - ChipLogProgress(NotSpecified, "wakeup source: rtc. %lu vs %lu ms @ %lu\r\n", - xExpectedIdleTime, (uint32_t)(bl_rtc_get_timestamp_ms() - sleep_before), (uint32_t)bl_rtc_get_timestamp_ms()); + ChipLogProgress(NotSpecified, "wakeup source: rtc. %lu vs %lu ms @ %lu\r\n", xExpectedIdleTime, + (uint32_t) (bl_rtc_get_timestamp_ms() - sleep_before), (uint32_t) bl_rtc_get_timestamp_ms()); - ChipLogProgress(NotSpecified, "application_sleep; %lu, %lu, %lu\r\n", (uint32_t)sleep_calling_time, (uint32_t)sleep_time, (uint32_t)wakeup_time); - - } else if(app_pds_wakeup_source == PDS_WAKEUP_BY_GPIO) { + ChipLogProgress(NotSpecified, "application_sleep; %lu, %lu, %lu\r\n", (uint32_t) sleep_calling_time, (uint32_t) sleep_time, + (uint32_t) wakeup_time); + } + else if (app_pds_wakeup_source == PDS_WAKEUP_BY_GPIO) + { - if (((1 << CHIP_RESET_PIN) & app_pds_wakeup_pin) && app_pds_irq_handler) { + if (((1 << CHIP_RESET_PIN) & app_pds_wakeup_pin) && app_pds_irq_handler) + { app_pds_irq_handler(&gpio_key); } - if (((1 << CHIP_CONTACT_PIN) & app_pds_wakeup_pin) && app_pds_irq_handler) { + if (((1 << CHIP_CONTACT_PIN) & app_pds_wakeup_pin) && app_pds_irq_handler) + { app_pds_irq_handler(&gpio_contact); } - ChipLogProgress(NotSpecified, "wakeup source: gpio -> 0x%08lX. %lu vs %lu ms @ %lu\r\n", - app_pds_wakeup_pin, xExpectedIdleTime, (uint32_t)(bl_rtc_get_timestamp_ms() - sleep_before), (uint32_t)bl_rtc_get_timestamp_ms()); + ChipLogProgress(NotSpecified, "wakeup source: gpio -> 0x%08lX. %lu vs %lu ms @ %lu\r\n", app_pds_wakeup_pin, + xExpectedIdleTime, (uint32_t) (bl_rtc_get_timestamp_ms() - sleep_before), + (uint32_t) bl_rtc_get_timestamp_ms()); } - app_pds_wakeup_source = -1; - app_pds_wakeup_pin = -1; + app_pds_wakeup_pin = -1; } -void app_pds_config_pin(void) +void app_pds_config_pin(void) { - uint8_t wakeup_pin [] = {gpio_key.port, gpio_contact.port}; + uint8_t wakeup_pin[] = { gpio_key.port, gpio_contact.port }; hosal_gpio_init(&gpio_key); hosal_gpio_init(&gpio_contact); @@ -176,14 +101,14 @@ void app_pds_config_pin(void) bl_pds_gpio_wakeup_cfg(wakeup_pin, sizeof(wakeup_pin) / sizeof(wakeup_pin[0]), PDS_GPIO_EDGE_BOTH); } -void app_pds_fastboot_done_callback(void) +void app_pds_fastboot_done_callback(void) { wakeup_time = bl_rtc_get_timestamp_ms(); #if CHIP_PROGRESS_LOGGING || CHIP_ERROR_LOGGING extern hosal_uart_dev_t uart_stdio; - bl_uart_init(uart_stdio.config.uart_id, uart_stdio.config.tx_pin, uart_stdio.config.rx_pin, - uart_stdio.config.cts_pin, uart_stdio.config.rts_pin, uart_stdio.config.baud_rate); + bl_uart_init(uart_stdio.config.uart_id, uart_stdio.config.tx_pin, uart_stdio.config.rx_pin, uart_stdio.config.cts_pin, + uart_stdio.config.rts_pin, uart_stdio.config.baud_rate); #endif btble_pds_fastboot_done_callback(); @@ -193,16 +118,17 @@ void app_pds_fastboot_done_callback(void) // app_pds_config_pin(); app_pds_wakeup_source = bl_pds_get_wakeup_source(); - app_pds_wakeup_pin = bl_pds_get_wakeup_gpio(); + app_pds_wakeup_pin = bl_pds_get_wakeup_gpio(); } -int app_pds_before_sleep_callback(void) +int app_pds_before_sleep_callback(void) { - if (otr_isStackIdle()) { + if (otr_isStackIdle()) + { bl_pds_set_psram_retention(1); lmac154_sleepStoreRegs(low_power_pds_lmac154_backup); - + sleep_time = bl_rtc_get_timestamp_ms(); return 0; @@ -211,9 +137,10 @@ int app_pds_before_sleep_callback(void) return -1; } -void app_pds_after_sleep_callback(void) +void app_pds_after_sleep_callback(void) { - if (lmac154_isDisabled()) { + if (lmac154_isDisabled()) + { lmac154_sleepRestoreRegs(low_power_pds_lmac154_backup); lmac154_disableRx(); @@ -227,7 +154,7 @@ void app_pds_after_sleep_callback(void) bl_sec_init(); } -void app_pds_init(hosal_gpio_irq_handler_t pinHandler) +void app_pds_init(hosal_gpio_irq_handler_t pinHandler) { btble_pds_init(&app_pds_conf); diff --git a/examples/contact-sensor-app/bouffalolab/bl702l/mboard.h b/examples/contact-sensor-app/bouffalolab/bl702l/mboard.h index 98f54f6eacd8f0..0c7568f3beadb3 100644 --- a/examples/contact-sensor-app/bouffalolab/bl702l/mboard.h +++ b/examples/contact-sensor-app/bouffalolab/bl702l/mboard.h @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2018, The OpenThread Authors. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file - * This file includes dev borad compile-time configuration constants for BL702L. - * - */ - -#pragma once - -#define CHIP_UART_PORT 0 -#define CHIP_UART_RX_BUFFSIZE 256 -#define CHIP_UART_PIN_RX 15 -#define CHIP_UART_PIN_TX 14 - -#define CHIP_CONTACT_PIN 20 -#define CHIP_RESET_PIN 16 \ No newline at end of file +/* + * Copyright (c) 2018, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * This file includes dev borad compile-time configuration constants for BL702L. + * + */ + +#pragma once + +#define CHIP_UART_PORT 0 +#define CHIP_UART_RX_BUFFSIZE 256 +#define CHIP_UART_PIN_RX 15 +#define CHIP_UART_PIN_TX 14 + +#define CHIP_CONTACT_PIN 20 +#define CHIP_RESET_PIN 16 diff --git a/examples/contact-sensor-app/bouffalolab/common/AppTask.cpp b/examples/contact-sensor-app/bouffalolab/common/AppTask.cpp index 84a9896e366b96..5990e4201e6d07 100644 --- a/examples/contact-sensor-app/bouffalolab/common/AppTask.cpp +++ b/examples/contact-sensor-app/bouffalolab/common/AppTask.cpp @@ -45,8 +45,8 @@ #include extern "C" { -#include #include +#include #include #include } @@ -63,7 +63,6 @@ AppTask AppTask::sAppTask; StackType_t AppTask::appStack[APP_TASK_STACK_SIZE / sizeof(StackType_t)]; StaticTask_t AppTask::appTaskStruct; - #if CONFIG_ENABLE_CHIP_SHELL void AppTask::AppShellTask(void * args) { @@ -110,23 +109,30 @@ void AppTask::PostEvent(app_event_t event) void AppTask::ButtonEventHandler(void * arg) { - hosal_gpio_dev_t *p_gpio = (hosal_gpio_dev_t *)arg; - uint8_t val = 1; + hosal_gpio_dev_t * p_gpio = (hosal_gpio_dev_t *) arg; + uint8_t val = 1; hosal_gpio_input_get(p_gpio, &val); - if (CHIP_RESET_PIN == p_gpio->port) { - if (val) { + if (CHIP_RESET_PIN == p_gpio->port) + { + if (val) + { GetAppTask().mButtonPressedTime = System::SystemClock().GetMonotonicMilliseconds64().count(); } - else { - if (GetAppTask().mButtonPressedTime) { - uint64_t pressed_time = System::SystemClock().GetMonotonicMilliseconds64().count() - GetAppTask().mButtonPressedTime; + else + { + if (GetAppTask().mButtonPressedTime) + { + uint64_t pressed_time = + System::SystemClock().GetMonotonicMilliseconds64().count() - GetAppTask().mButtonPressedTime; - if (pressed_time > APP_BUTTON_PRESS_LONG) { + if (pressed_time > APP_BUTTON_PRESS_LONG) + { GetAppTask().PostEvent(APP_EVENT_FACTORY_RESET); } - else if (APP_BUTTON_PRESS_JITTER < pressed_time && pressed_time < APP_BUTTON_PRESS_SHORT) { + else if (APP_BUTTON_PRESS_JITTER < pressed_time && pressed_time < APP_BUTTON_PRESS_SHORT) + { GetAppTask().PostEvent(APP_EVENT_BUTTON_PRESSED); } @@ -134,11 +140,14 @@ void AppTask::ButtonEventHandler(void * arg) } } } - else if (CHIP_CONTACT_PIN == p_gpio->port) { - if (val) { + else if (CHIP_CONTACT_PIN == p_gpio->port) + { + if (val) + { GetAppTask().PostEvent(APP_EVENT_CONTACT_SENSOR_TRUE); } - else { + else + { GetAppTask().PostEvent(APP_EVENT_CONTACT_SENSOR_FALSE); } } @@ -147,8 +156,8 @@ void AppTask::ButtonEventHandler(void * arg) void AppTask::AppTaskMain(void * pvParameter) { app_event_t appEvent; - bool stateValueAttrValue = false; - uint64_t currentHeapFree = 0; + bool stateValueAttrValue = false; + uint64_t currentHeapFree = 0; app_pds_init(GetAppTask().ButtonEventHandler); @@ -187,12 +196,14 @@ void AppTask::AppTaskMain(void * pvParameter) DeviceLayer::ConfigurationMgr().InitiateFactoryReset(); } - if (APP_EVENT_CONTACT_SENSOR_TRUE & appEvent) { + if (APP_EVENT_CONTACT_SENSOR_TRUE & appEvent) + { stateValueAttrValue = 1; app::Clusters::BooleanState::Attributes::StateValue::Set(1, stateValueAttrValue); } - if (APP_EVENT_CONTACT_SENSOR_FALSE & appEvent) { + if (APP_EVENT_CONTACT_SENSOR_FALSE & appEvent) + { stateValueAttrValue = 0; app::Clusters::BooleanState::Attributes::StateValue::Set(1, stateValueAttrValue); } @@ -203,7 +214,7 @@ void AppTask::AppTaskMain(void * pvParameter) } #if CHIP_DETAIL_LOGGING -void AppTask::OnEnterActiveMode() +void AppTask::OnEnterActiveMode() { ChipLogProgress(NotSpecified, "App ICD enter active mode."); } @@ -222,4 +233,4 @@ void AppTask::OnICDModeChange() { ChipLogProgress(NotSpecified, "App ICD mode change."); } -#endif \ No newline at end of file +#endif diff --git a/examples/contact-sensor-app/bouffalolab/common/AppTask.h b/examples/contact-sensor-app/bouffalolab/common/AppTask.h index a17e95b718faa1..92b3ba7c45d2f9 100644 --- a/examples/contact-sensor-app/bouffalolab/common/AppTask.h +++ b/examples/contact-sensor-app/bouffalolab/common/AppTask.h @@ -24,8 +24,8 @@ #include "FreeRTOS.h" #include "timers.h" -#include #include +#include extern "C" { #include @@ -53,7 +53,7 @@ using namespace ::chip::DeviceLayer; struct Identify; #if CHIP_DETAIL_LOGGING -class AppTask: public chip::app::ICDStateObserver +class AppTask : public chip::app::ICDStateObserver #else class AppTask #endif @@ -63,23 +63,23 @@ class AppTask enum app_event_t { - APP_EVENT_NONE = 0x00000000, + APP_EVENT_NONE = 0x00000000, - APP_EVENT_BUTTON_PRESSED = 0x00000010, - APP_EVENT_FACTORY_RESET = 0x00000020, - APP_EVENT_COMMISSION_COMPLETE = 0x00000080, - APP_EVENT_BUTTON_MASK = APP_EVENT_BUTTON_PRESSED | APP_EVENT_FACTORY_RESET | APP_EVENT_COMMISSION_COMPLETE, + APP_EVENT_BUTTON_PRESSED = 0x00000010, + APP_EVENT_FACTORY_RESET = 0x00000020, + APP_EVENT_COMMISSION_COMPLETE = 0x00000080, + APP_EVENT_BUTTON_MASK = APP_EVENT_BUTTON_PRESSED | APP_EVENT_FACTORY_RESET | APP_EVENT_COMMISSION_COMPLETE, - APP_EVENT_CONTACT_SENSOR_TRUE = 0x00000100, - APP_EVENT_CONTACT_SENSOR_FALSE = 0x00000200, - APP_EVENT_CONTACT_SENSOR_MASK = APP_EVENT_CONTACT_SENSOR_TRUE | APP_EVENT_CONTACT_SENSOR_FALSE, + APP_EVENT_CONTACT_SENSOR_TRUE = 0x00000100, + APP_EVENT_CONTACT_SENSOR_FALSE = 0x00000200, + APP_EVENT_CONTACT_SENSOR_MASK = APP_EVENT_CONTACT_SENSOR_TRUE | APP_EVENT_CONTACT_SENSOR_FALSE, - APP_EVENT_IDENTIFY_START = 0x01000000, - APP_EVENT_IDENTIFY_IDENTIFY = 0x02000000, - APP_EVENT_IDENTIFY_STOP = 0x04000000, - APP_EVENT_IDENTIFY_MASK = APP_EVENT_IDENTIFY_START | APP_EVENT_IDENTIFY_IDENTIFY | APP_EVENT_IDENTIFY_STOP, + APP_EVENT_IDENTIFY_START = 0x01000000, + APP_EVENT_IDENTIFY_IDENTIFY = 0x02000000, + APP_EVENT_IDENTIFY_STOP = 0x04000000, + APP_EVENT_IDENTIFY_MASK = APP_EVENT_IDENTIFY_START | APP_EVENT_IDENTIFY_IDENTIFY | APP_EVENT_IDENTIFY_STOP, - APP_EVENT_ALL_MASK = APP_EVENT_BUTTON_MASK | APP_EVENT_CONTACT_SENSOR_MASK | APP_EVENT_IDENTIFY_MASK, + APP_EVENT_ALL_MASK = APP_EVENT_BUTTON_MASK | APP_EVENT_CONTACT_SENSOR_MASK | APP_EVENT_IDENTIFY_MASK, }; void SetEndpointId(EndpointId endpointId) diff --git a/examples/contact-sensor-app/bouffalolab/common/ZclCallbacks.cpp b/examples/contact-sensor-app/bouffalolab/common/ZclCallbacks.cpp index 53821da407adac..f9899fafe5c491 100644 --- a/examples/contact-sensor-app/bouffalolab/common/ZclCallbacks.cpp +++ b/examples/contact-sensor-app/bouffalolab/common/ZclCallbacks.cpp @@ -29,7 +29,8 @@ using namespace ::chip::app::Clusters::BooleanState; void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & path, uint8_t type, uint16_t size, uint8_t * value) { - ChipLogProgress(Zcl, "Cluster callback: " ChipLogFormatMEI " " ChipLogFormatMEI, ChipLogValueMEI(path.mClusterId), ChipLogValueMEI(path.mAttributeId)); + ChipLogProgress(Zcl, "Cluster callback: " ChipLogFormatMEI " " ChipLogFormatMEI, ChipLogValueMEI(path.mClusterId), + ChipLogValueMEI(path.mAttributeId)); if (path.mClusterId == BooleanState::Id && path.mAttributeId == BooleanState::Attributes::StateValue::Id) { diff --git a/examples/lighting-app/bouffalolab/README.md b/examples/lighting-app/bouffalolab/README.md index 7647dcbe98d215..1c58f174808f9c 100644 --- a/examples/lighting-app/bouffalolab/README.md +++ b/examples/lighting-app/bouffalolab/README.md @@ -63,11 +63,11 @@ Legacy supported boards: - BL706 + BL602, Wi-Fi 4 as infrastructure network - BL616, Wi-Fi 6 as infrastructure network - BL706/BL616, Ethernet as as infrastructure network -- Matter ZigBee Bridge application based on FreeRTOS - - BL706 + BL602, Wi-Fi 4 as infrastructure network - - BL616, Wi-Fi 6 as infrastructure network - - BL706/BL616, Ethernet as as infrastructure network -> Please contact `Bouffalo Lab` for supports on OTBR and Matter ZigBee Bridge application +- Matter ZigBee Bridge application based on FreeRTOS - BL706 + BL602, Wi-Fi 4 + as infrastructure network - BL616, Wi-Fi 6 as infrastructure network - + BL706/BL616, Ethernet as as infrastructure network + > Please contact `Bouffalo Lab` for supports on OTBR and Matter ZigBee + > Bridge application ## Initial setup @@ -100,57 +100,70 @@ The following steps in this document were validated on Ubuntu 20.04. ## Build options with build_examples.py -Please try `./scripts/build/build_examples.py targets` to check supports options. +Please try `./scripts/build/build_examples.py targets` to check supports +options. + +- supported board options, select one of the following options to build -- supported board options, select one of the following options to build - - `-bl602dk` - - `-bl616dk` - - `-bl704ldk` - - `-bl706dk` - - `-bl602-night-light` - - `-bl706-night-light` - - `-bl602-iot-matter-v1` - - `-xt-zb6-devkit` + - `-bl602dk` + - `-bl616dk` + - `-bl704ldk` + - `-bl706dk` + - `-bl602-night-light` + - `-bl706-night-light` + - `-bl602-iot-matter-v1` + - `-xt-zb6-devkit` -- supported example options, select one of the following options to build - - `-light` - - `-contact-sensor` +- supported example options, select one of the following options to build -- connectivity options, select one of the following options to build + - `-light` + - `-contact-sensor` - - `-wifi`, specifies to use Wi-Fi for Matter application. +- connectivity options, select one of the following options to build - - `-ethernet`, specifies to use Ethernet for Matter application. + - `-wifi`, specifies to use Wi-Fi for Matter application. - - `-thread`, specifies to use Thread FTD for Matter application. + - `-ethernet`, specifies to use Ethernet for Matter application. - - `-thread-ftd`, specifies to use Thread FTD for Matter application. + - `-thread`, specifies to use Thread FTD for Matter application. - - `-thread-mtd`, specifies to use Thread MTD for Matter application. + - `-thread-ftd`, specifies to use Thread FTD for Matter application. -- storage options, select one of the following options to build + - `-thread-mtd`, specifies to use Thread MTD for Matter application. - - `-littlefs`, specifies to use `littlefs` for flash access. +- storage options, select one of the following options to build - - `-easyflash`, specifies to use `easyflash` for flash access. - - > `littlefs` has different format with `easyflash`, please uses `-easyflash` for your in-field production + - `-littlefs`, specifies to use `littlefs` for flash access. -- `-rotating_device_id`, enable rotating device id + - `-easyflash`, specifies to use `easyflash` for flash access. -- `-mfd`, enable Matter factory data feature, which load factory data from `MFD` partition - - Please refer to [Bouffalo Lab Matter factory data guide](../../../docs/platforms/bouffalolab/matter_factory_data.md) or contact to `Bouffalo Lab` for support. + > `littlefs` has different format with `easyflash`, please uses + > `-easyflash` for your in-field production + +- `-rotating_device_id`, enable rotating device id + +- `-mfd`, enable Matter factory data feature, which load factory data from + `MFD` partition + - Please refer to + [Bouffalo Lab Matter factory data guide](../../../docs/platforms/bouffalolab/matter_factory_data.md) + or contact to `Bouffalo Lab` for support. - `-shell`, enable command line - `-rpc`, enable Pigweed RPC feature -- `-cdc`, enable USB CDC feature, only support for BL706, and can't work with Ethernet Board -- `-mot`, to specify to use openthread stack under `third_party/openthread/repo` - - Without `-mot` specified, Matter Thread will use openthread stack under `Bouffalo Lab` SDK +- `-cdc`, enable USB CDC feature, only support for BL706, and can't work with + Ethernet Board +- `-mot`, to specify to use openthread stack under + `third_party/openthread/repo` + - Without `-mot` specified, Matter Thread will use openthread stack under + `Bouffalo Lab` SDK -By default, `Bouffalo Lab` Matter project uses UART baudrate 2000000 for logging output by default, please change variable `baudrate` in `BUILD.gn` under example project. +By default, `Bouffalo Lab` Matter project uses UART `baudrate` 2000000 for +logging output by default, please change variable `baudrate` in `BUILD.gn` under +example project. ## Build CHIP Lighting App example -The following steps take examples for `BL602DK`, `BL616DK`, `BL704LDK` and `BL706DK`. +The following steps take examples for `BL602DK`, `BL616DK`, `BL704LDK` and +`BL706DK`. - Build lighting app with UART baudrate 2000000 @@ -172,9 +185,12 @@ The following steps take examples for `BL602DK`, `BL616DK`, `BL704LDK` and `BL70 ## Download image -After Matter project compiled, take BL602DK lighting app with Wi-Fi and `littlefs` supported as example, `chip-bl602-lighting-example.flash.py` will be generated out under `./out/bouffalolab-bl602dk-light-wifi-littlefs/`. +After Matter project compiled, take BL602DK lighting app with Wi-Fi and +`littlefs` supported as example, `chip-bl602-lighting-example.flash.py` will be +generated out under `./out/bouffalolab-bl602dk-light-wifi-littlefs/`. -Download operation steps as below, please check `help` option of script for more detail. +Download operation steps as below, please check `help` option of script for more +detail. - Connect the board to your build machine with USB cable @@ -184,25 +200,28 @@ Download operation steps as below, please check `help` option of script for more - Click the **RESET** or **EN** button. - Release the **BOOT** button. -- Type following command for image download. Please set serial port accordingly, here we use /dev/ttyACM0 as a serial port example. - +- Type following command for image download. Please set serial port + accordingly, here we use /dev/ttyACM0 as a serial port example. + - `BL602DK`, `BL616DK`, `BL704LDK` and `BL706DK`. - + ```shell ./out/bouffalolab-bl602dk-light-wifi-littlefs/chip-bl702-lighting-example.flash.py --port /dev/ttyACM0 ``` - - - To wipe out flash and download image, please append `--erase` option. - + + - To wipe out flash and download image, please append `--erase` option. + ```shell ./out/bouffalolab-bl602dk-light-wifi-littlefs/chip-bl702-lighting-example.flash.py --port /dev/ttyACM0 --erase ``` - - > Note, better to append --erase option to download image for BL602 develop board at first time. + + > Note, better to append --erase option to download image for BL602 + > develop board at first time. ## Run the example -You can open the serial console. For example, if the device is at `/dev/ttyACM0` with UART baudrate 2000000 built: +You can open the serial console. For example, if the device is at `/dev/ttyACM0` +with UART baudrate 2000000 built: ```shell picocom -b 2000000 /dev/ttyACM0 @@ -210,19 +229,26 @@ picocom -b 2000000 /dev/ttyACM0 - To reset the board, Click the **RESET** or **EN** button. -- To toggle the light bulb’s on/off state by clicking BOOT button, which also toggles the LED. +- To toggle the light bulb’s on/off state by clicking BOOT button, which also + toggles the LED. -- To do factory reset, press BOOT button over 4 seconds, release BOOT button after led blink stopped. +- To do factory reset, press BOOT button over 4 seconds, release BOOT button + after led blink stopped. ## Test Commission and Control with chip-tool -Please follow [chip_tool_guide](../../../docs/guides/chip_tool_guide.md) and [guide](../../chip-tool/README.md) to build and use chip-tool for test. +Please follow [chip_tool_guide](../../../docs/guides/chip_tool_guide.md) and +[guide](../../chip-tool/README.md) to build and use chip-tool for test. ### Prerequisite for Thread Protocol -Thread wireless protocol runs on BL704L/BL706/BL616, which needs a Thread border router to connect Thread network to Wi-Fi/Ethernet network. Please follow this [guide](../../../docs/guides/openthread_border_router_pi.md) to setup a raspberry Pi border router. +Thread wireless protocol runs on BL704L/BL706/BL616, which needs a Thread border +router to connect Thread network to Wi-Fi/Ethernet network. Please follow this +[guide](../../../docs/guides/openthread_border_router_pi.md) to setup a +raspberry Pi border router. -After Thread border router setup, please type following command on Thread border router to get Thread network credential. +After Thread border router setup, please type following command on Thread border +router to get Thread network credential. ```shell sudo ot-ctl dataset active -x @@ -247,7 +273,11 @@ sudo ot-ctl dataset active -x ./chip-tool pairing ble-thread hex: 20202021 3840 ``` - > ``, which is node ID assigned to device within chip-tool fabric
``, Wi-Fi network SSID
``, Wi-FI network password
``, Thread network credential which running `sudo ot-ctl dataset active -x` command on border router to get. + > ``, which is node ID assigned to device within chip-tool + > fabric
``, Wi-Fi network SSID
``, Wi-FI + > network password
``, Thread network + > credential which running `sudo ot-ctl dataset active -x` command on border + > router to get. ### Cluster control @@ -287,11 +317,14 @@ After successful commissioning, cluster commands available to control the board. ## Test OTA software upgrade with ota-provider-app -Please take [guide](../../ota-provider-app/linux/README.md) for more detail on ota-provider-app build and usage. +Please take [guide](../../ota-provider-app/linux/README.md) for more detail on +ota-provider-app build and usage. ### Build on OTA image -After Matter project compiled, take BL602DK lighting app with Wi-Fi and littlefs supported as example, `chip-bl702-lighting-example.flash.py` will be generated out under `./out/bouffalolab-bl602dk-light-wifi-littlefs/`. +After Matter project compiled, take BL602DK lighting app with Wi-Fi and +`littlefs` supported as example, `chip-bl702-lighting-example.flash.py` will be +generated out under `./out/bouffalolab-bl602dk-light-wifi-littlefs/`. Type following command to generated OTA images: @@ -299,36 +332,47 @@ Type following command to generated OTA images: ./out/bouffalolab-bl602dk-light-wifi-littlefs/chip-bl702-lighting-example.flash.py --build-ota --vendor-id --product-id --version --version-str --digest-algorithm ``` -Please find `./src/app/ota_image_tool.py` for information on `vendor id`, `product id`, `version number`, `version number string` and `digest algorithm`. +Please find `./src/app/ota_image_tool.py` for information on `vendor id`, +`product id`, `version number`, `version number string` and `digest algorithm`. -Here is an example to generate an OTA image, +Here is an example to generate an OTA image, -> please change `CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION` in CHIPProjectConfig.h under example folder before to build a firmware image. +> please change `CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION` in +> CHIPProjectConfig.h under example folder before to build a firmware image. ```shell ./out/bouffalolab-bl602dk-light-wifi-littlefs/chip-bl702-lighting-example.flash.py --build-ota --vendor-id 0xFFF1 --product-id 0x8005 --version 10 --version-str "1.0" --digest-algorithm sha256 ``` -All of BL602, BL702L and BL706 have same OTA image format. Take BL602DK lighting app with Wi-Fi and littlefs supported as example, after command executed, OTA images will generated under `out/bouffalolab-bl602dk-light-wifi-littlefs/ota_images`: +All of BL602, BL702L and BL706 have same OTA image format. Take BL602DK lighting +app with Wi-Fi and `littlefs` supported as example, after command executed, OTA +images will generated under +`out/bouffalolab-bl602dk-light-wifi-littlefs/ota_images`: -- `chip-bl602dk-lighting-example.bin.hash.matter`, OTA image packed with raw firmware image. -- `chip-bl602dk-lighting-example.bin.xz.hash.matter`, OTA image packed with compressed firmware image. +- `chip-bl602dk-lighting-example.bin.hash.matter`, OTA image packed with raw + firmware image. +- `chip-bl602dk-lighting-example.bin.xz.hash.matter`, OTA image packed with + compressed firmware image. -BL616 SoC platform uses different OTA image format. Take BL616D lighting app with Wi-Fi and littlefs supported as example: +BL616 SoC platform uses different OTA image format. Take BL616D lighting app +with Wi-Fi and `littlefs` supported as example: -- `chip-bl616-lighting-example.bin.ota.matter`, OTA image packed with raw firmware image. -- `chip-bl616-lighting-example.xz.ota.matter`, OTA image packed with compressed firmware image. +- `chip-bl616-lighting-example.bin.ota.matter`, OTA image packed with raw + firmware image. +- `chip-bl616-lighting-example.xz.ota.matter`, OTA image packed with + compressed firmware image. -> Please contact `Bouffalo Lab` for more security requirements on firmware and OTA images. +> Please contact `Bouffalo Lab` for more security requirements on firmware and +> OTA images. ### Start ota-provider-app -- Start ota-provider-app with OTA image. +- Start ota-provider-app with OTA image. - ```shell - $ rm -r /tmp/chip_* - $ out/linux-x64-ota-provider/chip-ota-provider-app -f out/bouffalolab-bl602dk-light-wifi-littlefs/ota_images/chip-bl702-lighting-example.bin.xz.hash.matter - ``` + ```shell + $ rm -r /tmp/chip_* + $ out/linux-x64-ota-provider/chip-ota-provider-app -f out/bouffalolab-bl602dk-light-wifi-littlefs/ota_images/chip-bl702-lighting-example.bin.xz.hash.matter + ``` - Provision ota-provider-app with assigned node id to 1 ```shell @@ -343,14 +387,16 @@ BL616 SoC platform uses different OTA image format. Take BL616D lighting app wit ```shell ./chip-tool otasoftwareupdaterequestor announce-otaprovider 1 0 0 0 0 ``` - where `` is node id of BL602/BL616/BL702 lighting app. + where `` is node id of BL602/BL616/BL702 lighting + app. - After OTA software upgrade gets done, BL602/BL616/BL702 will get reboot automatically. ## Run RPC Console -- Build chip-console following this [guide](../../common/pigweed/rpc_console/README.md) - +- Build chip-console following this + [guide](../../common/pigweed/rpc_console/README.md) + - Start the console ``` diff --git a/examples/lighting-app/bouffalolab/bl616/BUILD.gn b/examples/lighting-app/bouffalolab/bl616/BUILD.gn index a98f9ffd921d9c..6671db3f9f7a6d 100644 --- a/examples/lighting-app/bouffalolab/bl616/BUILD.gn +++ b/examples/lighting-app/bouffalolab/bl616/BUILD.gn @@ -57,7 +57,6 @@ declare_args() { } bouffalo_sdk("sdk") { - include_dirs = [ "${example_dir}/bl616", "${examples_plat_dir}/bl616", @@ -261,13 +260,12 @@ bouffalolab_executable("lighting_app") { } if (bouffalo_sdk_component_easyflash_enabled) { - defines += [ "BOUFFALO_SDK_COMPONENTS_EASYFLASH_ENABLED=1" ] - } - else { - defines += [ "BOUFFALO_SDK_COMPONENTS_EASYFLASH_ENABLED=0" ] + defines += [ "BOUFFALO_SDK_COMPONENTS_EASYFLASH_ENABLED=1" ] + } else { + defines += [ "BOUFFALO_SDK_COMPONENTS_EASYFLASH_ENABLED=0" ] } - print ("bouffalo_sdk_root=${bouffalo_sdk_root}") + print("bouffalo_sdk_root=${bouffalo_sdk_root}") cflags_c = [ "-Wno-sign-compare" ] ldscript = "${bouffalo_sdk_root}/bsp/board/bl616dk/bl616_flash.ld" diff --git a/examples/lighting-app/bouffalolab/bl616/FreeRTOSConfig.h b/examples/lighting-app/bouffalolab/bl616/FreeRTOSConfig.h index 4bd8b4f5389113..609c13605a90a7 100644 --- a/examples/lighting-app/bouffalolab/bl616/FreeRTOSConfig.h +++ b/examples/lighting-app/bouffalolab/bl616/FreeRTOSConfig.h @@ -42,44 +42,46 @@ #include #include -#define configMTIME_BASE_ADDRESS (0xE0000000UL + 0xBFF8UL) +#define configMTIME_BASE_ADDRESS (0xE0000000UL + 0xBFF8UL) #define configMTIMECMP_BASE_ADDRESS (0xE0000000UL + 0x4000UL) -#define configSUPPORT_STATIC_ALLOCATION 1 -#define configUSE_PREEMPTION 1 -#define configUSE_IDLE_HOOK 0 -#define configUSE_TICK_HOOK 0 -#define configCPU_CLOCK_HZ ((uint32_t)(1 * 1000 * 1000)) -#define configTICK_RATE_HZ ((TickType_t)1000) -#define configMAX_PRIORITIES (32) -#define configMINIMAL_STACK_SIZE ((unsigned short)128) /* Only needs to be this high as some demo tasks also use this constant. In production only the idle task would use this. */ -#define configTOTAL_HEAP_SIZE ((size_t)100 * 1024) -#define configMAX_TASK_NAME_LEN (16) -#define configUSE_TRACE_FACILITY 1 -#define configUSE_STATS_FORMATTING_FUNCTIONS 1 -#define configUSE_16_BIT_TICKS 0 -#define configIDLE_SHOULD_YIELD 0 -#define configUSE_MUTEXES 1 -#define configQUEUE_REGISTRY_SIZE 8 -#define configCHECK_FOR_STACK_OVERFLOW 2 -#define configUSE_RECURSIVE_MUTEXES 1 -#define configUSE_MALLOC_FAILED_HOOK 1 -#define configUSE_APPLICATION_TASK_TAG 1 -#define configUSE_COUNTING_SEMAPHORES 1 -#define configGENERATE_RUN_TIME_STATS 1 +#define configSUPPORT_STATIC_ALLOCATION 1 +#define configUSE_PREEMPTION 1 +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 0 +#define configCPU_CLOCK_HZ ((uint32_t) (1 * 1000 * 1000)) +#define configTICK_RATE_HZ ((TickType_t) 1000) +#define configMAX_PRIORITIES (32) +#define configMINIMAL_STACK_SIZE \ + ((unsigned short) 128) /* Only needs to be this high as some demo tasks also use this constant. In production only the idle \ + task would use this. */ +#define configTOTAL_HEAP_SIZE ((size_t) 100 * 1024) +#define configMAX_TASK_NAME_LEN (16) +#define configUSE_TRACE_FACILITY 1 +#define configUSE_STATS_FORMATTING_FUNCTIONS 1 +#define configUSE_16_BIT_TICKS 0 +#define configIDLE_SHOULD_YIELD 0 +#define configUSE_MUTEXES 1 +#define configQUEUE_REGISTRY_SIZE 8 +#define configCHECK_FOR_STACK_OVERFLOW 2 +#define configUSE_RECURSIVE_MUTEXES 1 +#define configUSE_MALLOC_FAILED_HOOK 1 +#define configUSE_APPLICATION_TASK_TAG 1 +#define configUSE_COUNTING_SEMAPHORES 1 +#define configGENERATE_RUN_TIME_STATS 1 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 -#define configUSE_TICKLESS_IDLE 0 -#define configUSE_POSIX_ERRNO 1 +#define configUSE_TICKLESS_IDLE 0 +#define configUSE_POSIX_ERRNO 1 /* Co-routine definitions. */ -#define configUSE_CO_ROUTINES 0 -#define configMAX_CO_ROUTINE_PRIORITIES (2) +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES (2) /* Software timer definitions. */ -#define configUSE_TIMERS 1 -#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1) -#define configTIMER_QUEUE_LENGTH 4 -#define configTIMER_TASK_STACK_DEPTH (1024) +#define configUSE_TIMERS 1 +#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1) +#define configTIMER_QUEUE_LENGTH 4 +#define configTIMER_TASK_STACK_DEPTH (1024) /* Task priorities. Allow these to be overridden. */ #ifndef uartPRIMARY_PRIORITY @@ -88,17 +90,17 @@ /* Set the following definitions to 1 to include the API function, or zero to exclude the API function. */ -#define INCLUDE_vTaskPrioritySet 1 -#define INCLUDE_uxTaskPriorityGet 1 -#define INCLUDE_vTaskDelete 1 -#define INCLUDE_vTaskCleanUpResources 1 -#define INCLUDE_vTaskSuspend 1 -#define INCLUDE_vTaskDelayUntil 1 -#define INCLUDE_vTaskDelay 1 -#define INCLUDE_eTaskGetState 1 -#define INCLUDE_xTimerPendFunctionCall 1 -#define INCLUDE_xTaskAbortDelay 1 -#define INCLUDE_xTaskGetHandle 1 +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 1 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_eTaskGetState 1 +#define INCLUDE_xTimerPendFunctionCall 1 +#define INCLUDE_xTaskAbortDelay 1 +#define INCLUDE_xTaskGetHandle 1 #define INCLUDE_xSemaphoreGetMutexHolder 1 /* Normal assert() semantics without relying on the provision of an assert.h @@ -110,13 +112,14 @@ extern "C" void vAssertCalled(void); #else void vAssertCalled(void); #endif -#define configASSERT(x) \ - if ((x) == 0) { \ - printf("file [%s]\r\n", __FILE__); \ - printf("func [%s]\r\n", __FUNCTION__); \ - printf("line [%d]\r\n", __LINE__); \ - printf("%s\r\n", (const char *)(#x)); \ - vAssertCalled(); \ +#define configASSERT(x) \ + if ((x) == 0) \ + { \ + printf("file [%s]\r\n", __FILE__); \ + printf("func [%s]\r\n", __FUNCTION__); \ + printf("line [%d]\r\n", __LINE__); \ + printf("%s\r\n", (const char *) (#x)); \ + vAssertCalled(); \ } #if (configUSE_TICKLESS_IDLE != 0) @@ -132,8 +135,8 @@ extern "C" uint64_t bflb_mtimer_get_time_us(); #else extern uint64_t bflb_mtimer_get_time_us(); #endif -#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() ((void)0) -#define portGET_RUN_TIME_COUNTER_VALUE() bflb_mtimer_get_time_us() +#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() ((void) 0) +#define portGET_RUN_TIME_COUNTER_VALUE() bflb_mtimer_get_time_us() #endif #endif /* FREERTOS_CONFIG_H */ diff --git a/examples/lighting-app/bouffalolab/bl616/mboard.h b/examples/lighting-app/bouffalolab/bl616/mboard.h index 7c101f54363e23..c025609d89472e 100644 --- a/examples/lighting-app/bouffalolab/bl616/mboard.h +++ b/examples/lighting-app/bouffalolab/bl616/mboard.h @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2018, The OpenThread Authors. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file - * This file includes dev borad compile-time configuration constants for BL602. - * - */ - -#pragma once - -#define CHIP_UART_PORT 0 -#define CHIP_UART_RX_BUFFSIZE 256 - -#define LED_B_PWM_CH 0 -#define LED_B_PIN 0 - -#define LED_R_PWM_CH 1 -#define LED_R_PIN 1 - -#define LED_G_PWM_CH 2 -#define LED_G_PIN 30 - -#define MAX_PWM_CHANNEL 3 - -#define CHIP_UART_PIN_RX 7 -#define CHIP_UART_PIN_TX 16 +/* + * Copyright (c) 2018, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * This file includes dev borad compile-time configuration constants for BL602. + * + */ + +#pragma once + +#define CHIP_UART_PORT 0 +#define CHIP_UART_RX_BUFFSIZE 256 + +#define LED_B_PWM_CH 0 +#define LED_B_PIN 0 + +#define LED_R_PWM_CH 1 +#define LED_R_PIN 1 + +#define LED_G_PWM_CH 2 +#define LED_G_PIN 30 + +#define MAX_PWM_CHANNEL 3 + +#define CHIP_UART_PIN_RX 7 +#define CHIP_UART_PIN_TX 16 diff --git a/examples/lighting-app/bouffalolab/bl702l/BUILD.gn b/examples/lighting-app/bouffalolab/bl702l/BUILD.gn index ef962cfcf5a348..c004af4134dfc2 100644 --- a/examples/lighting-app/bouffalolab/bl702l/BUILD.gn +++ b/examples/lighting-app/bouffalolab/bl702l/BUILD.gn @@ -139,8 +139,8 @@ bouffalolab_executable("lighting_app") { ] deps = [ - ":sdk", ":bouffalolab-lighting", + ":sdk", "${chip_root}/examples/providers:device_info_provider", "${chip_root}/src/lib", "${chip_root}/src/platform/logging:default", diff --git a/examples/lighting-app/bouffalolab/bl702l/FreeRTOSConfig.h b/examples/lighting-app/bouffalolab/bl702l/FreeRTOSConfig.h index 9c506dbdef7b26..211c471007e947 100644 --- a/examples/lighting-app/bouffalolab/bl702l/FreeRTOSConfig.h +++ b/examples/lighting-app/bouffalolab/bl702l/FreeRTOSConfig.h @@ -163,7 +163,9 @@ extern "C" void vAssertCalled(void); #else extern void vAssertCalled(void); #endif -#define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled() +#define configASSERT(x) \ + if ((x) == 0) \ + vAssertCalled() /* Overwrite some of the stack sizes allocated to various test and demo tasks. Like all task stack sizes, the value is the number of words, not bytes. */ diff --git a/examples/lighting-app/bouffalolab/bl702l/mboard.h b/examples/lighting-app/bouffalolab/bl702l/mboard.h index d5140499cfd0fe..ceb458547e8189 100644 --- a/examples/lighting-app/bouffalolab/bl702l/mboard.h +++ b/examples/lighting-app/bouffalolab/bl702l/mboard.h @@ -1,90 +1,90 @@ -/* - * Copyright (c) 2018, The OpenThread Authors. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file - * This file includes dev borad compile-time configuration constants for BL702L. - * - */ - -#pragma once - -#define CHIP_UART_PORT 0 -#define CHIP_UART_RX_BUFFSIZE 256 - -#ifdef BL706_NIGHT_LIGHT - -#define LED_B_PIN_PORT 2 -#define LED_B_PIN 12 - -#define LED_R_PIN_PORT 0 -#define LED_R_PIN 10 - -#define LED_G_PIN_PORT 1 -#define LED_G_PIN 16 - -#define MAX_PWM_CHANNEL 3 - -#elif defined(XT_ZB6_DevKit) - -// #define LED_B_PIN_PORT 3 -// #define LED_B_PIN 18 - -// #define LED_R_PIN_PORT 4 -// #define LED_R_PIN 19 - -// #define LED_G_PIN_PORT 0 -// #define LED_G_PIN 20 - -#define LED_PIN_PORT 3 -#define LED_PIN 18 - -#define MAX_PWM_CHANNEL 1 - -#elif defined (BL704LDK) -#define LED_PIN_PORT 1 -#define LED_PIN 18 - -#define MAX_PWM_CHANNEL 1 -#else - -#define LED_PIN_PORT 2 -#define LED_PIN 22 - -#define MAX_PWM_CHANNEL 1 - -#endif - -#define SPI_WIFI_MISO_PIN 4 -#define SPI_WIFI_MOSI_PIN 5 -#define SPI_WIFI_CLK_PIN 3 -#define SPI_WIFI_CS_PIN 6 -#define SPI_WIFI_IRQ_PIN 10 - -#define CHIP_UART_PIN_RX 15 -#define CHIP_UART_PIN_TX 14 +/* + * Copyright (c) 2018, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * This file includes dev borad compile-time configuration constants for BL702L. + * + */ + +#pragma once + +#define CHIP_UART_PORT 0 +#define CHIP_UART_RX_BUFFSIZE 256 + +#ifdef BL706_NIGHT_LIGHT + +#define LED_B_PIN_PORT 2 +#define LED_B_PIN 12 + +#define LED_R_PIN_PORT 0 +#define LED_R_PIN 10 + +#define LED_G_PIN_PORT 1 +#define LED_G_PIN 16 + +#define MAX_PWM_CHANNEL 3 + +#elif defined(XT_ZB6_DevKit) + +// #define LED_B_PIN_PORT 3 +// #define LED_B_PIN 18 + +// #define LED_R_PIN_PORT 4 +// #define LED_R_PIN 19 + +// #define LED_G_PIN_PORT 0 +// #define LED_G_PIN 20 + +#define LED_PIN_PORT 3 +#define LED_PIN 18 + +#define MAX_PWM_CHANNEL 1 + +#elif defined(BL704LDK) +#define LED_PIN_PORT 1 +#define LED_PIN 18 + +#define MAX_PWM_CHANNEL 1 +#else + +#define LED_PIN_PORT 2 +#define LED_PIN 22 + +#define MAX_PWM_CHANNEL 1 + +#endif + +#define SPI_WIFI_MISO_PIN 4 +#define SPI_WIFI_MOSI_PIN 5 +#define SPI_WIFI_CLK_PIN 3 +#define SPI_WIFI_CS_PIN 6 +#define SPI_WIFI_IRQ_PIN 10 + +#define CHIP_UART_PIN_RX 15 +#define CHIP_UART_PIN_TX 14 diff --git a/examples/lighting-app/bouffalolab/common/AppTask.cpp b/examples/lighting-app/bouffalolab/common/AppTask.cpp index 49c11df0fcbb47..aa2039bf4e8620 100644 --- a/examples/lighting-app/bouffalolab/common/AppTask.cpp +++ b/examples/lighting-app/bouffalolab/common/AppTask.cpp @@ -24,9 +24,9 @@ #include #include #include -#include #include #include +#include #if HEAP_MONITORING #include "MemMonitoring.h" @@ -152,7 +152,7 @@ void AppTask::PostEvent(app_event_t event) void AppTask::AppTaskMain(void * pvParameter) { app_event_t appEvent; - bool onoff = false; + bool onoff = false; uint64_t currentHeapFree = 0; #if !(CHIP_DEVICE_LAYER_TARGET_BL702 && CHIP_DEVICE_CONFIG_ENABLE_ETHERNET) @@ -162,7 +162,7 @@ void AppTask::AppTaskMain(void * pvParameter) #ifdef BOOT_PIN_RESET ButtonInit(); #else - uint32_t resetCnt = 0; + uint32_t resetCnt = 0; Internal::BLConfig::ReadConfigValue(APP_REBOOT_RESET_COUNT_KEY, resetCnt); Internal::BLConfig::WriteConfigValue(APP_REBOOT_RESET_COUNT_KEY, resetCnt); GetAppTask().mButtonPressedTime = System::SystemClock().GetMonotonicMilliseconds64().count(); @@ -228,10 +228,11 @@ void AppTask::AppTaskMain(void * pvParameter) sLightLED.SetOnoff(false); } -#else +#else if (APP_EVENT_RESET_CNT & appEvent) { - if (resetCnt >= APP_REBOOT_RESET_COUNT) { + if (resetCnt >= APP_REBOOT_RESET_COUNT) + { GetAppTask().PostEvent(APP_EVENT_FACTORY_RESET); } ChipLogProgress(NotSpecified, "APP_REBOOT_RESET_COUNT_KEY resetCnt %ld", resetCnt); @@ -407,7 +408,8 @@ void AppTask::TimerEventHandler(app_event_t event) } } #else - if (GetAppTask().mButtonPressedTime && System::SystemClock().GetMonotonicMilliseconds64().count() - GetAppTask().mButtonPressedTime > APP_BUTTON_PRESS_LONG) + if (GetAppTask().mButtonPressedTime && + System::SystemClock().GetMonotonicMilliseconds64().count() - GetAppTask().mButtonPressedTime > APP_BUTTON_PRESS_LONG) { #if defined(BL602_NIGHT_LIGHT) || defined(BL706_NIGHT_LIGHT) || defined(BL616DK) /** change color to indicate to wait factory reset confirm */ @@ -467,10 +469,11 @@ void AppTask::ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction) #ifdef BOOT_PIN_RESET #if CHIP_DEVICE_LAYER_TARGET_BL616 static struct bflb_device_s * app_task_gpio_var = NULL; -static void app_task_gpio_isr(int irq, void *arg) +static void app_task_gpio_isr(int irq, void * arg) { bool intstatus = bflb_gpio_get_intstatus(app_task_gpio_var, BOOT_PIN_RESET); - if (intstatus) { + if (intstatus) + { bflb_gpio_int_clear(app_task_gpio_var, BOOT_PIN_RESET); } diff --git a/examples/lighting-app/bouffalolab/common/AppTask.h b/examples/lighting-app/bouffalolab/common/AppTask.h index 85ea2a3929ef25..37f8678e0505eb 100644 --- a/examples/lighting-app/bouffalolab/common/AppTask.h +++ b/examples/lighting-app/bouffalolab/common/AppTask.h @@ -65,12 +65,12 @@ class AppTask APP_EVENT_BTN_ISR = 0x00000100, APP_EVENT_RESET_CNT = 0x00000200, - APP_EVENT_LIGHTING_ONOFF = 0x00010000, - APP_EVENT_LIGHTING_LEVEL = 0x00020000, - APP_EVENT_LIGHTING_COLOR = 0x00040000, - APP_EVENT_LIGHTING_MASK = APP_EVENT_LIGHTING_ONOFF | APP_EVENT_LIGHTING_LEVEL | APP_EVENT_LIGHTING_COLOR, + APP_EVENT_LIGHTING_ONOFF = 0x00010000, + APP_EVENT_LIGHTING_LEVEL = 0x00020000, + APP_EVENT_LIGHTING_COLOR = 0x00040000, + APP_EVENT_LIGHTING_MASK = APP_EVENT_LIGHTING_ONOFF | APP_EVENT_LIGHTING_LEVEL | APP_EVENT_LIGHTING_COLOR, APP_EVENT_COMMISSION_COMPLETE = APP_EVENT_LIGHTING_MASK, - + APP_EVENT_IDENTIFY_START = 0x01000000, APP_EVENT_IDENTIFY_IDENTIFY = 0x02000000, APP_EVENT_IDENTIFY_STOP = 0x04000000, diff --git a/examples/platform/bouffalolab/bl602/ldscripts/flash_rom.ld b/examples/platform/bouffalolab/bl602/ldscripts/flash_rom.ld index c39a508da8fbdb..206f89bd077fd3 100644 --- a/examples/platform/bouffalolab/bl602/ldscripts/flash_rom.ld +++ b/examples/platform/bouffalolab/bl602/ldscripts/flash_rom.ld @@ -120,6 +120,12 @@ SECTIONS *(.static_blogpri_code*) _bl_static_blogpri_code_end = .; + /* section information for components's version */ + . = ALIGN(4); + _version_info_section_start = .; + KEEP(*(.version.*)) + _version_info_section_end = .; + *(.gnu.linkonce.r.*) /*Framework table section, use ALIGN here to avoid fill section*/ diff --git a/examples/platform/bouffalolab/bl616/lwipopts.h b/examples/platform/bouffalolab/bl616/lwipopts.h index f392551940e8b5..91d779fb9356e5 100644 --- a/examples/platform/bouffalolab/bl616/lwipopts.h +++ b/examples/platform/bouffalolab/bl616/lwipopts.h @@ -32,113 +32,125 @@ #ifndef LWIP_HDR_LWIPOPTS_H__ #define LWIP_HDR_LWIPOPTS_H__ -#include -#include "rtos_def.h" #include "arch/sys_arch.h" +#include "rtos_def.h" +#include #if defined(__cplusplus) extern "C" long random(void); extern "C" int * __errno(void); -extern "C" uint16_t fhost_ip_chksum(const void *dataptr, int len); +extern "C" uint16_t fhost_ip_chksum(const void * dataptr, int len); extern "C" sys_mutex_t lock_tcpip_core; extern "C" int sys_is_inside_interrupt(void); -extern "C" int sys_mutex_is_locked(sys_mutex_t *mutex); +extern "C" int sys_mutex_is_locked(sys_mutex_t * mutex); extern "C" int sys_current_is_tcpip(void); #else extern long random(void); extern int * __errno(void); -extern uint16_t fhost_ip_chksum(const void *dataptr, int len); +extern uint16_t fhost_ip_chksum(const void * dataptr, int len); extern sys_mutex_t lock_tcpip_core; extern int sys_is_inside_interrupt(void); -extern int sys_mutex_is_locked(sys_mutex_t *mutex); +extern int sys_mutex_is_locked(sys_mutex_t * mutex); extern int sys_current_is_tcpip(void); extern const int fhost_tcpip_priority; #endif -#define LWIP_TCPIP_CORE_LOCKING 1 -#define IP_DEFAULT_TTL 64 +#define LWIP_TCPIP_CORE_LOCKING 1 +#define IP_DEFAULT_TTL 64 #if defined(CONFIG_HIGH_PERFORMANCE) && (CONFIG_HIGH_PERFORMANCE == 1) #define LWIP_ASSERT_CORE_LOCKED() #define LWIP_NOASSERT #else #if LWIP_TCPIP_CORE_LOCKING -#define LWIP_ASSERT_CORE_LOCKED() do { if(lock_tcpip_core) { LWIP_ASSERT("api must call with lwip core lock", !sys_is_inside_interrupt() && sys_mutex_is_locked(&lock_tcpip_core)); } } while(0) +#define LWIP_ASSERT_CORE_LOCKED() \ + do \ + { \ + if (lock_tcpip_core) \ + { \ + LWIP_ASSERT("api must call with lwip core lock", !sys_is_inside_interrupt() && sys_mutex_is_locked(&lock_tcpip_core)); \ + } \ + } while (0) #else -#define LWIP_ASSERT_CORE_LOCKED() do { LWIP_ASSERT("api must call inside lwip task", !sys_is_inside_interrupt() && sys_current_is_tcpip()); } while(0) +#define LWIP_ASSERT_CORE_LOCKED() \ + do \ + { \ + LWIP_ASSERT("api must call inside lwip task", !sys_is_inside_interrupt() && sys_current_is_tcpip()); \ + } while (0) #endif #endif -#define LWIP_NETIF_API 1 -#define LWIP_DEBUG 1 -#define LWIP_STATS_DISPLAY 1 -#define SOCKETS_DEBUG LWIP_DBG_OFF +#define LWIP_NETIF_API 1 +#define LWIP_DEBUG 1 +#define LWIP_STATS_DISPLAY 1 +#define SOCKETS_DEBUG LWIP_DBG_OFF #ifdef BL616_DHCP_DEBUG -#define DHCP_DEBUG LWIP_DBG_ON +#define DHCP_DEBUG LWIP_DBG_ON #else -#define DHCP_DEBUG LWIP_DBG_OFF +#define DHCP_DEBUG LWIP_DBG_OFF #endif -#define ICMP_DEBUG LWIP_DBG_OFF -#define ETHARP_DEBUG LWIP_DBG_OFF -#define LWIP_MULTICAST_PING 1 -#define LWIP_BROADCAST_PING 1 - -#define TCPIP_MBOX_SIZE 64 -#define TCPIP_THREAD_STACKSIZE FHOST_TCPIP_STACK_SIZE -#define TCPIP_THREAD_PRIO fhost_tcpip_priority - -#define DEFAULT_THREAD_STACKSIZE 1024 -#define DEFAULT_THREAD_PRIO 1 -#define DEFAULT_RAW_RECVMBOX_SIZE 32 -#define DEFAULT_UDP_RECVMBOX_SIZE 64 -#define DEFAULT_TCP_RECVMBOX_SIZE 64 -#define DEFAULT_ACCEPTMBOX_SIZE 32 - -#define LWIP_NETIF_LOOPBACK 1 -#define LWIP_HAVE_LOOPIF 1 -#define LWIP_LOOPBACK_MAX_PBUFS 0 - -#define LWIP_CHKSUM_ALGORITHM 3 -#define LWIP_CHKSUM fhost_ip_chksum +#define ICMP_DEBUG LWIP_DBG_OFF +#define ETHARP_DEBUG LWIP_DBG_OFF +#define LWIP_MULTICAST_PING 1 +#define LWIP_BROADCAST_PING 1 + +#define TCPIP_MBOX_SIZE 64 +#define TCPIP_THREAD_STACKSIZE FHOST_TCPIP_STACK_SIZE +#define TCPIP_THREAD_PRIO fhost_tcpip_priority + +#define DEFAULT_THREAD_STACKSIZE 1024 +#define DEFAULT_THREAD_PRIO 1 +#define DEFAULT_RAW_RECVMBOX_SIZE 32 +#define DEFAULT_UDP_RECVMBOX_SIZE 64 +#define DEFAULT_TCP_RECVMBOX_SIZE 64 +#define DEFAULT_ACCEPTMBOX_SIZE 32 + +#define LWIP_NETIF_LOOPBACK 1 +#define LWIP_HAVE_LOOPIF 1 +#define LWIP_LOOPBACK_MAX_PBUFS 0 + +#define LWIP_CHKSUM_ALGORITHM 3 +#define LWIP_CHKSUM fhost_ip_chksum #define LWIP_TCPIP_CORE_LOCKING_INPUT 1 -#define PBUF_LINK_ENCAPSULATION_HLEN 388 +#define PBUF_LINK_ENCAPSULATION_HLEN 388 -#define MEMP_NUM_NETBUF 32 -#define MEMP_NUM_NETCONN 16 -#define MEMP_NUM_UDP_PCB 16 -#define MEMP_NUM_REASSDATA LWIP_MIN((IP_REASS_MAX_PBUFS), 5) +#define MEMP_NUM_NETBUF 32 +#define MEMP_NUM_NETCONN 16 +#define MEMP_NUM_UDP_PCB 16 +#define MEMP_NUM_REASSDATA LWIP_MIN((IP_REASS_MAX_PBUFS), 5) -#define PBUF_POOL_SIZE 0 -#define MEM_ALIGNMENT 4 -#define MEM_SIZE 30720 -#define PBUF_POOL_BUFSIZE (PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + 1280) -#define MEMP_MEM_MALLOC 1 +#define PBUF_POOL_SIZE 0 +#define MEM_ALIGNMENT 4 +#define MEM_SIZE 30720 +#define PBUF_POOL_BUFSIZE (PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + 1280) +#define MEMP_MEM_MALLOC 1 -//#define LWIP_HOOK_FILENAME "lwiphooks.h" -#define LWIP_HOOK_FILENAME "bl616_lwip_hooks.h" +// #define LWIP_HOOK_FILENAME "lwiphooks.h" +#define LWIP_HOOK_FILENAME "bl616_lwip_hooks.h" -#define LWIP_RAW 1 -#define LWIP_MULTICAST_TX_OPTIONS 1 +#define LWIP_RAW 1 +#define LWIP_MULTICAST_TX_OPTIONS 1 -#define LWIP_TIMEVAL_PRIVATE 0 // use sys/time.h for struct timeval - // -//#define LWIP_PROVIDE_ERRNO 1 +#define LWIP_TIMEVAL_PRIVATE \ + 0 // use sys/time.h for struct timeval + // +// #define LWIP_PROVIDE_ERRNO 1 #ifndef PLATFORM_PRIVDE_ERRNO -#define LWIP_PROVIDE_ERRNO 1 +#define LWIP_PROVIDE_ERRNO 1 #else -#define LWIP_ERRNO_STDINCLUDE 1 -#define LWIP_SOCKET_SET_ERRNO 1 +#define LWIP_ERRNO_STDINCLUDE 1 +#define LWIP_SOCKET_SET_ERRNO 1 #endif -#define LWIP_DHCP 1 -#define LWIP_DNS 1 -#define LWIP_IGMP 1 -#define LWIP_SO_RCVTIMEO 1 -#define LWIP_SO_SNDTIMEO 1 -#define SO_REUSE 1 -#define LWIP_TCP_KEEPALIVE 1 -#define LWIP_SO_RCVBUF 1 +#define LWIP_DHCP 1 +#define LWIP_DNS 1 +#define LWIP_IGMP 1 +#define LWIP_SO_RCVTIMEO 1 +#define LWIP_SO_SNDTIMEO 1 +#define SO_REUSE 1 +#define LWIP_TCP_KEEPALIVE 1 +#define LWIP_SO_RCVBUF 1 #define LWIP_IPV6 1 #define LWIP_IPV6_DHCP6 1 @@ -146,22 +158,23 @@ extern const int fhost_tcpip_priority; #define LWIP_IPV6_MLD 1 #define MEMP_NUM_MLD6_GROUP 10 -#define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + 8 + 3) +#define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + 8 + 3) #define LWIP_NETIF_STATUS_CALLBACK 1 #define LWIP_NETIF_API 1 #define LWIP_NETIF_EXT_STATUS_CALLBACK 1 -#define ETHARP_SUPPORT_STATIC_ENTRIES 1 +#define ETHARP_SUPPORT_STATIC_ENTRIES 1 -#define LWIP_SUPPORT_CUSTOM_PBUF 1 -#ifdef HIGH_PERFORMANCE_PBUF -#define LWIP_NETIF_TX_SINGLE_PBUF 0 +#define LWIP_SUPPORT_CUSTOM_PBUF 1 +#ifdef HIGH_PERFORMANCE_PBUF +#define LWIP_NETIF_TX_SINGLE_PBUF 0 #else -#define LWIP_NETIF_TX_SINGLE_PBUF 1 +#define LWIP_NETIF_TX_SINGLE_PBUF 1 #endif -#define LWIP_RAND() ((u32_t)rand()) +#define LWIP_RAND() ((u32_t) rand()) #undef LWIP_DECLARE_MEMORY_ALIGNED -#define LWIP_DECLARE_MEMORY_ALIGNED(variable_name, size) u8_t variable_name[size] __attribute__((aligned(4))) __attribute__((section("SHAREDRAM"))) +#define LWIP_DECLARE_MEMORY_ALIGNED(variable_name, size) \ + u8_t variable_name[size] __attribute__((aligned(4))) __attribute__((section("SHAREDRAM"))) #endif /* LWIP_HDR_LWIPOPTS_H__ */ diff --git a/examples/platform/bouffalolab/common/bouffalo_sdk/demo_pwm.c b/examples/platform/bouffalolab/common/bouffalo_sdk/demo_pwm.c index a080be5e4d92f1..98d1201af8391e 100644 --- a/examples/platform/bouffalolab/common/bouffalo_sdk/demo_pwm.c +++ b/examples/platform/bouffalolab/common/bouffalo_sdk/demo_pwm.c @@ -4,43 +4,41 @@ * Contact information: * web site: https://www.bouffalolab.com/ */ -#include #include #include #include +#include -#include "mboard.h" #include "demo_pwm.h" - +#include "mboard.h" #if MAX_PWM_CHANNEL == 3 static const uint32_t rgb_pwm[MAX_PWM_CHANNEL][2] = { - {LED_B_PIN, LED_B_PWM_CH}, - {LED_R_PIN, LED_R_PWM_CH}, - {LED_G_PIN, LED_G_PWM_CH}, + { LED_B_PIN, LED_B_PWM_CH }, + { LED_R_PIN, LED_R_PWM_CH }, + { LED_G_PIN, LED_G_PWM_CH }, }; #else static const uint32_t rgb_pwm[][2] = { - { - LED_PIN, LED_PIN_PWM_CH - }, + { LED_PIN, LED_PIN_PWM_CH }, }; #endif -struct bflb_device_s *bflb_device_pwm = NULL; +struct bflb_device_s * bflb_device_pwm = NULL; void demo_pwm_init(void) { struct bflb_pwm_v2_config_s cfg = { .clk_source = BFLB_SYSTEM_PBCLK, - .clk_div = 40, - .period = 1000, + .clk_div = 40, + .period = 1000, }; struct bflb_device_s * gpio = bflb_device_get_by_name("gpio"); bflb_device_pwm = bflb_device_get_by_name("pwm_v2_0"); - for (int i = 0; i < sizeof(rgb_pwm)/sizeof(rgb_pwm[0]); i ++) { + for (int i = 0; i < sizeof(rgb_pwm) / sizeof(rgb_pwm[0]); i++) + { bflb_gpio_init(gpio, rgb_pwm[i][0], GPIO_FUNC_PWM0 | GPIO_ALTERNATE | GPIO_PULLDOWN | GPIO_SMT_EN | GPIO_DRV_1); } @@ -49,7 +47,8 @@ void demo_pwm_init(void) void demo_pwm_start(void) { - for (int i = 0; i < sizeof(rgb_pwm)/sizeof(rgb_pwm[0]); i ++) { + for (int i = 0; i < sizeof(rgb_pwm) / sizeof(rgb_pwm[0]); i++) + { bflb_pwm_v2_channel_positive_start(bflb_device_pwm, rgb_pwm[i][1]); } @@ -69,9 +68,10 @@ void set_level(uint8_t currLevel) { currLevel = 5; // avoid demo off } - period = (int)currLevel * 1000 / 254; + period = (int) currLevel * 1000 / 254; - for (int i = 0; i < sizeof(rgb_pwm)/sizeof(rgb_pwm[0]); i ++) { + for (int i = 0; i < sizeof(rgb_pwm) / sizeof(rgb_pwm[0]); i++) + { bflb_pwm_v2_channel_set_threshold(bflb_device_pwm, rgb_pwm[i][1], 0, period); } } @@ -149,7 +149,7 @@ void set_color(uint8_t currLevel, uint8_t currHue, uint8_t currSat) } bflb_pwm_v2_channel_set_threshold(bflb_device_pwm, rgb_pwm[0][1], 0, blue * 1000 / 254); - bflb_pwm_v2_channel_set_threshold(bflb_device_pwm, rgb_pwm[1][1], 0, red * 1000 / 254); + bflb_pwm_v2_channel_set_threshold(bflb_device_pwm, rgb_pwm[1][1], 0, red * 1000 / 254); bflb_pwm_v2_channel_set_threshold(bflb_device_pwm, rgb_pwm[2][1], 0, green * 1000 / 254); #else set_level(currLevel); diff --git a/examples/platform/bouffalolab/common/bouffalo_sdk/platform_port.cpp b/examples/platform/bouffalolab/common/bouffalo_sdk/platform_port.cpp index bfea60c5c3f341..f92b527b410d3a 100644 --- a/examples/platform/bouffalolab/common/bouffalo_sdk/platform_port.cpp +++ b/examples/platform/bouffalolab/common/bouffalo_sdk/platform_port.cpp @@ -20,8 +20,8 @@ #include extern "C" { -#include #include +#include } #include @@ -56,7 +56,8 @@ extern "C" void vAssertCalled(void) printf("vAssertCalled, ra = %p in task %s\r\n", (void *) ra, pcTaskGetName(NULL)); } - while (true); + while (true) + ; } -extern "C" void bflb_assert(void) __attribute__((weak, alias("vAssertCalled"))); \ No newline at end of file +extern "C" void bflb_assert(void) __attribute__((weak, alias("vAssertCalled"))); diff --git a/examples/platform/bouffalolab/common/bouffalo_sdk/uart.c b/examples/platform/bouffalolab/common/bouffalo_sdk/uart.c index 49de97daaafbba..ef763dd286982d 100644 --- a/examples/platform/bouffalolab/common/bouffalo_sdk/uart.c +++ b/examples/platform/bouffalolab/common/bouffalo_sdk/uart.c @@ -1,228 +1,228 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may nCHIP use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include - -#ifdef CFG_USB_CDC_ENABLE -#include -#include -#include -#include -#include -#include -#include -#else -#include -#include -extern hosal_uart_dev_t uart_stdio; -#endif - -#if CONFIG_ENABLE_CHIP_SHELL || PW_RPC_ENABLED - -#define CHIP_UART_RX_TIMER_ID 1 -#define MAX_BUFFER_SIZE 256 - -typedef struct _chipUart -{ - SemaphoreHandle_t sema; - StaticSemaphore_t mutx; - uint32_t head; - uint32_t tail; - uint8_t rxbuf[MAX_BUFFER_SIZE]; -} chipUart_t; - -static chipUart_t chipUart_var; - -#ifndef CFG_USB_CDC_ENABLE -static int uartTxCallback(void * p_arg) -{ - hosal_uart_ioctl(&uart_stdio, HOSAL_UART_TX_TRIGGER_OFF, NULL); - - return 0; -} - -static int uartRxCallback(void * p_arg) -{ - uint32_t len = 0; - BaseType_t xHigherPriorityTaskWoken = 1; - - if (chipUart_var.head >= chipUart_var.tail) - { - if (chipUart_var.head < MAX_BUFFER_SIZE) - { - len = hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf + chipUart_var.head, MAX_BUFFER_SIZE - chipUart_var.head); - chipUart_var.head = (chipUart_var.head + len) % MAX_BUFFER_SIZE; - } - - if (0 == chipUart_var.head) - { - len = hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf, chipUart_var.tail - 1); - chipUart_var.head += len; - } - } - else - { - chipUart_var.head += - hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf + chipUart_var.head, chipUart_var.tail - chipUart_var.head - 1); - } - - if (chipUart_var.head != chipUart_var.tail) - { - xSemaphoreGiveFromISR(chipUart_var.sema, &xHigherPriorityTaskWoken); - } - - return 0; -} -#else -void aosUartRxCallback(int fd, void * param) -{ - uint32_t len = 0, readlen = 0; - BaseType_t xHigherPriorityTaskWoken = 1; - - if (chipUart_var.head >= chipUart_var.tail) - { - if (chipUart_var.head < MAX_BUFFER_SIZE) - { - readlen = len = aos_read(fd, chipUart_var.rxbuf + chipUart_var.head, MAX_BUFFER_SIZE - chipUart_var.head); - chipUart_var.head = (chipUart_var.head + len) % MAX_BUFFER_SIZE; - } - - if (0 == chipUart_var.head) - { - len = aos_read(fd, chipUart_var.rxbuf, chipUart_var.tail - 1); - chipUart_var.head += len; - readlen += len; - } - } - else - { - readlen = aos_read(fd, chipUart_var.rxbuf + chipUart_var.head, chipUart_var.tail - chipUart_var.head - 1); - chipUart_var.head += readlen; - } - - if (chipUart_var.head != chipUart_var.tail) - { - xSemaphoreGiveFromISR(chipUart_var.sema, &xHigherPriorityTaskWoken); - } -} -#endif - -//bl_iot_sdk -#else -static int uartTxCallback(void * p_arg) -{ - - return 0; -} - -static int uartRxCallback(void * p_arg) -{ - uint32_t len = 0; - BaseType_t xHigherPriorityTaskWoken = 1; - - if (chipUart_var.head >= chipUart_var.tail) - { - if (chipUart_var.head < MAX_BUFFER_SIZE) - { - //len = hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf + chipUart_var.head, MAX_BUFFER_SIZE - chipUart_var.head); - chipUart_var.head = (chipUart_var.head + len) % MAX_BUFFER_SIZE; - } - - if (0 == chipUart_var.head) - { - //len = hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf, chipUart_var.tail - 1); - chipUart_var.head += len; - } - } - else - { - chipUart_var.head += - //hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf + chipUart_var.head, chipUart_var.tail - chipUart_var.head - 1); - } - - if (chipUart_var.head != chipUart_var.tail) - { - xSemaphoreGiveFromISR(chipUart_var.sema, &xHigherPriorityTaskWoken); - } - - return 0; -} - -void uartInit(void) -{ - memset(&chipUart_var, 0, offsetof(chipUart_t, rxbuf)); - - chipUart_var.sema = xSemaphoreCreateBinaryStatic(&chipUart_var.mutx); - -#ifndef CFG_USB_CDC_ENABLE - hosal_uart_finalize(&uart_stdio); - hosal_uart_init(&uart_stdio); - hosal_uart_callback_set(&uart_stdio, HOSAL_UART_RX_CALLBACK, uartRxCallback, NULL); - hosal_uart_callback_set(&uart_stdio, HOSAL_UART_TX_CALLBACK, uartTxCallback, NULL); - hosal_uart_ioctl(&uart_stdio, HOSAL_UART_MODE_SET, (void *) HOSAL_UART_MODE_INT); -#endif -} - -int16_t uartRead(char * Buf, uint16_t NbBytesToRead) -{ - int16_t len = 0; - - xSemaphoreTake(chipUart_var.sema, portMAX_DELAY); - - taskENTER_CRITICAL(); - - for (len = 0; len < NbBytesToRead && chipUart_var.head != chipUart_var.tail; len++) - { - Buf[len] = chipUart_var.rxbuf[chipUart_var.tail]; - chipUart_var.tail = (chipUart_var.tail + 1) % MAX_BUFFER_SIZE; - } - - taskEXIT_CRITICAL(); - - if (chipUart_var.head != chipUart_var.tail) - { - xSemaphoreGive(chipUart_var.sema); - } - - return len; -} -#endif - -#ifndef CFG_USB_CDC_ENABLE -int16_t uartWrite(const char * Buf, uint16_t BufLength) -{ - return hosal_uart_send(&uart_stdio, Buf, BufLength); -} -#else -int16_t uartWrite(const char * Buf, uint16_t BufLength) -{ - uint16_t sent = 0; - do - { - extern int vfs_fd; - if (vfs_fd >= 0) - { - sent += (uint8_t) aos_write(vfs_fd, Buf + sent, BufLength - sent); - } - } while (sent < BufLength); - return sent; -} -#endif +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may nCHIP use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include + +#ifdef CFG_USB_CDC_ENABLE +#include +#include +#include +#include +#include +#include +#include +#else +#include +#include +extern hosal_uart_dev_t uart_stdio; +#endif + +#if CONFIG_ENABLE_CHIP_SHELL || PW_RPC_ENABLED + +#define CHIP_UART_RX_TIMER_ID 1 +#define MAX_BUFFER_SIZE 256 + +typedef struct _chipUart +{ + SemaphoreHandle_t sema; + StaticSemaphore_t mutx; + uint32_t head; + uint32_t tail; + uint8_t rxbuf[MAX_BUFFER_SIZE]; +} chipUart_t; + +static chipUart_t chipUart_var; + +#ifndef CFG_USB_CDC_ENABLE +static int uartTxCallback(void * p_arg) +{ + hosal_uart_ioctl(&uart_stdio, HOSAL_UART_TX_TRIGGER_OFF, NULL); + + return 0; +} + +static int uartRxCallback(void * p_arg) +{ + uint32_t len = 0; + BaseType_t xHigherPriorityTaskWoken = 1; + + if (chipUart_var.head >= chipUart_var.tail) + { + if (chipUart_var.head < MAX_BUFFER_SIZE) + { + len = hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf + chipUart_var.head, MAX_BUFFER_SIZE - chipUart_var.head); + chipUart_var.head = (chipUart_var.head + len) % MAX_BUFFER_SIZE; + } + + if (0 == chipUart_var.head) + { + len = hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf, chipUart_var.tail - 1); + chipUart_var.head += len; + } + } + else + { + chipUart_var.head += + hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf + chipUart_var.head, chipUart_var.tail - chipUart_var.head - 1); + } + + if (chipUart_var.head != chipUart_var.tail) + { + xSemaphoreGiveFromISR(chipUart_var.sema, &xHigherPriorityTaskWoken); + } + + return 0; +} +#else +void aosUartRxCallback(int fd, void * param) +{ + uint32_t len = 0, readlen = 0; + BaseType_t xHigherPriorityTaskWoken = 1; + + if (chipUart_var.head >= chipUart_var.tail) + { + if (chipUart_var.head < MAX_BUFFER_SIZE) + { + readlen = len = aos_read(fd, chipUart_var.rxbuf + chipUart_var.head, MAX_BUFFER_SIZE - chipUart_var.head); + chipUart_var.head = (chipUart_var.head + len) % MAX_BUFFER_SIZE; + } + + if (0 == chipUart_var.head) + { + len = aos_read(fd, chipUart_var.rxbuf, chipUart_var.tail - 1); + chipUart_var.head += len; + readlen += len; + } + } + else + { + readlen = aos_read(fd, chipUart_var.rxbuf + chipUart_var.head, chipUart_var.tail - chipUart_var.head - 1); + chipUart_var.head += readlen; + } + + if (chipUart_var.head != chipUart_var.tail) + { + xSemaphoreGiveFromISR(chipUart_var.sema, &xHigherPriorityTaskWoken); + } +} +#endif + +// bl_iot_sdk +#else +static int uartTxCallback(void * p_arg) +{ + + return 0; +} + +static int uartRxCallback(void * p_arg) +{ + uint32_t len = 0; + BaseType_t xHigherPriorityTaskWoken = 1; + + if (chipUart_var.head >= chipUart_var.tail) + { + if (chipUart_var.head < MAX_BUFFER_SIZE) + { + // len = hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf + chipUart_var.head, MAX_BUFFER_SIZE - chipUart_var.head); + chipUart_var.head = (chipUart_var.head + len) % MAX_BUFFER_SIZE; + } + + if (0 == chipUart_var.head) + { + // len = hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf, chipUart_var.tail - 1); + chipUart_var.head += len; + } + } + else + { + chipUart_var.head += + // hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf + chipUart_var.head, chipUart_var.tail - chipUart_var.head - 1); + } + + if (chipUart_var.head != chipUart_var.tail) + { + xSemaphoreGiveFromISR(chipUart_var.sema, &xHigherPriorityTaskWoken); + } + + return 0; +} + +void uartInit(void) +{ + memset(&chipUart_var, 0, offsetof(chipUart_t, rxbuf)); + + chipUart_var.sema = xSemaphoreCreateBinaryStatic(&chipUart_var.mutx); + +#ifndef CFG_USB_CDC_ENABLE + hosal_uart_finalize(&uart_stdio); + hosal_uart_init(&uart_stdio); + hosal_uart_callback_set(&uart_stdio, HOSAL_UART_RX_CALLBACK, uartRxCallback, NULL); + hosal_uart_callback_set(&uart_stdio, HOSAL_UART_TX_CALLBACK, uartTxCallback, NULL); + hosal_uart_ioctl(&uart_stdio, HOSAL_UART_MODE_SET, (void *) HOSAL_UART_MODE_INT); +#endif +} + +int16_t uartRead(char * Buf, uint16_t NbBytesToRead) +{ + int16_t len = 0; + + xSemaphoreTake(chipUart_var.sema, portMAX_DELAY); + + taskENTER_CRITICAL(); + + for (len = 0; len < NbBytesToRead && chipUart_var.head != chipUart_var.tail; len++) + { + Buf[len] = chipUart_var.rxbuf[chipUart_var.tail]; + chipUart_var.tail = (chipUart_var.tail + 1) % MAX_BUFFER_SIZE; + } + + taskEXIT_CRITICAL(); + + if (chipUart_var.head != chipUart_var.tail) + { + xSemaphoreGive(chipUart_var.sema); + } + + return len; +} +#endif + +#ifndef CFG_USB_CDC_ENABLE +int16_t uartWrite(const char * Buf, uint16_t BufLength) +{ + return hosal_uart_send(&uart_stdio, Buf, BufLength); +} +#else +int16_t uartWrite(const char * Buf, uint16_t BufLength) +{ + uint16_t sent = 0; + do + { + extern int vfs_fd; + if (vfs_fd >= 0) + { + sent += (uint8_t) aos_write(vfs_fd, Buf + sent, BufLength - sent); + } + } while (sent < BufLength); + return sent; +} +#endif diff --git a/examples/platform/bouffalolab/common/bouffalo_sdk/uart.h b/examples/platform/bouffalolab/common/bouffalo_sdk/uart.h index ff2a398a395dd7..44d49ac24f60ff 100644 --- a/examples/platform/bouffalolab/common/bouffalo_sdk/uart.h +++ b/examples/platform/bouffalolab/common/bouffalo_sdk/uart.h @@ -1,37 +1,37 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -void uartInit(void); -int16_t uartWrite(const char * Buf, uint16_t BufLength); -int16_t uartRead(char * Buf, uint16_t NbBytesToRead); - -#ifdef CFG_USB_CDC_ENABLE -void aosUartRxCallback(int fd, void * param); -#endif - -#ifdef __cplusplus -} // extern "C" -#endif +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void uartInit(void); +int16_t uartWrite(const char * Buf, uint16_t BufLength); +int16_t uartRead(char * Buf, uint16_t NbBytesToRead); + +#ifdef CFG_USB_CDC_ENABLE +void aosUartRxCallback(int fd, void * param); +#endif + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/examples/platform/bouffalolab/common/iot_sdk/platform_port.cpp b/examples/platform/bouffalolab/common/iot_sdk/platform_port.cpp index 4b42359851c9fb..64f8965ff8528e 100644 --- a/examples/platform/bouffalolab/common/iot_sdk/platform_port.cpp +++ b/examples/platform/bouffalolab/common/iot_sdk/platform_port.cpp @@ -79,7 +79,6 @@ extern "C" unsigned int sleep(unsigned int seconds) return 0; } - extern "C" void vApplicationStackOverflowHook(TaskHandle_t xTask, char * pcTaskName) { printf("Stack Overflow checked. Stack name %s", pcTaskName); @@ -179,7 +178,8 @@ extern "C" void vAssertCalled(void) portABORT(); - while (true) ; + while (true) + ; } extern "C" void user_vAssertCalled(void) __attribute__((weak, alias("vAssertCalled"))); @@ -303,10 +303,12 @@ static void bl_show_component_version(void) { extern uint8_t _version_info_section_start; extern uint8_t _version_info_section_end; - char **version_str_p = NULL; + char ** version_str_p = NULL; puts("Version of used components:\r\n"); - for (version_str_p = (char **)&_version_info_section_start; version_str_p < (char **)&_version_info_section_end; version_str_p++) { + for (version_str_p = (char **) &_version_info_section_start; version_str_p < (char **) &_version_info_section_end; + version_str_p++) + { puts("\tVersion: "); puts(*version_str_p); puts("\r\n"); diff --git a/examples/platform/bouffalolab/common/plat/plat.h b/examples/platform/bouffalolab/common/plat/plat.h index 229d5be560f1eb..f0360ff19a70c5 100644 --- a/examples/platform/bouffalolab/common/plat/plat.h +++ b/examples/platform/bouffalolab/common/plat/plat.h @@ -23,7 +23,7 @@ #define EXT_DISCOVERY_TIMEOUT_SECS 20 -typedef void (*app_pds_gpio_irq_handler_t)(void *arg); +typedef void (*app_pds_gpio_irq_handler_t)(void * arg); #ifdef __cplusplus diff --git a/examples/platform/bouffalolab/common/route_hook/bl_route_hook.c b/examples/platform/bouffalolab/common/route_hook/bl_route_hook.c index 1f376f7adeaee0..f9f35ba8d5da26 100644 --- a/examples/platform/bouffalolab/common/route_hook/bl_route_hook.c +++ b/examples/platform/bouffalolab/common/route_hook/bl_route_hook.c @@ -194,7 +194,8 @@ int8_t bl_route_hook_init(void) hook->netif = lwip_netif; hook->pcb = raw_new_ip_type(IPADDR_TYPE_V6, IP6_NEXTH_ICMP6); - if (NULL == hook->pcb) { + if (NULL == hook->pcb) + { ret = -1; goto exit; } diff --git a/scripts/build/builders/bouffalolab.py b/scripts/build/builders/bouffalolab.py index 73ed5446447b02..384a84d59cd9c4 100644 --- a/scripts/build/builders/bouffalolab.py +++ b/scripts/build/builders/bouffalolab.py @@ -73,6 +73,7 @@ def GnArgName(self): else: raise Exception('Unknown board #: %r' % self) + class BouffalolabThreadType(Enum): NONE = auto() THREAD_FTD = auto() @@ -181,7 +182,7 @@ def __init__(self, self.argsOpt.append(f'chip_mdns="{chip_mdns}"') self.argsOpt.append(f'chip_inet_config_enable_ipv4={str(enable_ethernet or enable_wifi).lower()}') - + if enable_easyflash and enable_littlefs: raise Exception("Only one of easyflash and littlefs can be enabled.") if bouffalo_chip == "bl616": @@ -215,7 +216,7 @@ def __init__(self, else: self.argsOpt.append( 'openthread_root="//third_party/connectedhomeip/third_party/bouffalolab/bouffalo_sdk/components/wireless/thread/openthread"') - + if enable_cdc: if bouffalo_chip != "bl702": raise Exception(f'SoC {bouffalo_chip} does NOT support USB CDC') @@ -284,7 +285,7 @@ def PreBuildCommand(self): def PostBuildCommand(self): - bouffalo_sdk_chips = [ "bl616" ] + bouffalo_sdk_chips = ["bl616"] abs_path_fw = os.path.join(self.output_dir, self.app.AppNamePrefix(self.chip_name) + ".bin") if self.chip_name not in bouffalo_sdk_chips: diff --git a/scripts/flashing/bouffalolab_firmware_utils.py b/scripts/flashing/bouffalolab_firmware_utils.py index f0a140ac27ac71..e6ca898609102f 100755 --- a/scripts/flashing/bouffalolab_firmware_utils.py +++ b/scripts/flashing/bouffalolab_firmware_utils.py @@ -505,9 +505,9 @@ def exe_prog_cmd(flashtool_exe, mfd_addr): def bouffalo_sdk_prog(self): def int_to_lhex(intvalue): - lhex = ((intvalue & 0xff000000) >> 24) | ((intvalue & 0xff0000) >> 8) + lhex = ((intvalue & 0xff000000) >> 24) | ((intvalue & 0xff0000) >> 8) lhex |= ((intvalue & 0xff00) << 8) | ((intvalue & 0xff) << 24) - + return "%08x" % lhex def get_tools(): @@ -523,7 +523,7 @@ def get_tools(): flashtool_exe = os.path.join(bflb_tools, bflb_tools_dict[sys.platform]["flash_tool"]) except Exception: raise Exception("Do NOT support {} operating system to program firmware.".format(sys.platform)) - + if not os.path.exists(flashtool_exe) or not os.path.exists(fw_proc_exe): logging.fatal('*' * 80) logging.error("Expecting tools as below:") @@ -533,7 +533,7 @@ def get_tools(): return fw_proc_exe, flashtool_exe - def prog_config(configDir, output, isErase = False): + def prog_config(configDir, output, isErase=False): partition_file = self.find_file(configDir, r'^partition.+\.toml$') if len(partition_file) != 1: @@ -615,16 +615,17 @@ def exe_prog_cmd(flashtool_exe): flashtool_exe, "--chipname", self.args["chipname"], "--baudrate", str(self.args["baudrate"]), - "--config",self.args["config"] + "--config", self.args["config"] ] if self.args["sk"] or (self.args["key"] and self.args["iv"]): - prog_cmd += [ - "--efuse", os.path.join(self.work_dir, "efusedata.bin") + prog_cmd += [ + "--efuse", os.path.join(self.work_dir, "efusedata.bin") ] if self.args["port"]: - prog_config(os.path.join(self.work_dir, "config"), os.path.join(self.work_dir, "flash_prog_cfg.ini"), self.option.erase) + prog_config(os.path.join(self.work_dir, "config"), os.path.join( + self.work_dir, "flash_prog_cfg.ini"), self.option.erase) prog_cmd += [ "--port", self.args["port"], @@ -637,7 +638,7 @@ def exe_prog_cmd(flashtool_exe): if line: logging.info(line) - fw_proc_exe, flashtool_exe = get_tools() + fw_proc_exe, flashtool_exe = get_tools() os.chdir(self.work_dir) self.parse_mfd() diff --git a/src/lib/shell/BUILD.gn b/src/lib/shell/BUILD.gn index a0bd5b71ae682e..fed0dfa5b8bbcb 100644 --- a/src/lib/shell/BUILD.gn +++ b/src/lib/shell/BUILD.gn @@ -90,19 +90,11 @@ static_library("shell") { chip_device_platform == "bl702" || chip_device_platform == "bl702l" || chip_device_platform == "bl616") { - - sources += [ - "streamer_bouffalolab.cpp", - ] + sources += [ "streamer_bouffalolab.cpp" ] if (chip_device_platform == "bl616") { - sources += [ - "MainLoopBouffalolab.cpp", - ] - } - else { - sources += [ - "MainLoopDefault.cpp", - ] + sources += [ "MainLoopBouffalolab.cpp" ] + } else { + sources += [ "MainLoopDefault.cpp" ] } } else if (chip_device_platform == "cc13x4_26x4") { sources += [ diff --git a/src/lib/shell/MainLoopBouffalolab.cpp b/src/lib/shell/MainLoopBouffalolab.cpp index 2ad7f8928b6108..098f3809cc8c0c 100644 --- a/src/lib/shell/MainLoopBouffalolab.cpp +++ b/src/lib/shell/MainLoopBouffalolab.cpp @@ -40,4 +40,4 @@ void Engine::RunMainLoop() } } // namespace Shell -} // namespace chip \ No newline at end of file +} // namespace chip diff --git a/src/lib/shell/streamer_bouffalolab.cpp b/src/lib/shell/streamer_bouffalolab.cpp index 139708cecb2847..d7e168ead571eb 100644 --- a/src/lib/shell/streamer_bouffalolab.cpp +++ b/src/lib/shell/streamer_bouffalolab.cpp @@ -1,106 +1,106 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * Source implementation of an input / output stream for Bouffalo Lab targets. - */ - -#include -#include -#include - -#if !CHIP_DEVICE_LAYER_TARGET_BL616 -#include -#include -#include -#endif - -namespace chip { -namespace Shell { - -#if CHIP_DEVICE_LAYER_TARGET_BL616 -namespace { -int streamer_bouffalo_sdk_init(streamer_t * streamer) -{ - (void) streamer; - return 0; -} - -ssize_t streamer_bouffalo_sdk_read(streamer_t * streamer, char * buffer, size_t length) -{ - (void) (streamer); - return 0; -} - -ssize_t streamer_bouffalo_sdk_write(streamer_t * streamer, const char * buffer, size_t length) -{ - (void) (streamer); - - printf ("%s", buffer); - return 0; -} - -static streamer_t streamer_bouffalo_sdk = { - .init_cb = streamer_bouffalo_sdk_init, - .read_cb = streamer_bouffalo_sdk_read, - .write_cb = streamer_bouffalo_sdk_write, -}; -} // namespace - -streamer_t * streamer_get(void) -{ - return &streamer_bouffalo_sdk; -} - -#else - -namespace { - -int streamer_iot_sdk_init(streamer_t * streamer) -{ - (void) streamer; - return 0; -} - -ssize_t streamer_iot_sdk_read(streamer_t * streamer, char * buffer, size_t length) -{ - (void) streamer; - return (ssize_t) uartRead(buffer, (uint16_t) length); -} - -ssize_t streamer_iot_sdk_write(streamer_t * streamer, const char * buffer, size_t length) -{ - (void) streamer; - return uartWrite(buffer, (uint16_t) length); -} - -static streamer_t streamer_iot_sdk = { - .init_cb = streamer_iot_sdk_init, - .read_cb = streamer_iot_sdk_read, - .write_cb = streamer_iot_sdk_write, -}; - -} // namespace -streamer_t * streamer_get(void) -{ - return &streamer_iot_sdk; -} -#endif - -} // namespace Shell -} // namespace chip +/* + * + * Copyright (c) 2020 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * Source implementation of an input / output stream for Bouffalo Lab targets. + */ + +#include +#include +#include + +#if !CHIP_DEVICE_LAYER_TARGET_BL616 +#include +#include +#include +#endif + +namespace chip { +namespace Shell { + +#if CHIP_DEVICE_LAYER_TARGET_BL616 +namespace { +int streamer_bouffalo_sdk_init(streamer_t * streamer) +{ + (void) streamer; + return 0; +} + +ssize_t streamer_bouffalo_sdk_read(streamer_t * streamer, char * buffer, size_t length) +{ + (void) (streamer); + return 0; +} + +ssize_t streamer_bouffalo_sdk_write(streamer_t * streamer, const char * buffer, size_t length) +{ + (void) (streamer); + + printf("%s", buffer); + return 0; +} + +static streamer_t streamer_bouffalo_sdk = { + .init_cb = streamer_bouffalo_sdk_init, + .read_cb = streamer_bouffalo_sdk_read, + .write_cb = streamer_bouffalo_sdk_write, +}; +} // namespace + +streamer_t * streamer_get(void) +{ + return &streamer_bouffalo_sdk; +} + +#else + +namespace { + +int streamer_iot_sdk_init(streamer_t * streamer) +{ + (void) streamer; + return 0; +} + +ssize_t streamer_iot_sdk_read(streamer_t * streamer, char * buffer, size_t length) +{ + (void) streamer; + return (ssize_t) uartRead(buffer, (uint16_t) length); +} + +ssize_t streamer_iot_sdk_write(streamer_t * streamer, const char * buffer, size_t length) +{ + (void) streamer; + return uartWrite(buffer, (uint16_t) length); +} + +static streamer_t streamer_iot_sdk = { + .init_cb = streamer_iot_sdk_init, + .read_cb = streamer_iot_sdk_read, + .write_cb = streamer_iot_sdk_write, +}; + +} // namespace +streamer_t * streamer_get(void) +{ + return &streamer_iot_sdk; +} +#endif + +} // namespace Shell +} // namespace chip diff --git a/src/lwip/BUILD.gn b/src/lwip/BUILD.gn index 8a1a1f7288698c..0bffafeb5afc5a 100644 --- a/src/lwip/BUILD.gn +++ b/src/lwip/BUILD.gn @@ -32,10 +32,10 @@ assert(lwip_platform == "external" || lwip_platform == "standalone" || lwip_platform == "nxp" || lwip_platform == "silabs" || lwip_platform == "qpg" || lwip_platform == "mbed" || lwip_platform == "psoc6" || lwip_platform == "cyw30739" || - lwip_platform == "mw320" || - lwip_platform == "bl602" || lwip_platform == "bl616" || - lwip_platform == "bl702" || lwip_platform == "bl702l" || - lwip_platform == "mt793x" || lwip_platform == "asr", + lwip_platform == "mw320" || lwip_platform == "bl602" || + lwip_platform == "bl616" || lwip_platform == "bl702" || + lwip_platform == "bl702l" || lwip_platform == "mt793x" || + lwip_platform == "asr", "Unsupported lwIP platform: ${lwip_platform}") if (lwip_platform != "external") { @@ -158,7 +158,6 @@ if (current_os == "zephyr" || current_os == "mbed") { } } else if (lwip_platform == "bl616" && defined(chip_enable_openthread) && chip_enable_openthread == false) { - group("lwip") { public_deps = [ ":lwip_buildconfig" ] public_deps += [ "${bouffalolab_iot_sdk_build_root}/bl616:bouffalo_sdk" ] diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index b78a87e9cffd5f..bc7f10f430e661 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -256,8 +256,7 @@ if (chip_device_platform != "none" && chip_device_platform != "external") { "CHIP_DEVICE_LAYER_TARGET=bouffalolab/common", "CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}", ] - } - else if (chip_device_platform == "bl702") { + } else if (chip_device_platform == "bl702") { device_layer_target_define = "BL702" defines += [ "CHIP_DEVICE_LAYER_TARGET=bouffalolab/common", diff --git a/src/platform/bouffalolab/BL616/BUILD.gn b/src/platform/bouffalolab/BL616/BUILD.gn index 20289c08903913..f77216b48b68f8 100644 --- a/src/platform/bouffalolab/BL616/BUILD.gn +++ b/src/platform/bouffalolab/BL616/BUILD.gn @@ -42,9 +42,7 @@ static_library("BL616") { ] if (chip_enable_ota_requestor) { - sources += [ - "../common/OTAImageProcessorImpl_bflb.cpp", - ] + sources += [ "../common/OTAImageProcessorImpl_bflb.cpp" ] } if (chip_enable_ble) { @@ -62,17 +60,16 @@ static_library("BL616") { } if (bouffalo_sdk_component_easyflash_enabled) { - sources += [ "../common/BLConfig.cpp"] - } - else { - sources += [ "../common/BLConfig_littlefs.cpp"] + sources += [ "../common/BLConfig.cpp" ] + } else { + sources += [ "../common/BLConfig_littlefs.cpp" ] } - + deps = [ "${chip_root}/src/credentials:credentials_header", "${chip_root}/src/platform/logging:headers", ] - + if (chip_enable_wifi) { sources += [ "ConfigurationManagerImpl.cpp", diff --git a/src/platform/bouffalolab/BL616/CHIPMem-Platform.cpp b/src/platform/bouffalolab/BL616/CHIPMem-Platform.cpp index 34e336d8a6d7c9..0e04b79a1cbfe6 100644 --- a/src/platform/bouffalolab/BL616/CHIPMem-Platform.cpp +++ b/src/platform/bouffalolab/BL616/CHIPMem-Platform.cpp @@ -54,9 +54,7 @@ CHIP_ERROR MemoryAllocatorInit(void * buf, size_t bufSize) return CHIP_NO_ERROR; } -void MemoryAllocatorShutdown() -{ -} +void MemoryAllocatorShutdown() {} void * MemoryAlloc(size_t size) { diff --git a/src/platform/bouffalolab/BL616/DiagnosticDataProviderImpl.cpp b/src/platform/bouffalolab/BL616/DiagnosticDataProviderImpl.cpp index da2a282fc87f06..f62ae3762183ab 100644 --- a/src/platform/bouffalolab/BL616/DiagnosticDataProviderImpl.cpp +++ b/src/platform/bouffalolab/BL616/DiagnosticDataProviderImpl.cpp @@ -82,7 +82,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiRssi(int8_t & rssi) if (ConnectivityMgrImpl()._IsWiFiStationConnected()) { wifi_mgmr_sta_rssi_get(&tmp_rssi); - rssi = (int8_t)tmp_rssi; + rssi = (int8_t) tmp_rssi; return CHIP_NO_ERROR; } diff --git a/src/platform/bouffalolab/BL616/NetworkCommissioningDriver.cpp b/src/platform/bouffalolab/BL616/NetworkCommissioningDriver.cpp index ebd7ffe5fa6723..dc5c22dcd0f1b0 100644 --- a/src/platform/bouffalolab/BL616/NetworkCommissioningDriver.cpp +++ b/src/platform/bouffalolab/BL616/NetworkCommissioningDriver.cpp @@ -17,8 +17,8 @@ #include #include -#include #include +#include #include #include extern "C" { @@ -134,23 +134,24 @@ Status BLWiFiDriver::ReorderNetwork(ByteSpan networkId, uint8_t index, MutableCh CHIP_ERROR BLWiFiDriver::ConnectWiFiNetwork(const char * ssid, uint8_t ssidLen, const char * key, uint8_t keyLen) { - wifi_mgmr_sta_connect_params_t conn_param = {0}; + wifi_mgmr_sta_connect_params_t conn_param = { 0 }; ConnectivityMgrImpl().ChangeWiFiStationState(ConnectivityManager::kWiFiStationState_Connecting); - strncpy((char *)conn_param.ssid, ssid, ssidLen); + strncpy((char *) conn_param.ssid, ssid, ssidLen); conn_param.ssid_len = ssidLen; - if (keyLen) { - strncpy((char *)conn_param.key, key, keyLen); + if (keyLen) + { + strncpy((char *) conn_param.key, key, keyLen); conn_param.key_len = keyLen; } - conn_param.freq1 = 0; - conn_param.freq2 = 0; - conn_param.use_dhcp = 1; - conn_param.pmf_cfg = 1; + conn_param.freq1 = 0; + conn_param.freq2 = 0; + conn_param.use_dhcp = 1; + conn_param.pmf_cfg = 1; conn_param.quick_connect = 1; - conn_param.timeout_ms = -1; + conn_param.timeout_ms = -1; wifi_mgmr_sta_connect(&conn_param); @@ -184,7 +185,7 @@ void BLWiFiDriver::ConnectNetwork(ByteSpan networkId, ConnectCallback * callback networkId.data()); err = ConnectWiFiNetwork(reinterpret_cast(mStagingNetwork.ssid), mStagingNetwork.ssidLen, - reinterpret_cast(mStagingNetwork.credentials), mStagingNetwork.credentialsLen); + reinterpret_cast(mStagingNetwork.credentials), mStagingNetwork.credentialsLen); mpConnectCallback = callback; exit: @@ -209,7 +210,8 @@ void BLWiFiDriver::ScanNetworks(ByteSpan ssid, WiFiDriver::ScanCallback * callba { mpScanCallback = callback; } - else { + else + { callback->OnFinished(Status::kUnknownError, CharSpan(), nullptr); } } @@ -218,14 +220,17 @@ void BLWiFiDriver::ScanNetworks(ByteSpan ssid, WiFiDriver::ScanCallback * callba void BLWiFiDriver::OnScanWiFiNetworkDone() { uint32_t nums = wifi_mgmr_sta_scanlist_nums_get(); - if (nums) { - wifi_mgmr_scan_item_t * pScanList = (wifi_mgmr_scan_item_t*)MemoryAlloc(nums * sizeof(wifi_mgmr_scan_item_t)); + if (nums) + { + wifi_mgmr_scan_item_t * pScanList = (wifi_mgmr_scan_item_t *) MemoryAlloc(nums * sizeof(wifi_mgmr_scan_item_t)); - if (NULL == pScanList || 0 == wifi_mgmr_sta_scanlist_dump(pScanList, nums)) { + if (NULL == pScanList || 0 == wifi_mgmr_sta_scanlist_dump(pScanList, nums)) + { mpScanCallback->OnFinished(Status::kUnknownError, CharSpan(), nullptr); mpScanCallback = nullptr; } - else { + else + { if (CHIP_NO_ERROR == DeviceLayer::SystemLayer().ScheduleLambda([nums, pScanList]() { BLScanResponseIterator iter(nums, pScanList); @@ -244,7 +249,8 @@ void BLWiFiDriver::OnScanWiFiNetworkDone() } } } - else { + else + { ChipLogProgress(DeviceLayer, "No AP found"); if (mpScanCallback != nullptr) { @@ -259,7 +265,8 @@ CHIP_ERROR GetConfiguredNetwork(Network & network) wifi_mgmr_connect_ind_stat_info_t statInfo; memset(&statInfo, 0, sizeof(wifi_mgmr_connect_ind_stat_info_t)); - if (0 == wifi_mgmr_sta_connect_ind_stat_get(&statInfo)) { + if (0 == wifi_mgmr_sta_connect_ind_stat_get(&statInfo)) + { memcpy(network.networkID, statInfo.ssid, strlen(statInfo.ssid)); network.networkIDLen = strlen(statInfo.ssid); return CHIP_NO_ERROR; @@ -283,7 +290,8 @@ void BLWiFiDriver::OnNetworkStatusChange() mpStatusChangeCallback->OnNetworkingStatusChange( Status::kSuccess, MakeOptional(ByteSpan(configuredNetwork.networkID, configuredNetwork.networkIDLen)), NullOptional); } - else { + else + { mpStatusChangeCallback->OnNetworkingStatusChange( Status::kUnknownError, MakeOptional(ByteSpan(configuredNetwork.networkID, configuredNetwork.networkIDLen)), MakeOptional(GetLastDisconnectReason())); @@ -333,11 +341,13 @@ bool BLWiFiDriver::WiFiNetworkIterator::Next(Network & item) void NetworkEventHandler(const ChipDeviceEvent * event, intptr_t arg) { - if (!(DeviceEventType::IsPlatformSpecific(event->Type) && DeviceEventType::IsPublic(event->Type))) { + if (!(DeviceEventType::IsPlatformSpecific(event->Type) && DeviceEventType::IsPublic(event->Type))) + { return; } - switch (event->Type) { + switch (event->Type) + { case kWiFiOnInitDone: break; case kWiFiOnScanDone: @@ -380,62 +390,68 @@ extern "C" void wifi_event_handler(uint32_t code) memset(&event, 0, sizeof(ChipDeviceEvent)); - switch (code) { - case CODE_WIFI_ON_INIT_DONE: - wifi_mgmr_init(&conf); - break; - case CODE_WIFI_ON_MGMR_DONE: - wifi_mgmr_sta_autoconnect_enable(); - break; - case CODE_WIFI_ON_SCAN_DONE: - event.Type = kWiFiOnScanDone; - PlatformMgr().PostEventOrDie(&event); - break; - case CODE_WIFI_ON_CONNECTING: - event.Type = kWiFiOnConnecting; - PlatformMgr().PostEventOrDie(&event); - break; - case CODE_WIFI_ON_CONNECTED: - event.Type = kWiFiOnConnected; - PlatformMgr().PostEventOrDie(&event); - break; - case CODE_WIFI_ON_GOT_IP: - event.Type = kGotIpAddress; - PlatformMgr().PostEventOrDie(&event); - break; - case CODE_WIFI_ON_DISCONNECT: - event.Type = kWiFiOnDisconnected; - PlatformMgr().PostEventOrDie(&event); - break; - default: { - ChipLogProgress(DeviceLayer, "[APP] [EVT] Unknown code %lu \r\n", code); - } + switch (code) + { + case CODE_WIFI_ON_INIT_DONE: + wifi_mgmr_init(&conf); + break; + case CODE_WIFI_ON_MGMR_DONE: + wifi_mgmr_sta_autoconnect_enable(); + break; + case CODE_WIFI_ON_SCAN_DONE: + event.Type = kWiFiOnScanDone; + PlatformMgr().PostEventOrDie(&event); + break; + case CODE_WIFI_ON_CONNECTING: + event.Type = kWiFiOnConnecting; + PlatformMgr().PostEventOrDie(&event); + break; + case CODE_WIFI_ON_CONNECTED: + event.Type = kWiFiOnConnected; + PlatformMgr().PostEventOrDie(&event); + break; + case CODE_WIFI_ON_GOT_IP: + event.Type = kGotIpAddress; + PlatformMgr().PostEventOrDie(&event); + break; + case CODE_WIFI_ON_DISCONNECT: + event.Type = kWiFiOnDisconnected; + PlatformMgr().PostEventOrDie(&event); + break; + default: { + ChipLogProgress(DeviceLayer, "[APP] [EVT] Unknown code %lu \r\n", code); + } } } -extern "C" void network_netif_ext_callback(struct netif* nif, netif_nsc_reason_t reason, const netif_ext_callback_args_t* args) +extern "C" void network_netif_ext_callback(struct netif * nif, netif_nsc_reason_t reason, const netif_ext_callback_args_t * args) { ChipDeviceEvent event; memset(&event, 0, sizeof(ChipDeviceEvent)); - if (((LWIP_NSC_IPV6_ADDR_STATE_CHANGED | LWIP_NSC_IPV6_SET) & reason) && args) { + if (((LWIP_NSC_IPV6_ADDR_STATE_CHANGED | LWIP_NSC_IPV6_SET) & reason) && args) + { - if (args->ipv6_addr_state_changed.addr_index >= LWIP_IPV6_NUM_ADDRESSES || - ip6_addr_islinklocal(netif_ip6_addr(nif, args->ipv6_addr_state_changed.addr_index))) { + if (args->ipv6_addr_state_changed.addr_index >= LWIP_IPV6_NUM_ADDRESSES || + ip6_addr_islinklocal(netif_ip6_addr(nif, args->ipv6_addr_state_changed.addr_index))) + { return; } if (netif_ip6_addr_state(nif, args->ipv6_addr_state_changed.addr_index) != args->ipv6_addr_state_changed.old_state && - ip6_addr_ispreferred(netif_ip6_addr_state(nif, args->ipv6_addr_state_changed.addr_index))) { - event.Type = kGotIpv6Address; + ip6_addr_ispreferred(netif_ip6_addr_state(nif, args->ipv6_addr_state_changed.addr_index))) + { + event.Type = kGotIpv6Address; PlatformMgr().PostEventOrDie(&event); } } - if ((LWIP_NSC_IPV4_SETTINGS_CHANGED & reason) && args) { - if (!ip4_addr_isany(netif_ip4_addr(nif)) && !ip4_addr_isany(netif_ip4_gw(nif))) { - event.Type = kGotIpAddress; + if ((LWIP_NSC_IPV4_SETTINGS_CHANGED & reason) && args) + { + if (!ip4_addr_isany(netif_ip4_addr(nif)) && !ip4_addr_isany(netif_ip4_gw(nif))) + { + event.Type = kGotIpAddress; PlatformMgr().PostEventOrDie(&event); } } @@ -444,4 +460,4 @@ extern "C" void network_netif_ext_callback(struct netif* nif, netif_nsc_reason_t } // namespace NetworkCommissioning } // namespace DeviceLayer } // namespace chip -//#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI +// #endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI diff --git a/src/platform/bouffalolab/BL616/NetworkCommissioningDriver.h b/src/platform/bouffalolab/BL616/NetworkCommissioningDriver.h index e28c2ddfe61569..5a8cc7a1096d03 100644 --- a/src/platform/bouffalolab/BL616/NetworkCommissioningDriver.h +++ b/src/platform/bouffalolab/BL616/NetworkCommissioningDriver.h @@ -38,7 +38,8 @@ constexpr uint8_t kWiFiConnectNetworkTimeoutSeconds = 20; class BLScanResponseIterator : public Iterator { public: - BLScanResponseIterator(const size_t size, const wifi_mgmr_scan_item_t * scanResults) : mSize(size), mpScanResults(scanResults) {} + BLScanResponseIterator(const size_t size, const wifi_mgmr_scan_item_t * scanResults) : mSize(size), mpScanResults(scanResults) + {} size_t Count() override { return mSize; } bool Next(WiFiScanResponse & item) override { @@ -48,9 +49,9 @@ class BLScanResponseIterator : public Iterator } item.security.SetRaw(mpScanResults[mIternum].auth); - item.ssidLen = (uint32_t)(mpScanResults[mIternum].ssid_len) < chip::DeviceLayer::Internal::kMaxWiFiSSIDLength - ? mpScanResults[mIternum].ssid_len - : chip::DeviceLayer::Internal::kMaxWiFiSSIDLength; + item.ssidLen = (uint32_t) (mpScanResults[mIternum].ssid_len) < chip::DeviceLayer::Internal::kMaxWiFiSSIDLength + ? mpScanResults[mIternum].ssid_len + : chip::DeviceLayer::Internal::kMaxWiFiSSIDLength; item.channel = mpScanResults[mIternum].channel; item.wiFiBand = chip::DeviceLayer::NetworkCommissioning::WiFiBand::k2g4; item.rssi = mpScanResults[mIternum].rssi; @@ -142,9 +143,8 @@ class BLWiFiDriver final : public WiFiDriver int32_t mLastDisconnectedReason; }; - } // namespace NetworkCommissioning } // namespace DeviceLayer } // namespace chip -#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI \ No newline at end of file +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI diff --git a/src/platform/bouffalolab/BL616/PlatformManagerImpl.cpp b/src/platform/bouffalolab/BL616/PlatformManagerImpl.cpp index 23489ef7f30a5f..4ed9920cfd843d 100644 --- a/src/platform/bouffalolab/BL616/PlatformManagerImpl.cpp +++ b/src/platform/bouffalolab/BL616/PlatformManagerImpl.cpp @@ -16,12 +16,12 @@ * limitations under the License. */ -#include #include #include +#include -#include #include +#include #include #include #include @@ -39,11 +39,11 @@ #include #endif -#include #include +#include extern "C" { -#include #include +#include } namespace chip { @@ -58,7 +58,7 @@ static int app_entropy_source(void * data, unsigned char * output, size_t len, s CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) { - CHIP_ERROR err = CHIP_NO_ERROR; + CHIP_ERROR err = CHIP_NO_ERROR; TaskHandle_t backup_eventLoopTask; int iret_rfInit = -1; @@ -73,13 +73,13 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) #if CHIP_DEVICE_CONFIG_ENABLE_WIFI wifi_start_firmware_task(); #endif - + #if CHIP_DEVICE_CONFIG_ENABLE_THREAD otRadio_opt_t opt; #if CHIP_DEVICE_CONFIG_THREAD_FTD - opt.bf.isFtd = true; + opt.bf.isFtd = true; #else - opt.bf.isFtd = false; + opt.bf.isFtd = false; #endif opt.bf.isCoexEnable = true; diff --git a/src/platform/bouffalolab/BL616/ThreadStackManagerImpl.cpp b/src/platform/bouffalolab/BL616/ThreadStackManagerImpl.cpp index 4efad008a1eadc..251ccf5113a294 100644 --- a/src/platform/bouffalolab/BL616/ThreadStackManagerImpl.cpp +++ b/src/platform/bouffalolab/BL616/ThreadStackManagerImpl.cpp @@ -101,12 +101,12 @@ extern "C" otInstance * otrGetInstance() return ThreadStackMgrImpl().OTInstance(); } -extern "C" void otrLock(void) +extern "C" void otrLock(void) { ThreadStackMgrImpl().LockThreadStack(); } -extern "C" void otrUnlock(void) +extern "C" void otrUnlock(void) { ThreadStackMgrImpl().UnlockThreadStack(); } diff --git a/src/platform/bouffalolab/BL616/bl616-chip-mbedtls-config.h b/src/platform/bouffalolab/BL616/bl616-chip-mbedtls-config.h index f5f4dd83b97737..32eeb078fbe236 100644 --- a/src/platform/bouffalolab/BL616/bl616-chip-mbedtls-config.h +++ b/src/platform/bouffalolab/BL616/bl616-chip-mbedtls-config.h @@ -38,7 +38,7 @@ * Enable FreeRTOS threading support */ #define MBEDTLS_FREERTOS -//#define MBEDTLS_THREADING_C +// #define MBEDTLS_THREADING_C /** * Enable H Crypto and Entropy modules @@ -61,7 +61,6 @@ typedef void mbedtls_ecp_restart_ctx; #define MBEDTLS_PLATFORM_MEMORY - #define MBEDTLS_CIPHER_PADDING_PKCS7 #define MBEDTLS_CIPHER_PADDING_ZEROS #define MBEDTLS_REMOVE_ARC4_CIPHERSUITES @@ -89,7 +88,7 @@ typedef void mbedtls_ecp_restart_ctx; #define MBEDTLS_ERROR_C #define MBEDTLS_GCM_C -#define MBEDTLS_ERROR_STRERROR_DUMMY +#define MBEDTLS_ERROR_STRERROR_DUMMY #define MBEDTLS_HAVE_ASM #define MBEDTLS_HKDF_C #define MBEDTLS_HMAC_DRBG_C diff --git a/src/platform/bouffalolab/BL616/bl616-openthread-core-bl-config.h b/src/platform/bouffalolab/BL616/bl616-openthread-core-bl-config.h index 12977f87d7486e..8c4c5f3807a7d0 100644 --- a/src/platform/bouffalolab/BL616/bl616-openthread-core-bl-config.h +++ b/src/platform/bouffalolab/BL616/bl616-openthread-core-bl-config.h @@ -31,15 +31,15 @@ #define OPENTHREAD_CONFIG_PLATFORM_INFO "BL616" -//#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG +// #define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG -#if ! defined (OPENTHREAD_FTD) && ! defined (OPENTHREAD_MTD) +#if !defined(OPENTHREAD_FTD) && !defined(OPENTHREAD_MTD) #if CHIP_DEVICE_CONFIG_THREAD_FTD -#define OPENTHREAD_FTD 1 -#define OPENTHREAD_MTD 0 +#define OPENTHREAD_FTD 1 +#define OPENTHREAD_MTD 0 #else -#define OPENTHREAD_FTD 0 -#define OPENTHREAD_MTD 1 +#define OPENTHREAD_FTD 0 +#define OPENTHREAD_MTD 1 #endif #endif diff --git a/src/platform/bouffalolab/BL616/wifi_mgmr_portable.c b/src/platform/bouffalolab/BL616/wifi_mgmr_portable.c index e54621f6eac30b..bf22cb51abccc3 100644 --- a/src/platform/bouffalolab/BL616/wifi_mgmr_portable.c +++ b/src/platform/bouffalolab/BL616/wifi_mgmr_portable.c @@ -11,7 +11,7 @@ #include -#define WIFI_STACK_SIZE (1536) +#define WIFI_STACK_SIZE (1536) #define TASK_PRIORITY_FW (16) static TaskHandle_t wifi_fw_task; @@ -20,18 +20,19 @@ static netif_ext_callback_t netifExtCallback; struct netif * deviceInterface_getNetif(void) { LOCK_TCPIP_CORE(); - struct netif *net_if = netif_find("wl1"); + struct netif * net_if = netif_find("wl1"); UNLOCK_TCPIP_CORE(); return net_if; } -int wifi_start_scan(const uint8_t * ssid, uint32_t length) +int wifi_start_scan(const uint8_t * ssid, uint32_t length) { wifi_mgmr_scan_params_t config; memset(&config, 0, sizeof(wifi_mgmr_scan_params_t)); - if (length && length <= MGMR_SSID_LEN) { + if (length && length <= MGMR_SSID_LEN) + { memcpy(config.ssid_array, ssid, length); config.ssid_length = length; } @@ -47,12 +48,12 @@ void wifi_start_firmware_task(void) GLB_AHB_MCU_Software_Reset(GLB_AHB_MCU_SW_WIFI); extern void interrupt0_handler(void); - bflb_irq_attach(WIFI_IRQn, (irq_callback)interrupt0_handler, NULL); + bflb_irq_attach(WIFI_IRQn, (irq_callback) interrupt0_handler, NULL); bflb_irq_enable(WIFI_IRQn); LOCK_TCPIP_CORE(); netif_add_ext_callback(&netifExtCallback, network_netif_ext_callback); UNLOCK_TCPIP_CORE(); - xTaskCreate(wifi_main, (char *)"fw", WIFI_STACK_SIZE, NULL, TASK_PRIORITY_FW, &wifi_fw_task); + xTaskCreate(wifi_main, (char *) "fw", WIFI_STACK_SIZE, NULL, TASK_PRIORITY_FW, &wifi_fw_task); } diff --git a/src/platform/bouffalolab/BL616/wifi_mgmr_portable.h b/src/platform/bouffalolab/BL616/wifi_mgmr_portable.h index faf61325a50df0..9ebffffa20e422 100644 --- a/src/platform/bouffalolab/BL616/wifi_mgmr_portable.h +++ b/src/platform/bouffalolab/BL616/wifi_mgmr_portable.h @@ -6,7 +6,7 @@ extern "C" { #endif int wifi_start_scan(const uint8_t * ssid, uint32_t length); -void network_netif_ext_callback(struct netif* netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t* args); +void network_netif_ext_callback(struct netif * netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t * args); void wifi_start_firmware_task(void); struct netif * deviceInterface_getNetif(void); diff --git a/src/platform/bouffalolab/BL702L/PlatformManagerImpl.cpp b/src/platform/bouffalolab/BL702L/PlatformManagerImpl.cpp index 64373fb25ee813..2cd84609ef0505 100644 --- a/src/platform/bouffalolab/BL702L/PlatformManagerImpl.cpp +++ b/src/platform/bouffalolab/BL702L/PlatformManagerImpl.cpp @@ -57,17 +57,17 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) TaskHandle_t backup_eventLoopTask; otRadio_opt_t opt; - opt.byte = 0; + opt.byte = 0; #if CHIP_DEVICE_CONFIG_ENABLE_THREAD #if CHIP_DEVICE_CONFIG_THREAD_FTD - opt.bf.isFtd = true; + opt.bf.isFtd = true; #else - opt.bf.isFtd = false; + opt.bf.isFtd = false; #endif opt.bf.isCoexEnable = true; #endif - + ot_utils_init(); ot_alarmInit(); diff --git a/src/platform/bouffalolab/common/BLConfig_littlefs.cpp b/src/platform/bouffalolab/common/BLConfig_littlefs.cpp index 536c3cb7e04f4e..7f5e221195e8d3 100644 --- a/src/platform/bouffalolab/common/BLConfig_littlefs.cpp +++ b/src/platform/bouffalolab/common/BLConfig_littlefs.cpp @@ -37,20 +37,20 @@ namespace DeviceLayer { namespace Internal { #if CHIP_DEVICE_LAYER_TARGET_BL616 - static struct lfs_context lfs_ctx = { .partition_name = (char *)"PSM" }; - static struct lfs_config lfs_cfg = { .read_size = 256, - .prog_size = 256, - .block_size = 4096, - .block_cycles = 500, - .cache_size = 512, - .lookahead_size = 256, - }; - static lfs_t * blconfig_lfs = NULL; +static struct lfs_context lfs_ctx = { .partition_name = (char *) "PSM" }; +static struct lfs_config lfs_cfg = { + .read_size = 256, + .prog_size = 256, + .block_size = 4096, + .block_cycles = 500, + .cache_size = 512, + .lookahead_size = 256, +}; +static lfs_t * blconfig_lfs = NULL; #else - static lfs_t * blconfig_lfs = nullptr; +static lfs_t * blconfig_lfs = nullptr; #endif - static inline char * blcfg_convert_key(const char * pKey, const char * pNameSpace = NULL) { int len_key = 0, len_namespace = 0; diff --git a/src/platform/bouffalolab/common/BLEManagerImpl.cpp b/src/platform/bouffalolab/common/BLEManagerImpl.cpp index c90077cb3fddac..c5a3932e83cc1f 100644 --- a/src/platform/bouffalolab/common/BLEManagerImpl.cpp +++ b/src/platform/bouffalolab/common/BLEManagerImpl.cpp @@ -841,7 +841,8 @@ ssize_t BLEManagerImpl::HandleC3Read(struct bt_conn * conId, const struct bt_gat } #endif -extern "C" int ble_connection_number(void) { +extern "C" int ble_connection_number(void) +{ return BLEMgr().NumConnections(); } } // namespace Internal diff --git a/src/platform/bouffalolab/common/DiagnosticDataProviderImpl.cpp b/src/platform/bouffalolab/common/DiagnosticDataProviderImpl.cpp index 9149e2320c8e6d..a5d70240ba5a04 100644 --- a/src/platform/bouffalolab/common/DiagnosticDataProviderImpl.cpp +++ b/src/platform/bouffalolab/common/DiagnosticDataProviderImpl.cpp @@ -51,7 +51,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapFree(uint64_t & currentHeap #ifdef CFG_USE_PSRAM currentHeapFree = xPortGetFreeHeapSize() + xPortGetFreeHeapSizePsram(); #else - currentHeapFree = xPortGetFreeHeapSize(); + currentHeapFree = xPortGetFreeHeapSize(); #endif #endif @@ -68,7 +68,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapUsed(uint64_t & currentHeap #ifdef CFG_USE_PSRAM currentHeapUsed = (get_heap_size() + get_heap3_size() - xPortGetFreeHeapSize() - xPortGetFreeHeapSizePsram()); #else - currentHeapUsed = (get_heap_size() - xPortGetFreeHeapSize()); + currentHeapUsed = (get_heap_size() - xPortGetFreeHeapSize()); #endif #endif @@ -249,7 +249,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** #if CHIP_DEVICE_CONFIG_ENABLE_WIFI ifp->type = app::Clusters::GeneralDiagnostics::InterfaceTypeEnum::kWiFi; #else - ifp->type = app::Clusters::GeneralDiagnostics::InterfaceTypeEnum::kEthernet; + ifp->type = app::Clusters::GeneralDiagnostics::InterfaceTypeEnum::kEthernet; #endif ifp->offPremiseServicesReachableIPv4.SetNull(); ifp->offPremiseServicesReachableIPv6.SetNull(); diff --git a/src/platform/bouffalolab/common/FactoryDataProvider.cpp b/src/platform/bouffalolab/common/FactoryDataProvider.cpp index 8fde7d498115f0..0785b5be88ab9a 100644 --- a/src/platform/bouffalolab/common/FactoryDataProvider.cpp +++ b/src/platform/bouffalolab/common/FactoryDataProvider.cpp @@ -19,8 +19,8 @@ #include -#include #include "FactoryDataProvider.h" +#include namespace chip { namespace DeviceLayer { diff --git a/src/platform/bouffalolab/common/Logging.cpp b/src/platform/bouffalolab/common/Logging.cpp index edfdb62fec287e..1ee0128d97cd62 100644 --- a/src/platform/bouffalolab/common/Logging.cpp +++ b/src/platform/bouffalolab/common/Logging.cpp @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include -#include #include #include +#include +#include #include #include diff --git a/src/platform/bouffalolab/common/OTAImageProcessorImpl.cpp b/src/platform/bouffalolab/common/OTAImageProcessorImpl.cpp index ab139fe14a219c..d55b2a26d10af4 100644 --- a/src/platform/bouffalolab/common/OTAImageProcessorImpl.cpp +++ b/src/platform/bouffalolab/common/OTAImageProcessorImpl.cpp @@ -20,8 +20,8 @@ extern "C" { #if CHIP_DEVICE_LAYER_TARGET_BL616 -#include #include +#include #else #include #include @@ -259,7 +259,7 @@ void OTAImageProcessorImpl::HandleProcessBlock(intptr_t context) (uint8_t *) block.data(), block.size()) < 0) #else if (hosal_ota_update(imageProcessor->mParams.totalFileBytes, imageProcessor->mParams.downloadedBytes, - (uint8_t *) block.data(), block.size()) < 0) + (uint8_t *) block.data(), block.size()) < 0) #endif { imageProcessor->mDownloader->EndDownload(CHIP_ERROR_WRITE_FAILED); diff --git a/src/platform/bouffalolab/common/OTAImageProcessorImpl.h b/src/platform/bouffalolab/common/OTAImageProcessorImpl.h index d58ca90c1abc68..2e0656affacf03 100644 --- a/src/platform/bouffalolab/common/OTAImageProcessorImpl.h +++ b/src/platform/bouffalolab/common/OTAImageProcessorImpl.h @@ -25,11 +25,12 @@ namespace chip { #if CHIP_DEVICE_LAYER_TARGET_BL616 -typedef struct _ota_header_s { +typedef struct _ota_header_s +{ uint8_t header[16]; - uint8_t type[4]; //RAW XZ - uint32_t image_len; //body len + uint8_t type[4]; // RAW XZ + uint32_t image_len; // body len uint8_t pad0[8]; uint8_t ver_hardware[16]; @@ -38,8 +39,10 @@ typedef struct _ota_header_s { uint8_t sha256[32]; } ota_header_s_t; -typedef struct _ota_header { - union { +typedef struct _ota_header +{ + union + { ota_header_s_t s; uint8_t _pad[512]; } u; diff --git a/src/platform/bouffalolab/common/OTAImageProcessorImpl_bflb.cpp b/src/platform/bouffalolab/common/OTAImageProcessorImpl_bflb.cpp index 271b02d300a482..0e0a6ff0ccd14d 100644 --- a/src/platform/bouffalolab/common/OTAImageProcessorImpl_bflb.cpp +++ b/src/platform/bouffalolab/common/OTAImageProcessorImpl_bflb.cpp @@ -15,37 +15,40 @@ * limitations under the License. */ +#include "OTAImageProcessorImpl.h" #include #include -#include "OTAImageProcessorImpl.h" extern "C" { -#include #include +#include } using namespace chip::System; namespace chip { -#define OTA_IMAGE_TYPE_XZ "XZ" -#define OTA_IMAGE_TYPE_RAW "RAW" +#define OTA_IMAGE_TYPE_XZ "XZ" +#define OTA_IMAGE_TYPE_RAW "RAW" -static bool check_ota_header(ota_header_s_t *ota_header_s) +static bool check_ota_header(ota_header_s_t * ota_header_s) { - char str[sizeof(ota_header_s->header) + 1]; + char str[sizeof(ota_header_s->header) + 1]; memcpy(str, ota_header_s->header, sizeof(ota_header_s->header)); str[sizeof(ota_header_s->header)] = '\0'; ChipLogProgress(SoftwareUpdate, "Bouffalo Lab OTA header: %s", str); - if (0 == memcmp(OTA_IMAGE_TYPE_XZ, ota_header_s->type, strlen(OTA_IMAGE_TYPE_XZ))) { + if (0 == memcmp(OTA_IMAGE_TYPE_XZ, ota_header_s->type, strlen(OTA_IMAGE_TYPE_XZ))) + { ChipLogProgress(SoftwareUpdate, "Bouffalo Lab OTA image type: %s", OTA_IMAGE_TYPE_XZ); } - else if (0 == memcmp(OTA_IMAGE_TYPE_RAW, ota_header_s->type, strlen(OTA_IMAGE_TYPE_RAW))) { + else if (0 == memcmp(OTA_IMAGE_TYPE_RAW, ota_header_s->type, strlen(OTA_IMAGE_TYPE_RAW))) + { ChipLogProgress(SoftwareUpdate, "Bouffalo Lab OTA image type: %s", OTA_IMAGE_TYPE_RAW); } - else { + else + { return false; } @@ -140,7 +143,6 @@ void OTAImageProcessorImpl::HandlePrepareDownload(intptr_t context) { auto * imageProcessor = reinterpret_cast(context); - if (imageProcessor == nullptr) { ChipLogError(SoftwareUpdate, "ImageProcessor context is null"); @@ -171,11 +173,11 @@ void OTAImageProcessorImpl::HandleFinalize(intptr_t context) return; } - ByteSpan block = imageProcessor->mBlock; if (bflb_ota_update(imageProcessor->mImageTotalSize, imageProcessor->mParams.downloadedBytes - sizeof(ota_header_t), - imageProcessor->mOtaHdr.sha256, sizeof(imageProcessor->mOtaHdr.sha256)) < 0) { + imageProcessor->mOtaHdr.sha256, sizeof(imageProcessor->mOtaHdr.sha256)) < 0) + { imageProcessor->mDownloader->EndDownload(CHIP_ERROR_WRITE_FAILED); return; } @@ -269,23 +271,28 @@ void OTAImageProcessorImpl::HandleProcessBlock(intptr_t context) if (imageProcessor->mParams.totalFileBytes) { - if (0 == imageProcessor->mImageTotalSize) { + if (0 == imageProcessor->mImageTotalSize) + { iSize = sizeof(ota_header_s_t) - imageProcessor->mParams.downloadedBytes; - if (block.size() < iSize) { + if (block.size() < iSize) + { iSize = block.size(); } - memcpy(reinterpret_cast(&imageProcessor->mOtaHdr) + imageProcessor->mParams.downloadedBytes, - block.data(), iSize); + memcpy(reinterpret_cast(&imageProcessor->mOtaHdr) + imageProcessor->mParams.downloadedBytes, block.data(), + iSize); - if (imageProcessor->mParams.downloadedBytes + iSize >= sizeof(ota_header_s_t)) { - if (!check_ota_header(&imageProcessor->mOtaHdr)) { + if (imageProcessor->mParams.downloadedBytes + iSize >= sizeof(ota_header_s_t)) + { + if (!check_ota_header(&imageProcessor->mOtaHdr)) + { imageProcessor->mDownloader->EndDownload(CHIP_ERROR_DECODE_FAILED); return; } - if (bflb_ota_start(imageProcessor->mOtaHdr.image_len + sizeof(imageProcessor->mOtaHdr.sha256)) < 0) { + if (bflb_ota_start(imageProcessor->mOtaHdr.image_len + sizeof(imageProcessor->mOtaHdr.sha256)) < 0) + { imageProcessor->mDownloader->EndDownload(CHIP_ERROR_OPEN_FAILED); return; } @@ -294,20 +301,23 @@ void OTAImageProcessorImpl::HandleProcessBlock(intptr_t context) } } - if (imageProcessor->mImageTotalSize && - imageProcessor->mParams.downloadedBytes + block.size() > sizeof(ota_header_t)) { + if (imageProcessor->mImageTotalSize && imageProcessor->mParams.downloadedBytes + block.size() > sizeof(ota_header_t)) + { - if (imageProcessor->mParams.downloadedBytes >= sizeof(ota_header_t)) { + if (imageProcessor->mParams.downloadedBytes >= sizeof(ota_header_t)) + { iOffset = imageProcessor->mParams.downloadedBytes - sizeof(ota_header_t); - iSize = 0; + iSize = 0; } - else { + else + { iOffset = 0; - iSize = sizeof(ota_header_t) - imageProcessor->mParams.downloadedBytes; + iSize = sizeof(ota_header_t) - imageProcessor->mParams.downloadedBytes; } - if (bflb_ota_update(imageProcessor->mImageTotalSize, iOffset, - const_cast(block.data() + iSize), block.size() - iSize) < 0) { + if (bflb_ota_update(imageProcessor->mImageTotalSize, iOffset, const_cast(block.data() + iSize), + block.size() - iSize) < 0) + { imageProcessor->mDownloader->EndDownload(CHIP_ERROR_WRITE_FAILED); return; } diff --git a/src/platform/bouffalolab/common/SystemTimeSupport.cpp b/src/platform/bouffalolab/common/SystemTimeSupport.cpp index 7d046a7e1c52ee..89a9756ca23fde 100644 --- a/src/platform/bouffalolab/common/SystemTimeSupport.cpp +++ b/src/platform/bouffalolab/common/SystemTimeSupport.cpp @@ -35,7 +35,6 @@ namespace Internal { ClockImpl gClockImpl; } // namespace Internal - static Microseconds64 gBootRealTime = Seconds64::zero(); Microseconds64 ClockImpl::GetMonotonicMicroseconds64(void) diff --git a/src/platform/bouffalolab/common/SystemTimeSupport.h b/src/platform/bouffalolab/common/SystemTimeSupport.h old mode 100755 new mode 100644 index 78c1dd66d80743..7ef95ab66c67cd --- a/src/platform/bouffalolab/common/SystemTimeSupport.h +++ b/src/platform/bouffalolab/common/SystemTimeSupport.h @@ -19,8 +19,6 @@ namespace chip { namespace System { -namespace Clock { - -} // namespace Clock +namespace Clock {} // namespace Clock } // namespace System } // namespace chip diff --git a/src/platform/device.gni b/src/platform/device.gni index 266aa84e6e5e26..a28d9823a91438 100644 --- a/src/platform/device.gni +++ b/src/platform/device.gni @@ -267,8 +267,8 @@ assert( chip_device_platform == "ameba" || chip_device_platform == "cyw30739" || chip_device_platform == "webos" || chip_device_platform == "mw320" || chip_device_platform == "zephyr" || chip_device_platform == "beken" || - chip_device_platform == "bl602" || chip_device_platform == "bl616" || - chip_device_platform == "bl702" || chip_device_platform == "bl702l" || + chip_device_platform == "bl602" || chip_device_platform == "bl616" || + chip_device_platform == "bl702" || chip_device_platform == "bl702l" || chip_device_platform == "mt793x" || chip_device_platform == "SiWx917" || chip_device_platform == "openiotsdk" || chip_device_platform == "asr" || chip_device_platform == "stm32" || chip_device_platform == "nuttx", diff --git a/src/system/BUILD.gn b/src/system/BUILD.gn index 280cad16e20071..3fff2a61e648da 100644 --- a/src/system/BUILD.gn +++ b/src/system/BUILD.gn @@ -200,8 +200,10 @@ source_set("system_config_header") { public_deps += [ "${bouffalolab_iot_sdk_build_root}/bl702l:bl_iot_sdk" ] } if (chip_device_platform == "bl616") { - public_deps += [ "${bouffalolab_iot_sdk_build_root}/bl616:bouffalo_sdk" ] + public_deps += + [ "${bouffalolab_iot_sdk_build_root}/bl616:bouffalo_sdk" ] } + # Add platform here as needed. } } diff --git a/third_party/bouffalolab/bl602/bl_iot_sdk.gni b/third_party/bouffalolab/bl602/bl_iot_sdk.gni index cfcc06754acc93..ba564db1469bec 100644 --- a/third_party/bouffalolab/bl602/bl_iot_sdk.gni +++ b/third_party/bouffalolab/bl602/bl_iot_sdk.gni @@ -197,16 +197,15 @@ template("bl_iot_sdk") { } source_set("${sdk_target_name}_hosal") { - defines = [ - "CONF_BL602_USE_1M_FLASH=0", - ] + defines = [ "CONF_BL602_USE_1M_FLASH=0" ] if (defined(invoker.chip_config_network_layer_ble) && invoker.chip_config_network_layer_ble) { defines += [ "CFG_BLE_ENABLE" ] } - if (defined(invoker.enable_debug_coredump) && invoker.enable_debug_coredump) { + if (defined(invoker.enable_debug_coredump) && + invoker.enable_debug_coredump) { defines += [ "SYS_ENABLE_COREDUMP" ] } @@ -365,15 +364,14 @@ template("bl_iot_sdk") { include_dirs += [ "${bl_iot_sdk_root}/components/stage/littlefs/port" ] } - if (defined(invoker.enable_debug_coredump) && invoker.enable_debug_coredump) { + if (defined(invoker.enable_debug_coredump) && + invoker.enable_debug_coredump) { include_dirs += [ "${bl_iot_sdk_root}/components/stage/coredump/inc" ] } } source_set("${sdk_target_name}_stage") { - defines = [ - "RHINO_CONFIG_WORKQUEUE=0", - ] + defines = [ "RHINO_CONFIG_WORKQUEUE=0" ] sources = [ "${bl_iot_sdk_root}/components/stage/blfdt/src/fdt.c", @@ -393,9 +391,11 @@ template("bl_iot_sdk") { "${bl_iot_sdk_root}/components/stage/yloop/src/yloop.c", ] - if (defined(invoker.enable_debug_coredump) && invoker.enable_debug_coredump) { + if (defined(invoker.enable_debug_coredump) && + invoker.enable_debug_coredump) { defines += [ "BFLB_COREDUMP_BINARY_ID=${invoker.coredump_binary_id}" ] - sources += [ "${bl_iot_sdk_root}/components/stage/coredump/bl_coredump.c" ] + sources += + [ "${bl_iot_sdk_root}/components/stage/coredump/bl_coredump.c" ] } cflags_c = [ "-Wno-sign-compare" ] @@ -406,12 +406,11 @@ template("bl_iot_sdk") { ":${sdk_target_name}_config_fs", ":${sdk_target_name}_config_sys", ":${sdk_target_name}_config_utils", - ":${sdk_target_name}_config_hosal" + ":${sdk_target_name}_config_hosal", ] if (defined(invoker.bouffalo_sdk_component_easyflash_enabled) && invoker.bouffalo_sdk_component_easyflash_enabled) { - defines += [ "EF_ENV_CACHE_TABLE_SIZE=64" ] sources += [ "${bl_iot_sdk_root}/components/stage/easyflash4/src/easyflash.c", diff --git a/third_party/bouffalolab/bl616/bouffalo_sdk.gni b/third_party/bouffalolab/bl616/bouffalo_sdk.gni index 1e2db05d4e5153..174b04b8160ae2 100644 --- a/third_party/bouffalolab/bl616/bouffalo_sdk.gni +++ b/third_party/bouffalolab/bl616/bouffalo_sdk.gni @@ -43,7 +43,6 @@ template("bouffalo_sdk") { sdk_target_name = target_name config("${sdk_target_name}_config") { - defines = [ "BL616=BL616", "ARCH_RISCV", @@ -61,12 +60,13 @@ template("bouffalo_sdk") { cflags_c = [ "-fno-jump-tables", "-fstrict-volatile-bitfields", - "-fshort-enums", - "-Wno-unused-but-set-variable" + "-fshort-enums", + "-Wno-unused-but-set-variable", ] cflags = [ - "-Wno-conversion", "-fstack-usage" + "-Wno-conversion", + "-fstack-usage", ] if (defined(invoker.defines)) { @@ -75,9 +75,7 @@ template("bouffalo_sdk") { } config("${sdk_target_name}_config_startup") { - include_dirs = [ - "${bouffalo_sdk_root}/drivers/soc/bl616/std/startup", - ] + include_dirs = [ "${bouffalo_sdk_root}/drivers/soc/bl616/std/startup" ] } source_set("${sdk_target_name}_startup") { @@ -87,21 +85,20 @@ template("bouffalo_sdk") { "CONFIG_IRQ_NUM=80", ] - if (defined(invoker.enable_debug_coredump) && invoker.enable_debug_coredump) { + if (defined(invoker.enable_debug_coredump) && + invoker.enable_debug_coredump) { defines += [ "CONFIG_COREDUMP" ] } - include_dirs = [ - "${bouffalo_sdk_root}/drivers/soc/bl616/std/startup", - ] + include_dirs = [ "${bouffalo_sdk_root}/drivers/soc/bl616/std/startup" ] sources = [ - "${bouffalo_sdk_root}/drivers/soc/bl616/std/startup/start.S", - "${bouffalo_sdk_root}/drivers/soc/bl616/std/startup/vector.S", - "${bouffalo_sdk_root}/drivers/soc/bl616/std/startup/riscv_fpu.S", "${bouffalo_sdk_root}/drivers/soc/bl616/std/startup/interrupt.c", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/startup/riscv_fpu.S", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/startup/start.S", "${bouffalo_sdk_root}/drivers/soc/bl616/std/startup/start_load.c", "${bouffalo_sdk_root}/drivers/soc/bl616/std/startup/system_bl616.c", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/startup/vector.S", ] configs += [ @@ -110,7 +107,7 @@ template("bouffalo_sdk") { ":${sdk_target_name}_config_lhal", ":${sdk_target_name}_config_utils", ] - + public_configs = [ ":${sdk_target_name}_config", ":${sdk_target_name}_config_startup", @@ -128,7 +125,7 @@ template("bouffalo_sdk") { "BFLB_USE_HAL_DRIVER", ] - cflags = ["-Wsign-compare"] + cflags = [ "-Wsign-compare" ] } source_set("${sdk_target_name}_std_drv") { @@ -151,24 +148,24 @@ template("bouffalo_sdk") { sources += [ #use rom api default - "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_romapi_e907.c", - "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_romapi_patch.c", "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_clock.c", "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_common.c", "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_ef_cfg.c", - "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_sdh.c", - "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_tzc_sec.c", - "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_psram.c", - "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_pm.c", "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_mfg_efuse.c", "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_mfg_flash.c", "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_mfg_media.c", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_pm.c", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_psram.c", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_romapi_e907.c", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_romapi_patch.c", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_sdh.c", + "${bouffalo_sdk_root}/drivers/soc/bl616/std/src/bl616_tzc_sec.c", ] cflags_c = [ "-Wno-sign-compare", "-Wno-enum-conversion", - "-Wno-type-limits" + "-Wno-type-limits", ] configs += [ @@ -183,7 +180,6 @@ template("bouffalo_sdk") { } config("${sdk_target_name}_config_lhal") { - include_dirs = [ #bl616 lhal "${bouffalo_sdk_root}/drivers/lhal/include", @@ -206,17 +202,35 @@ template("bouffalo_sdk") { #bl616 lhal "${bouffalo_sdk_root}/drivers/lhal/include", ] - + sources = [ - "${bouffalo_sdk_root}/drivers/lhal/src/bflb_common.c", - "${bouffalo_sdk_root}/drivers/lhal/src/bflb_adc.c", + "${bouffalo_sdk_root}/drivers/lhal/config/bl616/device_table.c", + "${bouffalo_sdk_root}/drivers/lhal/include/arch/risc-v/t-head/rv_hart.c", + "${bouffalo_sdk_root}/drivers/lhal/include/arch/risc-v/t-head/rv_pmp.c", "${bouffalo_sdk_root}/drivers/lhal/src/bflb_acomp.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_adc.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_auadc.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_audac.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_cam.c", "${bouffalo_sdk_root}/drivers/lhal/src/bflb_cks.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_common.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_dac.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_dbi.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_dma.c", "${bouffalo_sdk_root}/drivers/lhal/src/bflb_ef_ctrl.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_emac.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_flash.c", "${bouffalo_sdk_root}/drivers/lhal/src/bflb_gpio.c", "${bouffalo_sdk_root}/drivers/lhal/src/bflb_i2c.c", - "${bouffalo_sdk_root}/drivers/lhal/src/bflb_dma.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_i2s.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_ir.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_irq.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_l1c.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_mjpeg.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_mtimer.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_pwm_v2.c", "${bouffalo_sdk_root}/drivers/lhal/src/bflb_rtc.c", + "${bouffalo_sdk_root}/drivers/lhal/src/bflb_sdio2.c", "${bouffalo_sdk_root}/drivers/lhal/src/bflb_sec_aes.c", "${bouffalo_sdk_root}/drivers/lhal/src/bflb_sec_sha.c", "${bouffalo_sdk_root}/drivers/lhal/src/bflb_sec_trng.c", @@ -224,33 +238,13 @@ template("bouffalo_sdk") { "${bouffalo_sdk_root}/drivers/lhal/src/bflb_timer.c", "${bouffalo_sdk_root}/drivers/lhal/src/bflb_uart.c", "${bouffalo_sdk_root}/drivers/lhal/src/bflb_wdg.c", - "${bouffalo_sdk_root}/drivers/lhal/src/bflb_flash.c", "${bouffalo_sdk_root}/drivers/lhal/src/flash/bflb_sf_cfg.c", - "${bouffalo_sdk_root}/drivers/lhal/src/flash/bflb_xip_sflash.c", - "${bouffalo_sdk_root}/drivers/lhal/src/flash/bflb_sflash.c", "${bouffalo_sdk_root}/drivers/lhal/src/flash/bflb_sf_ctrl.c", - "${bouffalo_sdk_root}/drivers/lhal/src/bflb_dac.c", - "${bouffalo_sdk_root}/drivers/lhal/src/bflb_emac.c", - "${bouffalo_sdk_root}/drivers/lhal/src/bflb_ir.c", - "${bouffalo_sdk_root}/drivers/lhal/src/bflb_mjpeg.c", - "${bouffalo_sdk_root}/drivers/lhal/src/bflb_pwm_v2.c", - "${bouffalo_sdk_root}/drivers/lhal/src/bflb_cam.c", - "${bouffalo_sdk_root}/drivers/lhal/src/bflb_i2s.c", - "${bouffalo_sdk_root}/drivers/lhal/src/bflb_sdio2.c", - "${bouffalo_sdk_root}/drivers/lhal/src/bflb_dbi.c", - "${bouffalo_sdk_root}/drivers/lhal/src/bflb_audac.c", - "${bouffalo_sdk_root}/drivers/lhal/src/bflb_auadc.c", - "${bouffalo_sdk_root}/drivers/lhal/src/bflb_irq.c", - "${bouffalo_sdk_root}/drivers/lhal/src/bflb_l1c.c", - "${bouffalo_sdk_root}/drivers/lhal/src/bflb_mtimer.c", - "${bouffalo_sdk_root}/drivers/lhal/include/arch/risc-v/t-head/rv_hart.c", - "${bouffalo_sdk_root}/drivers/lhal/include/arch/risc-v/t-head/rv_pmp.c", - "${bouffalo_sdk_root}/drivers/lhal/config/bl616/device_table.c", + "${bouffalo_sdk_root}/drivers/lhal/src/flash/bflb_sflash.c", + "${bouffalo_sdk_root}/drivers/lhal/src/flash/bflb_xip_sflash.c", ] - libs = [ - "${bouffalo_sdk_root}/drivers/lhal/src/pka/libpka.a", - ] + libs = [ "${bouffalo_sdk_root}/drivers/lhal/src/pka/libpka.a" ] cflags_c = [ "-Wno-shadow", @@ -293,7 +287,7 @@ template("bouffalo_sdk") { "-Wno-shadow", "-Wno-format", "-Wno-format-nonliteral", - "-Wno-format-security" + "-Wno-format-security", ] configs += [ @@ -307,21 +301,17 @@ template("bouffalo_sdk") { } config("${sdk_target_name}_config_board") { - include_dirs = [ - "${bouffalo_sdk_root}/bsp/board", - ] + include_dirs = [ "${bouffalo_sdk_root}/bsp/board" ] } source_set("${sdk_target_name}_board") { defines = [ "CONFIG_MBEDTLS", "CONFIG_BFLOG", - "BL616" + "BL616", ] - include_dirs = [ - "${bouffalo_sdk_root}/bsp/board/bl616dk", - ] + include_dirs = [ "${bouffalo_sdk_root}/bsp/board/bl616dk" ] sources = [ "${bouffalo_sdk_root}/bsp/board/bl616dk/board.c", @@ -334,7 +324,7 @@ template("bouffalo_sdk") { "-Wno-enum-conversion", "-Wno-format", "-Wno-format-nonliteral", - "-Wno-format-security" + "-Wno-format-security", ] configs += [ @@ -346,21 +336,15 @@ template("bouffalo_sdk") { ":${sdk_target_name}_config_rf", ] - public_configs = [ - ":${sdk_target_name}_config_board", - ] + public_configs = [ ":${sdk_target_name}_config_board" ] } config("${sdk_target_name}_config_shell") { - include_dirs = [ - "${bouffalo_sdk_root}/components/shell", - ] + include_dirs = [ "${bouffalo_sdk_root}/components/shell" ] } source_set("${sdk_target_name}_shell") { - include_dirs = [ - "${bouffalo_sdk_root}/bsp/board/bl616dk", - ] + include_dirs = [ "${bouffalo_sdk_root}/bsp/board/bl616dk" ] sources = [ "${bouffalo_sdk_root}/components/shell/shell.c", @@ -373,7 +357,7 @@ template("bouffalo_sdk") { "-Wno-format-security", "-Wno-format-truncation", "-Wno-format-nonliteral", - "-Wno-sign-compare" + "-Wno-sign-compare", ] configs += [ @@ -384,9 +368,7 @@ template("bouffalo_sdk") { ":${sdk_target_name}_config_freertos", ":${sdk_target_name}_config_mm", ] - public_configs = [ - ":${sdk_target_name}_config_shell", - ] + public_configs = [ ":${sdk_target_name}_config_shell" ] } config("${sdk_target_name}_config_rf") { @@ -395,32 +377,24 @@ template("bouffalo_sdk") { "${bouffalo_sdk_root}/drivers/rfparam/Inc", ] - defines = [ - "WL_BL616=1" - ] + defines = [ "WL_BL616=1" ] } source_set("${sdk_target_name}_rf") { - defines = [ - "RFPARAM_BL616", - ] + defines = [ "RFPARAM_BL616" ] - include_dirs = [ - "${bouffalo_sdk_root}/drivers/rfparam/Inc", - ] + include_dirs = [ "${bouffalo_sdk_root}/drivers/rfparam/Inc" ] sources = [ "${bouffalo_sdk_root}/drivers/rfparam/Src/rfparam_adapter.c", "${bouffalo_sdk_root}/drivers/rfparam/Src/rfparam_rftlv.c", ] - libs = [ - "${bouffalo_sdk_root}/drivers/soc/bl616/phyrf/lib-gcc_10.2.0-toolchain_V2.6.1/libbl616_phyrf.a", - ] + libs = [ "${bouffalo_sdk_root}/drivers/soc/bl616/phyrf/lib-gcc_10.2.0-toolchain_V2.6.1/libbl616_phyrf.a" ] cflags_c = [ "-Wno-shadow", - "-Wno-sign-compare" + "-Wno-sign-compare", ] configs += [ @@ -435,10 +409,7 @@ template("bouffalo_sdk") { } source_set("${sdk_target_name}_libc") { - - include_dirs = [ - "${bouffalo_sdk_root}/components/libc", - ] + include_dirs = [ "${bouffalo_sdk_root}/components/libc" ] sources = [ "${bouffalo_sdk_root}/components/libc/newlib/port_init_fini.c", @@ -486,12 +457,12 @@ template("bouffalo_sdk") { "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_strtok.c", "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_strtokr.c", "${bouffalo_sdk_root}/components/libc/nuttx/libc/string/lib_vikmemcpy.c", - "${bouffalo_sdk_root}/components/libc/vsnprintf.c", + "${bouffalo_sdk_root}/components/libc/printf.c", "${bouffalo_sdk_root}/components/libc/snprintf.c", "${bouffalo_sdk_root}/components/libc/sprintf.c", - "${bouffalo_sdk_root}/components/libc/vsprintf.c", - "${bouffalo_sdk_root}/components/libc/printf.c", "${bouffalo_sdk_root}/components/libc/stdatomic.c", + "${bouffalo_sdk_root}/components/libc/vsnprintf.c", + "${bouffalo_sdk_root}/components/libc/vsprintf.c", ] cflags = [ @@ -504,13 +475,10 @@ template("bouffalo_sdk") { ":${sdk_target_name}_config_mm", ":${sdk_target_name}_config_lhal", ] - public_configs = [ - ":${sdk_target_name}_config", - ] + public_configs = [ ":${sdk_target_name}_config" ] } config("${sdk_target_name}_config_freertos") { - defines = [ "CONFIG_FREERTOS", "configSTACK_ALLOCATION_FROM_SEPARATE_HEAP=1", @@ -520,6 +488,7 @@ template("bouffalo_sdk") { "${bouffalo_sdk_root}/components/os/freertos/include", "${bouffalo_sdk_root}/components/os/freertos/portable/GCC/RISC-V/common", "${bouffalo_sdk_root}/components/os/freertos/portable/GCC/RISC-V/common/chip_specific_extensions/RV32I_CLINT_no_extensions", + #"${bouffalo_sdk_root}/components/os/freertos/posix/include", "${chip_root}/examples/platform/bouffalolab/bl616", ] @@ -529,6 +498,7 @@ template("bouffalo_sdk") { defines = [ "portasmHANDLE_INTERRUPT=interrupt_entry", "default_interrupt_handler=freertos_risc_v_trap_handler", + #"CONFIG_POSIX", ] @@ -542,14 +512,14 @@ template("bouffalo_sdk") { sources = [ "${bouffalo_sdk_root}/components/os/freertos/croutine.c", "${bouffalo_sdk_root}/components/os/freertos/event_groups.c", + "${bouffalo_sdk_root}/components/os/freertos/freertos_port.c", "${bouffalo_sdk_root}/components/os/freertos/list.c", + "${bouffalo_sdk_root}/components/os/freertos/portable/GCC/RISC-V/common/port.c", + "${bouffalo_sdk_root}/components/os/freertos/portable/GCC/RISC-V/common/portASM.S", + "${bouffalo_sdk_root}/components/os/freertos/portable/MemMang/heap_3.c", "${bouffalo_sdk_root}/components/os/freertos/queue.c", "${bouffalo_sdk_root}/components/os/freertos/tasks.c", "${bouffalo_sdk_root}/components/os/freertos/timers.c", - "${bouffalo_sdk_root}/components/os/freertos/freertos_port.c", - "${bouffalo_sdk_root}/components/os/freertos/portable/MemMang/heap_3.c", - "${bouffalo_sdk_root}/components/os/freertos/portable/GCC/RISC-V/common/port.c", - "${bouffalo_sdk_root}/components/os/freertos/portable/GCC/RISC-V/common/portASM.S", ] public_configs = [ @@ -579,15 +549,15 @@ template("bouffalo_sdk") { sources = [ "${bouffalo_sdk_root}/components/mm/mem.c", - "${bouffalo_sdk_root}/components/mm/tlsf/tlsf.c", "${bouffalo_sdk_root}/components/mm/tlsf/bflb_tlsf.c", + "${bouffalo_sdk_root}/components/mm/tlsf/tlsf.c", ] - cflags_c = [ + cflags_c = [ "-Wno-sign-compare", "-Wno-format", "-Wno-format-nonliteral", - "-Wno-format-security" + "-Wno-format-security", ] configs += [ @@ -602,35 +572,29 @@ template("bouffalo_sdk") { } config("${sdk_target_name}_config_easyflash4") { - include_dirs = [ - "${bouffalo_sdk_root}/components/easyflash4/inc", - ] + include_dirs = [ "${bouffalo_sdk_root}/components/easyflash4/inc" ] } source_set("${sdk_target_name}_easyflash4") { defines = [ "CONFIG_EASYFLASH4", "BL616", - "EF_ENV_CACHE_TABLE_SIZE=100" + "EF_ENV_CACHE_TABLE_SIZE=100", ] - include_dirs = [ - "${bouffalo_sdk_root}/components/easyflash4/inc", - ] + include_dirs = [ "${bouffalo_sdk_root}/components/easyflash4/inc" ] sources = [ "${bouffalo_sdk_root}/components/easyflash4/src/easyflash.c", + "${bouffalo_sdk_root}/components/easyflash4/src/easyflash_cli.c", "${bouffalo_sdk_root}/components/easyflash4/src/ef_env.c", - "${bouffalo_sdk_root}/components/easyflash4/src/ef_env_legacy_wl.c", "${bouffalo_sdk_root}/components/easyflash4/src/ef_env_legacy.c", + "${bouffalo_sdk_root}/components/easyflash4/src/ef_env_legacy_wl.c", "${bouffalo_sdk_root}/components/easyflash4/src/ef_port.c", "${bouffalo_sdk_root}/components/easyflash4/src/ef_utils.c", - "${bouffalo_sdk_root}/components/easyflash4/src/easyflash_cli.c", ] - cflags_c = [ - "-Wno-sign-compare", - ] + cflags_c = [ "-Wno-sign-compare" ] configs += [ ":${sdk_target_name}_config_lhal", @@ -638,9 +602,7 @@ template("bouffalo_sdk") { ":${sdk_target_name}_config_utils", ] - public_configs = [ - ":${sdk_target_name}_config_easyflash4", - ] + public_configs = [ ":${sdk_target_name}_config_easyflash4" ] } config("${sdk_target_name}_config_littlefs") { @@ -665,8 +627,8 @@ template("bouffalo_sdk") { sources = [ "${bouffalo_sdk_root}/components/fs/littlefs/easyflash_port/lfs_easyflash.c", - "${bouffalo_sdk_root}/components/fs/littlefs/littlefs/lfs_util.c", "${bouffalo_sdk_root}/components/fs/littlefs/littlefs/lfs.c", + "${bouffalo_sdk_root}/components/fs/littlefs/littlefs/lfs_util.c", "${bouffalo_sdk_root}/components/fs/littlefs/port/lfs_xip_flash.c", ] @@ -675,7 +637,7 @@ template("bouffalo_sdk") { "-Wno-format", "-Wno-format-nonliteral", "-Wno-format-security", - "-Wno-shadow" + "-Wno-shadow", ] configs += [ @@ -718,35 +680,36 @@ template("bouffalo_sdk") { "CONFIG_BFLOG_DEBUG", ] - if (defined(invoker.enable_debug_coredump) && invoker.enable_debug_coredump) { + if (defined(invoker.enable_debug_coredump) && + invoker.enable_debug_coredump) { defines += [ "CONFIG_COREDUMP" ] } sources = [ - "${bouffalo_sdk_root}/components/utils/log/log.c", - "${bouffalo_sdk_root}/components/utils/log/bflog/bflog.c", - "${bouffalo_sdk_root}/components/utils/log/log_freertos.c", - "${bouffalo_sdk_root}/components/utils/bflb_mtd/bflb_mtd.c", "${bouffalo_sdk_root}/components/utils/bflb_mtd/bflb_boot2.c", + "${bouffalo_sdk_root}/components/utils/bflb_mtd/bflb_mtd.c", "${bouffalo_sdk_root}/components/utils/bflb_ota/bflb_ota.c", "${bouffalo_sdk_root}/components/utils/bflb_ota/utils_sha256.c", "${bouffalo_sdk_root}/components/utils/getopt/utils_getopt.c", - "${bouffalo_sdk_root}/components/utils/partition/partition.c", - "${bouffalo_sdk_root}/components/utils/ring_buffer/ring_buffer.c", + "${bouffalo_sdk_root}/components/utils/log/bflog/bflog.c", + "${bouffalo_sdk_root}/components/utils/log/log.c", + "${bouffalo_sdk_root}/components/utils/log/log_freertos.c", "${bouffalo_sdk_root}/components/utils/math/src/utils_base64.c", "${bouffalo_sdk_root}/components/utils/math/src/utils_crc.c", "${bouffalo_sdk_root}/components/utils/math/src/utils_hex.c", + "${bouffalo_sdk_root}/components/utils/partition/partition.c", + "${bouffalo_sdk_root}/components/utils/ring_buffer/ring_buffer.c", ] - if (defined(invoker.enable_debug_coredump) && invoker.enable_debug_coredump) { + if (defined(invoker.enable_debug_coredump) && + invoker.enable_debug_coredump) { if (bouffalo_sdk_coredump_version == 1) { sources += [ "${bouffalo_sdk_root}/components/utils/coredump/bin_fmt_v1.c", "${bouffalo_sdk_root}/components/utils/coredump/coredump.c", "${bouffalo_sdk_root}/components/utils/coredump/encoder_v1.c", ] - } - else if (bouffalo_sdk_coredump_version == 2) { + } else if (bouffalo_sdk_coredump_version == 2) { sources += [ "${bouffalo_sdk_root}/components/utils/coredump/bin_fmt_v2.c", "${bouffalo_sdk_root}/components/utils/coredump/coredump.c", @@ -762,7 +725,7 @@ template("bouffalo_sdk") { "-Wno-format", "-Wno-format-nonliteral", "-Wno-format-security", - "-Wno-implicit-function-declaration" + "-Wno-implicit-function-declaration", ] configs += [ @@ -789,12 +752,10 @@ template("bouffalo_sdk") { } source_set("${sdk_target_name}_mbedtls") { + defines = [ "CONFIG_FREERTOS" ] - defines = ["CONFIG_FREERTOS"] - - include_dirs = [ - "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library", - ] + include_dirs = + [ "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library" ] sources = [ "${bouffalo_sdk_root}/components/crypto/mbedtls/port/hw_acc/aes_alt.c", @@ -815,6 +776,10 @@ template("bouffalo_sdk") { ] sources += [ + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls//library/poly1305.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls//library/ripemd160.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls//library/rsa.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls//library/rsa_internal.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/aes.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/aesni.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/arc4.c", @@ -822,7 +787,8 @@ template("bouffalo_sdk") { "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/asn1parse.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/asn1write.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/base64.c", -# "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/bignum.c", + + # "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/bignum.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/blowfish.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/camellia.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ccm.c", @@ -832,11 +798,11 @@ template("bouffalo_sdk") { "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/cipher.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/cipher_wrap.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/cmac.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/constant_time.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ctr_drbg.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/debug.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/des.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/dhm.c", - "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/constant_time.c", - "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ctr_drbg.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ecdh.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ecdsa.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ecjpake.c", @@ -846,11 +812,6 @@ template("bouffalo_sdk") { "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/entropy_poll.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/error.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/gcm.c", - "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/padlock.c", - "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/mps_reader.c", - "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/mps_trace.c", - "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/nist_kw.c", - "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/memory_buffer_alloc.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/havege.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/hkdf.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/hmac_drbg.c", @@ -858,21 +819,22 @@ template("bouffalo_sdk") { "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/md2.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/md4.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/md5.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/memory_buffer_alloc.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/mps_reader.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/mps_trace.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/nist_kw.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/oid.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/padlock.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/pem.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/pk.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/pk_wrap.c", - "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/pkparse.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/pkcs11.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/pkcs12.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/pkcs5.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/pkparse.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/pkwrite.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/platform.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/platform_util.c", - "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls//library/poly1305.c", - "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls//library/ripemd160.c", - "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls//library/rsa.c", - "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls//library/rsa_internal.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/sha1.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/sha256.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/sha512.c", @@ -883,19 +845,19 @@ template("bouffalo_sdk") { "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ssl_msg.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ssl_srv.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ssl_ticket.c", - "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ssl_tls13_keys.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ssl_tls.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/ssl_tls13_keys.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/threading.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/timing.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/version.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/version_features.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/x509.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/x509_create.c", - "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/x509_crt.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/x509_crl.c", - "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/x509write_csr.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/x509_crt.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/x509_csr.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/x509write_crt.c", + "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/x509write_csr.c", "${bouffalo_sdk_root}/components/crypto/mbedtls/mbedtls/library/xtea.c", ] @@ -904,14 +866,14 @@ template("bouffalo_sdk") { "-Wno-implicit-function-declaration", "-Wno-format", "-Wno-format-security", - "-Wno-format-nonliteral" + "-Wno-format-nonliteral", ] configs += [ ":${sdk_target_name}_config_lhal", ":${sdk_target_name}_config_freertos", ":${sdk_target_name}_config_mm", - ":${sdk_target_name}_config_lwip" + ":${sdk_target_name}_config_lwip", ] public_configs = [ @@ -930,9 +892,8 @@ template("bouffalo_sdk") { "${bouffalo_sdk_root}/components/net/lwip/lwip/lwip-port", ] - include_dirs += [ - "${bouffalo_sdk_root}/components/net/lwip/lwip/src/apps/dhcpd", - ] + include_dirs += + [ "${bouffalo_sdk_root}/components/net/lwip/lwip/src/apps/dhcpd" ] defines = [ "CONFIG_LWIP", @@ -942,9 +903,9 @@ template("bouffalo_sdk") { } source_set("${sdk_target_name}_lwip") { - sources = [ - "${bouffalo_sdk_root}/components/net/lwip/lwip/src/apps/http/fs.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/lwip-port/FreeRTOS/sys_arch.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/api/api_lib.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/api/api_msg.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/api/err.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/api/netbuf.c", @@ -952,16 +913,21 @@ template("bouffalo_sdk") { "${bouffalo_sdk_root}/components/net/lwip/lwip/src/api/netifapi.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/api/sockets.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/api/tcpip.c", - "${bouffalo_sdk_root}/components/net/lwip/lwip/src/api/api_lib.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/apps/http/fs.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/apps/mdns/mdns.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/def.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/dns.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/inet_chksum.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/init.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ip.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv4/autoip.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv4/dhcp.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv4/etharp.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv4/icmp.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv4/igmp.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv4/ip4.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv4/ip4_addr.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv4/ip4_frag.c", - "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv4/ip4.c", - "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv6/dhcp6.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv6/ethip6.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv6/icmp6.c", @@ -971,12 +937,6 @@ template("bouffalo_sdk") { "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv6/ip6_frag.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv6/mld6.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ipv6/nd6.c", - - "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/def.c", - "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/dns.c", - "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/inet_chksum.c", - "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/init.c", - "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/ip.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/mem.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/memp.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/netif.c", @@ -984,14 +944,12 @@ template("bouffalo_sdk") { "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/raw.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/stats.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/sys.c", + "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/tcp.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/tcp_in.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/tcp_out.c", - "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/tcp.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/timeouts.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/core/udp.c", "${bouffalo_sdk_root}/components/net/lwip/lwip/src/netif/ethernet.c", - "${bouffalo_sdk_root}/components/net/lwip/lwip/src/apps/mdns/mdns.c", - "${bouffalo_sdk_root}/components/net/lwip/lwip/lwip-port/FreeRTOS/sys_arch.c", ] sources += [ @@ -1004,7 +962,7 @@ template("bouffalo_sdk") { "-Wno-format", "-Wno-format-nonliteral", "-Wno-format-security", - "-Wno-unused-variable" + "-Wno-unused-variable", ] configs += [ @@ -1023,11 +981,10 @@ template("bouffalo_sdk") { } config("${sdk_target_name}_config_wifi") { - defines = [ "CFG_VIF_MAX=2", "CFG_STA_MAX=4", - "CFG_UMAC" + "CFG_UMAC", ] include_dirs = [ @@ -1038,19 +995,15 @@ template("bouffalo_sdk") { } source_set("${sdk_target_name}_wifi") { - defines = [ "CFG_IPV6" ] - libs = [ - "${bouffalo_sdk_root}/components/wireless/wifi6/lib/libwifi6.a", - ] + libs = [ "${bouffalo_sdk_root}/components/wireless/wifi6/lib/libwifi6.a" ] - include_dirs = [ - "${bouffalo_sdk_root}/components/wireless/wifi6/wifi6_lwip_adapter", - ] + include_dirs = + [ "${bouffalo_sdk_root}/components/wireless/wifi6/wifi6_lwip_adapter" ] sources = [ - "${bouffalo_sdk_root}/components/wireless/wifi6/bl6_os_adapter/src/rtos_al.c", "${bouffalo_sdk_root}/components/wireless/wifi6/bl6_os_adapter/src/platform_bouffalo_sdk.c", + "${bouffalo_sdk_root}/components/wireless/wifi6/bl6_os_adapter/src/rtos_al.c", "${bouffalo_sdk_root}/components/wireless/wifi6/wifi6_lwip_adapter/cli_al.c", "${bouffalo_sdk_root}/components/wireless/wifi6/wifi6_lwip_adapter/mat.c", "${bouffalo_sdk_root}/components/wireless/wifi6/wifi6_lwip_adapter/net_al.c", @@ -1070,7 +1023,7 @@ template("bouffalo_sdk") { "-Wno-format", "-Wno-format-nonliteral", "-Wno-discarded-qualifiers", - "-Wno-format-security" + "-Wno-format-security", ] configs += [ @@ -1088,7 +1041,6 @@ template("bouffalo_sdk") { } config("${sdk_target_name}_config_ble") { - defines = [ "BFLB_BLE", "CONFIG_BT_CONN=1", @@ -1167,11 +1119,10 @@ template("bouffalo_sdk") { "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/host/gatt.c", "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/host/hci_core.c", "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/host/l2cap.c", + "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/host/multi_adv.c", "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/host/settings.c", "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/host/uuid.c", "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/port/bl_port.c", - "${bouffalo_sdk_root}/components/wireless/bluetooth/blestack/src/host/multi_adv.c" - ] cflags_c = [ @@ -1181,13 +1132,13 @@ template("bouffalo_sdk") { "-Wno-format-nonliteral", "-Wno-format-security", "-Wno-discarded-qualifiers", - "-Wno-misleading-indentation" + "-Wno-misleading-indentation", ] configs += [ ":${sdk_target_name}_config", ":${sdk_target_name}_config_utils", - ":${sdk_target_name}_config_freertos" + ":${sdk_target_name}_config_freertos", ] public_configs = [ ":${sdk_target_name}_config", @@ -1196,7 +1147,6 @@ template("bouffalo_sdk") { } config("${sdk_target_name}_config_openthread_port") { - include_dirs = [ "${bouffalo_sdk_root}/components/wireless/thread/openthread_port/include", "${bouffalo_sdk_root}/components/wireless/thread/openthread_utils/include", @@ -1206,7 +1156,12 @@ template("bouffalo_sdk") { source_set("${sdk_target_name}_openthread_port") { import("//build_overrides/openthread.gni") - defines = [ "CONFIG_BL_SDK", "CHIP_HDR=", "CHIP_GLB_HDR=", "MAC_ADDRESS_MAX_NUM=3" ] + defines = [ + "CONFIG_BL_SDK", + "CHIP_HDR=", + "CHIP_GLB_HDR=", + "MAC_ADDRESS_MAX_NUM=3", + ] include_dirs = [ "${bouffalo_sdk_root}/components/wireless/lmac154/lmac154/include", @@ -1220,11 +1175,11 @@ template("bouffalo_sdk") { "${bouffalo_sdk_root}/components/wireless/thread/openthread_port/ot_sys_bflb.c", ] - if (defined(invoker.bouffalo_sdk_component_easyflash_enabled) && invoker.bouffalo_sdk_component_easyflash_enabled) { - sources += ["${bouffalo_sdk_root}/components/wireless/thread/openthread_port/ot_settings_easyflash.c"] - } - else { - sources += ["${bouffalo_sdk_root}/components/wireless/thread/openthread_port/ot_settings_littlefs.c"] + if (defined(invoker.bouffalo_sdk_component_easyflash_enabled) && + invoker.bouffalo_sdk_component_easyflash_enabled) { + sources += [ "${bouffalo_sdk_root}/components/wireless/thread/openthread_port/ot_settings_easyflash.c" ] + } else { + sources += [ "${bouffalo_sdk_root}/components/wireless/thread/openthread_port/ot_settings_littlefs.c" ] } libs = [ @@ -1232,13 +1187,9 @@ template("bouffalo_sdk") { "${bouffalo_sdk_root}/components/wireless/thread/openthread_utils/lib/libopenthread_utils.a", ] - cflags_c = [ - "-Wno-sign-compare", - ] + cflags_c = [ "-Wno-sign-compare" ] - configs += [ - ":${sdk_target_name}_config_freertos", - ] + configs += [ ":${sdk_target_name}_config_freertos" ] public_configs = [ ":${sdk_target_name}_config", ":${sdk_target_name}_config_utils", @@ -1257,11 +1208,11 @@ template("bouffalo_sdk") { } config("${sdk_target_name}_config_factory_data") { - include_dirs = [ "${bouffalo_sdk_root}/components/wireless/matter/mfd/include" ] + include_dirs = + [ "${bouffalo_sdk_root}/components/wireless/matter/mfd/include" ] } source_set("${sdk_target_name}_factory_data") { - defines = [ "BL_MFD_PLAT_H=\"bl_mfd_bl616.h\"" ] sources = [ "${bouffalo_sdk_root}/components/wireless/matter/mfd/bl_mfd.c", @@ -1279,25 +1230,25 @@ template("bouffalo_sdk") { group(sdk_target_name) { public_deps = [ - ":${sdk_target_name}_startup", - ":${sdk_target_name}_std_drv", - ":${sdk_target_name}_lhal", - ":${sdk_target_name}_sys", ":${sdk_target_name}_board", - ":${sdk_target_name}_shell", - ":${sdk_target_name}_rf", - ":${sdk_target_name}_libc", - ":${sdk_target_name}_mm", ":${sdk_target_name}_freertos", + ":${sdk_target_name}_lhal", + ":${sdk_target_name}_libc", ":${sdk_target_name}_mbedtls", + ":${sdk_target_name}_mm", + ":${sdk_target_name}_rf", + ":${sdk_target_name}_shell", + ":${sdk_target_name}_startup", + ":${sdk_target_name}_std_drv", + ":${sdk_target_name}_sys", ":${sdk_target_name}_utils", ] - if (defined(invoker.bouffalo_sdk_component_easyflash_enabled) && invoker.bouffalo_sdk_component_easyflash_enabled) { - public_deps += [ ":${sdk_target_name}_easyflash4" ] - } - else { - public_deps += [ ":${sdk_target_name}_littlefs" ] + if (defined(invoker.bouffalo_sdk_component_easyflash_enabled) && + invoker.bouffalo_sdk_component_easyflash_enabled) { + public_deps += [ ":${sdk_target_name}_easyflash4" ] + } else { + public_deps += [ ":${sdk_target_name}_littlefs" ] } if (defined(invoker.chip_enable_wifi) && invoker.chip_enable_wifi) { @@ -1308,11 +1259,13 @@ template("bouffalo_sdk") { public_deps += [ ":${sdk_target_name}_openthread_port" ] } - if (defined(invoker.chip_config_network_layer_ble) && invoker.chip_config_network_layer_ble) { + if (defined(invoker.chip_config_network_layer_ble) && + invoker.chip_config_network_layer_ble) { public_deps += [ ":${sdk_target_name}_ble" ] } - if (defined(invoker.chip_enable_factory_data) && invoker.chip_enable_factory_data) { + if (defined(invoker.chip_enable_factory_data) && + invoker.chip_enable_factory_data) { public_deps += [ ":${sdk_target_name}_factory_data" ] } } diff --git a/third_party/bouffalolab/bl702/bl_iot_sdk.gni b/third_party/bouffalolab/bl702/bl_iot_sdk.gni index dbbd36c360e999..76d35da758e883 100644 --- a/third_party/bouffalolab/bl702/bl_iot_sdk.gni +++ b/third_party/bouffalolab/bl702/bl_iot_sdk.gni @@ -106,7 +106,6 @@ template("bl_iot_sdk") { } source_set("${sdk_target_name}_BSP_Driver") { - sources = [ "${bl_iot_sdk_root}/components/platform/soc/bl702/bl702_std/BSP_Driver/std_drv/src/bl702_acomp.c", "${bl_iot_sdk_root}/components/platform/soc/bl702/bl702_std/BSP_Driver/std_drv/src/bl702_adc.c", @@ -249,12 +248,12 @@ template("bl_iot_sdk") { defines += [ "CFG_BLE_ENABLE" ] } - if (defined(invoker.enable_debug_coredump) && invoker.enable_debug_coredump) { + if (defined(invoker.enable_debug_coredump) && + invoker.enable_debug_coredump) { defines += [ "SYS_ENABLE_COREDUMP" ] } sources = [ - "${bl_iot_sdk_root}/components/platform/hosal/bl702_hal/bl_psram_sp.S", "${bl_iot_sdk_root}/components/platform/hosal/bl702_hal/bl_adc.c", "${bl_iot_sdk_root}/components/platform/hosal/bl702_hal/bl_boot2.c", "${bl_iot_sdk_root}/components/platform/hosal/bl702_hal/bl_chip.c", @@ -268,6 +267,7 @@ template("bl_iot_sdk") { "${bl_iot_sdk_root}/components/platform/hosal/bl702_hal/bl_irq.c", "${bl_iot_sdk_root}/components/platform/hosal/bl702_hal/bl_pds.c", "${bl_iot_sdk_root}/components/platform/hosal/bl702_hal/bl_psram.c", + "${bl_iot_sdk_root}/components/platform/hosal/bl702_hal/bl_psram_sp.S", "${bl_iot_sdk_root}/components/platform/hosal/bl702_hal/bl_pwm.c", "${bl_iot_sdk_root}/components/platform/hosal/bl702_hal/bl_rtc.c", "${bl_iot_sdk_root}/components/platform/hosal/bl702_hal/bl_sec.c", @@ -400,7 +400,8 @@ template("bl_iot_sdk") { include_dirs += [ "${bl_iot_sdk_root}/components/stage/littlefs/port" ] } - if (defined(invoker.enable_debug_coredump) && invoker.enable_debug_coredump) { + if (defined(invoker.enable_debug_coredump) && + invoker.enable_debug_coredump) { include_dirs += [ "${bl_iot_sdk_root}/components/stage/coredump/inc" ] } @@ -432,9 +433,11 @@ template("bl_iot_sdk") { "${bl_iot_sdk_root}/components/stage/yloop/src/yloop.c", ] - if (defined(invoker.enable_debug_coredump) && invoker.enable_debug_coredump) { + if (defined(invoker.enable_debug_coredump) && + invoker.enable_debug_coredump) { defines += [ "BFLB_COREDUMP_BINARY_ID=${invoker.coredump_binary_id}" ] - sources += [ "${bl_iot_sdk_root}/components/stage/coredump/bl_coredump.c" ] + sources += + [ "${bl_iot_sdk_root}/components/stage/coredump/bl_coredump.c" ] } cflags_c = [ "-Wno-sign-compare" ] @@ -445,12 +448,11 @@ template("bl_iot_sdk") { ":${sdk_target_name}_config_fs", ":${sdk_target_name}_config_sys", ":${sdk_target_name}_config_utils", - ":${sdk_target_name}_config_hosal" + ":${sdk_target_name}_config_hosal", ] if (defined(invoker.bouffalo_sdk_component_easyflash_enabled) && invoker.bouffalo_sdk_component_easyflash_enabled) { - defines += [ "EF_ENV_CACHE_TABLE_SIZE=64" ] sources += [ "${bl_iot_sdk_root}/components/stage/easyflash4/src/easyflash.c", @@ -740,9 +742,9 @@ template("bl_iot_sdk") { } config("${sdk_target_name}_config_openthread_port") { - defines = [ - "OT_FREERTOS_ENABLE=1", - "CONFIG_LMAC154_LOG=0" + defines = [ + "OT_FREERTOS_ENABLE=1", + "CONFIG_LMAC154_LOG=0", ] include_dirs = [ diff --git a/third_party/bouffalolab/bl702l/bl_iot_sdk.gni b/third_party/bouffalolab/bl702l/bl_iot_sdk.gni index 4ba6f377cd947f..ac608a72098cd6 100644 --- a/third_party/bouffalolab/bl702l/bl_iot_sdk.gni +++ b/third_party/bouffalolab/bl702l/bl_iot_sdk.gni @@ -156,7 +156,6 @@ template("bl_iot_sdk") { } source_set("${sdk_target_name}_bl702l_freertos") { - defines = [ "portasmHANDLE_INTERRUPT=interrupt_entry" ] include_dirs = [ "${bl_iot_sdk_root}/components/platform/soc/bl702l/bl702l_freertos/portable/GCC/RISC-V/chip_specific_extensions/RV32F_float_abi_single" ] @@ -207,7 +206,8 @@ template("bl_iot_sdk") { defines += [ "CFG_BLE_ENABLE" ] } - if (defined(invoker.enable_debug_coredump) && invoker.enable_debug_coredump) { + if (defined(invoker.enable_debug_coredump) && + invoker.enable_debug_coredump) { defines += [ "SYS_ENABLE_COREDUMP" ] } @@ -360,7 +360,8 @@ template("bl_iot_sdk") { include_dirs += [ "${bl_iot_sdk_root}/components/stage/littlefs/port" ] } - if (defined(invoker.enable_debug_coredump) && invoker.enable_debug_coredump) { + if (defined(invoker.enable_debug_coredump) && + invoker.enable_debug_coredump) { include_dirs += [ "${bl_iot_sdk_root}/components/stage/coredump/inc" ] } } @@ -388,9 +389,11 @@ template("bl_iot_sdk") { "${bl_iot_sdk_root}/components/stage/yloop/src/yloop.c", ] - if (defined(invoker.enable_debug_coredump) && invoker.enable_debug_coredump) { + if (defined(invoker.enable_debug_coredump) && + invoker.enable_debug_coredump) { defines += [ "BFLB_COREDUMP_BINARY_ID=${invoker.coredump_binary_id}" ] - sources += [ "${bl_iot_sdk_root}/components/stage/coredump/bl_coredump.c" ] + sources += + [ "${bl_iot_sdk_root}/components/stage/coredump/bl_coredump.c" ] } cflags_c = [ "-Wno-sign-compare" ] @@ -401,7 +404,7 @@ template("bl_iot_sdk") { ":${sdk_target_name}_config_sys", ":${sdk_target_name}_config_utils", ":${sdk_target_name}_config_freertos", - ":${sdk_target_name}_config_hosal" + ":${sdk_target_name}_config_hosal", ] if (defined(invoker.bouffalo_sdk_component_easyflash_enabled) && @@ -615,13 +618,13 @@ template("bl_iot_sdk") { "CONFIG_BT_CONN", "CONFIG_BT_HCI_VS_EVT_USER", "CONFIG_BT_ASSERT", - "CONFIG_BT_GATT_CLIENT" + "CONFIG_BT_GATT_CLIENT", ] if (defined(invoker.enable_pds) && invoker.enable_pds) { defines += [ "CFG_BLE_PDS", - "CONFIG_HW_SEC_ENG_DISABLE" + "CONFIG_HW_SEC_ENG_DISABLE", ] } @@ -629,10 +632,7 @@ template("bl_iot_sdk") { } source_set("${sdk_target_name}_ble") { - - libs = [ - "${bl_iot_sdk_root}/components/network/ble/btblecontroller_702l_m0s1p/lib/libbtblecontroller_702l_m0s1p.a", - ] + libs = [ "${bl_iot_sdk_root}/components/network/ble/btblecontroller_702l_m0s1p/lib/libbtblecontroller_702l_m0s1p.a" ] if (defined(invoker.enable_pds) && invoker.enable_pds) { libs += [ "${bl_iot_sdk_root}/components/network/ble/btble_pds/lib/libbtble_pds.a" ] } @@ -693,9 +693,9 @@ template("bl_iot_sdk") { } config("${sdk_target_name}_config_openthread_port") { - defines = [ - "OT_FREERTOS_ENABLE=1", - "CONFIG_LMAC154_LOG=0" + defines = [ + "OT_FREERTOS_ENABLE=1", + "CONFIG_LMAC154_LOG=0", ] include_dirs = [ @@ -784,9 +784,9 @@ template("bl_iot_sdk") { group(sdk_target_name) { public_deps = [ ":${sdk_target_name}_BSP_Driver", + ":${sdk_target_name}_bl702l_freertos", ":${sdk_target_name}_fs", ":${sdk_target_name}_hosal", - ":${sdk_target_name}_bl702l_freertos", ":${sdk_target_name}_libc", ":${sdk_target_name}_mbedtls", ":${sdk_target_name}_soc", diff --git a/third_party/bouffalolab/common/bouffalolab_executable.gni b/third_party/bouffalolab/common/bouffalolab_executable.gni index 97d52b7e61375a..491cb49cdf50ed 100644 --- a/third_party/bouffalolab/common/bouffalolab_executable.gni +++ b/third_party/bouffalolab/common/bouffalolab_executable.gni @@ -51,27 +51,22 @@ template("bouffalolab_executable") { flashing_config_target = target_name + ".config" if (invoker.bl_plat_name == "bl616") { objcopy_image_name = output_base_name + ".raw" - flashing_config_inputs = [ - "${chip_root}/examples/platform/bouffalolab/${invoker.bl_plat_name}/flash_config/partition_cfg_4M.toml", + flashing_config_inputs = [ + "${chip_root}/examples/platform/bouffalolab/${invoker.bl_plat_name}/flash_config/partition_cfg_4M.toml", "${chip_root}/third_party/bouffalolab/bouffalo_sdk/bsp/board/bl616dk/config/bl_factory_params_IoTKitA_auto.dts", - "${chip_root}/third_party/bouffalolab/bouffalo_sdk/bsp/board/bl616dk/config/boot2_bl616_isp_release_v8.1.6.bin" + "${chip_root}/third_party/bouffalolab/bouffalo_sdk/bsp/board/bl616dk/config/boot2_bl616_isp_release_v8.1.6.bin", ] copy(flashing_config_target) { sources = flashing_config_inputs outputs = [ "${root_out_dir}/config/{{source_file_part}}" ] } - } - else { + } else { objcopy_image_name = output_base_name + ".bin" if (invoker.bl_plat_name == "bl602") { - flashing_config_inputs = [ - "${chip_root}/examples/platform/bouffalolab/${invoker.bl_plat_name}/flash_config/partition_cfg_4M.toml" - ] + flashing_config_inputs = [ "${chip_root}/examples/platform/bouffalolab/${invoker.bl_plat_name}/flash_config/partition_cfg_4M.toml" ] } else { - flashing_config_inputs = [ - "${chip_root}/examples/platform/bouffalolab/${invoker.bl_plat_name}/flash_config/partition_cfg_2M.toml" - ] + flashing_config_inputs = [ "${chip_root}/examples/platform/bouffalolab/${invoker.bl_plat_name}/flash_config/partition_cfg_2M.toml" ] } copy(flashing_config_target) { @@ -88,7 +83,10 @@ template("bouffalolab_executable") { flashing_options += [ "${invoker.bl_plat_name}" ] if (invoker.bl_plat_name == "bl616") { - flashing_options += [ "--config", "${root_out_dir}/flash_prog_cfg.ini" ] + flashing_options += [ + "--config", + "${root_out_dir}/flash_prog_cfg.ini", + ] } else { flashing_options += [ "--xtal" ] if (invoker.bl_plat_name == "bl602") { @@ -112,7 +110,7 @@ template("bouffalolab_executable") { flashing_options += [ rebase_path("partition_cfg_2M.toml", root_out_dir, root_out_dir) ] } - } + } # set 2000000 baudrate for image download by default flashing_options += [ "--baudrate" ]