Zephyr SMP Server sample does not work on nRF52840 DK

Hello,

I am using the Zephyr SMP Server sample to update the firmware over BLE on a custom board with the nRF52840 and a nRF52840 DK. I followed the instructions in the documentation to configure and build the sample, and I used the nRF Connect app on my smartphone to connect to the device and upload the firmware image.

The problem is that the SMP Server sample works fine on my custom board, but not on the nRF52840 DK. When I try to update the firmware on the DK, I get a [McuMgr] Error (0x1): GATT INVALID HANDLE message in the app.

Can anyone please help me figure out what is causing this issue and how to fix it? Is there something different between the custom board and the DK that I need to consider? Is there a bug in the Zephyr SMP Server sample or in the nRF Connect app?

Thank you in advance for your assistance.

Parents
  • Hi,

    I need you to answer some questions before we can pinpoint the issue

    1. Which SDK version are you using?
    2. Which smartphone and smartphone OS are you running the nRF Connect App on?
    The problem is that the SMP Server sample works fine on my custom board, but not on the nRF52840 DK.

    This is typically the other way around, i.e that it works on a DK out of the box and not the custom board. 

    1. Have you made any modifications to the board files in the SDK making your custom board act as the default 52840 board?
    2. Have you modified the zephyr smp sample at any point? Do you see the same thing when you build with an unmodified sample?

    It would also be helpful if you could provide me with the full device log up until the error occurs

    Kind regards;
    Andreas

    1. I'm using nRF Connect SDK v2.4.0
    2. Realme GT 5G (Android)
    3. I have used the default nrf52840dk_nrf52840 board
    4. I have tired with unmodified and modified sample code and I had the same issue in both cases

    I appended the log file to this message. I connected to the device and triggered dfu.

    nRF Connect, 2023-09-25
    Avirings_v1 (FB:4A:B6:C5:58:10)
    D	14:01:46.561	gatt.close()
    D	14:01:46.567	wait(200)
    V	14:01:46.769	Connecting to FB:4A:B6:C5:58:10...
    D	14:01:46.770	gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
    D	14:01:47.137	[Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    D	14:01:47.151	[Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I	14:01:47.151	Connected to FB:4A:B6:C5:58:10
    V	14:01:47.153	Discovering services...
    D	14:01:47.153	gatt.discoverServices()
    D	14:01:47.158	[Callback] Services discovered with status: 0
    I	14:01:47.196	Services discovered
    V	14:01:47.202	Generic Attribute (0x1801)
    - Service Changed [I] (0x2A05)
       Client Characteristic Configuration (0x2902)
    - Client Supported Features [R W] (0x2B29)
    - Database Hash [R] (0x2B2A)
    Generic Access (0x1800)
    - Device Name [R] (0x2A00)
    - Appearance [R] (0x2A01)
    - Peripheral Preferred Connection Parameters [R] (0x2A04)
    Device Information (0x180A)
    - Model Number String [R] (0x2A24)
    - Manufacturer Name String [R] (0x2A29)
    Nordic UART Service (6e400001-b5a3-f393-e0a9-e50e24dcca9e)
    - TX Characteristic [N] (6e400003-b5a3-f393-e0a9-e50e24dcca9e)
       Client Characteristic Configuration (0x2902)
    - RX Characteristic [W WNR] (6e400002-b5a3-f393-e0a9-e50e24dcca9e)
    SMP Service (8d53dc1d-1db7-4cd3-868b-8a527460aa84)
    - SMP Characteristic [N WNR] (da2e7828-fbce-4e01-ae9e-261174997c48)
       Client Characteristic Configuration (0x2902)
    D	14:01:47.202	gatt.setCharacteristicNotification(00002a05-0000-1000-8000-00805f9b34fb, true)
    D	14:01:47.205	gatt.setCharacteristicNotification(6e400003-b5a3-f393-e0a9-e50e24dcca9e, true)
    I	14:01:47.781	PHY updated (TX: LE 2M, RX: LE 2M)
    I	14:01:52.328	Connection parameters updated (interval: 45.0ms, latency: 0, timeout: 420ms)
    V	14:01:59.004	[McuMgr] Connecting...
    D	14:01:59.011	[McuMgr] gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, LE 1M)
    D	14:01:59.070	[McuMgr] [Callback] Connection state changed with status: 0 and new state: 2 (CONNECTED)
    I	14:01:59.074	[McuMgr] Connected to FB:4A:B6:C5:58:10
    D	14:01:59.075	[McuMgr] wait(300)
    V	14:01:59.378	[McuMgr] Discovering services...
    D	14:01:59.383	[McuMgr] gatt.discoverServices()
    I	14:01:59.389	[McuMgr] Services discovered
    V	14:01:59.390	[McuMgr] Primary service found
    V	14:01:59.409	[McuMgr] Requesting new MTU...
    D	14:01:59.415	[McuMgr] gatt.requestMtu(498)
    I	14:01:59.484	[McuMgr] MTU changed to: 498
    D	14:01:59.491	[McuMgr] gatt.setCharacteristicNotification(da2e7828-fbce-4e01-ae9e-261174997c48, true)
    V	14:01:59.495	[McuMgr] Enabling notifications for da2e7828-fbce-4e01-ae9e-261174997c48
    D	14:01:59.498	[McuMgr] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x01-00)
    E	14:01:59.665	[McuMgr] Error (0x1): GATT INVALID HANDLE
    V	14:01:59.674	[McuMgr] Waiting for value change...
    V	14:01:59.678	[McuMgr] Writing characteristic da2e7828-fbce-4e01-ae9e-261174997c48 (WRITE COMMAND)
    D	14:01:59.684	[McuMgr] gatt.writeCharacteristic(da2e7828-fbce-4e01-ae9e-261174997c48, value=0x000000010000FF06A0, WRITE COMMAND)
    I	14:01:59.692	[McuMgr] Data written to da2e7828-fbce-4e01-ae9e-261174997c48
    W	14:02:00.678	[McuMgr] Request timed out
    A	14:02:00.687	[McuMgr] Sending (10 bytes) Header (Op: 0, Flags: 0, Len: 2, Group: 1, Seq: 0, Command: 0) CBOR {}
    V	14:02:00.709	[McuMgr] Writing characteristic da2e7828-fbce-4e01-ae9e-261174997c48 (WRITE COMMAND)
    D	14:02:00.714	[McuMgr] gatt.writeCharacteristic(da2e7828-fbce-4e01-ae9e-261174997c48, value=0x0000000200010000BFFF, WRITE COMMAND)
    I	14:02:00.719	[McuMgr] Data written to da2e7828-fbce-4e01-ae9e-261174997c48
    V	14:02:05.690	[McuMgr] Disconnecting...
    D	14:02:05.695	[McuMgr] gatt.disconnect()
    D	14:02:05.720	[McuMgr] [Callback] Connection state changed with status: 0 and new state: 0 (DISCONNECTED)
    I	14:02:05.724	[McuMgr] Disconnected
    D	14:02:05.726	[McuMgr] gatt.close()
    

  • Thank you for supplying this. I will have a look at the log and try to recreate what you observe.

    Could you state which revision your nRF52840DK is? It should be visible on the sticker attached on the board 

    Kind regards,
    Andreas

  • Hi,

    Unfortunately I've not been able to reproduce the issue you see by following the sample documentation. From the image below you can see that DFU with BLE using nRF Connect App

    Setup: 

    nRF52840DK, NCS v2.4.0, Samsung Galaxy Android phone

    1. Build with Bluetooth overlay using west build -b nrf52840dk_nrf52840 -- - DEXTRA_CONF_FILE=overlay.bt.conf or by adding the extra configuration file in the VS Code extension when choosing build configuration
    2. Flash the firmware to a 52840DK
    3. Check that it's running using for instance J-Link RTT Viewer or the built in RTT Viewer in VS Code extension
    4. Build once more in a new directory to make sure that it's a new project using west build -b nrf52840dk_nrf52840 -d build_1 -- - DEXTRA_CONF_FILE=overlay.bt.conf or by adding the extra configuration file in the VS Code extension when choosing build configuration
    5. Upload the bin app_uppdate.bin located in build/zephyr to somewhere your phone can access
    6. Open nRF Connect and find the device. Connect to it
    7. Press the DFU button (top right) and upload the bin. Choose test and confirm
    8. Observe that the process goes through and the new firmware is now running on the board

    Does your steps differ from these steps?

    Kind regards,
    Andreas

  • Hi Andreas,

    Thank you for your detailed response. I followed the steps you provided and managed to perform a firmware update successfully when I switched to a different phone (Pocophone F1).

    However, I encountered an error in the RTT log related to LittleFS. Here’s the log for your reference:

    The error message “Corrupted dir pair at {0x0, 0x1}” appeared and it seems that LittleFS couldn’t mount and had to format. I’m wondering if this is something I should be concerned about

    Kind regards,
    Vincent

Reply
  • Hi Andreas,

    Thank you for your detailed response. I followed the steps you provided and managed to perform a firmware update successfully when I switched to a different phone (Pocophone F1).

    However, I encountered an error in the RTT log related to LittleFS. Here’s the log for your reference:

    The error message “Corrupted dir pair at {0x0, 0x1}” appeared and it seems that LittleFS couldn’t mount and had to format. I’m wondering if this is something I should be concerned about

    Kind regards,
    Vincent

Children
Related