printk() maximum string length in Zephyr RTOS

0

I am new to Zephyr and I am a little baffled by the behaviour of printk() function.

What I want is to allow printing very long (up to 1024 character) strings in a single print operation to UART. When I do it without changing any configs, the string I'm trying to print gets abridged to 128 characters.

I figured, that if I add the following line to prj.conf, I can increase the maximum string length to 512 bytes:

CONFIG_LOG_PRINTK_MAX_STRING_LENGTH=512

However, if I change it further to, let's say, 768 bytes:

CONFIG_LOG_PRINTK_MAX_STRING_LENGTH=768

– this causes a crash loop with the following error message:

[00:00:00.251,861] <err> os: ***** MPU FAULT *****
[00:00:00.251,861] <err> os:   Stacking error (context area might be not valid)
[00:00:00.251,892] <err> os:   Data Access Violation
[00:00:00.251,892] <err> os:   MMFAR Address: 0x20015a28
[00:00:00.251,892] <err> os: r0/a1:  0x6ed54200  r1/a2:  0xdb5d3fa9  r2/a3:  0x0df5de7d
[00:00:00.251,922] <err> os: r3/a4:  0xb4da66d2 r12/ip:  0x65bcc27a r14/lr:  0x3d222cec
[00:00:00.251,922] <err> os:  xpsr:  0x717c5a00
[00:00:00.251,922] <err> os: s[ 0]:  0x00000000  s[ 1]:  0x00000000  s[ 2]:  0xffffffff  s[ 3]:  0xffffffff
[00:00:00.251,953] <err> os: s[ 4]:  0x00000000  s[ 5]:  0x00000003  s[ 6]:  0x00000000  s[ 7]:  0x00000000
[00:00:00.251,953] <err> os: s[ 8]:  0x00000000  s[ 9]:  0x00000000  s[10]:  0x00000000  s[11]:  0x00000000
[00:00:00.251,983] <err> os: s[12]:  0x00000000  s[13]:  0xffffffff  s[14]:  0x00000000  s[15]:  0x00000000
[00:00:00.251,983] <err> os: fpscr:  0x5bb10e10
[00:00:00.251,983] <err> os: Faulting instruction address (r15/pc): 0x2205e68f
[00:00:00.251,983] <err> os: >>> ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0
[00:00:00.252,014] <err> os: Current thread: 0x20000918 (unknown)
[00:00:01.758,026] <err> fatal_error: Resetting system

In the logger example inside Zephyr v1.5.1 this could be solved by simply adding CONFIG_TEST_EXTRA_STACKSIZE=4096 to prj.conf. However, in my own project, drastically increasing stack sizes of all my tasks for some reason doesn't help :(

So, the question is, what could be the cause and how can I fix it easily?

zephyr-rtos
asked on Stack Overflow May 21, 2021 by Andriy Makukha

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0