Commit graph

598 commits

Author SHA1 Message Date
Håkon Øye Amundsen 3b49d01593 cmake: flash: use genexpr to generate runners.yaml
This allows users to modify the contents of the data being
written after the cmake/flash/CMakeLists.txt has been
executed.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2020-04-08 11:01:53 +02:00
Jaron Kelleher bd4f721a59 RISCV compiler: Set mabi and march via Kconfig options
The mabi and march options of the compiler and linker commands
were previously hardcoded and depended only on the 64BIT config
option. This update allows these flags to be set by the config
options currently available, plus an additional option to
specify the compressed ISA.

Signed-off-by: Jaron Kelleher <jkelleher@fb.com>
2020-04-06 21:54:07 -04:00
Carles Cufi 6656214af2 boards: nrf52_pca10040: Rename to nrf52dk_nrf52832
The board name for the nRF52 DK, so far known as nrf52_pca10040, is
renamed to nrf52dk_nrf52832.  Its documentation and all references
to its name in the tree are updated accordingly. Overlay and
configuration files specific to this board are also renamed, to
match the new board name.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-04-06 13:09:07 +02:00
Stephanos Ioannidis 19965f8173 cmake: qemu: Support delayed expansion of QEMU_KERNEL_OPTION
This commit allows the `QEMU_KERNEL_OPTION` variable, which can be
overridden by the `board.cmake`, to contain references to the variables
that are not available at the time of `board.cmake` inclusion, by
expanding its escpaed variable references in `cmake/emu/qemu.cmake`
which is included nearby the end of the root `CMakeLists.txt`.

With this change, the `board.cmake` can escape variable references as
follows and allow them to be expanded later:

set(QEMU_KERNEL_OPTION "-device;loader,file=\$<TARGET_FILE:$\{...}>")

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-04-02 09:22:38 +02:00
Torsten Rasmussen db0b4e15e9 doc: Update documentation to describe use of find_package(Zephyr)
This commit changes the current boilerplate include description and
instead describes the use of find_package(Zephyr)

It also add a section covering additional possibilities when using
find_package(Zephyr).

- Search order
- Zephyr repository application description
- Zephyr workspace application description
- Zephyr freestanding application description
- Environment ZEPHYR_BASE setting
- Multiple Zephyr and preference setting

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-03-27 16:23:46 +01:00
Torsten Rasmussen e819fa46cd scripts: west-commands: Updates needed when removing ZEPHYR_BASE env
This commit includes the following fixes in order to remove environment
setting of ZEPHYR_BASE is west extension commands.

- Build command
  west build --pristine will now use the ZEPHYR_BASE variable found
  in CMakeCache.txt in the build folder.

  This ensures that the pristine command is executed from the same
  Zephyr that was used for compilation.

- Board command
  The west boards command no longer sets Zephyr base before invoking
  cmake -P cmake/boards.cmake

  Instead boards.cmake uses find_package(Zephyr) to ensure consistent
  behavior with Zephyr samples, so that the detection of Zephyr base is
  uniform across CMake commands.

  It also changes BOARD_ROOT_SPACE_SEPARATED to BOARD_ROOT in order to
  be consistent with existing user documentation.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-27 16:23:46 +01:00
Torsten Rasmussen 39cd4c8f52 cmake: propagating zephyr base to west
West utilizes Zephyr base when invoked out-of-tree in order to determine
west topdir.

This commit ensures that zephyr base when invoking west from CMake is
set to current zephyr base.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-03-27 16:23:46 +01:00
Torsten Rasmussen d7862cf776 cmake: using ${ZEPHYR_BASE} instead of $ENV{ZEPHYR_BASE}
With the introduction of ZephyrConfig.cmake all parts of CMake code
should rely on the CMake ZEPHYR_BASE variable instead of the environment
setting.

This ensures that after the first CMake invocation, then all subsequent
invocation in same build folder will use same zephyr base.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-03-27 16:23:46 +01:00
Torsten Rasmussen ad1fecc950 cmake: ninja usage build target
Fixed usage build target.

Previously, `ninja usage` would print:
Build flags:

  ninja VERBOSE=1 [targets] verbose build

This is clearly wrong, as VERBOSE=1 is for make targets.

To support both ninja based builds and make based build systems, the
CMAKE_MAKE_PROGRAM is now exported from the calling CMake / build
instance, and the verbose flag is set depending on whether ninja or
make is used as build program.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-03-27 16:23:46 +01:00
Torsten Rasmussen 3dd96d8927 cmake: Added possibility to disable the printing of version
When ZephyrConfig package is being version checked, then
ZephyrConfigVersion.cmake loads version.cmake.

This causes a print message, such as the following to happen:
-- Zephyr version: 2.2.0

Now, in case a user has multiple Zephyr installations, this could
result in something similar to:
-- Zephyr version: 2.2.0
-- Zephyr version: 2.x.0
-- Zephyr version: 3.x.0
being printed.

This commit add the possibility to disable version printing.

With new Zephyr base find_package, printing of ZEPHYR_BASE is added
after the version, in order to make it easy for users to see which
Zephyr is used.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>

suggested change: print ZEPHYR_BASE
2020-03-27 16:23:46 +01:00
Daniel Leung f72e4fc723 cmake: gcc: no need to force add system include
There is no need to force add system include by adding
${SYSROOT_DIR}/include. Let GCC tell us what include paths
are needed with --print-file-name and feed them via -isystem.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-03-27 09:06:03 -04:00
Andrzej Głąbek 4253eae005 boards: nrf52840_pca10056: Rename board to nrf52840dk_nrf52840
The nRF52840 DK board target, so far known as nrf52840_pca10056,
is renamed to nrf52840dk_nrf52840.
Its documentation and all references to its name in the tree are
updated accordingly. Overlay and configuration files specific to
this board are also renamed, to match the new board name.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-03-27 09:14:08 +01:00
Sebastian Bøe a8e90cbfb3 cmake: Fix shield bug when BOARD_ROOT is a list
Fix bug where SHIELDS would be marked as "not found" in the
NOT_FOUND_SHIELD_LIST when they were present, just not in the first
BOARD root in the BOARD_ROOT list.

Instead of marking shields in the NOT_FOUND_SHIELD_LIST, we (continue)
popping shields from SHIELD and check if there are any shields left in
SHIELD.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2020-03-25 20:23:09 +01:00
Martí Bolívar dc85edd2e9 scripts: dts: write new gen_defines.py
This is joint work with Kumar Gala (see signed-off-by).

This supports a new devicetree macro syntax coming. It's not really
worth mixing up the old and the new generation scripts into one file,
because:

- we aim to remove support for the old macros at some point, so it
  will be cleaner to start fresh with a new script based on the old one
  that only generates the new syntax

- it will avoid regressions to leave the existing code alone while
  we're moving users to the new names

Keep the existing script by moving it to gen_legacy_defines.py and
changing a few comments and strings around. It's responsible for
generating:

- devicetree.conf: only needed by deprecated kconfigfunctions
- devicetree_legacy_unfixed.h: "old" devicetree_unfixed.h macros

Put a new gen_defines.py in its place. It generates:

- zephyr.dts
- devicetree_unfixed.h in the new syntax

Include devicetree_legacy_unfixed.h from devicetree.h so no DT users
are affected by this change.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-24 10:11:20 -05:00
Kumar Gala c7f2c89783 gen_defines.py: rename gen_defines.py to gen_legacy_defines.py
This rename is mostly to easy git managment and review so any changes or
the addition of the new gen_defines.py doesn't look like a diff against
the old code if you look at just that commit.

We keep changes to a minimum to just keep things building with the
renamed gen_legacy_defines.py.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-24 10:11:20 -05:00
Torsten Rasmussen 1bc640b972 cmake: deprecation of board names
This commit introduces boards/deprecated.cmake to allow deprecation
of existing boards, when a board is renamed.

This allows users to still specify the old board name, and let Zephyr
build system to select the new board name.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-03-24 11:45:27 +01:00
Ioannis Glaropoulos f3807f19dc boards: arm: nrf51_pca10028: rename board to nrf51dk_nrf51422
We rename the nRF51 Dev Kit board target (nrf51_pca10028)
to nrf51dk_nrf51422. We update all associated references
in the supportive documentation and all nRF51-related
cofigurations and overlay files in the samples and tests
in the tree.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-03-24 11:45:27 +01:00
Emil Hammarstrom df9adeca44 cmake: Bump MIN_WEST_VERSION to 0.7.1
Updated WEST_DIR requires version >= 0.7.0

Signed-off-by: Emil Hammarstrom <emil.a.hammarstrom@gmail.com>
2020-03-23 17:55:14 +01:00
Emil Hammarstrom 86116f090a cmake: flash: Update WEST_DIR path
West >= 0.7.0 moved main.py into app dir

Signed-off-by: Emil Hammarstrom <emil.a.hammarstrom@gmail.com>
2020-03-23 17:55:14 +01:00
Torsten Rasmussen c09663efd4 cmake: Allow projects to add additional dependencies to flash target
Using zephyr_target_property::FLASH_DEPENDENCIES to fetch additional
dependencies to the flash operation.

The properties are fetched using a generator expression which allows
users of Zephyr to add dependencies both before and after the flash
target has been defined.

Dependencies can be other targets that must be build / custom commands
which must be executed before the flash operation. Or it can be targets
which must be built.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Signed-off-by: Haakon Oeye Amundsen <haakon.amundsen@nordicsemi.no>
2020-03-20 10:52:32 +01:00
Andrew Boie c1c54b13a6 build: prevent subsystems.json from being gen
Actual files make terrible dependency targets in CMake.
Wrap the generation of subsystems.json into a custom
target to get around this. Fixes a problem where
parse_syscalls.py was being called multiple times.

Fixes: #23504

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-03-17 18:07:54 +02:00
Corey Wharton ccd15df510 scripts: Dynamically add driver subsystems to subsystems list
This change extends the parse_syscalls.py script to scan for a
__subsystem sentinal added to driver api declarations. It thens
generates a list that is passed into gen_kobject_list.py to extend
the subsystems list. This allows subsystems to be declared in the
code instead of a separate python list and provides a mechanism for
defining out-of-tree subsystems.

Signed-off-by: Corey Wharton <coreyw7@fb.com>
2020-03-11 17:13:39 +02:00
Stephanos Ioannidis 0bd86f3604 arch: arm: aarch32: Allow selecting compiler instruction set
This commit introduces the `COMPILER_ISA_THUMB2` symbol to allow
choosing either the ARM or Thumb instruction set for C code
compilation.

In addition, this commit introduces the `ASSEMBLER_ISA_THUMB2` helper
symbol to specify the default target instruction set for the assembler.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-03-10 17:51:32 +01:00
Stephanos Ioannidis e89881f532 cmake: compiler: arm: Whitespace-align flags
This commit whitespace-aligns the toolchain flags.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-03-10 17:51:32 +01:00
Martí Bolívar c5f8e9a84b cmake: toolchain: print what we find
Print the name of the discovered toolchain as well as the variable
used to initialize it.

This is nice to know when doing remote support, since users will
sometimes misconfigure their toolchain and not know what that means.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-10 14:53:28 +02:00
Martí Bolívar 34a59168d5 build: clean up west build
The header printed at the beginning of every west build is kind of
annoying. Let's remove it and just print the application source
directory at cmake time instead. The build directory and board are
already printed there, anyway, and that's all IDE users will see.

Let's clean up the BOARD to make it say "board" instead. That matches
the west build --board option name a bit more closely and is still
legible.

Likewise, let's not print any west build messages if we're just
incrementally recompiling. That's noisy.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-10 14:53:28 +02:00
Jukka Rissanen c03336e442 cmake: Allow change of the QEMU Ethernet interface name
Instead of hardcoding the "zeth" network interface name, use the
name defined in Kconfig so that user can change it if needed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-03-10 14:38:28 +02:00
Martí Bolívar e4479e2fec cmake: flash: three runners.yaml fixes
There are two problems with the way runners.yaml is being created:

1. The dictionary which contains the arguments for each runner is
   using the runner's name converted to a C identifier instead of the
   runner's name itself. That causes west flash to fail when the two
   are different, e.g. for 'misc-flasher' (runner name), which is
   different than 'misc_flasher' (runner name as C identifier)

2. We need to make sure that the dictionary key maps to an empty list
   if there are no arguments, which normally doesn't happen since the
   runner usually at least takes the path of the file to flash or debug.
   It does happen in the case of misc-flasher, though, since the whole
   point of that runner is that it's an escape hatch for people with
   out of tree scripts that nevertheless want 'west flash' integration
   for things like sanitycheck device testing.

3. A copy/paste error is setting the debug runner to the flash runner.

Fix them all.

Fixes: #23004
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-24 14:00:29 +02:00
Martí Bolívar 5ba47f0728 cmake/flash: fix obsolete help text for missing west
This is only valid advice for west 0.5.x, which is obsolete.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-20 09:06:09 +02:00
Martí Bolívar b85954787e cmake/flash: persist python runners state in YAML
The YAML contents mirror the values in the ZEPHYR_RUNNER_CONFIG
variables, but they are phrased in terms of command line arguments.

This makes it possible for Python to intermix them with
runner-specific arguments, which is a step towards being able to set
arguments like --bin-file via board_set_runner_args(). The next step
is to handle them in Python too.

Move the RUNNERS_VERBOSE setting closer to its use while at it, to
preserve readability.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-20 09:06:09 +02:00
Anas Nashif ef486b2c50 cmake: report extra version (rcX)
Right now when building a release candidate in master cmake reports the
version wrongly as the final version, for example:

-- Zephyr version: 2.2.0

This is misleading and confusing. Cmake does not like the rcX suffix and
internally we indeed use 2.2.0 as the version.

This patch just changes the output of the status message and adds the
extra version field:

-- Zephyr version: 2.2.0-rc1

and continues to use the cmake compatible version internally.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-02-17 14:34:39 -05:00
Sebastian Bøe f58e4e0e67 cmake: Fix zephyr-sdk's with a single toolchain
It used to be that zephyr-sdk's were always contained all toolchains,
but as of recently it is also possible to download partial toolchains.

This patch fixes an issue where it was assumed that the zephyr sdk
contained an x86 toolchain. Now we glob for all known toolchains.

Note that the toolchain discovered by generic.cmake can be any generic
toolchain and does not need to be the same that is discovered by
target.cmake.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2020-02-11 17:48:56 +02:00
Torsten Rasmussen 9dbc5eeb3b cmake: Invoke west topdir only with version >= 0.7.1
West version 0.7.0 introduced `west topdir` command.
Unfortunately version 0.7.0 would print the path in windows path style
when executed in Windows.

This commit ensure that `west topdir` is only used if west >= 0.7.1.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-02-10 22:52:34 +01:00
Sebastian Bøe f17428a009 cmake: Have gperf be opt-out instead of mandatory
gperf is only used when CONFIG_USERSPACE is enabled. Users that use
arch's that don't support CONFIG_USERSPACE, or happen to not never
enable CONFIG_USERSPACE should not be artificially required to install
gperf.

This change makes gperf optional by moving it's presence-check to it's
usage.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2020-02-08 09:13:45 -05:00
Andrei Gansari 77b125a8b3 cmake: pass extra dtc flags to python scripts
Pass arguments as command line from cmake to python. Extra DTC flags are
used later on to check errors in python.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
2020-02-05 13:04:44 -06:00
Andrei Gansari 37af9cb065 cmake: allow boards to have extra cmake parametes
This commit allows boards to have custom cmake parameters that are
loaded before device tree is processed.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
2020-02-05 13:04:44 -06:00
Kumar Gala 5267a5e809 toolchain: Bump min SDK version to 0.11.1
For various reasons bump the min SDK required to 0.11.1.  We need 0.11.x
for xtensa and ARM64 support.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-03 14:57:10 -06:00
Carlo Caione 54acb7baf4 arch: arm64: Support zephyr toolchain
ARM64 is a valid target for the zephyr toolchain. Add support for it.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2020-02-01 08:08:43 -05:00
Carlo Caione 87d8a035dd arch: arm64: Support aarch64-gcc compiler
To be able to successfully compile the kernel for the ARM64 architecture
we have to tweak the compiler-related files to be able to use the
AArch64 GCC compiler.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2020-02-01 08:08:43 -05:00
Kumar Gala ed938bf7e7 toolchain: Fix selection of HAS_NEWLIB_LIBC_NANO for zephyr SDK
HAS_NEWLIB_LIBC_NANO only should be set on arch that have nano.spec
which is ARM, ARC, and RISCV.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-01-30 14:23:31 -06:00
Ulf Magnusson edfe5a653e dts: gen_defines.py: Save final devicetree to zephyr/zephyr.dts
Add a '--dts-out <file>' flag to gen_defines.py that saves the final
devicetree to <file>, in DTS format, using the new EDT.dts_source
attribute.

Handy to have available as a debugging aid. Unused otherwise.

Also write a dummy <BOARD>.dts_compiled file that tells people to look
at zephyr.dts, for people that might be used to that file. It was
removed in commit 8d8b06978c ("dts: Remove generation of
<BOARD>.dts_compiled").

Fixes: #22272

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-30 04:27:39 -06:00
Kumar Gala 6317c82f06 toolchain: Have Kconfig NEWLIB_LIBC_NANO depend on toolchain support
Introduce HAS_NEWLIB_LIBC_NANO Kconfig option that the toolchain
specific Kconfig (gnuarmemb & zephyr 0.11) can select to convey that the
feature is supported.

This removes the need to if protect the NEWLIB_LIBC_NANO Kconfig with:

    if "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "gnuarmemb"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-01-29 12:22:31 -06:00
Kumar Gala 2630fbaa75 cmake: Introduce optional Kconfig for toolchains
Allow a given toolchain to specify Kconfig options that might be
relevant to a feature available in that toolchain.

For example, the ARM embedded GNU toolchain supports two variants of
newlib and you select the smaller one via a spec file.  We can use a
Kconfig option like HAS_NEWLIB_LIBC_NANO to convey that this feature is
supported by that toolchain.

We look for the toolchain Kconfig in ${TOOLCHAIN_KCONFIG_DIR}/Kconfig,
and default TOOLCHAIN_KCONFIG_DIR to:

${TOOLCHAIN_ROOT}/cmake/toolchain/${ZEPHYR_TOOLCHAIN_VARIANT})

toolchain specific cmake files can override the default if needed.

Additionally tweaked the zephyr/generic.cmake to use
${CMAKE_CURRENT_LIST_DIR} to reduce some duplication.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-01-29 12:22:31 -06:00
Sebastian Bøe 23df708aa3 dtc: Support opting-out of installing dtc
dtc is only used for static analysis (producing warnings) of the
DeviceTree sources. This means that valid Zephyr firmware can sanely
be built without it.

For some users, for instance Windows users that are not permitted to
use Chocolatey, installing dtc is problematic and installing it is not
worth the DT warnings that it provides.

To make using Zephyr easier for these users we make using DTC
recommended and opt-out, instead of mandatory.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2020-01-28 12:47:54 -06:00
Sebastian Bøe d3a8fd40b9 cmake: Add option for exporting build metadata to Make
Add an opt-in feature that will generate a Makefile with build
variables like CC, and KBUILD_CFLAGS for consumption by third-party
Make-based build systems.

This emulates the 'outputexports' target that KBuild supported and is
supported for the same reasons that KBuild supported it. Easier
integration with third-party build systems.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2020-01-23 15:09:12 -05:00
Øyvind Rønningstad 05f0d85b6a extensions.cmake: Replace TEXT_START with ROM_START
In zephyr_linker_sources().
This is done since the point of the location is to place things at given
offsets. This can only be done consistenly if the linker code is placed
into the _first_ section.

All uses of TEXT_START are replaced with ROM_START.

ROM_START is only supported in some arches, as some arches have several
custom sections before text. These don't currently have ROM_START or
TEXT_START available, but that could be added with a bit of refactoring
in their linker script.

No SORT_KEYs are changed.

This also fixes an error introduced when TEXT_START was added, where
TEXT_SECTION_OFFSET was applied to riscv's common linker.ld instead of
to openisa_rv32m1's specific linker.ld.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2020-01-23 03:22:59 -08:00
Ulf Magnusson 45050dda48 kconfig/cmake: Improve reconfiguration behavior
There are some issues with the behavior when rerunning CMake in an
already initialized build directory:

 1. The check for assignments to promptless symbols in configuration
    fragments isn't run when reconfiguring, because it only runs if
    zephyr/.config doesn't exist

 2. As outlined in
    https://github.com/zephyrproject-rtos/zephyr/issues/9573, you can
    get into situations where zephyr/.config is invalid (e.g. due to
    being outdated), but menuconfig/guiconfig can't be run to fix it

 3. If kconfig.py fails while merging fragments during reconfiguration,
    it will ignore the fragments during the next reconfiguration and use
    the existing zephyr/.config instead, because the fragment checksum
    is calculated and saved before running kconfig.py

(Footnote: The input configuration file(s) to kconfig.py can be either a
list of configuration fragments, when merging fragments, or just
zephyr/.config, if the merged configuration is up-to-date. The output
configuration file is always zephyr/.config.)

To fix the first two issues, explicitly tell kconfig.py when it's
dealing with handwritten configuration input (fragments), via a new
--handwritten-input-configs flag. This is more robust than checking
whether zephyr/.config exists, which was the old logic.

When dealing with handwritten input, there should be no assignments to
promptless symbols. Assignments to promptless symbols is expected in
zephyr/.config however, because it doubles as configuration output.

When running menuconfig/guiconfig, the input configuration is
zephyr/.config rather than configuration fragments, so this change also
makes sure that menuconfig can always be run as long as zephyr/.config
exists and is up-to-date.

To fix the last issue, only write the checksum for the configuration
fragments if kconfig.py succeeds (which means it wrote a
zephyr/.config).

Also improve naming a bit, add help texts for the command-line
parameters to kconfig.py, and simplify write_kconfig_filenames() by
moving logic into it.

Partial fix for
https://github.com/zephyrproject-rtos/zephyr/issues/9573, without the
part in #issuecomment-469701831. Can still run into issues when e.g.
when CMake files can't make sense of settings.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-22 18:28:07 +01:00
Håkon Øye Amundsen 995e3676f3 cmake: allow appending dependencies to report targets
To facilitate extending the generated reports without having to
patch this file, leverage generator-expression so that
dependencies can be added to the 'zephyr_property_target' target.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2020-01-20 18:35:01 -05:00
Ulf Magnusson 4e85006ba4 dts: Rename generated_dts_board*.{h,conf} to devicetree*.{h,conf}
generated_dts_board.h is pretty redundant and confusing as a name. Call
it devicetree.h instead.

dts.h would be another option, but DTS stands for "devicetree source"
and is the source code format, so it's a bit confusing too.

The replacement was done by grepping for 'generated_dts_board' and
'GENERATED_DTS_BOARD'.

Two build diagram and input-output SVG files were updated as well, along
with misc. documentation.

hal_ti, mcuboot, and ci-tools updates are included too, in the west.yml
update.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-17 17:57:59 +01:00
Timor Gruber 0039fb86e7 doc: cmake: fixed 'strip_prefix' inconsistency
The `zephyr_get_xxx` API for option fetching
enables prefix stripping.  For some reason
the main API docs named it 'SKIP_PREFIX' instead.

Signed-off-by: Timor Gruber <timor.gruber@gmail.com>
2020-01-16 11:29:46 +01:00
Anas Nashif 009037185a cmake: print version to stdout, not stderr
The version message from cmake is not an error and should not go to
stderr.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-15 15:19:22 -05:00
Ulf Magnusson 8d8b06978c dts: Remove generation of <BOARD>.dts_compiled
Unused after the old devicescript were removed in commit c8c35f76ab
("scripts: dts: Remove deprecated extract_dts_includes.py script"). The
old scripts relied on parsing the output of 'dts -Odts', which replaces
e.g. phandle references. The new scripts parse the DTS files directly.

Keep running the dtc compiler just to catch any warnings/errors from it.

The edit to doc/guides/build/build-config-phase.svg is to remove the box
with '*.dts_compiled' in it (and the arrows to/from it). https://draw.io
can be used to edit it.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-14 16:53:12 -05:00
Stephanos Ioannidis 04e874485b x86: intel64: Split 'locore' and 'main' kernel images for QEMU
This commit splits the 'locore' and 'main' memory regions into
separate executable images and specifies the 'locore' as the boot
kernel, in order to prevent the QEMU direct multiboot kernel loader
from overwriting the BIOS and option ROM areas located in between
the two memory regions.

The Zephyr x86-64 kernel image consists of two discontiguous load
memory regions: 'locore' at 0x8000 and 'main' at 0x100000, but the
QEMU treats these as single contiguous memory region starting at
0x8000 and ending at (0x100000 + MAIN_IMAGE_SIZE - 1).

This results in the direct multiboot kernel loader overwriting the
BIOS and option ROM areas as part of the kernel loading process, and
causes any writable system regions to be corrupted (e.g. KVMVAPIC ROM).

By splitting the two discontiguous memory regions into separate images
and specifying only the boot image (i.e. 'locore') as the '-kernel',
it is possible to work around the QEMU direct kernel loading design
limitation.

This workaround is required to support the QEMU v4.2.0 and above.

For more details, refer to the issue zephyrproject-rtos/sdk-ng#168.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-01-08 07:49:24 -06:00
Sebastian Bøe d385d86f74 cmake: toolchain: Fix 'host' toolchain variant
Fix an issue with 'ZEPHYR_TOOLCHAIN_VARIANT=host' where CMAKE_C_FLAGS
was incorrectly assumed to be set.

This fixes #21614

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2020-01-07 13:25:47 -05:00
Daniel Leung e73231f7f0 toolchain: xcc: use Clang if exists
The XCC toolchain may come with Clang front-end depending on
how it's built. Currently, the only SoC/board using XCC is
the intel_s1000_crb and its XCC toolchain comes with Clang
3.9.0 which has a lot better support for C99 and C++11 than
the portion based on GCC 4.2 (which does not even support
C++11). So this change attempts to use the Clang portion
instead of GCC if the Clang executable exists.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-01-07 17:09:38 +01:00
Daniel Leung e6cf37a857 cmake: ld: use linker prefix for undefined symbols
The undefined symbol option "-u" applies to linker so prefix
it with the linker prefix (usually "-Wl"). This fixes warnings
from LLVM/Clang about unknown arguments.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-01-07 17:09:38 +01:00
Stephanos Ioannidis 244148a883 cmake: qemu: Use chardev for console
The current QEMU console configuration directly connects the console
serial port to the backend using '-serial' option.

This is less than ideal because only single console instance can be
connected to a backend and aggregation of multiple console outputs is
not possible (e.g. multiple console serial ports and semihosting
console to single console backend).

In order to solve this problem, single multiplexed chardev console
backend is declared and all consoles are connected to it.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-01-04 09:18:51 -05:00
Erwan Gouriou 6202d9c014 cmake: make shield list available to Kconfig
For application portability, it is required that feature activation
is made conditional in shield configuration. This way features remain
controlled on application side.
To enable this we need that list of user activated shield is made
available to Kconfig.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-01-02 17:02:41 -05:00
Daniel Leung 0638c7021d cmake: xtools: use SoC name in path to xtensa toolchain
Xtensa requires building a new toolchain for a specific SoC.
By default xtools built Xtensa toolchains all have prefix of
xtensa-zephyr-elf. In order to distinguish different toolchains,
they are now placed in their own directories under their SoC
name. This allows us to have multiple Xtensa toolchains
targeting multiple SoCs.

The additional level in path name is introduced in SDK v0.11
and sdk-ng master.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-12-21 10:27:32 -05:00
Øyvind Rønningstad 1a2ff6deda cmake: Add sorting of linker snippets by key
Allows snippets to be placed in a predictable order into the linker
script. This is useful for data that must be placed at a particular
location.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2019-12-20 08:54:53 -05:00
Øyvind Rønningstad d1c2a4edbf cmake: Add the TEXT_START location to zephyr_linker_sources()
Places linker code at or near the beginning of the text section.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2019-12-20 08:54:53 -05:00
Daniel Leung b61f448a3f xtensa: add support to build HAL as part of build process
This adds the necessary bits to build the Xtensa HAL as
a module, and removes the bits to use the HAL built with
the Zephyr SDK.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-12-18 20:24:18 -05:00
Peter A. Bigot 60ca2333dc cmake: toolchain: generalize exclusion of CXX options
-Wold-style-definition is not a supported option for C++ builds.  To
prevent it being passed:
* the list of compiler flags to be excluded from C++ builds is moved
  to be toolchain-specific;
* -Wold-style-definition is added to that list for gcc and clang;
* -Wold-style-definition is moved from zephyr_compiler_options to
  zephyr_cc_option so the option checking code is executed for it.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-12-18 21:45:00 +01:00
Robert Lubos cb3670c1b5 cmake: dts fixups
Trivial dts.cmake cleanups.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-12-18 21:42:43 +01:00
Martí Bolívar 7750254526 cmake: require python 3.6 or later
Zephyr currently requires Python 3.4 or later. The core Python team
declared version 3.4 hit End of Life (EOL) in March, so there's no
reason to continue to support it if that's causing a burden, which it
is.

This commit allows Zephyr's Python scripts to depend on features
present in version 3.6 or later.

This does skip support for a currently active version of Python:

- Python 3.5 is actively supported by the core Python devs until 09/2020
- Zephyr's 2.2 release, the first which could include this change, is
  tentatively scheduled for 02/2020.

However, almost all supported platforms are either unaffected, or
their users can upgrade easily:

- Windows users who need to can upgrade Python with:
  choco upgrade python

- macOS users who need to can upgrade Python with:
  brew upgrade python3

- Red Hat Enterprise Linux users who need to upgrade can use
  Software Collections (SCLs), e.g. as described here:
  https://developers.redhat.com/blog/2018/08/13/install-python3-rhel/

- CentOS Linux users also have access to SCLs, as described here:
  https://wiki.centos.org/AdditionalResources/Repositories/SCL

- Ubuntu's current long-term support (LTS) release (Bionic Beaver,
  version 18.04) ships with Python 3.6. It and all later versions of
  Ubuntu won't be affected by this change.

- Debian's current stable release (Buster, version 10) ships Python 3.7
  and likewise won't be affected.

The impact of this change is therefore biggest for older versions of
Linux. In particular, these are impacted:

- Older Ubuntu LTS releases.

  - Ubuntu 16.04 ships Python 3.5; it is still supported by Canonical.
  - Ubuntu 14.04 ships Python 3.4, which is EOL. This Ubuntu version
    is also no longer getting standard support from Canonical. Paying
    customers are receiving security updates only.

  https://wiki.ubuntu.com/Releases

- Older Debian versions.

  - Debian 9 (stretch) ships Python 3.5 and is still a supported
    Debian version.
  - Debian 8 (jessie) ships Python 3.4, which is EOL. This Debian
    version is no longer receiving mainline maintenance by the Debian
    project. LTS updates are provided by interested community
    volunteers only.

  https://wiki.debian.org/LTS

Affected Linux users will no longer have a system Python 3 which works
"out of the box" with Zephyr after this change. Some ideas for these
users are:

- Use Zephyr v2.1 or v1.14 LTS, which are maintained and still
  support Python 3.4
- Compile Python 3.6 or later from source and use it within a venv:
  https://docs.python.org/3/library/venv.html
- Use something like https://github.com/pyenv/pyenv

Python 3.6 has compelling new features which make writing Zephyr's
scripts easier, and which it would be good to be able to rely upon.
This motivates moving from Python 3.4 to 3.6 instead of 3.5.

My personal killer 3.6 features motivating skipping 3.5 (YMMV):

- Windows console and file system encodings are UTF-8 (PEPs 528 and
  529): Zephyr's scripts, and many utilities related to git, broadly
  assume strings are UTF-8, so this is very helpful
- os.PathLike and the file system path protocol (PEP 519) allow
  intermixing "smart" paths in pathlib with existing os.path based
  code
- f-strings (PEP 0498) are a wonderful and efficient string
  interpolation mechanism
- CPython dictionaries are insertion ordered as an implementation
  detail starting with 3.6, which in practice helps with
  reproducibility (and *all* Python implementations have insertion
  ordered dicts starting with 3.7)

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2019-12-18 10:15:45 +01:00
Sebastian Bøe 5f75c0f4a7 cmake: Fix cache directory detection
To detect where the cache directory has been located we have been
checking if $HOME is writable, and if it is assuming that $HOME/.cache
must be writable as well.

This is broken in environments where $HOME is owned by users and
$HOME/.cache is owned by admin. To fix this we check $HOME/.cache for
write-ability instead.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-12-15 10:33:03 -05:00
Daniel Leung 37f94d66ab cmake: extra_flags: fix EXTRA_CPPFLAGS being applied as macros
The EXTRA_CPPFLAGS is applied via zephyr_compile_definitions()
instead of zephyr_compile_options(), which makes all specified
options as macros. So fix it.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-12-13 13:23:40 -05:00
Sebastian Bøe 01d8dc0289 cmake: toolchain: Don't add -Werror=implicit-int to CXX builds
We do compiler flag compatibility tests to be able to support many
different toolchains and flags in a scalable way. But the test is not
perfect and in these situations we we will need to hardcode whether a
flag is compatible or not.

To support this we have zephyr_compiler_check first check if the flag
is covered by a hardcoded test before testing it.

Currently the only hardcoded compatibilty is that -Werror=implicit-int
is not supported for CXX.

This fixes #21229

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-12-12 07:58:45 -06:00
Sebastian Bøe 3a4d547c5a cmake: Change the DTS preprocessing work directory
Change the DTS preprocessor working directory from the binary
directory to the application directory.

This is done so that the user can specify
-DDTC_OVERLAY_FILE=overlay.dts with a relative path from the
application directory as is possible for CONF_FILE, and as is
reasonably expected to be possible by users.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-12-09 16:34:55 -05:00
Kumar Gala c8c35f76ab scripts: dts: Remove deprecated extract_dts_includes.py script
We now use EDTS and gen_defines.py to generate DTS defines.  We
deprecated the old script and defines several releases ago, so lets now
remove them.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-12-09 16:31:42 -05:00
Lauren Murphy e0b2fb75db hardening: Introducing hardenconfig tool
Basic tool to help checking Kconfig options against a list of
hardening preferences.

This tool is available as a kconfig target, so to run it:

make/ninja hardenconfig

[Flavio Ceolin: Simplify logic and fix python lint issues]

Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2019-12-09 12:54:29 -05:00
Stephanos Ioannidis cff94bf7a0 cmake: Add GCC -Og flag fallback to -O0.
The -Og (optimise for debugging) flag is only available for GCC 4.8.0
and above, and specifying it for a GCC version lower than 4.8.0 will
result in a compilation error.

This commit adds a check for compiler -Og optimisation flag support and
a fallback to -O0 (disable optimisation) when -Og flag is unsupported.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2019-12-09 16:17:12 +01:00
Daniel Leung 68729ad3f8 dts: tell compiler the name of dependency file for output
When generating the dependency file for DTS (${BOARD}.dts.pre.d),
some toolchains would use the source file for the file name stem.
So, the resulting dependency file is empty_file.d instead of one
with the board name. Fix this by passing -MF to explicitly tell
the compiler the name of the dependency file.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-11-25 07:43:52 -05:00
Stephanos Ioannidis 3cc5bda2fa cmake: Support renode 1.8.2.
Renode 1.8 introduced a behaviour change in which it automatically
launches the telnet monitor on the TCP port 1234 by default.

In order to prevent sanitycheck failures from multiple renode instances
attempting to listen on the TCP port 1234 simultaneously, this commit
disables renode telnet monitor by specifying '--port -2' (a negative
number lower than -1 is required to disable telnet monitor because of
the way renode command line parser is implemented).

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2019-11-15 17:37:17 -05:00
Martí Bolívar 258b71f8fe cmake: cache DTS bindings directory
We need this information in the cache now that we're not allowed to
parse generated_dts_board.conf from Python code after build time.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2019-11-15 07:53:25 -06:00
Daniel Leung 5c711bd4ba sdk: add support for Zephyr SDK 0.11
This adds support for Zephyr SDK 0.11.* is based on the 0.10 support
with the following changes:

Handle how xtensa toolchains for given targets are organized in SDK
0.11.x.  They have their own directories per specific xtensa SoC.

The x86_64 toolchain in the SDK has been updated to build for 32-bit
targets (as it has 32-bit soft float libraries).  Use this toolchain for
all x86 builds.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-11-13 10:32:02 -06:00
Stephanos Ioannidis d927018282 cmake: Use zephyr_link_libraries in toolchain_ld_cpp.
The toolchain_ld_cpp macro currently uses zephyr_ld_options function
to link libstdc++, instead of zephyr_link_libraries which is actually
intended for this purpose.

This commit replaces the usage of zephyr_ld_options with
zephyr_link_libraries as the former may erroneously filter out
-lstdc++ and the latter ensures that this linker flag is
unconditionally forwarded to the linker.

For more details, refer to the issue #20406.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2019-11-07 16:37:50 +01:00
Kumar Gala 7573e048ca cmake: dts: Drop loading symbols from generated_dts_board.conf
Now that DT symbols from generated_dts_board.conf are deprecated remove
loading symbols from it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-11-07 08:43:16 -06:00
Stephanos Ioannidis 2d7460482d headers: Refactor kernel and arch headers.
This commit refactors kernel and arch headers to establish a boundary
between private and public interface headers.

The refactoring strategy used in this commit is detailed in the issue

This commit introduces the following major changes:

1. Establish a clear boundary between private and public headers by
  removing "kernel/include" and "arch/*/include" from the global
  include paths. Ideally, only kernel/ and arch/*/ source files should
  reference the headers in these directories. If these headers must be
  used by a component, these include paths shall be manually added to
  the CMakeLists.txt file of the component. This is intended to
  discourage applications from including private kernel and arch
  headers either knowingly and unknowingly.

  - kernel/include/ (PRIVATE)
    This directory contains the private headers that provide private
   kernel definitions which should not be visible outside the kernel
   and arch source code. All public kernel definitions must be added
   to an appropriate header located under include/.

  - arch/*/include/ (PRIVATE)
    This directory contains the private headers that provide private
   architecture-specific definitions which should not be visible
   outside the arch and kernel source code. All public architecture-
   specific definitions must be added to an appropriate header located
   under include/arch/*/.

  - include/ AND include/sys/ (PUBLIC)
    This directory contains the public headers that provide public
   kernel definitions which can be referenced by both kernel and
   application code.

  - include/arch/*/ (PUBLIC)
    This directory contains the public headers that provide public
   architecture-specific definitions which can be referenced by both
   kernel and application code.

2. Split arch_interface.h into "kernel-to-arch interface" and "public
  arch interface" divisions.

  - kernel/include/kernel_arch_interface.h
    * provides private "kernel-to-arch interface" definition.
    * includes arch/*/include/kernel_arch_func.h to ensure that the
     interface function implementations are always available.
    * includes sys/arch_interface.h so that public arch interface
     definitions are automatically included when including this file.

  - arch/*/include/kernel_arch_func.h
    * provides architecture-specific "kernel-to-arch interface"
     implementation.
    * only the functions that will be used in kernel and arch source
     files are defined here.

  - include/sys/arch_interface.h
    * provides "public arch interface" definition.
    * includes include/arch/arch_inlines.h to ensure that the
     architecture-specific public inline interface function
     implementations are always available.

  - include/arch/arch_inlines.h
    * includes architecture-specific arch_inlines.h in
     include/arch/*/arch_inline.h.

  - include/arch/*/arch_inline.h
    * provides architecture-specific "public arch interface" inline
     function implementation.
    * supersedes include/sys/arch_inline.h.

3. Refactor kernel and the existing architecture implementations.

  - Remove circular dependency of kernel and arch headers. The
   following general rules should be observed:

    * Never include any private headers from public headers
    * Never include kernel_internal.h in kernel_arch_data.h
    * Always include kernel_arch_data.h from kernel_arch_func.h
    * Never include kernel.h from kernel_struct.h either directly or
     indirectly. Only add the kernel structures that must be referenced
     from public arch headers in this file.

  - Relocate syscall_handler.h to include/ so it can be used in the
   public code. This is necessary because many user-mode public codes
   reference the functions defined in this header.

  - Relocate kernel_arch_thread.h to include/arch/*/thread.h. This is
   necessary to provide architecture-specific thread definition for
   'struct k_thread' in kernel.h.

  - Remove any private header dependencies from public headers using
   the following methods:

    * If dependency is not required, simply omit
    * If dependency is required,
      - Relocate a portion of the required dependencies from the
       private header to an appropriate public header OR
      - Relocate the required private header to make it public.

This commit supersedes #20047, addresses #19666, and fixes #3056.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2019-11-06 16:07:32 -08:00
Marc Herbert eddbf3c986 cmake: -fmacro-prefix-map=${WEST_TOPDIR}=WEST_TOPDIR
Commit 28a5657f1f and f67dcdbdf8 stopped ZEPHYR_BASE and
CMAKE_SOURCE_DIR from leaking into __FILE__ and other macros.
WEST_TOPDIR was still missing. Add it now that the new 'west topdir'
command has been implemented in
https://github.com/zephyrproject-rtos/west/pull/311

If the west version is too old then do nothing; same as before.

Any ASSERT in a zephyr module outside ZEPHYR_BASE is enough to test
this. One example:

$ZEPHYR_BASE/sanitycheck -T $ZEPHYR_BASE/tests/posix/fs/ -p qemu_x86 -v

readelf --string-dump=.rodata.disk_status.str1.1 {} \
  $(find sanity-out -name zfs_diskio.c.obj | head -n 1)

String dump of section '.rodata.disk_status.str1.1':

  [     0]  WEST_TOPDIR/modules/fs/fatfs/zfs_diskio.c
  [    2a]  pdrv < ((long) (((int) sizeof(char[1 - 2 * !(!__built....
  [    de]  ASSERTION FAIL [%s] @ %s:%d^J

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-11-06 21:17:56 +01:00
Tobias Svehagen 4fc6a04eb1 cmake: dts: Remove duplicates from DTS_ROOT
If duplicates gets passed to scripts/dts/gen_defines.py, the bindings in
those directories will be loaded twice and actually get in conflict with
itself.

Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
2019-11-06 20:56:16 +01:00
Sebastian Bøe 6d6173f247 cmake: Speed up CMake by not invoking 'west'
Speed up CMake by 100ms by importing west instead of invoking it as an
executable.

There is significant overhead in invoking west as a script via
pip. The exact reason why is not clear.

Also, simplify the version output parsing as we get the version in a
more machine-readable form now.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-11-05 15:05:48 -06:00
Torsten Rasmussen 1f9723af19 cmake: app mem partion flexibility
This commit allows a more dynamic approach for specifying that a zephyr
library must be placed in a dedicated app memomory partition.
This is still done by defining the partition in code using
K_APPMEM_PARTITION_DEFINE, but now the zephyr library can be added to
the generation of partition table using zephyr_library_app_memory
instead of modifying the overall zephyr/CMakeLists.txt file.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2019-11-05 08:44:26 -08:00
Sebastian Bøe 5871fc24fb cmake: Don't test whether the installed west is the bootstrapper
Of the 1.7s or so that CMake spends in Configure-time there is 0.1s
spent to determine whether west can flash or not. This is significant
compared to the usefulness of flash-check.

AFAICT when installing west there is no longer a two-step procedure
where first a bootstrapper that can't flash is installed, and then a
proper west is installed, so the risk of having installed the
bootstrapper is no longer something we should spend 100ms testing for.

This patch removes the check, thereby speeding up CMake by 100ms.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-11-05 17:43:50 +01:00
Sebastian Bøe a5eb70fc70 cmake: Fixed a bug where python 3.8 was not detected on Windows
Fixed a bug where python 3.8 was not detected on Windows.

Python 3.8 was released two weeks ago and any Windows user that
installs it will detect the wrong version.

Also add detection for 3.9 for future-proofing.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-11-04 14:32:41 +01:00
Kumar Gala 00c7ce7942 linker: move where we define _LINKER and _ASMLANGUAGE
Move _LINKER and _ASMLANGUAGE to target.cmake because of how we pick the
linker script that might be used.  This way regardless of how or where a
linker.ld gets included we will always set _LINKER & _ASMLANGUAGE (so
any header that needs check based on those defines they can,
specifically generated_dts_board.h)

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-11-03 12:55:16 +01:00
Daniel Leung 7308fdc3c7 cmake: add --divide to GNU assembler options for x86
GNU Assembler, by default on non-Linux targets, treats slashes as
start of comments on i386.
(https://sourceware.org/binutils/docs-2.33.1/as/i386_002dChars.html#i386_002dChars)
In order to use division, `--divide` needs to be passed to
the assembler.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-10-31 09:09:22 +01:00
Daniel Leung 7aca9af7ed cmake: need to specify m32/m64 for x86_64 toolchain
Since x86_64-zephyr-elf is a multi-lib toolchain, m32/m64
need to be specified for the compiler to return the correct
library path when queried (e.g. --print-libgcc-file-name).
This affects the compile check done by CMake. Without these
flags, the compiler returns incorrect toolchain path (e.g.
requiring 64-bit libraries but returning 32-bit library path).
This also affects compiler flag checks for "-lstdc++". Incorrect
library path results in error when checking for "-lstdc++", and
this flag will not be used for the build. This results in
undefined references when compiling C++ code.

This creates target_x86.cmake to add the necessary flags for
CMake to use. The target_x86_64.cmake is also created to
mirror the same change.

Also removing the -m32 flags for host-gcc since we are not
building x86 targets with the host-gcc compiler.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-10-29 06:19:33 +01:00
Daniel Leung b57b1b19e7 cmake: toolchain/xtools: update to align with latest sdk-ng
The target.cmake for xtools needs to be updated for changes in
sdk-ng repo. This is simply a copy from the target.cmake for
0.10 SDK.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-10-29 06:19:33 +01:00
Daniel Leung b7eb04b300 x86: consolidate x86_64 architecture, SoC and boards
There are two set of code supporting x86_64: x86_64 using x32 ABI,
and x86 long mode, and this consolidates both into one x86_64
architecture and SoC supporting truly 64-bit mode.

() Removes the x86_64:x32 architecture and SoC, and replaces
   them with the existing x86 long mode arch and SoC.
() Replace qemu_x86_64 with qemu_x86_long as qemu_x86_64.
() Updates samples and tests to remove reference to
   qemu_x86_long.
() Renames CONFIG_X86_LONGMODE to CONFIG_X86_64.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-10-25 17:57:55 -04:00
Sebastian Bøe e79768c2df dtc: Remove support for common.dts
Remove the common.dts file which has been used for a year.

common.dts at one point allowed us to conditionally add an MCUBoot
overlay based on Kconfig.

but since DT lost access to Kconfig options it has been unused.

The overridable variable DTS_COMMON_OVERLAYS, which by default points
to common.dts, is also unused in-tree, and any out-of-tree usage can
be ported over to use DTC_OVERLAY_FILE instead, so we remove the
variable as well.

This simplifies the configuration system.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-10-24 11:01:08 -05:00
Sebastian Bøe 5c57abcc48 cmake: dt: Reconfigure when DTS dependencies change
When DT sources change CMake must be run again. CMake is currently
detecting changes to DT source files that we manually specify, but not
sources that are included through use of the preprocessor.

This patch makes the preprocessor output the includes used and adds
them to the 'CMAKE_CONFIGURE_DEPENDS' property.

This fixes #16791.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-10-23 17:54:41 +02:00
Sebastian Bøe c5dd84a316 cmake: Added function for parsing gcc dependency metadata
Added a function that can parse the dependency information given when
invoking gcc with the argument '-M'. This could be used to manually
add dependencies detected when preprocessing a file.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-10-23 17:54:41 +02:00
Torsten Rasmussen f0fa7b850c cmake: zephyr_library_amend feature
This commit introduces the cmake extension zephyr_library_amend.

This function allows for adding files in an out-of-tree Zephyr module
to a zephyr library created in zephyr repo CMake files.

As example:
drivers/entropy/CMakeLists.txt creates an zephyr library as:
zephyr_library()
only available to zephyr itself.

The amend function allows to amend to such a lib, by creating a
CMakeLists.txt file following identical folder structure in a Zephyr
Module:
<zephyr_module_oot>/drivers/entropy/CMakeLists.txt
zephyr_library_amend()
zephyr_library_sources() # Sources are amended to the original library

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2019-10-21 17:44:08 +02:00
Andrew Boie beb81885c2 qemu_x86_long: don't munge to elf32 in-place
Instead, use the QEMU_KERNEL_FILE facility to perform the
change in a new file zephyr-qemu.elf. This is what will
be sent to the emulator.

Fixes an issue where opening zephyr.elf in GDB would treat
it as a 32-bit binary instead of what it actually is,
forcing the user to override the arch setting.

Fixes: #19734

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-10-19 12:08:00 -07:00
Jan Van Winkel 23a866b828 cmake: toolchain abstraction for undefined behaviour sanitizer
Added toolchain abstraction for undefined behaviour sanitizer

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-10-07 15:00:20 +02:00
Andy Ross d042a3dac7 tests/kernel/mp: Update the MP test to run on emulated platforms
This was a very early test and got bitrotten inside a esp32-only
whitelist.  Make it run generically.

SMP must be forced off by the test (it's commonly a platform default).

Add a build-time failure when the configuration is single-CPU, for
clarity.

Filter the test likewise so it runs on all supported systems.

Also, the key argument to the CPU startup function is vestigial and
the test was being too strict by requiring it to be non-zero.

Finally, the qemu command line needs to predicate the "-smp" argument
on CONFIG_MP_NUM_CPUS and not just CONFIG_SMP so we have an extra CPU
to test against.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-10-06 12:53:28 -04:00
Jan Van Winkel 89e97d13ec cmake: toolchain abstraction for address sanitizer
Added toolchain abstraction for address sanitizer

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-10-04 13:39:52 -04:00
Peter Bigot 0582a0c1bf cmake: add app boards subdir as search location for board overlay files
Putting overlay files in the test/sample root clutters the file
system.  Allow them to be in the boards subdirectory alongside
board.conf files.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-10-01 20:38:24 -07:00
Sebastian Bøe ba287d2b27 cmake: Fix bug where DTS_BINDINGS_DIRS could only have one entry
Fix a bug where DTS_BINDINGS_DIRS could only have one entry. When
there were more than one entry the command for invoking menuconfig
became corrupted.

This changes the separator of DTS_BINDINGS_DIR from a space to ? so
that the shell does not interpret the space as an argument separator.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-10-01 10:35:23 -07:00