J-Link RTT output completely stops working after running for a long time

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • J-Link RTT output completely stops working after running for a long time

      Our project uses an EFM32WG940F256 microcontroller on a custom board. This board is connected via SWD to a J-Link device, which is connected via USB to a computer that runs Linux. We have a relatively big "bare-metal" program on the MCU which outputs debugging information to RTT. We are currently at the final stages of the project so we're running the program on the MCU for a longer time to see if it functions correctly. The debug information from RTT is very important to us for determining what the program is doing, and if it crashes, what happened before the crash.

      The problem we see is the following:
      After our device runs for a longer time (about 20 hours) with J-Link connected, the RTT eventually outputs some garbage and then stops working. I checked, and found that after it was running for 20 hours, RTT just output some contents from the end of the program binary, and then it won't work anymore, even if we restart the JLinkExe process.

      The computer runs 64-bit Ubuntu 16.04 and has the J-Link 6.46 package installed. We connect to the J-Link device using the command line:
      JLinkExe -if swd -device EFM32WG940F256 -speed 100000 -rtttelnetport 3334 -autoconnect 1

      Then we just use netcat to save the logs into a file:
      nc localhost 3334 > debug_log.txt
      Then, from time to time we look at the file to see what is happening on our device.

      This is how we use RTT in our program:

      Source Code

      1. static inline void board_setup_debugPrint(void)
      2. {
      3. SEGGER_RTT_Init();
      4. SEGGER_RTT_ConfigUpBuffer(0, NULL, NULL, 0, SEGGER_RTT_MODE_NO_BLOCK_TRIM);
      5. }
      6. __attribute__((no_instrument_function)) int __wrap_puts(char const *s)
      7. {
      8. size_t len = strnlen(s, 150);
      9. SEGGER_RTT_Write(0, s, len);
      10. return 0;
      11. }
      12. __attribute__((no_instrument_function)) int __wrap_printf(const char *__restrict fmt, ...)
      13. {
      14. int r;
      15. va_list ap;
      16. char buf[150];
      17. va_start(ap, fmt);
      18. r = vsnprintf(buf, sizeof(buf), fmt, ap);
      19. va_end(ap);
      20. buf[sizeof(buf) - 1] = 0; // Just in case
      21. puts(buf);
      22. return r;
      23. }
      Display All
      Then we compile with GCC and just use the linker's --wrap argument so that it replaces puts and printf from the C library with our own, RTT-based implementation.


      Can you please help figure out why it stops working after it had been running for 20+ hours?
      Thank you in advance for your answers!