出现问题后,我尝试把standby关闭,取消待机机制,连接和广播就都正常了,但是功耗极大,不符合实际需求。介于 MEM ALLOC ERR部分代码被封装了,想问问有什么解决办法?我也试过用定时器自己控制待机周期,也没成功
以下是问题阐述:
在从机广播操作完成后取消standby锁,用以降低功耗
if(sys_msg.ble_on == 1)
{
printf("XXXXXXX bt_le_adv_start\n");
if(IS_ENABLED(CONFIG_BT_EXT_ADV))
{
err = bt_le_adv_start(BT_LE_EXT_ADV_CONN_NAME_ONE_SHOT, ad, ARRAY_SIZE(ad), NULL, 0);
}
else
{
err = bt_le_adv_start(BT_LE_ADV_CONN_NAME_ONE_SHOT, ad, ARRAY_SIZE(ad), NULL, 0);
}
}
if (err)
{
printf("Advertising failed to start (err 0x%02x)\n", err);
}
else
{
SleepUnlock(SLEEP_LOCK_BLE);
}
这时,广播期间log出现MEM FREE ERR
ble rf_init done!
resume noirq devices took 1990 ms
resume devices took 0 ms
<E> <E> MEM FREE ERR 4: 0x00235A98, 06-02-AA-AE
suspend devices took 0 ms
在此状态下连接主机,从机连接报错
[H] Connected!!
========== Connection Parameter ==========
= Remote Address 21:90:34:00:20:EA
= Internval 24
= Latency 0
= Timeout 500
==========================================
vnd_ccc_cfg_changed vale=1
handle 0 ref 2 -> 1
<E> MEM ALLOC ERR 3:pool_idx 6, blck_cnt 151, no buf pool
<E> pool id: 1<E> slave should not send only 1 pkt with retransmit
<E> MEM ALLOC ERR 3:pool_idx 6, blck_cnt 151, no buf pool
<E> MEM FREE ERR 0: ptr_mem invalue
<E> cmd buff err<E> MEM ALLOC ERR 3:pool_idx 6, blck_cnt 151, no buf pool
<E> pool id: 1<E> EXEC error
<E> MEM ALLOC ERR 3:pool_idx 6, blck_cnt 151, no buf pool
<E> pool id: 1<E> EXEC error
<E> MEM ALLOC ERR 3:pool_idx 6, blck_cnt 151, no buf pool
<E> pool id: 1<E> EXEC error
而后,连接终止并断开
[bt] bt_recv: evt_flags & BT_HCI_EVT_FLAG_RECV_PRIO
[bt] hci_event_prio: hci_event_prio
[bt] hci_disconn_complete_prio: status 0x00 handle 0 reason 0x08
[bt] bt_conn_ref: handle 0 ref 1 -> 2
handle 0 ref 2 -> 1
[bt] hci_rx_thread: BT_BUF_EVT
[bt] hci_event: hci_event
[bt] hci_disconn_complete: status 0x00 handle 0 reason 0x08
[bt] bt_conn_ref: handle 0 ref 1 -> 2
handle 0 ref 2 -> 1
vnd_ccc_cfg_changed vale=0
[H] Disconnected 61:79:78:76:EB:47 reason 0x08
XXXXXXX bt_le_adv_start
bt_le_adv_start_legacy
[H] Disconnected 5F:72:B7:49:FD:42 reason 0x08
XXXXXXX bt_le_adv_start
bt_le_adv_start_legacy
*************************************************
[RandomAddress C0:66:66:61:88:88 ]
*************************************************
[bt] bt_le_adv_start_legacy: dir_adv=0
[bt] bt_le_adv_start_legacy: &adv->target_addr.a=
000000000000
bt_hci_cmd_send_sync()
[bt] bt_hci_cmd_send_sync: buf 0x23e3e8 opcode 0x2006 len 18 status 0x00
但在重新广播时,只运行到以下函数
param->peer == NULL
le_adv_update
bt_get_name
set_ad()
hci_set_ad()
而正常广播流程在hci_set_ad()后还会接着走
bt_hci_cmd_send_sync()
以下是我的prj_config.h 、 .config配置和free空间:
prj_config.h
#ifndef _PRJ_CONFIG_H_
#define _PRJ_CONFIG_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "user_src/task_wifi_comm.h"
/*
* project base config
*/
/* main thread priority */
#define PRJCONF_MAIN_THREAD_PRIO OS_THREAD_PRIO_APP
/* main thread stack size */
#define PRJCONF_MAIN_THREAD_STACK_SIZE (2 * 1024)
/* sys ctrl enable/disable */
#define PRJCONF_SYS_CTRL_EN 1
/* sys ctrl thread priority */
#define PRJCONF_SYS_CTRL_PRIO OS_THREAD_PRIO_SYS_CTRL
/* sys ctrl stack size */
#define PRJCONF_SYS_CTRL_STACK_SIZE (2 * 1024)
/* sys ctrl queue length for receiving message */
#define PRJCONF_SYS_CTRL_QUEUE_LEN 6
/* image flash ID */
#define PRJCONF_IMG_FLASH 0
/* image start address, including bootloader */
#define PRJCONF_IMG_ADDR 0x00000000
/* save sysinfo to flash or not */
#define PRJCONF_SYSINFO_SAVE_TO_FLASH 1
#if PRJCONF_SYSINFO_SAVE_TO_FLASH
/* sysinfo flash ID */
#define PRJCONF_SYSINFO_FLASH 0
/* sysinfo start address */
#define PRJCONF_SYSINFO_ADDR ((1024 - 4) * 1024)
/* sysinfo size */
#define PRJCONF_SYSINFO_SIZE (4 * 1024)
/* enable/disable checking whether sysinfo is overlap with image */
#define PRJCONF_SYSINFO_CHECK_OVERLAP 1
#endif /* PRJCONF_SYSINFO_SAVE_TO_FLASH */
/* MAC address source */
#define PRJCONF_MAC_ADDR_SOURCE SYSINFO_MAC_ADDR_CHIPID//SYSINFO_MAC_ADDR_FLASH
/* watchdog enable/disable */
#define PRJCONF_WDG_EN 1
/* watchdog timeout value */
#define PRJCONF_WDG_TIMEOUT WDG_TIMEOUT_16SEC
/* watchdog feeding period (in ms), MUST less than PRJCONF_WDG_TIMEOUT */
#define PRJCONF_WDG_FEED_PERIOD (10 * 1000)
/*
* project hardware feature
*/
/* uart enable/disable */
#if UART_DEBUG
#define PRJCONF_UART_EN 1
#else
#define PRJCONF_UART_EN 0
#endif
/* h/w crypto engine enable/disable */
#define PRJCONF_CE_EN 0
/* spi enable/disable */
#define PRJCONF_SPI_EN 1
/* Xradio internal codec sound card enable/disable */
#define PRJCONF_INTERNAL_SOUNDCARD_EN 0
/* AC107 sound card enable/disable */
#define PRJCONF_AC107_SOUNDCARD_EN 0
/*
* project service feature
*/
/* console enable/disable */
#define PRJCONF_CONSOLE_EN 0
/* network and wlan enable/disable */
#define PRJCONF_NET_EN 1
/* ble enable/disable */
#define PRJCONF_BLE_EN 1
/* environment variable "TZ" for time zone setting */
#define PRJCONF_ENV_TZ "TZ=GMT-8"
#ifdef __cplusplus
}
#endif
#endif /* _PRJ_CONFIG_H_ */
.config
#
# Automatically generated file; DO NOT EDIT.
# XR806 SDK Configuration
#
CONFIG_PROJECT="demo/at_demo"
#
# Project settings
#
CONFIG_CHIP_XR806=y
# CONFIG_HOSC_TYPE_24M is not set
# CONFIG_HOSC_TYPE_26M is not set
# CONFIG_HOSC_TYPE_32M is not set
CONFIG_HOSC_TYPE_40M=y
CONFIG_BOARD="xr806_dig_ver"
CONFIG_DEFAULT_FLASH_FLASHC=y
# CONFIG_DEFAULT_FLASH_SPI is not set
CONFIG_XIP=y
# CONFIG_PSRAM is not set
CONFIG_CACHE=y
# CONFIG_CACHE_SIZE_8K is not set
# CONFIG_CACHE_SIZE_16K is not set
CONFIG_CACHE_SIZE_32K=y
CONFIG_OTA=y
# CONFIG_OTA_POLICY_PINGPONG is not set
CONFIG_OTA_POLICY_IMAGE_COMPRESSION=y
# CONFIG_XPLAYER is not set
# CONFIG_BIN_COMPRESS is not set
# CONFIG_BENCH_MARK is not set
CONFIG_MSP_STACK_SIZE=1024
# CONFIG_BOOTLOADER is not set
# end of Project settings
CONFIG_PWR_INTERNAL_LDO=y
# CONFIG_PWR_INTERNAL_DCDC is not set
# CONFIG_PWR_EXTERNAL is not set
CONFIG_WLAN=y
#
# Networking options
#
CONFIG_MBEDTLS_VER="2.16.0"
# CONFIG_LWIP_VER_1_4_1 is not set
# CONFIG_LWIP_VER_2_0_3 is not set
CONFIG_LWIP_VER_2_1_2=y
# end of Networking options
CONFIG_WIFI_CERTIFIED=y
CONFIG_WLAN_STA=y
# CONFIG_WLAN_STA_WPS is not set
# CONFIG_WLAN_MONITOR is not set
# CONFIG_WLAN_AP is not set
# CONFIG_ETF is not set
CONFIG_MBUF_IMPL_MODE=0
# CONFIG_MUTIL_NET_STACK is not set
CONFIG_BLE_FEATURE=y
CONFIG_BLE=y
CONFIG_BT=y
CONFIG_BLEHOST=y
CONFIG_BLEHOST_Z_ITERABLE_SECTION=y
# CONFIG_BT_LOG_LEVEL_OFF is not set
# CONFIG_BT_LOG_LEVEL_ERR is not set
# CONFIG_BT_LOG_LEVEL_WRN is not set
CONFIG_BT_LOG_LEVEL_INF=y
# CONFIG_BT_LOG_LEVEL_DBG is not set
CONFIG_BT_LOG_LEVEL=3
CONFIG_BT_HCI=y
# CONFIG_BT_CUSTOM is not set
# CONFIG_BT_HCI_RAW is not set
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_BROADCASTER=y
# CONFIG_BT_EXT_ADV is not set
CONFIG_BT_OBSERVER=y
CONFIG_BT_CONN=y
CONFIG_BT_MAX_CONN=5
CONFIG_BT_HCI_ACL_FLOW_CONTROL=y
CONFIG_BT_REMOTE_VERSION=y
CONFIG_BT_PHY_UPDATE=y
CONFIG_BT_DATA_LEN_UPDATE=y
CONFIG_BT_DEINIT=y
CONFIG_BT_VAR_MEM_DYNC_ALLOC=y
CONFIG_BT_RPA=y
CONFIG_BT_ASSERT=y
CONFIG_BT_ASSERT_VERBOSE=y
# CONFIG_BT_ASSERT_PANIC is not set
CONFIG_BT_DEBUG=y
# CONFIG_BT_DEBUG_NONE is not set
# CONFIG_BT_DEBUG_LOG is not set
# CONFIG_BT_DEBUG_LOG_WITH_HCI_PRINT is not set
CONFIG_BTSNOOP=y
# CONFIG_BT_DEBUG_RPA is not set
#
# Networking
#
CONFIG_NET_BUF=y
CONFIG_NET_BUF_USER_DATA_SIZE=4
# CONFIG_NET_BUF_LOG is not set
# CONFIG_NET_BUF_LOG_LEVEL_OFF is not set
# CONFIG_NET_BUF_LOG_LEVEL_ERR is not set
# CONFIG_NET_BUF_LOG_LEVEL_WRN is not set
CONFIG_NET_BUF_LOG_LEVEL_INF=y
# CONFIG_NET_BUF_LOG_LEVEL_DBG is not set
CONFIG_NET_BUF_LOG_LEVEL=3
# CONFIG_NET_BUF_POOL_USAGE is not set
# end of Networking
#
# Debugging Options
#
CONFIG_ASSERT=y
CONFIG_ASSERT_LEVEL=2
# CONFIG_FORCE_NO_ASSERT is not set
# end of Debugging Options
CONFIG_LOG=y
#
# Logging levels filtering
#
CONFIG_LOG_DEFAULT_LEVEL=0
# end of Logging levels filtering
#
# Output Formatting
#
#
# Prepend non-hexdump log message with function name
#
CONFIG_LOG_FUNC_NAME_PREFIX_ERR=y
CONFIG_LOG_FUNC_NAME_PREFIX_WRN=y
CONFIG_LOG_FUNC_NAME_PREFIX_INF=y
CONFIG_LOG_FUNC_NAME_PREFIX_DBG=y
# end of Prepend non-hexdump log message with function name
# CONFIG_LOG_BACKEND_SHOW_COLOR is not set
# CONFIG_LOG_SHOW_TAGS is not set
# end of Output Formatting
# CONFIG_SETTINGS is not set
#
# Work Queue Options
#
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_SYSTEM_WORKQUEUE_PRIORITY=3
# end of Work Queue Options
CONFIG_POLL=y
CONFIG_SYS_CLOCK_EXISTS=y
#
# Host Stack Configuration
#
CONFIG_BT_HCI_HOST=y
CONFIG_BT_HCI_CMD_COUNT=2
CONFIG_BT_RX_BUF_COUNT=20
CONFIG_BT_RX_BUF_LEN=255
CONFIG_BT_DISCARDABLE_BUF_SIZE=255
CONFIG_BT_HCI_TX_STACK_SIZE=512
CONFIG_BT_HCI_ECC_STACK_SIZE=1024
CONFIG_BT_HCI_TX_PRIO=3
CONFIG_BT_HCI_RESERVE=0
CONFIG_BT_RX_STACK_SIZE=2200
CONFIG_BT_RX_PRIO=4
CONFIG_BT_HOST_CRYPTO=y
CONFIG_BT_WHITELIST=y
CONFIG_BT_ACL_RX_COUNT=6
CONFIG_BT_CONN_TX_MAX=8
CONFIG_BT_USER_PHY_UPDATE=y
# CONFIG_BT_AUTO_PHY_UPDATE is not set
CONFIG_BT_USER_DATA_LEN_UPDATE=y
# CONFIG_BT_AUTO_DATA_LEN_UPDATE is not set
CONFIG_BT_REMOTE_INFO=y
CONFIG_BT_SMP=y
# CONFIG_BT_PRIVACY is not set
CONFIG_BT_SIGNING=y
CONFIG_BT_SMP_APP_PAIRING_ACCEPT=y
# CONFIG_BT_SMP_SC_PAIR_ONLY is not set
# CONFIG_BT_SMP_SC_ONLY is not set
# CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY is not set
# CONFIG_BT_SMP_DISABLE_LEGACY_JW_PASSKEY is not set
CONFIG_BT_SMP_ALLOW_UNAUTH_OVERWRITE=y
# CONFIG_BT_FIXED_PASSKEY is not set
# CONFIG_BT_USE_DEBUG_KEYS is not set
CONFIG_BT_BONDABLE=y
# CONFIG_BT_BONDING_REQUIRED is not set
# CONFIG_BT_STORE_DEBUG_KEYS is not set
CONFIG_BT_SMP_ENFORCE_MITM=y
CONFIG_BT_KEYS_OVERWRITE_OLDEST=y
#
# L2CAP Options
#
CONFIG_BT_L2CAP_RX_MTU=247
CONFIG_BT_L2CAP_TX_BUF_COUNT=8
CONFIG_BT_L2CAP_TX_FRAG_COUNT=2
CONFIG_BT_L2CAP_TX_MTU=247
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
# CONFIG_BT_L2CAP_ECRED is not set
# CONFIG_BT_DEBUG_L2CAP is not set
# end of L2CAP Options
#
# ATT and GATT Options
#
# CONFIG_BT_ATT_ENFORCE_FLOW is not set
CONFIG_BT_ATT_PREPARE_COUNT=14
CONFIG_BT_GATT_SERVICE_CHANGED=y
CONFIG_BT_GATT_DYNAMIC_DB=y
# CONFIG_BT_GATT_CACHING is not set
CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_GATT_READ_MULTIPLE=y
CONFIG_BT_GATT_AUTO_DISCOVER_CCC=y
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=y
# CONFIG_BT_GAP_PERIPHERAL_PREF_PARAMS is not set
CONFIG_BT_DEVICE_NAME_GATT_WRITABLE=y
# CONFIG_BT_DEBUG_ATT is not set
# CONFIG_BT_DEBUG_GATT is not set
# end of ATT and GATT Options
CONFIG_BT_MAX_PAIRED=5
CONFIG_BT_CREATE_CONN_TIMEOUT=3
CONFIG_BT_CONN_PARAM_UPDATE_TIMEOUT=5000
CONFIG_BT_BACKGROUND_SCAN_INTERVAL=2048
CONFIG_BT_BACKGROUND_SCAN_WINDOW=18
# CONFIG_BT_SCAN_WITH_IDENTITY is not set
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
CONFIG_BT_DEVICE_NAME_MAX=28
CONFIG_BT_DEVICE_NAME="Xradio"
CONFIG_BT_DEVICE_APPEARANCE=192
CONFIG_BT_ID_MAX=2
# CONFIG_BT_DF is not set
CONFIG_BT_ECC=y
CONFIG_BT_TINYCRYPT_ECC=y
CONFIG_BT_HOST_CCM=y
# CONFIG_BT_DEBUG_RESOURCES_USE is not set
# CONFIG_BT_DEBUG_HCI_CORE is not set
# CONFIG_BT_DEBUG_CONN is not set
# CONFIG_BT_DEBUG_ISO is not set
# CONFIG_BT_DEBUG_KEYS is not set
# CONFIG_BT_DEBUG_SMP is not set
# CONFIG_BT_DEBUG_SERVICE is not set
# CONFIG_BT_TESTING is not set
# CONFIG_BT_HCI_VS_EVT_USER is not set
CONFIG_BT_COMPANY_ID=0x05F1
# CONFIG_BT_MESH is not set
CONFIG_BT_PWR_MGR=y
CONFIG_BT_XR_IMPL=y
#
# Console options
#
CONFIG_CONSOLE_CMD_LINE_SIZE=512
# end of Console options
# CONFIG_FILESYSTEMS is not set
#
# Kernel options
#
CONFIG_OS_FREERTOS=y
CONFIG_FREERTOS_VER_10_2_1=y
CONFIG_OS_FREERTOS_VERSION_STR="v10.2.1"
# CONFIG_OS_USE_IDLE_HOOK is not set
# end of Kernel options
#
# Devices Driver options
#
#
# Devices options
#
# CONFIG_FLASH_ERASE_WRITE_DISABLE_IRQ is not set
# CONFIG_FLASH_POWER_DOWN_PROTECT is not set
CONFIG_FLASH_PM_ALLOW_ENTER_PWR_DOWN=y
CONFIG_FLASH_ARBIT=y
CONFIG_FLASH_ERASE_DURATION=60
CONFIG_FLASH_WRITE_DURATION=10
#
# PSRAM Devices
#
# end of PSRAM Devices
#
# SDMMC Devices
#
# end of SDMMC Devices
# CONFIG_IR_USED_CLK_32K is not set
# end of Devices options
#
# AXP PMU support
#
# CONFIG_AXP_CORE is not set
# end of AXP PMU support
# CONFIG_DA217 is not set
# end of Devices Driver options
CONFIG_PM=y
CONFIG_PM_WAKELOCKS=y
CONFIG_PM_TRY_NUM_WHEN_FAIL=0
CONFIG_PM_IDLE_SUSPEND=y
CONFIG_STANDBY_RET_SRAM=y
CONFIG_STANDBY_RET_SRAM_ALL=y
# CONFIG_WAKEUP_PIN is not set
CONFIG_BLE_LOW_PWR_MODE=y
CONFIG_PM_DEBUG_LEVEL=4
#
# Security options
#
# CONFIG_SECURE_BOOT is not set
# CONFIG_FLASH_CRYPTO is not set
# CONFIG_TRUSTZONE is not set
# end of Security options
#
# Feature options
#
CONFIG_LIBC_REDEFINE_GCC_INT32_TYPE=y
CONFIG_LIBC_PRINTF_FLOAT=y
CONFIG_LIBC_SCANF_FLOAT=y
CONFIG_LIBC_WRAP_STDIO=y
CONFIG_MALLOC_MODE=0
CONFIG_SECTION_ATTRIBUTE_XIP=y
CONFIG_SECTION_ATTRIBUTE_NONXIP=y
CONFIG_SECTION_ATTRIBUTE_SRAM=y
# end of Feature options
#
# Debug options
#
# CONFIG_OS_DEBUG_CPU_USAGE is not set
CONFIG_MALLOC_TRACE=y
# CONFIG_BACKTRACE is not set
# CONFIG_WATCHPOINT is not set
# CONFIG_HEAP_FREE_CHECK is not set
# CONFIG_PSRAM_MALLOC_TRACE is not set
CONFIG_ROM_FREERTOS=y
CONFIG_REDUCE_DBG_MSG=y
# CONFIG_REDUCE_RAM is not set
# CONFIG_WLAN_SHARE_RAM is not set
# CONFIG_EXT_FLASH_ONLY is not set
CONFIG_ROM=y
CONFIG_ROM_XZ=y
# end of Debug options
# CONFIG_CPLUSPLUS is not set
free
total used free shared buff/cache available
Mem: 28491712 3856648 20704212 62280 3930852 24141956
Swap: 945416 0 945416