This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to change the NRF9160 Simple MQTT to send UART - the old example by Simon mqtt_w_uart does not compile

Hi there

We are trying to modify the MQTT_Simple example to be able to send more info than the status of pressing a button and having a button pressed notification go back up to the cloud.  There was an attempt by Simon from 2 years ago to help someone and called mqtt_w_uart, however there are a number of odd things about the code (zephyr deprecated type u8_t which I changed to uint8_t for example - but there were more serious problems like trying to compile and having problems with other dependencies.  Now using the 1.7.0 environment.)  Trying to pull the special additional mqtt_w_uart code into the current version of MQTT_simple (which uses LOG_INF and LOG_ERR instead of printf or whatever, and also you need to #import <drivers/uart.h> instead of just <uart.h> and a few other fun changes that arent obvious) is fine until the main function in main.c has the line  uart_irq_callback_set(uart_gb, uart_cb)  or the line  uart_irq_rx_enable(uart_gb)  plunked into it.  Once this is tried, it DOES compile, however the program keeps resetting and this is what the log shows over and over:

[0m<inf> mqtt_simple: The MQTT simple sample started

[1;31m<err> os: Exception occurred in Secure State

[1;31m<err> os: ***** HARD FAULT *****

[1;31m<err> os:   Fault escalation (see below)

[1;31m<err> os: ***** BUS FAULT *****

[1;31m<err> os:   Precise data bus error

[1;31m<err> os:   BFAR Address: 0x50008158

[1;31m<err> os: r0/a1:  0x00000000  r1/a2:  0x000249a4  r2/a3:  0x00000055

[1;31m<err> os: r3/a4:  0x00000047 r12/ip:  0x2001455c r14/lr:  0x0001c9f5

[1;31m<err> os:  xpsr:  0x61000000

[1;31m<err> os: Faulting instruction address (r15/pc): 0x0001179c

[1;31m<err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0

[1;31m<err> os: Current thread: 0x20014e30 (unknown)

[1;31m<err> fatal_error: Resetting system
  • Hi Gerry,

    There is a big difference introduced between NCS 1.1.0 and NCS 1.7.0 after two years passed, so you should not expect this unofficial example will just work on the latest NCS.

    Please try to adapt the original mqtt_w_uart example to NCS 1.70 by yourself first. Feel free to ask if you have any further problems.

    Best regards,


  • Hi Charlie.

    The problem we're still encountering is that just trying to enable a UART RX within the main function causes a hard fault.  I know it has something to do with the kernel but there aren't any clues about the nature of the conflict.  I can go back to 1.1.0 to get it to work but I was hoping to put it in the modern form.  I've tried setting CONFIG_SPM_NRF_UARTE1_NS=y and CONFIG_SPM_NRF_UARTE2_NS=y in the Prj.conf file to make sure that neither are secure, but the error still is in secure state.  "Exception occurred in Secure State".  Were there any big changes in the zephyr kernel between 1.1.0 and 1.7.0 ?

    OK nevermind the idea of reverting back to 1.1.0 or even 1.2.0 - "The evaluation period for this release has now expired"

    So I guess we're stuck with this problem

  • 0
    585 pts.
    in reply to GerryB

    Hi Gerry,

    I update this example to NCS 1.7.0 now. Since uart0 has been used as log output, it enables uart1 as your message input terminal. Which can also be accessed through one of the 3 VCOM ports of nRF9160DK.

    Best regards,


  • OK thanks Charlie I will give it a try

Reply Children
No Data