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

nrf9160 MQTT example

Hi!

I just saw the MQTT example that has been merged in the master branch and tried to run it on my DK (NB-IoT). Without changing anything in the code or configuration the execution leads to the following output in the console appears:

***** BUS FAULT *****
Precise data bus error
BFAR Address: 0x4002a514
***** Hardware exception *****
Current thread ID = 0x2000031c
Faulting instruction address = 0x6604
Fatal fault in essential thread! Spinning...

I used the latest tags of the releases of zephyr, etc. and only copied mqtt_simple from master branch. Are there any hints or tips how I can make the example work?

Parents
  • Build and program the samples/nrf9160/secure_boot/ example first, then it should work.

    This is needed since the SPU peripheral needs to be configured with a "NON SECURE" area, in which the MQTT example will reside.

    The secure_boot sample performs this configuration.

  • Hi! Thanks for the answer. There is something very strange going on.

    So I am able to compile and flash secure_boot, at_client, asset_tracker, and the NTP example. Everything seems to work. Serial output looks ok.

    (...)

    Secure Boot: SPU: set SRAM region 30 as Non-Secure
    Secure Boot: SPU: set SRAM region 31 as Non-Secure
    Secure Boot: configure peripherals
    Secure Boot: MSP_NS 200265f0
    Secure Boot: prepare to jump to Non-Secure image
    ***** Booting Zephyr OS v1.13.99-ncs2 *****
    The AT host sample started

    (...)

    Now opening and compiling the mqtt_simple example from the master branch.

    After build and run the output in segger studio is:

    (...)

    Preparing target for download
    Executing script TargetInterface.resetAndStop()
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    Downloading ‘zephyr.elf’ to J-Link
    Programming 83.3 KB of addresses 00000000 — 00014d37
    Programming 0.4 KB of addresses 00014d38 — 00014edb
    J-Link: Flash download: Bank 0 @ 0x00000000: 1 range affected (16384 bytes)
    J-Link: Flash download: Total time needed: 0.570s (Prepare: 0.042s, Compare: 0.041s, Erase: 0.357s, Program: 0.120s, Verify: 0.000s, Restore: 0.007s)
    Download successful

    Console output:

    Secure Boot: SPU: set SRAM region 30 as Non-Secure
    Secure Boot: SPU: set SRAM region 31 as Non-Secure
    Secure Boot: configure peripherals
    Secure Boot: MSP_NS 200265f0
    Secure Boot: prepare to jump to Non-Secure image
    ***** Booting Zephyr OS v1.13.99-ncs2 *****
    The AT host sample started
    ***** BUS FAULT *****
    Precise data bus error
    BFAR Address: 0x4002a514
    ***** Hardware exception *****
    Current thread ID = 0x2000031c
    Faulting instruction address = 0x6f74
    Fatal fault in essential thread! Spinning...

    Reset and power cycle leads to the same result. Immediate output is always "Bus Fault".

    Now I tried to reprogram the at_client. But it seems like flashing another application is not possible. The output is the following:

    (...)
    Preparing target for download
    Executing script TargetInterface.resetAndStop()
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    Downloading ‘zephyr.elf’ to J-Link
    Programming 78.3 KB of addresses 00040000 — 0005397b
    Programming 0.4 KB of addresses 0005397c — 00053b23
    J-Link: Flash download: Bank 0 @ 0x00000000: Skipped. Contents already match
    Download successful

    The only thing I can do is re-flashing the secure_boot sample. After that, the device starts to run the at_client

    It seems like there is a problem when flashing the mqtt_client sample.

    Is anybody experiencing similar problems?

  • Hi Dominik,

    If you are going to use the latest updates in the master branch to nrf, you should also make sure that you are in the master branches to the other repos and update them to the latest:

    cd <sourcecode_root>\ncs\zephyr ; git checkout master ; git pull
    cd <sourcecode_root>\ncs\mcuboot ; git checkout master ; git pull
    cd <sourcecode_root>\ncs\nrf ; git checkout master ; git pull
    cd <sourcecode_root>\ncs\nrfxlib ; git checkout master ; git pull

    Unfortunately, there is an issue with building using SES with the latest master branch (I can assure you that we are working on fixing this). 


    Workaround:
    In the meantime you can build the application via the terminal, where the board name for a non-secure project has changed to “nrf9160_pca10090ns”.

    Here’s the way to generate/compile a project from terminal:

    export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb
    export GNUARMEMB_TOOLCHAIN_PATH="/path/to/gcc-arm-none-eabi-Qx-2018/"
    source /path/to/ncs/zephyr/zephyr-env.sh
    cd /path/to/ncs/nrf/samples/nrf9160/mqtt_simple/
    mkdir build && cd build
    cmake .. -DBOARD=nrf9160_pca10090ns -GNinja
    ninja flash
    

    - If your build folder exists, you might need to clear it (delete the content) first.

    (use ninja to compile and/or ninja flash to compile and flash to the kit)

    Note that you also need to build/flash the secure_boot sample again to be sure that everything is on the right memory area.

    Please note that when building for secure_boot you need to use this command instead: 

    cmake .. -DBOARD=nrf9160_pca10090 -GNinja

    (note that it does not have the ns at the end ["non-secure"])

    It should look something like this:


    I must apologize for the inconvenience this may have caused.

    Best Regards,

    Martin L.

  • Hi Martin,

    I followed the 7 steps above but cannot flash because of this error:

    FileNotFoundError: [Errno 2] No such file or directory: 'nrfjprog': 'nrfjprog'

    I ran pip3 install --user pynrfjprog and retried but it made no difference.  Any suggestions?

    -rob

  • Hi Rob,

    You are missing the nRF command Line Tools.

    Please download it and it should work.

  • Same result after untar of that archive into my /opt/SEGGER/JLink directory.  Is there a variable that I can 'export' so that ninja can find nrfjprog?

Reply Children
  • Hi Rob,

    You need to add nrfjprog to PATH (set the path in Linux), so your terminal can find the program

  • OK, I exported the location so that nrfjprog is accessible but I get this error now...

    rob@rob-VirtualBox:~/dev/ncs/nrf/samples/nrf9160/mqtt_simple/build$ west -v flash --skip-rebuild
    ZEPHYR_BASE=/home/rob/dev/ncs/zephyr (origin: manifest file /home/rob/dev/ncs/nrf/west.yml)
    Using runner: nrfjprog
    nrfjprog --ids
    Flashing file: /home/rob/dev/ncs/nrf/samples/nrf9160/mqtt_simple/build/zephyr/zephyr.hex
    nrfjprog --program /home/rob/dev/ncs/nrf/samples/nrf9160/mqtt_simple/build/zephyr/zephyr.hex -f NRF91 --snr 960011468 --sectorerase
    ERROR: JLinkARM DLL reported an error. Try again. If error condition
    ERROR: persists, run the same command again with argument --log, contact Nordic
    ERROR: Semiconductor and provide the generated log.log file to them.
    ERROR: command exited with status 33: nrfjprog --program /home/rob/dev/ncs/nrf/samples/nrf9160/mqtt_simple/build/zephyr/zephyr.hex -f NRF91 --snr 960011468 --sectorerase
    Traceback (most recent call last):
    File "/home/rob/dev/ncs/.west/west/src/west/main.py", line 505, in main
    args.handler(args, unknown)
    File "/home/rob/dev/ncs/.west/west/src/west/main.py", line 326, in ext_command_handler
    command.run(*west_parser.parse_known_args(argv))
    File "/home/rob/dev/ncs/.west/west/src/west/commands/command.py", line 85, in run
    self.do_run(args, unknown)
    File "/home/rob/dev/ncs/zephyr/scripts/west_commands/flash.py", line 32, in do_run
    'ZEPHYR_BOARD_FLASH_RUNNER')
    File "/home/rob/dev/ncs/zephyr/scripts/west_commands/run_common.py", line 246, in do_run_common
    runner.run(command_name)
    File "/home/rob/dev/ncs/zephyr/scripts/west_commands/runners/core.py", line 407, in run
    self.do_run(command, **kwargs)
    File "/home/rob/dev/ncs/zephyr/scripts/west_commands/runners/nrfjprog.py", line 128, in do_run
    self.check_call(cmd)
    File "/home/rob/dev/ncs/zephyr/scripts/west_commands/runners/core.py", line 466, in check_call
    subprocess.check_call(cmd)
    File "/usr/lib/python3.6/subprocess.py", line 291, in check_call
    raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['nrfjprog', '--program', '/home/rob/dev/ncs/nrf/samples/nrf9160/mqtt_simple/build/zephyr/zephyr.hex', '-f', 'NRF91', '--snr', '960011468', '--sectorerase']' returned non-zero exit status 33.

    ..sorry for being a pain.

Related