This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP-EXP432E401Y: MQTT ssl connection problem

Part Number: MSP-EXP432E401Y

Hi,

I am using MEP-EXP432E401Y. I am trying to connect secure mqtt with "test.mosquitto.org". I am using mqtt client freertos code form SDK. I follow the instruction from readme for adding secure file. I add that file data in certificate.h file. But my code is stuck in vPortFree when MQTTclient_connection  call. 

 certificate.h

  • Hello Dinkar,

    Can you let us know which version of the SDK you are using? We had found a bug in an earlier version of SDK which resulted in the Secure MQTT not working.

    I will check if this bug was fixed.

    Thanks,
    Sai
  • Hi,

    I am using SDK version 2.30.00.14.

    Thanks,
    Dinkar
  • Hi Dinkar,

    Have you made any modifications to the example beyond uncommenting SECURE_CLIENT and adding in the certificate? I downloaded a fresh version of the SDK and haven't been able to reproduce the issue.

    Best,

    Brandon

  • Hi,

    No, I am only modify SECURE_CLIENT and add that server certificate.

    Dinkar

  • Hi,

    can you tell me that what is the problem in previous version of SDK that device stuck at  vPortFree when try to connect secure MQTT? is there a problem regarding secure file?

    DInkar

  • Hi Dinkar,

    I was finally able to reproduce the issue. I've filed a bug (NDK-319) and this will be fixed in a future release.

    You can fix this in your personal SDK by doing the following (replace SDK below with your install location):

    1. Open the file (SDK)/source/ti/ndk/slnetif/slnetifndk.c
    2. Around line 2183 make the following change
      error:
          if (retVal != SLNETERR_RET_CODE_OK) {
              sCtxPtr->isSecure = false;
              if (initSsl) {
                  mbedtls_ssl_free(sCtxPtr->ssl);
              }
              if (sCtxPtr->ssl) {
                  free(sCtxPtr->ssl);
              }
              if (sCtxPtr->initCookie) {
                  mbedtls_ssl_cookie_free(&sCtxPtr->cookieCtx);
              }
              if (sCtxPtr->initLocalCert) {
                  mbedtls_x509_crt_free(&sCtxPtr->localCert);
              }
              if (sCtxPtr->initCaCert) {
                  mbedtls_x509_crt_free(&sCtxPtr->caCert);
              }
              if (sCtxPtr->initKey) {
                  mbedtls_pk_free(&sCtxPtr->key);
              }
              if (sCtxPtr->initConf) {
                  mbedtls_ssl_config_free(&sCtxPtr->conf);
              }
              if (sCtxPtr->domainName) {
                  free(sCtxPtr->domainName);
              }
          }
          return (retVal);
      }
      #endif /* SLNETIFNDK_ENABLEMBEDTLS */
    3. From here you will need to rebuild the NDK library - if you are unsure how to do this, please tell me what operating system you're using, so I can help.
    4. Now attempt rebuilding and running the mqttclient example in CCS

    Best,

    Brandon

  • Hi,

    I am using windows 10 ,64- bit operating system and i don't no how to rebuild NDK? help me to rebuild NDK library.

    Dinkar

  • Hi,

    Here is a write-up (an old one) on rebuilding the NDK: processors.wiki.ti.com/.../Rebuilding_The_NDK_Core_Using_Gmake

    A few things to note:
    In the section titled "Rebuilding The NDK Core Using The ndk.mak Makefile" replace 'ndk.mak' with 'imports.mak'.
    XDCtools should have been installed when you installed CCS, so you shouldn't need to reinstall it.
    The page will instruct you to make a new copy of your ndk folder, so that you have a backup. When you create the new copy, you can
    follow my instructions above regarding editing the slnetifndk.c file.

    Best,
    Brandon
  • Hi, 

    Thank you for quick reply.

    I see step for NDK rebuilding in document. 

    I have some question.

    1. From where i can find imports.mak? 

    2. Which ndk path i have to use from msp432 library(C:\ti\simplelink_msp432e4_sdk_2_30_00_14\source\ti\ndk) or  extra ndk version 2.25.01.11 (which i install on my machine)?

    3. If  i use imports.mak then i have to edit this file as document step(rebuilding the ndk core using then ndk.mak makefile)?

    Thanks.

  • Hi,

    1. From where i can find imports.mak?

    imports.mak can be found under C:\ti\simplelink_msp432e4_sdk_2_30_00_14

    2. Which ndk path i have to use from msp432 library(C:\ti\simplelink_msp432e4_sdk_2_30_00_14\source\ti\ndk) or extra ndk version 2.25.01.11 (which i install on my machine)?

    It is more straightforward to use the ndk path inside your msp432 library. If you look at C:\ti\simplelink_msp432e4_sdk_2_30_00_14/examples/rtos/MSP_EXP432E401Y/ns/mqttclient/freertos/ccs/makefile you'd see that it sets a path to different ndk libraries based off of your simplelink installation directory. The mqttclient project settings does something similar in its properties under CCS Build -> GNU Linker -> Libraries.

    3. If i use imports.mak then i have to edit this file as document step(rebuilding the ndk core using then ndk.mak makefile)?

    Correct. You shouldn't need to edit it as drastically as the document describes, however.
    As a first step, after making the changes to slnetifndk.c, I would enter the C:\ti\simplelink_msp432e4_sdk_2_30_00_14\source\ti\ndk directory and execute C:\ti\xdctools_(whiever version is installed)\gmake.exe and proceed from there - that may be all you need to do.

    Regards,
    Brandon

  • Hi,

    I am trying to rebuild NDK but i get syntax error. I shared my error screenshot here.

    Dinkar


  • Greetings!

    Is this the first time you've run this command? Were there different errors in a previous execution?

    This is likely a result of an incorrect path in imports.mak.

    Are you planning to use the IAR version of the library? If not, inside imports.mak, comment out the line

    #IAR_ARMCOMPILER        ?= c:/Program Files (x86)/IAR Systems/Embedded Workbench 8.0/arm

    by appending a '#' to the front, like above.

    If you were intending to use the IAR compiler (assuming you already have it installed) double-check that the path listed is correct. If it is, you may try removing any spaces in the path listed in imports.mak as well as moving your IAR installation to a location with no spaces in the path. This has been known to cause issues.

    Best,

    Brandon

  • Hi,

    Thank for reply.

    I rebuild NDK successfully. Now I am able create MQTT connection with "test.mosquitto.org" successfully.
    I am not able to connect with my MQTT server. I change server ip and certificate for my MQTT server. But I am getting error -2021(SLNETERR_RET_CODE_FUNCTION_FAILED (Function couldn't execute correctly)) . Can You tell me that what is problem ?

    Dinkar
  • Hello Dinkar,

    I believe the original question on this thread has been answered by Brandon. So we should close this thread.

    Please start a separate thread if you have a different question, like the one you have just posted.

    Thanks,
    Sai

**Attention** This is a public forum