mirror of
https://github.com/Fishwaldo/bl_mcu_sdk.git
synced 2025-07-22 20:59:03 +00:00
[feat][examples/ble] update ble ld file,add mbedtls for oad,add capcode setting for ble
This commit is contained in:
parent
82ddd766ab
commit
c555e79e07
8 changed files with 95 additions and 34 deletions
|
@ -42,11 +42,16 @@ SECTIONS
|
|||
|
||||
KEEP (*(.text.metal.init.enter))
|
||||
KEEP (*(SORT_NONE(.init)))
|
||||
/* section information for finsh shell */
|
||||
/* section information for shell */
|
||||
. = ALIGN(4);
|
||||
_shell_command_start = .;
|
||||
KEEP(*(shellCommand))
|
||||
_shell_command_end = .;
|
||||
__fsymtab_start = .;
|
||||
KEEP(*(FSymTab))
|
||||
__fsymtab_end = .;
|
||||
|
||||
. = ALIGN(4);
|
||||
__vsymtab_start = .;
|
||||
KEEP(*(VSymTab))
|
||||
__vsymtab_end = .;
|
||||
|
||||
/* section information for usb desc */
|
||||
. = ALIGN(4);
|
||||
|
@ -59,14 +64,18 @@ SECTIONS
|
|||
*(.text.*)
|
||||
|
||||
/*put .rodata**/
|
||||
*(EXCLUDE_FILE( *bl702_glb.o \
|
||||
*bl702_pds.o \
|
||||
*bl702_common.o \
|
||||
*bl702_sf_cfg.o \
|
||||
*bl702_sf_ctrl.o \
|
||||
*bl702_sflash.o \
|
||||
*bl702_xip_sflash.o \
|
||||
*bl702_ef_ctrl.o) .rodata*)
|
||||
*(EXCLUDE_FILE( *bl702_glb*.o* \
|
||||
*bl702_pds*.o* \
|
||||
*bl702_common*.o* \
|
||||
*bl702_sf_cfg*.o* \
|
||||
*bl702_sf_cfg_ext*.o* \
|
||||
*bl702_sf_ctrl*.o* \
|
||||
*bl702_sflash*.o* \
|
||||
*bl702_sflash_ext*.o* \
|
||||
*bl702_xip_sflash*.o* \
|
||||
*bl702_xip_sflash_ext*.o* \
|
||||
*bl702_ef_ctrl*.o*) .rodata*)
|
||||
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
|
||||
|
@ -92,19 +101,22 @@ SECTIONS
|
|||
. = ALIGN(4);
|
||||
__tcm_code_start__ = .;
|
||||
|
||||
*(.tcm_code)
|
||||
*(.tcm_const)
|
||||
*(.sclock_rlt_code)
|
||||
*(.sclock_rlt_const)
|
||||
*(.tcm_code.*)
|
||||
*(.tcm_const.*)
|
||||
*(.sclock_rlt_code.*)
|
||||
*(.sclock_rlt_const.*)
|
||||
|
||||
*bl702_glb.o*(.rodata*)
|
||||
*bl702_pds.o*(.rodata*)
|
||||
*bl702_common.o*(.rodata*)
|
||||
*bl702_sf_cfg.o*(.rodata*)
|
||||
*bl702_sf_ctrl.o*(.rodata*)
|
||||
*bl702_sflash.o*(.rodata*)
|
||||
*bl702_xip_sflash.o*(.rodata*)
|
||||
*bl702_ef_ctrl.o*(.rodata*)
|
||||
*bl702_glb*.o*(.rodata*)
|
||||
*bl702_pds*.o*(.rodata*)
|
||||
*bl702_common*.o*(.rodata*)
|
||||
*bl702_sf_cfg*.o*(.rodata*)
|
||||
*bl702_sf_cfg_ext*.o*(.rodata*)
|
||||
*bl702_sf_ctrl*.o*(.rodata*)
|
||||
*bl702_sflash*.o*(.rodata*)
|
||||
*bl702_sflash_ext*.o*(.rodata*)
|
||||
*bl702_xip_sflash*.o*(.rodata*)
|
||||
*bl702_xip_sflash_ext*.o*(.rodata*)
|
||||
*bl702_ef_ctrl*.o*(.rodata*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__tcm_code_end__ = .;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common)
|
||||
set(TARGET_REQUIRED_SRCS ${CMAKE_CURRENT_LIST_DIR}/ble_central_tp_client.c)
|
||||
set(TARGET_REQUIRED_LIBS freertos ble)
|
||||
set(TARGET_REQUIRED_LIBS freertos ble mbedtls)
|
||||
set(mains main.c)
|
||||
set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/examples/ble/bl702_flash_ble.ld)
|
||||
set(LINKER_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/../bl702_flash_ble.ld)
|
||||
generate_bin()
|
||||
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "log.h"
|
||||
#include "ble_lib_api.h"
|
||||
#include "hci_driver.h"
|
||||
#include "bl702_sec_eng.h"
|
||||
|
||||
#define NAME_LEN 30
|
||||
|
||||
|
@ -265,10 +266,19 @@ int main(void)
|
|||
{
|
||||
static StackType_t ble_init_stack[1024];
|
||||
static StaticTask_t ble_init_task_h;
|
||||
uint32_t tmpVal = 0;
|
||||
|
||||
bflb_platform_init(0);
|
||||
HBN_Set_XCLK_CLK_Sel(HBN_XCLK_CLK_XTAL);
|
||||
|
||||
//Set capcode
|
||||
tmpVal = BL_RD_REG(AON_BASE, AON_XTAL_CFG);
|
||||
tmpVal = BL_SET_REG_BITS_VAL(tmpVal, AON_XTAL_CAPCODE_IN_AON, 33);
|
||||
tmpVal = BL_SET_REG_BITS_VAL(tmpVal, AON_XTAL_CAPCODE_OUT_AON, 33);
|
||||
BL_WR_REG(AON_BASE, AON_XTAL_CFG, tmpVal);
|
||||
|
||||
Sec_Eng_Trng_Enable();
|
||||
|
||||
vPortDefineHeapRegions(xHeapRegions);
|
||||
|
||||
MSG("[OS] ble init task...\r\n");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
```bash
|
||||
|
||||
$ make APP=ble_central BOARD=bl706_iot SUPPORT_FLOAT=y SUPPORT_FREERTOS=y SUPPORT_BLE=y
|
||||
$ make APP=ble_central BOARD=bl706_iot SUPPORT_FLOAT=y
|
||||
|
||||
```
|
|
@ -1,8 +1,7 @@
|
|||
set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common)
|
||||
set(TARGET_REQUIRED_SRCS ${CMAKE_CURRENT_LIST_DIR}/ble_peripheral_tp_server.c)
|
||||
set(TARGET_REQUIRED_LIBS freertos ble)
|
||||
set(TARGET_REQUIRED_LIBS freertos ble mbedtls)
|
||||
set(mains main.c)
|
||||
set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/examples/ble/bl702_flash_ble.ld)
|
||||
set(LINKER_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/../bl702_flash_ble.ld)
|
||||
generate_bin()
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,9 @@ static void ble_tp_connected(struct bt_conn *conn, u8_t err);
|
|||
static void ble_tp_disconnected(struct bt_conn *conn, u8_t reason);
|
||||
|
||||
static struct bt_conn *ble_tp_conn;
|
||||
#if !defined(CONFIG_BT_OAD_SERVER)
|
||||
static struct bt_gatt_exchange_params exchg_mtu;
|
||||
#endif
|
||||
static TaskHandle_t ble_tp_task_h;
|
||||
|
||||
static struct k_sem notify_poll_sem;
|
||||
|
@ -41,6 +43,7 @@ static struct bt_conn_cb ble_tp_conn_callbacks = {
|
|||
.disconnected = ble_tp_disconnected,
|
||||
};
|
||||
|
||||
#if !defined(CONFIG_BT_OAD_SERVER)
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_tp_tx_mtu_size
|
||||
|
@ -55,16 +58,18 @@ static void ble_tp_tx_mtu_size(struct bt_conn *conn, u8_t err,
|
|||
BT_WARN("ble tp echange mtu size failure, err: %d", err);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
/*************************************************************************
|
||||
NAME
|
||||
ble_tp_connected
|
||||
*/
|
||||
static void ble_tp_connected(struct bt_conn *conn, u8_t err)
|
||||
{
|
||||
#if !defined(CONFIG_BT_OAD_SERVER)
|
||||
int tx_octets = 0x00fb;
|
||||
int tx_time = 0x0848;
|
||||
int ret = -1;
|
||||
#endif
|
||||
|
||||
if (err) {
|
||||
return;
|
||||
|
@ -73,6 +78,7 @@ static void ble_tp_connected(struct bt_conn *conn, u8_t err)
|
|||
BT_WARN("Tp connected");
|
||||
ble_tp_conn = conn;
|
||||
|
||||
#if !defined(CONFIG_BT_OAD_SERVER)
|
||||
//set data length after connected.
|
||||
ret = bt_le_set_data_len(ble_tp_conn, tx_octets, tx_time);
|
||||
|
||||
|
@ -91,6 +97,7 @@ static void ble_tp_connected(struct bt_conn *conn, u8_t err)
|
|||
} else {
|
||||
BT_WARN("ble tp exchange mtu size failure, err: %d", ret);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
|
|
|
@ -29,6 +29,12 @@
|
|||
#include "ble_peripheral_tp_server.h"
|
||||
#include "ble_lib_api.h"
|
||||
#include "hci_driver.h"
|
||||
#include "bl702_sec_eng.h"
|
||||
|
||||
#if defined(CONFIG_BT_OAD_SERVER)
|
||||
#include "oad_main.h"
|
||||
#include "oad_service.h"
|
||||
#endif
|
||||
|
||||
extern uint8_t _heap_start;
|
||||
extern uint8_t _heap_size; // @suppress("Type cannot be resolved")
|
||||
|
@ -127,16 +133,32 @@ int ble_start_adv(void)
|
|||
};
|
||||
|
||||
char *adv_name = "BL_TEST_01"; // This name must be the same as adv_name in ble_central
|
||||
struct bt_data adv_data[] = {
|
||||
struct bt_data adv_data[2] = {
|
||||
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_NO_BREDR | BT_LE_AD_GENERAL)),
|
||||
BT_DATA(BT_DATA_NAME_COMPLETE, adv_name, strlen(adv_name)),
|
||||
};
|
||||
|
||||
return bt_le_adv_start(&adv_param, adv_data, ARRAY_SIZE(adv_data), NULL, 0);
|
||||
return bt_le_adv_start(&adv_param, adv_data, ARRAY_SIZE(adv_data), &adv_data[1], 1);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_OAD_SERVER)
|
||||
bool app_check_oad(u32_t cur_file_ver, u32_t new_file_ver)
|
||||
{
|
||||
//App layer decides whether to do oad according to file version
|
||||
/*if(new_file_ver > cur_file_ver)
|
||||
return true;
|
||||
else
|
||||
return false;*/
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
void bt_enable_cb(int err)
|
||||
{
|
||||
ble_tp_init();
|
||||
#if defined(CONFIG_BT_OAD_SERVER)
|
||||
oad_service_enable(app_check_oad);
|
||||
#endif
|
||||
ble_start_adv();
|
||||
}
|
||||
|
||||
|
@ -169,10 +191,19 @@ int main(void)
|
|||
{
|
||||
static StackType_t ble_init_stack[1024];
|
||||
static StaticTask_t ble_init_task_h;
|
||||
uint32_t tmpVal = 0;
|
||||
|
||||
bflb_platform_init(0);
|
||||
HBN_Set_XCLK_CLK_Sel(HBN_XCLK_CLK_XTAL);
|
||||
|
||||
//Set capcode
|
||||
tmpVal = BL_RD_REG(AON_BASE, AON_XTAL_CFG);
|
||||
tmpVal = BL_SET_REG_BITS_VAL(tmpVal, AON_XTAL_CAPCODE_IN_AON, 33);
|
||||
tmpVal = BL_SET_REG_BITS_VAL(tmpVal, AON_XTAL_CAPCODE_OUT_AON, 33);
|
||||
BL_WR_REG(AON_BASE, AON_XTAL_CFG, tmpVal);
|
||||
|
||||
Sec_Eng_Trng_Enable();
|
||||
|
||||
vPortDefineHeapRegions(xHeapRegions);
|
||||
|
||||
MSG("[OS] ble_init_task.....\r\n");
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
```bash
|
||||
|
||||
$ make APP=ble_peripheral BOARD=bl706_iot SUPPORT_FLOAT=y SUPPORT_FREERTOS=y SUPPORT_BLE=y
|
||||
$ make APP=ble_peripheral BOARD=bl706_iot SUPPORT_FLOAT=y
|
||||
|
||||
The Ble OTA function is enable by add command "set(CONFIG_BT_OAD_SERVER 1) " , in the script file “ble_flags.cmake”
|
||||
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue