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
  • The case is quite urgent, can I ask about some answer...?

  •   , please "cherry-pick" the commit linked to below as it was not included in SDK 2.1.0. This should fix the "toolchain not found" error you encountered. 

    https://github.com/nrfconnect/sdk-zephyr/commit/3ebb18b882634be29955a52ea70cd59f634492c1 

      , I was not able to reproduce this here. Below is from my terminal when I tried to build the blinky sample with sparse. Could you try to repeat these steps on your end to see if you get the same result? Notice I had to make a symlink for cgcc as cgcc is not included in the ARM toolchain.

    user@user-OptiPlex-7070:~/ncs/v2.2.0/zephyr/samples/basic/blinky$ ln -s /home/user/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc /home/user/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/cgcc
    user@user-OptiPlex-7070:~/ncs/v2.2.0/zephyr/samples/basic/blinky$ ls -la /home/user/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/cgcc
    lrwxrwxrwx 1 user user 90 des.  14 14:02 /home/user/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/cgcc -> /home/user/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
    user@user-OptiPlex-7070:~/ncs/v2.2.0/zephyr/samples/basic/blinky$ export $REAL_CC=/home/user/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
    bash: export: `=/home/user/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc': not a valid identifier
    user@user-OptiPlex-7070:~/ncs/v2.2.0/zephyr/samples/basic/blinky$ export REAL_CC=/home/user/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
    user@user-OptiPlex-7070:~/ncs/v2.2.0/zephyr/samples/basic/blinky$ west build -b nrf52dk_nrf52832 -p -- -DSPARSE=y
    -- west build: making build dir /home/user/ncs/v2.2.0/zephyr/samples/basic/blinky/build pristine
    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base).
    -- Application: /home/user/ncs/v2.2.0/zephyr/samples/basic/blinky
    -- Using NCS Toolchain 2.2.0 for building. (/home/user/ncs/toolchains/v2.2.0/cmake)
    -- Found Python3: /home/user/ncs/toolchains/v2.2.0/usr/local/bin/python3 (found suitable exact version "3.8.2") found components: Interpreter 
    -- Cache files will be written to: /home/user/.cache/zephyr
    -- Zephyr version: 3.2.99 (/home/user/ncs/v2.2.0/zephyr)
    -- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
    -- Board: nrf52dk_nrf52832
    -- Found host-tools: zephyr 0.15.1 (/home/user/ncs/toolchains/v2.2.0/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.15.1 (/home/user/ncs/toolchains/v2.2.0/opt/zephyr-sdk)
    -- Found Dtc: /home/user/ncs/toolchains/v2.2.0/usr/local/bin/dtc (found suitable version "1.4.7", minimum required is "1.4.6") 
    -- Found BOARD.dts: /home/user/ncs/v2.2.0/zephyr/boards/arm/nrf52dk_nrf52832/nrf52dk_nrf52832.dts
    -- Generated zephyr.dts: /home/user/ncs/v2.2.0/zephyr/samples/basic/blinky/build/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: /home/user/ncs/v2.2.0/zephyr/samples/basic/blinky/build/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: /home/user/ncs/v2.2.0/zephyr/samples/basic/blinky/build/zephyr/dts.cmake
    Parsing /home/user/ncs/v2.2.0/zephyr/Kconfig
    Loaded configuration '/home/user/ncs/v2.2.0/zephyr/boards/arm/nrf52dk_nrf52832/nrf52dk_nrf52832_defconfig'
    Merged configuration '/home/user/ncs/v2.2.0/zephyr/samples/basic/blinky/prj.conf'
    Configuration saved to '/home/user/ncs/v2.2.0/zephyr/samples/basic/blinky/build/zephyr/.config'
    Kconfig header saved to '/home/user/ncs/v2.2.0/zephyr/samples/basic/blinky/build/zephyr/include/generated/autoconf.h'
    -- Found sparse: /home/user/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/cgcc
    -- The C compiler identification is GNU 12.1.0
    -- The CXX compiler identification is GNU 12.1.0
    -- The ASM compiler identification is GNU
    -- Found assembler: /home/user/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/cgcc
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /home/user/ncs/v2.2.0/zephyr/samples/basic/blinky/build
    -- west build: building application
    [1/166] Preparing syscall dependency handling
    
    [2/166] Generating include/generated/version.h
    -- Zephyr version: 3.2.99 (/home/user/ncs/v2.2.0/zephyr), build: v3.2.99-ncs1
    [21/166] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/printk.c.obj
    /home/user/ncs/v2.2.0/zephyr/lib/os/printk.c: In function 'vsnprintk':
    /home/user/ncs/v2.2.0/zephyr/lib/os/printk.c:255:19: warning: passing argument 1 of 'cbvprintf' from incompatible pointer type [-Wincompatible-pointer-types]
      255 |         cbvprintf(str_out, &ctx, fmt, ap);
          |                   ^~~~~~~
          |                   |
          |                   int (*)(int,  struct str_context *)
    In file included from ../../../../include/zephyr/logging/log_msg.h:11,
                     from ../../../../include/zephyr/logging/log_core.h:9,
                     from ../../../../include/zephyr/logging/log.h:11,
                     from /home/user/ncs/v2.2.0/zephyr/lib/os/printk.c:21:
    ../../../../include/zephyr/sys/cbprintf.h:715:27: note: expected 'cbprintf_cb' {aka 'int (*)(int,  void *)'} but argument is of type 'int (*)(int,  struct str_context *)'
      715 | int cbvprintf(cbprintf_cb out, void *ctx, const char *format, va_list ap)
          |               ~~~~~~~~~~~~^~~
    [99/166] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdout/sprintf.c.obj
    /home/user/ncs/v2.2.0/zephyr/lib/libc/minimal/source/stdout/sprintf.c: In function 'snprintf':
    /home/user/ncs/v2.2.0/zephyr/lib/libc/minimal/source/stdout/sprintf.c:45:23: warning: passing argument 1 of 'cbvprintf' from incompatible pointer type [-Wincompatible-pointer-types]
       45 |         r = cbvprintf(sprintf_out, (void *) (&p), format, vargs);
          |                       ^~~~~~~~~~~
          |                       |
          |                       int (*)(int,  struct emitter *)
    In file included from /home/user/ncs/v2.2.0/zephyr/lib/libc/minimal/source/stdout/sprintf.c:11:
    ../../../../include/zephyr/sys/cbprintf.h:715:27: note: expected 'cbprintf_cb' {aka 'int (*)(int,  void *)'} but argument is of type 'int (*)(int,  struct emitter *)'
      715 | int cbvprintf(cbprintf_cb out, void *ctx, const char *format, va_list ap)
          |               ~~~~~~~~~~~~^~~
    /home/user/ncs/v2.2.0/zephyr/lib/libc/minimal/source/stdout/sprintf.c: In function 'sprintf':
    /home/user/ncs/v2.2.0/zephyr/lib/libc/minimal/source/stdout/sprintf.c:63:23: warning: passing argument 1 of 'cbvprintf' from incompatible pointer type [-Wincompatible-pointer-types]
       63 |         r = cbvprintf(sprintf_out, (void *) (&p), format, vargs);
          |                       ^~~~~~~~~~~
          |                       |
          |                       int (*)(int,  struct emitter *)
    ../../../../include/zephyr/sys/cbprintf.h:715:27: note: expected 'cbprintf_cb' {aka 'int (*)(int,  void *)'} but argument is of type 'int (*)(int,  struct emitter *)'
      715 | int cbvprintf(cbprintf_cb out, void *ctx, const char *format, va_list ap)
          |               ~~~~~~~~~~~~^~~
    /home/user/ncs/v2.2.0/zephyr/lib/libc/minimal/source/stdout/sprintf.c: In function 'vsnprintf':
    /home/user/ncs/v2.2.0/zephyr/lib/libc/minimal/source/stdout/sprintf.c:84:23: warning: passing argument 1 of 'cbvprintf' from incompatible pointer type [-Wincompatible-pointer-types]
       84 |         r = cbvprintf(sprintf_out, (void *) (&p), format, vargs);
          |                       ^~~~~~~~~~~
          |                       |
          |                       int (*)(int,  struct emitter *)
    ../../../../include/zephyr/sys/cbprintf.h:715:27: note: expected 'cbprintf_cb' {aka 'int (*)(int,  void *)'} but argument is of type 'int (*)(int,  struct emitter *)'
      715 | int cbvprintf(cbprintf_cb out, void *ctx, const char *format, va_list ap)
          |               ~~~~~~~~~~~~^~~
    /home/user/ncs/v2.2.0/zephyr/lib/libc/minimal/source/stdout/sprintf.c: In function 'vsprintf':
    /home/user/ncs/v2.2.0/zephyr/lib/libc/minimal/source/stdout/sprintf.c:99:23: warning: passing argument 1 of 'cbvprintf' from incompatible pointer type [-Wincompatible-pointer-types]
       99 |         r = cbvprintf(sprintf_out, (void *) (&p), format, vargs);
          |                       ^~~~~~~~~~~
          |                       |
          |                       int (*)(int,  struct emitter *)
    ../../../../include/zephyr/sys/cbprintf.h:715:27: note: expected 'cbprintf_cb' {aka 'int (*)(int,  void *)'} but argument is of type 'int (*)(int,  struct emitter *)'
      715 | int cbvprintf(cbprintf_cb out, void *ctx, const char *format, va_list ap)
          |               ~~~~~~~~~~~~^~~
    [101/166] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdout/fprintf.c.obj
    /home/user/ncs/v2.2.0/zephyr/lib/libc/minimal/source/stdout/fprintf.c: In function 'fprintf':
    /home/user/ncs/v2.2.0/zephyr/lib/libc/minimal/source/stdout/fprintf.c:21:23: warning: passing argument 1 of 'cbvprintf' from incompatible pointer type [-Wincompatible-pointer-types]
       21 |         r = cbvprintf(fputc, DESC(stream), format, vargs);
          |                       ^~~~~
          |                       |
          |                       int (*)(int,  FILE *) {aka int (*)(int,  int *)}
    In file included from /home/user/ncs/v2.2.0/zephyr/lib/libc/minimal/source/stdout/fprintf.c:11:
    ../../../../include/zephyr/sys/cbprintf.h:715:27: note: expected 'cbprintf_cb' {aka 'int (*)(int,  void *)'} but argument is of type 'int (*)(int,  FILE *)' {aka 'int (*)(int,  int *)'}
      715 | int cbvprintf(cbprintf_cb out, void *ctx, const char *format, va_list ap)
          |               ~~~~~~~~~~~~^~~
    /home/user/ncs/v2.2.0/zephyr/lib/libc/minimal/source/stdout/fprintf.c: In function 'vfprintf':
    /home/user/ncs/v2.2.0/zephyr/lib/libc/minimal/source/stdout/fprintf.c:32:23: warning: passing argument 1 of 'cbvprintf' from incompatible pointer type [-Wincompatible-pointer-types]
       32 |         r = cbvprintf(fputc, DESC(stream), format, vargs);
          |                       ^~~~~
          |                       |
          |                       int (*)(int,  FILE *) {aka int (*)(int,  int *)}
    ../../../../include/zephyr/sys/cbprintf.h:715:27: note: expected 'cbprintf_cb' {aka 'int (*)(int,  void *)'} but argument is of type 'int (*)(int,  FILE *)' {aka 'int (*)(int,  int *)'}
      715 | int cbvprintf(cbprintf_cb out, void *ctx, const char *format, va_list ap)
          |               ~~~~~~~~~~~~^~~
    /home/user/ncs/v2.2.0/zephyr/lib/libc/minimal/source/stdout/fprintf.c: In function 'printf':
    /home/user/ncs/v2.2.0/zephyr/lib/libc/minimal/source/stdout/fprintf.c:43:23: warning: passing argument 1 of 'cbvprintf' from incompatible pointer type [-Wincompatible-pointer-types]
       43 |         r = cbvprintf(fputc, DESC(stdout), format, vargs);
          |                       ^~~~~
          |                       |
          |                       int (*)(int,  FILE *) {aka int (*)(int,  int *)}
    ../../../../include/zephyr/sys/cbprintf.h:715:27: note: expected 'cbprintf_cb' {aka 'int (*)(int,  void *)'} but argument is of type 'int (*)(int,  FILE *)' {aka 'int (*)(int,  int *)'}
      715 | int cbvprintf(cbprintf_cb out, void *ctx, const char *format, va_list ap)
          |               ~~~~~~~~~~~~^~~
    /home/user/ncs/v2.2.0/zephyr/lib/libc/minimal/source/stdout/fprintf.c: In function 'vprintf':
    /home/user/ncs/v2.2.0/zephyr/lib/libc/minimal/source/stdout/fprintf.c:53:23: warning: passing argument 1 of 'cbvprintf' from incompatible pointer type [-Wincompatible-pointer-types]
       53 |         r = cbvprintf(fputc, DESC(stdout), format, vargs);
          |                       ^~~~~
          |                       |
          |                       int (*)(int,  FILE *) {aka int (*)(int,  int *)}
    ../../../../include/zephyr/sys/cbprintf.h:715:27: note: expected 'cbprintf_cb' {aka 'int (*)(int,  void *)'} but argument is of type 'int (*)(int,  FILE *)' {aka 'int (*)(int,  int *)'}
      715 | int cbvprintf(cbprintf_cb out, void *ctx, const char *format, va_list ap)
          |               ~~~~~~~~~~~~^~~
    [156/166] Linking C executable zephyr/zephyr_pre0.elf
    
    [160/166] Linking C executable zephyr/zephyr_pre1.elf
    
    [166/166] Linking C executable zephyr/zephyr.elf
    Memory region         Used Size  Region Size  %age Used
               FLASH:       19390 B       512 KB      3.70%
                 RAM:        5504 B        64 KB      8.40%
            IDT_LIST:          0 GB         2 KB      0.00%

  •   , did you make the symlink as I suggested?  

      , our SDK toolchain includes the zephyr SDK in addition to other dependencies such as python, git and west. The easiest way to use this toolchain is to open the terminal via the toolchain manager app. This will update your env. variable with the paths defined in /ncs/toolchains/v2.2.0/environment.json

    Edit: I see now that you created the symlink. Can you echo REAL_CC to confirm it's set correctly?

    Edit 2: Please use the 2.2.0 release.

  • root@ca30ef32b4ea:~/ncs/nrf# cat VERSION 
    2.2.0
    root@ca30ef32b4ea:~/ncs/nrf#

    root@ca30ef32b4ea:~/ncs# echo $REAL_CC
    ~/zephyr-sdk-0.15.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
    root@ca30ef32b4ea:~/ncs# 
    

  • Please specify the full path when you set REAL_CC

  • Did not know that env variables were defined there. Awesome, thanks a lot!

  • There is no difference.. There is complete set of commands that I've run on completely clear ubuntu 22.04 image using Podman...

    podman run -dit --name ncs ubuntu
    podman attach ncs
    
    apt-get update
    apt-get install sudo
    adduser ncs
    usermod -aG sudo ncs
    login ncs
    sudo apt install --no-install-recommends git cmake ninja-build gperf ccache dfu-util device-tree-compiler wget python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1
    mkdir ${HOME}/gn && cd ${HOME}/gn
    wget -O gn.zip https://chrome-infra-packages.appspot.com/dl/gn/gn/linux-amd64/+/latest
    sudo apt-get install unzip
    unzip gn.zip
    rm gn.zip
    echo 'export PATH=${HOME}/gn:"$PATH"' >> ${HOME}/.bashrc
    cd ~
    source ${HOME}/.bashrc
    pip3 install --user west
    echo 'export PATH=~/.local/bin:"$PATH"' >> ~/.bashrc
    source ~/.bashrc
    mkdir ncs
    cd ncs/
    west init -m https://github.com/nrfconnect/sdk-nrf --mr v2.2.0
    west update
    west zephyr-export
    pip3 install --user -r zephyr/scripts/requirements.txt
    pip3 install --user -r nrf/scripts/requirements.txt
    pip3 install --user -r bootloader/mcuboot/scripts/requirements.txt
    cd ~
    wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.15.1/zephyr-sdk-0.15.1_linux-x86_64.tar.gz
    wget -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.15.1/sha256.sum | shasum --check --ignore-missing
    tar xvf zephyr-sdk-0.15.1_linux-x86_64.tar.gz
    cd zephyr-sdk-0.15.1
    ./setup.sh
    cd ../ncs/
    source zephyr/zephyr-env.sh
    ln -s /home/ncs/zephyr-sdk-0.15.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc /home/ncs/zephyr-sdk-0.15.1/arm-zephyr-eabi/bin/cgcc
    ls -la /home/ncs/zephyr-sdk-0.15.1/arm-zephyr-eabi/bin/cgcc
    export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
    export REAL_CC="/home/ncs/zephyr-sdk-0.15.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc"
    cd zephyr/samples/basic/blinky 
    west build -p always -b nrf52dk_nrf52832  -- -DSPARSE=y
    
    
    

    ncs@7b954ae51633:~/ncs/zephyr/samples/basic/blinky$ ls -la /home/ncs/zephyr-sdk-0.15.1/arm-zephyr-eabi/bin/cgcc                                
    lrwxrwxrwx 1 ncs ncs 67 Dec 20 13:59 /home/ncs/zephyr-sdk-0.15.1/arm-zephyr-eabi/bin/cgcc -> /home/ncs/zephyr-sdk-0.15.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc                                                                                                                              
    ncs@7b954ae51633:~/ncs/zephyr/samples/basic/blinky$

    ncs@7b954ae51633:~/ncs/zephyr/samples/basic/blinky$ echo $REAL_CC
    /home/ncs/zephyr-sdk-0.15.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
    ncs@7b954ae51633:~/ncs/zephyr/samples/basic/blinky$

    ncs@7b954ae51633:~/ncs/zephyr/samples/basic/blinky$ west build -p always -b nrf52dk_nrf52832  -- -DSPARSE=y
    -- west build: making build dir /home/ncs/ncs/zephyr/samples/basic/blinky/build pristine
    -- west build: generating a build system                                                                                                       
    Loading Zephyr default modules (Zephyr base).                                                                                                  
    -- Application: /home/ncs/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/ncs/.cache/zephyr
    -- Zephyr version: 3.2.99 (/home/ncs/ncs/zephyr)
    -- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
    -- Board: nrf52dk_nrf52832
    -- Found host-tools: zephyr 0.15.1 (/home/ncs/zephyr-sdk-0.15.1)
    -- Found toolchain: zephyr 0.15.1 (/home/ncs/zephyr-sdk-0.15.1)
    -- Found Dtc: /home/ncs/zephyr-sdk-0.15.1/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6") 
    -- Found BOARD.dts: /home/ncs/ncs/zephyr/boards/arm/nrf52dk_nrf52832/nrf52dk_nrf52832.dts
    -- Generated zephyr.dts: /home/ncs/ncs/zephyr/samples/basic/blinky/build/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: /home/ncs/ncs/zephyr/samples/basic/blinky/build/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: /home/ncs/ncs/zephyr/samples/basic/blinky/build/zephyr/dts.cmake
    Parsing /home/ncs/ncs/zephyr/Kconfig
    Loaded configuration '/home/ncs/ncs/zephyr/boards/arm/nrf52dk_nrf52832/nrf52dk_nrf52832_defconfig'
    Merged configuration '/home/ncs/ncs/zephyr/samples/basic/blinky/prj.conf'
    Configuration saved to '/home/ncs/ncs/zephyr/samples/basic/blinky/build/zephyr/.config'
    Kconfig header saved to '/home/ncs/ncs/zephyr/samples/basic/blinky/build/zephyr/include/generated/autoconf.h'
    CMake Error at /home/ncs/ncs/zephyr/cmake/compiler/gcc/target.cmake:10 (find_program):
      Could not find CMAKE_C_COMPILER using the following names: cgcc                                                                              
    Call Stack (most recent call first):                                                                                                           
      /home/ncs/ncs/zephyr/cmake/modules/FindTargetTools.cmake:102 (include)                                                                       
      /home/ncs/ncs/zephyr/cmake/modules/kernel.cmake:25 (find_package)                                                                            
      /home/ncs/ncs/zephyr/cmake/modules/zephyr_default.cmake:117 (include)                                                                        
      /home/ncs/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)                                                              
      /home/ncs/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/ncs/ncs/zephyr/samples/basic/blinky/build -GNinja -DBOARD=nrf52dk_nrf52832 -DSPARSE=y -S/home/ncs/ncs/zephyr/samples/basic/blinky

Reply
  • There is no difference.. There is complete set of commands that I've run on completely clear ubuntu 22.04 image using Podman...

    podman run -dit --name ncs ubuntu
    podman attach ncs
    
    apt-get update
    apt-get install sudo
    adduser ncs
    usermod -aG sudo ncs
    login ncs
    sudo apt install --no-install-recommends git cmake ninja-build gperf ccache dfu-util device-tree-compiler wget python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1
    mkdir ${HOME}/gn && cd ${HOME}/gn
    wget -O gn.zip https://chrome-infra-packages.appspot.com/dl/gn/gn/linux-amd64/+/latest
    sudo apt-get install unzip
    unzip gn.zip
    rm gn.zip
    echo 'export PATH=${HOME}/gn:"$PATH"' >> ${HOME}/.bashrc
    cd ~
    source ${HOME}/.bashrc
    pip3 install --user west
    echo 'export PATH=~/.local/bin:"$PATH"' >> ~/.bashrc
    source ~/.bashrc
    mkdir ncs
    cd ncs/
    west init -m https://github.com/nrfconnect/sdk-nrf --mr v2.2.0
    west update
    west zephyr-export
    pip3 install --user -r zephyr/scripts/requirements.txt
    pip3 install --user -r nrf/scripts/requirements.txt
    pip3 install --user -r bootloader/mcuboot/scripts/requirements.txt
    cd ~
    wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.15.1/zephyr-sdk-0.15.1_linux-x86_64.tar.gz
    wget -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.15.1/sha256.sum | shasum --check --ignore-missing
    tar xvf zephyr-sdk-0.15.1_linux-x86_64.tar.gz
    cd zephyr-sdk-0.15.1
    ./setup.sh
    cd ../ncs/
    source zephyr/zephyr-env.sh
    ln -s /home/ncs/zephyr-sdk-0.15.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc /home/ncs/zephyr-sdk-0.15.1/arm-zephyr-eabi/bin/cgcc
    ls -la /home/ncs/zephyr-sdk-0.15.1/arm-zephyr-eabi/bin/cgcc
    export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
    export REAL_CC="/home/ncs/zephyr-sdk-0.15.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc"
    cd zephyr/samples/basic/blinky 
    west build -p always -b nrf52dk_nrf52832  -- -DSPARSE=y
    
    
    

    ncs@7b954ae51633:~/ncs/zephyr/samples/basic/blinky$ ls -la /home/ncs/zephyr-sdk-0.15.1/arm-zephyr-eabi/bin/cgcc                                
    lrwxrwxrwx 1 ncs ncs 67 Dec 20 13:59 /home/ncs/zephyr-sdk-0.15.1/arm-zephyr-eabi/bin/cgcc -> /home/ncs/zephyr-sdk-0.15.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc                                                                                                                              
    ncs@7b954ae51633:~/ncs/zephyr/samples/basic/blinky$

    ncs@7b954ae51633:~/ncs/zephyr/samples/basic/blinky$ echo $REAL_CC
    /home/ncs/zephyr-sdk-0.15.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
    ncs@7b954ae51633:~/ncs/zephyr/samples/basic/blinky$

    ncs@7b954ae51633:~/ncs/zephyr/samples/basic/blinky$ west build -p always -b nrf52dk_nrf52832  -- -DSPARSE=y
    -- west build: making build dir /home/ncs/ncs/zephyr/samples/basic/blinky/build pristine
    -- west build: generating a build system                                                                                                       
    Loading Zephyr default modules (Zephyr base).                                                                                                  
    -- Application: /home/ncs/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/ncs/.cache/zephyr
    -- Zephyr version: 3.2.99 (/home/ncs/ncs/zephyr)
    -- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
    -- Board: nrf52dk_nrf52832
    -- Found host-tools: zephyr 0.15.1 (/home/ncs/zephyr-sdk-0.15.1)
    -- Found toolchain: zephyr 0.15.1 (/home/ncs/zephyr-sdk-0.15.1)
    -- Found Dtc: /home/ncs/zephyr-sdk-0.15.1/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6") 
    -- Found BOARD.dts: /home/ncs/ncs/zephyr/boards/arm/nrf52dk_nrf52832/nrf52dk_nrf52832.dts
    -- Generated zephyr.dts: /home/ncs/ncs/zephyr/samples/basic/blinky/build/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: /home/ncs/ncs/zephyr/samples/basic/blinky/build/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: /home/ncs/ncs/zephyr/samples/basic/blinky/build/zephyr/dts.cmake
    Parsing /home/ncs/ncs/zephyr/Kconfig
    Loaded configuration '/home/ncs/ncs/zephyr/boards/arm/nrf52dk_nrf52832/nrf52dk_nrf52832_defconfig'
    Merged configuration '/home/ncs/ncs/zephyr/samples/basic/blinky/prj.conf'
    Configuration saved to '/home/ncs/ncs/zephyr/samples/basic/blinky/build/zephyr/.config'
    Kconfig header saved to '/home/ncs/ncs/zephyr/samples/basic/blinky/build/zephyr/include/generated/autoconf.h'
    CMake Error at /home/ncs/ncs/zephyr/cmake/compiler/gcc/target.cmake:10 (find_program):
      Could not find CMAKE_C_COMPILER using the following names: cgcc                                                                              
    Call Stack (most recent call first):                                                                                                           
      /home/ncs/ncs/zephyr/cmake/modules/FindTargetTools.cmake:102 (include)                                                                       
      /home/ncs/ncs/zephyr/cmake/modules/kernel.cmake:25 (find_package)                                                                            
      /home/ncs/ncs/zephyr/cmake/modules/zephyr_default.cmake:117 (include)                                                                        
      /home/ncs/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)                                                              
      /home/ncs/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/ncs/ncs/zephyr/samples/basic/blinky/build -GNinja -DBOARD=nrf52dk_nrf52832 -DSPARSE=y -S/home/ncs/ncs/zephyr/samples/basic/blinky

Children
Related