Closed k0d closed 2 years ago
Nice redacted log
Ok, this seems linked to the use of CONFIG_SEGGER_SYSTEMVIEW with M0/M0+ target.
I'm hitting the same issue with bbc_microbit
@microbuilder Can you have a look ?
Same issue on board atsamd20_xpro
. Is there a quick fix or work around?
My Log:
In file included from <redacted>/modules/debug/segger/Config/SEGGER_RTT_Conf.h:150,
from <redacted>/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h:66,
from <redacted>/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:65,
from <redacted>/zephyr/subsys/tracing/sysview/./tracing_sysview_syscall.h:10,
from <redacted>/zephyr/include/tracing/tracing_syscall.h:11,
from <redacted>/echo-server-samd/zephyr/include/generated/syscalls/atomic_c.h:7,
from <redacted>/zephyr/include/sys/atomic_c.h:75,
from <redacted>/zephyr/include/sys/atomic.h:31,
from <redacted>/zephyr/include/logging/log_msg.h:9,
from <redacted>/zephyr/include/logging/log_core.h:9,
from <redacted>/zephyr/include/logging/log.h:11,
from <redacted>/modules/flexbus-l2-uart/samples/echo_server/src/main.c:6:
<redacted>/zephyr/include/kernel.h: In function 'k_work_user_is_pending':
<redacted>/zephyr/include/kernel.h:4041:9: warning: implicit declaration of function 'atomic_test_bit' [-Wimplicit-function-declaration]
4041 | return atomic_test_bit(&work->flags, K_WORK_USER_STATE_PENDING);
| ^~~~~~~~~~~~~~~
<redacted>/zephyr/include/kernel.h: In function 'k_work_user_submit_to_queue':
<redacted>/zephyr/include/kernel.h:4067:7: warning: implicit declaration of function 'atomic_test_and_set_bit'; did you mean 'sys_test_and_set_bit'? [-Wimplicit-function-declaration]
4067 | if (!atomic_test_and_set_bit(&work->flags,
| ^~~~~~~~~~~~~~~~~~~~~~~
| sys_test_and_set_bit
<redacted>/zephyr/include/kernel.h:4075:4: warning: implicit declaration of function 'atomic_clear_bit'; did you mean 'atomic_clear'? [-Wimplicit-function-declaration]
4075 | atomic_clear_bit(&work->flags,
| ^~~~~~~~~~~~~~~~
| atomic_clear
In file included from <redacted>/zephyr/include/logging/log_msg.h:9,
from <redacted>/zephyr/include/logging/log_core.h:9,
from <redacted>/zephyr/include/logging/log.h:11,
from <redacted>/modules/flexbus-l2-uart/samples/echo_server/src/main.c:6:
<redacted>/zephyr/include/sys/atomic.h: At top level:
<redacted>/zephyr/include/sys/atomic.h:131:20: error: conflicting types for 'atomic_test_bit'
131 | static inline bool atomic_test_bit(const atomic_t *target, int bit)
| ^~~~~~~~~~~~~~~
In file included from <redacted>/modules/debug/segger/Config/SEGGER_RTT_Conf.h:150,
from <redacted>/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h:66,
from <redacted>/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:65,
from <redacted>/zephyr/subsys/tracing/sysview/./tracing_sysview_syscall.h:10,
from <redacted>/zephyr/include/tracing/tracing_syscall.h:11,
from <redacted>/echo-server-samd/zephyr/include/generated/syscalls/atomic_c.h:7,
from <redacted>/zephyr/include/sys/atomic_c.h:75,
from <redacted>/zephyr/include/sys/atomic.h:31,
from <redacted>/zephyr/include/logging/log_msg.h:9,
from <redacted>/zephyr/include/logging/log_core.h:9,
from <redacted>/zephyr/include/logging/log.h:11,
from <redacted>/modules/flexbus-l2-uart/samples/echo_server/src/main.c:6:
<redacted>/zephyr/include/kernel.h:4041:9: note: previous implicit declaration of 'atomic_test_bit' was here
4041 | return atomic_test_bit(&work->flags, K_WORK_USER_STATE_PENDING);
| ^~~~~~~~~~~~~~~
In file included from <redacted>/zephyr/include/logging/log_msg.h:9,
from <redacted>/zephyr/include/logging/log_core.h:9,
from <redacted>/zephyr/include/logging/log.h:11,
from <redacted>/modules/flexbus-l2-uart/samples/echo_server/src/main.c:6:
<redacted>/zephyr/include/sys/atomic.h:176:20: error: conflicting types for 'atomic_test_and_set_bit'
176 | static inline bool atomic_test_and_set_bit(atomic_t *target, int bit)
| ^~~~~~~~~~~~~~~~~~~~~~~
In file included from <redacted>/modules/debug/segger/Config/SEGGER_RTT_Conf.h:150,
from <redacted>/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h:66,
from <redacted>/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:65,
from <redacted>/zephyr/subsys/tracing/sysview/./tracing_sysview_syscall.h:10,
from <redacted>/zephyr/include/tracing/tracing_syscall.h:11,
from <redacted>/echo-server-samd/zephyr/include/generated/syscalls/atomic_c.h:7,
from <redacted>/zephyr/include/sys/atomic_c.h:75,
from <redacted>/zephyr/include/sys/atomic.h:31,
from <redacted>/zephyr/include/logging/log_msg.h:9,
from <redacted>/zephyr/include/logging/log_core.h:9,
from <redacted>/zephyr/include/logging/log.h:11,
from <redacted>/modules/flexbus-l2-uart/samples/echo_server/src/main.c:6:
<redacted>/zephyr/include/kernel.h:4067:7: note: previous implicit declaration of 'atomic_test_and_set_bit' was here
4067 | if (!atomic_test_and_set_bit(&work->flags,
| ^~~~~~~~~~~~~~~~~~~~~~~
In file included from <redacted>/zephyr/include/logging/log_msg.h:9,
from <redacted>/zephyr/include/logging/log_core.h:9,
from <redacted>/zephyr/include/logging/log.h:11,
from <redacted>/modules/flexbus-l2-uart/samples/echo_server/src/main.c:6:
<redacted>/zephyr/include/sys/atomic.h:198:20: warning: conflicting types for 'atomic_clear_bit'
198 | static inline void atomic_clear_bit(atomic_t *target, int bit)
| ^~~~~~~~~~~~~~~~
<redacted>/zephyr/include/sys/atomic.h:198:20: error: static declaration of 'atomic_clear_bit' follows non-static declaration
In file included from <redacted>/modules/debug/segger/Config/SEGGER_RTT_Conf.h:150,
from <redacted>/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h:66,
from <redacted>/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:65,
from <redacted>/zephyr/subsys/tracing/sysview/./tracing_sysview_syscall.h:10,
from <redacted>/zephyr/include/tracing/tracing_syscall.h:11,
from <redacted>/echo-server-samd/zephyr/include/generated/syscalls/atomic_c.h:7,
from <redacted>/zephyr/include/sys/atomic_c.h:75,
from <redacted>/zephyr/include/sys/atomic.h:31,
from <redacted>/zephyr/include/logging/log_msg.h:9,
from <redacted>/zephyr/include/logging/log_core.h:9,
from <redacted>/zephyr/include/logging/log.h:11,
from <redacted>/modules/flexbus-l2-uart/samples/echo_server/src/main.c:6:
<redacted>/zephyr/include/kernel.h:4075:4: note: previous implicit declaration of 'atomic_clear_bit' was here
4075 | atomic_clear_bit(&work->flags,
| ^~~~~~~~~~~~~~~~
[19/195] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/rb.c.obj
ninja: build stopped: subcommand failed.
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.
@teburd Could you have a look at this. I think this has been broken on Cortex-M0 targets since #39454.
This is caused by circular header dependencies. IMHO the segger systemview header should never direclty include zephyr kernel headers but what happens is
In file included from ../include/zephyr/kernel_includes.h:37,
from ../include/zephyr/kernel.h:17,
from /home/user/workspace/zephyrproject/modules/debug/segger/Config/SEGGER_RTT_Conf.h:150,
from /home/user/workspace/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h:66,
from /home/user/workspace/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:65,
from ../subsys/tracing/sysview/./tracing_sysview_syscall.h:10,
from ../include/zephyr/tracing/tracing_syscall.h:11,
from zephyr/include/generated/syscalls/atomic_c.h:7,
from ../include/zephyr/sys/atomic_c.h:75,
from ../include/zephyr/sys/atomic.h:31,
from ../include/zephyr/kernel_structs.h:24,
from ../include/zephyr/arch/arm/aarch32/arch_inlines.h:10,
from ../include/zephyr/arch/arch_inlines.h:18,
from ../include/zephyr/sys/arch_interface.h:1265,
from ../include/zephyr/arch/cpu.h:12,
from /home/user/workspace/zephyrproject/zephyr/arch/common/isr_tables.c:10:
../include/zephyr/fatal.h:87:59: error: unknown type name 'z_arch_esf_t'
87 | void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *esf);
So regular code includes zephyr kernel code, which includes the tracing with segger, which then in SEGGER_RTT_Conf.h includes the kernel again.
I prepared a fix which moves all the dependent code into the c files of the segger module. Unfortunately that needs changes in both zephyr and segger repositories:
zephyr - fix_segger_dependencies segger - fix_include_dependencies
Let me know if it works for you, then I will start a merge request.
@ccoenenatbaumer Do you mind making a pair of PRs for these changes?
With the changes it builds again, but I am unable to verify if Segger SystemView is still working properly. Would be great if someone could do that.
I was previously able to compile on the M33 (all I had on hand at the time with a built-in J-Link was the nrf5340dk_nrf5340_cpuapp
), but I haven't been able to get SystemView (v3.32) to work.
KConfig Settings:
# Segger SystemView
CONFIG_THREAD_NAME=y
CONFIG_SEGGER_SYSTEMVIEW=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_TRACING=y
CONFIG_TRACING_BACKEND_RAM=y
# Optional: Start logging SystemView events on system start
CONFIG_SEGGER_SYSTEMVIEW_BOOT_ENABLE=y
# Optional: `CONFIG_SEGGER_SYSVIEW_POST_MORTEM_MODE` enables the debugger
# to be attached after the system has crashed using ``west attach`` for
# post-mortum analysis in SystemView.
CONFIG_SEGGER_SYSVIEW_POST_MORTEM_MODE=n
As per the tracing documentation, I also updated this file:
$ cp $ZEPHYR_BASE/subsys/tracing/sysview/SYSVIEW_Zephyr.txt ~/.config/SEGGER/
I haven't used SystemView with Zephyr before, so I'm not sure if one of these settings is wrong, or if this has been silently broken for a while, or if it's just something specific to MacOS in my case.
@nordic-krch Are you responsible for SystemView as well? Just curious if the above looks right to you. Wasn't able to get any tracing input working to test on the nRF53, but don't know when this was last known to work.
@ccoenenatbaumer Thanks for your proposal. I picked your changes and in a quick test with the synchronization sample everything seems to work. So I would suggest you to open a PR. Even if you have not tested the changes fully you can always open a draft PR, because that simplifies testing and giving feedback for others.
@ccoenenatbaumer Thanks for your proposal. I picked your changes and in a quick test with the synchronization sample everything seems to work. So I would suggest you to open a PR. Even if you have not tested the changes fully you can always open a draft PR, because that simplifies testing and giving feedback for others.
What config flags did you add that you were able to get SystemView working? Couldn't get any output myself with the settings here https://github.com/zephyrproject-rtos/zephyr/issues/43887#issuecomment-1199059992
I was testing with samples/synchronization
adding an overlay file with the following options:
CONFIG_THREAD_NAME=y
CONFIG_TRACING=y
CONFIG_SEGGER_SYSTEMVIEW=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_SEGGER_SYSTEMVIEW_BOOT_ENABLE=y
With SystemView V3.32 on Linux. Have you tried with Cortex-M4 or a Cortex-M0+? Those targets have worked quite reliable in the few tests I have performed. Also tried with an STM32U5 target (CM33), but there it had issues finding the buffer and only worked from time to time.
I could successfully test with nucleo_g431rb and created two pull requests
zephyrproject-rtos/segger#13
Describe the bug I'm trying to enable tracing using systemview on a STM32L071 board. I can compile the same code for an nrf9160dk board and it works fine. It fails with the console log shown below.
To Reproduce have this in your project config
Expected behavior It should compile without errors.
Logs and console output
Environment (please complete the following information):