This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

BT_SETTINGS CCCD creates more flash storage

HI,

i have enabled CONFIG_BT_SETTINGS_CCC_STORE_ON_WRITE=y

so after power cycle the device automatically connects with iphone and the service also works fine

after this

I found that RAM flash memory

gets increase at every disconnect and connect

Example

I connect the device with nrf connect app desktop -> programmer

i read the device and found

flash NVM size  25 bytes from F8000

                          24 bytes from F8FF7.

after connected and paired with iphone 8 plus

flash NVM size  158 bytes from F8000

                          72 bytes from F8FF7.

again read the device

flash NVM size  195 bytes from F8000

                          104 bytes from F8FF7.

I need to work on DFU and also NVM flash storage to store 5KB data. My concern is because of this memory increase . where it get collapse or not

to memories the CCCD where only enable is memorize and disable is not to be memorize is it possible

because

when device is out of bound then it will disconnect at the time memory will increase and then in bound it auto connect and that also write .

i want to control this only write the enable function

2. How to delete the particular CCCD stored flash page

3. how to delete the pair bond stored flash page . peer bond data is controlled by softdevice

Parents
  • Hi,

    I think the best way to solve this is to set CONFIG_BT_MAX_PAIRED to the max number of devices/Bluetooth bonds you want to support.
    If you set CONFIG_BT_KEYS_OVERWRITE_OLDEST=y the Bluetooth Host will overwrite oldest keys with new ones if key storage is full.

  • currently i have used prj.conf is

    
    #CONFIG_NCS_SAMPLES_DEFAULTS=y
    
    #BT config
    CONFIG_BT=y
    CONFIG_BT_DEBUG_LOG=y
    CONFIG_BT_MAX_CONN=2
    CONFIG_BT_MAX_PAIRED=1
    CONFIG_BT_SMP=y
    CONFIG_BT_L2CAP_TX_BUF_COUNT=5
    CONFIG_BT_PERIPHERAL=y
    
    #Devie Name config
    CONFIG_BT_DEVICE_NAME="Headset"
    CONFIG_BT_DEVICE_APPEARANCE=961
    
    #Device Info service config
    CONFIG_BT_DIS=y
    CONFIG_BT_DIS_PNP=y
    CONFIG_BT_DIS_MANUF="NordicSemiconductor"
    CONFIG_BT_DIS_PNP_VID_SRC=2
    CONFIG_BT_DIS_PNP_VID=0x1915
    CONFIG_BT_DIS_PNP_PID=0xEEEF
    CONFIG_BT_DIS_PNP_VER=0x0100
    
    #Battery Service Config
    CONFIG_BT_BAS=y
    
    #HID config
    CONFIG_BT_HIDS=y
    CONFIG_BT_HIDS_MAX_CLIENT_COUNT=1
    CONFIG_BT_HIDS_DEFAULT_PERM_RW_ENCRYPT=y
    CONFIG_BT_GATT_UUID16_POOL_SIZE=40
    CONFIG_BT_GATT_CHRC_POOL_SIZE=20
    
    CONFIG_BT_LL_SOFTDEVICE_DEFAULT=y
    CONFIG_BT_CONN_CTX=y
    
    # Enable the NUS service
    CONFIG_BT_NUS=y
    CONFIG_BT_NUS_UART_BUFFER_SIZE=300 
    
    # Enable bonding
    CONFIG_BT_SETTINGS=y
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_NVS=y
    CONFIG_SETTINGS=y
    CONFIG_BT_SETTINGS_CCC_STORE_ON_WRITE=y
    
    # Enable DK LED and Buttons library
    CONFIG_DK_LIBRARY=y
    
    # This example requires more workqueue stack
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    # Enable the UART driver
    CONFIG_UART_ASYNC_API=y
    CONFIG_NRFX_UARTE1=y
    CONFIG_SERIAL=y		
    
    CONFIG_GPIO=y
    
    # Make sure printk is not printing to the UART console
    CONFIG_CONSOLE=y
    CONFIG_RTT_CONSOLE=n
    CONFIG_UART_CONSOLE=y
    CONFIG_PRINTK=y
    
    CONFIG_HEAP_MEM_POOL_SIZE=2048
    
    
    # Config logger
    CONFIG_LOG=y
    CONFIG_LOG_BUFFER_SIZE=2048
    CONFIG_LOG_PRINTK=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_LOG_BACKEND_UART=n
    
    CONFIG_ASSERT=y
    
    # Clock configuration
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_SYNTH=y
    
    # I2C Enable
    CONFIG_I2C=y
    CONFIG_SENSOR=y
    
    #MLX90393 Enable
    CONFIG_MLX90393=y
    CONFIG_MLX90393_TRIGGER_GLOBAL_THREAD=y
    
    # NFC configuration
    CONFIG_NFC_OOB_PAIRING=n
    
    # Optimize for debug
    CONFIG_DEBUG_OPTIMIZATIONS=y
    
    # Added
    
    CONFIG_BT_GATT_CLIENT=y
    CONFIG_BT_USER_DATA_LEN_UPDATE=y
    CONFIG_BT_RX_BUF_LEN=260
    CONFIG_BT_ATT_TX_MAX=10
    CONFIG_BT_ATT_PREPARE_COUNT=2
    CONFIG_BT_CONN_TX_MAX=10
    CONFIG_BT_L2CAP_TX_BUF_COUNT=10
    CONFIG_BT_L2CAP_TX_MTU=252
    CONFIG_BT_L2CAP_RX_MTU=252
    CONFIG_BT_CTLR_TX_BUFFER_SIZE=251
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    
    
    # Added for FOTA
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_MCUMGR=y
    CONFIG_MCUMGR_CMD_OS_MGMT=y
    CONFIG_MCUMGR_CMD_IMG_MGMT=y
    CONFIG_MCUMGR_SMP_BT=y
    CONFIG_IMG_ERASE_PROGRESSIVELY=y
    CONFIG_MCUMGR_SMP_BT_AUTHEN=n

    1 . if i set max_pair to be 1 when i connect second device it will over write  if i enable keys_overwrite_oldest?

    2. what will happen for CCCD flash writes how to over write the CCCD enable disable in same flash address

    3. Is it possible to delete the pairing data from flash storage . and how?

    i have enabled DFU

    before dfu the flash starts at 0xF8000 and now it starts at 0xFE000 why?

Reply
  • currently i have used prj.conf is

    
    #CONFIG_NCS_SAMPLES_DEFAULTS=y
    
    #BT config
    CONFIG_BT=y
    CONFIG_BT_DEBUG_LOG=y
    CONFIG_BT_MAX_CONN=2
    CONFIG_BT_MAX_PAIRED=1
    CONFIG_BT_SMP=y
    CONFIG_BT_L2CAP_TX_BUF_COUNT=5
    CONFIG_BT_PERIPHERAL=y
    
    #Devie Name config
    CONFIG_BT_DEVICE_NAME="Headset"
    CONFIG_BT_DEVICE_APPEARANCE=961
    
    #Device Info service config
    CONFIG_BT_DIS=y
    CONFIG_BT_DIS_PNP=y
    CONFIG_BT_DIS_MANUF="NordicSemiconductor"
    CONFIG_BT_DIS_PNP_VID_SRC=2
    CONFIG_BT_DIS_PNP_VID=0x1915
    CONFIG_BT_DIS_PNP_PID=0xEEEF
    CONFIG_BT_DIS_PNP_VER=0x0100
    
    #Battery Service Config
    CONFIG_BT_BAS=y
    
    #HID config
    CONFIG_BT_HIDS=y
    CONFIG_BT_HIDS_MAX_CLIENT_COUNT=1
    CONFIG_BT_HIDS_DEFAULT_PERM_RW_ENCRYPT=y
    CONFIG_BT_GATT_UUID16_POOL_SIZE=40
    CONFIG_BT_GATT_CHRC_POOL_SIZE=20
    
    CONFIG_BT_LL_SOFTDEVICE_DEFAULT=y
    CONFIG_BT_CONN_CTX=y
    
    # Enable the NUS service
    CONFIG_BT_NUS=y
    CONFIG_BT_NUS_UART_BUFFER_SIZE=300 
    
    # Enable bonding
    CONFIG_BT_SETTINGS=y
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_NVS=y
    CONFIG_SETTINGS=y
    CONFIG_BT_SETTINGS_CCC_STORE_ON_WRITE=y
    
    # Enable DK LED and Buttons library
    CONFIG_DK_LIBRARY=y
    
    # This example requires more workqueue stack
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    # Enable the UART driver
    CONFIG_UART_ASYNC_API=y
    CONFIG_NRFX_UARTE1=y
    CONFIG_SERIAL=y		
    
    CONFIG_GPIO=y
    
    # Make sure printk is not printing to the UART console
    CONFIG_CONSOLE=y
    CONFIG_RTT_CONSOLE=n
    CONFIG_UART_CONSOLE=y
    CONFIG_PRINTK=y
    
    CONFIG_HEAP_MEM_POOL_SIZE=2048
    
    
    # Config logger
    CONFIG_LOG=y
    CONFIG_LOG_BUFFER_SIZE=2048
    CONFIG_LOG_PRINTK=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_LOG_BACKEND_UART=n
    
    CONFIG_ASSERT=y
    
    # Clock configuration
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_SYNTH=y
    
    # I2C Enable
    CONFIG_I2C=y
    CONFIG_SENSOR=y
    
    #MLX90393 Enable
    CONFIG_MLX90393=y
    CONFIG_MLX90393_TRIGGER_GLOBAL_THREAD=y
    
    # NFC configuration
    CONFIG_NFC_OOB_PAIRING=n
    
    # Optimize for debug
    CONFIG_DEBUG_OPTIMIZATIONS=y
    
    # Added
    
    CONFIG_BT_GATT_CLIENT=y
    CONFIG_BT_USER_DATA_LEN_UPDATE=y
    CONFIG_BT_RX_BUF_LEN=260
    CONFIG_BT_ATT_TX_MAX=10
    CONFIG_BT_ATT_PREPARE_COUNT=2
    CONFIG_BT_CONN_TX_MAX=10
    CONFIG_BT_L2CAP_TX_BUF_COUNT=10
    CONFIG_BT_L2CAP_TX_MTU=252
    CONFIG_BT_L2CAP_RX_MTU=252
    CONFIG_BT_CTLR_TX_BUFFER_SIZE=251
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    
    
    # Added for FOTA
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_MCUMGR=y
    CONFIG_MCUMGR_CMD_OS_MGMT=y
    CONFIG_MCUMGR_CMD_IMG_MGMT=y
    CONFIG_MCUMGR_SMP_BT=y
    CONFIG_IMG_ERASE_PROGRESSIVELY=y
    CONFIG_MCUMGR_SMP_BT_AUTHEN=n

    1 . if i set max_pair to be 1 when i connect second device it will over write  if i enable keys_overwrite_oldest?

    2. what will happen for CCCD flash writes how to over write the CCCD enable disable in same flash address

    3. Is it possible to delete the pairing data from flash storage . and how?

    i have enabled DFU

    before dfu the flash starts at 0xF8000 and now it starts at 0xFE000 why?

Children
No Data
Related