nRF5340 BLE DFU from NET core

Hello! 
Introduction. Responsibilities of the cores in my device:
1. app core. 
1.1. data processing from a stereo microphone
1.2. data sending to net core.
2. net core. 
2.1. ble communication, services supporting. 
2.2. data receiving from app core.

Everything works fine :)
But now I want to add BLE DFU )

As I understood from examples, I should use app core for smp server, so I should use ble communication support on app core, which changes my whole architecture.

Could please anyone help me with that situation? :)

  • valeriy_simakov said:
    Could you please explane how to add FOTA handler to the network core or where I can find the example?

    Well we dont have any example as such. For the application core we use the mcumgr library for this, but this will just write to flash directly. For Alt1, you would want to transfer the DFU image received to the application core. I think this can be done in one of three ways:

    A: Trick/patch the mcumgr library to make it send data to the application core instead of writing to flash.

    B: Write a BLE service that uses the SMP Protocol to receive the DFU and send it to the application core.

    C: Write a custom BLE service that receives a custom binary with your DFU files and send it to the application core

  •  
    * Thanks, I will investigate all three ways. 

    * Net core flash usage is so big. I reduced it by logging disabling. Could you please tell me how to reduce it more efficiently? I attached the file from 'rom_report'. The section 'no paths' takes 50% :(
    net_core_flash_usage.txt

    * To be honest, I had doubts about my architecture. The app core continuously accumulates data from the microphone for a certain time and transmits it in chunks to the network core, which then sends the data via BLE. I did this to unload the app core so that it would not send data over BLE. Maybe I use the wrong way and there would be no problems with continuously receiving and sending data. I need your opinion.

  • static struct bt_gatt_attr smp_bt_attrs[] = {
        /* SMP Primary Service Declaration */
        BT_GATT_PRIMARY_SERVICE(&smp_bt_svc_uuid),

        BT_GATT_CHARACTERISTIC(&smp_bt_chr_uuid.uuid,
                       BT_GATT_CHRC_WRITE_WITHOUT_RESP |
                       BT_GATT_CHRC_NOTIFY,
    #ifdef CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN
                       BT_GATT_PERM_WRITE_AUTHEN,
    #else
                       BT_GATT_PERM_WRITE,
    #endif
                       NULL, smp_bt_chr_write, NULL),
        BT_GATT_CCC(smp_bt_ccc_changed,
    #ifdef CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN
                       BT_GATT_PERM_READ_AUTHEN |
                       BT_GATT_PERM_WRITE_AUTHEN),
    #else
                       BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
    #endif
    };

    With corresponding CONFIG_x values in 'peripheral_lbs' example we have attributes without response where mcumgr writes the data. 
    I think I can write BLE service wrapper of smp service to get data and send it to app core (data, len). On app core I can write smp_uart wrapper to receive data. What do you think about it?
  • valeriy_simakov said:
    static struct bt_gatt_attr smp_bt_attrs[] = {
        /* SMP Primary Service Declaration */
        BT_GATT_PRIMARY_SERVICE(&smp_bt_svc_uuid),

        BT_GATT_CHARACTERISTIC(&smp_bt_chr_uuid.uuid,
                       BT_GATT_CHRC_WRITE_WITHOUT_RESP |
                       BT_GATT_CHRC_NOTIFY,
    #ifdef CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN
                       BT_GATT_PERM_WRITE_AUTHEN,
    #else
                       BT_GATT_PERM_WRITE,
    #endif
                       NULL, smp_bt_chr_write, NULL),
        BT_GATT_CCC(smp_bt_ccc_changed,
    #ifdef CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN
                       BT_GATT_PERM_READ_AUTHEN |
                       BT_GATT_PERM_WRITE_AUTHEN),
    #else
                       BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
    #endif
    };

    Im not a BLE expert, but I can suggest that if you want to verify this, check our DFU SMP service ( and .c file), as this is the closest we got to that.

    But yes, this implementing of your own service for SMP.

    valeriy_simakov said:
    I think I can write BLE service wrapper of smp service to get data and send it to app core (data, len).

    Nice!

    valeriy_simakov said:
    On app core I can write smp_uart wrapper to receive data. What do you think about it?

    I would suggest that you use DFU Target on the application core to receive the data. This is the library we have for custom handling of received DFU binaries.

Related