Init project
This commit is contained in:
233
Makefile
Normal file
233
Makefile
Normal file
@ -0,0 +1,233 @@
|
||||
CUR_MK_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
CUR_MK_DIR := $(dir $(CUR_MK_PATH))
|
||||
CUR_MK_DIR := $(realpath $(CUR_MK_DIR))
|
||||
|
||||
# basic dir
|
||||
SDK_DIR := $(CUR_MK_DIR)
|
||||
OUTPUT_DIR := $(SDK_DIR)/output
|
||||
OUTPUT_BIN_DIR := $(OUTPUT_DIR)/bin
|
||||
OUTPUT_BUILD_DIR := $(OUTPUT_DIR)/build
|
||||
OPEN_SROUCE_DIR := $(SDK_DIR)/open_source
|
||||
BSLE_SRC_DIR := $(SDK_DIR)/driver/bsle
|
||||
WIFI_SRC_DIR := $(SDK_DIR)/driver/wifi
|
||||
PLATFORM_SRC_DIR := $(SDK_DIR)/driver/platform
|
||||
SCRIPT_DIR := $(SDK_DIR)/build/scripts
|
||||
CONFIG_DIR := $(SDK_DIR)/build/config
|
||||
BSLE_DFT_DRIVER_SRC_DIR := $(SDK_DIR)/application/dft
|
||||
# config file
|
||||
ACTIVE_KCONFIG_CONFIG := $(SDK_DIR)/.config
|
||||
DEFAULT_KCONFIG_CONFIG := $(CONFIG_DIR)/ws73_default.config
|
||||
LIGHT_KCONFIG_CONFIG := $(CONFIG_DIR)/ws73_light.config
|
||||
|
||||
# other
|
||||
define echo_ok
|
||||
@echo -e "\033[1;32m$(1)\033[0m"
|
||||
endef
|
||||
|
||||
# 导出由Kconfig生成的配置文件路径,供下层Makefile使用
|
||||
ifneq ($(wildcard $(ACTIVE_KCONFIG_CONFIG)),)
|
||||
WSCFG_KCONFIG_CONFIG = $(realpath $(ACTIVE_KCONFIG_CONFIG))
|
||||
else
|
||||
WSCFG_KCONFIG_CONFIG = $(realpath $(DEFAULT_KCONFIG_CONFIG))
|
||||
endif
|
||||
LIGHT_WSCFG_KCONFIG_CONFIG = $(realpath $(LIGHT_KCONFIG_CONFIG))
|
||||
export WSCFG_KCONFIG_CONFIG
|
||||
export LIGHT_WSCFG_KCONFIG_CONFIG
|
||||
export WSCFG_AUTOCONFIG_H = $(OUTPUT_BIN_DIR)/autoconfig.h
|
||||
export LIGHT_WSCFG_AUTOCONFIG_H = $(OUTPUT_BIN_DIR)/light_autoconfig.h
|
||||
|
||||
include $(WSCFG_KCONFIG_CONFIG)
|
||||
include $(LIGHT_WSCFG_KCONFIG_CONFIG)
|
||||
|
||||
export DIR_MAP_CONFIG_FILE = release.mk
|
||||
|
||||
ALL_CBB_BUILD_TARGETS := platform wifi
|
||||
LIGHT_CBB_BUILD_TARGETS := platform_light wifi_light
|
||||
ALL_CBB_CLEAN_TARGETS := platform_clean wifi_clean
|
||||
ALL_CBB_BUILD_TARGETS_ANDROID := platform wifi
|
||||
|
||||
ifdef WSCFG_BLE_COMPILE_BY_DEFAULT
|
||||
ALL_CBB_BUILD_TARGETS += ble
|
||||
ALL_CBB_BUILD_TARGETS += dft_driver
|
||||
ALL_CBB_BUILD_TARGETS += dft_channel
|
||||
ALL_CBB_BUILD_TARGETS += dft_ctrl
|
||||
ALL_CBB_BUILD_TARGETS_ANDROID += ble_android
|
||||
ALL_CBB_CLEAN_TARGETS += ble_clean ble_android_clean dft_channel_clean dft_ctrl_clean
|
||||
LIGHT_CBB_BUILD_TARGETS += ble_light
|
||||
endif
|
||||
|
||||
ifdef WSCFG_SLE_COMPILE_BY_DEFAULT
|
||||
ALL_CBB_BUILD_TARGETS += sle
|
||||
ALL_CBB_BUILD_TARGETS_ANDROID += sle
|
||||
LIGHT_CBB_BUILD_TARGETS += sle_light
|
||||
ALL_CBB_CLEAN_TARGETS += sle_clean
|
||||
endif
|
||||
|
||||
# cpu counts
|
||||
CPU_NUM := $(shell nproc)
|
||||
|
||||
.PHONY: wifi platform ble sle ini hso tools menuconfig ble_android full_build all clean
|
||||
|
||||
all: prepare $(ALL_CBB_BUILD_TARGETS)
|
||||
$(call echo_ok,all built!)
|
||||
|
||||
light: prepare_light $(LIGHT_CBB_BUILD_TARGETS)
|
||||
$(call echo_ok,light built!)
|
||||
|
||||
clean: $(ALL_CBB_CLEAN_TARGETS) hso_clean
|
||||
$(call echo_ok,all clean!)
|
||||
|
||||
full_build: prepare ini platform wifi ble_android sle hso
|
||||
$(call echo_ok,all built!)
|
||||
|
||||
android: prepare $(ALL_CBB_BUILD_TARGETS_ANDROID)
|
||||
$(call echo_ok,all android built!)
|
||||
|
||||
prepare_light:
|
||||
@mkdir -p $(OUTPUT_BIN_DIR) $(OUTPUT_BUILD_DIR)
|
||||
@python3 $(SCRIPT_DIR)/hconfig.py $(SDK_DIR)/Kconfig ${LIGHT_WSCFG_KCONFIG_CONFIG} -a ${LIGHT_WSCFG_AUTOCONFIG_H}
|
||||
@cp $(OUTPUT_BIN_DIR)/light_autoconfig.h $(OUTPUT_BIN_DIR)/autoconfig.h
|
||||
$(call echo_ok,prepare_light built!)
|
||||
|
||||
prepare:
|
||||
@mkdir -p $(OUTPUT_BIN_DIR) $(OUTPUT_BUILD_DIR)
|
||||
@python3 $(SCRIPT_DIR)/hconfig.py $(SDK_DIR)/Kconfig ${WSCFG_KCONFIG_CONFIG} -a ${WSCFG_AUTOCONFIG_H}
|
||||
|
||||
ini: prepare
|
||||
@cp -f $(CONFIG_DIR)/ws73_cfg_default.ini $(OUTPUT_BIN_DIR)/ws73_cfg.ini
|
||||
@python3 $(SCRIPT_DIR)/hconfig_to_ini.py $(CONFIG_DIR)/ini_map.csv $(SDK_DIR)/Kconfig ${WSCFG_KCONFIG_CONFIG} $(OUTPUT_BIN_DIR)/ws73_cfg.ini
|
||||
$(call echo_ok,INI file generate success in $(OUTPUT_BIN_DIR)/ws73_cfg.ini!)
|
||||
|
||||
ini_light: prepare_light
|
||||
@cp -f $(CONFIG_DIR)/ws73_cfg_default.ini $(OUTPUT_BIN_DIR)/ws73_cfg.ini
|
||||
@python3 $(SCRIPT_DIR)/hconfig_to_ini.py $(CONFIG_DIR)/ini_map.csv $(SDK_DIR)/Kconfig ${LIGHT_WSCFG_AUTOCONFIG_H} $(OUTPUT_BIN_DIR)/ws73_cfg.ini
|
||||
$(call echo_ok,ini_light file generate success in $(OUTPUT_BIN_DIR)/ws73_cfg.ini!)
|
||||
|
||||
wifi: prepare
|
||||
cd $(WIFI_SRC_DIR) && \
|
||||
CONFIG_WSXX_KERNEL_MODULES_BUILD_SUPPORT=yes\
|
||||
make -j$(CPU_NUM) && cp -f wifi_soc.ko $(OUTPUT_BIN_DIR)/
|
||||
$(call echo_ok,WIFI ko built success in $(OUTPUT_BIN_DIR)/wifi_soc.ko!)
|
||||
|
||||
wifi_light: prepare_light
|
||||
cd $(WIFI_SRC_DIR) && \
|
||||
CONFIG_WSXX_KERNEL_MODULES_BUILD_SUPPORT=yes\
|
||||
make -j$(CPU_NUM) && cp -f wifi_soc.ko $(OUTPUT_BIN_DIR)/
|
||||
$(call echo_ok, wifi_light ko built success in $(OUTPUT_BIN_DIR)/wifi_soc.ko!)
|
||||
|
||||
wifi_clean: prepare
|
||||
cd $(WIFI_SRC_DIR) && \
|
||||
CONFIG_WSXX_KERNEL_MODULES_BUILD_SUPPORT=yes\
|
||||
make clean
|
||||
@find $(WIFI_SRC_DIR) -name "*.o" -exec rm {} \;
|
||||
@find $(WIFI_SRC_DIR) -name "*.cmd" -exec rm {} \;
|
||||
|
||||
platform: prepare ini
|
||||
cd $(PLATFORM_SRC_DIR) && \
|
||||
BUILD_DEVICE_WITH_ROM_REPO=yes\
|
||||
make -j$(CPU_NUM) && cp -f plat_soc.ko $(OUTPUT_BIN_DIR)/
|
||||
$(call echo_ok,platform ko built success in $(OUTPUT_BIN_DIR)/plat_soc.ko!)
|
||||
|
||||
platform_light: prepare_light ini_light
|
||||
cd $(PLATFORM_SRC_DIR) && \
|
||||
BUILD_DEVICE_WITH_ROM_REPO=yes\
|
||||
make -j$(CPU_NUM) && cp -f plat_soc.ko $(OUTPUT_BIN_DIR)/
|
||||
$(call echo_ok,platform_light ko built success in $(OUTPUT_BIN_DIR)/plat_soc.ko!)
|
||||
|
||||
platform_clean: prepare
|
||||
cd $(PLATFORM_SRC_DIR) && \
|
||||
make clean
|
||||
@find $(PLATFORM_SRC_DIR) -name "*.o" -exec rm {} \;
|
||||
@find $(PLATFORM_SRC_DIR) -name "*.cmd" -exec rm {} \;
|
||||
|
||||
ble: prepare
|
||||
cd $(BSLE_SRC_DIR)/ble_driver/linux && \
|
||||
make -j$(CPU_NUM) && cp -f ble_soc.ko $(OUTPUT_BIN_DIR)/
|
||||
$(call echo_ok,ble_linux ko built success in $(OUTPUT_BIN_DIR)/ble_soc.ko!)
|
||||
|
||||
dft_driver: prepare
|
||||
cd $(BSLE_DFT_DRIVER_SRC_DIR)/bsle_dft_driver && \
|
||||
make -j$(CPU_NUM) && cp -f bp_test.ko $(OUTPUT_BIN_DIR)/
|
||||
$(call echo_ok,ble_linux ko built success in $(OUTPUT_BIN_DIR)/bp_test.ko!)
|
||||
|
||||
dft_channel: prepare
|
||||
cd $(BSLE_DFT_DRIVER_SRC_DIR)/bsle_dft_channel/linux && \
|
||||
make -j$(CPU_NUM) && cp -f build/bp_channel $(OUTPUT_BIN_DIR)/
|
||||
$(call echo_ok,bp_channel ko built success in $(OUTPUT_BIN_DIR)/bp_channel!)
|
||||
|
||||
dft_channel_clean: prepare
|
||||
cd $(BSLE_DFT_DRIVER_SRC_DIR)/bsle_dft_channel/linux && \
|
||||
make clean
|
||||
|
||||
dft_ctrl: prepare
|
||||
cd $(BSLE_DFT_DRIVER_SRC_DIR)/bsle_dft_ctrl/linux && \
|
||||
make -j$(CPU_NUM) && cp -f build/sparklinkctrl $(OUTPUT_BIN_DIR)/
|
||||
$(call echo_ok,sparklinkctrl ko built success in $(OUTPUT_BIN_DIR)/sparklinkctrl!)
|
||||
|
||||
dft_ctrl_clean: prepare
|
||||
cd $(BSLE_DFT_DRIVER_SRC_DIR)/bsle_dft_ctrl/linux && \
|
||||
make clean
|
||||
|
||||
ble_light: prepare_light
|
||||
cd $(BSLE_SRC_DIR)/ble_driver/linux && \
|
||||
make -j$(CPU_NUM) && cp -f ble_soc.ko $(OUTPUT_BIN_DIR)/
|
||||
$(call echo_ok,ble_light_linux ko built success in $(OUTPUT_BIN_DIR)/ble_soc.ko!)
|
||||
|
||||
ble_clean: prepare
|
||||
cd $(BSLE_SRC_DIR)/ble_driver/linux && \
|
||||
make clean
|
||||
|
||||
ble_android: prepare
|
||||
cd $(BSLE_SRC_DIR)/ble_driver/android && \
|
||||
make -j$(CPU_NUM) && cp -f ble_soc.ko $(OUTPUT_BIN_DIR)/
|
||||
$(call echo_ok,ble_android ko built success in $(OUTPUT_BIN_DIR)/ble_soc.ko!)
|
||||
|
||||
ble_android_clean: prepare
|
||||
cd $(BSLE_SRC_DIR)/ble_driver/android && \
|
||||
make clean
|
||||
|
||||
sle: prepare
|
||||
cd $(BSLE_SRC_DIR)/sle_driver && \
|
||||
make -j$(CPU_NUM) && cp -f sle_soc.ko $(OUTPUT_BIN_DIR)/
|
||||
$(call echo_ok,sle ko built success in $(OUTPUT_BIN_DIR)/sle_soc.ko!)
|
||||
|
||||
sle_light: prepare_light
|
||||
cd $(BSLE_SRC_DIR)/sle_driver && \
|
||||
make -j$(CPU_NUM) && cp -f sle_soc.ko $(OUTPUT_BIN_DIR)/
|
||||
$(call echo_ok,sle_light ko built success in $(OUTPUT_BIN_DIR)/sle_soc.ko!)
|
||||
|
||||
sle_clean: prepare
|
||||
cd $(BSLE_SRC_DIR)/sle_driver && \
|
||||
make clean
|
||||
|
||||
hso_clean: prepare
|
||||
@rm -rf $(OUTPUT_DIR)/database_es0
|
||||
|
||||
hso: prepare
|
||||
@echo "Generate hdb..."
|
||||
@cp -rf $(CONFIG_DIR)/hso/database_es0 $(OUTPUT_DIR)/
|
||||
@python3 $(SCRIPT_DIR)/build_host_hso.py -c $(CONFIG_DIR)/hso/generate_hdb.ini
|
||||
$(call echo_ok,hso generate success in $(OUTPUT_DIR)/database_es0!)
|
||||
|
||||
tools_clean: prepare
|
||||
@make -f $(OPEN_SROUCE_DIR)/open_source.mk\
|
||||
SDK_OUTPUT_BUILD_DIR=$(OUTPUT_BUILD_DIR)\
|
||||
SDK_OUTPUT_BIN_DIR=$(OUTPUT_BIN_DIR) clean
|
||||
|
||||
tools_clean_light: prepare
|
||||
@make -f $(OPEN_SROUCE_DIR)/open_source_light.mk\
|
||||
SDK_OUTPUT_BUILD_DIR=$(OUTPUT_BUILD_DIR)\
|
||||
SDK_OUTPUT_BIN_DIR=$(OUTPUT_BIN_DIR) clean
|
||||
|
||||
tools: prepare
|
||||
@make -j$(CPU_NUM) -f $(OPEN_SROUCE_DIR)/open_source.mk\
|
||||
SDK_OUTPUT_BUILD_DIR=$(OUTPUT_BUILD_DIR)\
|
||||
SDK_OUTPUT_BIN_DIR=$(OUTPUT_BIN_DIR)
|
||||
$(call echo_ok,open source tools built success!)
|
||||
|
||||
tools_light: prepare
|
||||
@make -j$(CPU_NUM) -f $(OPEN_SROUCE_DIR)/open_source_light.mk\
|
||||
SDK_OUTPUT_BUILD_DIR=$(OUTPUT_BUILD_DIR)\
|
||||
SDK_OUTPUT_BIN_DIR=$(OUTPUT_BIN_DIR)
|
||||
$(call echo_ok,open source tools built success!)
|
||||
|
||||
BIN
application/bin/1155/sparklinkchba
Executable file
BIN
application/bin/1155/sparklinkchba
Executable file
Binary file not shown.
BIN
application/bin/1155/sparklinkctrl
Executable file
BIN
application/bin/1155/sparklinkctrl
Executable file
Binary file not shown.
BIN
application/bin/1155/sparklinkd
Executable file
BIN
application/bin/1155/sparklinkd
Executable file
Binary file not shown.
BIN
application/bin/1156/sparklinkchba
Executable file
BIN
application/bin/1156/sparklinkchba
Executable file
Binary file not shown.
BIN
application/bin/1156/sparklinkctrl
Executable file
BIN
application/bin/1156/sparklinkctrl
Executable file
Binary file not shown.
BIN
application/bin/1156/sparklinkd
Executable file
BIN
application/bin/1156/sparklinkd
Executable file
Binary file not shown.
BIN
application/bin/1156_iot/sparklinkchba
Executable file
BIN
application/bin/1156_iot/sparklinkchba
Executable file
Binary file not shown.
BIN
application/bin/1156_iot/sparklinkctrl
Executable file
BIN
application/bin/1156_iot/sparklinkctrl
Executable file
Binary file not shown.
BIN
application/bin/1156_iot/sparklinkd
Executable file
BIN
application/bin/1156_iot/sparklinkd
Executable file
Binary file not shown.
BIN
application/bin/1156_ont/sparklinkchba
Executable file
BIN
application/bin/1156_ont/sparklinkchba
Executable file
Binary file not shown.
BIN
application/bin/1156_ont/sparklinkctrl
Executable file
BIN
application/bin/1156_ont/sparklinkctrl
Executable file
Binary file not shown.
BIN
application/bin/1156_ont/sparklinkd
Executable file
BIN
application/bin/1156_ont/sparklinkd
Executable file
Binary file not shown.
BIN
application/bin/3516V610/bluetoothctrl
Executable file
BIN
application/bin/3516V610/bluetoothctrl
Executable file
Binary file not shown.
BIN
application/bin/3516V610/bluetoothd
Executable file
BIN
application/bin/3516V610/bluetoothd
Executable file
Binary file not shown.
BIN
application/bin/3516V610/bp_channel
Executable file
BIN
application/bin/3516V610/bp_channel
Executable file
Binary file not shown.
BIN
application/bin/3518_usb/ble/bluetoothctrl
Executable file
BIN
application/bin/3518_usb/ble/bluetoothctrl
Executable file
Binary file not shown.
BIN
application/bin/3518_usb/ble/bluetoothd
Executable file
BIN
application/bin/3518_usb/ble/bluetoothd
Executable file
Binary file not shown.
BIN
application/bin/3518_usb/sle/sle_chba.ko
Normal file
BIN
application/bin/3518_usb/sle/sle_chba.ko
Normal file
Binary file not shown.
BIN
application/bin/3518_usb/sle/sparklinkchba
Executable file
BIN
application/bin/3518_usb/sle/sparklinkchba
Executable file
Binary file not shown.
BIN
application/bin/3518_usb/sle/sparklinkctrl
Executable file
BIN
application/bin/3518_usb/sle/sparklinkctrl
Executable file
Binary file not shown.
BIN
application/bin/3518_usb/sle/sparklinkd
Executable file
BIN
application/bin/3518_usb/sle/sparklinkd
Executable file
Binary file not shown.
BIN
application/bin/3519d/sle_chba.ko
Normal file
BIN
application/bin/3519d/sle_chba.ko
Normal file
Binary file not shown.
BIN
application/bin/3519d/sparklinkchba
Executable file
BIN
application/bin/3519d/sparklinkchba
Executable file
Binary file not shown.
BIN
application/bin/3519d/sparklinkctrl
Executable file
BIN
application/bin/3519d/sparklinkctrl
Executable file
Binary file not shown.
BIN
application/bin/3519d/sparklinkd
Executable file
BIN
application/bin/3519d/sparklinkd
Executable file
Binary file not shown.
BIN
application/bin/7205_sdio/sparklinkchba
Executable file
BIN
application/bin/7205_sdio/sparklinkchba
Executable file
Binary file not shown.
BIN
application/bin/7205_sdio/sparklinkctrl
Executable file
BIN
application/bin/7205_sdio/sparklinkctrl
Executable file
Binary file not shown.
BIN
application/bin/7205_sdio/sparklinkd
Executable file
BIN
application/bin/7205_sdio/sparklinkd
Executable file
Binary file not shown.
BIN
application/bin/7205_usb/sparklinkchba
Executable file
BIN
application/bin/7205_usb/sparklinkchba
Executable file
Binary file not shown.
BIN
application/bin/7205_usb/sparklinkctrl
Executable file
BIN
application/bin/7205_usb/sparklinkctrl
Executable file
Binary file not shown.
BIN
application/bin/7205_usb/sparklinkd
Executable file
BIN
application/bin/7205_usb/sparklinkd
Executable file
Binary file not shown.
BIN
application/bin/920/sparklinkchba
Executable file
BIN
application/bin/920/sparklinkchba
Executable file
Binary file not shown.
BIN
application/bin/920/sparklinkctrl
Executable file
BIN
application/bin/920/sparklinkctrl
Executable file
Binary file not shown.
BIN
application/bin/920/sparklinkd
Executable file
BIN
application/bin/920/sparklinkd
Executable file
Binary file not shown.
BIN
application/bin/9633/sparklinkchba
Executable file
BIN
application/bin/9633/sparklinkchba
Executable file
Binary file not shown.
BIN
application/bin/9633/sparklinkctrl
Executable file
BIN
application/bin/9633/sparklinkctrl
Executable file
Binary file not shown.
BIN
application/bin/9633/sparklinkd
Executable file
BIN
application/bin/9633/sparklinkd
Executable file
Binary file not shown.
BIN
application/bin/A40I/ble/bluetoothctrl
Executable file
BIN
application/bin/A40I/ble/bluetoothctrl
Executable file
Binary file not shown.
BIN
application/bin/A40I/ble/bluetoothd
Executable file
BIN
application/bin/A40I/ble/bluetoothd
Executable file
Binary file not shown.
BIN
application/bin/A40I/sle/sparklinkctrl
Executable file
BIN
application/bin/A40I/sle/sparklinkctrl
Executable file
Binary file not shown.
BIN
application/bin/A40I/sle/sparklinkd
Executable file
BIN
application/bin/A40I/sle/sparklinkd
Executable file
Binary file not shown.
BIN
application/bin/rk3568/ble/bluetoothctrl
Executable file
BIN
application/bin/rk3568/ble/bluetoothctrl
Executable file
Binary file not shown.
BIN
application/bin/rk3568/ble/bluetoothd
Executable file
BIN
application/bin/rk3568/ble/bluetoothd
Executable file
Binary file not shown.
BIN
application/bin/rk3568/sle/sparklinkctrl
Executable file
BIN
application/bin/rk3568/sle/sparklinkctrl
Executable file
Binary file not shown.
BIN
application/bin/rk3568/sle/sparklinkd
Executable file
BIN
application/bin/rk3568/sle/sparklinkd
Executable file
Binary file not shown.
BIN
application/bin/rv1126/sparklinkchba
Executable file
BIN
application/bin/rv1126/sparklinkchba
Executable file
Binary file not shown.
BIN
application/bin/rv1126/sparklinkctrl
Executable file
BIN
application/bin/rv1126/sparklinkctrl
Executable file
Binary file not shown.
BIN
application/bin/rv1126/sparklinkd
Executable file
BIN
application/bin/rv1126/sparklinkd
Executable file
Binary file not shown.
BIN
application/bin/stm32mp157/ble/bluetoothctrl
Executable file
BIN
application/bin/stm32mp157/ble/bluetoothctrl
Executable file
Binary file not shown.
BIN
application/bin/stm32mp157/ble/bluetoothd
Executable file
BIN
application/bin/stm32mp157/ble/bluetoothd
Executable file
Binary file not shown.
BIN
application/bin/stm32mp157/sle/sparklinkctrl
Executable file
BIN
application/bin/stm32mp157/sle/sparklinkctrl
Executable file
Binary file not shown.
BIN
application/bin/stm32mp157/sle/sparklinkd
Executable file
BIN
application/bin/stm32mp157/sle/sparklinkd
Executable file
Binary file not shown.
BIN
application/bin/t23/bluetoothctrl
Executable file
BIN
application/bin/t23/bluetoothctrl
Executable file
Binary file not shown.
BIN
application/bin/t23/bluetoothd
Executable file
BIN
application/bin/t23/bluetoothd
Executable file
Binary file not shown.
BIN
application/bin/t41/sparklinkchba
Executable file
BIN
application/bin/t41/sparklinkchba
Executable file
Binary file not shown.
BIN
application/bin/t41/sparklinkctrl
Executable file
BIN
application/bin/t41/sparklinkctrl
Executable file
Binary file not shown.
BIN
application/bin/t41/sparklinkd
Executable file
BIN
application/bin/t41/sparklinkd
Executable file
Binary file not shown.
50
application/dft/bsle_dft_channel/android/Android.mk
Normal file
50
application/dft/bsle_dft_channel/android/Android.mk
Normal file
@ -0,0 +1,50 @@
|
||||
# Copyright 2006 The Android Open Source Project
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
SRC_FILE_LIST := $(wildcard $(LOCAL_PATH)/../../../../driver/platform/libc_sec/src/*.c)
|
||||
LOCAL_SRC_FILES += $(SRC_FILE_LIST:$(LOCAL_PATH)/%=%)
|
||||
|
||||
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../driver/platform/libc_sec/include
|
||||
|
||||
LOCAL_CFLAGS += -Os -pipe
|
||||
LOCAL_CFLAGS += -fno-short-enums
|
||||
LOCAL_CFLAGS += -Wall -Wextra -Wundef -Wstrict-prototypes -Wfloat-equal -Wunused
|
||||
LOCAL_CFLAGS += -DNDEBUG -DSECUREC_SUPPORT_STRTOLD=1 -DWSCFG_ANDROID
|
||||
LOCAL_LDFLGAS := -s -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now
|
||||
LOCAL_MULTILIB := both
|
||||
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/lib
|
||||
|
||||
LOCAL_MODULE := libc_sec_bp
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
$(info nearlink-PRODUCT_OUT=$(PRODUCT_OUT))
|
||||
TARGET_NEARLINK_PATH := $(PRODUCT_OUT)/vendor
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
../main.c \
|
||||
../dft_channel/bsle_dft_chan_user.c \
|
||||
../dft_shell/bsle_dft_at_server.c \
|
||||
../../bsle_dft_common/dft_msgqueue/msg_queue.c
|
||||
|
||||
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../dft_channel
|
||||
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../dft_shell
|
||||
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../driver/platform/libc_sec/include
|
||||
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../driver/platform/osal/include
|
||||
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../driver/platform/drv/device/romable/include
|
||||
|
||||
LOCAL_CFLAGS += -Werror
|
||||
LOCAL_CFLAGS += -Wall
|
||||
LOCAL_CFLAGS += -DHAVE_CONFIG_H
|
||||
LOCAL_CFLAGS += -D_FILE_OFFSET_BITS=64
|
||||
LOCAL_CFLAGS += -DWSCFG_ANDROID
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := libc_sec_bp
|
||||
|
||||
LOCAL_MODULE := bp_channel
|
||||
|
||||
LOCAL_MODULE_PATH := $(TARGET_NEARLINK_PATH)/bin
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
set(
|
||||
sle_comm_src_list
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bsle_dft_chan_user.c
|
||||
)
|
||||
set(BTH_SLE_RAM_LIST "${BTH_SLE_RAM_LIST}" "${sle_comm_src_list}" CACHE INTERNAL "sle ram obj list" FORCE)
|
||||
@ -0,0 +1,218 @@
|
||||
/*
|
||||
* Copyright (c) @CompanyNameMagicTag 2023-2023. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <asm/types.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/socket.h>
|
||||
#include "securec.h"
|
||||
#include "bsle_dft_chan_user.h"
|
||||
|
||||
static struct sockaddr_nl g_dst_addr = {
|
||||
.nl_family = AF_NETLINK,
|
||||
.nl_pad = 0,
|
||||
.nl_pid = 0,
|
||||
.nl_groups = 0,
|
||||
};
|
||||
|
||||
static struct sockaddr_nl g_src_addr_hci = {
|
||||
.nl_family = AF_NETLINK,
|
||||
.nl_pad = 0,
|
||||
.nl_pid = SLE_CHAN_USER_PORT_HCI,
|
||||
.nl_groups = 0,
|
||||
};
|
||||
|
||||
static struct sockaddr_nl g_src_addr_tm = {
|
||||
.nl_family = AF_NETLINK,
|
||||
.nl_pad = 0,
|
||||
.nl_pid = BLE_CHAN_USER_PORT_HCI,
|
||||
.nl_groups = 0,
|
||||
};
|
||||
|
||||
sle_chan_cfg_t g_sle_chan_cfg[SLE_CHAN_MAX] = {
|
||||
{
|
||||
.chan_id = SLE_CHAN_HCI,
|
||||
.user_port = SLE_CHAN_USER_PORT_HCI,
|
||||
.netlink_protocol = SLE_CHAN_NETLINK_HCI,
|
||||
.src_addr = &g_src_addr_hci,
|
||||
.dst_addr = &g_dst_addr,
|
||||
.nl_fd = -1,
|
||||
},
|
||||
{
|
||||
.chan_id = BLE_CHAN_HCI,
|
||||
.user_port = BLE_CHAN_USER_PORT_HCI,
|
||||
.netlink_protocol = BLE_CHAN_NETLINK_HCI,
|
||||
.src_addr = &g_src_addr_tm,
|
||||
.dst_addr = &g_dst_addr,
|
||||
.nl_fd = -1,
|
||||
}
|
||||
};
|
||||
|
||||
static sle_chan_cfg_t *sle_chan_find_cfg(sle_chan_id_t chan_id)
|
||||
{
|
||||
for (int i = 0; i < SLE_CHAN_MAX; i++) {
|
||||
if (g_sle_chan_cfg[i].chan_id == chan_id) {
|
||||
return &g_sle_chan_cfg[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void sle_register_recv_data_cb(sle_chan_id_t chan_id, sle_recv_data_cb_t cb)
|
||||
{
|
||||
sle_chan_cfg_t *chan_cfg = sle_chan_find_cfg(chan_id);
|
||||
if (chan_cfg == NULL) {
|
||||
printf("ERROR: [sle_register_recv_data_cb] not find chan, chan_id: %d\n", chan_id);
|
||||
return;
|
||||
}
|
||||
chan_cfg->recv = cb;
|
||||
}
|
||||
void sle_hci_register_recv_data_cb(sle_recv_data_cb_t cb)
|
||||
{
|
||||
sle_register_recv_data_cb(SLE_CHAN_HCI, cb);
|
||||
}
|
||||
|
||||
void ble_hci_register_recv_data_cb(sle_recv_data_cb_t cb)
|
||||
{
|
||||
sle_register_recv_data_cb(BLE_CHAN_HCI, cb);
|
||||
}
|
||||
|
||||
static int sle_chan_recv_data(sle_chan_id_t chan_id, uint8_t **data_buf, uint16_t *buf_size)
|
||||
{
|
||||
sle_nl_msg_t sle_msg;
|
||||
socklen_t addr_len;
|
||||
size_t data_len;
|
||||
sle_chan_cfg_t *chan_cfg = NULL;
|
||||
|
||||
memset_s(&sle_msg, sizeof(sle_nl_msg_t), 0, sizeof(sle_nl_msg_t));
|
||||
chan_cfg = sle_chan_find_cfg(chan_id);
|
||||
if (data_buf == NULL || buf_size == NULL || chan_cfg == NULL) {
|
||||
printf("ERROR: [sle_chan_recv_data] not find chan, chan_id: %d\n", chan_id);
|
||||
return SLE_CHAN_PARAM_INVALID;
|
||||
}
|
||||
if (chan_cfg->nl_fd == -1) {
|
||||
printf("ERROR: [sle_chan_recv_data] chan not init: %d\n", chan_id);
|
||||
return SLE_CHAN_FAILED;
|
||||
}
|
||||
int ret = recvfrom(chan_cfg->nl_fd,
|
||||
&sle_msg,
|
||||
sizeof(sle_nl_msg_t),
|
||||
0,
|
||||
(struct sockaddr *)(uintptr_t)chan_cfg->dst_addr,
|
||||
&addr_len);
|
||||
if (!ret) {
|
||||
printf("ERROR: recvfrom error: %d\n", ret);
|
||||
return SLE_CHAN_FAILED;
|
||||
}
|
||||
data_len = sle_msg.hdr.nlmsg_len - sizeof(struct nlmsghdr);
|
||||
|
||||
if (data_len > sle_msg.hdr.nlmsg_len) {
|
||||
return SLE_CHAN_FAILED;
|
||||
}
|
||||
*data_buf = (uint8_t *)malloc(data_len);
|
||||
if (*data_buf == NULL) {
|
||||
printf("ERROR: [sle_chan_recv_data] memory malloc failed!\n");
|
||||
return SLE_CHAN_MEMORY_ERR;
|
||||
}
|
||||
if (memcpy_s(*data_buf, data_len, sle_msg.data, data_len) != EOK) {
|
||||
printf("ERROR: [sle_chan_recv_data] memcpy_s failed!\n");
|
||||
}
|
||||
*buf_size = data_len;
|
||||
if (chan_cfg->recv) {
|
||||
chan_cfg->recv(sle_msg.data, data_len);
|
||||
}
|
||||
return SLE_CHAN_SUCCESS;
|
||||
}
|
||||
|
||||
int sle_hci_chan_recv_data(uint8_t **data_buf, uint16_t *buf_size)
|
||||
{
|
||||
return sle_chan_recv_data(SLE_CHAN_HCI, data_buf, buf_size);
|
||||
}
|
||||
int ble_hci_chan_recv_data(uint8_t **data_buf, uint16_t *buf_size)
|
||||
{
|
||||
return sle_chan_recv_data(BLE_CHAN_HCI, data_buf, buf_size);
|
||||
}
|
||||
static int sle_chan_send_data(sle_chan_id_t chan_id, uint8_t *data, uint16_t data_len)
|
||||
{
|
||||
sle_chan_cfg_t *chan_cfg;
|
||||
struct nlmsghdr *nlh;
|
||||
chan_cfg = sle_chan_find_cfg(chan_id);
|
||||
if (chan_cfg == NULL) {
|
||||
printf("ERROR: [sle_chan_send] not find chan, chan_id: %d\n", chan_id);
|
||||
return SLE_CHAN_PARAM_INVALID;
|
||||
}
|
||||
if (chan_cfg->nl_fd == -1) {
|
||||
printf("ERROR: [sle_chan_send] chan not init: %d\n", chan_id);
|
||||
return SLE_CHAN_FAILED;
|
||||
}
|
||||
nlh = (struct nlmsghdr *)malloc(NLMSG_SPACE(data_len)); // nlh数据发出之后再内核态释放
|
||||
if (nlh == NULL) {
|
||||
printf("ERROR: [sle_chan_send] nlh malloc fail\n");
|
||||
return SLE_CHAN_FAILED;
|
||||
}
|
||||
if (memset_s(nlh, NLMSG_SPACE(data_len), 0, sizeof(struct nlmsghdr)) != EOK) {
|
||||
printf("ERROR: [sle_chan_recv_data] memset_s failed!\n");
|
||||
}
|
||||
nlh->nlmsg_len = (uint32_t)NLMSG_LENGTH(data_len);
|
||||
/* 修改成进程id, getpid接口 */
|
||||
nlh->nlmsg_pid = chan_cfg->user_port;
|
||||
if (memcpy_s(NLMSG_DATA(nlh), data_len, data, data_len) != EOK) {
|
||||
printf("ERROR: [sle_chan_recv_data] memcpy_s failed!\n");
|
||||
}
|
||||
int ret = sendto(chan_cfg->nl_fd,
|
||||
nlh,
|
||||
nlh->nlmsg_len,
|
||||
0,
|
||||
(struct sockaddr *)(uintptr_t)chan_cfg->dst_addr,
|
||||
sizeof(struct sockaddr_nl));
|
||||
free(nlh);
|
||||
if (!ret) {
|
||||
printf("ERROR: sendto error: %d\n", ret);
|
||||
return SLE_CHAN_FAILED;
|
||||
}
|
||||
return SLE_CHAN_SUCCESS;
|
||||
}
|
||||
|
||||
int sle_hci_chan_send_data(uint8_t *data, uint16_t data_len)
|
||||
{
|
||||
return sle_chan_send_data(SLE_CHAN_HCI, data, data_len);
|
||||
}
|
||||
|
||||
int ble_hci_chan_send_data(uint8_t *data, uint16_t data_len)
|
||||
{
|
||||
return sle_chan_send_data(BLE_CHAN_HCI, data, data_len);
|
||||
}
|
||||
void sle_chan_init(void)
|
||||
{
|
||||
for (int i = 0; i < SLE_CHAN_MAX; i++) {
|
||||
int nl_fd = socket(AF_NETLINK, SOCK_RAW, g_sle_chan_cfg[i].netlink_protocol);
|
||||
if (nl_fd == -1) {
|
||||
printf("ERROR: create socket error\n");
|
||||
return;
|
||||
}
|
||||
if (bind(nl_fd, (struct sockaddr *)(uintptr_t)g_sle_chan_cfg[i].src_addr, sizeof(struct sockaddr_nl)) != 0) {
|
||||
printf("ERROR: bind error\n");
|
||||
close(nl_fd);
|
||||
return;
|
||||
}
|
||||
g_sle_chan_cfg[i].nl_fd = nl_fd;
|
||||
}
|
||||
}
|
||||
|
||||
void sle_chan_deinit(void)
|
||||
{
|
||||
for (int i = 0; i < SLE_CHAN_MAX; i++) {
|
||||
if (g_sle_chan_cfg[i].nl_fd != -1) {
|
||||
close(g_sle_chan_cfg[i].nl_fd);
|
||||
g_sle_chan_cfg[i].nl_fd = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) @CompanyNameMagicTag 2023-2023. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef BSLE_DFT_CHAN_USER_H
|
||||
#define BSLE_DFT_CHAN_USER_H
|
||||
#include <linux/netlink.h>
|
||||
|
||||
/* 创建nl通道和接收内核数据在一个进程中实现(进程ID相同) */
|
||||
#define MSG_LEN 256 // 需要修改成sle业务里面数据量的宏定义
|
||||
typedef struct sle_nl_msg {
|
||||
struct nlmsghdr hdr;
|
||||
uint8_t data[MSG_LEN];
|
||||
} sle_nl_msg_t;
|
||||
|
||||
|
||||
typedef void (*sle_recv_data_cb_t)(uint8_t *data, uint16_t datalen);
|
||||
|
||||
typedef enum {
|
||||
SLE_CHAN_SUCCESS = 0,
|
||||
SLE_CHAN_FAILED = -1,
|
||||
SLE_CHAN_MEMORY_ERR = -2,
|
||||
SLE_CHAN_PARAM_INVALID = -3,
|
||||
} sle_chan_error_code_t;
|
||||
|
||||
typedef enum {
|
||||
SLE_CHAN_USER_PORT_HCI = 100,
|
||||
BLE_CHAN_USER_PORT_HCI,
|
||||
} sle_chan_user_port_t;
|
||||
|
||||
typedef enum {
|
||||
SLE_CHAN_NETLINK_HCI = 22,
|
||||
BLE_CHAN_NETLINK_HCI,
|
||||
} sle_chan_netlink_protocol_t;
|
||||
|
||||
typedef enum {
|
||||
SLE_CHAN_HCI,
|
||||
BLE_CHAN_HCI,
|
||||
SLE_CHAN_MAX,
|
||||
} sle_chan_id_t;
|
||||
|
||||
typedef struct sle_chan_cfg {
|
||||
sle_chan_id_t chan_id;
|
||||
sle_chan_user_port_t user_port;
|
||||
sle_chan_netlink_protocol_t netlink_protocol;
|
||||
struct sockaddr_nl *src_addr;
|
||||
struct sockaddr_nl *dst_addr;
|
||||
sle_recv_data_cb_t recv;
|
||||
int nl_fd;
|
||||
} sle_chan_cfg_t;
|
||||
|
||||
void sle_hci_register_recv_data_cb(sle_recv_data_cb_t cb);
|
||||
void ble_hci_register_recv_data_cb(sle_recv_data_cb_t cb);
|
||||
|
||||
int ble_hci_chan_recv_data(uint8_t **data_buf, uint16_t *buf_size);
|
||||
int sle_hci_chan_recv_data(uint8_t **data_buf, uint16_t *buf_size);
|
||||
|
||||
int sle_hci_chan_send_data(uint8_t *data, uint16_t data_len);
|
||||
int ble_hci_chan_send_data(uint8_t *data, uint16_t data_len);
|
||||
|
||||
void sle_chan_init(void);
|
||||
void sle_chan_deinit(void);
|
||||
|
||||
#endif /* __SLE_CHAN_USER_H */
|
||||
@ -0,0 +1,5 @@
|
||||
set(
|
||||
sle_comm_src_list
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bsle_dft_at_server.c
|
||||
)
|
||||
set(BTH_SLE_RAM_LIST "${BTH_SLE_RAM_LIST}" "${sle_comm_src_list}" CACHE INTERNAL "sle ram obj list" FORCE)
|
||||
1248
application/dft/bsle_dft_channel/dft_shell/bsle_dft_at_server.c
Normal file
1248
application/dft/bsle_dft_channel/dft_shell/bsle_dft_at_server.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) @CompanyNameMagicTag 2023-2023. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef BSLE_DFT_AT_SERVER
|
||||
#define BSLE_DFT_AT_SERVER
|
||||
int cmd_main_add_functions(void);
|
||||
/* DFT_AGV_NUM_TWO */
|
||||
#define DFT_AGV_NUM_TWO 2
|
||||
#define DFT_AGV_INDEX_ZERO 0
|
||||
#define DFT_AGV_INDEX_ONE 1
|
||||
#define DFT_AGV_INDEX_TWO 2
|
||||
#define DFT_AGV_INDEX_THREE 3
|
||||
#define DFT_AGV_INDEX_FOUR 4
|
||||
#define DFT_AGV_INDEX_FIVE 5
|
||||
#define DFT_AGV_INDEX_SIX 6
|
||||
#define DFT_AGV_INDEX_SEVEN 7
|
||||
#define DFT_AGV_INDEX_EIGHT 8
|
||||
#define DFT_AGV_INDEX_NINE 9
|
||||
#define DFT_AGV_INDEX_TEN 10
|
||||
#define DFT_AGV_INDEX_TRIRTEEN 13
|
||||
#define DFT_AGV_INDEX_FIFTEEN 15
|
||||
#define DFT_AGV_INDEX_SEVENTEEN 17
|
||||
#define DFT_AGV_INDEX_NINETEEN 19
|
||||
#define DFT_AGV_INDEX_TWENTY_ONE 21
|
||||
#define DFT_AGV_INDEX_TWENTY_THREE 23
|
||||
#define DFT_AGV_INDEX_THIRTY_FIVE 35
|
||||
#endif
|
||||
70
application/dft/bsle_dft_channel/linux/CMakeLists.txt
Normal file
70
application/dft/bsle_dft_channel/linux/CMakeLists.txt
Normal file
@ -0,0 +1,70 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project("bp_channel")
|
||||
get_filename_component(CURRENT_SOURCE_DIR "" ABSOLUTE)
|
||||
|
||||
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../../../driver/platform)
|
||||
set(CMAKE_SEC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../driver/platform/libc_sec)
|
||||
set(CMAKE_OSAL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../driver/platform/osal)
|
||||
set(CMAKE_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../)
|
||||
elseif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../utils/securec)
|
||||
set(CMAKE_SEC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../utils/securec)
|
||||
set(CMAKE_OSAL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../utils/osal)
|
||||
set(CMAKE_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../)
|
||||
endif()
|
||||
|
||||
add_definitions(${defines} -D BTH_TEST -D CONFIG_GLE -D BT_MANAGER_DEPLOYED=2 -D BT_CODEC_TID=2 -D __BTC_INLINE=)
|
||||
|
||||
set(headers
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../dft_channel
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../dft_shell
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../bsle_dft_common/dft_msgqueue
|
||||
${CMAKE_SEC_DIR}/include
|
||||
${CMAKE_OSAL_DIR}/linux/userspace/include
|
||||
${CMAKE_ROOT_DIR}/driver/platform/drv/include
|
||||
${CMAKE_ROOT_DIR}/driver/platform/osal/linux
|
||||
${CMAKE_ROOT_DIR}/utils/osal/linux/
|
||||
${CMAKE_ROOT_DIR}/utils/osal/linux/userspace/include/memory
|
||||
${CMAKE_ROOT_DIR}/include/native
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/platform
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/product
|
||||
)
|
||||
|
||||
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../../../driver/platform)
|
||||
set(headers
|
||||
${headers}
|
||||
${CMAKE_OSAL_DIR}/include
|
||||
)
|
||||
endif()
|
||||
|
||||
set(sources
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../main.c
|
||||
${CMAKE_SEC_DIR}/src/memcpy_s.c
|
||||
${CMAKE_SEC_DIR}/src/memset_s.c
|
||||
${CMAKE_SEC_DIR}/src/memmove_s.c
|
||||
${CMAKE_SEC_DIR}/src/sprintf_s.c
|
||||
${CMAKE_SEC_DIR}/src/vsprintf_s.c
|
||||
${CMAKE_SEC_DIR}/src/strcpy_s.c
|
||||
${CMAKE_SEC_DIR}/src/strncpy_s.c
|
||||
${CMAKE_SEC_DIR}/src/strcat_s.c
|
||||
${CMAKE_SEC_DIR}/src/secureprintoutput_a.c
|
||||
)
|
||||
|
||||
add_subdirectory(../dft_channel ../build/channel_build)
|
||||
add_subdirectory(../dft_shell ../build/shell_build)
|
||||
add_subdirectory(../../bsle_dft_common/dft_msgqueue ../build/msgqueue_build)
|
||||
|
||||
# add_library生成.a和add_executable可执行文件二选一放开
|
||||
# add_library(sparklinkd STATIC ${sources})
|
||||
list(APPEND CFLAGS -s -fPIE -pie -W -Wall -Wl,-z,now -Wl,-z,relro -fstack-protector-all -Os)
|
||||
|
||||
add_executable(bp_channel ${sources} ${BTH_SLE_RAM_LIST})
|
||||
target_include_directories(bp_channel PRIVATE ${headers})
|
||||
target_compile_options(bp_channel PRIVATE ${CFLAGS})
|
||||
target_link_libraries(bp_channel pthread ${CFLAGS})
|
||||
|
||||
#上板需要设置如下交叉编译链,本地可以通过删除交叉编译链配置进行验证
|
||||
set(CMAKE_C_COMPILER ${WSCFG_CROSS_COMPILE}gcc)
|
||||
set(CMAKE_CXX_COMPILER ${WSCFG_CROSS_COMPILE}g++)
|
||||
|
||||
message("CMAKE_CURRENT_SOURCE_DIR:" ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
8
application/dft/bsle_dft_channel/linux/Makefile
Normal file
8
application/dft/bsle_dft_channel/linux/Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
include $(WSCFG_KCONFIG_CONFIG)
|
||||
STRIP := $(WSCFG_CROSS_COMPILE)strip
|
||||
$(warning defconfig: ================ARCH=$(WSCFG_ARCH_NAME) CROSS_COMPILE=$(WSCFG_CROSS_COMPILE)=======================)
|
||||
all:
|
||||
mkdir -p build && cd build && cmake ../ -DWSCFG_CROSS_COMPILE=${WSCFG_CROSS_COMPILE} && make -j
|
||||
$(STRIP) --strip-unneeded -s build/bp_channel
|
||||
clean:
|
||||
rm -rf build
|
||||
16
application/dft/bsle_dft_channel/linux/release.mk
Normal file
16
application/dft/bsle_dft_channel/linux/release.mk
Normal file
@ -0,0 +1,16 @@
|
||||
CUR_MK_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
CUR_MK_DIR := $(dir $(CUR_MK_PATH))
|
||||
CUR_MK_DIR := $(realpath $(CUR_MK_DIR))
|
||||
|
||||
# 项目顶层目录(不要其他Makefile中使用)
|
||||
_TOP_DIR := $(realpath $(CUR_MK_DIR))
|
||||
_PLATFORM_DIR := $(realpath $(CUR_MK_DIR)/../../../../platform)
|
||||
|
||||
# 平台目录
|
||||
PLATFORM_INC_DIR := $(_PLATFORM_DIR)/inc
|
||||
PLATFORM_CFG_DIR := $(_PLATFORM_DIR)/cfg
|
||||
PLATFORM_DRV_DIR := $(_PLATFORM_DIR)/drv
|
||||
PLATFORM_DEVICE_DIR := $(_PLATFORM_DIR)/drv/device
|
||||
PLATFORM_HCC_DIR := $(_PLATFORM_DIR)/hcc
|
||||
PLATFORM_OSAL_DIR := $(_PLATFORM_DIR)/osal
|
||||
PLATFORM_LIBC_SEC_DIR := $(_PLATFORM_DIR)/libc_sec
|
||||
89
application/dft/bsle_dft_channel/main.c
Normal file
89
application/dft/bsle_dft_channel/main.c
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* SLE main entry
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include <malloc.h>
|
||||
#include "bsle_dft_chan_user.h"
|
||||
#include "bsle_dft_at_server.h"
|
||||
|
||||
void *sle_hci_recv_data_task(void *arg)
|
||||
{
|
||||
(void)(arg);
|
||||
uint8_t *data_buf = NULL;
|
||||
uint16_t data_len = 0;
|
||||
int ret;
|
||||
|
||||
for (;;) {
|
||||
if (data_buf != NULL && data_len > 0) {
|
||||
free(data_buf);
|
||||
data_buf = NULL;
|
||||
data_len = 0;
|
||||
}
|
||||
ret = sle_hci_chan_recv_data(&data_buf, &data_len);
|
||||
if (ret != 0) {
|
||||
printf("sle_hci_recv_data_task failed:0x%x\n", ret);
|
||||
continue;
|
||||
}
|
||||
printf("CMD Send OK\n");
|
||||
for (uint32_t i = 0; i < data_len; i++) {
|
||||
printf("%02X ", data_buf[i]);
|
||||
}
|
||||
printf("\n");
|
||||
#ifdef WSCFG_ANDROID
|
||||
printf("#\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void *ble_hci_recv_data_task(void *arg)
|
||||
{
|
||||
(void)(arg);
|
||||
uint8_t *data_buf = NULL;
|
||||
uint16_t data_len = 0;
|
||||
int ret;
|
||||
|
||||
for (;;) {
|
||||
if (data_buf != NULL && data_len > 0) {
|
||||
free(data_buf);
|
||||
data_buf = NULL;
|
||||
data_len = 0;
|
||||
}
|
||||
ret = ble_hci_chan_recv_data(&data_buf, &data_len);
|
||||
if (ret != 0) {
|
||||
printf("ble_hci_recv_data_task failed:0x%x\n", ret);
|
||||
continue;
|
||||
}
|
||||
printf("CMD Send OK\n");
|
||||
for (uint32_t i = 0; i < data_len; i++) {
|
||||
printf("%02X ", data_buf[i]);
|
||||
}
|
||||
printf("\n");
|
||||
#ifdef WSCFG_ANDROID
|
||||
printf("#\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("main start.\n\n");
|
||||
sle_chan_init();
|
||||
printf("sle_chan_init\n");
|
||||
pthread_t thread_id = (pthread_t)(-1);
|
||||
pthread_attr_t thread_attr;
|
||||
pthread_attr_init(&thread_attr);
|
||||
pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_JOINABLE);
|
||||
if (pthread_create(&thread_id, &thread_attr, sle_hci_recv_data_task, NULL) != 0) {
|
||||
printf("create sle_hci_recv_data_task fail.\n");
|
||||
return -1;
|
||||
}
|
||||
if (pthread_create(&thread_id, &thread_attr, ble_hci_recv_data_task, NULL) != 0) {
|
||||
printf("create ble_hci_recv_data_task fail.\n");
|
||||
return -1;
|
||||
}
|
||||
cmd_main_add_functions();
|
||||
printf("main end.\n\n");
|
||||
return 0;
|
||||
}
|
||||
5
application/dft/bsle_dft_common/dft_msgqueue/CMakeLists.txt
Executable file
5
application/dft/bsle_dft_common/dft_msgqueue/CMakeLists.txt
Executable file
@ -0,0 +1,5 @@
|
||||
set(
|
||||
sle_comm_src_list
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/msg_queue.c
|
||||
)
|
||||
set(BTH_SLE_RAM_LIST "${BTH_SLE_RAM_LIST}" "${sle_comm_src_list}" CACHE INTERNAL "sle ram obj list" FORCE)
|
||||
91
application/dft/bsle_dft_common/dft_msgqueue/msg_queue.c
Normal file
91
application/dft/bsle_dft_common/dft_msgqueue/msg_queue.c
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) @CompanyNameMagicTag 2023-2023. All rights reserved.
|
||||
*/
|
||||
#include "securec.h"
|
||||
#include "msg_queue.h"
|
||||
|
||||
static int test_suite_creat_msg_queue(int def)
|
||||
{
|
||||
key_t queue_id = ftok(PATH, PROJ_ID); /* queue_id标识唯一的消息队列 */
|
||||
if (queue_id < 0) {
|
||||
perror("ftok");
|
||||
return -EINVAL;
|
||||
}
|
||||
int msgqueue_id = msgget(queue_id, def);
|
||||
if (msgqueue_id < 0) {
|
||||
perror("msgget"); /* 创建消息队列失败 */
|
||||
return -EINVAL;
|
||||
}
|
||||
return msgqueue_id;
|
||||
}
|
||||
|
||||
int test_suite_creat_queue(void)
|
||||
{
|
||||
/* IPC_CREAT和IPC_EXCL一起使用保证创建一个全新的消息队列,IPC_EXCL单独使用没有用,必须和IPC_CREAT配合着使用,
|
||||
若消息队列存在,则错误返回;0666是使创建的消息队列的权限是666 */
|
||||
int def = IPC_CREAT | IPC_EXCL | 0666;
|
||||
return test_suite_creat_msg_queue(def);
|
||||
}
|
||||
|
||||
int test_suite_get_queue(void)
|
||||
{
|
||||
int def = IPC_CREAT; /* 如果该队列不存在,则创建它,否则打开它 */
|
||||
return test_suite_creat_msg_queue(def);
|
||||
}
|
||||
|
||||
int test_suite_new_queue(void)
|
||||
{
|
||||
int msgqueue_id = test_suite_creat_queue();
|
||||
if (msgqueue_id < 0) { /* 如果该队列存在,删除重建 */
|
||||
msgqueue_id = test_suite_get_queue();
|
||||
test_suite_delete_queue(msgqueue_id);
|
||||
msgqueue_id = test_suite_creat_queue();
|
||||
}
|
||||
return msgqueue_id;
|
||||
}
|
||||
|
||||
/* 生产消息 */
|
||||
int test_suite_send_msg(int msgqueue_id, int msg_src, const char *msg)
|
||||
{
|
||||
struct msgbuf_sle _buf; /* _buf存放要发送的消息 */
|
||||
if (memset_s(&_buf, sizeof(_buf), '\0', sizeof(_buf)) != EOK) {
|
||||
perror("memset_s error");
|
||||
}
|
||||
_buf.mtype = msg_src; /* 指定是谁发送的消息,也可以指定是谁接受该条消息 */
|
||||
if (strncpy_s(_buf.mtext, SIZE, msg, strlen(msg) + 1) != EOK) {
|
||||
perror("strncpy_s error");
|
||||
}
|
||||
return msgsnd(msgqueue_id, &_buf, sizeof(_buf.mtext), 0);
|
||||
}
|
||||
|
||||
int test_suite_recv_msg(int msgqueue_id, int msg_dst, char out[], int out_len)
|
||||
{ // 消费消息
|
||||
struct msgbuf_sle _buf;
|
||||
if (memset_s(&_buf, sizeof(_buf), '\0', sizeof(_buf)) != EOK) {
|
||||
perror("memset_s error");
|
||||
}
|
||||
/* 想要把want的_buf里面的消息删除,成功则返回消息的大小 */
|
||||
int ret = msgrcv(msgqueue_id, &_buf, sizeof(_buf.mtext), msg_dst, 0);
|
||||
if (ret <= -1) {
|
||||
perror("msgrcv");
|
||||
return -1;
|
||||
}
|
||||
if (memset_s(out, out_len, '\0', out_len) != EOK) {
|
||||
perror("memset_s error");
|
||||
}
|
||||
if (strcpy_s(out, out_len, _buf.mtext) != EOK) {
|
||||
perror("strcpy_s error");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 删除消息队列 */
|
||||
int test_suite_delete_queue(int msgqueue_id)
|
||||
{
|
||||
int ret = msgctl(msgqueue_id, IPC_RMID, NULL);
|
||||
if (ret < 0) {
|
||||
perror("msgctl");
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
34
application/dft/bsle_dft_common/dft_msgqueue/msg_queue.h
Normal file
34
application/dft/bsle_dft_common/dft_msgqueue/msg_queue.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) @CompanyNameMagicTag 2023-2023. All rights reserved.
|
||||
*/
|
||||
#ifndef MSG_QUEUE_H
|
||||
#define MSG_QUEUE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/msg.h>
|
||||
#include <string.h>
|
||||
|
||||
#define PATH "." /* 当前路径下 */
|
||||
#define PROJ_ID 0x6654
|
||||
#define SIZE 3000
|
||||
|
||||
#define SERVER_TYPE 2
|
||||
#define CLIENT_TYPE 1
|
||||
|
||||
#define START_MSG "start\n"
|
||||
|
||||
struct msgbuf_sle {
|
||||
long mtype; /* 标识是谁发的消息,也可以标识是给谁发的消息,此处举例是前者 */
|
||||
char mtext[SIZE]; /* 存放发的消息 */
|
||||
};
|
||||
|
||||
int test_suite_send_msg(int msgqueue_id, int msg_src, const char *msg); /* 生产消息 */
|
||||
int test_suite_recv_msg(int msgqueue_id, int msg_dst, char out[], int out_len); /* 消费消息 */
|
||||
|
||||
int test_suite_delete_queue(int msgqueue_id); /* 删除消息队列 */
|
||||
|
||||
int test_suite_get_queue(void); /* 获取消息队列 */
|
||||
int test_suite_new_queue(void);
|
||||
#endif /* MSG_QUEUE_H */
|
||||
5
application/dft/bsle_dft_ctrl/dft_ctrl/CMakeLists.txt
Executable file
5
application/dft/bsle_dft_ctrl/dft_ctrl/CMakeLists.txt
Executable file
@ -0,0 +1,5 @@
|
||||
set(
|
||||
sle_comm_src_list
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/dft_ctrl.c
|
||||
)
|
||||
set(BTH_SLE_RAM_LIST "${BTH_SLE_RAM_LIST}" "${sle_comm_src_list}" CACHE INTERNAL "sle ram obj list" FORCE)
|
||||
44
application/dft/bsle_dft_ctrl/dft_ctrl/dft_ctrl.c
Executable file
44
application/dft/bsle_dft_ctrl/dft_ctrl/dft_ctrl.c
Executable file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) @CompanyNameMagicTag 2023-2023. All rights reserved.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "securec.h"
|
||||
#include "msg_queue.h"
|
||||
|
||||
int dft_ctrl(const char* ctrl_name)
|
||||
{
|
||||
int msgqueue_id = test_suite_get_queue();
|
||||
char buf[SIZE];
|
||||
if (strncpy_s(buf, SIZE, START_MSG, strlen(START_MSG) + 1) != EOK) {
|
||||
perror("strncpy_s error");
|
||||
}
|
||||
test_suite_send_msg(msgqueue_id, CLIENT_TYPE, buf); // 发送一条启动消息
|
||||
printf("waiting server start...\n");
|
||||
int ret = test_suite_recv_msg(msgqueue_id, SERVER_TYPE, buf, SIZE); // 等待server响应
|
||||
if (ret == 0 && strncasecmp(buf, START_MSG, 5) == 0) { // start len 5
|
||||
printf("server started\n");
|
||||
while (1) {
|
||||
printf("%s>", ctrl_name);
|
||||
(void)fflush(stdout);
|
||||
if (memset_s(buf, sizeof(buf), '\0', sizeof(buf)) != EOK) {
|
||||
perror("memset_s error");
|
||||
}
|
||||
(void)fgets(buf, SIZE - 1, stdin);
|
||||
if (strncasecmp(buf, "Exit", 4) == 0) { // quit len 4
|
||||
printf("Exit\n");
|
||||
return 0;
|
||||
}
|
||||
test_suite_send_msg(msgqueue_id, CLIENT_TYPE, buf); // 经buf里面的消息发送给server
|
||||
if (strncasecmp(buf, "Quit", 4) == 0) { // quit len 4
|
||||
printf("Quit\n");
|
||||
return 0;
|
||||
}
|
||||
usleep(50 * 1000); // 50 * 1000 = 50ms
|
||||
if (memset_s(buf, sizeof(buf), '\0', sizeof(buf)) != EOK) { // buf保存消费掉的消息
|
||||
perror("memset_s error");
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
9
application/dft/bsle_dft_ctrl/dft_ctrl/dft_ctrl.h
Executable file
9
application/dft/bsle_dft_ctrl/dft_ctrl/dft_ctrl.h
Executable file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) @CompanyNameMagicTag 2023-2023. All rights reserved.
|
||||
*/
|
||||
#ifndef BTH_AT_CLIENT_H
|
||||
#define BTH_AT_CLIENT_H
|
||||
|
||||
int dft_ctrl(const char* ctrl_name);
|
||||
|
||||
#endif /* BTH_AT_CLIENT_H */
|
||||
66
application/dft/bsle_dft_ctrl/linux/CMakeLists.txt
Executable file
66
application/dft/bsle_dft_ctrl/linux/CMakeLists.txt
Executable file
@ -0,0 +1,66 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project("bp_channel")
|
||||
get_filename_component(CURRENT_SOURCE_DIR "" ABSOLUTE)
|
||||
|
||||
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../../../driver/platform)
|
||||
set(CMAKE_SEC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../driver/platform/libc_sec)
|
||||
set(CMAKE_OSAL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../driver/platform/osal)
|
||||
set(CMAKE_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../)
|
||||
elseif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../utils/securec)
|
||||
set(CMAKE_SEC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../utils/securec)
|
||||
set(CMAKE_OSAL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../utils/osal)
|
||||
set(CMAKE_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../)
|
||||
endif()
|
||||
|
||||
add_definitions(${defines} -D BTH_TEST -D CONFIG_GLE -D BT_MANAGER_DEPLOYED=2 -D BT_CODEC_TID=2 -D __BTC_INLINE=)
|
||||
|
||||
set(headers
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../dft_ctrl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../bsle_dft_common/dft_msgqueue
|
||||
${CMAKE_SEC_DIR}/include
|
||||
${CMAKE_OSAL_DIR}/linux/userspace/include
|
||||
${CMAKE_ROOT_DIR}/driver/platform/drv/include
|
||||
${CMAKE_ROOT_DIR}/utils/osal/linux/userspace/include/memory
|
||||
${CMAKE_ROOT_DIR}/include/native
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/platform
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/product
|
||||
)
|
||||
|
||||
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../../../driver/platform)
|
||||
set(headers
|
||||
${headers}
|
||||
${CMAKE_OSAL_DIR}/include
|
||||
)
|
||||
endif()
|
||||
|
||||
set(sources
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../main.c
|
||||
${CMAKE_SEC_DIR}/src/memcpy_s.c
|
||||
${CMAKE_SEC_DIR}/src/memset_s.c
|
||||
${CMAKE_SEC_DIR}/src/memmove_s.c
|
||||
${CMAKE_SEC_DIR}/src/sprintf_s.c
|
||||
${CMAKE_SEC_DIR}/src/vsprintf_s.c
|
||||
${CMAKE_SEC_DIR}/src/strcpy_s.c
|
||||
${CMAKE_SEC_DIR}/src/strncpy_s.c
|
||||
${CMAKE_SEC_DIR}/src/strcat_s.c
|
||||
${CMAKE_SEC_DIR}/src/secureprintoutput_a.c
|
||||
)
|
||||
|
||||
add_subdirectory(../dft_ctrl ../build/ctrl_build)
|
||||
add_subdirectory(../../bsle_dft_common/dft_msgqueue ../build/msgqueue_build)
|
||||
|
||||
# add_library生成.a和add_executable可执行文件二选一放开
|
||||
# add_library(sparklinkd STATIC ${sources})
|
||||
list(APPEND CFLAGS -s -fPIE -pie -W -Wall -Wl,-z,now -Wl,-z,relro -fstack-protector-all -Os)
|
||||
|
||||
add_executable(sparklinkctrl ${sources} ${BTH_SLE_RAM_LIST})
|
||||
target_include_directories(sparklinkctrl PRIVATE ${headers})
|
||||
target_compile_options(sparklinkctrl PRIVATE ${CFLAGS})
|
||||
target_link_options(sparklinkctrl PRIVATE ${CFLAGS})
|
||||
|
||||
#上板需要设置如下交叉编译链,本地可以通过删除交叉编译链配置进行验证
|
||||
set(CMAKE_C_COMPILER ${WSCFG_CROSS_COMPILE}gcc)
|
||||
set(CMAKE_CXX_COMPILER ${WSCFG_CROSS_COMPILE}g++)
|
||||
|
||||
message("CMAKE_CURRENT_SOURCE_DIR:" ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
8
application/dft/bsle_dft_ctrl/linux/Makefile
Executable file
8
application/dft/bsle_dft_ctrl/linux/Makefile
Executable file
@ -0,0 +1,8 @@
|
||||
include $(WSCFG_KCONFIG_CONFIG)
|
||||
STRIP := $(WSCFG_CROSS_COMPILE)strip
|
||||
$(warning defconfig: ================ARCH=$(WSCFG_ARCH_NAME) CROSS_COMPILE=$(WSCFG_CROSS_COMPILE)=======================)
|
||||
all:
|
||||
mkdir -p build && cd build && cmake ../ -DWSCFG_CROSS_COMPILE=${WSCFG_CROSS_COMPILE} && make -j4
|
||||
$(STRIP) --strip-unneeded -s build/sparklinkctrl
|
||||
clean:
|
||||
rm -rf build
|
||||
16
application/dft/bsle_dft_ctrl/linux/release.mk
Executable file
16
application/dft/bsle_dft_ctrl/linux/release.mk
Executable file
@ -0,0 +1,16 @@
|
||||
CUR_MK_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
CUR_MK_DIR := $(dir $(CUR_MK_PATH))
|
||||
CUR_MK_DIR := $(realpath $(CUR_MK_DIR))
|
||||
|
||||
# 项目顶层目录(不要其他Makefile中使用)
|
||||
_TOP_DIR := $(realpath $(CUR_MK_DIR))
|
||||
_PLATFORM_DIR := $(realpath $(CUR_MK_DIR)/../../../../platform)
|
||||
|
||||
# 平台目录
|
||||
PLATFORM_INC_DIR := $(_PLATFORM_DIR)/inc
|
||||
PLATFORM_CFG_DIR := $(_PLATFORM_DIR)/cfg
|
||||
PLATFORM_DRV_DIR := $(_PLATFORM_DIR)/drv
|
||||
PLATFORM_DEVICE_DIR := $(_PLATFORM_DIR)/drv/device
|
||||
PLATFORM_HCC_DIR := $(_PLATFORM_DIR)/hcc
|
||||
PLATFORM_OSAL_DIR := $(_PLATFORM_DIR)/osal
|
||||
PLATFORM_LIBC_SEC_DIR := $(_PLATFORM_DIR)/libc_sec
|
||||
11
application/dft/bsle_dft_ctrl/main.c
Executable file
11
application/dft/bsle_dft_ctrl/main.c
Executable file
@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) @CompanyNameMagicTag 2024-2024. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "dft_ctrl.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
dft_ctrl("sparklinkctrl");
|
||||
return 0;
|
||||
}
|
||||
50
application/dft/bsle_dft_driver/Makefile
Normal file
50
application/dft/bsle_dft_driver/Makefile
Normal file
@ -0,0 +1,50 @@
|
||||
CUR_MK_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
CUR_MK_DIR := $(dir $(CUR_MK_PATH))
|
||||
CUR_MK_DIR := $(realpath $(CUR_MK_DIR))
|
||||
|
||||
include $(CUR_MK_DIR)/$(DIR_MAP_CONFIG_FILE)
|
||||
include $(WSCFG_KCONFIG_CONFIG)
|
||||
ifneq ($(KERNELRELEASE),)
|
||||
$(warning defconfig: ================ARCH=$(WSCFG_ARCH_NAME) CROSS_COMPILE=$(WSCFG_CROSS_COMPILE)=======================)
|
||||
obj-m := bp_test.o
|
||||
bp_test-objs := bsle_dft_host_register.o
|
||||
bp_test-objs += bsle_dft_socket/bsle_dft_chan_kernel.o bsle_dft_hcc/bsle_dft_hcc_proc.o
|
||||
|
||||
_INCLUDES += -I$(PLATFORM_CFG_DIR)
|
||||
_INCLUDES += -I$(PLATFORM_INC_DIR)/oal
|
||||
_INCLUDES += -I$(PLATFORM_INC_DIR)/oal/linux
|
||||
_INCLUDES += -I$(PLATFORM_DRV_DIR)/include
|
||||
_INCLUDES += -I$(PLATFORM_DEVICE_DIR)/romable/include
|
||||
_INCLUDES += -I$(PLATFORM_HCC_DIR)/cfg
|
||||
_INCLUDES += -I$(PLATFORM_OSAL_DIR)/include
|
||||
_INCLUDES += -I$(PLATFORM_HCC_DIR)/comm
|
||||
_INCLUDES += -I$(PLATFORM_HCC_DIR)/host
|
||||
_INCLUDES += -I$(PLATFORM_HCC_DIR)
|
||||
_INCLUDES += -I$(PLATFORM_HCC_DIR)/inc
|
||||
_INCLUDES += -I$(PLATFORM_LIBC_SEC_DIR)/include
|
||||
_INCLUDES += -I$(CUR_MK_DIR)/bsle_dft_hcc
|
||||
_INCLUDES += -I$(CUR_MK_DIR)/bsle_dft_socket
|
||||
_INCLUDES += -I$(CUR_MK_DIR)
|
||||
|
||||
EXTRA_CFLAGS = $(_INCLUDES)
|
||||
# CleanCode Build Option
|
||||
EXTRA_CFLAGS += -Werror
|
||||
EXTRA_CFLAGS += -include $(WSCFG_AUTOCONFIG_H) -include $(PLATFORM_INC_DIR)/oneimage/oneimage.h
|
||||
|
||||
else
|
||||
$(warning defconfig: ================$(WSCFG_KERNEL_DIR)=======================)
|
||||
|
||||
STRIP := $(WSCFG_CROSS_COMPILE)strip
|
||||
|
||||
modules:
|
||||
make -C $(WSCFG_KERNEL_DIR) ARCH=$(WSCFG_ARCH_NAME) CROSS_COMPILE=$(WSCFG_CROSS_COMPILE) M=$(CUR_MK_DIR) modules KBUILD_MODPOST_WARN=1
|
||||
$(STRIP) --strip-unneeded bp_test.ko
|
||||
|
||||
clean:
|
||||
rm -f *.o *.ko *.mod.c *.o.cmd .*.o.cmd .*.ko.cmd .*.mod.o.cmd *.symvers *.order *.tmp_versions
|
||||
rm -f bsle_dft_socket/*.o
|
||||
rm -f bsle_dft_socket/.*.o.cmd
|
||||
rm -f bsle_dft_hcc/*.o
|
||||
rm -f bsle_dft_hcc/.*.o.cmd
|
||||
|
||||
endif
|
||||
150
application/dft/bsle_dft_driver/bsle_dft_hcc/bsle_dft_hcc_proc.c
Normal file
150
application/dft/bsle_dft_driver/bsle_dft_hcc/bsle_dft_hcc_proc.c
Normal file
@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright (c) @CompanyNameMagicTag 2023. All rights reserved.
|
||||
*/
|
||||
#include "hcc_comm.h"
|
||||
#include "hcc_if.h"
|
||||
#include "hcc_adapt.h"
|
||||
#include "bsle_dft_chan_kernel.h"
|
||||
#include "td_base.h"
|
||||
|
||||
/**
|
||||
* @function : sle_hcc_adapt_free
|
||||
* @brief : liteos的bsle host向device发送的消息,hcc需要额外分配sdio传输相应的32字节对齐的内存空间,
|
||||
* @brief : 在hcc发送消息成功后,会进入此回调函数
|
||||
* @param : queue_id [input] hcc通道收发消息类型id
|
||||
* @param : buf [input] 需要被释放的hcc通道申请的内存空间
|
||||
* @param : user_param [input] 需要被释放的bth申请的内存空间
|
||||
* @return : void
|
||||
*/
|
||||
static td_void sle_hcc_adapt_free(hcc_queue_type queue_id, td_u8 *buf, td_u8 *user_param)
|
||||
{
|
||||
if (user_param != TD_NULL) {
|
||||
osal_kfree(user_param);
|
||||
}
|
||||
if (buf != TD_NULL) {
|
||||
osal_kfree(buf);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @function : sle_hcc_adapt_alloc
|
||||
* @brief : bsle device向liteos发送的消息,hcc接收到原始消息需要申请32字节对齐的内存空间
|
||||
* @param : queue_id [input] hcc通道收发消息类型id
|
||||
* @param : len [input] hcc申请保存数据的大小
|
||||
* @param : buf [input] hcc申请保存数据的内存空间地址
|
||||
* @param : user_param [input] 当前未使用,业务可能需要的额外内存空间可以指向这里
|
||||
* @return : 内存分配正常返回EXT_ERR_SUCCESS
|
||||
*/
|
||||
static td_u32 sle_hcc_adapt_alloc(hcc_queue_type queue_id, td_u32 len, td_u8 **buf, td_u8 **user_param)
|
||||
{
|
||||
*buf = (td_u8 *)osal_kmalloc(len, OSAL_GFP_KERNEL);
|
||||
if (*buf == TD_NULL) {
|
||||
hcc_debug("sle_hcc_adapt_alloc failed\r\n");
|
||||
return EXT_ERR_FAILURE;
|
||||
}
|
||||
return EXT_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @function : sle_hcc_adapt_rx
|
||||
* @brief : bsle host的rx处理,user_param和buf共享同一片内存空间,user_param即是bsle_hcc_adapt_alloc函数中的buf
|
||||
* @param : queue_id [input] hcc通道收发消息类型id
|
||||
* @param : len [input] device发送消息的实际长度
|
||||
* @param : buf [input] device发送的实际消息的内存起始地址
|
||||
* @param : user_param [input] 指向的是hcc原始分配的32字节对齐的起始内存空间地址
|
||||
* @return : 接收业务处理正常返回EXT_ERR_SUCCESS
|
||||
*/
|
||||
static td_u32 sle_hcc_adapt_rx(hcc_queue_type queue_id, td_u8 sub_type, td_u8 *buf, td_u32 len, td_u8 *user_param)
|
||||
{
|
||||
if (buf == TD_NULL || user_param == TD_NULL) {
|
||||
return EXT_ERR_FAILURE;
|
||||
}
|
||||
sle_hci_chan_recv_frame(buf, len);
|
||||
|
||||
osal_kfree(user_param);
|
||||
return EXT_ERR_SUCCESS;
|
||||
}
|
||||
static td_u32 hcc_bt_rx_proc(hcc_queue_type queue_id, td_u8 sub_type, td_u8 *buf, td_u32 len, td_u8 *user_param)
|
||||
{
|
||||
if (buf == TD_NULL || user_param == TD_NULL) {
|
||||
return EXT_ERR_FAILURE;
|
||||
}
|
||||
ble_hci_chan_recv_frame(buf, len);
|
||||
osal_kfree(user_param);
|
||||
return EXT_ERR_SUCCESS;
|
||||
}
|
||||
hcc_adapt_ops g_hcc_ble_adapt = {
|
||||
.free = sle_hcc_adapt_free,
|
||||
.alloc = sle_hcc_adapt_alloc,
|
||||
.start_subq = TD_NULL,
|
||||
.stop_subq = TD_NULL,
|
||||
.rx_proc = hcc_bt_rx_proc,
|
||||
};
|
||||
|
||||
hcc_adapt_ops g_sle_hcc_adapt = {
|
||||
.free = sle_hcc_adapt_free,
|
||||
.alloc = sle_hcc_adapt_alloc,
|
||||
.start_subq = TD_NULL,
|
||||
.stop_subq = TD_NULL,
|
||||
.rx_proc = sle_hcc_adapt_rx,
|
||||
};
|
||||
|
||||
/* Send frames from HCI layer */
|
||||
void sle_hci_send_frame(uint8_t *data_buf, uint16_t len)
|
||||
{
|
||||
int ret;
|
||||
/* 已和平台确认,sub_type和fc_flag值为0的话,则不生效 */
|
||||
hcc_transfer_param sle_transfer_param = {0};
|
||||
|
||||
sle_transfer_param.service_type = HCC_ACTION_TYPE_SLE;
|
||||
/* sub_type类型业务可以在service_type上自定义,在device侧去区分做不同业务 */
|
||||
sle_transfer_param.sub_type = 0;
|
||||
sle_transfer_param.queue_id = SLE_DATA_QUEUE;
|
||||
/* fc_flag代表流控类型,当前蓝牙未使用 */
|
||||
sle_transfer_param.fc_flag = 0;
|
||||
sle_transfer_param.user_param = NULL;
|
||||
|
||||
/**
|
||||
* 调用完tx_data后,若hcc返回成功,则进入到hcc_sle_rx_proc释放hcc通道申请的buf。
|
||||
* 因为netlink机制,此处不用释放data_buf.
|
||||
*/
|
||||
ret = hcc_bt_tx_data(HCC_CHANNEL_AP, data_buf, len, &sle_transfer_param);
|
||||
if (ret != EXT_ERR_SUCCESS) {
|
||||
hcc_debug("send tx data failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
void ble_hci_send_frame(uint8_t *data_buf, uint16_t len)
|
||||
{
|
||||
int ret;
|
||||
/* 已和平台确认,sub_type和fc_flag值为0的话,则不生效 */
|
||||
hcc_transfer_param sle_transfer_param = {0};
|
||||
|
||||
sle_transfer_param.service_type = HCC_ACTION_TYPE_BT;
|
||||
/* sub_type类型业务可以在service_type上自定义,在device侧去区分做不同业务 */
|
||||
sle_transfer_param.sub_type = 0;
|
||||
sle_transfer_param.queue_id = BT_DATA_QUEUE;
|
||||
/* fc_flag代表流控类型,当前蓝牙未使用 */
|
||||
sle_transfer_param.fc_flag = 0;
|
||||
sle_transfer_param.user_param = NULL;
|
||||
|
||||
/**
|
||||
* 调用完tx_data后,若hcc返回成功,则进入到hcc_sle_rx_proc释放hcc通道申请的buf。
|
||||
* 因为netlink机制,此处无不用释放data_buf.
|
||||
*/
|
||||
ret = hcc_bt_tx_data(HCC_CHANNEL_AP, data_buf, len, &sle_transfer_param);
|
||||
if (ret != EXT_ERR_SUCCESS) {
|
||||
hcc_debug("send tx data failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ext_errno sle_hcc_init(void)
|
||||
{
|
||||
return hcc_service_init(HCC_CHANNEL_AP, HCC_ACTION_TYPE_SLE, &g_sle_hcc_adapt);
|
||||
}
|
||||
|
||||
ext_errno ble_hcc_init(void)
|
||||
{
|
||||
return hcc_service_init(HCC_CHANNEL_AP, HCC_ACTION_TYPE_BT, &g_hcc_ble_adapt);
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (c) @CompanyNameMagicTag 2023-2023. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef BSLE_DFT_HCC_PROC_H
|
||||
#define BSLE_DFT_HCC_PROC_H
|
||||
|
||||
#include "td_base.h"
|
||||
|
||||
ext_errno sle_hcc_init(void);
|
||||
ext_errno ble_hcc_init(void);
|
||||
void sle_hci_send_frame(uint8_t *data_buf, uint16_t len);
|
||||
void ble_hci_send_frame(uint8_t *data_buf, uint16_t len);
|
||||
#endif
|
||||
34
application/dft/bsle_dft_driver/bsle_dft_host_register.c
Normal file
34
application/dft/bsle_dft_driver/bsle_dft_host_register.c
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) @CompanyNameMagicTag 2023. All rights reserved.
|
||||
*/
|
||||
#include "bsle_dft_host_register.h"
|
||||
#include "bsle_dft_chan_kernel.h"
|
||||
#include "bsle_dft_hcc_proc.h"
|
||||
|
||||
#include <asm/unaligned.h>
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
static int32_t sle_host_init(void)
|
||||
{
|
||||
int32_t ret;
|
||||
ret = sle_chan_init();
|
||||
if (ret == SLE_CHAN_FAILED) {
|
||||
oal_print_err("sle_chan_init failed\r\n");
|
||||
return OAL_FAIL;
|
||||
}
|
||||
sle_hci_register_send_frame_cb((sle_send_frame_cb_t)sle_hci_send_frame);
|
||||
ble_hci_register_send_frame_cb((sle_send_frame_cb_t)ble_hci_send_frame);
|
||||
|
||||
oal_print_err("sle host init finished\n");
|
||||
return OAL_SUCC;
|
||||
}
|
||||
|
||||
static osal_void sle_host_deinit(void)
|
||||
{
|
||||
sle_chan_exit();
|
||||
oal_print_err("finish: H2D_MSG_SLE_CLOSE\n");
|
||||
}
|
||||
|
||||
module_init(sle_host_init);
|
||||
module_exit(sle_host_deinit);
|
||||
14
application/dft/bsle_dft_driver/bsle_dft_host_register.h
Normal file
14
application/dft/bsle_dft_driver/bsle_dft_host_register.h
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (c) @CompanyNameMagicTag 2023-2023. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef BSLE_DFT_HOST_REGISTER_H
|
||||
#define BSLE_DFT_HOST_REGISTER_H
|
||||
|
||||
#include "customize_bsle_ext.h"
|
||||
#include "oal_schedule.h"
|
||||
#include "hcc_comm.h"
|
||||
#include "hcc_if.h"
|
||||
#include "hcc_adapt.h"
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,239 @@
|
||||
/*
|
||||
* Copyright (c) @CompanyNameMagicTag 2023. All rights reserved.
|
||||
*/
|
||||
#include <net/net_namespace.h>
|
||||
#include <crypto/internal/skcipher.h>
|
||||
#include <crypto/internal/rng.h>
|
||||
#include <crypto/akcipher.h>
|
||||
#include <crypto/kpp.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/security.h>
|
||||
|
||||
#include "oal_schedule.h"
|
||||
#include "securec.h"
|
||||
#include "bsle_dft_hcc_proc.h"
|
||||
#include "bsle_dft_chan_kernel.h"
|
||||
|
||||
static void sle_hci_chan_send_frame(struct sk_buff *skb);
|
||||
static void ble_hci_chan_send_frame(struct sk_buff *skb);
|
||||
#define BT_POWER_FLAG 4
|
||||
|
||||
struct netlink_kernel_cfg cfg_hci = {
|
||||
.groups = 0,
|
||||
.flags = 0,
|
||||
.input = sle_hci_chan_send_frame,
|
||||
.cb_mutex = NULL,
|
||||
.bind = NULL,
|
||||
.unbind = NULL,
|
||||
.compare = NULL
|
||||
};
|
||||
struct netlink_kernel_cfg cfg_tm = {
|
||||
.groups = 0,
|
||||
.flags = 0,
|
||||
.input = ble_hci_chan_send_frame,
|
||||
.cb_mutex = NULL,
|
||||
.bind = NULL,
|
||||
.unbind = NULL,
|
||||
.compare = NULL
|
||||
};
|
||||
sle_chan_cfg_t g_sle_chan_cfg[SLE_CHAN_MAX] = {
|
||||
{
|
||||
.chan_id = SLE_CHAN_HCI,
|
||||
.user_port = SLE_CHAN_USER_PORT_HCI,
|
||||
.netlink_protocol = SLE_CHAN_NETLINK_HCI,
|
||||
.netlink_cfg = &cfg_hci,
|
||||
},
|
||||
{
|
||||
.chan_id = BLE_CHAN_HCI,
|
||||
.user_port = BLE_CHAN_USER_PORT_HCI,
|
||||
.netlink_protocol = BLE_CHAN_NETLINK_HCI,
|
||||
.netlink_cfg = &cfg_tm,
|
||||
}
|
||||
};
|
||||
|
||||
static sle_chan_cfg_t *sle_chan_find_cfg(sle_chan_id_t chan_id)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < SLE_CHAN_MAX; i++) {
|
||||
if (g_sle_chan_cfg[i].chan_id == chan_id) {
|
||||
return &g_sle_chan_cfg[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
static void sle_register_send_frame_cb(sle_chan_id_t chan_id, sle_send_frame_cb_t cb)
|
||||
{
|
||||
sle_chan_cfg_t *chan_cfg = sle_chan_find_cfg(chan_id);
|
||||
if (chan_cfg == NULL) {
|
||||
oal_print_err("[sle_register_send_frame_cb] not find chan, chan_id: %d\n", chan_id);
|
||||
return;
|
||||
}
|
||||
chan_cfg->send = cb;
|
||||
}
|
||||
|
||||
void sle_hci_register_send_frame_cb(sle_send_frame_cb_t cb)
|
||||
{
|
||||
sle_register_send_frame_cb(SLE_CHAN_HCI, cb);
|
||||
}
|
||||
void ble_hci_register_send_frame_cb(sle_send_frame_cb_t cb)
|
||||
{
|
||||
sle_register_send_frame_cb(BLE_CHAN_HCI, cb);
|
||||
}
|
||||
|
||||
static int sle_chan_recv_frame(sle_chan_id_t chan_id, uint8_t *data, uint16_t data_len)
|
||||
{
|
||||
struct nlmsghdr *nlh;
|
||||
int ret;
|
||||
struct sk_buff *nl_skb;
|
||||
sle_chan_cfg_t *chan_cfg;
|
||||
if (data == NULL || data_len == 0) {
|
||||
return SLE_CHAN_PARAM_INVALID;
|
||||
}
|
||||
nl_skb = nlmsg_new(data_len, GFP_ATOMIC);
|
||||
chan_cfg = sle_chan_find_cfg(chan_id);
|
||||
if (chan_cfg == NULL) {
|
||||
oal_print_err("[sle_chan_recv_frame] not find chan, chan_id: %d\n", chan_id);
|
||||
return SLE_CHAN_PARAM_INVALID;
|
||||
}
|
||||
/* 设置netlink消息头部 */
|
||||
nlh = nlmsg_put(nl_skb, 0, 0, chan_cfg->netlink_protocol, data_len, 0);
|
||||
if (nlh == NULL) {
|
||||
oal_print_err("nlmsg_put failaure\n");
|
||||
nlmsg_free(nl_skb);
|
||||
return SLE_CHAN_MEMORY_ERR;
|
||||
}
|
||||
ret = memcpy_s(nlmsg_data(nlh), data_len, data, data_len);
|
||||
if (ret != EOK) {
|
||||
return SLE_CHAN_MEMORY_ERR;
|
||||
}
|
||||
ret = netlink_unicast(chan_cfg->nlsk_sock, nl_skb, chan_cfg->user_port, MSG_DONTWAIT);
|
||||
return ret;
|
||||
}
|
||||
int sle_hci_chan_recv_frame(uint8_t *data, uint16_t data_len)
|
||||
{
|
||||
return sle_chan_recv_frame(SLE_CHAN_HCI, data, data_len);
|
||||
}
|
||||
int ble_hci_chan_recv_frame(uint8_t *data, uint16_t data_len)
|
||||
{
|
||||
return sle_chan_recv_frame(BLE_CHAN_HCI, data, data_len);
|
||||
}
|
||||
|
||||
static void sle_chan_send_frame_pm_open(void)
|
||||
{
|
||||
bool boot_finish;
|
||||
int32_t ret = pm_sle_open();
|
||||
if (ret != OAL_SUCC) {
|
||||
printk("pm_sle_open failed\n");
|
||||
}
|
||||
ret = pm_ble_open();
|
||||
if (ret != OAL_SUCC) {
|
||||
printk("pm_ble_open failed\n");
|
||||
}
|
||||
|
||||
boot_finish = hbsle_hcc_customize_get_device_status(BSLE_STATUS_BOOT_FINISH);
|
||||
if (boot_finish == false) {
|
||||
printk("device boot not finish \n");
|
||||
}
|
||||
|
||||
ret = sle_hcc_init();
|
||||
if (ret != OAL_SUCC) {
|
||||
printk("initial hcc sle service failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = ble_hcc_init();
|
||||
if (ret != OAL_SUCC) {
|
||||
printk("initial hcc ble service failed\n");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void sle_chan_send_frame_pm_close(void)
|
||||
{
|
||||
int32_t ret;
|
||||
hcc_service_deinit(HCC_CHANNEL_AP, HCC_ACTION_TYPE_SLE);
|
||||
hcc_service_deinit(HCC_CHANNEL_AP, HCC_ACTION_TYPE_BT);
|
||||
hbsle_hcc_customize_reset_device_status();
|
||||
ret = pm_sle_close();
|
||||
if (ret != OAL_SUCC) {
|
||||
printk("pm_sle_close failed\n");
|
||||
}
|
||||
ret = pm_ble_close();
|
||||
if (ret != OAL_SUCC) {
|
||||
printk("pm_sle_close failed\n");
|
||||
}
|
||||
oal_print_err("enter:%s\n", __func__);
|
||||
return;
|
||||
}
|
||||
static void sle_chan_send_frame(sle_chan_id_t chan_id, struct sk_buff *skb)
|
||||
{
|
||||
uint8_t pm_open[BT_POWER_FLAG] = {00, 00, 00, 00};
|
||||
uint8_t pm_close[BT_POWER_FLAG] = {01, 01, 01, 01};
|
||||
struct nlmsghdr *nlh = NULL;
|
||||
uint8_t *umsg = NULL;
|
||||
sle_chan_cfg_t *chan_cfg;
|
||||
uint16_t udata_len = 0;
|
||||
if (skb == NULL || skb->len < nlmsg_total_size(0)) {
|
||||
oal_print_err("netlink channel skb err! %d\n", chan_id);
|
||||
return;
|
||||
}
|
||||
nlh = nlmsg_hdr(skb);
|
||||
umsg = NLMSG_DATA(nlh);
|
||||
udata_len = (uint16_t)nlmsg_len(nlh);
|
||||
if (memcmp(umsg, pm_open, udata_len) == 0) {
|
||||
printk("CMD Send OK\n");
|
||||
sle_chan_send_frame_pm_open();
|
||||
return;
|
||||
}
|
||||
if (memcmp(umsg, pm_close, udata_len) == 0) {
|
||||
printk("CMD Send OK\n");
|
||||
sle_chan_send_frame_pm_close();
|
||||
return;
|
||||
}
|
||||
chan_cfg = sle_chan_find_cfg(chan_id);
|
||||
if (chan_cfg == NULL) {
|
||||
oal_print_err("[sle_chan_send_frame] not find chan, chan_id: %d\n", chan_id);
|
||||
return;
|
||||
}
|
||||
if (chan_cfg->send) {
|
||||
chan_cfg->send(umsg, udata_len);
|
||||
} else {
|
||||
oal_print_err("[sle_chan_send_frame] chan send fun null, chan_id: %d\n", chan_id);
|
||||
}
|
||||
}
|
||||
|
||||
static void sle_hci_chan_send_frame(struct sk_buff *skb)
|
||||
{
|
||||
sle_chan_send_frame(SLE_CHAN_HCI, skb);
|
||||
}
|
||||
|
||||
static void ble_hci_chan_send_frame(struct sk_buff *skb)
|
||||
{
|
||||
sle_chan_send_frame(BLE_CHAN_HCI, skb);
|
||||
}
|
||||
|
||||
int sle_chan_init(void)
|
||||
{
|
||||
uint32_t i;
|
||||
printk("[sle_chan_init] init sle chan\n");
|
||||
for (i = 0; i < SLE_CHAN_MAX; i++) {
|
||||
struct sock *sle_nlsk
|
||||
= netlink_kernel_create(&init_net, g_sle_chan_cfg[i].netlink_protocol, g_sle_chan_cfg[i].netlink_cfg);
|
||||
if (sle_nlsk == NULL) {
|
||||
return SLE_CHAN_FAILED;
|
||||
}
|
||||
g_sle_chan_cfg[i].nlsk_sock = sle_nlsk;
|
||||
}
|
||||
return SLE_CHAN_SUCCESS;
|
||||
}
|
||||
|
||||
void sle_chan_exit(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < SLE_CHAN_MAX; i++) {
|
||||
if (g_sle_chan_cfg[i].nlsk_sock) {
|
||||
netlink_kernel_release(g_sle_chan_cfg[i].nlsk_sock);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) @CompanyNameMagicTag 2023-2023. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef BSLE_DFT_CHAN_KERNEL_H
|
||||
#define BSLE_DFT_CHAN_KERNEL_H
|
||||
|
||||
#include <net/netlink.h>
|
||||
#include "customize_bsle_ext.h"
|
||||
#include "hcc_comm.h"
|
||||
#include "hcc_if.h"
|
||||
#include "hcc_adapt.h"
|
||||
|
||||
extern osal_s32 pm_sle_open(void);
|
||||
extern osal_s32 pm_sle_close(void);
|
||||
extern osal_s32 pm_ble_open(void);
|
||||
extern osal_s32 pm_ble_close(void);
|
||||
|
||||
typedef void (*sle_send_frame_cb_t)(uint8_t *data, uint16_t data_len);
|
||||
|
||||
typedef enum {
|
||||
SLE_CHAN_SUCCESS = 0,
|
||||
SLE_CHAN_FAILED = -1,
|
||||
SLE_CHAN_MEMORY_ERR = -2,
|
||||
SLE_CHAN_PARAM_INVALID = -3,
|
||||
} sle_chan_error_code_t;
|
||||
|
||||
typedef enum {
|
||||
SLE_CHAN_USER_PORT_HCI = 100,
|
||||
BLE_CHAN_USER_PORT_HCI,
|
||||
} sle_chan_user_port_t;
|
||||
|
||||
typedef enum {
|
||||
SLE_CHAN_NETLINK_HCI = 22,
|
||||
BLE_CHAN_NETLINK_HCI,
|
||||
} sle_chan_netlink_protocol_t;
|
||||
|
||||
typedef enum {
|
||||
SLE_CHAN_HCI,
|
||||
BLE_CHAN_HCI,
|
||||
SLE_CHAN_MAX,
|
||||
} sle_chan_id_t;
|
||||
|
||||
typedef struct sle_chan_cfg {
|
||||
sle_chan_id_t chan_id;
|
||||
sle_chan_user_port_t user_port;
|
||||
sle_chan_netlink_protocol_t netlink_protocol;
|
||||
sle_send_frame_cb_t send;
|
||||
struct netlink_kernel_cfg *netlink_cfg;
|
||||
struct sock *nlsk_sock;
|
||||
} sle_chan_cfg_t;
|
||||
|
||||
int sle_hci_chan_recv_frame(uint8_t *data, uint16_t data_len);
|
||||
int ble_hci_chan_recv_frame(uint8_t *data, uint16_t data_len);
|
||||
void sle_hci_register_send_frame_cb(sle_send_frame_cb_t cb);
|
||||
void ble_hci_register_send_frame_cb(sle_send_frame_cb_t cb);
|
||||
int sle_chan_init(void);
|
||||
void sle_chan_exit(void);
|
||||
|
||||
#endif
|
||||
20
application/dft/bsle_dft_driver/build-in.mk
Normal file
20
application/dft/bsle_dft_driver/build-in.mk
Normal file
@ -0,0 +1,20 @@
|
||||
CUR_MK_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
CUR_MK_DIR := $(dir $(CUR_MK_PATH))
|
||||
CUR_MK_DIR := $(realpath $(CUR_MK_DIR))
|
||||
|
||||
# 计算第一个参数相对于第二个参数的相对路径
|
||||
define calc_relpath
|
||||
$(shell realpath $(1) --relative-to=$(2))
|
||||
endef
|
||||
|
||||
# 项目顶层目录(不要其他Makefile中使用)
|
||||
_TOP_DIR := $(realpath $(CUR_MK_DIR)/../../../../../../)
|
||||
|
||||
# 平台目录
|
||||
PLATFORM_INC_DIR := $(_TOP_DIR)/host/wifi/platform/inc
|
||||
PLATFORM_CFG_DIR := $(_TOP_DIR)/host/common/customize
|
||||
PLATFORM_DRV_DIR := $(_TOP_DIR)/host/wifi/platform/driver
|
||||
PLATFORM_DEVICE_DIR := $(_TOP_DIR)/device/soc/vendor/ws73
|
||||
PLATFORM_HCC_DIR := $(_TOP_DIR)/utils/hcc
|
||||
PLATFORM_OSAL_DIR := $(_TOP_DIR)/utils/osal
|
||||
PLATFORM_LIBC_SEC_DIR := $(_TOP_DIR)/utils/securec
|
||||
21
application/dft/bsle_dft_driver/release.mk
Normal file
21
application/dft/bsle_dft_driver/release.mk
Normal file
@ -0,0 +1,21 @@
|
||||
CUR_MK_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
CUR_MK_DIR := $(dir $(CUR_MK_PATH))
|
||||
CUR_MK_DIR := $(realpath $(CUR_MK_DIR))
|
||||
|
||||
# 计算第一个参数相对于第二个参数的相对路径
|
||||
define calc_relpath
|
||||
$(shell python3 -c "import os.path; print(os.path.relpath('$(1)','$(2)'))")
|
||||
endef
|
||||
|
||||
# 项目顶层目录(不要其他Makefile中使用)
|
||||
_TOP_DIR := $(realpath $(CUR_MK_DIR))
|
||||
_PLATFORM_DIR := $(realpath $(CUR_MK_DIR)/../../../driver/platform)
|
||||
|
||||
# 平台目录
|
||||
PLATFORM_INC_DIR := $(_PLATFORM_DIR)/inc
|
||||
PLATFORM_CFG_DIR := $(_PLATFORM_DIR)/cfg
|
||||
PLATFORM_DRV_DIR := $(_PLATFORM_DIR)/drv
|
||||
PLATFORM_DEVICE_DIR := $(_PLATFORM_DIR)/drv/device
|
||||
PLATFORM_HCC_DIR := $(_PLATFORM_DIR)/hcc
|
||||
PLATFORM_OSAL_DIR := $(_PLATFORM_DIR)/osal
|
||||
PLATFORM_LIBC_SEC_DIR := $(_PLATFORM_DIR)/libc_sec
|
||||
BIN
application/lib/1155/libble_host.a
Normal file
BIN
application/lib/1155/libble_host.a
Normal file
Binary file not shown.
BIN
application/lib/1155/libbsle_host.a
Normal file
BIN
application/lib/1155/libbsle_host.a
Normal file
Binary file not shown.
BIN
application/lib/1155/libsle_host.a
Normal file
BIN
application/lib/1155/libsle_host.a
Normal file
Binary file not shown.
BIN
application/lib/1156/libble_host.a
Normal file
BIN
application/lib/1156/libble_host.a
Normal file
Binary file not shown.
BIN
application/lib/1156/libbsle_host.a
Normal file
BIN
application/lib/1156/libbsle_host.a
Normal file
Binary file not shown.
BIN
application/lib/1156/libsle_host.a
Normal file
BIN
application/lib/1156/libsle_host.a
Normal file
Binary file not shown.
BIN
application/lib/1156_iot/libble_host.a
Normal file
BIN
application/lib/1156_iot/libble_host.a
Normal file
Binary file not shown.
BIN
application/lib/1156_iot/libbsle_host.a
Normal file
BIN
application/lib/1156_iot/libbsle_host.a
Normal file
Binary file not shown.
BIN
application/lib/1156_iot/libsle_host.a
Normal file
BIN
application/lib/1156_iot/libsle_host.a
Normal file
Binary file not shown.
BIN
application/lib/1156_ont/libble_host.a
Normal file
BIN
application/lib/1156_ont/libble_host.a
Normal file
Binary file not shown.
BIN
application/lib/1156_ont/libbsle_host.a
Normal file
BIN
application/lib/1156_ont/libbsle_host.a
Normal file
Binary file not shown.
BIN
application/lib/1156_ont/libsle_host.a
Normal file
BIN
application/lib/1156_ont/libsle_host.a
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user