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

Working with dongle

Hi,

What changes do I need to make to the C/C++ library & ble_connectivity firmware so that the nrf52 dongle can support a BLE packet > 27 bytes?

Parents Reply
  • Hi,

    bscdb said:
    I was referring to what changes need to be made as per below response (this is from someone else's ticket)

    I see. But NRF_SDH_BLE_GAP_DATA_LENGTH is just the default data length, not the maximum.

    bscdb said:
    Also, where can I get the USB bootloader code/hex which the dongle uses? What are the steps to flash the SD+bootloader+app to the dongle?

    You can get it from the pc-ble-driver repo. If you download the latest release (currently 4.1.1), you will find all connectivity firmware variants under share\nrf-ble-driver\hex\.

Children
  • Since I will have to modify the ble_Connectivity firmware, what are the steps to combine the SD, bootloader (I'm guessing that's the open bootloader) & firmware files & then flash them to the dongle?

    I have a JLink attached to the nrf52840 dongle, how do I do a hardware flash?

    I used this batch script & I think it erased the bootloader on the dongle.

    @echo off
    
    :: # Check to make sure nrfutil and mergehex and nrfjprog are installed before moving on
    WHERE >nul 2>nul nrfutil
    IF %ERRORLEVEL% NEQ 0 (
    ECHO "nrfutil was not found in PATH, please install using pip install"
    goto :end
    )
    WHERE >nul 2>nul nrfjprog
    IF %ERRORLEVEL% NEQ 0 (
    ECHO "nrfjprog was not found in PATH, please install using windows installer from nordicsemi.com"
    goto :end
    )
    
    SET S140=".\softdevice\s140_nrf52_6.1.1_softdevice.hex"
    SET APPLICATION_HEX="..\ble_connectivity_dongle\pca10059\ser_s140_usb_hci\arm5_no_packs\_build\nrf52840_xxaa.hex"
    
    echo "## Looking to make sure %S140% exists"
    if not exist %S140% (
    echo "#### s140 hex file does not exist! Make sure the softdevice is in the same folder as this script!"
    goto :end
    )
    echo.
    
    echo "## Looking to make sure %APPLICATION_HEX% is present in folder"
    if not exist %APPLICATION_HEX% (
    echo "#### app.hex file does not exist! Please copy a application .hex file into the folder, rename it, and try again!"
    goto :end
    )
    echo.
    
    nrfjprog --family nRF52 --program %S140% --chiperase --verify
    nrfjprog --family NRF52 --program %APPLICATION_HEX% --sectorerase --verify
    nrfjprog --family NRF52 --reset
    
    :end
    pause

  • Hi,

    bscdb said:
    Since I will have to modify the ble_Connectivity firmware, what are the steps to combine the SD, bootloader (I'm guessing that's the open bootloader) & firmware files & then flash them to the dongle?

    You can program the dongle using nrfjprog as you do in your script. I suggest you just use the USB bootloader that the device was shipped with unless you have a reason to change it. The connectivity firmware is not special in any way in this regard, so you could program it like you wound any other firmware. The only thing you need to remember is that if you program via a debugger instead of DFU, then you must also generate and program a valid DFU settings page so that the bootloader sees that there is a valid application that it will start.

    bscdb said:
    I have a JLink attached to the nrf52840 dongle, how do I do a hardware flash?

    I don't understand completely since your script shows you are familiar with nrfjprog. Essentially you erase and program with nrfjprog. Use nrfjprog -h to see all details. Just remember that you should set the regulator voltage in the nRF correctly, if not it might end up in an unprogrammable state (depending on your programmer). See the last part of nRF52840 Dongle Programming Tutorial for details.

    bscdb said:
    I used this batch script & I think it erased the bootloader on the dongle.

    Yes, it did ( --chiperase). It also changed the REGOUT0 register so that the VDD voltage is 1.8 V unless the application you programmed configures it to something else. That might lead to problems, as described in the last part of the dongle programming tutorial. You can download the bootloader .hex file from the tutorial (or here).

  • Thanks for the info. I will work on this. So coming back to my original question, I modified the ble_connectivity firmware for packet size > 27

    I changed

    #define BLE_GATT_ATT_MTU_DEFAULT          32

    in ble_gatt.h

    &

    #define NRF_SDH_BLE_GAP_DATA_LENGTH 36

    in sdk_config.h

    I also modified the C/C++ library.

    I changed #define BLE_GATT_ATT_MTU_DEFAULT          32

    in ble_gatt.h

    But still I can see only 20 bytes which means it supports only 27 bytes packets.

  • Hi,

    bscdb said:
    But still I can see only 20 bytes which means it supports only 27 bytes packets.

    Can you elaborate? Where do you see this?

    Do you do a data length update procedure? Please refer to the migration document for the SoftDevic for details on this ("Data Length Update Procedure" section). This pseudo code snipped from the migration document demonstrates how to do it (the first part resided in the connectivity firmware in this case, but the latter resides on the PC side via the pc-ble-driver):

    const uint16_t client_rx_mtu = 247;
    const uint32_t long_att_conn_cfg_tag = 1;
    
    /* ATT_MTU must be configured first */
    ble_cfg_t cfg;
    memset(&cfg, 0, sizeof(ble_cfg_t));
    cfg.conn_cfg.conn_cfg_tag = long_att_conn_cfg_tag;
    cfg.conn_cfg.params.gatt_conn_cfg.att_mtu = client_rx_mtu;
    sd_ble_cfg_set(BLE_CONN_CFG_GATT, &cfg, ...);
    
    /* Enable the BLE Stack */
    sd_ble_enable(...);
    
    [...]
    
    uint16_t long_att_conn_handle;
    
    /* Establish connection */
    sd_ble_gap_adv_start(..., long_att_conn_cfg_tag);
    
    [...]
    
    /* Start Data Length Update Procedure, can be done without ATT_MTU exchange */
    ble_gap_data_length_params_t params = {
    .max_tx_octets = client_rx_mtu + 4,
    .max_rx_octets = client_rx_mtu + 4,
    .max_tx_time_us = BLE_GAP_DATA_LENGTH_AUTO,
    .max_rx_time_us = BLE_GAP_DATA_LENGTH_AUTO
    };
    sd_ble_gap_data_length_update(long_att_conn_handle, &params, NULL);
    
    [...]
    
    case BLE_GAP_EVT_DATA_LENGTH_UPDATE:
    {
        /* Data Length Update Procedure completed, see p_ble_evt->evt.gap_evt.params.data_length_update.
        effective_params for negotiated parameters. */
        break;
    }

  • Hi,

    I opened "..examples\connectivity\ble_connectivity\pca10059\ser_s140_usb_hci\ses ble_connectivity_s140_usb_hci_pca10059.emProject" with SEGGER Embedded Studio and built this project. Uploaded "..\examples\connectivity\ble_connectivity\pca10059\ser_s140_usb_hci\ses\Output\Release\Exe ble_connectivity_s140_usb_hci_pca10059.hex" and "..\components\softdevice\s140\hex s140_nrf52_6.1.1_softdevice.hex" by nRF Connect Programmer. 

    But the dongle didn't work, and nRF Connect Programmer displayed:

    My question is "How to compile and use connectivity for nRF52840 Dongle?"

    Best regards

Related