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

Problem 'stopped by vector catch' in allocating RAM when I added a new ble service" (nrf52840 sdk15.3.0)

Hello,everyone

I want to add dfu service in UART example ,but when I tried to allocate the RAM,Debug terminal shows nothing,Then I set the breakpoint in nrf_sdh_ble.c and debugging,I can't enter the C file,

After I set breakpoint in main.c,I found that when debug goes to "ble_stack_init();",It will be block and I can't do anything,like the images:

1.before  debug "ble_stack_init();"

2.after  debug "ble_stack_init();"

it shows"restricted memory" in Watch,and The window "output" shows"stopped by vector catch",If I start"built and run" directly,It can succeed,but I think it doesn;t make anythings,Finally,I see maybe I can use app_error_handler_bare(), unfortunately I don't know how to use it.could you please give me some help? thanks!

best regards,

zhong

Parents
  • Hi zhong.

    For the issue with Restricted Memory Range, please read this.

    For adjustment of RAM, please read this tutorial and look at chapter 8 or 9.

    Best regards,

    Andreas

  • Hi AndreasF,

    I try the chapter 8 or 9 in this tutorial,but there a problem occurs,

    1.In chapter 8

    First,I set the RAM like this in configuration debug,like this image.(sdk15.3.0,softdevice6.1.1)

    and then I change the define in sdk_config.h which are shown in chapter 8.after I cancel all the breakpoint and click "go" in option "debug",but it's nothing in debug terminal,like the image.

    Finally I click "go" once more,it shows"stopped by vector catch"

    2.in chapter 9

    In this way ,I set a breakpoint in line" ret_code_t ret_code = sd_ble_enable(p_app_ram_start);" shown in chapter 9, and then I click "go" in option"debug" once time ,the result like this image:

    and then I click"go" once more,The debug never jump into the breakpoint which I set and it was blocked wtih"stopped by vector catch",like the image:

    So what should I do?and if there are some tutorial which can tell me how to allocate RAM when I want to add a new service in a example(add dfu_buttonless service is better),Look forward to your help,thanks!

    best regards,

    zhong

  • Hi,

    There is no RTT output here, just printouts from JLinkExe. You also need to connect to JLinkExe via telnet, as described in the end in the post I linked to.

  • Hi,

    It's the log file:

    <debug> nrf_sdh: State request: 0x00000000

    <debug> nrf_sdh: State change: 0x00000000

    <debug> nrf_sdh: State change: 0x00000001

    <debug> nrf_sdh_ble: RAM starts at 0x20002AA8

    <info> app: Debug logging for UART over RTT started.

    <debug> nrf_sdh_ble: BLE event: 0x10.

    <debug> nrf_ble_gatt: Requesting to update ATT MTU to 247 bytes on connection 0x0.

    <debug> nrf_ble_gatt: Updating data length to 251 on connection 0x0.

    <info> app: Connected

    <debug> nrf_sdh_ble: BLE event: 0x3A.

    0xF7

    x0.

    <debug> nrf_sdh: State request: 0x00000000

    <debug> nrf_sdh: State change: 0x00000000

    <debug> nrf_sdh: State change: 0x00000001

    <debug> nrf_sdh_ble: RAM starts at 0x20002AA8

    <info> app: Debug logging for UART over RTT started.

    <debug> nrf_sdh_ble: BLE event: 0x10.

    <debug> nrf_ble_gatt: Requesting to update ATT MTU to 247 bytes on connection 0x0.

    <debug> nrf_ble_gatt: Updating data length to 251 on connection 0x0.

    <info> app: Connected

    <debug> nrf_sdh_ble: BLE event: 0x3A.

    <debug> nrf_ble_gatt: ATT MTU updated to 185 bytes on connection 0x0 (response).

    <info> app: Data len is set to 0xB6(182)

    <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7

    <debug> nrf_sdh_ble: BLE event: 0x24.

    <debug> nrf_ble_gatt: Data length updated to 251 on connection 0x0.

    <debug> nrf_ble_gatt: max_rx_octets: 251

    <debug> nrf_ble_gatt: max_tx_octets: 251

    <debug> nrf_ble_gatt: max_rx_time: 2120

    <debug> nrf_ble_gatt: max_tx_time: 2120

    <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7

    <debug> nrf_sdh_ble: BLE event: 0x23.

    <debug> nrf_ble_gatt: Peer on connection 0x0 requested a data length of 251 bytes.

    <debug> nrf_ble_gatt: Updating data length to 251 on connection 0x0.

    <debug> nrf_sdh_ble: BLE event: 0x24.

    <debug> nrf_ble_gatt: Data length updated to 251 on connection 0x0.

    <debug> nrf_ble_gatt: max_rx_octets: 251

    <debug> nrf_ble_gatt: max_tx_octets: 251

    <debug> nrf_ble_gatt: max_rx_time: 2120

    <debug> nrf_ble_gatt: max_tx_time: 2120

    <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7

    <debug> nrf_sdh_ble: BLE event: 0x50.

    <debug> nrf_sdh_ble: BLE event: 0x52.

    <debug> nrf_sdh_ble: BLE event: 0x50.

    <info> app: Received indication state 1

    <debug> nrf_sdh_ble: BLE event: 0x51.

    <debug> nrf_sdh_ble: BLE event: 0x53.

    <info> app: Device is preparing to enter bootloader mode.

    <debug> app: Disconnected connection handle 0

    <info> app: Disconnected 1 links.

    <debug> app: In ble_dfu_buttonless_bootloader_start_finalize

    <info> app: Device will enter bootloader mode.

    <info> app: Power management wants to reset to DFU mode.

    <info> app: Power management allowed to reset to DFU mode.

    and I can finish dfu when I open the RTT mode,but If I don't use RTT to test.It won't finish the dfu Just like before(always in 100%),Is it normal?(app“nrf connect”in iphone).

    best regards,

    zhong

  • Hi,

    This RTT log only covers the application. That is an unfortunate consequence of the RTT viewer only searching for the RTT buffer once, as described here and here. Can you try to disconnect the RTT viewer and connect again after entering DFU mode? That way you should get the bootloader RTT output. (alternatively, you could make sure that the RTT buffer of the application and bootloader is in the same memory address).

  • Hi,

    I try to disconnect the RTT viewer and connect again after entering DFU mode.but nothing I can find,

    and then I try the dfu in another phone(android),unfortunately,even if I open the RTT ,The dfu fail too.

    It's the information in RTT viewer and in the phone:

    1.RTT viewer

    Process: JLinkExe

    <debug> nrf_sdh: State request: 0x00000000

    <debug> nrf_sdh: State change: 0x00000000

    <debug> nrf_sdh: State change: 0x00000001

    <debug> nrf_sdh_ble: RAM starts at 0x20002AA8

    <info> app: Debug logging for UART over RTT started.

    <debug> nrf_sdh_ble: BLE event: 0x10.

    <debug> nrf_ble_gatt: Requesting to update ATT MTU to 247 bytes on connection 0x0.

    <debug> nrf_ble_gatt: Updating data length to 251 on connection 0x0.

    <info> app: Connected

    <debug> nrf_sdh_ble: BLE event: 0x3A.

    <debug> nrf_ble_gatt: ATT MTU updated to 247 bytes on connection 0x0 (response).

    <info> app: Data len is set to 0xF4(244)

    <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7

    <debug> nrf_sdh_ble: BLE event: 0x24.

    <debug> nrf_ble_gatt: Data length updated to 27 on connection 0x0.

    <debug> nrf_ble_gatt: max_rx_octets: 27

    <debug> nrf_ble_gatt: max_tx_octets: 27

    <debug> nrf_ble_gatt: max_rx_time: 328

    <debug> nrf_ble_gatt: max_tx_time: 328

    <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7

    <debug> nrf_sdh_ble: BLE event: 0x12.

    2.in the phone

    what' the matter?

    best regards,

    zhong

  • Hi,

    1. This seems to be RTT log from the application. Is the bootloader running? Another way of making sure that the RTT log of the debug bootloader is printed is to disable RTT logging in the application. This way you know there is no "residue" RTT buffer from the application in RAM. Also remember that it only the debug bootloader that has RTT logging.

    2. The phone shows that there are no DFU characteristics. This indicates that neither the bootloader nor an application with the buttonless DFU service is running. Can you double check?

Reply
  • Hi,

    1. This seems to be RTT log from the application. Is the bootloader running? Another way of making sure that the RTT log of the debug bootloader is printed is to disable RTT logging in the application. This way you know there is no "residue" RTT buffer from the application in RAM. Also remember that it only the debug bootloader that has RTT logging.

    2. The phone shows that there are no DFU characteristics. This indicates that neither the bootloader nor an application with the buttonless DFU service is running. Can you double check?

Children
  • Hi,

    Thank you very much,I don't know what happened,but sometimes I can accomplish the dfu service directly, and now I want to know what code I must add in the main.c,Is this the following?

    1.Implement the DFU event handler
    static void ble_dfu_buttonless_evt_handler(ble_dfu_buttonless_evt_type_t event)
    {
    switch (event)
    {
    case BLE_DFU_EVT_BOOTLOADER_ENTER_PREPARE:
    NRF_LOG_INFO("Device is preparing to enter bootloader mode\r\n");
    break;
    case BLE_DFU_EVT_BOOTLOADER_ENTER:
    NRF_LOG_INFO("Device will enter bootloader mode\r\n");
    break;
    case BLE_DFU_EVT_BOOTLOADER_ENTER_FAILED:
    NRF_LOG_ERROR("Device will enter bootloader mode\r\n");
    break;
    default:
    NRF_LOG_INFO("Unknown event from ble_dfu.\r\n");
    break;
    }
    }
    
    2.Enabling power management auto shutdown retry
    #ifndef NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY
    #define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 1
    #endif
    
    3. Implement the power management
    static bool app_shutdown_handler(nrf_pwr_mgmt_evt_t event)
    {
    switch (event)
    {
    case NRF_PWR_MGMT_EVT_PREPARE_DFU:
    NRF_LOG_INFO("Power management wants to reset to DFU mode\r\n"); 
    // Change this code to tailor to your reset strategy.
    // Returning false here means that the device is not ready to jump to DFU mode yet.
    // 
    // Here is an example using a variable to delay resetting the device:
    if (!m_ready_for_reset)
    {
    return false;
    }
    break;
    default:
    // Implement any of the other events available from the power management module:
    // -NRF_PWR_MGMT_EVT_PREPARE_SYSOFF
    // -NRF_PWR_MGMT_EVT_PREPARE_WAKEUP
    // -NRF_PWR_MGMT_EVT_PREPARE_RESET
    return true;
    }
    NRF_LOG_INFO("Power management allowed to reset to DFU mode\r\n");
    return true;
    }
    
    
    4. Initializing the Buttonless Secure DFU Service
    static void services_init(void)
    {
    ...
    ble_dfu_buttonless_init_t dfus_init =
    {
    .evt_handler = ble_dfu_buttonless_evt_handler
    };
    err_code = ble_dfu_buttonless_init(&dfus_init);
    APP_ERROR_CHECK(err_code);
    ...
    }
    

    Because I'm not sure whether I can use it in other application simply,or I need change a lot of things if I want to add dfu in another application.Looking forward to your reply.

    best regards

    zhong,

  • Hi,

    It looks like you have everything covered there. You can refer to Adding Buttonless Secure DFU Service to a BLE application for more information.

Related