zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.77k stars 6.57k forks source link

SystemView tracing with STM32L0x fails to compile #43887

Closed k0d closed 2 years ago

k0d commented 2 years ago

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

CONFIG_THREAD_NAME=y
CONFIG_SEGGER_SYSTEMVIEW=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_TRACING=y
CONFIG_SEGGER_SYSVIEW_POST_MORTEM_MODE=n
CONFIG_SEGGER_SYSTEMVIEW_BOOT_ENABLE=y

Expected behavior It should compile without errors.

Logs and console output

❯ west build .
-- west flash: rebuilding
[0/1] Re-running CMake...
Including boilerplate (Zephyr base (cached)): <redacted>/zephyrproject/zephyr/cmake/app/boilerplate.cmake
-- Application: <redacted>
-- Zephyr version: 3.0.0 (<redacted>/zephyrproject/zephyr)
-- Found west (found suitable version "0.11.0", minimum required is "0.7.1")
-- Board: <redacted>_<redacted>
-- Cache files will be written to: <redacted>/Library/Caches/zephyr
-- Found dtc: /opt/homebrew/bin/dtc (found suitable version "1.6.1", minimum required is "1.4.6")
-- Found toolchain: gnuarmemb (/Applications/ARM)
-- Found BOARD.dts: <redacted>/boards/arm/<redacted>_<redacted>/<redacted>_<redacted>.dts
node '/board' compatible '<redacted>,<redacted>' has unknown vendor prefix '<redacted>'
-- Generated zephyr.dts: <redacted>/build/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: <redacted>/build/zephyr/include/generated/devicetree_unfixed.h
-- Generated device_extern.h: <redacted>/build/zephyr/include/generated/device_extern.h
-- Including generated dts.cmake file: <redacted>/build/zephyr/dts.cmake
<redacted>/build/zephyr/zephyr.dts:677.5-26: Warning (i2c_bus_reg): /soc/i2c@40005400/st25dv@53:reg: I2C address must be less than 7-bits, got "0x200". Set I2C_TEN_BIT_ADDRESS for 10 bit addresses or fix the property
<redacted>/build/zephyr/zephyr.dts:73.39-78.5: Warning (interrupt_provider): /soc/interrupt-controller@40010400: Missing #address-cells in interrupt provider
Parsing <redacted>/zephyrproject/zephyr/Kconfig
Loaded configuration '<redacted>/boards/arm/<redacted>_<redacted>/<redacted>_<redacted>_defconfig'
Merged configuration '<redacted>/prj.conf'
Configuration saved to '<redacted>/build/zephyr/.config'
Kconfig header saved to '<redacted>/build/zephyr/include/generated/autoconf.h'
-- Configuring done
-- Generating done
-- Build files have been written to: <redacted>/build
[30/154] Building C object modules/segger/CMake...odules/debug/segger/SEGGER/SEGGER_SYSVIEW.c.obj
In file included from <redacted>/zephyrproject/zephyr/include/tracing/tracing_syscall.h:11,
                 from <redacted>/build/zephyr/include/generated/syscalls/atomic_c.h:7,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic_c.h:75,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic.h:31,
                 from <redacted>/zephyrproject/zephyr/include/kernel_includes.h:21,
                 from <redacted>/zephyrproject/zephyr/include/kernel.h:17,
                 from <redacted>/zephyrproject/modules/debug/segger/Config/SEGGER_RTT_Conf.h:150,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h:66,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:65,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_Int.h:64,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.c:146:
<redacted>/zephyrproject/zephyr/include/sys/atomic.h: In function 'atomic_test_and_clear_bit':
<redacted>/zephyrproject/zephyr/subsys/tracing/sysview/./tracing_sysview_syscall.h:14:2: warning: implicit declaration of function 'SEGGER_SYSVIEW_RecordU32' [-Wimplicit-function-declaration]
   14 |  SEGGER_SYSVIEW_RecordU32(TID_SYSCALL, (uint32_t)id)
      |  ^~~~~~~~~~~~~~~~~~~~~~~~
<redacted>/build/zephyr/include/generated/syscalls/atomic_c.h:234:61: note: in expansion of macro 'sys_port_trace_syscall_enter'
  234 | #define atomic_and(target, value) ({  atomic_val_t retval;  sys_port_trace_syscall_enter(K_SYSCALL_ATOMIC_AND, atomic_and, target, value);  retval = atomic_and(target, value);  sys_port_trace_syscall_exit(K_SYSCALL_ATOMIC_AND, atomic_and, target, value, retval);  retval; })
      |                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
<redacted>/zephyrproject/zephyr/include/sys/atomic.h:151:8: note: in expansion of macro 'atomic_and'
  151 |  old = atomic_and(ATOMIC_ELEM(target, bit), ~mask);
      |        ^~~~~~~~~~
<redacted>/zephyrproject/zephyr/subsys/tracing/sysview/./tracing_sysview_syscall.h:17:2: warning: implicit declaration of function 'SEGGER_SYSVIEW_RecordEndCallU32' [-Wimplicit-function-declaration]
   17 |  SEGGER_SYSVIEW_RecordEndCallU32(TID_SYSCALL, (uint32_t)id)
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<redacted>/build/zephyr/include/generated/syscalls/atomic_c.h:234:178: note: in expansion of macro 'sys_port_trace_syscall_exit'
  234 | #define atomic_and(target, value) ({  atomic_val_t retval;  sys_port_trace_syscall_enter(K_SYSCALL_ATOMIC_AND, atomic_and, target, value);  retval = atomic_and(target, value);  sys_port_trace_syscall_exit(K_SYSCALL_ATOMIC_AND, atomic_and, target, value, retval);  retval; })
      |                                                                                                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
<redacted>/zephyrproject/zephyr/include/sys/atomic.h:151:8: note: in expansion of macro 'atomic_and'
  151 |  old = atomic_and(ATOMIC_ELEM(target, bit), ~mask);
      |        ^~~~~~~~~~
In file included from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_Int.h:64,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.c:146:
<redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h: At top level:
<redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:263:6: warning: conflicting types for 'SEGGER_SYSVIEW_RecordU32'
  263 | void SEGGER_SYSVIEW_RecordU32                     (unsigned int EventId, U32 Para0);
      |      ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from <redacted>/zephyrproject/zephyr/include/tracing/tracing_syscall.h:11,
                 from <redacted>/build/zephyr/include/generated/syscalls/atomic_c.h:7,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic_c.h:75,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic.h:31,
                 from <redacted>/zephyrproject/zephyr/include/kernel_includes.h:21,
                 from <redacted>/zephyrproject/zephyr/include/kernel.h:17,
                 from <redacted>/zephyrproject/modules/debug/segger/Config/SEGGER_RTT_Conf.h:150,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h:66,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:65,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_Int.h:64,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.c:146:
<redacted>/zephyrproject/zephyr/subsys/tracing/sysview/./tracing_sysview_syscall.h:14:2: note: previous implicit declaration of 'SEGGER_SYSVIEW_RecordU32' was here
   14 |  SEGGER_SYSVIEW_RecordU32(TID_SYSCALL, (uint32_t)id)
      |  ^~~~~~~~~~~~~~~~~~~~~~~~
<redacted>/build/zephyr/include/generated/syscalls/atomic_c.h:234:61: note: in expansion of macro 'sys_port_trace_syscall_enter'
  234 | #define atomic_and(target, value) ({  atomic_val_t retval;  sys_port_trace_syscall_enter(K_SYSCALL_ATOMIC_AND, atomic_and, target, value);  retval = atomic_and(target, value);  sys_port_trace_syscall_exit(K_SYSCALL_ATOMIC_AND, atomic_and, target, value, retval);  retval; })
      |                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
<redacted>/zephyrproject/zephyr/include/sys/atomic.h:151:8: note: in expansion of macro 'atomic_and'
  151 |  old = atomic_and(ATOMIC_ELEM(target, bit), ~mask);
      |        ^~~~~~~~~~
In file included from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_Int.h:64,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.c:146:
<redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:281:6: warning: conflicting types for 'SEGGER_SYSVIEW_RecordEndCallU32'
  281 | void SEGGER_SYSVIEW_RecordEndCallU32              (unsigned int EventID, U32 Para0);
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from <redacted>/zephyrproject/zephyr/include/tracing/tracing_syscall.h:11,
                 from <redacted>/build/zephyr/include/generated/syscalls/atomic_c.h:7,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic_c.h:75,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic.h:31,
                 from <redacted>/zephyrproject/zephyr/include/kernel_includes.h:21,
                 from <redacted>/zephyrproject/zephyr/include/kernel.h:17,
                 from <redacted>/zephyrproject/modules/debug/segger/Config/SEGGER_RTT_Conf.h:150,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h:66,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:65,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_Int.h:64,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.c:146:
<redacted>/zephyrproject/zephyr/subsys/tracing/sysview/./tracing_sysview_syscall.h:17:2: note: previous implicit declaration of 'SEGGER_SYSVIEW_RecordEndCallU32' was here
   17 |  SEGGER_SYSVIEW_RecordEndCallU32(TID_SYSCALL, (uint32_t)id)
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<redacted>/build/zephyr/include/generated/syscalls/atomic_c.h:234:178: note: in expansion of macro 'sys_port_trace_syscall_exit'
  234 | #define atomic_and(target, value) ({  atomic_val_t retval;  sys_port_trace_syscall_enter(K_SYSCALL_ATOMIC_AND, atomic_and, target, value);  retval = atomic_and(target, value);  sys_port_trace_syscall_exit(K_SYSCALL_ATOMIC_AND, atomic_and, target, value, retval);  retval; })
      |                                                                                                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
<redacted>/zephyrproject/zephyr/include/sys/atomic.h:151:8: note: in expansion of macro 'atomic_and'
  151 |  old = atomic_and(ATOMIC_ELEM(target, bit), ~mask);
      |        ^~~~~~~~~~
[87/154] Building C object zephyr/kernel/CMakeFiles/kernel.dir/atomic_c.c.obj
FAILED: zephyr/kernel/CMakeFiles/kernel.dir/atomic_c.c.obj 
ccache /Applications/ARM/bin/arm-none-eabi-gcc -DHSE_VALUE=8000000 -DKERNEL -DSTM32L071xx -DUSE_FULL_LL_DRIVER -DUSE_HAL_DRIVER -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR_SUPERVISOR__ -D__ZEPHYR__=1 -I<redacted>/zephyrproject/zephyr/kernel/include -I<redacted>/zephyrproject/zephyr/arch/arm/include -I<redacted>/zephyrproject/zephyr/include -I<redacted>/build/zephyr/include/generated -I<redacted>/zephyrproject/zephyr/soc/arm/st_stm32/stm32l0 -I<redacted>/zephyrproject/zephyr/drivers -I<redacted>/zephyrproject/zephyr/soc/arm/st_stm32/common -I<redacted>/zephyrproject/zephyr/subsys/tracing/include -I<redacted>/zephyrproject/zephyr/subsys/tracing/sysview/. -I<redacted>/zephyrproject/modules/hal/cmsis/CMSIS/Core/Include -I<redacted>/zephyrproject/modules/hal/stm32/stm32cube/stm32l0xx/soc -I<redacted>/zephyrproject/modules/hal/stm32/stm32cube/stm32l0xx/drivers/include -I<redacted>/zephyrproject/modules/hal/stm32/stm32cube/stm32l0xx/drivers/include/Legacy -I<redacted>/zephyrproject/modules/hal/stm32/stm32cube/common_ll/include -I<redacted>/zephyrproject/modules/debug/segger/SEGGER -I<redacted>/zephyrproject/modules/debug/segger/Config -I<redacted>/zephyrproject/zephyr/modules/segger/. -I<redacted>/include -isystem <redacted>/zephyrproject/zephyr/lib/libc/minimal/include -isystem /Applications/ARM/bin/../lib/gcc/arm-none-eabi/10.3.1/include -isystem /Applications/ARM/bin/../lib/gcc/arm-none-eabi/10.3.1/include-fixed -Os -imacros <redacted>/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m0plus -mthumb -mabi=aapcs -mfp16-format=ieee -imacros <redacted>/zephyrproject/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=<redacted>=CMAKE_SOURCE_DIR -fmacro-prefix-map=<redacted>/zephyrproject/zephyr=ZEPHYR_BASE -fmacro-prefix-map=<redacted>/zephyrproject=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT zephyr/kernel/CMakeFiles/kernel.dir/atomic_c.c.obj -MF zephyr/kernel/CMakeFiles/kernel.dir/atomic_c.c.obj.d -o zephyr/kernel/CMakeFiles/kernel.dir/atomic_c.c.obj -c <redacted>/zephyrproject/zephyr/kernel/atomic_c.c
In file included from <redacted>/zephyrproject/modules/debug/segger/Config/SEGGER_RTT_Conf.h:150,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h:66,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:65,
                 from <redacted>/zephyrproject/zephyr/subsys/tracing/sysview/./tracing_sysview_syscall.h:10,
                 from <redacted>/zephyrproject/zephyr/include/tracing/tracing_syscall.h:11,
                 from <redacted>/build/zephyr/include/generated/syscalls/atomic_c.h:7,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic_c.h:75,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic.h:31,
                 from <redacted>/zephyrproject/zephyr/include/spinlock.h:15,
                 from <redacted>/zephyrproject/zephyr/kernel/atomic_c.c:23:
<redacted>/zephyrproject/zephyr/include/kernel.h:1634:20: error: field 'lock' has incomplete type
 1634 |  struct k_spinlock lock;
      |                    ^~~~
<redacted>/zephyrproject/zephyr/include/kernel.h:2005:20: error: field 'lock' has incomplete type
 2005 |  struct k_spinlock lock;
      |                    ^~~~
<redacted>/zephyrproject/zephyr/include/kernel.h:2479:20: error: field 'lock' has incomplete type
 2479 |  struct k_spinlock lock;
      |                    ^~~~
<redacted>/zephyrproject/zephyr/include/kernel.h: In function 'k_work_user_is_pending':
<redacted>/zephyrproject/zephyr/include/kernel.h:4000:9: warning: implicit declaration of function 'atomic_test_bit' [-Wimplicit-function-declaration]
 4000 |  return atomic_test_bit(&work->flags, K_WORK_USER_STATE_PENDING);
      |         ^~~~~~~~~~~~~~~
<redacted>/zephyrproject/zephyr/include/kernel.h: In function 'k_work_user_submit_to_queue':
<redacted>/zephyrproject/zephyr/include/kernel.h:4026:7: warning: implicit declaration of function 'atomic_test_and_set_bit'; did you mean 'sys_test_and_set_bit'? [-Wimplicit-function-declaration]
 4026 |  if (!atomic_test_and_set_bit(&work->flags,
      |       ^~~~~~~~~~~~~~~~~~~~~~~
      |       sys_test_and_set_bit
<redacted>/zephyrproject/zephyr/include/kernel.h:4034:4: warning: implicit declaration of function 'atomic_clear_bit'; did you mean 'atomic_clear'? [-Wimplicit-function-declaration]
 4034 |    atomic_clear_bit(&work->flags,
      |    ^~~~~~~~~~~~~~~~
      |    atomic_clear
<redacted>/zephyrproject/zephyr/include/kernel.h: At top level:
<redacted>/zephyrproject/zephyr/include/kernel.h:4239:20: error: field 'lock' has incomplete type
 4239 |  struct k_spinlock lock;
      |                    ^~~~
<redacted>/zephyrproject/zephyr/include/kernel.h:4542:20: error: field 'lock' has incomplete type
 4542 |  struct k_spinlock lock;
      |                    ^~~~
<redacted>/zephyrproject/zephyr/include/kernel.h:4670:20: error: field 'lock' has incomplete type
 4670 |  struct k_spinlock lock;  /**< Synchronization lock */
      |                    ^~~~
<redacted>/zephyrproject/zephyr/include/kernel.h:4870:20: error: field 'lock' has incomplete type
 4870 |  struct k_spinlock lock;
      |                    ^~~~
<redacted>/zephyrproject/zephyr/include/kernel.h:5081:20: error: field 'lock' has incomplete type
 5081 |  struct k_spinlock lock;
      |                    ^~~~
In file included from <redacted>/zephyrproject/zephyr/include/spinlock.h:15,
                 from <redacted>/zephyrproject/zephyr/kernel/atomic_c.c:23:
<redacted>/zephyrproject/zephyr/include/sys/atomic.h:128:20: error: conflicting types for 'atomic_test_bit'
  128 | static inline bool atomic_test_bit(const atomic_t *target, int bit)
      |                    ^~~~~~~~~~~~~~~
In file included from <redacted>/zephyrproject/modules/debug/segger/Config/SEGGER_RTT_Conf.h:150,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h:66,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:65,
                 from <redacted>/zephyrproject/zephyr/subsys/tracing/sysview/./tracing_sysview_syscall.h:10,
                 from <redacted>/zephyrproject/zephyr/include/tracing/tracing_syscall.h:11,
                 from <redacted>/build/zephyr/include/generated/syscalls/atomic_c.h:7,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic_c.h:75,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic.h:31,
                 from <redacted>/zephyrproject/zephyr/include/spinlock.h:15,
                 from <redacted>/zephyrproject/zephyr/kernel/atomic_c.c:23:
<redacted>/zephyrproject/zephyr/include/kernel.h:4000:9: note: previous implicit declaration of 'atomic_test_bit' was here
 4000 |  return atomic_test_bit(&work->flags, K_WORK_USER_STATE_PENDING);
      |         ^~~~~~~~~~~~~~~
In file included from <redacted>/zephyrproject/zephyr/include/spinlock.h:15,
                 from <redacted>/zephyrproject/zephyr/kernel/atomic_c.c:23:
<redacted>/zephyrproject/zephyr/include/sys/atomic.h:167:20: error: conflicting types for 'atomic_test_and_set_bit'
  167 | static inline bool atomic_test_and_set_bit(atomic_t *target, int bit)
      |                    ^~~~~~~~~~~~~~~~~~~~~~~
In file included from <redacted>/zephyrproject/modules/debug/segger/Config/SEGGER_RTT_Conf.h:150,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h:66,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:65,
                 from <redacted>/zephyrproject/zephyr/subsys/tracing/sysview/./tracing_sysview_syscall.h:10,
                 from <redacted>/zephyrproject/zephyr/include/tracing/tracing_syscall.h:11,
                 from <redacted>/build/zephyr/include/generated/syscalls/atomic_c.h:7,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic_c.h:75,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic.h:31,
                 from <redacted>/zephyrproject/zephyr/include/spinlock.h:15,
                 from <redacted>/zephyrproject/zephyr/kernel/atomic_c.c:23:
<redacted>/zephyrproject/zephyr/include/kernel.h:4026:7: note: previous implicit declaration of 'atomic_test_and_set_bit' was here
 4026 |  if (!atomic_test_and_set_bit(&work->flags,
      |       ^~~~~~~~~~~~~~~~~~~~~~~
In file included from <redacted>/zephyrproject/zephyr/include/spinlock.h:15,
                 from <redacted>/zephyrproject/zephyr/kernel/atomic_c.c:23:
<redacted>/zephyrproject/zephyr/include/sys/atomic.h:186:20: warning: conflicting types for 'atomic_clear_bit'
  186 | static inline void atomic_clear_bit(atomic_t *target, int bit)
      |                    ^~~~~~~~~~~~~~~~
<redacted>/zephyrproject/zephyr/include/sys/atomic.h:186:20: error: static declaration of 'atomic_clear_bit' follows non-static declaration
In file included from <redacted>/zephyrproject/modules/debug/segger/Config/SEGGER_RTT_Conf.h:150,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h:66,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:65,
                 from <redacted>/zephyrproject/zephyr/subsys/tracing/sysview/./tracing_sysview_syscall.h:10,
                 from <redacted>/zephyrproject/zephyr/include/tracing/tracing_syscall.h:11,
                 from <redacted>/build/zephyr/include/generated/syscalls/atomic_c.h:7,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic_c.h:75,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic.h:31,
                 from <redacted>/zephyrproject/zephyr/include/spinlock.h:15,
                 from <redacted>/zephyrproject/zephyr/kernel/atomic_c.c:23:
<redacted>/zephyrproject/zephyr/include/kernel.h:4034:4: note: previous implicit declaration of 'atomic_clear_bit' was here
 4034 |    atomic_clear_bit(&work->flags,
      |    ^~~~~~~~~~~~~~~~
[96/154] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/tracing/sysview/sysview.c.obj
ninja: build stopped: subcommand failed.
FATAL ERROR: re-build in <redacted>/build failed (no --build-dir given)

Environment (please complete the following information):

erwango commented 2 years ago

Nice redacted log

erwango commented 2 years ago

Ok, this seems linked to the use of CONFIG_SEGGER_SYSTEMVIEW with M0/M0+ target. I'm hitting the same issue with bbc_microbit

erwango commented 2 years ago

@microbuilder Can you have a look ?

kmeinhar commented 2 years ago

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.
github-actions[bot] commented 2 years ago

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.

str4t0m commented 2 years ago

@teburd Could you have a look at this. I think this has been broken on Cortex-M0 targets since #39454.

ccoenenatbaumer commented 2 years ago

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.

microbuilder commented 2 years ago

@ccoenenatbaumer Do you mind making a pair of PRs for these changes?

ccoenenatbaumer commented 2 years ago

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.

microbuilder commented 2 years ago

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.

microbuilder commented 2 years ago

@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.

str4t0m commented 2 years ago

@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.

microbuilder commented 2 years ago

@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

str4t0m commented 2 years ago

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.

ccoenenatbaumer commented 2 years ago

I could successfully test with nucleo_g431rb and created two pull requests

48513

zephyrproject-rtos/segger#13