1 Reply Latest reply on Apr 22, 2019 12:19 AM by PriyaM_16

    snip.secure_mqtt example hangs (or exits with data exception)



      I have been dealing with a processor hang (or data exception issue in some instances) for a couple of days. The issue can be easily replicated using the snip.secure_mqtt example and I am hoping someone from Cypress (or the community) can provide some insight...



      - I am running the secure_mqtt snip example over ethernet. Initially, right after a board flash, the snip runs without issues.

      - After a complete board power cycle, snip starts but then the processor hangs. (Eventually watchdog steps in if wdg is enabled and the cycle repeats)

      - The issue is consistent on multiple dev boards as well as the custom application board I am working on for my client.



      - Wiced Studio on Windows 7

      - CYW943907AEVAL1F dev board

      - Trying to run snip.secure_mqtt example on this board but over the ethernet inerface (as opposed to wifi in the original example)



      - To demonstrate the problem, I modified the snip.secure_mqtt example to run over the ethernet interface. The modification is done in "secure_mqtt.c" file by replacing all instances of "WICED_STA_INTERFACE" with "WICED_ETHERNET_INTERFACE". Everything else stays the same as in the original snip example.

      - Compile and flash using this target: "snip.secure_mqtt-CYW954907AEVAL1F-debug download run"

      - With ethernet port connected to a network switch, code flashes and continues on to execute the snip example without any issues.

      - After a complete dev board power cycle (not just a reset), snip will start and run until after it completes the "test.mosquitto.org" address resolution, but then the processor hangs.



      - The processor hang occurs after the "mqtt_thread_main" attempts to process the first "MQTT_SEND_EVENT" it receives.

      - The MQTT_SEND_EVENT results in a series of calls to lower level support lib functions and eventually it fails (causes the program to hang or throws exception) at this line: - Line# 2490 in "ssl_tls.c": if( ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER || ssl->handshake->retransmit_state == MBEDTLS_SSL_RETRANS_SENDING)

      - Specifically, accessing ssl->handshake->retransmit_state seems to cause a data exception.

      - Note that I mentioned exceptions as well as mcu hangs... If you replicate the example the way I described above, the code just hangs. If in addition to the change above, we change the code to not initialize wifi at all (since it's not used), the code executes up to the same point but in this case, mcu exception is caught by the handler and appropriately shown.

      - In either case, code fails on the same line of code shown above.

      - My thought is that some part of memory within the wiced_mqtt_object_t structure is not setup correctly by the time this statement is executed, but it's quite difficult to navigate that huge structure...


      All help is very much appreciated,