Static code analyze tools for NRF Connect SDK

Hello,

I'm doing reasearch in static code analyze tools for my projects. At link below I saw that since version ncs 2.1.0 there is possible to use "Sparse" tool to static code analyze but some configs are required... I can't find what kind of configs...

 nrf Connect 1.6.1 SDK : Static Code Analysis 

 I also saw this:

https://docs.zephyrproject.org/3.1.0/develop/test/sparse.html

I've tried to build some example with "-- -DSPARSE=y".

west build -p always -b nrf52dk_nrf52832 samples/basic/blinky -- -DSPARSE=y

As a result I've got...

es2@es2-hpprobook450g1:~/ncs/zephyr$ west build -p always -b nrf52dk_nrf52832 samples/basic/blinky -- -DSPARSE=y
-- west build: making build dir /home/es2/ncs/zephyr/build pristine
-- west build: generating a build system                                                                                                                                                      
Loading Zephyr default modules (Zephyr base).                                                                                                                                                 
-- Application: /home/es2/ncs/zephyr/samples/basic/blinky
-- Found Python3: /usr/bin/python3.10 (found suitable exact version "3.10.6") found components: Interpreter
-- Cache files will be written to: /home/es2/.cache//zephyr
-- Zephyr version: 3.1.99 (/home/es2/ncs/zephyr)
-- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
-- Board: nrf52dk_nrf52832
-- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
-- Found host-tools: zephyr 0.14.1 (/home/es2/zephyr-sdk-0.14.1)
-- Found dtc: /home/es2/zephyr-sdk-0.14.1/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6")
-- Found toolchain: zephyr 0.14.1 (/home/es2/zephyr-sdk-0.14.1)
-- Found BOARD.dts: /home/es2/ncs/zephyr/boards/arm/nrf52dk_nrf52832/nrf52dk_nrf52832.dts
-- Generated zephyr.dts: /home/es2/ncs/zephyr/build/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: /home/es2/ncs/zephyr/build/zephyr/include/generated/devicetree_unfixed.h
-- Generated device_extern.h: /home/es2/ncs/zephyr/build/zephyr/include/generated/device_extern.h
-- Including generated dts.cmake file: /home/es2/ncs/zephyr/build/zephyr/dts.cmake
Parsing /home/es2/ncs/zephyr/Kconfig
Loaded configuration '/home/es2/ncs/zephyr/boards/arm/nrf52dk_nrf52832/nrf52dk_nrf52832_defconfig'
Merged configuration '/home/es2/ncs/zephyr/samples/basic/blinky/prj.conf'
Configuration saved to '/home/es2/ncs/zephyr/build/zephyr/.config'
Kconfig header saved to '/home/es2/ncs/zephyr/build/zephyr/include/generated/autoconf.h'
CMake Error at /home/es2/ncs/zephyr/cmake/compiler/gcc/target.cmake:17 (message):
  C compiler                                                                                                                                                                                  
  /home/es2/zephyr-sdk-0.14.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc not                                                                                                                     
  found - Please check your toolchain installation                                                                                                                                            
Call Stack (most recent call first):                                                                                                                                                          
  /home/es2/ncs/zephyr/cmake/modules/target_toolchain.cmake:63 (include)                                                                                                                      
  /home/es2/ncs/zephyr/cmake/modules/zephyr_default.cmake:121 (include)                                                                                                                       
  /home/es2/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)                                                                                                             
  /home/es2/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)                                                                                                 
  CMakeLists.txt:4 (find_package)                                                                                                                                                             


-- Configuring incomplete, errors occurred!
FATAL ERROR: command exited with status 1: /usr/bin/cmake -DWEST_PYTHON=/usr/bin/python3 -B/home/es2/ncs/zephyr/build -GNinja -DBOARD=nrf52dk_nrf52832 -DSPARSE=y -S/home/es2/ncs/zephyr/samples/basic/blinky

If this is still in progress or something, what kind of tool You recommend for static code analyzing...?

Best regards,

Kamil

Parents
  • I have issues with static analysis too. Currently using ncs v2.2.0. I get this error:

    The only way to override its 'cc' default when cross-compiling with sparse
    is unfortunately an environment variable. So you _must_ set REAL_CC at
    both configuration time and build time to:
    ${HOME}/zephyr-sdk-0.15.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc


    I've tried setting REAL_CC in bash to the specified value, but the error stays the same.

Reply
  • I have issues with static analysis too. Currently using ncs v2.2.0. I get this error:

    The only way to override its 'cc' default when cross-compiling with sparse
    is unfortunately an environment variable. So you _must_ set REAL_CC at
    both configuration time and build time to:
    ${HOME}/zephyr-sdk-0.15.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc


    I've tried setting REAL_CC in bash to the specified value, but the error stays the same.

Children
No Data
Related