Re: Cmake and DTC Version issues installing Zephyr

Bolivar, Marti

"Lawrence King via Lists.Zephyrproject.Org"
<> writes:

Today I wanted to ensure that my documentation on how to rebuild my code was complete and correct. I setup a new virtual machine with Ubuntu 18.04 LTS (which is the most recent LTS version available). I then install Zephyr following (mostly) the instructions in the getting started guide, followed by pulling my code from my local git and then attempting to build.

This is where things go bad.

First problem is west wants to build with cmake newer than 1.13.3, but
the 'default' cmake in 18.04 LTS is much older, I was able to work
around this by removing cmake, and installing with pip3.
Yes, Zephyr requires a recent CMake. Since you're on Ubuntu, you might
want to check out the official cmake apt repository from KitWare, which
does support 18.04.

The 'latest' zephyr (actually west and cmake) insists that I need a
device tree compiler with version 1.4.6, unfortunately the latest is
version on Ubunti 18.04 is 1.4.5 (see hence I
can't build. OK, to work around this I went into
zephyr/cmake/host-tools.cmake and changed the MIN_DTC_VERSION to
1.4.5. OK, I am past this...
This isn't a west or a CMake requirement, in my opinion, but is instead
a requirement based on the contents of the zephyr DTS files.

Since you're on Ubuntu, if you're building with the Zephyr SDK (which
you seem to be), you should have all the host tools you need from there.
This includes a recent enough DTC.

I would not recommend manually overriding the CMake version enforcement
checks for the dtc binary.

But things continue to be bad. The next issue I hit is cmake can't find the file zephyr/cmake/toolchain/zephyr/0.10.1/host-tools.cmake and when I look, sure enough the file isn't there. In fact the directory isn't there. There are directories for 0.10.0 and 0.9.5, but I installed zephyr tools 0.10.1 so I am not sure why the directory is not there, and more importantly why is cmake even looking there?.

Here is a 'step-by-step' of the process I followed after bringing up a
new Ubuntu 18.04 box:
This appears to be missing some steps. In particular, it doesn't show
how you got the zephyr tree itself. Given that it's in ~/zephyr instead
of something like ~/zephyrproject/zephyr, I suspect you didn't do a west
init + west update. Is that the case? If so, I'd recommend trying again,
but following the instructions in the getting started guide. Zephyr
without west is possible, but harder to do correctly.

sudo apt-get upgrade
sudo apt-get install -y build-essential module-assistant
sudo apt-get install -y --no-install-recommends git ninja-build gperf \
ccache dfu-util device-tree-compiler wget \
python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \
make gcc gcc-multilib
sudo apt remove cmake

sudo -H pip3 install --upgrade setuptools
sudo -H pip3 install --user cmake
chmod +x
sudo ./
export ZEPHYR_SDK_INSTALL_DIR=/opt/zephyr-sdk
# cmake must be version 1.13.3 or better!
cmake --version

sudo -H pip3 install git+
west update
Out of curiosity, why are you building from the latest west master
instead of running "pip3 install --user west" as recommended in the
getting started documentation?

At this point I checkout my code from git and try to build, but it
fails just as well on the blinky program.
Based on the above (and the below output) it seems like you might have
done "git clone" or
similar. This leaves out all the other modules.

I also don't see any mention here of installing the python packages
in zephyr's scripts/requirements.txt, which is also mentioned in the
getting started guide.

Please try these steps and holler if you continue to have problems:


cd zephyr/samples/blinky
export BPOARD=nrf52840_mdk
west -v build

Here is the output:
lawrence@Bob:~/zephyr/samples/basic/blinky$ west -v build
ZEPHYR_BASE=/home/lawrence/zephyr (origin: configfile)
source directory: /home/lawrence/zephyr/samples/basic/blinky
build directory: /home/lawrence/zephyr/samples/basic/blinky/build (created)
BOARD: nrf52840_mdk (origin: env)
Running CMake: /usr/local/bin/cmake -B/home/lawrence/zephyr/samples/basic/blinky/build -S/home/lawrence/zephyr/samples/basic/blinky -GNinja -DBOARD=nrf52840_mdk
Zephyr version: 1.14.99
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.6.8", minimum required is "3.4")
-- Selected BOARD nrf52840_mdk
CMake Error at /home/lawrence/zephyr/cmake/toolchain/zephyr/host-tools.cmake:46 (include):
include could not find load file:

Call Stack (most recent call first):
/home/lawrence/zephyr/cmake/host-tools.cmake:3 (include)
/home/lawrence/zephyr/cmake/app/boilerplate.cmake:386 (include)
CMakeLists.txt:4 (include)

-- Found west: /usr/local/bin/west (found suitable version "0.6.0", minimum required is "0.5.6")
CMake Error at /home/lawrence/zephyr/cmake/toolchain/zephyr/generic.cmake:7 (include):
include could not find load file:

Call Stack (most recent call first):
/home/lawrence/zephyr/cmake/generic_toolchain.cmake:64 (include)
/home/lawrence/zephyr/cmake/app/boilerplate.cmake:402 (include)
CMakeLists.txt:4 (include)

-- Loading /home/lawrence/zephyr/boards/arm/nrf52840_mdk/nrf52840_mdk.dts as base
-- Overlaying /home/lawrence/zephyr/dts/common/common.dts
CMake Error at /home/lawrence/zephyr/cmake/dts.cmake:126 (message):
command failed with return code: No such file or directory
Call Stack (most recent call first):
/home/lawrence/zephyr/cmake/app/boilerplate.cmake:403 (include)
CMakeLists.txt:4 (include)

-- Configuring incomplete, errors occurred!
ERROR: command exited with status 1: /usr/local/bin/cmake -B/home/lawrence/zephyr/samples/basic/blinky/build -S/home/lawrence/zephyr/samples/basic/blinky -GNinja -DBOARD=nrf52840_mdk
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/west/", line 566, in main
args.handler(args, unknown)
File "/usr/local/lib/python3.6/dist-packages/west/", line 325, in ext_command_handler, unknown, topdir)
File "/usr/local/lib/python3.6/dist-packages/west/commands/", line 112, in run
self.do_run(args, unknown)
File "/home/lawrence/zephyr/scripts/west_commands/", line 161, in do_run
self._run_cmake(board, origin, self.args.cmake_opts)
File "/home/lawrence/zephyr/scripts/west_commands/", line 380, in _run_cmake
run_cmake(final_cmake_args, dry_run=self.args.dry_run)
File "/home/lawrence/zephyr/scripts/west_commands/", line 68, in run_cmake
raise subprocess.CalledProcessError(p.returncode, p.args)
subprocess.CalledProcessError: Command '['/usr/local/bin/cmake', '-B/home/lawrence/zephyr/samples/basic/blinky/build', '-S/home/lawrence/zephyr/samples/basic/blinky', '-GNinja', '-DBOARD=nrf52840_mdk']' returned non-zero exit status 1.

Lawrence King
Principal Developer
Connected Transport Market Unit

[1]<> [2 - linkedin] <> [3 - instagram] <> [4 - youtube] <> [6 - facebook] <> [7] <>

CONFIDENTIAL: This e-mail and any attachments are confidential and intended solely for the use of the individual(s) to whom it is addressed. It can contain proprietary confidential information and be subject to legal privilege and/or subject to a non-disclosure Agreement. Unauthorized use, disclosure or copying is strictly prohibited. If you are not the/an addressee and are in possession of this e-mail, please delete the message and notify us immediately. Please consider the environment before printing this e-mail. Thank you.

Join to automatically receive all group messages.