Question about NCS DTM and BLE stack option.

I would like to develop DTM and normal BLE stack operation in single firmware by NCS. Basically i will check a GPIO, go DTM test mode if GPIO short to High, go normal BLE stack if GPIO short to GND.

However, it seems no way to achieve that.

If i set CONFIG_BT=y, then start DTM, it get crash or HARDWARE FAULT.

If i set CONFIG_BT=n, then ok for DTM, but no way to initialixe the BLE Stack manually in code.

Am i correct?

So is it possible to enable CONFIG_BT=y manually in codes? Or disable BLE Stack completely so that i can switch to DTM mode properly?

Already search but still seems no feasible solution.

Thanks.

Parents
  • Hello,

    I guess there are different ways of doing this, and simplest should be as you suggest, is to select whether to run DTM or BLE after a reset. For instance you can have test pin on the board, e.g. with pull-up, such that when it's low on reset the application run DTM, else it will run BLE.

    So in start of main() you would simply do something like (example is outdated, check direct_test_mode.zip file instead):

    // Edit: Updated code.
    // in prj.conf
    // DYNAMIC_DIRECT_INTERRUPTS=y
    // MPSL_DYNAMIC_INTERRUPTS=y
    
       void main(void) {
           // read pin to find if application should run DTM or BLE
    
           if (dtm_mode) {
               printk("Booting into DTM mode\n");
               err = mpsl_lib_uninit();
               dtm_init();
               // Enter DTM mode loop
               while (1) {
                   dtm_cmd_process();
               }
           } else {
               printk("Booting into BLE mode\n");
               int err = bt_enable(NULL);
               // Normal BLE application logic here
           }
       }

    Or are you saying you have tried this but it doesn't work?

    Kenneth

  • Hi Kenneth,

    We have tried and done something like what you suggested but it doesn't work.

    But the problem is how should we set CONFIG_BT in proj.conf?

    If we set CONFIG_BT=y, and the firmware boots int DTM mode. It doesn't work to get "HARD FAULT" error.

    If we set CONFIG_BT=n (or no CONFIG_BT), and the firmware boots int BLE mode. It doesn't work as the BLE stack is not loaded in the firmware after build.

    What i am struggling now is how should we set to the proj.conf for CONFIG_BT.
    So we can really make the DTM and BLE mode combined in one firmware.

    Any further idea for that?

    Thank  you very much.

  • Hi Kenneth,

    Yes I did see the reply and had a try already.

    I have tried to add the config but still doesn't work for the DTM mode.

    DYNAMIC_DIRECT_INTERRUPTS=y
    MPSL_DYNAMIC_INTERRUPTS=y

    However that is a radio test example, not a DTM example.

    Or do i need to add more config or other settings for DTM?

  • Can you try the attachment? At least this seems to work with ncs v2.6.1 and CONFIG_BT=y.

    Kenneth

    0677.direct_test_mode.zip

  • Hi Kenneth,

    Thanks for your attachment and highly appreciated.
    I have run the codes and it really works for DTM.

    One follow up example, how about if i start the normal BLE stack first, this will run the bt_enable().

    If i would like to switch to DTM test from normal BLE without power reset, i tried to call bt_disable() before i start the DTM part of code. However it doesn't work. My nrf52832 DK cannot receive UART command and the nrf Connect at the PC side fail to start the DTM operation.

    So am i do something wrong? Or what should i do if i would switch the DTM from BLE without power reset? 

    Thank you very much.

  • By the way, I have seen another post (2 years ago).
    https://devzone.nordicsemi.com/f/nordic-q-a/93656/shutting-down-ble-host-stack-using-bt_disable
    You have replied that  "it's not possible to disable the bt stack. So you would need to execute a soft reset to enter DTM mode."

    So, how about now for the latest NCS?
    Is it possible to disable the BT stack to start the DTM without power reset?
    Or if not, as you mentioned, which kind of soft reset is feasible to achieve that?
    As i know, take BT stack->DFU as example, there is internal flag to indicate to enter DFU after soft reset.
    So is there any flag I can use for indication/checking right now for "BT stack -> soft reset -> DFU"?

    Thanks a lot.

  • Hi,

    Yes, it should be possible to disable the bt_stack() with bt_disable() if you are on SDK v2.6. 

Reply Children
No Data
Related