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

Thread SDK / OTA bug

I merged in some of my code to the examples/thread/dfu/client in the v4.1.0 SDK for Thread and Zigbee. After getting OTA DFU working, I moved onto some commissioning related stuff. I spent several days trying to figure out why I could not join my 52840DK to the Border Router. No matter what I did, I would get 'Join failed [Security]'. Wireshark shows failure in the DTLS handshake. I thought I had done something wrong, but turns out something in Nordic code has broken openthread.

For me this was very easy to reproduce. Simply take the examples/thread/dfu/client, and modify main.c to change ' .autocommissioning = true,' to ' .autocommissioning = false, .autostart_disable = true' so you can join a thread network rather than using built in hardcoded credentials.

Program the device (being sure to follow nordic instructions for mbr, bootloader, and this app), connect using the UART, and try to join a border router that is ready to accept the device.

> ifconfig up
Done
> joiner start TEST1234
Done
> Join failed [Security]

On a packet sniffer note that DTLS handshake fails.

I saw some other UNANSWERED devzone messages with a theme of nrf crypto breaking openthread DTLS. Not sure if that related, but one big difference between the thread/dfu/client and thread/cli example is the inclusion of nrf crypto related libraries. Also the thread/dfu/bootloader is part of the picture.

I am completely stuck at this point.

Parents
  • Hi ,

    Thanks for your patience.

    The issue is related to the heap memory. Both DFU and Thread Commissioning use the mem manager to allocate the memory.

    The following changes in the sdk_config.h solve the problem with the Thread DFU Client Commissioning.

    #define MEMORY_MANAGER_XSMALL_BLOCK_COUNT 4 (line 1982).

    #define MEMORY_MANAGER_XXSMALL_BLOCK_COUNT 28 (line 1996).

    Please note that if your application uses the memory allocated by the memory manager this values may not be sufficient.

    In that case I recommend to switch on logging (#define MEM_MANAGER_CONFIG_LOG_ENABLED 1) and possibly limit the number of log messagess with setting the default log level to error for all components (#define NRF_LOG_DEFAULT_LEVEL 1).

    Then I would modify the mem_manager.c:719 to: 

            NRF_LOG_ERROR("Memory reservation result %d, memory %p, size %d!",
                    err_code,
                    (uint32_t)(*pp_buffer),
                    (*p_size));

    Then the RTT console would nicely report what buffer allocation failed and you can increase the count of those.

    Best regards,

    Piotr Szkotak

Reply
  • Hi ,

    Thanks for your patience.

    The issue is related to the heap memory. Both DFU and Thread Commissioning use the mem manager to allocate the memory.

    The following changes in the sdk_config.h solve the problem with the Thread DFU Client Commissioning.

    #define MEMORY_MANAGER_XSMALL_BLOCK_COUNT 4 (line 1982).

    #define MEMORY_MANAGER_XXSMALL_BLOCK_COUNT 28 (line 1996).

    Please note that if your application uses the memory allocated by the memory manager this values may not be sufficient.

    In that case I recommend to switch on logging (#define MEM_MANAGER_CONFIG_LOG_ENABLED 1) and possibly limit the number of log messagess with setting the default log level to error for all components (#define NRF_LOG_DEFAULT_LEVEL 1).

    Then I would modify the mem_manager.c:719 to: 

            NRF_LOG_ERROR("Memory reservation result %d, memory %p, size %d!",
                    err_code,
                    (uint32_t)(*pp_buffer),
                    (*p_size));

    Then the RTT console would nicely report what buffer allocation failed and you can increase the count of those.

    Best regards,

    Piotr Szkotak

Children
No Data
Related