Skip to content

Commit

Permalink
[Bouffalolab] Refactor Bouffalolab SDK gn scripts (#24132)
Browse files Browse the repository at this point in the history
* create bl_iot_sdk.gni

* update bl_iot_sdk.gni

* remove more 702 specific-name

* update bl602

* update bl602 & bl702

* update toolchain path

* fix issues for bl602

* fix parition table for bl702

* fix restyle
  • Loading branch information
wy-hh authored and pull[bot] committed Jun 2, 2023
1 parent beb48fb commit 1256471
Show file tree
Hide file tree
Showing 51 changed files with 1,991 additions and 1,852 deletions.
6 changes: 1 addition & 5 deletions build_overrides/bouffalolab_iot_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
# limitations under the License.

declare_args() {
# Root directory for bl602 SDK build files.
bl602_sdk_build_root = "//third_party/bouffalolab/bl602"

# Root directory for bl702 SDK build files.
bl702_sdk_build_root = "//third_party/bouffalolab/bl702"
bouffalolab_iot_sdk_build_root = "//third_party/bouffalolab/"

bouffalolab_sdk_root = "/opt/bouffalolab_sdk"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020 Project CHIP Authors
# Copyright (c) 2022 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.
Expand All @@ -12,10 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import("bl702_board.gni")
# Options from standalone-chip.mk that differ from configure defaults. These
# options are used from examples/.

riscv_arch = "rv32imfc"
riscv_abi = "ilp32f"
# riscv_cpu = ""
# riscv_float_abi = "hard"
# riscv_fpu = ""
custom_toolchain =
"//third_party/connectedhomeip/config/bouffalolab/toolchain:riscv_gcc"
File renamed without changes.
9 changes: 2 additions & 7 deletions examples/build_overrides/bouffalolab_iot_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@
# limitations under the License.

declare_args() {
# Root directory for bl602 SDK build files.
bl602_sdk_build_root =
"//third_party/connectedhomeip/third_party/bouffalolab/bl602"

# Root directory for bl702 SDK build files.
bl702_sdk_build_root =
"//third_party/connectedhomeip/third_party/bouffalolab/bl702"
bouffalolab_iot_sdk_build_root =
"//third_party/connectedhomeip/third_party/bouffalolab"

bouffalolab_sdk_root = "/opt/bouffalolab_sdk"
}
12 changes: 8 additions & 4 deletions examples/lighting-app/bouffalolab/bl602/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import("//build_overrides/bouffalolab_iot_sdk.gni")
import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")

import("${bl602_sdk_build_root}/bl602_executable.gni")
import("${bl602_sdk_build_root}/bl602_sdk.gni")
import("${bouffalolab_iot_sdk_build_root}/bl602/bl_iot_sdk.gni")
import("${bouffalolab_iot_sdk_build_root}/common/bouffalolab_executable.gni")
import("${build_root}/config/defaults.gni")
import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
import("${chip_root}/src/platform/device.gni")
Expand Down Expand Up @@ -51,7 +51,7 @@ declare_args() {
baudrate = 2000000
}

bl602_sdk("sdk") {
bl_iot_sdk("sdk") {
include_dirs = [
"${chip_root}/src/platform/bouffalolab/BL602",
"${example_dir}",
Expand All @@ -66,6 +66,7 @@ bl602_sdk("sdk") {
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
"OTA_PERIODIC_QUERY_TIMEOUT=${ota_periodic_query_timeout}",
"CHIP_UART_BAUDRATE=${baudrate}",
"SYS_AOS_LOOP_ENABLE",
]

if (chip_enable_pw_rpc) {
Expand All @@ -77,16 +78,18 @@ bl602_sdk("sdk") {
}
}

bl602_executable("lighting_app") {
bouffalolab_executable("lighting_app") {
output_name = "chip-bl602-lighting-example.out"

defines = [
"APP_TASK_STACK_SIZE=2044",
"CHIP_UART_BAUDRATE=${baudrate}",
"BL602_ENABLE",
"START_ENTRY=bfl_main",
"SYS_AOS_LOOP_ENABLE",
]

bl_plat_name = "bl602"
sources = [
"${examples_plat_dir}/route_hook/bl_route_hook.c",
"${examples_plat_dir}/route_hook/bl_route_table.c",
Expand Down Expand Up @@ -195,6 +198,7 @@ bl602_executable("lighting_app") {
sources += [ "${examples_plat_common_dir}/plat/OTAConfig.cpp" ]
}

cflags_c = [ "-Wno-sign-compare" ]
ldscript = "${examples_plat_dir}/ldscripts/flash_rom.ld"

ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ]
Expand Down
2 changes: 2 additions & 0 deletions examples/lighting-app/bouffalolab/bl602/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,5 @@
#define CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE (512)

#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1

#define CHIP_SYSTEM_CRYPTO_HEADER_RESERVE_SIZE 128
2 changes: 1 addition & 1 deletion examples/lighting-app/bouffalolab/bl602/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import("//build_overrides/pigweed.gni")
import("${chip_root}/config/standalone/args.gni")
import("${chip_root}/src/platform/bouffalolab/BL602/args.gni")

bl602_sdk_target = get_label_info(":sdk", "label_no_toolchain")
bl_iot_sdk_target = get_label_info(":sdk", "label_no_toolchain")

pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
pw_assert_BACKEND = "$dir_pw_assert_log"
Expand Down
9 changes: 5 additions & 4 deletions examples/lighting-app/bouffalolab/bl702/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import("//build_overrides/bouffalolab_iot_sdk.gni")
import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")

import("${bl702_sdk_build_root}/bl702_executable.gni")
import("${bl702_sdk_build_root}/bl702_sdk.gni")
import("${bouffalolab_iot_sdk_build_root}/bl702/bl_iot_sdk.gni")
import("${bouffalolab_iot_sdk_build_root}/common/bouffalolab_executable.gni")
import("${build_root}/config/defaults.gni")
import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
import("${chip_root}/src/platform/device.gni")
Expand Down Expand Up @@ -54,7 +54,7 @@ declare_args() {
baudrate = 2000000
}

bl702_sdk("sdk") {
bl_iot_sdk("sdk") {
include_dirs = [
"${example_dir}",
"${example_common_dir}",
Expand Down Expand Up @@ -88,8 +88,9 @@ bl702_sdk("sdk") {
}
}

bl702_executable("lighting_app") {
bouffalolab_executable("lighting_app") {
output_name = "chip-bl702-lighting-example.out"
bl_plat_name = "bl702"

defines = [
"APP_TASK_STACK_SIZE=2044",
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/bouffalolab/bl702/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import("//build_overrides/pigweed.gni")
import("${chip_root}/config/standalone/args.gni")
import("${chip_root}/src/platform/bouffalolab/BL702/args.gni")

bl702_sdk_target = get_label_info(":sdk", "label_no_toolchain")
bl_iot_sdk_target = get_label_info(":sdk", "label_no_toolchain")

pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
pw_assert_BACKEND = "$dir_pw_assert_log"
Expand Down
3 changes: 2 additions & 1 deletion examples/lighting-app/bouffalolab/common/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ void AppTask::ChipEventHandler(const ChipDeviceEvent * event, intptr_t arg)
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
case DeviceEventType::kWiFiConnectivityChange:

ChipLogProgress(NotSpecified, "Wi-Fi state changed\r\n", ConnectivityMgr().IsWiFiStationConnected());
ChipLogProgress(NotSpecified, "Wi-Fi state changed to %s.\r\n",
ConnectivityMgr().IsWiFiStationConnected() ? "connected" : "disconnected");

chip::app::DnssdServer::Instance().StartServer();
NetworkCommissioning::BLWiFiDriver::GetInstance().SaveConfiguration();
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/bouffalolab/bl602/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import("//build_overrides/bouffalolab_iot_sdk.gni")
import("//build_overrides/chip.gni")

import("${bl602_sdk_build_root}/bl602_sdk.gni")
import("${bouffalolab_iot_sdk_build_root}/bl602/bl_iot_sdk.gni")

config("chip_examples_project_config") {
include_dirs = [ "project_include" ]
Expand Down
188 changes: 85 additions & 103 deletions examples/platform/bouffalolab/bl602/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,8 @@
1 tab == 4 spaces!
*/

#pragma once

#ifdef __cplusplus
extern "C" {
#endif
#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H

#include "platform.h"
#include <stdio.h>
Expand All @@ -118,116 +115,101 @@ extern "C" {
* See http://www.freertos.org/a00110.html.
*----------------------------------------------------------*/

/* Tickless mode is not used. */

/* Some of the standard demo test tasks assume a tick rate of 1KHz, even
though that is faster than would normally be warranted by a real
application. */
#define configTICK_RATE_HZ (1000)

/* The full demo always has tasks to run so the tick will never be turned
off. The blinky demo will use the default tickless idle implementation to
turn the tick off. */
#define configUSE_TICKLESS_IDLE (0)
#define configSUPPORT_STATIC_ALLOCATION 1

/* Hook function related definitions. */
#define configUSE_TICK_HOOK (0)
#define configCHECK_FOR_STACK_OVERFLOW (2)
#define configUSE_MALLOC_FAILED_HOOK (1)
#define configUSE_IDLE_HOOK (0)

#define configENERGY_MODE (sleepEM1)

/* Main functions*/
/* Run time stats gathering related definitions. */
#define configGENERATE_RUN_TIME_STATS (0)

/* Co-routine related definitions. */
#define configUSE_CO_ROUTINES (0)
#define configCLINT_BASE_ADDRESS CLINT_CTRL_ADDR
#define configCLIC_TIMER_ENABLE_ADDRESS (0x02800407)
#define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 1
#define configUSE_TICK_HOOK 0
#ifndef configUSE_TICKLESS_IDLE
// Maybe Compile flags is passed by command line
#define configUSE_TICKLESS_IDLE 1
#endif
#define configCPU_CLOCK_HZ (10 * 1000 * 1000) /*QEMU*/
#define configTICK_RATE_HZ ((TickType_t) 1000)
#define configMAX_PRIORITIES (32)
/* Creating idle task */
/* -1 -> prvInitialiseNewTask: (subtract 1 to get top of stack) pxTopOfStack = &( pxNewTCB->pxStack[ ulStackDepth - ( uint32_t ) 1
* ] ); */
/* -1 -> prvInitialiseNewTask: (subtract 1 in case not matching 8 bytes alignment) pxTopOfStack = ( StackType_t * ) ( ( (
* portPOINTER_SIZE_TYPE ) pxTopOfStack ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); */
/* Running idle task */
/* -12 -> prvIdleTask: addi sp, sp, -48 */
/* -16 -> prvIdleTask.xTaskResumeAll: addi sp, sp, -64 */
/* Here comes an interrupt after prvIdleTask.xTaskResumeAll.vTaskExitCritical */
/* -30 -> freertos_risc_v_trap_handler: addi sp, sp, -portCONTEXT_SIZE */
/* -34 -> portasmSAVE_ADDITIONAL_REGISTERS: addi sp, sp, -(portasmADDITIONAL_CONTEXT_SIZE * portWORD_SIZE) */
/* Checking for stack overflow */
/* 4 -> taskCHECK_FOR_STACK_OVERFLOW: if( ( pulStack[ 0 ] != ulCheckValue ) || ( pulStack[ 1 ] != ulCheckValue ) || ( pulStack[ 2
* ] != ulCheckValue ) || ( pulStack[ 3 ] != ulCheckValue ) ) */
#define configMINIMAL_STACK_SIZE ((unsigned short) 114) /* SIZE-1-1-12-16-30-34>=4 */
#define configTOTAL_HEAP_SIZE ((size_t) 14100)
#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 1
#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 0
#define configUSE_COUNTING_SEMAPHORES 1
#define configGENERATE_RUN_TIME_STATS 0
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1

/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES (2)

/* Software timer related definitions. */
#define configUSE_TIMERS (1)
#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1) /* Highest priority */
#define configTIMER_QUEUE_LENGTH (4)
/* Software timer definitions. */
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1)
#define configTIMER_QUEUE_LENGTH 4
#define configTIMER_TASK_STACK_DEPTH (400)

/* Cortex-M specific definitions. */
#ifdef __NVIC_PRIO_BITS
/* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
#define configPRIO_BITS (__NVIC_PRIO_BITS)
#else
#define configPRIO_BITS 3 /* 7 priority levels */
/* Task priorities. Allow these to be overridden. */
#ifndef uartPRIMARY_PRIORITY
#define uartPRIMARY_PRIORITY (configMAX_PRIORITIES - 3)
#endif

/* The lowest interrupt priority that can be used in a call to a "set priority"
function. */
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY (0x07)

/* The highest interrupt priority that can be used by any interrupt service
routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY (0x03)

/* Interrupt priorities used by the kernel port layer itself. These are generic
to all Cortex-M ports, and do not rely on any particular library functions. */
#define configKERNEL_INTERRUPT_PRIORITY (configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS))
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configMAX_SYSCALL_INTERRUPT_PRIORITY (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS))

/* FreeRTOS MPU specific definitions. */
#define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS (0)

#define configCPU_CLOCK_HZ (10 * 1000 * 1000)
#define configUSE_PREEMPTION (1)
#define configUSE_TIME_SLICING (1)
#define configUSE_PORT_OPTIMISED_TASK_SELECTION (1)
#define configUSE_TICKLESS_IDLE_SIMPLE_DEBUG (1) /* See into vPortSuppressTicksAndSleep source code for explanation */
#define configMAX_PRIORITIES (32)
#define configMINIMAL_STACK_SIZE ((unsigned short) 112) /* Number of words to use for Idle and Timer stacks */
#define configMAX_TASK_NAME_LEN (16)
#define configUSE_16_BIT_TICKS (0)
#define configIDLE_SHOULD_YIELD (1)
#define configUSE_MUTEXES (1)
#define configUSE_RECURSIVE_MUTEXES (1)
#define configUSE_COUNTING_SEMAPHORES (1)
#define configQUEUE_REGISTRY_SIZE (8)
// #define configUSE_QUEUE_SETS (0)
// #define configUSE_NEWLIB_REENTRANT (0)
#define configENABLE_BACKWARD_COMPATIBILITY (1)
#define configSUPPORT_STATIC_ALLOCATION (1)

/* Optional functions - most linkers will remove unused functions anyway. */
#define INCLUDE_vTaskPrioritySet (1)
#define INCLUDE_uxTaskPriorityGet (1)
#define INCLUDE_vTaskDelete (1)
#define INCLUDE_vTaskSuspend (1)
// #define INCLUDE_xResumeFromISR (1)
#define INCLUDE_vTaskDelayUntil (1)
#define INCLUDE_vTaskDelay (1)
#define INCLUDE_xTaskGetSchedulerState (0)
#define INCLUDE_xTaskGetCurrentTaskHandle (0)
#define INCLUDE_uxTaskGetStackHighWaterMark (1)
#define INCLUDE_xTaskGetIdleTaskHandle (0)
// #define INCLUDE_xTimerGetTimerDaemonTaskHandle (1)
// #define INCLUDE_pcTaskGetTaskName (1)
#define INCLUDE_eTaskGetState (1)
// #define INCLUDE_xEventGroupSetBitFromISR (1)
#define INCLUDE_xTimerPendFunctionCall (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_xTimerPendFunctionCall 1
#define INCLUDE_uxTaskGetStackHighWaterMark 1

/* 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. */
#define bktBLOCK_TIME_TASK_STACK_SIZE 100
#define notifyNOTIFIED_TASK_STACK_SIZE 120
#define priSUSPENDED_RX_TASK_STACK_SIZE 90
#define tmrTIMER_TEST_TASK_STACK_SIZE 100
#define ebRENDESVOUS_TEST_TASK_STACK_SIZE 100
#define ebEVENT_GROUP_SET_BITS_TEST_TASK_STACK_SIZE 115
#define genqMUTEX_TEST_TASK_STACK_SIZE 90
#define genqGENERIC_QUEUE_TEST_TASK_STACK_SIZE 100
#define recmuRECURSIVE_MUTEX_TEST_TASK_STACK_SIZE 90

extern void vAssertCalled(void);
/* Stop if an assertion fails. */
#define configASSERT(x) \
if ((x) == 0) \
vAssertCalled()

/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
standard names. */
// #define vPortSVCHandler SVC_Handler
// #define xPortPendSVHandler PendSV_Handler
#define xPortSysTickHandler SysTick_Handler
#if (configUSE_TICKLESS_IDLE != 0)
#include "portmacro.h"
extern void vApplicationSleep(TickType_t xExpectedIdleTime);
#define portSUPPRESS_TICKS_AND_SLEEP(xExpectedIdleTime) vApplicationSleep(xExpectedIdleTime)
#endif

#ifdef __cplusplus
}
#endif
Loading

0 comments on commit 1256471

Please sign in to comment.