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:
Then we just use netcat to save the logs into a file:
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:
Display All
Then we compile with GCC and just use the linker's
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!
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
- static inline void board_setup_debugPrint(void)
- {
- SEGGER_RTT_Init();
- SEGGER_RTT_ConfigUpBuffer(0, NULL, NULL, 0, SEGGER_RTT_MODE_NO_BLOCK_TRIM);
- }
- __attribute__((no_instrument_function)) int __wrap_puts(char const *s)
- {
- size_t len = strnlen(s, 150);
- SEGGER_RTT_Write(0, s, len);
- return 0;
- }
- __attribute__((no_instrument_function)) int __wrap_printf(const char *__restrict fmt, ...)
- {
- int r;
- va_list ap;
- char buf[150];
- va_start(ap, fmt);
- r = vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
- buf[sizeof(buf) - 1] = 0; // Just in case
- puts(buf);
- return r;
- }
--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!