Commit graph

1503 commits

Author SHA1 Message Date
Anas Nashif d589e7f04e scripts: move gen_relocate_app.py to scripts/build
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Anas Nashif efbadbb677 scripts: move gen_kobject_list.py to scripts/build/gen_kobject_list.py
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Anas Nashif bfb65b054c cmake: binutils: find binutils nm for host compiler
We need this to generate symbols from final binary.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-11 11:56:39 +02:00
Anas Nashif 47a673f2f4 build: generate symbols file
Optional way for generating symbols file using binutils. This file will
be generated on demand for tests which will then be parsed by twister to
create an accurate test plan from the listed testcase/suites.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-11 11:56:39 +02:00
Enjia Mai 5d28ee77ef testsuite: ztest: fix the linker generator not working of new ztest
Fix the linking error when CONFIG_CMAKE_LINKER_GENERATOR=y when
applying the new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-07-08 10:45:59 +02:00
Yuval Peress 10feb693f5 unittest: support ztest_new_api
Add support for the new Ztest API when using unittest.

Fixes #47420

Signed-off-by: Yuval Peress <peress@google.com>
2022-07-07 18:22:14 +02:00
Jaroslaw Stelter 69913adc80 cmake: filter not supported C++ compilation flags
Compilation warnings appears for C++ files, that following
options are not valid:
-ffrestanding,
-Wno-format-zero-length
-Wno-main
-fgnu89-inline
-std-gnu99
Added checks to filter out unsupported flags.

Signed-off-by: Jaroslaw Stelter <Jaroslaw.Stelter@intel.com>
2022-07-07 10:26:22 +00:00
Reto Schneider 7a6c5710ff cmake: Update cmake_minimum_required to 3.20.0
As Zephyr currently requires CMake version 3.20.0, update all
occurrences of cmake_minimum_required.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-07-04 10:18:45 +02:00
Yuval Peress a7ceba3710 testing: add zephyr/ prefix to testing include path
Continuation of issue #41543 to add prefix scope for Zephyr's include
files.

Signed-off-by: Yuval Peress <peress@google.com>
2022-06-29 06:04:32 -04:00
Eugene Cohen b84ab912af arch: arm64: define A55 core
Define a CPU_CORTEX_A55 configuration and align the gcc
cpu type accordingly when selected.

Signed-off-by: Eugene Cohen <quic_egmc@quicinc.com>
2022-06-29 10:27:19 +02:00
Jeremy Bettis 6ede43b078 npcx: Set hex_file automatically w/ npcx hex image
When using CONFIG_NPCX_IMAGE_OUTPUT_HEX, set the hex_file
runners_yaml_props_target property, so that west flash will flash the
correct file.

Change the cmake flash rules to populate the hex_file value in the
runners.yaml file if either CONFIG_BUILD_OUTPUT_HEX is enabled or some
cmake file set the runners_yaml_props_target hex_file property.

Update the npcx9m6f_evb instructions now that the filename is implicit.

Signed-off-by: Jeremy Bettis <jbettis@google.com>
2022-06-28 11:09:35 +02:00
Marc Herbert f7414ab859 cmake: dts: resolve symlinks before de-duplicating DTS_ROOT
DTS directories can come from multiple places. Some places like a user's
CMakeLists.txt can preserve symbolic links. Others like
`scripts/zephyr_module.py --settings-out` resolve symbolic
links.

list(REMOVE_DUPLICATES ...) does not know anything about directories;
only about strings. To fix it the de-duplication, resolve all symbolic
links in DTS_ROOT first using file(REAL_PATH ...).

Fixes this somewhat confusing error:
```
-- Found BOARD.dts:    /home/proj/mymodule/boards/myboard/myboard.dts
devicetree error: both /home/proj/mymodule/dts/bindings/intel,stuff.yaml
             and /disk1/home/proj/mymodule/dts/bindings/intel,stuff.yaml
have 'compatible: intel,stuff'
```

Also, print `gen_defines.py` arguments in case of an error so anyone can
see what failed and not just west+CMake experts.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-06-24 20:26:02 +02:00
Keith Packard c034050bba cmake/clang: Disable -Wunused-but-set-variable warnings
Not sure why this is needed for this branch, but it pretty clearly is --
there are hundreds of set-but-unused variables in the codebase.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-14 01:50:36 +09:00
Nicholas Lowell 3da90ad21f cmake: use all compile options arguments for uniqueness
zephyr_library_compile_options() was attempting to create
unique hashes for compile options in order to prevent creating
them multiple times.  However, it was only using the first
argument to create the hash, so if multiple libraries had
different compile options but the first line was the same,
the second set would be mistaken for the first set and would
actually be passed the first set during compilation instead
of its own set.

The fix should be to use the entire compile options argument
list to create the hash so they should only match if the entire
options list is exactly the same.

This is a continued fix for #43835

Signed-off-by: Nicholas Lowell <nlowell@lexmark.com>
2022-06-08 12:42:28 +02:00
Carlo Caione 673f41e708 riscv: Introduce support for RV32E
Introduce support for RV32E.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-08 18:50:22 +09:00
Carlo Caione 10061efdc4 riscv: Rework and cleanup Kconfig
This patch is doing several things:

- Core ISA and extension Kconfig symbols have now a formalized name
  (CONFIG_RISCV_ISA_* and CONFIG_RISCV_ISA_EXT_*)

- a new Kconfig.isa file was introduced with the full set of extensions
  currently supported by the v2.2 spec

- a new Kconfig.core file was introduced to host all the RISCV cores
  (currently only E31)

- ISA and extensions settings are moved to SoC configuration files

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-05 14:28:42 +02:00
Chen Peng1 d8fa857b19 LLVM: add built-in lld linker support for x86.
add support to use LLVM built-in lld linker to build
zephyr applications for x86 platforms.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-06-05 14:10:25 +02:00
Yuval Peress 86cadf9283 ztest: Fix userspace ztests in new API
Update the new API to use K_USER as the flags for both
CONFIG_USERSPACE and CONFIG_TEST_USERSPACE. Also, fix the linker
script to properly include the suites, tests, and rules.

Fixes #44108

Signed-off-by: Yuval Peress <peress@google.com>
2022-05-25 11:20:13 +09:00
Luca Fancellu b3949415d8 cmake: gcc: Use --sysroot with gcc when SYSROOT_DIR is provided
When SYSROOT_DIR is provided, gcc should use it through the --sysroot=
option otherwise some commands won't work as expected.

For example, in the Yocto environment when cross compiling,
--print-libgcc-file-name prints only "libgcc.a" instead of the full
path to it and the subsequent assert_exists(LIBGCC_FILE_NAME) will
fail.

Fixes #45578
Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2022-05-23 19:33:33 +09:00
Sylvio Alves c9f6d18dfc soc: esp32: add Espressif HAL config
Current Espressif porting requires standard include as
part of hal implementation. compiler_flags.cmake checks for
variant name to keep those stdinc in build.
Instead of using variant name as check, use this new CONFIG
to make it clear and to allow having toolchain integrated
in zephyr-sdk package.
stdinc dependency in hal_espressif will be worked out and removed
soon.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2022-05-11 10:47:27 +02:00
Evgeniy Paltsev 48301dde0f ARC: ARCv3: add HS5x support
Add HS5x CPU support - ARCv3 32bit ISA.

Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2022-05-10 14:12:25 -04:00
Gerard Marull-Paretas a4eac53b9e ztest: add support for new and legacy include paths
The ztest unittest module relies on some headers that fake the real
ones, e.g. <zephyr/arch/cpu.h>. When new header location was introduced,
their path was not updates. This patch fixes this problem and provides
ztest with both, legacy and new include paths so that it can keep
working on both scenarios.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 20:03:00 +02:00
Stephanos Ioannidis 18398948db cmake: gcc: target_arm: Force FP hard ABI for DCLS
When Dual-redundant Core Lock-step (DCLS) topology is used, the VFP
registers across the two redundant cores must be manually initialised
and synchronised, and this requires the `-mfloat-abi=hard` option to
be specified.

This commit forces the use of FP "hard" ABI on the VFP-equipped cores
that are configured in DCLS topology.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-05 12:03:27 +09:00
Stephanos Ioannidis 6d4bce81ae cmake: gcc: target_arm: Support advanced floating-point options
This commit updates the Zephyr build system to support specifying
advanced floating-point compilation options derived from the newly
introduced unified floating-point configurations.

The following changes are introduced by this commit:

1. Specify architecture floating-point option to the `-mcpu` flag.
2. Specify floating-point unit (FPU) type using the `-mfpu` flag.

Note that the `-march` flag is not specified separately because the
`-mcpu` flag provides more detailed architecture options and this
makes the `-march` flag redundant.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-05 12:03:27 +09:00
Stephanos Ioannidis e6629abcb0 cmake: Correct PATHS usage
`PATH` is not a valid option for `find_program`; correct all such
usages to `PATHS`.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-04-29 08:57:21 +02:00
Guennadi Liakhovetski 7a85ff7683 sparse: add sparse support
With this adding "-DSPARSE=y" to the "west build" command line
performs a sparse check of the project build. So far only gcc-based
builds are supported.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2022-04-28 08:54:21 -04:00
Keith Packard aeaad1b07d cmake: Add .tdata and .tbss to generated TLS linker sections
The linker_script generating tool needs to ensure that .tdata gets added
to the TLS data section while .tbss is added to the TLS BSS section.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-04-28 11:09:01 +09:00
Keith Packard 2aca7e5e0f ld_script: Add __tbss_align and __tdata_align to generated linker scripts
Scripts generated with ld_script.cmake also need to have the _align
symbols defined so that they work with TLS values.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-04-28 11:09:01 +09:00
Anas Nashif 462b13e16e Revert "ztest: Fix userspace ztests in new API"
This reverts commit 900b6723e7.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-26 18:55:32 -04:00
Yuval Peress 900b6723e7 ztest: Fix userspace ztests in new API
Update the new API to use K_USER as the flags for both
CONFIG_USERSPACE and CONFIG_TEST_USERSPACE. Also, fix the linker
script to properly include the suites, tests, and rules.

Fixes #44108

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-26 14:29:18 -04:00
Anas Nashif 399a0b4b31 debug: generate call graph profile data using gprof
This will generate profile data that can be analyzed using gprof. When
you build the application (currently for native_posix only), after
running the application you will get a file "gmon.out" with the call
graph which can be processed with gprof:

  gprof build/zephyr/zephyr.exe gmon.out > analysis.txt

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-22 16:04:08 -04:00
Jordan Yates 070422db46 arch: common: dedicated SEMIHOST symbol
Control the usage of semihosting with a dedicated symbol, instead of
implying semihosting from the usage of `SEMIHOST_CONSOLE`. This allows
semihosting to be used without the semihost console.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-04-21 13:04:52 +02:00
Mahesh Mahadevan b2d3fdceff cmake: Add support to add symbols to ramfunc section
This PR allows the user to add symbols to the ramfunc
section. The use for this could be as follows:

zephyr_linker_sources_ifdef(CONFIG_ARCH_HAS_RAMFUNC_SUPPORT
  RAMFUNC_SECTION
  quick_access_code.ld
)

quick_access_code.ld (as shown below) can define additional
symbols to  go into the ramfunc section

. = ALIGN(4);
KEEP(*(CodeQuickAccess))

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2022-04-18 17:24:12 -07:00
Martí Bolívar c11b7852d1 Kconfig: add CONFIG_BOARD_REVISION
Propagate the board revision to Kconfig via the environment.

This is useful for application code to have access to for similar
reasons that CONFIG_BOARD is useful.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-04-08 10:30:54 -07:00
Yuval Peress 1ec0c6f530 build: make non zephyr/ include prefix configurable
Add a Kconfig to disable non prefixed includes. By setting
`CONFIG_LEGACY_INCLUDE_PATH=n` developers can disable having
`include/zephyr` in the search path. This means that includes such
as `#include <kernel.h>` will no longer work.

Internally, every header should be updated to add the `zephyr/`
prefix to the headers. Only then, will developers be able to use
this config value for their applications.

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-08 19:03:32 +02:00
Yuval Peress 53ef68d459 include: Prefix includes to use a scope
Move include paths and add new target_include_directories to support
backwards compatibility:
* /include -> /include/zephyr
  example: <irq.h> -> <zephyr/irq.h>

Issue #41543

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-08 19:03:32 +02:00
Gerard Marull-Paretas 671067bd61 cmake: linker: lld: add missing -imacros flag
The autoconf.h macros were not passed to the CMake custom command for
linker script generation.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-05 11:18:20 +02:00
Carlo Caione 18914ccdd4 devicetree_regions: Remove path fallback and sanitize name
This patch is doing two things:

- it is removing the fallback on the path. This is not possible anymore
  since the DT binding file is now actually requiring the
  'zephyr,memory-region' property to be present from which the region
  name is obtained.

- it is sanitizing the name when CONFIG_CMAKE_LINKER_GENERATOR is used
  or not.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-03-31 10:29:31 +02:00
Evgeniy Paltsev fabe038395 ARC: hs6x: gcc-m-cpu: update mcpu to be aligned with new toolchain
New ARCv3 GNU toolchain uses hs6x mcpu value for hs6x CPUs, the older
one allows to use any mcpu value.

Update old 'arc64' mcpu to 'hs6x' to be aligned with new toolchain

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2022-03-24 08:15:01 -04:00
Stephanos Ioannidis 07e4d08554 cmake: Use Zephyr SDK by default on all host operating systems
This commit updates the Zephyr build system to use the Zephyr SDK by
default for all host operating systems, when `ZEPHYR_TOOLCHAIN_VARIANT`
environment variable is not explicitly set.

Note that the Zephyr SDK is now available on all three major host
operating systems (i.e. Linux, macOS, Windows), and there is no reason
to exclude this behaviour for non-Linux hosts anymore.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-03-24 11:45:05 +01:00
Nathan Krueger 6a5520c626 arch/riscv: Adding KConfig options for 'A' and 'M' RISC-V extensions
New KConfig options for 'A' and 'M' RISC-V extensions have been
added.  These are used to configure the '-march' string used by GCC
to produce a compatible binary for the requested RISC-V variant.
In order to maintain compatibility with all currently defined SoC,
default the options for HW mul / Atomics support to 'y', but allow
them to be overridden for any SoC which does not support these.

I tested this change locally via twister agaisnt a few RISC-V platforms
including some 32bit and 64bit. To verify the 4 possibilities of Atomics
& HW Mul: (No, No), (No, Yes), (Yes, No), (Yes, Yes -- current behavior),
I used an out-of-tree GCC (xPack RISC-V GCC) which has multilib support
for rv32i, rv32ia, rv32ima to test against our out-of-tree Intel Nios V/m
processor in HW.  The Zephyr SDK RISCV GCC currently does not contain
multilib support for all variants exposed by these new KConfig options.

Signed-off-by: Nathan Krueger <nathan.krueger@intel.com>
2022-03-22 18:00:32 -04:00
David Leach c243da02ed code_relocation: Move NOCOPY flag to avoid OS drive colon
COPY/NOCOPY flag was added to the end of the string with ':'
as separators. The python script then split the line on ':'
which breaks on Windows build because the string was

[MEM]:[FILE]:[COPY]

In windows you will have 'c:\' in the file path so the
line.split() in script will split on the 'c:'.

Move the COPY/NOCOPY to:

[MEM]:[COPY/NOCOPY]:[FILE]

Note that the comments at top of gen_relocate_app.py also
indicates this format.

Fixes #43950

Signed-off-by: David Leach <david.leach@nxp.com>
2022-03-22 12:33:40 +01:00
Carlo Caione bc72fb67b1 linker: Create sections from zephyr,memory-region nodes
Currently when a node has a 'zephyr,memory-region' compatible and a
'zephyr,memory-region' string property, a new memory region is created
in the linker script.

Having a memory region without a section to place variables in could be
not that useful. With this patch we extend the memory-region mechanism
to also create sections.

The user can then place variables in the sections as usual by using for
example the GCC attributes.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-03-19 14:32:17 -04:00
Nazar Kazakov f483b1bc4c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-18 13:24:08 -04:00
Torsten Rasmussen a5ad4e8a56 cmake: reuse interface lib for compile options if it already exists
Fixes: #43835

In zephyr_library_compile_options() the existence of the compile
options interface library is checked and function returns if it already
exists. This results in #43835 meaning two libraries cannot add the
same option.

This commit fixes this by re-using the already created unique interface
library and link this to the Zephyr library.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-03-18 10:14:52 +01:00
Torsten Rasmussen a199291ddc cmake: remove base_name for dep file
With CMake 3.20 relative path inside DEPFILEs are treated relative to
CMAKE_CURRENT_BINARY_DIR and are transformed by CMake in its internal
dep file.

Therefore Zephyr build system must no longer add `base_name` to the
`-MT` argument for the preprocessor.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-03-17 11:37:07 +01:00
Jaxson Han a072a801e7 cmake: armfvp: Remove the unnecessary parameters
The Armv8R aarch64 is compiled with armv8.4-a, so the atomic_cas is
implemented by casal instruction, which needs FVP booting with
'-C bp.dram.enable_atomic_ops=1'

However, the FVP >= 11.17 has changed its parameters
'-C bp.dram.enable_atomic_ops' to '-C bp.s_dram.enable_atomic_ops' and
'-C bp.sram.enable_atomic_ops' to '-C bp.s_sram.enable_atomic_ops',
which is very annoying.

To fix this issue, disable LSE feature of GCC with 'armv8.4-a+nolse'.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
2022-03-16 09:19:44 -05:00
Jaxson Han 1a682680a7 cmake: armfvp: Improve the FVP version check
Print a warning message on 'west build -t run', if the FVP does not meet
the minimal requirement. The check acts as a reminder instead of an
entrance guard. So, the check won't stop executing the FVP program.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
2022-03-16 09:19:44 -05:00
Yonatan Schachter 0f73144ee9 cmake: Add compiler property for disabling pointer arithmetic warnings
Add a compiler property for disabling pointer arithmetic warnings,
and implement that property for GCC.

Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
2022-03-16 10:24:32 +01:00
Nazar Kazakov 9713f0d47c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-14 20:22:24 -04:00
Jim Tan c31cb0075a cmake: fix out of tree hal build fail
Fix out of tree building hal fail with different drive on windows.

Signed-off-by: Jim Tan <KuoChun.Tan@ite.com.tw>
2022-03-11 15:46:54 -08:00
Julien Massot 59aae63f51 arch: arm: Add support for Cortex-R52
Cortex-R52 is an ARMv8-R processor with AArch32 profile.

Signed-off-by: Julien Massot <julien.massot@iot.bzh>
2022-03-11 10:59:48 +01:00
Damian Krolik a505148d2f scripts: enforce module name uniqueness
Although CMake scripts already support duplicated module
names, if two modules with the same name provide different
Kconfig files, then both files will be loaded leading to
potential conflicts.

Modify zephyr_module.py to enforce that all modules are
uniquely named so that it is possbile to override some of
the built-in modules using ZEPHYR_EXTRA_MODULES variable.

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2022-03-10 09:47:58 -05:00
Joakim Andersson 5ee41d8b4e scripts: size_report: Add support for TF-M and BL2 image size reports
Add support for TF-M and BL2 image size reports.
This adds the following targets when TF-M or BL2 is enabled:
tfm_rom_report, tfm_ram_report, tfm_footprint
bl2_rom_report, bl2_ram_report, bl2_footprint

Example:
west build -t tfm_rom_report

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-03-09 14:03:52 -05:00
Jaxson Han 3c1f3197e2 cmake: armfvp: Add FVP min version check
After the fix of FVP_BaseR_AEMv8R booting issue, the minimum required
version of FVP will be 11.16.16. Add an FVP minimal required version
check in building time.

When the ARMFVP_MIN_VERSION is set in board cmake file, the version
check will be enabled and print a warning.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
Change-Id: Ibbade0c328b5e91b8830fb35cba6917f08aabbda
2022-03-08 11:09:13 +01:00
Torsten Rasmussen f96ee77c7c cmake: function to update Zephyr_DIR when loading old Zephyr packages
Fixes: #43094

This commit introduces a function which updates Zephyr_DIR to point to
the directory of the Zephyr package being loaded.

For Zephyr 3.0 and earlier, the Zephyr_DIR might in some cases be
`Zephyr_DIR-NOTFOUND` or pointing to the Zephyr package including the
boilerplate code instead of the Zephyr package of the included
boilerplate code.

This code ensures that when a package is loaded then Zephyr_DIR will
point correctly.
This ensures that when Zephyr releases <=3.0 is loaded, then Zephyr_DIR
will point correctly, see more in #43094.

Old style Zephyr package will in some cases load boilerplate.cmake
directly so to ensure proper behavior, restrict boilerplate uses of
`find_package(Zephyr)` to not use default search path, but allow only
the current Zephyr.

Of the same reason, only print warning if Zephyr_DIR is not defined as
this indicates old style inclusion.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-03-07 16:35:54 +01:00
Torsten Rasmussen 491aea49a1 cmake: move ZEPHYR_TOOLCHAIN_VARIANT export to common settings
Fixes: #43378

Move the exporting of ZEPHYR_TOOLCHAIN_VARIANT from the custom target to
the COMMON_KCONFIG_ENV_SETTINGS variable.
This ensures that the setting is exported both when running the initial
kconfiglib parsing but also on later menuconfig / guiconfig invocations.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-03-04 09:07:43 -06:00
Fabio Baltieri 98dea7e0bd cmake: extensions: fix a STRUCT_SECTION_ITERABLE comment reference
The STRUCT_SECTION_ITERABLE have been renamed to drop the Z_ prefix,
this drops the last reference in the cmake comments.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-02-28 12:19:15 +01:00
Sebastian Bøe ac65420121 cmake: Don't translate from relative to absolute include paths
Don't translate from relative to absolute include paths.

It is lost to history why this was necessary and it is causing
problems with generator expressions so we remove the logic.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2022-02-28 11:08:48 +01:00
Torsten Rasmussen 8b199b0fbb cmake: test CMake and issue error if using 3.22.1 / 3.22.2 from PyPI
Fixes: #43099

The CMake 3.22.1 / 3.22.2 PyPI version suffers a bug in the
`cmake_path(... PARENT_PATH)` implementation.

Therefore, when CMake version 3.22.1 / 3.22.2 is detected, test if the
CMake version is suffering from the bug, and in case the bug is present,
fail with an error regarding the issue.

The reason for failing, and not implementing work arounds is that Zephyr
already uses `cmake_path()` at two locations, and we cannot prevent
contributors from adding code which uses this function.

Secondly, Zephyr modules may also use `cmake_path()`, and thus be
affected by said bug.
It is impractical to implement work arounds at all possible locations
for something that is a CMake bug.

Therefore the safest solution is to test CMake itself, to check if the
version in use suffers said bug, and fail with a proper error message
if an affected CMake version is used.

See more here:
https://gitlab.kitware.com/cmake/cmake/-/issues/23187
https://github.com/scikit-build/cmake-python-distributions/issues/221

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-25 10:16:25 -08:00
Ederson de Souza 41d05fccd6 cmake: Add xcc-clang toolchain
Instead of setting XCC_USE_CLANG=1, this patch adds xcc-clang toolchain
that is basically xcc using the clang compiler.

Initially, the new toolchain simply includes files from current xcc
toolchain and (re)sets some variables. This should be a more scalable
approach to diverge the toolchains in the future than placing
"if($ENV{XCC_USE_CLANG})" at several places.

It should also help to filter tests that run (or not) exclusively with
the clang variant of XCC on twister.

The XCC_USE_CLANG flag is documented as deprecated, and a message is
emitted during build if still in use. Its new behaviour is to instruct
Zephyr to use `xcc-clang` toolchain.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2022-02-25 11:17:06 -05:00
Torsten Rasmussen 117008331d cmake: package_helper CMake script
The Zephyr CMake package helper script allows to invoke Zephyr package
modules as they are invoked at configure time, up to the modules given
with `-DMODULES=<modules>`.
This allows to run the configure time part of the Zephyr build system
without generating a complete build system.

This means that for example devicetree module can be invoked for a given
sample and board to generate zephyr.dts identical to what is created
by the build system during a build.

To generate zephyr.dts for hello_world, invoke the script as:
$ cmake -DBOARD=<board> -B build -S samples/hello_world \
$       -DMODULES=dts -P <ZEPHYR_BASE>/cmake/package_helper.cmake

Other modules, for example 'kconfig' and 'zephyr_modules' can also be
invoked this way.

This will allow other tools, such as twister, to executed only a
subset of the build system like dts in order to do filtering before
determine if a complete build should be invoked.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-23 11:34:22 -08:00
Torsten Rasmussen 31e90f1bc5 cmake: support sub-component loading in zephyr_default module
This commit allows to load only subcomponents of the default Zephyr
CMake module, zephyr_default.cmake.

This allows other tools to execute Zephyr CMake build system up to a
specific module and the stop further processing.

This commit is an enabler for future support in twister to process only
devicetree or kconfig, to allow test / sample filtering before
generating a complete build system.

Sub-components can be loaded as:
> find_package(Zephyr COMPONENTS zephyr_default:<sub-component>)

for example:
> find_package(Zephyr COMPONENTS zephyr_default:dts)

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-23 11:34:22 -08:00
Torsten Rasmussen 604f705fda cmake: doc: created a doc.cmake CMake module in Zephyr CMake modules dir
Creating a doc.cmake to the new Zephyr CMake modules dir.

This removes the need for `set(NO_BOILERPLATE TRUE)` before loading the
Zephyr CMake package.

It also removes the need within the doc/CMakeLists.txt file to manually
include individual parts of the Zephyr CMake files as this is now
controlled through a single Zephyr CMake doc module.

This aligns the way a Zephyr package is sourced with other places.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-22 10:02:39 -08:00
Torsten Rasmussen e4ccde3774 cmake: moved unittest.cmake to Zephyr CMake modules dir
Move the unittest.cmake to the new Zephyr CMake modules dir.

This allows us to have a single Zephyr CMake package and load unittest
module as: 'find_package(Zephyr COMPONENTS unittest)'

This unifies the way Zephyr package is sourced and removes the need for
a dedicated ZephyrUnittest package.

Deprecate the use of: 'find_package(ZephyrUnittest)'

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-22 10:02:39 -08:00
Torsten Rasmussen 61453e4a58 cmake: Zephyr CMake package and CMake modules
Create a cmake/modules folder containing all Zephyr CMake modules.
All Zephyr cmake files that are included from boilerplate are now
converted into CMake modules which can be individually loaded.

The Zephyr CMake package is updated to support loading of individual
CMake modules using the COMPONENTS argument to `find_package(Zephyr)`.
If the COMPONENTS argument is not specified, the default Zephyr build
system will load.
If COMPONENTS is specified then, only those components and the
dependencies will be loaded.

If a Zephyr CMake module depends on another CMake module which has not
been loaded, it will automatically be loaded.

This allows us to modularize and reuse individual parts of the Zephyr
CMake build system in a more flexible way in future.

Such usage could be:
- Higher livel multi image build system
- Invocation of individual components, for example dts processing by
  twister without loading all build code
- Doc build
- Unittesting

With this new CMake package and CMake module scheme then direct
sourcing of boilerplate.cmake has been deprecated.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-22 10:02:39 -08:00
Torsten Rasmussen 96b3e4d0c4 cmake: create a root.cmake CMake module
The root.cmake CMake module remove boilerplate code and place
it inside a dedicated root.cmake CMake module.

This is part of a general CMake overhaul to allow better modularization
and reuse of the Zephyr build system.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-22 10:02:39 -08:00
Torsten Rasmussen bdb99a330f cmake: create a kernel.cmake CMake module
The kernel.cmake CMake module remove boilerplate code and place
it inside a dedicated kernel.cmake CMake module.

This is part of a general CMake overhaul to allow better modularization
and reuse of the Zephyr build system.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-22 10:02:39 -08:00
Torsten Rasmussen 9bb162d1d5 cmake: create a configuration_files.cmake CMake module
The configuration_files.cmake CMake module remove boilerplate code and
place it inside a dedicated configuration_files.cmake CMake module.

This is part of a general CMake overhaul to allow better modularization
and reuse of the Zephyr build system.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-22 10:02:39 -08:00
Torsten Rasmussen d2b11174f3 cmake: create a user_cache.cmake CMake module
The user_cache.cmake CMake module remove boilerplate code and place it
inside a dedicated user_cache.cmake CMake module.

The user cache functions has been moved to the new Zephyr CMake module.

This is part of a general CMake overhaul to allow better modularization
and reuse of the Zephyr build system.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-22 10:02:39 -08:00
Torsten Rasmussen 5504096560 cmake: boards and shields cmake files repurposed
The boards.cmake and shields.cmake has been repurposed to do board and
shield validation so that such validation code can be re-factored out
of boilerplate itself.

The boards.cmake and shields.cmake will both perform validation and
printing errors when validation fails.

Also it will specify the boards and shields build targets.

This ensures that validation code, message printing and target
specification for boards and shields are located logically together.

This is part of a general CMake overhaul to allow better modularization
and reuse of the Zephyr build system.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-22 10:02:39 -08:00
Torsten Rasmussen de34b67c45 cmake: move CMAKE_<lang>_COMPILER_FORCED into toolchain code.
To prepare for more modular approach move the compiler forced out of
boilerplate and into the specific toolchain cmake code (generic/target).

Code is added to both generic and target toolchain modules to allow
future use of one module without requiring a load of the other module.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-22 10:02:39 -08:00
Torsten Rasmussen 254e35d61d cmake: create an arch.cmake module
The arch.cmake CMake module remove boilerplate code and place it inside
a dedicated arch.cmake CMake module.

This is part of a general CMake overhaul to allow better modularization
and reuse of the Zephyr build system.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-22 10:02:39 -08:00
Torsten Rasmussen 7f6bb02287 cmake: create a soc.cmake module
The soc.cmake CMake module remove boilerplate code and place it inside
a dedicated soc.cmake CMake module.

This is part of a general CMake overhaul to allow better modularization
and reuse of the Zephyr build system.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-22 10:02:39 -08:00
Torsten Rasmussen 0a9a3c0a79 cmake: default value for KCONFIG_BINARY_DIR moved to zephyr_modules
This is a cleanup commit moves the default setting of KCONFIG_BINARY_DIR
from boilerplate.cmake to zephyr_modules.cmake to prepare for better
re-usability.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-22 10:02:39 -08:00
Torsten Rasmussen a5d0b2f734 cmake: Move default value for AUTOCONF_H to kconfig.cmake
This is a cleanup commit moves the setting of AUTOCONF_H from
boilerplate.cmake to kconfig.cmake for better re-usability.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-22 10:02:39 -08:00
Ederson de Souza 780bc430e3 compiler/xcc: Remove -Werror flag unknown to XCC
XCC (based on GCC 4.2) doesn't recognize -Wvla (for variable-length
array), so remove it from "warning_error_misra_sane" property.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2022-02-21 22:17:27 -05:00
Carlo Caione d3203dc70d code_relocation: Add NOCOPY feature
* Use case of interest:

Some platforms are shipping in parallel to the internal FLASH some other
storage / external FLASH (usually a QSPI FLASH) that can be used to
execute (XIP) code from.

The content of this external FLASH can usually be written at flash time
using proper tools (see for example the case of the external FLASH on
the nRF5340DK that can be written at flash time using nrfjprog).

The external FLASH is a nice addition that is extremely useful when a
large application code doesn't entirely fit on the internal FLASH so
that we could want to move part of it in the auxiliary FLASH to XIP the
code from there.

* The problem:

Right now Zephyr doesn't have a formal and generic way to move at build
time part of the code to a different memory region.

* The current status:

Zephyr is indeed shipping a code_relocation feature but that doesn't
entirely match our needs.

When XIP is enabled, the code_relocation feature is used in Zephyr to
move the selected code (that is to copy text section, to initialize data
and zero bss) from FLASH to SRAM at run time and execute code from SRAM.

The relocation is done by a generated snippet of code that is
memcpy()-ing the right content to the destination region also using some
build-time generated portions of linker script to retrieve start and
destination addresses and regions.

* This patch:

This patch is leveraging the code_relocation code and adding a NOCOPY
feature. This feature is using the code_relocation feature to
dynamically build the linker script snippets but entirely skipping the
run-time code relocation so that the code can be XIP-ed from the
destination region.

* Example:

Let's say that we have a big file called `huge_file.c` that we want to
XIP from the external FLASH that is mapped in an EXTFLASH region.

In this case we should enable `CONFIG_XIP` and
`CONFIG_CODE_DATA_RELOCATION` and instruct cmake as follows:

  zephyr_code_relocate(src/huge_file.c EXTFLASH_TEXT NOCOPY)
  zephyr_code_relocate(src/huge_file.c SRAM_DATA)

this means that:

- The .text section of the `huge_file.c` must reside in the EXTFLASH
  memory region and we do not need to copy the section there because we
  are going to XIP it (and we assume that the file is going to be placed
  in the external FLASH at flash time).
- The .data section of the `huge_file.c` must still reside in the SRAM
  memory region.

* TODOs:

It's desirable to have the possibility to relocate libraries and
pre-build files instead of source code files.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-02-21 22:09:46 -05:00
Carlo Caione 34339e2560 cmake: linker: Automatically generates memory regions
As already done for the regular linker script, dinamically generates the
memory regions with the 'zephyr,memory-region' compatible also when
using the cmake linker generator.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-02-21 22:02:04 -05:00
Carlo Caione 3c0c03b9eb cmake: dts: Add dt_comp_path() cmake function
Add a new cmake extension function:

  dt_comp_path(<var> COMPATIBLE <compatible> [INDEX <idx>])

to get a list of paths for the nodes with the given <compatible>. This
is useful when we have to cycle through several nodes with the same
compatible.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-02-21 22:02:04 -05:00
Nicolas Pitre 678b76e4b0 kernel/init.c: allow for memset/memcpy alternatives during early boot
Zeroing the BSS and copying data to RAM with regular memset/memcpy may
cause problems when those functions are assuming a fully initialized
system for their optimizations to work e.g. some instructions require
an active MMU, but turning the MMU on needs the .bss section to be
cleared first, etc.

Commit c5b898743a ("aarch64: Fix alignment fault on z_bss_zero()")
provides a detailed explanation of such a case.

Replacing z_bss_zero() with an architecture specific one is problematic
as the former may see new sections added to it that would be missed by
the later. The same reasoning goes for z_data_copy().

Let's make maintenance much easier by providing weak versions of
memset/memcpy that can be overridden by architecture-specific safe
versions when needed.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-02-21 21:00:12 -05:00
Torsten Rasmussen ea082ac2c9 cmake: only write devicetree files when there are changes.
As part of #40167 is was discovered that devicetree headers are always
generated when CMake re-runs.

This causes all source files that directly or indirectly through
included headers to recompile when CMake re-runs, even if there are no
changes to devicetree.

This commits introduces `zephyr_file_copy(...)` similar to
`file(COPY_FILE ...)` from CMake 3.21.
However, as CMake 3.20 is supported by Zephyr we need a zephyr variant
of this function to allow usage with CMake 3.20.

This ensures that only when there are changes to devicetree headers,
then source files will recompile.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-11 15:47:09 +01:00
Torsten Rasmussen 91709778a4 cmake: version.h generation performed at build time
Fixes: #39503
Fixes: #40167

This commit moves `BUILD_VERSION` CMake variable from a compile
definition to be a define inside version.h.

Besides the benefit of having related settings grouped in a common
header, it also means that an updated `BUILD_VERSION` value does not
need to trigger re-compilation of all source files.

When using compile definitions, CMake cannot tell whether a given source
files uses the definition or not, and hence all sources must be
recompiled to be sure they are up-to-date.

Placing `BUILD_VERSION` in version.h, the source dependencies ensures
that only source files including `version.h` gets recompiled.

As part of this, version.h generation is moved so that it is now done
at build time.
This means that re-generation of version.h is no longer depending on a
CMake re-run but can have it's own dependency in `.git/index` when git
described is used to obtain `BUILD_VERSION` information.

Generation of logging dictionary database has been updated to support
BUILD_VERSION from header file instead of CMake configure time variable.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-08 07:50:24 -05:00
Daniel Leung 83939c267c cmake: force assembler ID to be GNU for GCC-based XCC
GCC-based XCC uses GNU Assembler (xt-as). However, CMake doesn't
recognize it when invoking through xt-xcc. This results in CMake
going through all possible combinations of command line arguments
while invoking xt-xcc to determine assembler vendor. This multiple
invocation of xt-xcc unnecessarily lengthens the CMake phase of
build, especially when XCC needs to obtain license information
from remote licensing servers. So here forces the assembler ID
to be GNU to speed things up a bit.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-02-01 18:19:43 -05:00
Daniel Leung 5c037fe122 Revert "cmake: compiler/xcc: omit -g if needed for Clang"
This reverts commit deeb98da53.

A less invasive change has been implemented which does not
require changes to the GCC compiler flag file. So revert
the commit.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-02-01 16:13:11 -05:00
Daniel Leung 0b09ca8cd0 cmake: compiler/xcc: override and clear debug property for clang
Some older versions of XCC Clang would result in the following
error during compilation:

  /tmp/file.s: Assembler messages:
  /tmp/file.s:20: Error: file number 1 already allocated
  clang-3.9: error: Xtensa-as command failed with exit code 1

due to a bug in LLVM: https://bugs.llvm.org/show_bug.cgi?id=11740.
This is fixed in upstream, https://reviews.llvm.org/D20002, in 2016.
However, it seems that it is only fixed after XCC RI-2018.0.
Instead of blanket disabling usage of '-g', use an environment
variable "XCC_NO_G_FLAG" to disable usage of flag '-g' to workaround
this issue. This needs to be manually set because there is no way to
know which XCC version is being used, and compiler flag checking for
'-g' would not result in error (and thus '-g' is not ignored).
This is only needed for older XCC Clang. For sufficiently new XCC
verisons, there is no need for this.

Note that this is an alternative implementation to commit
deeb98da53. This one does not
alter the GCC flag file, and instead, simply clear the debug
compiler property so "-g" is not used.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-02-01 16:13:11 -05:00
Anas Nashif 670b8af142 cmake: fix path in comment
Use correct path for soc in the comment.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-01-26 11:43:30 -05:00
Daniel Leung deeb98da53 cmake: compiler/xcc: omit -g if needed for Clang
Some older versions of XCC Clang would result in the following
error during compilation:

  /tmp/file.s: Assembler messages:
  /tmp/file.s:20: Error: file number 1 already allocated
  clang-3.9: error: Xtensa-as command failed with exit code 1

due to a bug in LLVM: https://bugs.llvm.org/show_bug.cgi?id=11740.
This is fixed in upstream, https://reviews.llvm.org/D20002, in 2016.
However, it seems that it is only fixed after XCC RI-2018.0.
Instead of blanket disabling usage of '-g', use an environment
variable "XCC_NO_G_FLAG" to disable usage of flag '-g' to workaround
this issue. This needs to be manually set because there is no way to
know which XCC version is being used, and compiler flag checking for
'-g' would not result in error (and thus '-g' is not ignored).
This is only needed for older XCC Clang. For sufficiently new XCC
verisons, there is no need for this.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-25 21:16:32 -05:00
Torsten Rasmussen d51a67b7c0 cmake: support ELF image adjustment
This commit adds support for adjust the addresses of the final image.
This is useful when the image is to be flashed at a location different
from the LMA address encoded in the ELF file by the linker.

An example use-case is multicore systems where core A might load image
from a flash partition into RAM in order for core B to execute and load,
but where the image itself is build with the RAM addresses as LMA.

It updates the zephyr_image_info.h header with information of adjustment
value.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-01-22 16:57:31 -05:00
Antony Pavlov 76769a42d0 soc: mips: add Qemu Malta support
The MIPS Malta is an ATX form factor evaluation board made by MIPS
Technologies. Malta board is the most popular platform for MIPS
full-system emulation.

See https://www.linux-mips.org/wiki/MIPS_Malta for details.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Remy Luisant <remy@luisant.ca>
2022-01-19 13:48:21 -05:00
Antony Pavlov 436066e3c4 cmake: add MIPS support
This commit defines the toolchain command line options for the
Zephyr MIPS architectural port.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Remy Luisant <remy@luisant.ca>
2022-01-19 13:48:21 -05:00
Torsten Rasmussen 34c79072c5 cmake: linker: Use depfile for Makefile generators
Since CMake 3.20 DEPFILE has been supported by Makefile generators.

Simplify the CMake code by using DEPFILE for both Ninja and Makefile
generators.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-01-10 09:49:11 -06:00
Torsten Rasmussen a0ba67df63 cmake: remove base_name for dep file
With CMake 3.20 relative path inside DEPFILEs are treated relative to
CMAKE_CURRENT_BINARY_DIR and are transformed by CMake in its internal
dep file.

Therefore Zephyr build system must no longer add `base_name` to the
`-MT` argument for the preprocessor.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-01-10 09:49:11 -06:00
Stephanos Ioannidis 3181331586 cmake: bintools: gnu: Suppress GDB check console outputs
The GDB check routine added in the PR #38749 does not suppress the
console outputs (stdout and stderr) and may print out a misleading
error message during a CMake configuration when the required version
of Python is not available on the system:

  arm-zephyr-eabi-gdb: error while loading shared libraries:
  libpython3.8.so.1.0: cannot open shared object file: No such file or
  directory

This commit adds the `OUTPUT_QUIET` and `ERROR_QUIET` options when
executing the GDB process so that the console outputs during the GDB
executable validation are not displayed to the user.

In addition, this commit removes the unused `GDB_PY_NO_PY` standard
output redirection variable since it is unnecessary.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-01-10 09:38:41 -06:00
Torsten Rasmussen 6d72d915f9 cmake: remove platform / build file specific escaping
Fixes: #41435

Remove build host specific escaping of start symbol command argument.
The start symbol for armlink is: Image$$device$$Base
and were escaped as: Image\\$$\\$$device\\$$\\$$Base

However, the $ must only be escaped in Linux and MacOS, not on windows
hosts.

Instead of escaping the start symbol in the CMake code then it is better
to use the VERBATIM flag on `add_custom_command()` which ensures correct
escaping for the build host.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-01-07 18:20:30 +01:00
Torsten Rasmussen a03e7df9f5 cmake: linker generator replace % with @ for symbol referencing
Fixes: #41435

The use of %<symbol>% works well in Linux and MacOS but when passed
to the linker script generator in Windows the %<symbol>% is processed
by the windows shell causing the value to disappear and thus an empty
value inside the generated ld linker script or scatter file.

This is fixed by using the @ character instead of the % character.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-01-07 18:20:30 +01:00
Sebastian Bøe dbe473bc83 cmake: Test the compiler before testing compiler flags
We used to test that the compiler works at all, before testing
compiler flags. But during some toolchain refactoring this got
re-arranged.

This commit corrects the ordering.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2021-12-23 13:01:41 +01:00
Torsten Rasmussen d9f0ca3943 cmake: add ztest_suite_node output section to linker script generator
The commit dee79d2b66 introduced a new
linker output section ztest_suite_node in linker/common-ram.ld but
without updating the corresponding linker_script/common/common-ram.cmake
linker script generator code.

This causes test cases for arm Compiler 6 to fail.

Add the same section to common-ram.ld.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-12-22 17:53:48 +01:00
Torsten Rasmussen 84fe8f8121 cmake: armlink: fix handling of argument in configure_linker_script
The PR #40174 changed `configure_linker_script()` macro from handling a
single string to handle a list of strings for the
linker_pass_define argument.

This changed the armlink/target.cmake from STREQUAL to IN_LIST, however
as `configure_linker_script()` is a macro, then arguments are not
variables in the CMake sense but string replacements, and therefore
IN_LIST doesn't work directly on the argument.

Fix this by creating a true CMake list from the content of the argument
and use this list for IN_LIST checking.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-12-22 17:53:48 +01:00
Torsten Rasmussen 225bea4bb2 cmake: armlink: remove sourcing of ld/target_base.cmake file
The armlink/target.cmake should not source ld/target_base.cmake file
as it provides its own (empty) implementation of the
`toolchain_ld_base` macro.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-12-22 17:53:48 +01:00
Shubham Kulkarni f9eaabbd9b module: mcuboot: Add config option to support unsigned binary generation
This commit adds a change to support running west sign command even if
the keyfile is not provided. Default value of the configuration
is set to n in order to maintain backward compatibility.

Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
2021-12-18 07:20:38 -05:00
Torsten Rasmussen ca0702283f cmake: remove CMake policy CMP0002 and CMP0116
The CMake policies CMP0002 and CMP0116 can now safely be removed.

Setting CMake minimum version to 3.20 ensures that policies are set to
NEW per default for those two policies:
> The cmake_minimum_required() command does more than report an error
> if a too-old version of CMake is used to build a project. It also sets
> all policies introduced in that CMake version or earlier to NEW
> behavior.

CMP0002 was introduced in CMake 2.6 and was set to NEW.

CMP0116 was introduced in CMake 3.20 and set to OLD because of:
> Use the old CMake behaviour until we are updating the CMake 3.20 as
> minimum required. This ensure that CMake >=3.20 will be consistent
> with older CMakes.
and can thus be removed as we are now having 3.20 as minimum required.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-12-17 14:24:02 +01:00
Torsten Rasmussen 92a1ca61eb cmake: remove xtensa workaround in Zephyr toolchain code.
Remove xtensa specific workaround as this code is now present in Zephyr
SDK cmake code.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-12-17 14:23:49 +01:00
Torsten Rasmussen fb3a113eb8 cmake: zephyr toolchain code cleanup
With the revert of commit 820d327b4618d587a9cae0d085f00c6ab9c81cf2 then
some additional code can be cleaned up.

This removes the final left-overs from Zephyr SDK 0.11.1 support and
older.

It further aligns message printing when including Zephyr SDK toolchain
to other toolchain message printing.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-12-17 14:23:49 +01:00
Torsten Rasmussen e747fe73cd Revert "cmake: Zephyr sdk backward compatibility with 0.11.1 and 0.11.2"
This reverts commit 820d327b4618d587a9cae0d085f00c6ab9c81cf2.

Commit b973cdc9e8 updated the minimum
required Zephyr SDK version to 0.13.

Therefore revert commit 820d327b4618d587a9cae0d085f00c6ab9c81cf2 as
backward support for 0.11.1 and 0.11.2 is no longer required.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-12-17 14:23:49 +01:00
Fabio Baltieri c07d747173 cmake: use the correct property for the memory region name
Fix the zephyr_linker_dts_memory to lookup the correct property name
when trying to figre the region name.

Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
2021-12-10 07:14:00 -06:00
Carles Cufi cf111962e0 gcc: Enable address-of-packed-member warnings
After having resolved all of the instances of packed member access,
re-enable the warning.

Fixes #16587.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-12-10 14:08:59 +01:00
Jordan Yates 6da04c965f cmake: zephyr_linker_dts_memory no name param
Remove the `NAME` function argument from `zephyr_linker_dts_memory` as
the name is now automatically derived from the devicetree node.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-12-09 16:23:03 +01:00
Jordan Yates 0d185f08a2 cmake: zephyr_linker_dts_memory auto-name
Update the linker script generator to automatically derive memory
region names from the devicetree node according to the same logic in
`devicetree_regions.h`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-12-09 16:23:03 +01:00
Martí Bolívar 77a403cf6e cmake: extensions: add NAME parameter to DT register helpers
Allow register address and size access by name.

Example devicetree fragment:

  / {
          foo@deadbeef {
                  reg = <0xdeadbeef 0x1000>, <0xfeedface 0x2000>;
                  reg-names = "bar", "baz";
          };
  };

Example usage:

  dt_reg_addr(bar_addr PATH "/foo@deadbeef" NAME bar)
  dt_reg_size(bar_size PATH "/foo@deadbeef" NAME bar)

  dt_reg_addr(baz_addr PATH "/foo@deadbeef" NAME baz)
  dt_reg_size(baz_size PATH "/foo@deadbeef" NAME baz)

Results:

  - bar_addr is 0xdeadbeef
  - bar_size is 0x1000
  - baz_addr is 0xfeedface
  - baz_size is 0x2000

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-12-07 20:25:40 -06:00
Martí Bolívar 2b7c61e306 cmake: re-work devicetree preprocessing steps
This causes any devicetree error messages to refer to the source files
which contain the errors instead of intermediate <BOARD>.dts.pre.tmp
files in the build directory.

Do this using a new python-devicetree feature which can correctly
handle cpp's generated line marker directives.

To use this feature, rework the way that the C preprocessor is run on
devicetree inputs so that line marker directives are preserved by
removing the -P option.

This is a backwards incompatible change to the way the generated files
in the build directory used to work, as not all tools can consume line
markers. In particular, dtc can't handle these lines. We therefore
pass dtc zephyr.dts instead (the final parsed devicetree output from
python-devicetree).

Since <BOARD>.dts.pre.tmp is a publicly documented file, this is
changing existing behavior, so use a new file name for the
intermediate files to make it more obvious that something changed. In
particular, use zephyr.dts.pre instead of <BOARD>.dts.pre.tmp.
(The $BOARD.dts.pre.tmp name is a little cumbersome anyway.)

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-12-07 13:39:37 -05:00
Martí Bolívar fc416ca52f cmake: run dtc after gen_defines.py and friends
Curently, any and all devicetree syntax errors are being handled by
dtc, because it runs before gen_defines.py. This means that any
improvements we make to devicetree error handling and reporting in
dtlib or edtlib will never be noticed by users that have dtc
installed.

(This also has the unfortunate effect of hiding dtlib error reporting
from me, since my systems all have dtc installed.)

Move dtc to after gen_defines.py, so that initial error handling and
warnings all come from python. If DTC has some additional warnings or
errors to report, let them come last. They will still halt the build
if anything is wrong.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-12-07 13:39:37 -05:00
Ryan McClelland fca38c38e5 cmake: fix multiple shield parsing
When multiple shields are defined, only the shield last in the -DSHIELD
list gets defined in `.config`. This is due to too many backslashes
used defining it for an env setting.

Signed-off-by: Ryan McClelland <ryanmcclelland@fb.com>
2021-12-06 08:12:18 -05:00
Martí Bolívar 2c5c622839 cmake: extensions: add target_sources_if_dt_node()
This is like target_sources_ifdef(), except it works if a devicetree
node exists.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-12-06 08:01:48 -05:00
Martí Bolívar 8346032d19 cmake: extensions: improve DT consistency with python APIs
In the python APIs we use for devicetree, you can generally use an
alias interchangeably with the full path to a node.

For example, dtlib.py says:

    [...] both dt.get_node("/foo/bar") and dt.get_node("bar-alias")
    will return the 'bar' node below:

      /dts-v1/;

      / {
              foo {
                      bar_label: bar {
                              baz {
                              };
                      };
              };

              aliases {
                      bar-alias = &bar-label;
              };
      };

    Fetching subnodes via aliases is supported:
    dt.get_node("bar-alias/baz") returns the 'baz' node.

Now that we have the necessary helper functions for resolving alias
names, make the CMake APIs to devicetree behave the same way. This
improves consistency between the two sets of devicetree helpers used
by the build system, making them both match the general devicetree
practice that an alias is as good as a path. This is good for
consistency.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-12-06 08:01:48 -05:00
Martí Bolívar ecece731fd cmake: extensions: add internal DT helpers
Add a couple of helper functions we'll use to make some other
improvements.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-12-06 08:01:48 -05:00
Martí Bolívar a9f5578137 cmake: extensions: add dt_alias()
This is a helper function for looking up the path to a devicetree
alias. It is analogous to dt_chosen(). It has to exist as a separate
function from dt_prop() for similar reasons that dt_chosen() does:
the edtlib APIs for interacting with /aliases are special-cased in the
same way they are for /chosen.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-12-06 08:01:48 -05:00
Martí Bolívar e05810dd5d cmake: extensions: DT helper fixes
Fix miscellaneous issues:

- dt_node_has_status() is missing a return() statement
- dt_chosen()'s comment string and error handling message contain errors

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-12-06 08:01:48 -05:00
Maureen Helm 2cf91050c8 cmake: Fix invalid warning related to rimage
Fixes an issue on SOF-supported boards where the build system
incorrectly believed that the rimage target was changing when rerunning
CMake, even though the user did not change any configuration. This issue
was introduced in commit 525fa76f4d.

Create initial build dir:
$ west build --board intel_adsp_cavs18 samples/subsys/audio/sof

Re-run CMake with no arguments in that build dir:
$ cd build
$ cmake .

CMake Warning at /home/mhelm/zephyrproject/zephyr/cmake/extensions.cmake:2403 (message):
  The build directory must be cleaned pristinely when changing rimage target,

  Current value="", Ignored value="cnl"
Call Stack (most recent call first):
  /home/mhelm/zephyrproject/zephyr/cmake/extensions.cmake:829 (zephyr_check_cache)
  /home/mhelm/zephyrproject/zephyr/boards/xtensa/intel_adsp_cavs18/board.cmake:6 (board_set_rimage_target)
  /home/mhelm/zephyrproject/zephyr/cmake/app/boilerplate.cmake:635 (include)
  /home/mhelm/zephyrproject/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
  /home/mhelm/zephyrproject/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:40 (include_boilerplate)
  CMakeLists.txt:5 (find_package)

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2021-12-03 07:53:19 -05:00
Henrik Brix Andersen abbc89f026 boards: add support for integer board revisions
Add support for simple integer board revisions (1, 2, 3, ...).

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-12-01 13:53:30 -06:00
Torsten Rasmussen a1c49be42e cmake: ZEPHYR_MODULES_NAMES list created before ext-root
Create the ZEPHYR_MODULES_NAMES list of zephyr modules present in the
system before calling roots defined in `MODULE_EXT_ROOT`.

This will allow external module roots to process based on Zephyr modules
available in the system.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-11-27 13:07:09 +01:00
Torsten Rasmussen f643b8b369 scripts: support compile_commands.json in gen_app_partitions.py
Fixes: #40590

This commit updates gen_app_partitions.py to include only files present
in the current build by extracting the information from the CMake
generated `compile_commands.json` file.

This ensures that object files in sub-projects, such as `empty_cpu0`,
will not be considered by the script.

Using the compile_commands.json instead of walking the whole build tree
for finding object files also improves performance:

Time of executing `gen_app_partitions.py` (Old):
__________________________
Executed in  480.06 millis
   usr time  425.83 millis
   sys time   49.55 millis

Time of executing `gen_app_partitions.py` (New):
________________________________________________________
Executed in   76.22 millis
   usr time   49.00 millis
   sys time   24.59 millis

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-11-25 10:41:28 -05:00
Torsten Rasmussen 447a893a2f cmake: boilerplate update comment to CMake 3.20
boilerplate.cmake contained a comment referring to CMake 3.13.1 but
minimal required version is 3.20, so update the comment to 3.20.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-11-19 12:32:44 -05:00
Maureen Helm 525fa76f4d boards: xtensa: Use a CMake variable to set the rimage target name
Removes hardcoded logic in the west signing script that translates
Zephyr board names to rimage target names. Instead, use a cached CMake
variable set at the board level to define its respective rimage target
name. This eliminates the need to modify the west signing script when
new SOF-supported boards are introduced to Zephyr.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2021-11-17 19:44:35 -05:00
Ross Burton a4da64033d cmake: expand DTC version regex
DTC can be built with both traditional Makefiles or Meson. When built
with Makefiles the --version output looks like 'Version: DTC
1.6.1-dirty' but when built with Meson the output is 'Version: DTC
v1.6.1+.

This fails to match the version regex and the cmake then fails:

CMake Error at cmake/host-tools.cmake:28 (if):
  if given arguments:
    "VERSION_GREATER" "1.4.6"
  Unknown arguments specified

Expanding the regex with an optional 'v' covers both cases and the build
succeeds.

Signed-off-by: Ross Burton <ross.burton@arm.com>
2021-11-17 11:14:31 -05:00
Jordan Yates 28b2e55321 cmake: rework linker script generation and linker prebuilt stages
This commit reworks the linker script generation and linking stages in
order to better support fixed section location as required by #38836.

Today we have the following generated linker scripts and the elf output
depending on the system configuration:
- linker_app_smem_unaligned.cmd --> app_smem_unaligned_prebuilt.elf
- linker_zephyr_prebuilt.cmd    --> zephyr_prebuilt.elf
- linker.cmd                    --> zephyr.elf

as not all linker scripts may be created and as there is a need for the
possibility to move gen handles earlier then those stages has been
renamed into more generic names so that with this commit we have:
- linker_zephyr_pre0.cmd --> zephyr_pre0.elf
- linker_zephyr_pre1.cmd --> zephyr_pre1.elf
- linker.cmd             --> zephyr.elf

This also means that is the stage zephyr_pre1 is not needed, then build
can go from `zephyr_pre0.elf` to `zephyr.elf`.

The gen_handles.py has been changed so it now uses `zephyr_pre0.elf` as
input. This ensures that the handles array are final when invoking the
next build and linking stages.

To keep the current behavior of generating the isr table and kobj hash
of what was `zephyr_prebuilt` stage the code blocks contolling isr
generation and kobj hash has been relocated to be located after
app_smem and device handle generation.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-11-16 10:41:59 +01:00
Jordan Yates 8d93217af4 cmake: new global property for generated files
Introduce a new global property for source files that are generated from
the initial Zephyr link (app_smem_unaligned_prebuilt). This source list
is used for files which will introduce address shifts into the final
binary, which need to be present in `zephyr_prebuilt.elf` for
`CONFIG_USERSPACE` scripts to correctly generate `zephyr.elf`.

This resolves #38836.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-11-16 10:41:59 +01:00
Jordan Yates c03e658369 cmake: update desc of GENERATED_KERNEL_* variables
The previous description of the `GENERATED_KERNEL_*` cmake variables
was incorrect in that these are generated after the second link stage
when `CONFIG_USERSPACE` is enabled.

The sources in these variables are generated from `zephyr_prebuilt.elf`
for inclusion in `zephyr.elf`. However `zephyr_prebuilt.elf` is preceded
by `app_smem_unaligned_prebuilt.elf` when `CONFIG_USERSPACE` is enabled.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-11-16 10:41:59 +01:00
Filip Kokosinski 94428044e2 cmake: support multiple entries in board.cmake
Currently there is no way to support running a board on multiple
emulation platforms nor to choose a desired emulation platform for the
simulation to be run on. This commit introduces a new
SUPPORTED_EMU_PLATFORMS list, which defines available emulation
platforms for a given board.

Fixes #12375.

Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
2021-11-12 21:33:42 -05:00
Torsten Rasmussen fffaf05e5d scripts: support for build meta file creation
This commit is motivated by the west discussion in:
https://github.com/zephyrproject-rtos/west/issues/548

The commit provides the ability to generate a build meta info file
containing lists of:
- Zephyr:         path and revision
- Zephyr modules: name, path, and revision
- West:           manifest path
                  path and revision for each project

For Zephyr or Zephyr modules the revision will be `null` if it is not
under git version control.

If Zephyr, a modules, or a project has uncommitted changes, the revision
will be marked dirty.

If west is not installed or used for the build process, the
west-projects list will be empty.

If a project is both a Zephyr module and a west project it will show up
in both lists.

Similar to Zephyr, which is independently referred as the Zephyr in use
but also listed as west project when west is used.
This is important in case ZEPHYR_BASE was manually set and pointing to
a different Zephyr repository.

The build meta file is not created per default but can be enabled with
the BUILD_OUTPUT_META Kconfig setting.

A project using west and having an extra Zephyr module loaded not
controlled using git can look like:
zephyr:
  path: /.../zephyr
  revision: 863600cd0e3c0a271e86629c5089821e5e4380cc-dirty
modules:
- name: mcuboot
  path: /.../bootloader/mcuboot
  revision: c61538748ead773ea75a551a7beee299228bdcaf
- name: local_module
  path: /.../local_module
  revision: null
west:
  manifest: /.../zephyr/west.yml
  projects:
  - path: /.../zephyr
    revision: 863600cd0e3c0a271e86629c5089821e5e4380cc-dirty
  - path: /.../bootloader/mcuboot
    revision: c61538748ead773ea75a551a7beee299228bdcaf
  - path: /.../tools/net-tools
    revision: f49bd1354616fae4093bf36e5eaee43c51a55127

And without west:
zephyr:
  path: /.../zephyr
  revision: 863600cd0e3c0a271e86629c5089821e5e4380cc-dirty
modules:
- name: hal_nordic
  path: /.../modules/hal/nordic
  revision: a6e5299041f152da5ae0ab17b2e44e088bb96d6d
west: null

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-11-11 06:06:07 -05:00
Torsten Rasmussen 1198087440 cmake: APPLICATION_CONFIG_DIR support implemented
With this commit a dedicated APPLICATION_CONFIG_DIR is added to the
Zephyr build system.

Currently, the APPLICATION_SOURCE_DIR is identical also the base
location of configuration files.

This is very practical for simple samples, but also has it limitations
for more complex setups.

Introducing a dedicated APPLICATION_CONFIG_DIR allows users more
customization options in Zephyr build system.
Especially in terms of custom build configuration files unknown to
Zephyr itself.

For example, instead of all configuration files being located directly
in the application source folder, a project might prefer to organize
their configuration files on a per board basis, for example:
<app>/boards/custom_board_A/prj.conf
<app>/boards/custom_board_A/app.overlay
<app>/boards/custom_board_A/custom_file.mine
<app>/boards/custom_board_B/prj.conf
<app>/boards/custom_board_B/app.overlay
<app>/boards/custom_board_B/custom_file.mine
...

instead of n-files located in the root of the sample.

If the user / sample specifies APPLICATION_CONFIG_DIR, then this folder
will always be used instead of the default configuration folder.

As part of this extension the behaviour of
`-DCONF_FILE=<relative-path>/prj_<build>.conf` and additional Kconfig
fragments automatic sourcing has been aligned with the default behavior
of `prj.conf`.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-11-10 08:25:36 -05:00
Torsten Rasmussen 2eb13159ec cmake: kconfig: use absolute files for merge_config_files
The `merge_config_files` list contains files with both relative and
absolute paths.
Each entry is checked and files with a relative path are converted to
absolute path. This creates a `merge_config_files_with_absolute_paths`
identical to the `merge_config_files` but with absolute path on each
entry.

Afterwards it is mixed whether `merge_config_files` or
`merge_config_files_with_absolute_paths` are used creating unnecessary
risk when the list with relative path files are used.

This commit sets the content of `merge_config_files` with updated
absolute paths files, and also updates all places to use this list.

This ensures that after path conversion then only the list with absolute
paths is used.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-11-10 08:25:36 -05:00
Torsten Rasmussen 9c74027a7b cmake: CMake linker script generator pass handling
To prepare for linker script creation with flexible number of linker
passes depending on system configuration then the Zephyr CMake linker
script generator has been updated to use pass names instead of pass
numbers.

This allows greater flexibility as a section can now be active based on
the settings on the pass and not the linking pass index number.

As part of this, the `PASS` processing in `linker_script_common.cmake`
has been adjusted so that it properly handles when a linking pass is
handling multiple settings, such as both `LINKER_APP_SMEM_UNALIGNED`
and `DEVICE_HANDLES_PASS1` in same linking pass.

As the number of linking passes are more flexible, then the PASS
argument in `zephyr_linker_section()` and
`zephyr_linker_section_configure()` has been updated to also support
a `NOT <name>` argument, for example: `PASS NOT LINKER_ZEPHYR_FINAL`.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-11-08 20:45:07 +01:00
Torsten Rasmussen 1fa3f15137 cmake: update configure_linker_script() to prepend -D on defines
Currently all calls to `configure_linker_script()` specifies `-D<name>`
when calling `configure_linker_script()`.

This works well for the gcc pre-processed ld linker script templates,
but Zephyr also supports a CMake linker script generator which can be
used for ld scripts and armlink scatter files.

In this case, a `-D` must be stripped.

This commit changes this so that Zephyr CMake build system calls
`configure_linker_script()` without `-D`.
Thus the `LINKER_SCRIPT` choice can decide how this information should
be passed to underlying linker script functionality, that is `-D` for
linker script template and CMake variable for the CMake linker script
generator.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-11-08 20:45:07 +01:00
Immo Birnbaum f4d41b1a6c cmake: boards: make QEMU icount sleep parameter configurable
When QEMU is running in icount mode, the behaviour regarding
the CPU being in sleep mode is configurable, with the default
value being set to 'off'. In this case, instruction counting
continues even when the CPU is sleeping or no target time is
set in the system timer. If the sleep parameter is set to
'on', instruction counting stops if the CPU is sleeping, and
the instruction count will fast-forward directly to the next
target time once it is being set.

In the Xilinx derivative of QEMU (which simulates ZynqMP and
Zynq-7000 SoCs), the default configuration causes QEMU to no
longer accept control commands via the console or remotely
whenever Zephyr enters and remains in idle mode.

Therefore, this commit makes the value of the sleep para-
meter of the icount functionality configurable, with the
default value remaining 'off'. The value can be changed at
board level alongside with the specification of the icount
shift value.

Signed-off-by: Immo Birnbaum <Immo.Birnbaum@Weidmueller.com>
2021-10-28 15:26:50 +02:00
Immo Birnbaum a69cd66b6e cmake: add the gcc -mcpu parameter value for the Cortex-A9 CPU
Add the -mcpu=cortex-a9 option as part of the basic aarch32 Cortex-A
CPU support.

Signed-off-by: Immo Birnbaum <Immo.Birnbaum@weidmueller.com>
2021-10-28 15:26:50 +02:00
Torsten Rasmussen 429d6cf055 cmake: create zephyr_build_string
This commit creates a new `zephyr_build_string()` function.

`zephyr_build_string()` provides a common way of constructing a build
string based on board name, board revision, and build type.

Having this as a function facilitate creation of names in a common way
and thus helps to ensure naming consistency, especially if newer info
is later embedded into the build string.

Initially the build string will be used to lookup configuration
fragments and devicetree overlay files.

This function is used by `zephyr_file(CONF_FILES ...)`.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-10-14 13:22:14 +02:00
Jordan Yates 9c4366f1ae cmake: remove LINKER_PASS2 define
This option was deprecated for the v2.6 release, and has therefore met
the 2 release deprecation cycle requirements.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-10-11 10:21:53 +02:00
Yuval Peress a81f8af701 build: Fix native_posix build on GNU GCC
Update -fno-pie to only be added when relevant. This fixes native_posix
builds on Debian hosts.

* Debian and other Linux distributions have ld with --warn-textrel as
default.
* The option generates a warning when linking on x86.
* The warning make scripts/twister fail because we treat all warnings
as error.
* The warning is issued when no PIE objects are linked against PIE
library.
* PIE (Position Independent Executable) or not can be seen with the
following command.
* When you want to generate non PIE, link with `-no-pie.`

Non PIE

  $ readelf -l build/zephyr/zephyr.elf | grep 'Elf file type is'
  Elf file type is EXEC (Executable file)

PIE

  $ readelf -l /lib/x86_64-linux-gnu/libc.so.6 | \
  grep 'Elf file type is'
  Elf file type is DYN (Shared object file)

Issue #35244

Signed-off-by: Yuval Peress <peress@google.com>
2021-10-05 05:44:32 -04:00
Torsten Rasmussen 0455d268df devicetree: remove support for DTC_OVERLAY_FILE in environment
Setting of DTC_OVERLAY_FILE as an environment setting was deprecated
before Zephyr 1.14 LTS.

This commit remove the support for this possibility and thus cleans up
the build system.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-10-01 14:42:42 -04:00
Torsten Rasmussen 917d5021d7 cmake: CMake compile features support
Fixes: #36558 #32577

This commit introduces CMAKE_C_COMPILE_FEATURES and
CMAKE_CXX_COMPILE_FEATURES.

This allows users to use the `target_compile_features()` in their own
code.

In Zephyr, the CMAKE_C/CXX_COMPILE_FEATURES are defined based on the
compiler and the Kconfig / CSTD setting.
Doing so ensures that a user compiling Zephyr with c99 and specifies
`target_compile_features(<target> ... c_std_11)` will get an error.
And similar if building Zephyr with C++ support and c++11, but testing
for `target_compile_features(<target> ... cxx_std_17)`.

For example in the C++ case, the user must ensure that Zephyr is
compiled with C++17, that is: CPLUSPLUS=y and STD_CPP17=y, in which case
the CMAKE_CXX_COMPILE_FEATURES will contain support for C++17 and thus
the `target_compile_features(<target> ... cxx_std_17)` will succeed.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-10-01 14:40:33 -04:00
Sylvio Alves e47eeec810 toolchain: esp32: define target toolchain
In order to retrieve TOOLCHAIN_NAME from Kconfig,
generic.cmake points to any toolchain as a
boilerplate implementation. Now, target.cmake file handles
proper toolchain selection.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-09-28 20:06:25 -04:00
Torsten Rasmussen 734e52899a cmake: linker: arm: utilize zephyr_linker_group(... SYMBOL SECTION)
The root cause of #38591 was region symbols being placed before the
section description for data region.

To support both schemes with the linker generator, a new
`SYMBOL SECTION` argument has been added to the zephyr_linker_group()
function.

This commit updates the arm/linker.cmake CMake linker file to use the
new `SYMBOL SECTION` argument for the data region group and text region
group so that those two groups now behave identical to the behavior when
using the cortex_m linker.ld template.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-09-24 15:13:13 -04:00
Torsten Rasmussen 57ab0342d3 cmake: linker generator: group symbol from section
The root cause of #38591 was region symbols being placed before the
section description for data region.

Some region start symbols are placed before section description, other
region start symbols are placed inside the first section in the region
and thus identical to the sections own first symbol.

To support both schemes with the linker generator, a new
`SYMBOL SECTION` argument has been added to the zephyr_linker_group()
function.

The ld_script.cmake linker script generator has been updated to support
the new argument so that generated ld linker script has identical
behavior to the templated ld linker scripts.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-09-24 15:13:13 -04:00
Stephanos Ioannidis 0ae9f5a626 cmake: Set minimum required Zephyr SDK version to 0.13.1
This commit sets the minimum required Zephyr SDK version to 0.13.1,
which fixes the following critical issues:

1. Xtensa initial malloc failure (GitHub issue #38258)
2. ARMv8-M security extension vulnerability (CVE-2021-35465)

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-09-24 07:35:40 -04:00
Torsten Rasmussen b2b411dae6 cmake: remove target_compile_definitions() in zephyr_library_property
Fixes: #38761

The introduction of zephyr_library_property in #38347 contained a
stray function call `target_compile_definitions()` resulting in the
library property name and value to also be added compile definitions to
the Zephyr library.

The Zephyr library property is an internal property and is not supposed
to be added as compile definitions, and thus this call is removed with
this commit.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-09-23 10:32:35 -04:00
Carles Cufi 76c4591e6b cmake: gnu: Fix debugging when GDB fails to load because of Python
GDB can be built with or without Python support. When built with Python
support this can cause a particular problem: The gdb executable relies
on shared libraries that are bound to a specific Python version. But
since most Linux distributions typically ship with a single version, it
is very difficult to choose which one to target when building GDB.
When GDB executes, if it fails to load the shared libraries it will exit
immediately with an error code of 127 and output resembling this:

/home/carles/bin/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb:
error while loading shared libraries: libpython3.8.so.1.0: cannot open
shared object file: No such file or directory

There are two known approaches to shipping multiple gdb executables:

- The Zephyr SDK ships a default gdb with Python enabled, and then a
  separate gdb-no-py executable with Python disabled
- GNU Arm Embedded ships with a default gdb with Python disabled, and an
  additional gdb-py with Python enabled

To mitigate the problem of not being able to debug, fall back to a
'gdb-no-py' if it exists whenever the standard gdb executable fails to
even run.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-09-23 12:47:39 +02:00
Torsten Rasmussen e59f375038 cmake: remove policy CMP0079 old behavior
Fixes: #38558

This commit removes: `cmake_policy(SET CMP0079 OLD)`

This means Zephyr will now allow the new CMP0079 behavior introduced
with CMake version 3.13.

Code has now been examined and no occurences has been found where the
INTERFACE keyword was used with `target_link_libraries()` outside the
CMakeLists.txt scope where the original libraries were created.

As an additional safeguard `./scripts/twister -c -N --cmake-only`
has been executed before and after this change and all `build.ninja`
files for each test / sample have been diffed.
Removing the CMP0079 policy creates identical build files, hence removal
of the old policy will not impact the build.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-09-22 09:40:07 -04:00
Stephanos Ioannidis c2859bc7aa cmake: compiler: Add nostdincxx property for gcc
This commit adds the `nostdincxx` C++ compiler property for GCC, which
is specified when the C++ standard library (`CONFIG_LIB_CPLUSPLUS`) is
disabled.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-09-21 11:39:18 -04:00
Stephanos Ioannidis fd4700d7b7 cmake: compiler: Add framework for disabling C++ standard includes
This commit adds a new C++ compiler property `nostdincxx` which
specifies the C++ compiler flag for excluding the C++ standard library
include directory from the include paths.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-09-21 11:39:18 -04:00
Torsten Rasmussen 14b6314897 cmake: fixing toolchain_parse_make_rule to correctly handle \ files
Fixes: #37637

toolchain_parse_make_rule() parses depfiles and converted `\\` to the
CMake list separator `;`.

However, gcc -M might create depfiles with windows path separator `\`
causing this conversion to fail, as a path like:
c:\...\zephyr\samples\drivers\led_ws2812\nrf52-bindings.h

resulting in a file list as:
c:;...;zephyr;samples;drivers;led_ws2812;nrf52-bindings.h

which results in a CMake configure dependency to be added to `C:`.
As C: is always newer than the build.ninja file, this resulted in
continues CMake re-invocation.

As a small side-note, the `\` in file name did only occur in situations
where a relative past had been used elsewhere in the build system, such
as here:
https://github.com/zephyrproject-rtos/zephyr/blob/\
c3050a5aab1e86d02642eb4c6a027419e6a3a096/samples/drivers/led_ws2812/\
boards/nrf52dk_nrf52832.overlay#L9

To ensure proper handling of files, then all files are converted to
CMake paths, that is with forward slashes: `/`

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-09-11 04:49:38 -04:00
Martí Bolívar 8daf68ff6d cmake: allow users to give runner args at cmake time
If the BOARD_RUNNER_ARGS_${runner_id} variable contains anything, add
it to the global property of the same name with all the final runner
args from board_runner_args() and friends.

This allows use cases like this:

  west build ... -- -DBOARD_RUNNER_ARGS_jlink="--some-jlink-arg"

The ${runner_id} part is the runner's name converted to a C
identifier, i.e. with special characters changed to underscores.

So e.g. the 'dfu-util' runner would use BOARD_RUNNER_ARGS_dfu_util.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-09-09 21:22:16 -04:00
Andy Ross 0d763e0a10 cmake/compiler/xcc: sched: Support XCC inlining semantics
Cadence XCC is based off of a very old 4.2 gcc compiler, which didn't
perfectly support C99 "inline" semantics with respect to
cross-translation-unit inline linkage (which Zephyr does not use, our
inlines are static only) and declaration order.

Fix the one spot where we were calling an inline before its
ALWAYS_INLINE definition, and add a flag to suppress the warning so
CI's trying to build with XCC and -Werror don't flip out.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-09-08 09:28:31 -04:00
Torsten Rasmussen 153196b378 cmake: Zephyr ALLOW_EMPTY library property
This introduces a dedicated zephyr_library_property() function which
provides a common way to set Zephyr build system known properties on
Zephyr libraries.

As a first common property is the `ALLOW_EMPTY` property which allows
to create a `zephyr_library()` without putting any content inside of it.

In general libraries should not be created unless there are files to
places inside of it, however in some cases there are so many
`zephyr_library_sources_ifdef(<setting> <file.c>)`
where testing each setting before creating the library may not be
desired.

This commit allows the following construct in those cases:
```
zephyr_library()
zephyr_library_property(ALLOW_EMPTY TRUE)
zephyr_library_sources_ifdef(CONFIG_SETTING_1 file_1.c)
zephyr_library_sources_ifdef(CONFIG_SETTING_2 file_2.c)
...
zephyr_library_sources_ifdef(CONFIG_SETTING_n file_n.c)

```

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-09-07 11:42:47 +02:00
Neil Armstrong 538968a773 boards: fvp_base_revc_2xaemv8a: permit running Zephyr at EL1NS
It may be needed to run Zephyr at EL1NS level with `CONFIG_ARMV8_A_NS`
In order to run at EL1NS, you'll need a proper Firmware loaded in the
FVP model to run Zephyr at non-secure EL3.

The ARM TF-A for FVP can used to run Zephyr as preloaded BL33.

This adds the necessary cmake scripts to load the TF-A binaries and
load Zephyr as preloaded BL33 payload.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2021-09-06 14:11:32 -04:00
Torsten Rasmussen 7038c0909d cmake: remove deprecated set_conf_file() support
The `set_conf_file()` was deprecated in
6d4ba3490f

which is before Zephyr v1.14 LTS.
Let's remove the support now, before releasing a new LTS.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-09-03 07:20:17 -04:00
Jeremy Bettis 1fee4849bc cmake: Populate var CMAKE_GCOV
For each compiler, also set a CMAKE_GCOV var referencing the appropriate
gcov tool.

Tested with gcc and host-gcc on the ChromeOS codebase.

Signed-off-by: Jeremy Bettis <jbettis@chromium.org>
2021-09-02 19:44:00 -04:00
Evgeniy Paltsev 60fdec616b ARC: MWDT: get rid of MWDT startup libs
__cxa_atexit implementation provided by MWDT startup code calls
malloc which isn't supported right now. As we don't support
calling static destructors in Zephyr let's provide our own
__cxa_atexit stub and get rid of MWDT startup libs
entirely.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-09-01 17:08:32 -04:00
Martí Bolívar d98a15dbd2 cmake: extensions: fix copy/paste issues in DT error messages
These were copied from dt_reg_addr and not changed.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-31 19:06:33 -05:00
Stephanos Ioannidis 41fd6e003c arch: arm: aarch32: Add half-precision floating-point configs
This commit adds the half-precision (16-bit) floating-point
configurations to the ARM AArch32 architectures.

Enabling CONFIG_FP16 has the effect of specifying `-mfp16-format`
option (in case of GCC) which allows using the half-precision floating
point types such as `__fp16` and `_Float16`.

Note that this configuration can be used regardless of whether a
hardware FPU is available or supports half-precision operations.

When an FP16-capable FPU is not available, the compiler will
automatically provide the software emulations.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-08-30 18:17:47 +02:00
Torsten Rasmussen 36bb00d1f5 armclang: ARM Compiler C library support
Support for ARM Compiler C library.

This commit add support for the ARM Compiler C libary in:
- Kconfig
- libc/armstdc

A new Kconfig symbol is added to allow a toolchain to specify if they
support linking with the minimal C library.
Also the CMake variable `TOOLCHAIN_HAS_NEWLIB` is exported to Kconfig
so that CONFIG_NEWLIB_LIBS can only be enabled if the toolchain has
newlib.

The armclang toolchain selects the CMake scatter file generator and
disables support for the LD linker template which is not supported by
armlink.

For the ARM Compiler C library, a corresponding lib/libc/armstc/ folder
with a minimal implementation to work with the ARM Compiler C library
is added.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-30 08:54:23 -04:00
Torsten Rasmussen 28ba86d066 armclang: armlinker: armlink symbol steering file
This commit introduces armlink steering file.

A steering file in armlink allows Zephyr to keep using existing linker
symbols defined in ld scripts and used throughout the code tree.

The steering file is generated at build time in order to resolve Zephyr
linker symbols to their corresponding armlink symbols.

As example, Zephyr defines __ramfunc_start which corresponds to the
armlink auto defined Image$$ramfunc$$Base symbol.

Or __init_PRE_KERNEL_1_start which corresponds to Image$$init_0$$Base.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-30 08:54:23 -04:00
Torsten Rasmussen 5dfbd227a6 armclang: specify armlink link executable signature
The default armlink signature uses `--list=<TARGET_BASE>.map`, but in
Zephyr we uses a different name for the map file, therefore we need to
specify a custom link executable signature.

This is done in the linker specific flags file:
cmake/linker/armlink/linker_flags.cmake

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-30 08:54:23 -04:00
Torsten Rasmussen 93f0d0d528 armclang: warn on non-Ninja generator for CMake 3.20.
When using ARMClang linker and scatter files (armlink) then all
libraries are linked as object libraries using `$<TARGET_OBJECTS:lib>`.

CMake version 3.20 only has limited support for such linking:
> Referencing $<TARGET_OBJECTS> in target_link_libraries calls worked
> in versions of CMake prior to 3.21 for some cases, but was not fully
> supported.

One of those cases that do not work is Unix Makefiles generators.

As only Ninja is currently verified to work, this commit will check the
CMake version in use and the generator, and if CMake version <=3.21 is
used with non-Ninja generator then an error is raised informing user
to either use Ninja generator or update CMake.

As the Ninja generator has been confirmed to work as expected, then that
generator is accepted with CMake 3.20 and older.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-30 08:54:23 -04:00
Torsten Rasmussen 40a2ffd2ea armclang: support for armclang compiler and armlink linker
This is the initial support for the armclang compiler together with the
armlink linker.

Introduced in this commit:
- armclang compiler support
- armlink linker support
- armlink scatter file generator for scatter loading
- dual pass linker script generation

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-30 08:54:23 -04:00
Torsten Rasmussen 4de0d5511c armclang: bintools support for armclang (arm-ds/Keil)
Initial bintools support for elfconvert
- hex, srec, bin conversion
- strip
- gap fill

Initial bintools support for readelf
Initial bintools support for disaasembly

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-30 08:54:23 -04:00
Torsten Rasmussen 761eada9d3 kconfig: cmake: CMake linker script generator symbol added
A "Linker script" choice group has been added to the linker options
menu.

The existing HAVE_CUSTOM_LINKER_SCRIPT config has been relocated inside
the linker script menu.

Two new entries has been created:
- LD template, for using the old ld template files together with the C
  pre-processor to create the final linker script.
- CMake linker generator, used for ARMClang / armlink toolchain.
  The CMake linker generator is also supported for LD linker scripts
  for the ARM architecture.

In CMake, the file cmake/linker/ld/target.cmake has been updated to
support the CMake LD linker generator.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-30 08:54:23 -04:00
Torsten Rasmussen e9e47a45dd cmake: ld: adding ld linker script generator
Adding intial version of ld_script.cmake.

This script can generate ld linker script from the Zephyr CMake linker
functions.

This script is called by the build system and all linker settings, such
as memory regions, groups, output sections, linker symbols defined with
Zephyr CMake linker functions are passed to this script in order to
generate an ld linker script.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-30 08:54:23 -04:00
Torsten Rasmussen 02fb26dd44 cmake: ld: adding common linker script generator
Adding intial version of linker_script_common.cmake.

This script parses memory regions, groups, sections, settings, and
symbols defined in the Zephyr CMake build system.

The linker script creates objects for each type above and groups
sections, symbols, and groups together based on their configuration.

This creates a hierarchy which the `<linker>_script.cmake`
implementations can then use during linker script generation.

linker_script_common.cmake also provides stubs for <type>_to_string()
functions which are used when generating the output script.

Each specific `<linker>_script.cmake` must implement those to_string()
functions to create the final linker script.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-30 08:54:23 -04:00
Torsten Rasmussen 450b9fa9bc cmake: linker: arm: memory regions from devicetree added
This commit add devicetree memory regions added to arm/linker.cmake.

The following memory regions are now added to the generated linker
script and scatter file if they exists in the devicetree.
- chosen:    zephyr,itcm
- chosen:    zephyr,dtcm
- nodelabel: ti_ccfg_partition
- nodelabel: sram1
- nodelabel: sram2
- nodelabel: sram3
- nodelabel: sram4
- nodelabel: sdram1
- nodelabel: sdram2
- nodelabel: backup_sram

Also support for the itcm and dtcm section and their placement in
corresponding memory regions has been added.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-30 08:54:23 -04:00
Torsten Rasmussen c2842c388d cmake: linker: arm: adding Zephyr CMake linker files for arm arch
This is the initial version of a Zephyr CMake linker file for the arm
architecture.

This file defines memory regions, groups, linker sections and symbols
for the arm architecture.

It also sources the common common-ram.cmake, common-rom.cmake,
debug-sections,cmake, and thread-local-storage.cmake.

It configure sections for SoC families using zephyr_linker_sources()
functions:
- nxp_imx

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-30 08:54:23 -04:00
Torsten Rasmussen 38040292c3 cmake: linker: converter arm and common ld scripts into CMake code
Converted existing ld script templates into CMake files.

This commit takes the common-ram.ld, common-rom.ld, debug-sections.ld,
and thread-local-storage.ld and creates corresponding CMake files for
the linker script generator.

The CMake files uses the new Zephyr CMake functions:
- zephyr_linker_section()
- zephyr_linker_section_configure()
- zephyr_linker_section_obj_level()

to generate the same linker result as the existing C preprocessor based
scheme.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-30 08:54:23 -04:00
Torsten Rasmussen 90e7078fa8 cmake: CMake devicetree related linker functions implemented
This commit introduces zephyr_linker_dts CMake functions for creation of
linker scripts based on devicetree nodes.

The linker devicetree functions supports the following features:
- Configuration of memory sections based on devicetree nodes

Overview of functions introduced with this commit:
- zephyr_linker_dts_memory

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-30 08:54:23 -04:00
Torsten Rasmussen a7d2fd9fb6 cmake: CMake linker functions implemented
This commit introduces zephyr_linker CMake functions for creation of
linker scripts.

The linker functions supports the following features:
- Configuration of memory sections
- Configuration of memory groups
- Creation of output sections
- Configuration of input section the should go into output section and
  how those should be treated, such as sorting, keep, priority.
- Defining linker symbols
- Specifying Kernel VMA to support virtual linking on x86

Overview of functions and macros introduce with this commit:
- pow2round
- zephyr_linker
- zephyr_linker_memory
- zephyr_linker_memory_ifdef
- zephyr_linker_group
- zephyr_linker_section
- zephyr_linker_section_ifdef
- zephyr_iterable_section
- zephyr_linker_section_obj_level
- zephyr_linker_section_configure
- zephyr_linker_symbol
- zephyr_linker_property_append

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-30 08:54:23 -04:00
Torsten Rasmussen c9804d24fe scripts: gen_handles.py: take device start symbol as argument.
The current gen_handles.py script uses linker defined symbols.
As preparation for support of more linkers the gen_tables.py now takes
the device start symbol as argument.

For example, armlink and ld uses different symbols.
With ld those can be named explicitly, but for armlink the linker
decides the names.

For ld, Zephyr defines: __device_start
For armlink, the symbol is defined as: Image$$<section name>$$Base

Therefore knowledge of the linker symbol to be used must be passed to
gen_handles.py so that the correct symbol can be used for locating
devices.

To support this change, the creation of the asm, compiler, compiler-cpp,
linker targets has been moved from target_toolchain_flags.cmake to
target_toolchain.cmake.

All linkers has been updated to support the use of the
device_start_symbol on the linker target.

List of linkers updated:
- ld
- lld
- arcmwdt

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-30 08:54:23 -04:00
Iuliana Prodan e310367c09 cmake: add support for NXP i.MX
Xtensa GCC needs a different toolchain per SOC,
so add support for i.MX8.
If SOC_SERIES is imx8, that's for i.MX8QM and
i.MX8QXP.
If SOC_SERIES is imx8m, that's for i.MX8MP.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
2021-08-28 23:27:02 -04:00
Gerson Fernando Budke c3db83ba58 scripts: runners: openocd: Enable thread awareness
Zephyr thread awareness is available for openocd but boards don't
have debuggers configuration.  This configure OpenOCD runner
automatically to complete configuration.

User still require enable CONFIG_DEBUG_THREAD_INFO=y to visualize
thread debug information.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2021-08-27 06:44:45 -04:00
Daniel Leung 2117a2a44b kernel: app_smem: allowing pinning memory partitions
This allows memory partitions to be put into the pinned
section so they are available during boot. For example,
the stack guard (in libc partition) is needed during boot
but before the paging mechanism is initialized. Without
pinning it in physical memory, it would fault in early
boot process.

A new cmake property app_smem,pinned_partitions is
introduced so that additional partitions can be pinned
if needed.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-26 21:16:22 -04:00
Helge Juul 8749cd4d76 kconfig: Add option for encryption of binaries
Introduce new Kconfig option MCUBOOT_ENCRYPTION_KEY_FILE. If the
string is not empty Cmake will try to encrypt the final binaries using
the given key file.

Signed-off-by: Helge Juul <helge@fastmail.com>
2021-08-26 21:15:54 -04:00
Stephanos Ioannidis 52b2d39b6a cmake: extensions: Add corresponding ifndef for all ifdef functions
This commit adds the corresponding '_ifndef' functions for all the
existing '_ifdef' functions.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-08-25 22:08:01 -04:00
Stephanos Ioannidis 877239abfe cmake: extensions: Move ifndef functions to correct location
This commit moves the '_ifndef' functions that are implemented in the
"3.1. *_ifdef" section to the "3.2. *_ifndef" section.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-08-25 22:08:01 -04:00
Torsten Rasmussen fcf720941f cmake: dts: import devicetree symbols into CMake
This commit introduces devicetree API in CMake so that devicetree
properties and register block can be used in the CMake build system.

The script scripts/dts/gen_dts_cmake.py processes the edt.pickle and
generates a corresponding devicetree property map in a devicetree_target
that is then used in CMake.

The following devicetree API has been made available in Zephyr CMake:
- dt_nodelabel(<var> NODELABEL <label>)
- dt_node_exists(<var> PATH <path>)
- dt_node_has_status(<var> PATH <path> STATUS <status>)
- dt_prop(<var> PATH <path> PROPERTY <prop>)
- dt_prop(<var> PATH <path> INDEX <idx> PROPERTY <prop>)
- dt_num_regs(<var> PATH <path>)
- dt_reg_addr(<var> PATH <path> [INDEX <idx>])
- dt_reg_size(<var> PATH <path> [INDEX <idx>])
- dt_has_chosen(<var> PROPERTY <prop>)
- dt_chosen(<var> PROPERTY <prop>)

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-25 20:28:26 -04:00
Jingru Wang cd87366016 cmake: emu: nsim: Allow all nsim platform use mdb
Currently the default runner of nsim_hs_smp is mdb,
the runner of other nsim platform is nsimdrv, user
can't change the default runner unless he uses
west command(--runner).

With this change cmake will choose runner according
to BOARD_DEBUG_RUNNER or BOARD_FLASH_RUNNER. so if
add -DBOARD_FLASH_RUNNER=mdb-nsim or
-DBOARD_DEBUG_RUNNER=mdb-nsim to cmake command,
the apllication will be run with mdb.

Signed-off-by: Jingru Wang <jingru@synopsys.com>
2021-08-24 07:22:22 -04:00
Evgeniy Paltsev d8590d7e2b ARC: MWDT: fix include path for the case of C/C++ lib usage
Fix include path of headers provided by MWDT toolchain for the
case of MWDT C/C++ lib usage.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-08-21 21:33:18 -04:00
Evgeniy Paltsev b82ffbd860 ARC: MWDT: add C++14, C++17 standards support
Add missing properties for C++14, C++17 standards support

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-08-21 21:33:18 -04:00
Evgeniy Paltsev 357694e307 ARC: MWDT: use LLVM C++ library instead of MWDT one
The MWDT toolchain provides two C++ libraries. Let's use
LLVM C++ library.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-08-21 21:33:18 -04:00
Martí Bolívar 66a64c35b1 cmake: dts: give each DTS_ROOT a vendor-prefixes.txt
Now that the infrastructure we need is in place, we can allow every
element of DTS_ROOT to have its own dts/bindings/vendor-prefixes.txt
file instead of just special-casing ZEPHYR_BASE (which is always in
DTS_ROOT).

This treats all modules equally and eases out of tree management of
downstream-specific vendor prefixes.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-20 18:57:30 -04:00
Martí Bolívar a417983507 cmake: dts: refactor DTS_ROOT loop
It's a bit weird to loop over the same list twice like this.
Just unify the two loops into one.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-20 18:57:30 -04:00
Torsten Rasmussen 8c31f31143 Revert "cmake: manual handling of CMakeCheckCompilerFlag.cmake inclusion"
With the change to cmake_minimum_required(VERSION 3.20.0) then this
commit is no longer needed.

This reverts commit 6ca2bf25cb.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-20 09:47:34 +02:00
Torsten Rasmussen 1cccc8a8fe cmake: increase minimal required version to 3.20.0
Move to CMake 3.20.0.

At the Toolchain WG it was decided to move to CMake 3.20.0.

The main reason for increasing CMake version is better toolchain
support.

Better toolchain support is added in the following CMake versions:
- armclang, CMake 3.15
- Intel oneAPI, CMake 3.20
- IAR, CMake 3.15 and 3.20

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-20 09:47:34 +02:00
Daniel Leung 2a50386a39 cmake: add zephyr_library_include_directories_ifdef()
The zephyr_library_* variant is missing the ability to
include directories based on kconfig. So add the function.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-17 06:06:03 -04:00
Stephanos Ioannidis 6df8f7e435 arch: arm: cortex_m: Add ARMv8.1-M MVE configs
This commit adds the ARMv8.1-M M-Profile Vector Extension (MVE)
configurations as well as the compiler flags to enable it.

The M-Profile Vector Extension consists of the MVE-I and MVE-F
instruction sets which are integer and floating-point vector
instruction sets, respectively.

The MVE-I instruction set is a superset of the ARM DSP instruction
set (ARMv7E-M) and therefore depends on ARMV8_M_DSP, and the MVE-F
instruction set is a superset of the ARM MVE-I instruction set and
therefore depends on ARMV8_1_M_MVEI.

The SoCs that implement the MVE instruction set should select the
following configurations:

  select ARMV8_M_DSP
  select ARMV8_1_M_MVEI
  select ARMV8_1_M_MVEF (if floating-point MVE is supported)

The GCC compiler flags for the MVE instruction set are specified
through the `-mcpu` flag.

In case of the Cortex-M55 (the only supported processor type for
ARMv8.1-M at the time of writing), the `-mcpu=cortex-m55` flag, by
default, enables all the supported extensions which are DSP, MVE-I and
MVE-F.

The extensions that are not supported can be specified by appending
`+no(ext)` to the `-mcpu=cortex-m55` flag:

  -mcpu=cortex-m55           Cortex-M55 with DSP + MVE-I + MVE-F
  -mcpu=cortex-m55+nomve.fp  Cortex-M55 with DSP + MVE-I
  -mcpu=cortex-m55+nomve     Cortex-M55 with DSP
  -mcpu=cortex-m55+nodsp     Cortex-M55 without any extensions

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-08-14 20:29:57 -04:00
Evgeniy Paltsev 33d5be8656 ARC: MWDT: generate access to builtin funcs only if ARCMWDT_LIBC is used
The MWDT compiler can replace some code with call to builtin
functions. We can't rely on these functions presence if we
don't use MWDT libc.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-08-13 13:43:19 -05:00
Evgeniy Paltsev 22e0bef358 ARC: MWDT: link mwdt libc only if it is required
We don't need MWDT libc if we are using minimal one provided by
Zephyr. So let's avoid linking mwdt libc if CONFIG_MINIMAL_LIBC
is enabled.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-08-13 13:43:19 -05:00
Evgeniy Paltsev cfed6428f4 ARC: MWDT: don't link MetaWare hostlink lib ever
MetaWare hostlink is a library of system calls for debugging.
We don't use in case of Zephyr, however we provide real system
calls implementations. Let's pass -Hhostlib= to MWDT linker to
eliminate the MetaWare hostlink library from linkage.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-08-13 13:43:19 -05:00
Torsten Rasmussen eecc0961b6 cmake: dts: removing generated <board>.dts_compiled
The file <board>.dts_compiled was made obsolete in 8d8b06978c.

<board>.dts_compiled contains only a reference to zephyr.dts.

Users interested in devicetree should be familiar with zephyr.dts,
therefore it's time to remove the unused <board>.dts_compiled.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-11 11:16:18 -04:00
Chen Peng1 ce7ebb0821 tests: add a test to verify UEFI boot on x86_64 targets.
add a config CONFIG_QEMU_UEFI_BOOT to indicate whether
the qemu will use UEFI bootable method;
add a new test "sample.basic.helloworld.uefi" to verify
UEFT bootable method on qemu_x86_64 platform.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2021-08-11 11:46:13 +02:00
Martí Bolívar 361956b669 cmake: add a comment header to zephyr_settings.txt
I saw a user wondering what this is for and and where it comes from.
Provide a comment header with some explanation and a pointer to where
to find out more.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-10 07:37:19 -04:00
Evgeniy Paltsev 497cb2e587 CPP: fix static objects init for MWDT toolchain
The constructors of static objects are stored in ".ctors"
section. In case of MWDT toolchain we have incompatible
".ctors" section format with GNU toolchain. So let's use
initialization code provided by MWDT instead of Zephyr one
in case of MWDT toolchain usage.

As it is done for GNU toolchain We call constructors of
static objects but we don't call destructors for them.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-08-09 22:47:22 -04:00
Stephanos Ioannidis b973cdc9e8 cmake: Set minimum required Zephyr SDK version to 0.13
In order to use the newlib retagetable locking interface (for thread
safety), which requires the newlib multi-threading feature to be
enabled, the Zephyr SDK 0.13.0 or above must be used.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-08-09 08:51:24 -05:00
Evgeniy Paltsev 37a14c7e39 ARC: add nsim_hs6x_smp board with 2 cores ARCv3 HS6x
Add nsim_hs6x_smp simulation board (nSIM based) with
2 cores ARCv3 HS6x CPU.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-08-07 20:36:23 -04:00
Fabio Baltieri ef93bbad57 linker: add an initialized DATA_SECTIONS linker location option
Current location options for linker source files includes init and
noinit ram data, but only a noinit ram section. This makes it impossible
for application code to define an initialized RAM output section,
such as with the Z_ITERABLE_SECTION_RAM() helpers.

Adding a DATA_SECTIONS linker source option for this use case.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2021-08-07 20:26:41 -04:00
Martí Bolívar f261d77c75 cmake: dts: warn on unrecognized vendor prefixes
This uses the list of vendor prefixes provided by the user by default.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-03 12:21:45 -05:00
Glauber Maroto Ferreira ed63e2a562 soc: esp32s2: add initial soc support files for esp32s2
by adding specific soc files for esp32s2 bring-up, such as:
- linker script
- soc initialization code
- initial device tree source files
- esp32s2 saola board support.

Signed-off-by: Glauber Maroto Ferreira <glauber.ferreira@espressif.com>
2021-07-28 21:09:27 -04:00
Chen Peng1 fbe13b7bc2 cmake: oneApi: add oneApi support on windows.
add .S file extension suffix into CMAKE_ASM_SOURCE_FILE_EXTENSIONS,
because clang from OneApi can't recongnize them as asm files on
windows, then they won't be added into build system.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2021-07-27 07:20:12 -04:00
Chen Peng1 98f324000c cmake: oneApi: add oneApi support on windows
The icx compiler of oneApi will invoke clang-cl on windows,
this is not supported in zephyr now, so change to use
clang directly.
And the clang from oneApi can't recognize those cross
compiling target variables of cmake, such as
CMAKE_C_COMPILER_TARGET, so used other cmake functions
to pass them to clang.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2021-07-27 07:20:12 -04:00
Daniel Leung 70d0077574 cmake: don't enable color diagnostics for xcc
The compiler option "-fdiagnostics-color=always" is not known to XCC
(which is based on really old GCC). So don't enable color
diagnostic output when building with XCC.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-07-22 15:41:11 +03:00
Anas Nashif 7a2266d5f5 build: reports: publish all reports
Publish all reports in json format.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-07-21 14:54:30 +03:00
David Palchak ac85886070 toolchain: linker: Add kconfig header to link script generation
Add auto-generated kconfig header to linker script pre-processing
via -imacros flag. This permits link scripts supplied via
zephyr_linker_sources() to use CONFIG_* variables.

Signed-off-by: David Palchak <palchak@google.com>
2021-07-21 07:43:13 -04:00
Alexander Wachter ad130f2661 cpp: Restore C++2A Kconfig
Restore the legacy C++2a Kconfig for compilers that
do not support C++20.

Signed-off-by: Alexander Wachter <alexander.wachter@leica-geosystems.com>
2021-07-14 07:19:43 -04:00
Torsten Rasmussen ccdb3f89cc cmake: extended zephyr_library_amend description with an extra example
Add some more example to the description of zephyr_library_amend().
This should help users to get input of the extra possibilities that this
function provides.

See: #35770

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-07-12 20:07:16 -04:00
Evgeniy Paltsev 46b2df2b75 ARC: MWDT: don't use compact C library
-Hcl option instructs linker to use MetaWare C Compactlib.
According to MWDT documentation "Compactlib is not thread-safe"

So, let's use MetaWare C library instead which is thread-safe.

Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-07-10 12:42:45 -04:00
Ioannis Glaropoulos 102fd5d41c arm: cortex-m: add FPU option for v8.M without DSP
With respect to the mapping between the CPU variant
and the FPU we add an entry for Cortex-M v8-M CPU
variants without DSP. This should cover the case
of a Mainline Cortex-M which implements the Floating
Point extension but not the DSP extension.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-06-22 08:45:41 -04:00
Stephanos Ioannidis 1836f10bb7 cmake: ld: Disable manual linking of libgcc components for host
When the host toolchain is used, `-nostdlib` option is not specified
and therefore all default libraries, including the libgcc and its
components, are automatically linked -- so it is not necessary to
manually link them here.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-06-16 18:35:54 +02:00
Stephanos Ioannidis 733240378e cmake: host-gcc: Remove libgcc library path resolution
The host toolchain makes use of the host toolchain libraries (i.e.
`-nostdlib` is not specified), so it is not necessary to detect the
toolchain libgcc path and specify one manually.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-06-16 18:35:54 +02:00
Stephanos Ioannidis ccda920c28 cmake: host-gcc: Detect libgcc for all archs
This commit updates the build system to always detect the libgcc path
for the host platforms regardless of the target architecture.

The native_posix_64 target previously used the x32 ABI (`-mx32`) and
the multilib for this ABI was not commonly available in the x86-64 host
toolchains.

That is no longer the case because native_posix_64 had been updated to
use the x86-64 ABI (`-m64`).

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-06-16 18:35:54 +02:00
Stephanos Ioannidis 010a95c2d0 cmake: gcc: Remove no_libgcc exclusion for libgcc detection
This commit removes the `NOT no_libgcc` condition for the automatic
libgcc path detection.

The `no_libgcc` variable was previously set in this file to exclude
libgcc detection for the x86-64 targets because the x86-64 arch used
x32 ABI (`-mx32`) and the multilib for this ABI was not commonly
available. This is no longer the case (x86-64 targets now use `-m64`)
and libgcc must always be available.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-06-16 18:35:54 +02:00
Torsten Rasmussen 2f7ede5ab5 cmake: set CMP0116 policy to old, Ninja DEPFILE behaviour
Fixes: #36185

CMake >=3.20 now supports relative paths in Ninja depfiles.

As Zephyr still supports the use of CMake 3.13, and the current use of
DEPFILE in linker/ld/target.cmake is already absolute path, then the
safest choice is to use old behavior.
This can be changed when Zephyr increases minimum required CMake to be
3.20 or newer.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-06-16 10:42:01 +02:00
Torsten Rasmussen 6be1b2af9b kconfig: soc and shield cleanup
Always source the Zephyr base soc and shield (board root) Kconfigs
directly from Kconfig instead of generated Kconfig files.

This has the benefit that it is no longer necessary to generate Kconfig
files to source SoC root and shield (board root) when no custom roots
are provided.

Also this cleans up the doc/CMakeLists.txt and ensures that the
doc/CMakeLists.txt is not getting out of sync with the Kconfig.cmake.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-06-11 16:13:22 +02:00
Dino Li 2bf63134e8 arch: riscv: linker script: add support for rom_start section
With this change, we can put contents into rom_start section
by calling zephyr_linker_sources(ROM_START ...)

Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Co-authored-by: Torsten Tejlmand Rasmussen
Change-Id: If1169423b013d3e4df52d91cdb2fbdddc3bace7b
2021-06-04 16:31:00 -05:00
Daniel Leung 72c2f182bc cmake: force GCC to emit DWARF version 4
GCC 11 defaults to output DWARF version 5 which pyelftools cannot
currently parse. So keep output at version 4 for the time being.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-06-04 16:22:03 -05:00
Torsten Rasmussen 489a69c092 cmake: support ZephyrBuildConfiguration_ROOT for package location
Fixes: #35890

The current implementation of Zephyr build configuration CMake package
only allows the build configuration package to be placed inside a
Zephyr workspace.

This commit extends the usability by allowing users to locate the
Zephyr build configuration CMake package outside the Zephyr workspace
and then refer to the package using
`-DZephyrBuildConfiguration_ROOT=<path>`
`set(ZephyrBuildConfiguration_ROOT <path>)`

This allows users greater flexibility in their workspace layouts.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-06-04 12:50:28 -05:00
Torsten Rasmussen 86c92869d2 cmake: warn the user if a Zephyr library is created in app-mode
Fixes: #19582

When `find_package(Zephyr)` completes then all boilerplate code has been
processed and all Zephyr libraries has been placed inside the
whole archive flags.

Also all libs dependencies has been processed.

This is indicated by the presence of the zephyr_prebuilt target.

Thus, warn the user if `zephyr_library()` / `zephyr_library_named()`
is called in app-mode.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-06-03 08:34:19 -05:00
Daniel Leung d475f9865b scripts: size_report: add tree node for WORKSPACE
Add a tree node to group files under WORKSPACE so that
they won't be shown with full path. The WORKSPACE is
usually the same as WEST_TOPDIR unless ZEPHYR_WORKSPACE
is defined during build.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-05-27 15:23:48 +02:00
Torsten Rasmussen 7d37fe21d1 cmake: c++ exceptions linking support
Fixes part of: #32448

This commit updates the CMake CMAKE_CXX_LINK_EXECUTABLE to include
crtbegin.o and crtend.o at the right locations when linking with gcc.

It also updates linker scripts to ensure proper location of the
exception header frame sections.

This ensure proper handling of exceptions for those architectures
- x86
- xtensa
- riscv32

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-05-27 07:43:28 -05:00
Carlo Caione 835ff89c40 cmake: arm64: Bail out if the old SDK is used
After the ARM/ARM64 split the SDK 0.12.4 is needed to be able to compile
the ARM64 arch code. Bail out if an old SDK is detected at compile time.

Also change the minimal supported Zephyr SDK to v0.12, as agreed in
Toolchain WG.  Main reason is added compiler architectures and important
inclusion of fixes, for example qemu and arm fixes for veneers (TFM)

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-05-26 18:15:08 -05:00
Evgeniy Paltsev 18a24c3f6f ARC: gcc-m-cpu: use -mcpu=archs as a default for ARCv2 HS
Due to the fact that we use -mcpu=hs as a default for ARCv2 HS
the compiler doesn't generate multiply/divide/mac/64bit memory
operations instructions.

Fix that by using -mcpu=archs as a default for ARCv2 HS which is
fits for all existing boards with ARCv2 HS CPU.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-05-26 18:13:30 -05:00
Torsten Rasmussen 39f06e0195 ld.bfd: ensure that ld.bfd is preferred over ld.
Fixes: #32237

When building for native_posix, then host tools are used.
This means that gcc will link using `/usr/bin/ld` per default.

If ld points to lld, then linking will fail.

This commit will first look for ld.bfd, and if found then use
-fuse-ld=bfd for linking. If ld.bfd is not found, then ld is used as
fallback as that will be assumed to be the best working candidate.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-05-26 10:54:45 -05:00
Jennifer Williams 9b2d8e8226 cmake: extensions.cmake: use blocklist instead in comment
There is a comment which needed to be rephrased for inclusive
language. This commit replaces it with the recommended
replacement.

Signed-off-by: Jennifer Williams <jennifer.m.williams@intel.com>
2021-05-24 23:16:28 -04:00
Lauren Murphy e6b8c50599 samples: tensorflow: add no-threadsafe-statics to compiler flags
Adds no-threadsafe-statics to compiler flags for gcc and arcmwdt.

The flag is required to compile the samples - the module can compile
without it.

Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
2021-05-20 20:59:45 -04:00
Torsten Rasmussen 2a74dc26de cmake: cleanup version printing during CMake configure time
Follow-up: #34842

This is a follow-up commit that ensures relevant version information
regarding the build is located together as discussed in #34842.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-05-07 20:50:02 -04:00
Torsten Rasmussen 8ff65f4087 cmake: get: using NOT DEFINE BUILD_VERSION instead of NOT BUILD_VERSION
If user is specifying `-DBUILD_VERSION=<value>` then the proper way to
test is using `NOT DEFINED BUILD_VERSION`.

The difference between `NOT DEFINED BUILD_VERSION` and
`NOT BUILD_VERSION` is that a user specifying `-DBUILD_VERSION=0` will
result in `NOT BUILD_VERSION` becoming true, whereas
`NOT DEFINED BUILD_VERSION` would be false, which is the correct
behavior here, as the user actually provided a specific BUILD_VERSION.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-05-07 20:50:02 -04:00
Evgeniy Paltsev 359f3494a3 ARC: ARCv3: add nsim_hs6x board
Add nSIM-based (simulator) board with single core ARCv3 HS6x 64 bit
CPU.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-05-07 14:55:49 -05:00
Evgeniy Paltsev 6afe7c5fd2 ARC: prepare for building for ARCv3 HS6x
Do basic preparations for building code for ARCv3 HS6x
* add ISA_ARCV3 and CPU_HS6X config options
* add off_t type support for __ARC64__
* use elf64-littlearc format for linking
* use arc64 mcpu for CPU_HS6X

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-05-07 14:55:49 -05:00
Evgeniy Paltsev 8ed87be4ff ARC: gcc-m-cpu: check for exact HS CPU time instead of whole family
As of today we check against CPU_ARCHS config option which may be
related to different HS CPUs (i.e. ARCv2 HS, ARCv3 HS, etc...).
Let's check against exact HS CPU type (CPU_HS3X) as we do EM
processors.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-05-07 14:55:49 -05:00
Marc Herbert 4ea66b32fa git.cmake: git describe --always to support shallow clones
There's no reason for BUILD_VERSION to work only when there are git
tags.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-05-06 16:30:15 -05:00
Marc Herbert 654a2f245d git.cmake: print BUILD_VERSION always, simplify and fix error message
In an ideal world, good CIs make it very clear what exact git versions
are getting built. However:

- Zephyr is (re-)used in many projects and they cannot all be expected
  to have ideal CI.

- CI with multiple git repos is complex (#34713) which makes the world
  an even less ideal place: much more chance for some git versions to be
  missing.

- Many developers don't realize that Github and other CIs do not test
  pull/12345/head but the moving target pull/12345/merge instead. While
  not resolving pull/12345/merge completely (maybe another day), this
  commit provides at least evidence that pull/12345/head is NOT the
  commit tested.

So the addition of the following line in the logs is a very small price
to pay that can save enormous amounts of time when trying to understand
some obscure build failures.

-- BUILD_VERSION=zephyr-v2.5.0-2957-g6230b5bb66bc

Note this obviously does not provide any git information when
BUILD_VERSION is overriden but it does not hurt either in this case:
knowing BUILD_VERSION was overriden is also useful.

The "BUILD_VERSION is left undefined" message was just wrong in
the (unlikely) case `git describe` printed something while also
failing. Remove it; it's so much simpler to just print $BUILD_VERSION
and give the direct, unfiltered information.

Note this simplification is also a partial revert of 1b80f00f56
which threw the entire git warnings "baby" with some obscure duplicate
1.13.0 "bathwater" that is not relevant any more and that I guess barely
anyone noticed even at the time.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-05-06 16:30:15 -05:00
Torsten Rasmussen 5db987f922 cmake: use WEST_PYTHON as a preferred python installation if defined.
Fixes: #34368

Now added WEST_PYTHON to list of preferred pythons to check.
WEST_PYTHON is added after PYTHON_PREFER so that a user may still
request a specific python is used by supplying
`-DPYTHON_PREFER=<python>` even when building using `west build`.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-04-27 13:31:23 -04:00
Anas Nashif 29d35ced53 cmake: llvm: llvm has no newlib
llvm does not have newlib integrated for all architectures.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-04-22 07:42:58 -04:00
Torsten Rasmussen 3dd65a7663 runners: remove dependencies from runners
Today, there is a build target is added for each runner: flash, debug,
debugserver, attach.

And those runners will have a dependency to Zephyr logical target that
is built before invoking `west <runner>`.

This design has some flaws, mainly that additional dependencies directly
on the target will not be built when running `west <runner>` directly.
That generator expressions cannot be used for the DEPENDS argument.

Instead, the build target `<runner>` will not have any dependencies, and
will raise a build error if a dependency is added to the target.
Due to how `add_dependencies()` work, this must be done as a build time
check, and not configure time check.

`west <runner>` will invoke a build before executing the runner, and
this way ensure the build target is up-to-date, which again removes the
need for a dedicated `west_<runner>_target`.

It also minimizes the risk of developer errors, as developers no longer
need to consider the need for adding additional dependencies.
If a custom target is part of the default `all` build, then it's ensured
to be up-to-date.

Fixes: Issue reported on slack.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-04-19 15:35:30 +02:00
Flavio Ceolin 10fc05ced6 toolchain: llvm: Find strip command
Some targets require *strip* command. This command was not
being set when selecting llvm toolchain.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-04-17 21:03:13 -04:00
Arvin Farahmand b8f5968a42 cmake: gcc/clang: enable colour diagnostics in terminal output
When compiler results are piped through a non-terminal (e.g. ninja)
the compiler disables colour diagnostics. Using `-fdiagnostics-color`
forces the compiler to enable colour output. This flag is set for
clang and gcc when `ZEPHYR_BUILD_COLOUR_DIAGNOSTIC` environment
variable is set when a clean build is started.

Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
2021-04-16 12:20:53 +02:00
Detlev Zundel f1f5f607b2 scripts: size_report: Add a depth parameter to CMakeLists.txt
The parameter can be used to limit the ram and rom reports to a
certain depth.  The resulting graphs with depths of e.g. 3 or 4 are
visually easier to grasp.

Signed-off-by: Detlev Zundel <dzu@member.fsf.org>
2021-04-14 07:05:58 -04:00
Jaxson Han 72287491df cmake: arm64: Add Cortex-R82 in toolchain option
Use -march=armv8.4-a to compile zephyr on cortex-R82.
Because Cortex-R82 has not been enabled in GCC 10.x currently.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
2021-04-13 07:47:44 -04:00
Jaxson Han 8af11d40d0 cmake: emu: Add arm fvp emulator
Add arm fvp emulator in order to use ninja run or west build -t run.
Add armfvp in order to run twister.

Set env ARMFVP_BIN_PATH before using it,
e.g. export ARMFVP_BIN_PATH=<path/to/fvp/dir>
NOTE: ARMFVP_BIN_PATH is the dir path.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
2021-04-13 07:47:44 -04:00
Anas Nashif 11e44627e9 cmake: fix isystem_include_dir path for windows
The system include directory might include spaces on windows, so quote
it.

Partially part of fix for #32111

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-04-02 13:36:49 -04:00
Christian Taedcke ea46c7a1a0 cmake: kconfig: Remove unused extra dtc flags
The usage of EXTRA_DTC_FLAGS was removed in commit
269f350487

If ninja was used and e.g. menuconfig is called, when more than one
element is in EXTRA_DTC_FLAGS, calling "ninja menuconfig" failed.

E.g.
west build -b lpcxpresso55s28_ns -t menuconfig samples/hello_world
resulted in and error. This is fixed with this commit.

Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
2021-04-01 07:31:50 -05:00
Rafał Kuźnia e68cfb5683 cmake: allow binary directory to be specified
Extend the add_subdirectory_ifdef extension to allow specifying
the binary directory.

Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
2021-04-01 14:08:08 +02:00
Nicolas Pitre 5a1d069ae7 cmake: pick up some crumbs after the arm/arm64 split
Pick up some crumbs after the arm/arm64 split.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2021-04-01 01:03:04 -05:00
Carlo Caione 3539c2fbb3 arm/arm64: Make ARM64 a standalone architecture
Split ARM and ARM64 architectures.

Details:

- CONFIG_ARM64 is decoupled from CONFIG_ARM (not a subset anymore)
- Arch and include AArch64 files are in a dedicated directory
  (arch/arm64 and include/arch/arm64)
- AArch64 boards and SoC are moved to soc/arm64 and boards/arm64
- AArch64-specific DTS files are moved to dts/arm64
- The A72 support for the bcm_vk/viper board is moved in the
  boards/bcm_vk/viper directory

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-03-31 10:34:33 -05:00
Anas Nashif 1bb4e71bf2 toolchain: add support Intel oneApi toolchain based on llvm
This adds preliminary support for the oneApi toolchain for X86. The
toolchain is available from here:

   https://software.intel.com/content/www/us/en/develop/tools/oneapi/base-toolkit/download.html

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-03-25 08:54:10 -04:00
Anas Nashif 1d949ee20f cmake: llvm: use lld
Use lld linker instead of ld.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-03-25 08:54:10 -04:00
Anas Nashif 22c1c505c4 cmake: bintool: add llvm abstraction
Based on abstraction for gcc with slight modifications.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-03-25 08:54:10 -04:00
Kumar Gala 95e4b3eb2c arch: arm: Add initial support for Cortex-M55 Core
Add initial support for the Cortex-M55 Core which is an implementation
of the Armv8.1-M mainline architecture and includes support for the
M‑profile Vector Extension (MVE).

The support is based on the Cortex-M33 support that already exists in
Zephyr.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-23 13:13:32 -05:00
Torsten Rasmussen 41e283c262 cmake: move the BOARD variable watch below deprecated board handling
Fixes: #33138

Board alias and deprecated board handling is setting the BOARD variable
after zephyr_boilerplate_watch(BOARD) has been executed.

This results in the board changed warning.

This commit moves the zephyr_boilerplate_watch(BOARD) code below the
board alias and deprecation handling.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-03-18 10:20:41 +01:00
Watson Zeng 1b99f0e67f linker: arcmwdt: use preprocess opiton -E.
-P is an option that was inherited from the old MetaWare compiler.
[ccac foo.c -P] is actually a shortcut for: [ccac -E foo.c -o foo.i].
In new version of mwdt, -P option can't redirect the output. we need
to use -E option, which works in all versions.

-P:  Preprocess the file and write it to <src>.i (C) or
      <src>.ii(C++). No compilation is performed.

-E:  Run preprocessor only.

Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
2021-03-17 15:29:43 -04:00
Torsten Rasmussen 6360593f99 cmake: west: do not print error if west topdir fails
`west` is an optional tool.
Although `west` is optional, a developer might be working with both west
and non-west based projects, like
- vanilla Zephyr (using west)
- downstream project (not using west)

and thus have west installed, but not always in use.

In the downstream project scenario not using west, then running CMake
will print the following error:
```
FATAL ERROR: no west workspace found from "<path>/zephyr";
"west topdir" requires one.
Things to try:
  - Change directory to somewhere inside a west workspace and retry.
  - Set ZEPHYR_BASE to a zephyr repository path in a west workspace.
  - Run "west init" to set up a workspace here.
  - Run "west init -h" for additional information.
```

This commit sets `WEST` CMake variable to `WEST-NOTFOUND` when west is
found but Zephyr is not in a west workspace (`west topdir` fails)

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-03-17 11:28:14 +01:00
Torsten Rasmussen ffff2124d3 cmake: zephyr_file() now accepts BOARD and BOARD_REVISION as argument
With the introduction of #32556 changing the BOARD now prints a warning.

Zephyr provides `zephyr_file()` to look up overlays and Kconfig
fragments for a specified board, and it used to be possible and safe to
do:
```
function(my_func)
  set(BOARD <local_scope_board>)
  zephyr_file(CONF_FILES ...)
endfunction(my_func)
```

As the BOARD inside `my_func` is locally scoped, this is safe to do.
But with introduction of #32556 a warning is now printed when running
CMake.

Therefore `zephyr_file` has been extended to allow for optional BOARD
and BOARD_REVISION arguments.
If BOARD is not given as argument the current BOARD in the build system
will be used.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-03-16 17:03:04 -05:00
Torsten Rasmussen b3bb1d6ad2 cmake: make WATCH an optional argument to zephyr_check_cache()
Watching of specific Zephyr CMake build variables ensure users cannot
accidentally set important variables, such as BOARD, SHIELD, CONF_FILES
late in the build process.

This was also added to zephyr_check_cache() function.
However, the BOARD provided by the user may look as `<board>@<revision>`
and will be kept in the cache in that form.

However, the BOARD value from cache is spit into internal build
variables as: BOARD=<board> and BOARD_REVISION=<revision>.
However, this is done after `zephyr_check_cache()` which then triggers
the variable watch to trigger, and printing a warning when using board
revisions.

Therefore WATCH is now optional for `zephyr_check_cache()` and watch for
BOARD variable will be enabled when boilerplate has completed all board
handling.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-03-16 17:03:04 -05:00
Eugeniy Paltsev d80a11ab9d ARC: MWDT: avoid xcheck object linkage as we don't use xcheck
We don't use xcheck (we disable it by passing '-Hnoxcheck' to
linker) so let's avoid xcheck object linkage as well by
passing '-Hnoxcheck_obj' option.

'-Hnoxcheck_obj' option implies the '-Hnoxcheck' option.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2021-03-12 18:29:27 -05:00
Wolfgang Puffitsch 4a01446a72 cmake: modules: Remove duplicates only from existing ZEPHYR_MODULE_NAMES
Remove duplicates from ZEPHYR_MODULE_NAMES only if that list
exists. That avoids cmake error "list sub-command REMOVE_DUPLICATES
requires list to be present" if ZEPHYR_MODULE_NAMES is empty.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2021-03-09 07:04:09 -05:00
Anas Nashif 01b1ac8c7e xcc: do not assume clang by default
Some toolchain variants come with no clang support, so do not assume
clang by default and enable this using the enviornment variable
XCC_USE_CLANG.

export XCC_USE_CLANG=1

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-03-08 16:04:28 -05:00
Anas Nashif 7c15ccf8ca xcc: do not make assumptions about toolchain path
the toolchain path can either be part of a full SDK install or
standalone, support both modes.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-03-08 16:04:28 -05:00
Martí Bolívar 163a253539 cmake: check BOARD and SOC roots before use
People frequently do things like setting BOARD_ROOT to
/my/module/boards/arm/my_board when it should be set to /my/module.

Similar misconfigurations happen for SOC_ROOT.

Emit warnings in these situations to try to point users in the right
direction.

A similar change could be made for DTS_ROOT, but that is trickier
since at least one directory (the application root) is legitimately
added to it that does not always contain dts/ or include/
subdirectories.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-03-08 12:51:29 +01:00
Torsten Rasmussen 3a58b45ced cmake: board_check_revision() also accepts a list of valid revisions
To remove the need of empty config files, the `board_check_revision()`
now accepts a list of valid revisions.

As example:
```
board_check_revision(
  FORMAT MAJOR.MINOR.PATCH
  VALID_REVISIONS 0.1.0 0.5.0 0.10.0
)
```

The code is still compatible with the `<board>_<revision>.conf` changes
so that if different revisions of a board has Kconfig differences, then
there is no need to also specify the list of valid revisions.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-03-04 12:58:43 +01:00
Kumar Gala 444a2d19a8 cmake: dtc: Validate EXTRA_DTC_FLAGS flags
Make sure the flags in EXTRA_DTC_FLAGS are valid for the version of dtc
we have and only invoke dtc with flags it supports.

Fixes #32644

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-03 17:29:29 +01:00
Martí Bolívar 2a52fa3eab cmake: dts: pass EXTRA_GEN_DEFINES_ARGS to gen_defines.py
Users can now set this CMake variable to pass additional arguments to
gen_defines.py.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-03-03 10:22:36 -06:00
Torsten Rasmussen 48321ef252 shield: cmake: adjust if(EXISTS <shield>.conf) to check for right file
Fixes: #32269

This commit is a followup to #31877 where the `${shield_dir}/${s_dir}`
was adjusted to `${SHIELD_DIR_${s}}` to ensure only including shields
and not boards in list of known shields.

An `if(EXISTS ${shield_dir}/${s_dir}...)` was missed in this process
which causes #32269. This is corrected in this commit.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-03-01 15:50:52 -06:00
Martí Bolívar 0629e698af cmake: warn if it's too late to set a boilerplate variable
Several variables must be set by the time boilerplate.cmake is run.
This includes BOARD, SHIELD, CONF_FILE, and DTC_OVERLAY_FILE.

It's not always clear to users that this is the case, and we sometimes
see attempts to modify these variables in app CMakeLists.txt files
after find_package(Zephyr ...) lines, where they will have no effect.
This causes confusion.

Add a new extension function, zephyr_boilerplate_watch(), which traps
attempts to set these variables and prints a noisy warning. Use it
from boilerplate.cmake on the variables mentioned above.

This will hopefully make it clearer at build time why the changes are
being ignored.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-02-28 16:48:23 -05:00
Pete Johanson 310a464acf cmake: Add UF2 as an additional build output option.
Add ability to build a UF2 (https://github.com/Microsoft/uf2)
image as an additional output type. This leverages the code
partition offset for the UF2 base address, and a configurable
UF2 family ID.

Includes an unmodified (except for headers for licensing, pylit
disabling) version of the uf2conv.py script copied the UF2
format specification repository, used to convert the bin to UF2.

Origin: UF2 file format specification reference utilies
License: MIT
URL: https://github.com/microsoft/uf2/blob/master/utils/uf2conv.py
commit: 587abb8b909266e9b468d6284f2fbd425235d1b5
Signed-off-by: Pete Johanson <peter@peterjohanson.com>
2021-02-23 21:11:04 +01:00
Henrik Brix Andersen 19b540630e boards: shields: add SHIELD_DIRS to DTS_ROOT
Treat shield directories containing a dts subdirectory as a DTS root
directory.

This allows shield specific devicetree include files and bindings to be
stored under the shield dts subdirectory.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-02-23 12:37:54 +01:00
Henrik Brix Andersen 50aab5d27c boards: shields: add shield directories to SHIELD_DIRS
Keep a list of shield directories for use in other parts of the build
system.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-02-23 12:37:54 +01:00
Torsten Rasmussen fa8912d9f4 cmake: remove duplicated ZEPHYR_BASE append to BOARD_ROOT
The following two lines are duplicated in boilerplate.cmake
```
zephyr_file(APPLICATION_ROOT BOARD_ROOT)
list(APPEND BOARD_ROOT ${ZEPHYR_BASE})
```

This commit removes one set of the duplicated lines.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-02-19 10:24:13 +03:00
Anas Nashif c7bc6380bd compiler: do not allow expansion-to-defined
'-Wexpansion-to-defined'
     Warn whenever 'defined' is encountered in the expansion of a macro
     (including the case where the macro is expanded by an '#if'
     directive).  Such usage is not portable.  This warning is also
     enabled by '-Wpedantic' and '-Wextra'.

This is enabled by default in llvm but not in gcc. Given that it is 'not
portable', lets disallow this in gcc and keep both compilers in sync.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-02-17 04:05:42 -05:00
Torsten Rasmussen c4c79f5f33 cmake: improved handling of output and byproducts in CMake
Fixes: #23449

This commit adds additional OUTPUT and BYPRODUCTS to custom command
and targets in the Zephyr build system.

This ensures that files produced during the build will be removed again
when invoking ninja clean / make clean.

The generated syscalls headers include folder is added to the syscall
target using ADDITIONAL_CLEAN_FILES property.
However, this property is new in CMake 3.15, so will not work when using
older CMake with ninja.

For CMake versions <=3.15 the ADDITIONAL_MAKE_CLEAN_FILES property is
used. However, this only supports Makefile generator.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-02-14 18:09:24 -05:00
Anas Nashif 467f916860 renode: fix dependencies for renode platforms
Make renode platforms run target depend on zephyr ELF.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-02-08 21:03:48 -05:00
Torsten Rasmussen d162e9e1ff cmake: twister: Using common script for toolchain setting verification
Fixes: #30713

Now using the common script `verify-toolchain.cmake` for verifying
toolchain settings.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-02-04 20:05:05 -05:00
Torsten Rasmussen 7f970093b3 cmake: remove ZEPHYR_GCC_VARIANT variable
ZEPHYR_GCC_VARIANT was deprecated in #6139 in 02/2018

Removing the variable now.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-02-04 20:05:05 -05:00
Anas Nashif 59365f576e cmake: remove usage of deprecated gccarmemb variant
gccarmemb was deprecated 2 years ago, so remove it.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-02-04 11:14:44 -05:00
Kumar Gala 5a11af3ce2 cmake: dts: Fix passing multiple EXTRA_DTC_FLAGS to gen_defines.py
Since EXTRA_DTC_FLAGS will be ';' seperated if we pass that as is if
there are multiple items in the list we'll get an error.  Sanitize
EXTRA_DTC_FLAGS by replacing ';' with ' ' before we call gen_defines.py

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-02-04 10:05:47 -05:00
Torsten Rasmussen 2bf26ecf4d cmake: modules: remove Zephyr module duplicates from ZEPHYR_MODULE_NAMES
This allows users to overrule a module from command line.
As example, the Zephyr build system loads the module FOO from
`modules/FOO`, but user has a custom FOO locally at `custom/FOO` and
would like to use this module instead of manifest specified.

If user does `-DZEPHYR_EXTRA_MODULES=custom/FOO` the following error
will be seen:
```
The binary directory

  build/modules/FOO

is already used to build a source directory.  It cannot be used to build
source directory

  custom/FOO

Specify a unique binary directory name.
```

Removing duplicates from the list allows a user to use
`-DZEPHYR_EXTRA_MODULES=custom/FOO` and thus replace `modules/FOO` for
the current build.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-02-03 16:58:28 -05:00
Torsten Rasmussen 6055c253ee shield: cmake: using Kconfig.shield instead of looking for overlay files
Fixes: #26522

Now searching for Kconfig.shield instead of recursively looking for
overlay files.

Globbing recursively for overlay files also picks up board overlays,
which leads to errors in the shield handling, as user could wrongly
specify certain boards as shields.
Also it led to wrongly list some board as shields, as reported
in #26522.

The folder containing a Kconfig.shield is then used when looking up
overlay files, as all overlay files in that folder represents a shield.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-02-02 19:05:47 -05:00
Torsten Rasmussen bc47797fbb cmake: Look for revision specific overlays also in <app>/boards/
This is a follow-up to commit 77ecd6837d.

Add missing check that looks for a revision specific overlay located
in the `<app>/boards/` directory similar to how overlays and Kconfig
fragments are handled.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-02-02 14:02:13 -05:00
Torsten Rasmussen d24ca1be1b cmake: shields: escaping and quoting list when used for env settings
Fixes: #30553

The `;` in a list must be escaped when used as for execute_process and
add_custom_target, as those functions are using `cmake -E env` to setup
correct environment before executing kconfig and menuconfig.

This commits escapes `SHIELD_AS_LIST` variable list correctly before
using it.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-01-26 17:42:08 -05:00
Torsten Rasmussen 774103d050 cmake: pristine.cmake requires SOURCE_DIR and BINARY_DIR as arguments
Calling cmake/pristine.cmake now requires SOURCE_DIR and BINARY_DIR as
arguments.

This ensures that pristine.cmake can evaluate if pristine is requested
on in-source builds, and bail out in such case with an error message.

All uses of `pristine.cmake` has been updated to use the new arguments.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-01-23 08:31:13 -05:00
Daniel Leung ff720cd9b3 x86: enable soft float support for Zephyr SDK
This adds the correct compiler and linker flags to
support software floating point operations. The flags
need to be added to TOOLCHAIN_*_FLAGS for GCC to find
the correct library (when calling GCC with
--print-libgcc-file-name).

Note that software floating point needs to be turned
on for Newlib. This is due to Newlib having floating
point numbers in its various printf() functions which
results in floating point instructions being emitted
from toolchain. These instructions are placed very
early in the functions which results in them being
executed even though the format string contains
no floating point conversions. Without using CONFIG_FPU
to enable hardware floating point support, any calls to
printf() like functions will result in exceptions
complaining FPU is not available. Although forcing
CONFIG_FPU=y with newlib is an option, and because
the OS doesn't know which threads would call these
printf() functions, Zephyr has to assume all threads
are using FPU and thus incurring performance penalty as
every context switching now needs to save FPU registers.
A compromise here is to use soft float instead. Newlib
with soft float enabled does not have floating point
instructions and yet can still support its printf()
like functions.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-01-20 16:45:31 -05:00
Torsten Rasmussen 3d88083bf1 cmake: zephyr modules: sanitize all module name when used as variable
The introduction of Zephyr module glue code in the Zephyr repository
introduces a Kconfig variable in the form of:
`config ZEPHYR_<MODULE_NAME>_MODULE`.

All Kconfig variables go into `autoconf.h`, therefore it is necessary
to sanitize the Kconfig variable, so that it does not contain special
characters. To ensure consistent variable name, then the module name
will be sanitized in all variable use in both Kconfig and CMake.
The sanitization is done be replacing all special characters with an
underscore, `_`.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-01-20 12:59:19 +01:00
Torsten Rasmussen 1bd0b29918 cmake: scripts: supporting gen_relocate_app feature in windows
Fixes: #28847

This commit fixes two places that was causing gen_relocate_app to fail
in windows.

gen_relocate_app.py now splits only on first `:` in
`<MEM_REGION>:<file>`.

Windows contains `:` in path, thus only first `:` is valid for splitting
mem region and file path.

Second part of the issue is fixed in CMake where `'` was used for
quoting of command arguments.
This causes a file not found on Windows because the final `'` would be
treated as part of the filename. Similar the first `'` would be treated
as path of the mem region name.

This is fixed by using `"` for quoting, which works correctly on all
platforms.

gen_relocate_app.py:403: UserWarning: File: .../kernel/sem.c' Not found
Note the stray `'`                                         ^^^

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-01-20 11:51:47 +01:00
Daniel Noom d2a682f372 cmake: Fix unexpected token after &
In bash a '&&' cannot follow directly after a '&'. So a task that is
run in the background should be enclosed in (curly) braces.

This:
```
west build -b qemu_x86 -d build/server samples/net/sockets/echo_server\
 -- -DOVERLAY_CONFIG=overlay-qemu_802154.conf -DPCAP=capture.pcap
west build -t server -d build/server
```
works correctly after this fix.

Fixes #29793

Signed-off-by: Daniel Noom <ggatw@outlook.com>
2021-01-18 19:08:45 +01:00
Torsten Rasmussen 3673e288bd modules: introducing MODULE_EXT_ROOT to allow glue code in Zephyr repo
This commit introduces MODULE_EXT_ROOT which allows CMake and Kconfig
glue code to be placed outside of the Zephyr module repository.

This allows for placing glue code in Zephyr, but also allows users to
specify custom MODULE_EXT_ROOTs for glue code using either
`-DMODULE_EXT_ROOT` or `zephyr/module.yml` with
`build:settings:module_ext_root` settings.

MODULE_EXT_ROOT' is a list of directories, similar to other roots such
as BOARD_ROOT, DTS_ROOT, etc.
The Zephyr repo folder ${ZEPHYR_BASE} is always to the MODULE_EXT_ROOT
list as lowest priority.
For each MODULE_EXT_ROOT, the file
`<module_ext_root>/modules/modules.cmake` will be processed.

In Zephyr repo, the folder `modules/<module>/` contains CMakeLists.txt
and Kconfig glue code for the Zephyr module.

A Zephyr module can specify that CMakeLists.txt and Kconfig glue code is
placed in an external module root by specifying:
```
build:
  cmake-ext: True
  kconfig-ext: True
```

It is still possible to place the CMakeLists.txt and Kconfig files
directly in the Zephyr module using the existing:
```
build:
  cmake: <path>
  kconfig: <file>
```.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-01-18 18:02:46 +01:00
Martí Bolívar 0d5e6c13e9 boards/shields: re-work handling in cmake and west
Remove the boards and shields lists from the 'usage' target output.
That might have been readable at some point long ago in Zephyr's
history, when only a few boards were available, but right now it's
obscuring the high level targets we really want 'usage' to print.

Instead, add 'boards' and 'shields' targets which the user can run to
get those lists, and reference them from the 'usage' output. This
makes 'usage' squintable again. We use the new list_boards.py script
from the 'boards' target.

Reference the 'help' target from 'usage' as well, and drop the
recommendation that people run '--target help' from the 'west build
--help' output for the 'west build --target' option. The canonical
place to look is 'usage' now.

Use the new list_boards.py code from 'west boards' as well, which
allows us to add the board's directory as a format string key, in
addition to its name and architecture.

Keep west-completion.bash up to date. While doing that, I noticed that
a bunch of references to this file refer to a stale location, so fix
those too.

Finally, the 'usage' output is what we print for a failed board or
shield lookup, so that needs to be updated also. Handle that by
invoking boards.cmake and a new shields.cmake in CMake script mode to
print the relevant output.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-01-15 15:07:49 -05:00
Martin Åberg 0b7c89927c riscv: give -mcmodel=medany to GCC when linking
We compile objects with -mcmodel=medany. Now also give -mcmodel=medany
to the GCC front-end when linking to pick up the corresponding
multilibs.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2021-01-15 13:06:33 -05:00
Kumar Gala 98b6e4f834 devicetree: generate extern's for devicetree struct devices
Generate a header (device_extern.h) that handles extern of possible
device structs that would come from devicetree.  This removes the need
for DEVICE_DT_DECLARE and DEVICE_DT_INST_DECLARE which we can remove.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-01-15 07:16:21 -06:00
Shubham Kulkarni a5ddb72261 boards: esp32: add 'nostdinc' expection for espressif toolchain
disable nostdinc for espressif tolchain

Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
2021-01-13 09:10:46 -05:00
Julien Massot d3345dd54d arch: arm: Add Cortex-R7 support
Pass the correct -mcpu flags to the compiler when building for the
Cortex-R7.

Signed-off-by: Julien Massot <julien.massot@iot.bzh>
2021-01-13 15:04:43 +01:00
Eugeniy Paltsev a50927ebfc ARC: MWDT: drop incorrect -Hnocopyr linker option
-Hnocopyr option suppress copyright message in case of LDAC linker
but in case of LLDAC linker somehow it leads to partial linking
and generation output file with relocations. Looks like we
are converting MWDT option to LLVM option incorrectly in this
case. Among the partial linking itself it may cause build errors
when 'elf.get_dwarf_info' from 'gen_kobject_list.py' meets the
arch-specific relocation which isn't supported by 'elftools'

It requires future investigation, let's disable -Hnocopyr for now
to have elf image linked correctly.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2021-01-04 12:52:10 -05:00
Martí Bolívar afcfa43f6b cmake: dts: remove stale error
We're well past Zephyr v1.16 (which turned out to be v2.1,
since v1.14 was followed by v2.0), so remove a message about a
variable that's been obsolete for two versions before that.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-12-22 07:34:29 -06:00
Anas Nashif 08253db46b xtensa: set toolchain variant per SoC
The toolchain variant per SoC is not always the soc name, so set this
per SoC and use this in the SDK instead of hardcoding the soc name.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-12-20 14:30:50 -05:00
Peter Bigot c7ad0b574a cmake: disable warning on C++ 20
Compound assigments like x |= y to volatile qualified values are
deprecated in C++20.  This idiom is common in CMSIS headers for
manipulating peripheral registers.  Since these headers are core they
are likely to be included indirectly in C++ modules; since they are in
vendor-provided headers we can't "fix" them.

Disable the warning when building for C++.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-19 04:54:46 -06:00
Torsten Rasmussen 16d66b0e1d cmake: additional board revision comments addressed for #29990
This commit contains some additional review comments that was posted
after board revision PR #29990 was merged.

The follow-up changes are:
- Fixed typo: REVIVISION --> REVISION
- Renaming leftover in print message:
  zephyr_check_board_revision --> board_check_revision
- Fixed regex, to allow revision 10, 20, 30, 40, etc.
- digits --> number in comment

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-12-17 09:25:54 -05:00
Tomasz Bursztyka 892714f818 cmake: Adds the necessary flags support for Qemu ivshmem feature
Depending whether doorbell or plain versions are enabled, it will set
the right flags to qemu.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-12-16 18:47:35 -05:00
Torsten Rasmussen 77ecd6837d cmake: support versioning of board
This commit introduces support for versioning of boards.
The existing board handling is limited in such a way that it is not
possible to support a specific board in multiple variants.

This commit introduces versioning of board revisions so that it is
possible to support minor variations to a board without having to
defining a completely new board.

This can be done by adding a revision.cmake file in the board folder:
boards/<arch>/<board-dir>/revision.cmake

Depending on the revision format chosen, additional configuration files
for each revision available must also be added, those have the form:
boards/<arch>/<board-dir>/<board>_<revision>.conf

Examples:
boards/<arch>/<board-dir>/<board>_defconfig:  Common board settings

Revision format: MAJOR.MINOR.PATCH
boards/<arch>/<board-dir>/<board>_0_5_0.conf: Revision 0.5.0
boards/<arch>/<board-dir>/<board>_1_0_0.conf: Revision 1.0.0
boards/<arch>/<board-dir>/<board>_1_5_0.conf: Revision 1.5.0

Revision format: LETTER
boards/<arch>/<board-dir>/<board>_A.conf:     Revision A
boards/<arch>/<board-dir>/<board>_B.conf:     Revision B

The `board_check_revision` function is available in `extensions.cmake`
to facilitate board revision handling in `revision.cmake`.

User select the board revision using: `-DBOARD=<board>@<revision>`, as
example `-DBOARD=plank@0.5.0`.

If a shield, test, sample, or application needs to specify DTS overlay
or Kconfig fragments, this can be done by adding revision specific
configuration files in the sample/test/shield folder, like this:
<shield/sample-path>/boards/<board>.conf
<shield/sample-path>/boards/<board>_<revision>.conf

or if there is there is only a need for adjusting on a given board
revision:
<shield/sample-path>/boards/<board>_<revision>.conf

Similar for DTS overlay files:
<shield-path>/boards/<board>.overlay
<shield-path>/boards/<board>_<revision>.overlay

or:
<shield-path>/boards/<board>_<revision>.conf

For test/samples/apps:
<sample-path>/<board>.overlay
<sample-path>/<board>_<revision>.overlay

or:
<sample-path>/<board>_<revision>.overlay

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-12-16 08:50:10 -05:00
Torsten Rasmussen bbaf00b8e4 cmake: extend zephyr_file(<mode>) to support searching of config files
This commit extends zephyr_file(<mode>) to support `CONF_FILES` which
allows for finding and appending Zephyr Kconfig fragments and DTS
overlays.

Introducing mode:CONF_FILES allows have a uniform way of looking up
<board>.conf and <board>.overlay, and ensure that extending such
functionality keeps identical behaviour in shields, tests, and samples.

Using zephyr_file(CONF_FILES) a lot of duplicated code can be removed.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-12-16 08:50:10 -05:00
Torsten Rasmussen e3b6d65cd0 cmake: fixed issue with CONF_FILE pattern when using build type
This commit fixes an issue where specifying a build type config file
in a subfolder named: `prj_<something>` would cause a wrong match and
fail to find Kconfig fragments, as example:

Working: `-DCONF_FILE=myconfigs/prj_debug.conf` would correctly add
myconfigs/boards/<board>_debug.conf to list of conf files.

Failing: `-DCONF_FILE=prj_configs/prj_debug.conf` would fail to locate
prj_configs/boards/<board>_debug.conf, and thus the board specific
config fragment was not added to the list of config files.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-12-16 08:50:10 -05:00
Torsten Rasmussen a1c8da6d7a cmake: print shields together with board
Currently only BOARD is printed when running CMake.

This commit prints shields together with board, if one or more shields
are specified.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-12-16 08:50:10 -05:00
Torsten Rasmussen 7247412a9e cmake: cleanup board and shield cmake code
Cleanup board and shield cmake code so that code duplication is reduced.

Before this commit, the code for verifying if BOARD or SHIELD user input
had changed was almost identical.

The common code has been made into a Zephyr extension function so that
all part of Zephyr build system can have a uniform way of checking if
sticky arguments has changed, and print user warning in a uniform way.

This also fixes an undiscovered flaw, where changing a shield is not
possible if a shield was defined at first CMake invocation, but in case
no shield had been specified at all, then build system would wrongly
allow specifying and changing shields, for example doing:
cmake -DBOARD=nrf52840dk_nrf52840 -DSHIELD=sparkfun_sara_r4 <sample>
cmake -DSHIELD=wnc_m14a2a

results correctly in:
> CMake Warning at zephyr/cmake/app/boilerplate.cmake:287 (message):
>   The build directory must be cleaned pristinely when changing shields

and correctly keep existing SHIELD settings.

but doing:
cmake -DBOARD=nrf52840dk_nrf52840 <sample>
cmake -DSHIELD=sparkfun_sara_r4
cmake -DSHIELD=wnc_m14a2a

would not result in any warning, because `CACHED_SHIELD` was not
correctly checked in this case.

Changing shield is not a supported feature as it have unknown behavior.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-12-16 08:50:10 -05:00
Torsten Rasmussen a019b6f280 cmake: using zephyr_get_compile_options_for_lang_as_string for export
Fixes: #30712

Now using zephyr_get_compile_options_for_lang_as_string for makefile
export of Zephyr build flags.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-12-15 08:37:54 -05:00
Torsten Rasmussen f73da678a4 cmake: use the toolchain path, id and version as extended signature.
Fixes: #30531

Now using MD5 sum of CMAKE_C_COMPILER (path), CMAKE_C_COMPILER_ID and
CMAKE_C_COMPILER_VERSION variables as part of the TOOLCHAIN_SIGNATURE.

Moved MD5 calculation of executable into
cmake/target_toolchain_flags.cmake to have common location, as
CMAKE_C_COMPILER_ID and CMAKE_C_COMPILER_VERSION are not available until
project() has executed.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-12-14 11:56:00 -05:00
Christopher Friedt bf304ffed9 cmake: zephyr_module.cmake ZEPHYR_EXTRA_MODULES evaluated too late
Previously, `cmake/app/boilerplate.cmake` evaluated
ZEPHYR_EXTRA_MODULES on line ~548 *after* `zephyr_module.cmake`
was included on line ~168.

This change ensures that modules defined in `ENV{ZEPHYR_EXTRA_MODULES}`
are processed properly through `zephyr_module.cmake`.

Fixes #30673

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-12-14 11:19:46 +01:00
Anas Nashif 217186ffdb twister: rename in cmake/
Some extenstions in cmake used sanitycheck name, replace those with
twister.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-12-11 14:13:02 -05:00
Martin Åberg 53a4acb2dc SPARC: add FPU support
This change adds full shared floating point support for the SPARC
architecture.

All SPARC floating point registers are scratch registers with respect
to function call boundaries. That means we only have to save floating
point registers when switching threads in ISR. The registers are
stored to the corresponding thread stack.

FPU is disabled when calling ISR. Any attempt to use FPU in ISR
will generate the fp_disabled trap which causes Zephyr fatal error.

- This commit adds no new thread state.
- All FPU contest save/restore is synchronous and lazy FPU context
  switch is not implemented.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2020-12-04 14:33:43 +02:00
Torsten Rasmussen 94288bdcc5 cmake: zephyr_get_<flags>_for_lang_as_string() uses space as delimiter
The use of zephyr_get_<flags>_for_lang_as_string will now use space as
delimiter, this will allow for existing used of the
zephyr_get_<flags>_for_lang_as_string() to return a string with spaces
instead of semicolons as a quoted list.

Note, in most situations it is prefered to have a proper CMake list
returned, in which case zephyr_get_<flags>_for_lang() is probably the
correct function to use.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-12-03 09:23:07 -05:00
Torsten Rasmussen 8275d39d4d cmake: adding $<SEMICOLON> instead of space on zephyr_get_compile_<type>
The current zephyr_get_compile_<type> flags returns compile / include
flags based on generator expressions.

But they also included a space.

This have the unintended side-effect that when the properties are
fetched into another variable and later appended to lists in order to
finally be used in a CMake target function / custom command, then CMake
in some cases will quote the string, creating a quoted argument like:
"arg0 arg1 arg2: instead of individual arguments like: "arg0" "arg1"
"arg2".

By using $<SEMICOLON>, then arguments are seperated correctly.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-12-03 09:23:07 -05:00
Torsten Rasmussen 6ca2bf25cb cmake: manual handling of CMakeCheckCompilerFlag.cmake inclusion
Fixes: #30232

This is a workaround for #30232.

During Zephyr CMake invocation a plain C compiler is used for DTS.
This results in the internal `CheckCompilerFlag.cmake` being included
by CMake

Later, when the full toolchain is configured, then
`CMakeCheckCompilerFlag.cmake` is included.
This overloads the `cmake_check_compiler_flag()` function, thus
causing #30232.

By manualy loading `CMakeCheckCompilerFlag.cmake` then
`CheckCompilerFlag.cmake` will overload the functions (and thus win the
battle), and because `include_guard(GLOBAL)` is used in
`CMakeCheckCompilerFlag.cmake` this file will not be re-included later.

It also prints a warning informing the user of the issue.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-12-01 08:46:41 -06:00
Torsten Rasmussen c08ef381c8 bintools: append ; to > to ensure a space
Ensure > is an independent argument.
The ; will ensure that the `>` and `outfile` are given as two arguments
and thus ensure correct behavior in all cases.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-11-26 14:20:03 +01:00
Martin Åberg e15297e7d9 cmake: Preparation for SDK 0.12 and SPARC
Zephyr SDK version 0.12 is distributed with SPARC cmake target support,
while version 0.11.3 and 0.11.4 need target.cmake from the Zephyr repo.

This commit has been tested with:
- zephyr-sdk-0.11.3 (currently used in CI)
- zephyr-sdk-0.11.4
- zephyr-sdk-0.12.0-beta-2

This commit is expected to be compatible with
- zephyr-sdk-0.12.0 (not yet released)

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2020-11-19 16:57:37 -05:00
Keith Packard 1201bd6418 xtools: Select correct ARM architecture for xtools
Just like the zephyr SDK code, the xtools toolchain needs to select
aarch64-zephyr-elf instead of arm-zephyr-eabi for the target triple when
building for 64-bit ARM processors.

Signed-off-by: Keith Packard <keithp@keithp.com>
2020-11-19 10:32:35 -06:00
Martin Åberg c107714214 sanitycheck: Add TSIM3 support
TSIM3 is a LEON processor and system simulator.

This commit allows using TSIM sanitycheck and the make run target.

TSIM parameters can be further specified in the board configuration
using TSIM and TSIM_SYS.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2020-11-13 14:53:55 -08:00
Martin Åberg 97f6dfdd72 cmake: SPARC workaround for SDK toolchain 0.11
Zephyr SDK version 0.11.3, 0.11.4 and 0.12.0-beta-1 does not have
the required SPARC target support.

Zephyr CI is currently using SDK 0.11.3, which causes the following
build error:

CMake Error at /workdir/zephyr/cmake/compiler/gcc/target.cmake:10
(message):
  C compiler /opt/sdk/zephyr-sdk-0.11.3//bin/-gcc not found - Please
  check your toolchain installation

This patch adds a workaround such that the SDK target.cmake is picked
up from the directory 0.11 when ARCH=sparc.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2020-11-13 14:53:55 -08:00
Martin Åberg f8d1a9e5ea cmake: Added SPARC support
This commit defines the tool prefix and command line options for the
Zephyr SPARC architectural port.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2020-11-13 14:53:55 -08:00
Torsten Rasmussen 4558ba7128 cmake: ensure shields can be placed in other BOARD_ROOTs
Fixes: #28462

This commit allows shields to be defined in other BOARD_ROOTs, either
using `-DBOARD_ROOT=<path>` or a Zephyr module defined BOARD_ROOT.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-11-13 13:36:48 +01:00
Daniel Leung 7d16ab50d7 cmake: fix xcc not supporting -Wno-unsed-but-set-variable
XCC does not support the compiler flag -Wno-unused-but-set-variable
so check for flag support before setting it in cmake.

Fixes #29707

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-11-10 21:51:36 -05:00
Torsten Rasmussen 59bbc5a3c8 Revert "shields: Modify overlay file order"
Fixes: #29074

This reverts commit fc8f639b9a.

The suggestion provided in #27901 is impacting processing order of
overlay files in a non-logical way, see #29074 discussion for details.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-11-10 13:14:36 -05:00
Anas Nashif 03de10091a clang: use LLVM_TOOLCHAIN_PATH instead of CLANG_ROOT_DIR
Be consistent with other toolchains.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-11-02 14:30:37 -05:00
Anas Nashif 7fe8198102 llvm: add support for building x86_64-pc
set triplet for 64bit x86.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-11-02 14:30:37 -05:00
Anas Nashif 39bd354389 clang: remove cache handling
This is taking too long for every run and does not seem to work as
expected and wastes time instead of saving it. Remove for now..

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-11-02 14:30:37 -05:00
Anas Nashif 8f7f31b654 clang: do not assert on libgcc not found
We do not need libgcc always, some environments do not have libgcc and
do not require it, so keep it more flexible.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-11-02 14:30:37 -05:00
Anas Nashif 6e418c7022 clang: remove include-fixed inclusion
This directory does not exist in clang/llvm, remove it.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-11-02 14:30:37 -05:00
Anas Nashif e6e29c0ccf toolchain: clang: add -Wno-typedef-redefinition option
Without the -Wno-typedef-redefinition option, clang complains if a
typedef gets redefined in gnu99  mode (since this is officially a C11
feature).

While new versions of GCC do not seem to issue this warning in gnu99
mode anymore. So some existing code with typedef redefined which works
well with GCC will issue this warning.

Similar to what was done in 2354f055ec.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-11-02 14:30:37 -05:00
Torsten Rasmussen ad78766139 cmake: dts: getting realpath for system includes for dts.
Fixes: #28893

Now using get_filename_component(REALPATH) to ensure full path with
symlinks and `..` resolved.

Having `..` in path causes the gcc generated dependency file to contain
`\` in path on windows. This confuses ninja.
The result is that ninja consider the file missing, and thus invokes a
CMake run to create the file, resulting in endless loop.

By ensuring that full path (containing `/` which is already ensured)
when calling gcc, then all paths will be posix style, making ninja
happy.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-10-27 16:40:19 +01:00
Torsten Rasmussen 90f56dbabf cmake: extend target_ld_options() to support grouping of flags
Fixes #28456

This commit extends `target_ld_options()` with a NO_SPLIT flag.

Specifying `NO_SPLIT` will ensure that all linker flags will be applied
together when testing the compiler and linker.
This allows a caller to ensure that flags are tested together.

This fixes the RISC-V case where the flags `-mabi` and `-march` were
omitted because they were tested individually.

Note, the update of `target_ld_options()` will allow the same flag on
`zephyr_ld_options()`

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-10-27 13:09:02 +01:00
Anas Nashif 483b4ff030 cmake: work around sdk toolchain configuration for xtensa [REVERTME]
until we have this change in the SDK where we should not depend on
SOC_NAME but a new identifier.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-10-21 06:38:53 -04:00
Andy Ross 544a38ee62 soc/xtensa/intel_adsp: Upstream updates
Significant rework of the Intel Audio DSP SoC/board layers.  Includes
code from the following upstream commits:

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Thu Jun 25 16:34:36 2020 +0100

    xtesna: adsp: use 50k ticks per sec for audio

    Audio needs high resolution scheduling so schedule to nearest 20uS.

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Andy Ross <andrew.j.ross@intel.com>
 Date:   Wed Jun 24 13:59:01 2020 -0700

    soc/xtensa/intel_adsp: Remove sof-config.h includes

    This header isn't used any more, and in any case shouldn't be included
    by SoC-layer Zephyr headers that need to be able to build without SOF.

    Signed-off-by: Andy Ross <andrew.j.ross@intel.com>

 Author: Andy Ross <andrew.j.ross@intel.com>
 Date:   Sat Jun 20 15:42:58 2020 -0700

    soc/intel_adsp: Leave interrupts disabled at MP startup

    This had some code that was pasted in from esp32 that was inexplicably
    enabling interrupts when starting an auxiliary CPU.  The original
    intent was that the resulting key would be passed down to the OS, but
    that's a legacy SMP mechanism and unused.  What it actually did was
    SET the resulting value in PS.INTLEVEL, enabling interrupts globally
    before the CPU is ready to handle them.

    Just remove.  The system doesn't need to enable interrupts until the
    entrance to the first user thread on this CPU, which will do it
    automatically as part of the context switch.

    Signed-off-by: Andy Ross <andrew.j.ross@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Tue Jun 23 13:57:54 2020 +0300

    dts: intel_cavs: Add required label

    Add required label fixing build for CAVS15, 20, 25.
    Fixes following errors:
    ...
    devicetree error: 'label' is marked as required in 'properties:' in
    bindings/interrupt-controller/intel,cavs-intc.yaml,
    but does not appear in
    ...

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Tue Jun 23 15:19:56 2020 +0300

    soc: cavs_v18: Remove dts_fixup and fix build

    Remove unused now dts_fixup.h and fix build with the recent code base.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Tue Jun 23 15:12:25 2020 +0300

    soc: cavs_v20: Remove dts_fixup and fix build

    Remove unused now dts_fixup.h and fix build with the recent code base.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Tue Jun 23 14:59:23 2020 +0300

    soc: cavs_v25: Remove dts_fixup fix build

    Remove unused now dts_fixup and fix build with the latest code base.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Fri Jun 12 12:29:06 2020 +0300

    soc: intel_adsp: Remove unused functions

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Wed Jun 10 17:53:58 2020 +0300

    soc: intel_adsp: Clean up soc.h

    Remove unused or duplicated definitions.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Wed Jun 10 17:02:23 2020 +0300

    soc: intel_adsp: De-duplicate soc.h

    Move soc.h to common SOC area.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Wed Jun 10 15:54:19 2020 +0300

    soc: intel_adsp: Remove duplicated io.h

    Move duplicated io.h to common SOC area.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Fri Jun 12 12:39:46 2020 +0300

    cmake: Correct SOC_SERIES name for byt and bdw

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Fri Jun 12 12:39:02 2020 +0300

    soc: intel_adsp: Build bootloader only for specific SOCs

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Thu Jun 11 13:46:25 2020 +0100

    boards: xtensa: adsp: add byt and bdw boards WIP

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Andy Ross <andrew.j.ross@intel.com>
 Date:   Wed Jun 10 10:01:29 2020 -0700

    soc/intel_adsp: Make the HDA timer the default always

    The CAVS_TIMER was originally written because the CCOUNT values are
    skewed between SMP CPUs, so it's the default when SMP=y.  But really
    it should be the default always, the 19.2 MHz timer is plenty fast
    enough to be the Zephyr cycle timer, and it's rate is synchronized
    across the whole system (including the host CPU), making it a better
    choice for timing-sensitive applications.

    Signed-off-by: Andy Ross <andrew.j.ross@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Wed Jun 10 15:21:43 2020 +0300

    soc: cavs_v25: Enable general samples build

    Enables general samples build for SOC cavs_v25.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Wed Jun 10 15:13:53 2020 +0300

    soc: cavs_v20: Enable general samples build

    Enable general sample build.

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Wed Jun 10 14:35:13 2020 +0300

    soc: cavs_v18: Fix build general samples

    Fix building general samples for CAVS18.

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Wed Jun 10 14:22:40 2020 +0300

    soc: intel_adsp: Add support for other SOCs

    Support other SOCs in the "ready" message to the Host.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Wed Jun 10 13:25:39 2020 +0300

    soc: intel_adsp: Move adsp.c to common SOC area

    Move adsp.c to common and clean makefiles.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Tue Jun 9 17:18:18 2020 +0300

    boards: intel_adsp: Remove dependency on SOF

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Tue Jun 9 14:29:44 2020 +0100

    soc: xtensa: cavs: build now good for cavs20 + 25

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Tue Jun 9 15:57:01 2020 +0300

    soc: cavs_v15: Fix build for hello_world

    Fix build for other then audio/sof targets.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Tue Jun 9 14:50:12 2020 +0300

    sample: audio/sof: Remove old overlays

    Removing old overlays used to switch logging backend.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Mon Jun 8 15:02:01 2020 +0300

    soc: intel_adsp: Correct TEXT area

    Correct HEADER_SPACE and put TEXT to:
    (HP_SRAM_WIN0_BASE +  HP_SRAM_WIN0_SIZE + VECTOR_TBL_SIZE)

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Tue Jun 9 14:44:47 2020 +0300

    soc: intel_adsp: Trivial syntax cleanup

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Tue Jun 9 14:41:07 2020 +0300

    soc: intel_adsp: Fix bootloader script path

    Make it possible to find linker script if build is done not inside
    ZEPHYR_BASE.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Tue Jun 9 12:10:17 2020 +0100

    soc: xtensa: cavs20/25: fix build with new headers - WIP

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Tue Jun 9 13:35:38 2020 +0300

    soc: intel_adsp: Fix include headers

    Fixes include headers

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Tue Jun 9 10:38:50 2020 +0100

    soc: xtensa: cav18: updated headers- WIP

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Andy Ross <andrew.j.ross@intel.com>
 Date:   Fri May 1 15:29:26 2020 -0700

    soc/xtensa/intel_adsp: Clean up MP config logic

    CONFIG_MP_NUM_CPUS is a platform value, indicating the number of CPUs
    for which the Zephyr image is built.  This is the value kernel and
    device code should use to predicate questions like "is there more than
    one CPU?"

    CONFIG_SMP is an application tunable, controlling whether or not the
    kernel schedules threads on CPUs other than the first one.  This is
    orthogonal to MP_NUM_CPUS: it's possible to build a "SMP" kernel on a
    uniprocessor system or have a UP kernel on a MP system if the other
    cores are used for non-thread application code.

    CONFIG_SCHED_IPI_SUPPORTED is a platform flag telling an SMP kernel
    whether or not it can synchronously signal other CPUs of scheduler
    state changes.  It should be inspected only inside the scheduler (or
    other code that uses the API).  This should be selected in kconfig by
    soc layer code, or by a driver that implements the feature.

    CONFIG_IPM_CAVS_IDC is a driver required to implement IPI on this
    platform.  This is what we should use as a predicate if we have
    dependence on the IPM driver for a platform feature.

    These were all being sort of borged together in code.  Split them up
    correctly, allowing the platform MP layer to be unit tested in the
    absence of SMP (c.f. tests/kernel/mp), and SMP kernels with only one
    CPU (which is pathlogical in practice, but also a very good unit test)
    to be built.

    Also removes some dead linker code for SMP-related sections that don't
    exist in Zephyr.

    Signed-off-by: Andy Ross <andrew.j.ross@intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon Jun 8 16:41:55 2020 +0100

    soc: xtensa: bootloader - use linker script

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon Jun 8 16:26:18 2020 +0100

    soc: xtensa: further fix headers - WIP

    Simplify the directory structure, WIP for cavs20 and cavs25

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Mon Jun 8 12:59:30 2020 +0300

    soc: cavs_v15: Remove unneeded include

    Remove include fixing build.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Sun Jun 7 12:37:35 2020 +0100

    soc:xtensa: adsp: remove sof specific code from soc headers

    TODO: v1.8+

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Marc Herbert <marc.herbert@intel.com>
 Date:   Thu Jun 4 23:19:37 2020 -0700

    intel_adsp_*/doc: fix duplicate .rst labels

    Quick fix purely to make the build green again.

    Signed-off-by: Marc Herbert <marc.herbert@intel.com>

 Author: Marc Herbert <marc.herbert@intel.com>
 Date:   Thu Jun 4 22:34:40 2020 -0700

    samples/audio/sof: use OVERLAY_CONFIG to import apollolake_defconfig

    This reverts commit 21f16b5b1d29fca83d1b62b1b75683b5a1bc2935 that
    copied it here instead.

    Signed-off-by: Marc Herbert <marc.herbert@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Fri Jun 5 12:34:48 2020 +0300

    soc: intel_adsp: Move soc_mp to common

    Moving soc_mp to common SOC area, it still needs fixes for taking
    number of cores from Zephyr Kconfig, etc.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Thu Jun 4 16:05:06 2020 +0300

    soc: intel_adsp: Move memory.h from lib/

    For those files from SOF referencing platform/lib/memory.h we have
    include.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Thu Jun 4 15:20:09 2020 +0300

    soc: intel_adsp: Rename platform.h to soc.h

    Rename to prevent including it from SOF.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Thu Jun 4 11:47:55 2020 +0300

    soc: intel_adsp: Move headers

    Move headers to more convenient place

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Thu Jun 4 11:21:51 2020 +0300

    soc: intel_adsp: More SOC cleaning

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Marc Herbert <marc.herbert@intel.com>
 Date:   Mon Jun 1 15:31:34 2020 -0700

    samples/audio/sof: import sof/src/arch/xtensa/  apollolake_defconfig

    Import modules/audio/sof/src/arch/xtensa/configs/apollolake_defconfig
    into prj.conf and new boards/up_squared_adsp.conf

    Signed-off-by: Marc Herbert <marc.herbert@intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Wed Jun 3 15:07:40 2020 +0100

    soc:xtensa: adsp: let SOF configure the DSP for audio

    Let SOF do this for the moment.

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Wed Jun 3 15:06:20 2020 +0100

    soc: xtensa: cavs: remove headers similar to cavs15

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Wed Jun 3 15:58:38 2020 +0300

    soc: intel_adsp: Move ipc header to common

    Remove duplicated headers from CAVS to common SOC part

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Wed Jun 3 13:02:09 2020 +0300

    soc: cavs_v15: Remove unneeded headers

    Remove also from CAVS15.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Tue Jun 2 18:34:11 2020 +0300

    Remove more headers

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Wed Jun 3 14:12:09 2020 +0100

    soc: xtensa: remove cavs sod headers for drivers and trace.

    Duplicate cavs15 headers.

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Wed Jun 3 14:05:12 2020 +0100

    samples: move sof dai, dma and clk configs to SOF

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Tue Jun 2 17:38:45 2020 +0300

    soc: intel_adsp: Remove more duplicated headers

    Remove more headers

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Tue Jun 2 15:50:03 2020 +0100

    samples: sof: remove pm realted files.

    Use the SOF versions.

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Tue Jun 2 16:55:40 2020 +0300

    WIP: Strip lib from include path

    WIP, pushed for sync

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Tue Jun 2 14:44:33 2020 +0300

    soc: intel_adsp: Remove more headers

    Remove even more common headers

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Tue Jun 2 14:00:47 2020 +0300

    soc: intel_adsp: Remove SOF headers

    The headers would be used by audio/sof app directly from SOF module.

 Author: Andy Ross <andrew.j.ross@intel.com>
 Date:   Sat May 30 11:01:26 2020 -0700

    soc/intel_adsp: Alternative log reading script

    This script speaks the same protocol and works with the same firmware,
    but:

    * Is a single file with no dependencies outside the python3 standard
      library and can be run out-of-tree (i.e. with setups where the
      firmware is not built on the device under test)

    * Operates in "tail" mode, where it will continue polling for more
      output, making it easier to watch a running process and acting more
      like a conventional console device.

    * Has no dependence on the diag_driver kernel module (it reads the DSP
      SRAM memory directly from the BAR mapping in the PCI device)

    * Is MUCH smaller than the existing tool.

    Signed-off-by: Andy Ross <andrew.j.ross@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Thu May 28 16:17:51 2020 +0300

    Decrease HEP pool size to 192000

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Fri May 29 10:27:00 2020 +0100

    soc: xtensa: cavs25: complete support for cavs25

    Builds, not tested on qmeu due to missing SOF ROM (TODO)

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Fri May 29 10:24:26 2020 +0100

    soc: xtensa: cavs20: complete cavs20 support

    Now boots on qemu.

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Fri May 29 10:22:13 2020 +0100

    soc: xtensa: cavs18: complete boot support

    Now boots on qemu.

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Fri May 29 10:19:23 2020 +0100

    soc: xtensa: cavs15: use cavs15 instead of apl as linker soc name

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Fri May 29 10:16:06 2020 +0100

    TODO: samples: sof: work  around missing trace symbols.

    Disable local trace.
    Needs trace updates finished before this can be removed.

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Wed May 27 15:57:19 2020 +0100

    dts: xtensa: rename apl to cavs15 DTS

    This DTS is used by more than APL SOC. i.e. all CAVS15 SOCs

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Wed May 27 15:52:20 2020 +0100

    west: commands: sign: Add signing support for other CAVS targets

    Sign for CAVS15, CAVS18, CAVS20 and CAVS25 SOCs

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Wed May 27 15:50:07 2020 +0100

    boards: xtensa: cavs: used Zephyr mask macro

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Wed May 27 15:49:46 2020 +0100

    soc: xtensa: move code to SOF

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Tue May 26 11:40:36 2020 +0100

    soc: xtensa: use SOF versions of clk

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Mon May 25 18:38:45 2020 +0300

    soc: intel_adsp: Send FW ready for non SOF configuration

    Configure windows and send FW ready when used without SOF, should be
    loaded with fw_loader script.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Mon May 25 18:02:22 2020 +0300

    soc: intel_adsp: Use SOF version of the file

    Use exact copy from SOF module.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Mon May 25 17:47:27 2020 +0300

    soc: intel_adsp: Clean up include headers

    Remove SOF mentions from the SOC headers.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Mon May 25 17:43:05 2020 +0300

    soc: intel_adsp: Move SOF specific code to samples/audio/sof

    Move SOF specific code to the SOF sample.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Mon May 25 17:39:42 2020 +0300

    soc: intel_adsp: Use SOF module's version of mem_window.c

    Use exact copy from SOF module.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Mon May 25 17:36:41 2020 +0300

    soc: intel_adsp: Use exact copy from SOF module

    Use SOF module verion of the clk.c

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Mon May 25 14:03:35 2020 +0300

    soc: xtensa: Add {SOC_FAMILY}/common/include path

    Add ${SOC_DIR}/${ARCH}/${SOC_FAMILY}/common/include path if exist.
    Fixes issues for xtensa SOCs.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon May 25 16:18:50 2020 +0100

    soc: xtensa: cavs common: fix headers for build

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon May 25 16:10:57 2020 +0100

    soc: xtensa: adsp: add so_inthandlers.h for Intel platforms

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon May 25 16:08:26 2020 +0100

    cmake: xtensa: select correct compiler per CAVS target.

    TODO: what about XCC ?

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Tue May 19 14:59:26 2020 +0300

    boards: up_squared_adsp: Move SOF configuration to samples

    Move SOF-specific configuration to samples/audio/sof prj.

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Fri May 15 15:29:50 2020 +0300

    soc: intel_adsp: Move SOF code to modules/audio/sof

    Move SOF dependent code out of SOC area.

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Thu May 14 17:30:38 2020 +0300

    Move task_main_start() to audio/sof sample

    Start task_main_start() from main of audio/sof sample.

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Wed May 13 15:37:20 2020 +0300

    Rename up_xtreme_adsp to intel_adsp_cavs18

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Mon Apr 27 14:12:59 2020 +0300

    Add sample audio/sof for SOF initialization

    Add dedicated sample where we put SOF specific initialization.

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Mon May 11 18:49:36 2020 +0300

    WIP: soc: cavs_v18: Cleanup

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Mon May 11 15:44:06 2020 +0300

    soc: cavs_v15: Move soc init to common part

    Moving SOC init to the right place.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Mon May 11 15:02:28 2020 +0300

    soc: intel_adsp: Move common part to special dir

    Moving common part to common/adsp.c

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Fri May 8 14:37:50 2020 +0300

    boards: up_xtreme_adsp: Add initial up_xtreme_adsp board

    Add initial board copying existing up_squared_adsp board and using
    CAVS1.8 SOC family.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Thu May 7 15:30:51 2020 +0300

    soc: intel_adsp: Generalize bootloader

    Move bootloader to soc/xtensa/intel_adsp making it available for other
    boards.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Tue May 5 21:31:00 2020 +0100

    boards: xtensa: up_squared: Add support for all CAVS

    Add boot support for all CAVS versions. TODO: needs to be made common

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Tue May 5 21:25:34 2020 +0100

    soc: xtensa: intel_adsp: Manage cache for DMA descriptors

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon May 4 21:10:50 2020 +0100

    soc: xtensa: adsp: use 24M567 clock

    Use audio clock

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon May 4 10:04:01 2020 +0100

    xtensa: soc: adsp: enable system agent

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Sun May 3 15:03:07 2020 +0100

    soc: xtensa: intel_adsp: increase mem pool to 192k

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Sun May 3 15:02:31 2020 +0100

    soc: xtensa: intel_adsp: re-enable DMA trace

    Buffer will be empty (as trace items sent to Zephyr LOG) but
    logic is running.

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Sun May 3 11:18:55 2020 +0100

    soc: xtensa: intel: dont use uncache region yet.

    Some code was still using this region. Use later.

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Sun May 3 10:07:28 2020 +0100

    soc: xtensa: intel_adsp: fix notifier init

    Topology now loads.

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Fri May 1 21:18:38 2020 +0100

    boards: up2: Need to use sof config for bootloader

    This will need uncoupled at some point. For testing today.

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Fri May 1 21:16:38 2020 +0100

    boards: up2: increase heap to 128k

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Thu Apr 30 11:35:19 2020 +0300

    boards: up_squared_adsp: Use bigger HEAP

    Use HEAP from old demo.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Fri May 1 16:06:32 2020 +0100

    soc: xtensa: intel_adsp: Fix config.h naming collisions

    Rename sof version to sof-config.h

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Thu Apr 30 11:22:42 2020 +0300

    Small cleanups

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Wed Apr 29 22:00:44 2020 +0300

    tests: sof/audio: Test ll scheduler

    Add more tests for scheduler.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Wed Apr 29 18:38:35 2020 +0300

    tests: Add first schedule test

    Add initial test for testing scheduling.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Wed Apr 29 13:36:23 2020 +0100

    soc: xtensa: rmeove build warnings

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Tue Apr 28 18:04:33 2020 +0300

    soc/intel_adsp: Register sof logging

    Register sof logging for tracing

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Tue Apr 28 14:16:55 2020 +0300

    boards: up_squared_adsp: Define HEAP_MEM_POOL_SIZE

    Define HEAP_MEM_POOL_SIZE when SOF enabled.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Tue Apr 28 10:09:20 2020 +0300

    tests: audio/sof: Add interrupt API for testing

    Add initial interrupt API for testing.

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon Apr 27 15:54:28 2020 +0100

    soc: xtensa: adsp: Update linker script for SOF sections.

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon Apr 27 11:20:01 2020 +0100

    soc: xtensa: adsp: send SOF FW metadata as boot message

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Sun Apr 26 21:47:20 2020 +0100

    soc: xtensa: adsp: re-enable all SOF IP init.

    Do all SOF IP init.

    TODO: ATOMCTL, WFI on LX6

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Sat Apr 25 15:30:40 2020 +0100

    soc: xtensa: irq: Make sure IPC IRQ is registered.

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Wed Apr 22 20:56:09 2020 +0300

    tests: sof: Enable console

    Enable console for the test.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Wed Apr 22 17:57:22 2020 +0300

    soc: cavs_v15: Fix XTENSA_KERNEL_CPU_PTR_SR

    Use correct value for XTENSA_KERNEL_CPU_PTR_SR.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Wed Apr 22 14:48:31 2020 +0300

    tests: audio/sof: Add tests for alloc API testing

    Add initial tests for allocation API testing. Can be extended for
    other later.

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Tue Apr 21 17:49:32 2020 +0300

    logging: Enable xtensa simulator backend for ADSP

    Enable xtensa simulator backend for SOC_FAMILY_INTEL_ADSP.

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon Apr 20 20:58:30 2020 +0100

    soc: xtensa: add common cpu logic

    Support for additional cores.

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
 Date:   Tue Apr 21 10:11:07 2020 +0300

    Update west.yaml to point to the latest repo

    Update west.yaml

    Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon Apr 20 16:17:01 2020 +0100

    soc: xtensa: cavs: Fix build for clk.c on cavs18+

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon Apr 20 16:05:31 2020 +0100

    soc: xtensa: cavs15: removed unused headers.

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon Apr 20 16:05:09 2020 +0100

    soc: xtensa: cavs25: align with SOF headers

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon Apr 20 16:03:52 2020 +0100

    soc: xtensa: cavs20: align with SOF headers

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon Apr 20 16:03:09 2020 +0100

    soc: xtensa: cavs18:  Align with SOF headers.

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon Apr 20 11:42:39 2020 +0100

    west: sof: Updated to latest version.

    Now builds, links and runs SOF code (but not to FW ready).

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Sun Apr 19 13:28:53 2020 +0100

    xtensa: intel adsp: build in SOF symbols if CONFIG_SOF

    Code now fully links against SOF. Needs to be run tested.

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Daniel Leung <daniel.leung@intel.com>
 Date:   Wed Apr 15 10:19:28 2020 -0700

    DO NOT MERGE: temporarily add thesoftproject as remote for sof module

    Signed-off-by: Daniel Leung <daniel.leung@intel.com>

 Author: Daniel Leung <daniel.leung@intel.com>
 Date:   Wed Apr 15 10:33:40 2020 -0700

    ipm: cavs_idc: use the IPC/IDC definitions in SoC

    The SoC definitions have the necessary IPC/IDC bits so there is
    no need to define them separately.

    Signed-off-by: Daniel Leung <daniel.leung@intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Wed Apr 15 14:30:20 2020 +0100

    TODO: config: Use static config for SOF module.

    TODO: needs to be generated as part of SOF kconfig

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Fri Apr 10 21:56:07 2020 +0100

    HACK: Add SOF into build

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Wed Apr 15 13:55:15 2020 +0100

    west: modules: Add SOF audio module.

    Add support for building SOF as a Zephyr module. This is the starting
    point for add SOF audio into Zephyr. Currently builds but does not use
    any symbols yet.

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Wed Apr 15 13:48:48 2020 +0100

    WIP soc: adsp-cavs15: Use same include directory structure as SOF

    Use the same directory structure as SOF to simplify porting and allow
    SOF to build without Zephyr until porting work is complete.

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Wed Apr 15 13:43:44 2020 +0100

    WIP soc: adsp-common: Use same include directory structure as SOF

    Use the same directory structure as SOF to simplify porting and allow
    SOF to build without Zephyr until porting work is complete.

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon Mar 16 14:36:32 2020 +0000

    WIP: soc: adsp-common: cache is common across all Intel ADSP platforms

    De-duplicate soc.h cache definitions.
    TODO: this needs done for other common functions.
    TODO: need to fix include path

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon Mar 30 11:07:43 2020 -0700

    WIP: soc: cavs25: Import SOF SoC support

    SOF commit 2746df76b98f21d3e0b2c5cd4fe405c9a42014a4

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon Mar 30 11:07:12 2020 -0700

    WIP: soc: cavs20: Import SOF SoC support

    SOF commit 2746df76b98f21d3e0b2c5cd4fe405c9a42014a4

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon Mar 30 11:06:40 2020 -0700

    WIP: soc: cavs18: Import SOF SoC support

    SOF commit 2746df76b98f21d3e0b2c5cd4fe405c9a42014a4

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Daniel Leung <daniel.leung@intel.com>
 Date:   Mon Mar 30 12:37:17 2020 -0700

    soc: intel_adsp: use main_entry.S in common for cavs_v15

    The files are identical anyway.

    Signed-off-by: Daniel Leung <daniel.leung@intel.com>

 Author: Daniel Leung <daniel.leung@intel.com>
 Date:   Mon Mar 30 11:38:14 2020 -0700

    soc: intel_adsp/cavs_v15: link common code

    Let cavs_v15 link against the code compiled under common/.

    Signed-off-by: Daniel Leung <daniel.leung@intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon Mar 16 13:08:28 2020 +0000

    WIP: soc: common: Import SOF SoC support

    SOF commit 2746df76b98f21d3e0b2c5cd4fe405c9a42014a4

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon Mar 16 14:37:32 2020 +0000

    WIP soc: adsp-cavs15: build power down support

    Build the power down support for CAVS1.5

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon Mar 16 12:40:17 2020 +0000

    WIP: soc: cavs15: Import SOF SoC support

    SOF commit 2746df76b98f21d3e0b2c5cd4fe405c9a42014a4

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon Mar 16 14:30:08 2020 +0000

    soc: cavs15: Add missing SHIM registers.

    SOF commit 2746df76b98f21d3e0b2c5cd4fe405c9a42014a4

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Mon Mar 9 15:43:01 2020 +0000

    xtensa: intel_adsp/cavs_v15: fix usage of LP SRAM power gating

    Remove LSPGCTL as it can cause confusion, use SHIM_LSPGCTL instead.

    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
 Date:   Wed Feb 26 15:28:48 2020 +0000

    boards: up_squared_adsp: Use local xtensa HAL instead of SDK HAL

    SDK HAL is deprecated for Intel ADSP SoCs so fix and use local HAL
    module.

    Signed-off-by: Daniel Leung <daniel.leung@intel.com>
    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

 Author: Daniel Leung <daniel.leung@intel.com>
 Date:   Mon Mar 30 10:45:15 2020 -0700

    soc: add Intel Audio DSP SoC family

    This creates a SoC family for the audio DSPs on various
    Intel CPUs. The intel_apl_adsp is being moved into
    this family as well, since it is part of the CAVS v1.5
    series of DSPs.

    Signed-off-by: Daniel Leung <daniel.leung@intel.com>

 Author: Daniel Leung <daniel.leung@intel.com>
 Date:   Mon Mar 30 11:29:02 2020 -0700

    soc: xtensa: add CMakeLists.txt

    Add CMakeLists.txt under soc/xtensa so that CMakeLists.txt
    inside each SoC directory will be included, similar to
    what ARM and RISCV have.

    Signed-off-by: Daniel Leung <daniel.leung@intel.com>

 Author: Andy Ross <andrew.j.ross@intel.com>
 Date:   Wed Jun 17 12:30:43 2020 -0700

    Revert "boards: up_squared_adsp: Add flasher script"

    This reverts commit 80f295a9dd.

 Author: Andy Ross <andrew.j.ross@intel.com>
 Date:   Wed Jun 17 12:30:32 2020 -0700

    Revert "boards: up_squared_adsp: Update logtool tool"

    This reverts commit 7770d182c1.

 Author: Andy Ross <andrew.j.ross@intel.com>
 Date:   Wed Jun 17 12:30:23 2020 -0700

    Revert "soc: intel_adsp: Generalize bootloader"

    This reverts commit d6a33ef467.

 Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>

    soc: xtensa; intel: remove sof-config.h - SQUASH

    No longer used.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-10-21 06:38:53 -04:00
Watson Zeng 2354f055ec toolchain: arcmwdt: add compile options: -Wno-typedef-redefinition
Without the -Wno-typedef-redefinition option, arcmwdt (clang based)
complains if a typedef gets redefined in gnu99  mode (since this is
officially a C11 feature). While new versions of GCC do not seem to
issue this warning in gnu99 mode anymore. So some existing code
with typedef redefined which works well with GCC will issue this
warning. As this warning is not fatal, so simply shut it off for good.

Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
2020-10-19 14:06:07 -05:00
Kumar Gala 2619b7cc57 cmake: remove BOARD_FAMILY variable
BOARD_FAMILY isn't used anywhere so remove it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-10-16 18:50:29 -05:00
Torsten Rasmussen 1368295183 cmake: fix DTS handling of multiple overlay files
This commit fixes an issue where providing a list of overlay files for
dts was not handled correctly.
The means that using `-DDTC_OVERLAY_FILE="file1.overlay;file2.overlay"`
would fail as those two file names would be concatenated into a single
file name.

This is fixed by properly quote the `DTC_OVERLAY_FILE` variable.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-10-15 22:47:52 -05:00
Martí Bolívar 8165008f44 dts: remove legacy macro support
The legacy macros were first deprecated in Zephyr v2.3. Now that
Zephyr v2.4 has been released, that makes two releases where these
macros have been deprecated, so it's OK to remove them.

This leaves support for legacy binding syntax in place. Removing that
is left to future work.

We need to update various pieces of documentation related to flash
partitions that never got updated when the new API was introduced.
Consolidate this information in the flash_map.h API reference page,
since that's really where users will run into it. This also gives us
the opportunity to improve this documentation.

Adjust a couple of kconfigfunctions.py and sanitycheck bits to use
non-legacy edtlib APIs.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-10-09 08:45:38 -05:00
Eugeniy Paltsev 9b0ef4f19a ARC: MWDT: drop redundant stack checking
MWDT toolchain has Stackcheck_alloca option enabled by default.
So it adds stack checking in addition to Zephyr's stack checking.

As it is completely redundant let's drop it.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2020-10-02 11:32:12 +02:00
Torsten Rasmussen d1268206cf llvm: use bintools/gnu/target_bintools.cmake
Fixes llvm inclusion of gnu/target_bintools.cmake.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-10-01 22:35:39 -04:00
Erwan Gouriou 531af45b38 cmake: dts: Remove duplicated "Remove duplicates"
"Remove duplicates" step was duplicated.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-10-01 11:08:42 -05:00
Torsten Rasmussen 5d473dc092 cmake: fix zephyr_get_system_include_directories_for_lang() function
This commit fixes the zephyr_get_system_include_directories_for_lang()
function in the event that no system include directories are specified
for Zephyr interface.

This fixes an issue where the value returned by this function is
`-isystem` with no directory.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-22 16:31:32 -05:00
Torsten Rasmussen 2d2fea8732 cmake: create zephyr_get_targets() functions
Fixes: #28197

zephyr_get_targets() provides a mechanism for retrieving all CMake
targets for a given directory and below.

This is useful when including external modules where only libraries
required by Zephyr should be built.

For example, in openthread, this reduces the number of build steps and
build time significantly.

Before, 780 steps:
`time ninja -Cbuild`
[708/708] Linking CXX executable zephyr/zephyr.elf
135.08user 30.24system 0:46.21elapsed 357%CPU

After, 480 steps:
`time ninja -Cbuild`
[480/480] Linking CXX executable zephyr/zephyr.elf
84.02user 18.92system 0:30.72elapsed 335%CPU

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-14 16:40:42 +02:00
Torsten Rasmussen eb2a705497 cmake: support absolute path in zephyr_code_relocate() function
Fixes: #27288

The Zephyr CMake function `zephyr_code_relocate()` would treat any file
argument as relative to `CMAKE_CURRENT_SOURCE_DIR` even if an absolute
path is provided.

A file with absolute path would thus become
`${CMAKE_CURRENT_SOURCE_DIR}/<absolute-path>/<file>` which leads to a
non existing file.

This is fixed by checking if path argument is a relative path, and only
use `CMAKE_CURRENT_SOURCE_DIR` in such case.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-10 16:24:45 -05:00
Jan Van Winkel 5e21434692 cmake: Ignore LDFLAGS and AFLAGS from environment
Zephyr does not use CFLAGS, CXXFLAGS, CPPFLAGS if they are defined in
the environment but provides the option to pass them via extra cmake
flags.

The option is also for seen to pass AFLAGS and LDFLAGS as extra cmake
flags but both of them are not ignored if they are defined in the
environment which could lead to unexpected behaviour.

As such lineup the behaviour between all the flags and ignore them, and
generate a warning, if they are defined in the environment.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2020-09-10 15:35:50 -05:00
Torsten Rasmussen fb16a3deb0 cmake: ensure consistent behavior between x_ROOT settings
Fixes: #23825

Today, BOARD, SOC, ARCH, DTS, KCONFIG, and TOOLCHAIN_ROOT can be
specified by users or through other CMake files.

It is not clear if relative paths are permitted and/or from where a
relative path is constructed.

Inside CMake, it is very easy to specify `${ZEPHYR_BASE}`,
`${CMAKE_CURRENT_SOURCE_DIR}`, or similar, thus there is no reason to
use relative path inside CMake, as it easy can lead to discussion on
relative to what.

For users manually invoking CMake using, `cmake ... <app-dir>` it is
nice to have to possibility to specify a relative path.
For this purpose, relative path are considered relative to the
`APPLICATION_SOURCE_DIR`.

This commit updates:
- BOARD_ROOT
- SOC_ROOT
- ARCH_ROOT
- DTS_ROOT
- KCONFIG_ROOT
- TOOLCHAIN_ROOT

to allow paths relative to `APPLICATION_SOURCE_DIR` when specified with
`-D<type>_ROOT=<relative-path>`

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-10 21:30:24 +02:00
Torsten Rasmussen 3083205f4d cmake: introduce zephyr_file() extension command
Fixes: #23825

This commit introduces a `zephyr_file()` extension command that allows
for examine a path list for relative paths, and convert relative paths
provided with `-D<path>` into absolute paths, starting from
`APPLICATION_SOURCE_DIR`.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-10 21:30:24 +02:00
Torsten Rasmussen a5917f0af4 cmake: export build flags to external build systems excluding SHELL tag
Fixes: #28230

The introduction of CMake SHELL prefix in compile options to avoid
symbol de-duplication caused the build flag export feature to fail.

The export itself works, but unfortunately CMake only strips `SHELL`
prefix for its own compiler invocation, and not when exporting the build
flags.

This causes `SHELL` to be present in the Makefile.exports.<language>
files, leading to problems in external build systems.

This is fixed by using `zephyr_get_compile_options_for_lang()` that
strips `SHELL` and use the returned value for the export handling.

To ensure all compile options has been defined, then the inclusion of
`cmake/makefile_exports` has been moved to the end of
`zephyr/CMakeLists.txt` file.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-10 11:31:53 +02:00
Torsten Rasmussen 5c10eafb2b cmake: improved handling of CONF_FILE cached variable
Fixes: #28134

Minor fix for correctly testing if CONF_FILE variable is defined, and
if it is defined, then a current scope variable will be set with same
name. For a variable that is already present in current scope this has
no effect, but a cached variable (such as one provided with -DCONF_FILE)
will now have both a current scope and cached definition.
This ensures that current scope CONF_FILE will continue to be defined
even when the cached variable is cleared later.

Clearing of the cached variable ensures correct detection if user later
re-invokes CMake with a new -DCONF_FILE value.

The cached version is cleared later in favor of the CACHED_CONF_FILE
that is used between multiple CMake invocations.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-08 14:01:54 +02:00
Torsten Rasmussen 27e1fd69f9 cmake: c++ compiler flag exclusion, -Werror=implicit-int
Fixes: #28097

The compiler warning flag `-Werror=implicit-int` was added using
`set_compiler_property()` which will always add the compiler flag if the
compiler flag supports it.

This has been changed to `check_set_compiler_property()` which will
check if the flag is among the list of `CXX_EXCLUDED_OPTIONS`, and only
adds the flag if both the compiler supports it, and it is not an
excluded option.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-07 17:22:37 +02:00
Torsten Rasmussen 9aa4039d41 cmake: MWDT linker command list fix.
This commit fixes an issue where the list returned by
zephyr_get_include_directories_for_lang() would be a space separated
list, cause the arguments to be quoted during linking.

This is fixed by requesting `$<SEMICOLON>` to be used as separated which
which again ensures a correct expansion of the list.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-05 10:22:56 -05:00
Torsten Rasmussen 571f48fc77 cmake: mwdt bintools adopted to new toolchain abstraction
This commit converts the MWDT bintools implementation from the old
macro based approach and into the new toolchain property scheme.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-05 10:22:56 -05:00
Torsten Rasmussen 93e063ffc8 cmake: mwdt compiler adopted to new toolchain abstraction
This commit converts the MWDT compiler implementation from the old
macro based approach and into the new toolchain property scheme.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-05 10:22:56 -05:00
Eugeniy Paltsev 6dfaac0c95 cmake: allow to specify compliler for DTS preprocessing
MWDT CCAC compiler can't handle the dts file as gcc does, so
allow to specify compliler for DTS preprocessing which is differ
from ${CMAKE_C_COMPILER}.

Use ARC GNU compiler for DTS preprocessing in case of MWDT
toolchain.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2020-09-05 10:22:56 -05:00
Wayne Ren b868018b51 cmake: add metaware toolchain support in build system
* add metaware toolchain support in build system:
   * compiler
   * linker
   * binutils
     * gcc objcopy is used because it can't be replaced
       with mwdt's binutils currently
* To use ARC metaware toolchain, you'd better:
   * in Linux/Unix environment
   * install arc gcc/zephyr toolchain to use gnu's objcopy
     tool
   * set ZEPHYR_TOOLCHAIN_VARIANT=arcmwdt

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2020-09-05 10:22:56 -05:00
Torsten Rasmussen f160dee935 cmake: bintools abstraction, support <command>_flag_final property
This command add support for `<command>_flag_final` to all bintools
commands.

This allows users that has special use-cases to use a CMake script
for bintool command execution, and thereby have full control of command
invocation and argument processing.

Example of how to specify the property for such use:
Calling a custom script for elfconvert command:
set_property(TARGET bintools
             PROPERTY elfconvert_command ${CMAKE_COMMAND})
set_property(TARGET bintools
             PROPERTY elfconvert_flag "")
set_property(TARGET bintools
             PROPERTY elfconvert_flag_final     -P elfconvert.cmake)
set_property(TARGET bintools
             PROPERTY elfconvert_flag_strip_all "-DSTRIP_ALL=True")
set_property(TARGET bintools
             PROPERTY elfconvert_flag_infile    "-DINFILE=")
set_property(TARGET bintools
             PROPERTY elfconvert_flag_outfile   "-DOUT_FILE=")

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-04 20:36:59 +02:00
Torsten Rasmussen b94ce67899 cmake: get Zephyr settings for language extension
This commit updates the get Zephyr settings functions to be able to
handle settings if those settings are expressed using a generator
expression.

As example, zephyr_get_include_directories_for_lang(...) would prefix
each include property of zephyr_interface with `-I`, like this:
Property: include;include/generated;lib/libc/minimal/include
becomes: `-Iinclude -Iinclude/generated -Ilib/libc/minimal/include`

But if the property contains a generator expression:
Property: include;$<TARGET_PROPERTY:compiler,some_include>
becomes: -Iinclude -I$<TARGET_PROPERTY:compiler,some_include>
and in case that property is a list, this results in:
`-Iinclude -Iinclude/list_item1;include/list_item2;include/list_itemN`
and thus breaking the build.

This is fixed by using `$<JOIN:<list>>` expression instead, which
ensures all list item, regardless of provided as simple list or through
the usage another generator expression, will always expand correctly.

Functions updated in the commit:
- zephyr_get_include_directories_for_lang
- zephyr_get_system_include_directories_for_lang
- zephyr_get_compile_definitions_for_lang
- zephyr_get_compile_options_for_lang

The sample `application_development/external_lib` has been updated
according to those changes.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-04 20:36:59 +02:00
Torsten Rasmussen 9d501f4ba8 cmake: Remove SHELL: tag in process_flags function
When fetching include, system include, compiler options, or compiler
defines, then it is important to strip the SHELL: (no de-duplication)
tag of any flag.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-04 20:36:59 +02:00
Torsten Rasmussen 3c761e8180 cmake: fixed regex handling in process_flags function extensions.cmake
This commit fixes an issue in the process_flags function.
The function check a list of flags for generator expression for provided
language, for example:
$<$<COMPILE_LANGUAGE:C>:--flag>
and then converts that into a single compile flag, `--flag`

This works as long as $<COMPILE_LANGUAGE:[language]> is the only
generator expression present in the flag.

In case the flag contains multiple generator expression, then the
current substitution fails.

This commit keep existing behaviour for simple cases, but extends the
more complex cases into a always enabled generator expression, that is
$<$<COMPILE_LANGUAGE:C>:$<ADDITIONAL_EXPRESSION>> into
$<1:$<ADDITIONAL_EXPRESSION>>
and
$<$<FIRST_EXPRESSION>$<COMPILE_LANGUAGE:C>:--flag> into
$<$<FIRST_EXPRESSION>$<1:--flag>

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-04 20:36:59 +02:00
Torsten Rasmussen 73117e7cad toolchain: Xtensa C compiler using new abstraction pattern
The Xtense xcc compiler now uses the new compiler abstraction.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-04 20:36:59 +02:00
Torsten Rasmussen 31a1411cbd cmake: toolchain: Toolchain abstraction templates
As part of toolchain abstraction three template files to facilitate
additional toolchain support development has been introduced.

Those covers:
- bintools
- compiler flags
- linker flags

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-04 20:36:59 +02:00
Torsten Rasmussen c060b075a6 cmake: toolchain: bintools abstraction
GNU/bintools abstraction completed.
The following commands and flags are now available in bintools:
- memusage
- elfconvert
- dissassembly
- readelf
- strip

The bintools template has now been updated with more description which
will be useful when adding support for more toolchains in future.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-04 20:36:59 +02:00
Torsten Rasmussen c55c64e242 toolchain: improved toolchain abstraction for compilers and linker
First abstraction completed for the toolchains:
- gcc
- clang

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-04 20:36:59 +02:00
Torsten Rasmussen 212c336400 cmake: extend support for conf file and board overlays
Fixes: #27934

This commit introduces additional naming support of config files.

It is now possible to create a config file of the form
`prj_<build>.conf` and automatically have a corresponding
`boards/<BOARD>_<build>.conf` config file merged.

As example, one can create a structure as:
|-- prj.conf
|-- prj_debug.conf
|-- boards
      |-- nrf52840dk_nrf52840.conf
      |-- nrf52840dk_nrf52840_debug.conf

when building: (existing behavior)
cmake -DBOARD=nrf52840dk_nrf52840 ...
prj.conf is merged with nrf52840dk_nrf52840.conf

when building: (new behavior)
cmake -DBOARD=nrf52840dk_nrf52840 -DCONF_FILE=prj_debug.conf ...
prj_debug.conf is merged with nrf52840dk_nrf52840_debug.conf

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-04 17:52:27 +02:00
Henrik Brix Andersen 7e39e1d747 cmake: mcuboot: confirmed images needs to be padded
Add --pad to imgtool.py command line arguments when generating confirmed
images, otherwise the image contains no trailer magic for writing the
confirmed status.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-09-04 12:00:04 +02:00
Martí Bolívar 003d30b6f0 cmake: flash signed binaries for mcuboot
When CONFIG_MCUBOOT_SIGNATURE_KEY_FILE is set and the build system
successfully creates signed outputs, use them as the default artifacts
to flash.

This flashes the non-confirmed variant regardless of
CONFIG_MCUBOOT_GENERATE_CONFIRMED_IMAGE, allowing POST code in the
application to confirm the image or not. Since this is used primarily
from development, I'd hesitate to assume the confirmed image is good.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-09-03 16:49:09 -05:00
Martí Bolívar 3124c02987 cmake: flash/debug: refactor runner configuration
This commit message is a bit of a novel mostly:

- because the issues involved are longstanding
- as evidence this is not a capricious refactoring

The runners.core.RunnerConfig Python class holds common configuration
values used by multiple runners, such as the location of the build
outputs and board directory.

The runners code, first written in 2017-ish, replaced various shell
scripts that got this information from the environment. Avoiding
environment variables was a requirement, however. It's ghastly to set
environment variables for a single command invocation on Windows, and
the whole thing was part of a larger push to make Zephyr development
on Windows better.

I had a hammer (the argparse module). Finding a replacement naturally
looked like a nail, so the information that ends up in RunnerConfig
got shunted from the build system to Python in the form of 'west
flash' / 'west debug' command line options like '--board-dir',
'--elf-file', etc.

I initially stored the options and their values in the CMake cache.
This was chosen in hopes the build system maintainer would like
the strategy (which worked).

I knew the command line arguments approach was a bit hacky (this
wasn't a nail), but I also honestly didn't have a better idea at the
time.

It did indeed cause issues:

- users don't know that just because they specify --bin-file on the
  command line doesn't mean that their runner respects the option, and
  have gotten confused trying to flash alternate files, usually for
  chain-loading by MCUboot (for example, see #15961)

- common options weren't possible to pass via board.cmake files
  (#22563, fixed partly via introduction of runners.yaml and the west
  flash/debug commands no longer relying on the cache)

- it is confusing that "west flash --help" prints information about
  openocd related options even when the user's board has no openocd
  support. The same could be said about gdb in potential future use
  cases where debugging occurs via some other tool.

Over time, they've caused enough users enough problems that
improvements are a priority.

To work towards this, put these values into runners.yaml using a new
'config: ...' key/value instead of command line options.

For example, instead of this in the generated runners.yaml file:

args:
  common:
  - --hex-file=.../zephyr.hex

we now have:

config:
  hex_file: zephyr.hex

and similarly for other values.

In Python, we still support the command line options, but they are not
generated by the build system for any in-tree boards. Further work is
needed to deprecate the confusing ones (like --hex-file) and move the
runner-specific host tool related options (like --openocd) to the
runners that need them.

Individual board.cmake files should now influence these values by
overriding the relevant target properties of the
runners_yaml_props_target.

For example, instead of:

  board_runner_args(foo "--hex-file=bar.hex")

Do this:

  set_target_properties(runners_yaml_props_target PROPERTIES
                        hex_file bar.hex)

This change additionally allows us to stitch cmake/mcuboot.cmake and
the runners together easily by having mcuboot.cmake override the
properties that set the hex or bin file to flash. (The command line
arguments are still supported as-is.)

Combined with 98e0c95d91ae16f14e4997fb64ccdf0956595712 ("build:
auto-generate signed mcuboot binaries"), this will allow users to
build and flash images to be chain loaded by mcuboot in a way that
avoids calling 'west sign' and passing 'west flash' its output files
entirely.

While we are here, rename runner_yml_write to runners_yaml_append().
This function doesn't actually write anything, and we're here
refactoring this file anyway, so we might as well improve the
situation while we're at it.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-09-03 16:49:09 -05:00
Martí Bolívar e27b36807a cmake: rename and move runner_yml_props_target to boilerplate
Rename it to "runners_yaml_props_target", because the file name is
runners.yaml, not runner.yml.

Move it to the boilerplate definition so that we can modify it before
cmake/flash/CMakeLists.txt gets run.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-09-03 16:49:09 -05:00
Martí Bolívar db4df3ce1a cmake: flash: remove stale cache variables
Commit c1f80db44a removed various
now-unused CMake cache variables, but it missed the ones that begin
with ZEPHYR_RUNNER_ARGS. Delete those now.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-09-03 16:49:09 -05:00
Daniel Leung 9eebe6a45e cmake: add WEST to cached variable
Commit 79b1f89f7d causes the WEST
variable to no longer cached in the CMakeCache. However,
the Eclipse plugin needs this WEST variable so that it can
invoke west properly. So tell CMake to put it in the cache.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-09-03 17:32:48 -04:00
Watson Zeng fad20c42c6 boards: arc: nsim: add a new board nsim_em7d_v22
Typically we have ARC core configurations where Fast IRQs (FIRQ) are
enabled together with multiple register files and those we have covered
by testing. But FIRQ & single register bank we only happen to have on
the older EMSK v2.2.it might be a good idea to add a similar
configuration to nSIM "boards" so that we keep it tested regularly.

nsim_em7d_v22 configuration is similar with em_staterkit_em7d_v22,
both configed with FIRQ & single register bank.

Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
2020-09-03 21:47:51 +02:00
Rihards Skuja 38e1bf1f29 cmake: toolchain: fix unsupported warnings for C++ builds
Compile with arm-none-eabi-g++ (10.2.0 with -std=c++17) generates a
warning for every C++ source file:
"cc1plus: warning: command-line option '-Wno-pointer-sign' is valid for
C/ObjC but not for C++"

Get rid of those warnings by adding '-Wno-pointer-sign' to the list of
excluded CXX options.

Signed-off-by: Rihards Skuja <rihardssk@mikrotik.com>
2020-09-03 21:47:14 +02:00
Torsten Rasmussen 6dc8f0e79e cmake: dts overlay file with mixed separator style support
Fixes: #26112

All file paths provided on the list of overlay files are converted to
CMake style paths.

This ensures that even paths with mixed style `\` and `/` on Windows are
treated correctly. This fixes the issue where the deps file created
would cause ninja to re-invoke CMake in an endless loop on windows.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-03 14:45:13 -05:00
Peter A. Bigot 0950b2549e dts: support specifying preprocessor flags for devicetree
In some cases it is useful to use the C preprocessor to control the
content of a devicetree file.  A specific use case is in testing,
where different combinations of node properties must be checked.
Provide a mechanism to allow arbitrary preprocessor flags to be passed
through CMake to affect the devicetree content.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-09-03 14:02:36 -05:00
Carles Cufi f8ad4d5f87 scripts: size_report: Fix colorized output
Colorama needs to be initialized, and for colors to display correctly on
Windows one needs to use the `USES_TERMINAL` option in CMake.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-09-03 09:54:21 -04:00
Martí Bolívar f66a0c3772 build: auto-generate signed mcuboot binaries
Add new Kconfig options which depend on CONFIG_BOOTLOADER_MCUBOOT:

- CONFIG_MCUBOOT_SIGNATURE_KEY_FILE: the path to the key pair which
  should be used to sign the image, in PEM format. This is sent to
  imgtool via 'west sign' when set to produce zephyr.signed.bin and
  zephyr.signed.hex files as needed.

- CONFIG_MCUBOOT_EXTRA_IMGTOOL_ARGS: additional arguments to pass to
  imgtool.

- CONFIG_MCUBOOT_GENERATE_CONFIRMED_IMAGE: also generate
  zephyr.signed.confirmed.{bin,hex}

Add build system support for these options.

This makes a separate 'west sign' step unnecessary when using MCUboot,
if the application image is properly configured with the location of
the key file.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-09-01 13:33:46 +02:00
Martí Bolívar a0382cb925 cmake: add IMGTOOL optional dependency
This will be used in subsequent patches to integrate imgtool into the
build when the user has set CONFIG_BOOTLOADER_MCUBOOT=y.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-09-01 13:33:46 +02:00
Martí Bolívar c32e90d2a5 build: update stale comment in boilerplate.cmake
The zephyr_property_target use cases have grown.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-09-01 13:33:46 +02:00
Martí Bolívar 79b1f89f7d cmake: west detection fixes and improvements
Starting with west 0.8, we will have a stable way to run west as a
python module. In west 0.7, we have an undocumented way.

Handle these two cases to override the WEST variable used by the build
system to run west inside the same python interpreter as the rest of
the build system. This makes it intuitive to shell out to west from
elsewhere in the build, without making people reimplement existing
commands in the west API when it is not necessary.

Do so for the 'west topdir' invocation in west.cmake as an example.

The check that looks for whether PYTHON_EXECUTABLE and WEST_PYTHON
match is also not working properly when symbolic links are in use.
Fix it by using REALPATH instead of ABSOLUTE in the
get_filename_component() calls.

Finally, print the error on a failed import that we expect to work.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-09-01 13:33:46 +02:00
Ismael Fillonneau fc8f639b9a shields: Modify overlay file order
Shield overlay file has to be taken into account after board overlay
file.
ex: When a new node need to be created for a specific board (in
boards/shields/shield_name/boards/board_name/*.overlay) and used by the
shield (in boards/shields/*.overlay), the order of the overlay files is
important

Signed-off-by: Ismael Fillonneau <ismael.fillonneau@stimio.fr>
2020-09-01 13:30:06 +02:00
Torsten Rasmussen 2fa48f79d1 cmake: warn user if CPPFLAGS is set as environment setting
Zephyr doesn't use CFLAGS, CXXFLAGS, and CPPFLAGS if they are defined
in environment.

In case user defines CFLAGS or CXXFLAGS in environment, then a warning
message is printed, however CPPFLAGS does not raise a warning.

CPPFLAGS is updated to follow the principle of CFLAGS and CXXFLAGS.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-01 13:29:24 +02:00
Torsten Rasmussen 4e8a991590 cmake: Zephyr module error on module name current
In CMake, ZEPHYR_CURRENT_MODULE_DIR is used during processing of module
CMakeLists.txt files.
If a module is named `current` then it's corresponding
`ZEPHYR_<module_name>_MODULE_DIR` would become ZEPHYR_CURRENT_MODULE_DIR
and thus colliding with internal Zephyr CMake variable.

Using module name `current` is therefore forbidden.
Print an error to users when a module named `current` is used in
Zephyr.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-08-31 12:15:02 +02:00
Torsten Rasmussen a861fc96b2 cmake: export Zephyr modules as Kconfig variables.
In CMake it is possible to reference each Zephyr module as a CMake
variable. This commit introduces the same feature to Kconfig, so that
it is possible to reference a module in consistent way in both CMake
and Kconfig.

To include a file from module FOO in CMake, use:
include(${ZEPHYR_FOO_MODULE_DIR}/somefile.cmake

To source a file from module FOO in Kconfig, use:
source "$(ZEPHYR_FOO_MODULE_DIR)/Kconfig.somefile"

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-08-31 12:15:02 +02:00
Torsten Rasmussen ab7ec17b86 cmake: zephyr module processing improvements.
This commit improves Zephyr modules support in CMake.
All Zephyr modules will now have a corresponding
`ZEPHYR_${module_name}_MODULE_DIR` set, regardless of whether they
define a cmake folder in module.yml.

This results in:
`ZEPHYR_${module_name}_MODULE_DIR` defined for all modules and refers to
the root of the modle.
`ZEPHYR_${module_name}_CMAKE_DIR` defined for modules that specifies
cmake in module.yml, or is having both a CMakeLists.txt and Kconfig file
in the zephyr folder.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-08-31 12:15:02 +02:00
Torsten Rasmussen 2fc062b3a4 cmake: zephyr modules variable names.
This commit refactors processing of Zephyr modules.
The Zephyr module name processing has been moved to zephyr_modules.cmake
to ensure that all `ZEPHYR_<MODULE_NAME>_MODULE_DIR` are defined early
in the build system.

No changes to inclusion of Zephyr module CMake code.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-08-31 12:15:02 +02:00
Torsten Rasmussen c8295b19aa cmake: kconfig cmake file environment cleanup
This commit is a cleanup of the cmake/kconfig.cmake file.
It removes `set(ENV{<name>} <value>)` and instead creates a shared list
that can be used for execute_process() and add_custom_target() when
running Kconfig during CMake configure time or menuconfig and related
build targets.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-08-31 12:15:02 +02:00
Flavio Ceolin 438adb0109 coding_guideline: Add optional flag to check override initialization
This enforce Rule 9.4

"""
An element of an object shall not be initialized more than once
"""

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-08-28 16:50:39 -04:00
Flavio Ceolin d34c44d724 coding_guideline: Add optional flag to check invalid conversions
Generate errors for implicit conversions that may alter a value, that
covers conversions implicit conversions to narrower types, different
signal, different essential types (float -> int), ... From GCC
documentation
(https://gcc.gnu.org/onlinedocs/gcc-9.3.0/gcc/Warning-Options.html)

"""
Warn for implicit conversions that may alter a value. This includes
conversions between real and integer, like abs (x) when x is double;
conversions between signed and unsigned, like unsigned ui = -1; and
conversions to smaller types, like sqrtf (M_PI). Do not warn for
explicit casts like abs ((int) x) and ui = (unsigned) -1, or if the
value is not changed by the conversion like in abs (2.0). Warnings
about conversions between signed and unsigned integers can be disabled
by using -Wno-sign-conversion.

For C++, also warn for confusing overload resolution for user-defined
conversions; and conversions that never use a type conversion
operator: conversions to void, the same type, a base class or a
reference to them. Warnings about conversions between signed and
unsigned integers are disabled by default in C++ unless
-Wsign-conversion is explicitly enabled.
"""

This partially cover rules: 10.4, 10.5, 10.6, 10.7 and 10.8

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-08-28 16:50:39 -04:00
Flavio Ceolin 4bf529a4b9 coding_guideline: Add optional fallthrough enforcement flag
Add implicit-fallthrough flag when CONFIG_MISRA_SANE is set.
It will require __fallthrough macro or a proper comment tells the
compiler that this happens intentionally.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-08-28 16:50:39 -04:00
Flavio Ceolin b587e8d063 coding_guideline: Add an option to enforce rules
Add a Kconfig option to enable compiler flags that help to enforce
some code guideline rules.

Note: As the current code base is not in compliance with the adopted
code guideline, some rules will generate warnings during the
build. This is intended to help to spot violations.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-08-28 16:50:39 -04:00
Torsten Rasmussen 6c294bc0b8 cmake: zephyr_module.py working directory when listing modules
Fixes: #27237

This commit fixes an issue when `zephyr_module.py` was executed outside
a west workspace.
This would happen when build an out-of-tree (out-of-workspace)
application, in which case the current west workspace would be unknown.

This is now changed, so that execution of `zephyr_module.py` will be
done in the current Zephyr base.
This ensures that the west workspace that holds the current Zephyr will
be the same workspace used for west list, and hence solve fix the issue.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-08-26 14:25:17 -04:00
Anas Nashif d0f5253f9e Revert "compiler: gcc: Add warning option to spot poblematic switches"
This reverts commit 680f401ef2.

3rd party code in modules is failing due to this enforcment. We need a
away to exclude module code to support such options.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-08-25 12:57:05 -04:00
Flavio Ceolin 680f401ef2 compiler: gcc: Add warning option to spot poblematic switches
Option -Wimplicit-fallthrough as the name suggests raises a warning when
there is an implicit fallthrough in a switch clause. This warning does
not happen when the last statement is a return or a call to a function
declared with noreturn attribute.

This flag helps to enforce two MISRA-C rules (not completely), 16.1 and
16.3

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-08-24 20:28:47 -04:00
Martí Bolívar c1f80db44a cmake: flash: remove unused cache variables
Resolve a TODO item that followed the introduction of runners.yaml
files by removing the now-unused CMake cache variables that they
obsolete.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-08-19 09:51:13 -04:00
Anas Nashif f420c7bb8d cmake: generate json file for ram/rom reports
Create a json file from the output of ram/rom report targets.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-08-14 18:49:26 -04:00
Henrik Brix Andersen 8acd7966af cmake: gcc: add support for compiling for the ARM Cortex-M1
Add support for compiling for the ARM Cortex-M1 CPU via GCC.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2020-08-14 13:35:39 -05:00
Wayne Ren 6f6fddf7e9 cmake: combine nsim and mdb for emulation
* to avoid confusion, combine nsim and mdb related
cmake configurations.

* this also enable the lanuch of mdb in sanitycheck

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2020-08-14 13:30:56 +02:00
Anas Nashif 07b4df1945 cmake: put elf files for Qemu in /zephyr
The ELF files were placed in ${CMAKE_BINARY_DIR} when all other ELF
files are actually in ${CMAKE_BINARY_DIR}/zephyr, so keep things
consistent and in one place.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-08-13 12:42:27 -04:00
Kumar Gala a15c8717e3 cmake: Set TOOLCHAIN_ARCH based on OS_PLATFORM
To support a host environment of aarch64 (arm64) or x86_64 set
TOOLCHAIN_ARCH based on what OS_PLATFORM reports (which Linux will be
result of 'uname -m').

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-08-07 06:54:18 -05:00
Torsten Rasmussen 9ca3f61947 cmake: convert WEST_PYTHON path to be correct CMake style
The `WEST_PYTHON` reported by west (python) may use a different path
style (casing and separator) than the path style in CMake
find_package(Python3).

This may result in following additional error text when west version is
not meeting the minimum required version:

    The Python version used by west is:  c:\python37\python.exe
    The Python version used by CMake is: C:/Python37/python.exe
    This might be correct, but please verify your installation.

Using `get_filename_component` will return the path in same style as
CMake find_package(Python3).

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-08-06 13:49:08 +02:00
Torsten Rasmussen 25d57ba5af modules: adding support for ROOTs definitions in zephyr/module.yml
Fixes: #25215

This commit introduces the possibility of defining ROOTs in a Zephyr
module and have it automatically appended to list of other ROOTs.
Supported with this commit:
- BOARD_ROOT
- SOC_ROOT
- DTS_ROOT
- ARCH_ROOT

In order to support this in Zephyr module files, the detection of west
has been moved to dedicated west.cmake file and included immediately
after python.cmake.

Also the inclusion of zephyr_modules.cmake has moved before first use
of BOARD_ROOT.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-08-05 08:06:07 -04:00
Torsten Rasmussen 14b60200bd cmake: allowing list of ARCH_ROOTs
This commit aligns ARCH_ROOT to conform to BOARD_ROOT, DTS_ROOT,
SOC_ROOT that all allows list of directories.

Also it avoid code, such as:
if(BOARD STREQUAL my_board_using_out_of_tree_arch)
  set(ARCH_ROOT some/out/of/tree/arch/path)
endif()
in application CMakeLists.txt.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-08-05 08:06:07 -04:00
Torsten Rasmussen 5f7cc8ded9 cmake: kconfig: support for multiple SOC_ROOT
This commit introduces support for multiple SOC_ROOT.

This means that additional SOC_ROOTs specified using -DSOC_ROOT as
argument to CMake will be forming a list together with ${ZEPHYR_BASE}.

This allows for greater flexibility, as developers can now specify
multiple out-of-tree SoCs and not worry about the SoC used for the
board they compile for.

Also it avoid code, such as:
if(BOARD STREQUAL my_board_using_out_of_tree_soc)
  set(SOC_ROOT some/out/of/tree/soc/path)
endif()
in application CMakeLists.txt.

Finally, allowing multiple SOC_ROOTs prepares for specifying SOC_ROOTs
in Zephyr modules.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-08-05 08:06:07 -04:00
Torsten Rasmussen 01f55a4e53 cmake: relocation of generated Kconfig file for Zephyr modules
This commit relocates the generated Kconfig.modules file from
${CMAKE_BINARY_DIR} into ${CMAKE_BINARY_DIR}/Kconfig.

This is done as preparation of multiple SOC and ARCH root support.

A single Kconfig folder inside ${CMAKE_BINARY_DIR} helps to keep the
build folder tidy.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-08-05 08:06:07 -04:00
Aleksandr Koltsoff 0f44669ceb cmake: sort shield list and improve indent
Currently, when usage.cmake is run, the shield list is in construction
order, making it difficult to locate the shield of interest. This sorts
the list upon display and also makes the display indent consistent.

Signed-off-by: Aleksandr Koltsoff <czr@iki.fi>
2020-08-05 12:01:49 +02:00
Carles Cufi 244f826e3c cmake: remove _if_kconfig() functions
This set of functions seem to be there just because of historical
reasons, stemming from Kbuild. They are non-obvious and prone to errors,
so remove them in favor of the `_ifdef()` ones with an explicit
`CONFIG_` condition.

Script used:

git grep -l _if_kconfig | xargs sed -E -i
"s/_if_kconfig\(\s*(\w*)/_ifdef(CONFIG_\U\1\E \1/g"

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-08-01 12:35:20 +02:00
Martí Bolívar 9c92baa73f devicetree: use edt.pickle more
Consolidate creation of edtlib.EDT objects from a build directory's
devicetree into one place by loading it from build/zephyr/edt.pickle
everywhere. A previous commit creates edt.pickle from gen_defines.py.

In addition to probably speeding things up slightly by not reparsing
the devicetree, the main benefit of this approach is creating a single
point of truth for the bindings directories and warnings
configuration, meaning we don't have to worry about them getting out
of sync while being passed around between devicetree creation and
usage time.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-07-23 09:19:45 -05:00
Daniel Leung ba5f627815 scripts: size_report: rework to use pyelftools...
...instead of GNU binutils to extract DWARF information.
This is now a bit more portable across OS and toolchain.
One bouns is that this nows with on qemu_x86_64.

A few differences are:
() z_mrsh_* which are aliases to handler_no_syscalls() are now
   dropped as they are mapped to the same address, so that they
   are not counted multiple times.
() Static functions and variables with same names should now be
   attributed to the correct source files instead of being
   accumulated into the same symbol of one file (e.g. multiple
   thread_entry() in kernel tests).
() The totals for ROM and RAM are calculated from the
   corresponding sections. Previous script includes the debug
   sections as total ROM size which is not entirely correct.

Fixes #22996

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-07-16 12:14:22 +02:00
Martí Bolívar b08309e992 cmake: fix kconfig targets
Commit 269f350487 introduced a new
mechanism for loading the edtlib.EDT representation of the devicetree
from kconfigfunctions.py.

While this works for running kconfig.py from kconfig.cmake using
execute_process(), it doesn't work when kconfigfunctions.py is loaded
by the menuconfig target or any other Kconfig targets that use
add_custom_target().

The reason why is that these targets' environments do not have the
location of the EDT pickle file available. This is unlike kconfig.py,
which executes using the same environment as cmake itself, where
edt.pickle's location is already available in the environment.

Fix that by adding EDT_PICKLE to the environment for menuconfig and
friends.

Reported-by: Simon Guinot <simon.guinot@seagate.com>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-07-10 11:26:11 +02:00
Martí Bolívar a043d48c54 cmake: fix the build on windows
Commit ef3c5e5516 changed the way
WEST_TOPDIR is initialized from calling 'west topdir' as a subprocess
to using the west API.

However, WEST_TOPDIR is a cmake variable and must be a cmake-style
path, with forward slashes. While 'west topdir' as a command does
output a forward slash separated path (basically in order to make the
zephyr build system work), west_topdir() as an API returns the path in
the host environment path style, which on Windows uses backslashes.

This turns out to be the ultimate cause of the following build error:

CMake Error at C:/.../CheckCCompilerFlag.cmake:41 (set):
  Syntax error in cmake code when parsing string
    -fmacro-prefix-map=C:\Users\Marti\zp=WEST_TOPDIR

Fix it by converting to POSIX style in Python. We could have
potentially also done this using file(TO_CMAKE_PATH "${WEST_TOPDIR}"
...), but I'm intentionally repeating the old way of doing things
since it was known to work.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-07-09 18:13:44 -04:00
Henrik Brix Andersen b36aea82ce build: reports: add pahole target
Poke-a-hole (pahole) is an object-file analysis tool to find the size of
the data structures, and the holes caused due to aligning the data
elements to the word-size of the CPU by the compiler.

http://git.kernel.org/cgit/devel/pahole/pahole.git

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-07-09 06:24:00 -04:00
Torsten Rasmussen ef3c5e5516 cmake: west: invoke west using same python as rest of build system
When running CMake, then Python3 will be used.
This is detected through FindPython3, with a preference for using the
python or python3 in path, if any of those matches the required Python
minimal version in Zephyr.

It is also possible for users to specify a different Python, as example
by using:
`cmake -DPYTHON_PREFER=/usr/bin/python3.x`

However, when running `west` as native command, then west will be
invoked on linux based on the python defined in:
`west` launcher, which could be: `#!/usr/bin/python3.y`

Thus there could be mismatch in Pythons used for `west` and the python
used for other scripts.

This is even worse on windows, where a user might experience:
```
>.\opt\bin\Scripts\west.exe --version
Traceback (most recent call last):
  File "C:\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  ...
  File "C:\Python37\lib\socket.py", line 49, in <module>
    import _socket
ImportError: Module use of python38.dll conflicts with this version of
Python.
```

when testing out a newer Python, but the python in path is still a 3.7.

By importing `west` into zephyr_module.py and by using, as example
`python -c "from west.util import west_topdir; print(topdir())"`
we ensure the same python is used in all python scripts.

Also it allows the user to control the python to use for west.

It also ensures that the west version being tested, is also the version
being used, where old code would test the version imported by python,
but using the west in path (which could be a different version)

If the west version installed in the current Python, and west invocation
is using a different Python interpreter, then an additional help text
is printed, to easier assist users with debugging.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-07-08 23:23:04 -04:00
Martí Bolívar 148542c080 build: remove dead stores to environment
Now that kconfigfunctions.py is loading the EDT object from a pickle
file, I can't find any other reads of the environment variables it was
previously using to do that.

(The CMake variables with the same names are read in different places;
I'm specifically talking about environment variables here.)

Remove the dead stores.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-07-08 14:02:44 -05:00
Martí Bolívar 269f350487 kconfig: load edt from edt.pickle
This saves time and avoids the need to pass additional state around in
the environment to recreate the edt exactly.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-07-08 14:02:44 -05:00
Martí Bolívar 533f451e7e dts: marshal the EDT object for later use
We need to save and restore the devicetree data to generate optimized
dependency information later on in the build, in particular during the
final application link.

Make this happen by pickling the EDT object in BUILD_DIR/edt.pickle.

The existence of this file is an implementation detail, so do not add
it to the documentation.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-07-08 14:02:44 -05:00
Torsten Rasmussen 13642fe013 cmake: west: west flash dependencies in sync with CMake flash target
This commit creates a list of a phony targets for each runner, that is:
`west_flash_depends`, `west_debug_depends`, and so on.
Those targets has identical dependencies as CMake runner target.
flash, debug, debugserver, attach targets.

As example `ninja flash` correctly ensures dependencies are taken into
consideration before calling `west flash`.

Unfortunately, calling `west flash` directly would not re-run the flash
dependencies, cause `west flash` would only build the default CMake
target.

Now, `west flash` calls the phony `west_flash_depends` target, ensuring
all deps are up-to-date before flashing (unless --skip-rebuild is given)

The same is true for the other mentioned runners.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-07-01 07:58:10 -04:00
Torsten Rasmussen d38da9d386 cmake: runners dependencies cleanup
This commit renames `FLASH_DEPS` to `RUNNERS_DEPS`.
The current name `FLASH_DEPS` is misleading in the sense that this
depency is added to all runner targets, flash, debug, debugserver,
attach, and not only the flash runners.

Therefore this is now named `RUNNERS_DEPS` instead.

Similar, zephyr_property_target now contains the property
FLASH_DEPENDENCIES, DEBUG_DEPENDENCIES, and so on, so that additional
dependencies can be added for each runner.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-07-01 07:58:10 -04:00
Andrew Boie a9670ab5cf boards: centralize QEMU icount management
Instead of endlessly repeating the same command line args,
centralize this and tune the shift value on a per-board
basis.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-06-24 20:28:36 -04:00
Torsten Rasmussen b69a3d8824 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-06-22 12:44:39 +02:00
Torsten Rasmussen 8e8c6cd92b cmake: improved DTC detection handling
Fixes: #26096

In some cases DTC may be installed, but in a non-working state.
In such cases, CMake will abort processing with an cryptic error.

This commit now handles dtc version errors and print a warning., and
CMake processing continues.

dtc is an optional component and failures should not break CMake run.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-06-12 17:10:36 +02:00
Torsten Rasmussen e1c1d1daca cmake: make find_package(ZephyrUnittest...) REQUIRED
This commit is a followup to PR #25808 which updates the tests to
ensure the REQUIRED keyword is also used for the ZephyrUnitest package.

This provides a better error message when building with CMake and
forgetting ZEPHYR_BASE or not registering Zephyr in the CMake package
registry.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-06-12 11:10:23 +02:00
Pete Johanson 9b27cfd8c4 cmake: Fixes for shields in multiple roots
* Reset SHIELD_LIST on each root loop, to avoid matching
  on shields from the previous iteration of the loop.

Signed-off-by: Pete Johanson <peter@peterjohanson.com>
2020-06-09 15:24:48 +02:00
Reto Schneider 0b4b3ae4dd cmake, samples, tests: Use semi-accurate project names
When using an IDE (e.g. Eclipse, Qt Creator), the project name gets
displayed. This greatly simplifies the navigation between projects when
having many of them open at the same time. Naming multiple projects
"NONE" defeats this functionality.

This patch tries to use sensible project names while not duplicating
too much of what is already represented in the path. This is done by
using the name of the directory the relevant CMakeLists.txt file is
stored in. To ensure unique project names, small, manual adjustments
have been done.

See also 7eabab2f5d ("samples, tests: Use semi-accurate project names")

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2020-06-09 08:18:29 -04:00
Torsten Rasmussen 8d3e822e79 cmake: resolved list issue when parsing shield list
Fixes: #25656

The commit a8e90cbfb3 improved handling of
shields. Unfortunately it pops items from the SHIELD variable which
works well if SHIELD is a CMake ;-separated list, but if the list is
a space separated list, as may be provided by the user, then this
principle fails as reported in #25656.

This is fixed by keeping improved behaviour, while popping from an
alternative SHIELD-NOTFOUND list instead.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-05-29 13:11:17 +02:00
Marc Herbert 3a04536487 doc,cmake: make find_package(Zephyr...) REQUIRED
This provides a better error message when building with CMake and
forgetting ZEPHYR_BASE or not registering Zephyr in the CMake package
registry. See parent commit for more details (split from parent for
better readability).

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-05-29 10:47:25 +02:00
Torsten Rasmussen 9adcabe38d cmake: introduction of ZephyrBuildConfiguration package
The ZephyrBuildConfiguration package allow downstream users to control
the Zephyr build system using a cmake package.

A Zephyr Build Configuration package allows for setting of additional
DTS_ROOT, BOARD_ROOT, and similar variables without having to patch
Zephyr repo, but it also allows for inclusion of additional boilerplate
code for more advanced use cases.

The repository or folder containing the Zephyr Build Configuration
package must be on toplevel in the Zephyr workspace.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-05-27 17:58:50 +02:00
Martí Bolívar 3ea8293ef0 Revert "cmake: introduction of ZephyrExtension package"
This reverts commit ac898bc49e.

This commit was merged by mistake, but in a way that was against the
decision of the TSC on May 20, 2020, which was to wait a week to let
people digest befor merging.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-21 00:33:06 +02:00
Torsten Rasmussen ac898bc49e cmake: introduction of ZephyrExtension package
The ZephyrExtension package allow downstream users to extend the current
Zephyr package.
A ZephyrExtension package allows for setting of additional DTS_ROOT,
BOARD_ROOT, and similar variables without having to patch Zephyr repo.

The repository or folder containing the ZephyrExtension package must be
on toplevel in the Zephyr workspace.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-05-20 19:27:15 +02:00
Jukka Rissanen c6a19a2046 cmake: qemu: Allow user to add parameters to Ethernet TAP
User can now add extra Ethernet TAP parameters when starting QEMU.
This is useful if we want to set for example the MAC address
of the network interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-20 15:36:39 +02:00
Stephanos Ioannidis fb35591f1e cmake: Correct PATHS usage
`PATH` is not a valid option for `find_program`; correct all such
usages to `PATHS`.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-05-20 12:10:20 +02:00
Torsten Rasmussen c519f6ee87 cmake: fix usage of Zephyr SDK tools with 3rd party toolchains
Fixes: #25183

This commit fixes the issue where combining a 3rd party toolchain with
Zephyr SDK Tools would result in the Zephyr SDK overruling the toolchain
in use.

This is fixed by keeping track of current toolchain variant.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-05-19 17:12:11 +02:00
Torsten Rasmussen 32f351a7a2 cmake: raise a fatal error when C compiler is not found
This commit introduces an early error in case a valid C compiler is not
found in the system.

This will help to early identify misconfigured systems with the error:
  C compiler <compiler> not found - Please check your toolchain
  installation

instead of an obscure error, such as:
No such file or directory: LIBGCC_FILE_NAME: ''

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-05-19 14:45:36 +02:00
Torsten Rasmussen 3a2f8349fd cmake: find python3 on windows when multiarch are installed
Fixes: #24692

This commit fixes an issue where FindPython3 could wrongly select the
Python version not in environment path.

If user installed both 32 and 64 bit versions of the same Python, for
example 3.7.x, the current search would only specify that 3.7 is needed.

In some cases, FindPython3 could select the 32 bit version, even if the
64 bit version is the one on %PATH%.

This is fixed, by setting Python3_ROOT_DIR to point to the tested Python
in %PATH%.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-05-13 12:13:36 +02:00
Torsten Rasmussen b557bd90a6 cmake: Zephyr sdk backward compatibility with 0.11.1 and 0.11.2
This commit introduces backward compatibility with Zephyr SDK 0.11.1
and 0.11.2 so that users having one of those versions installed can
continue to use that version.

This remove the need to force users to update their SDK.

This is kept in independent commit to ensure it can easily be reverted
when minimum required Zephyr SDK is bumped to version 0.12.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-05-08 17:15:55 +02:00
Torsten Rasmussen 299a154fdd cmake: Zephyr sdk package handling
This commit introduces Zephyr SDK CMake config package.

This removes the need for setting ZEPHYR_SDK_INSTALL_DIR and
ZEPHYR_TOOLCHAIN_VARIANT when using Zephyr SDK in Linux.
It also allows to introduces never SDKs without breaking Zephyr.

For example, with this PR, the current Zephyr SDK is 0.11.1 but when
releasing 0.12 then the current Zephyr will no longer built.
This PR moves the Zephyr SDK CMake related code to the SDK and thus
allowing to use newer SDKs, as long as they are backwards compatible.

It also allows multiple SDK installations, and will automatically select
the version closet to the required version.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-05-08 17:15:55 +02:00
Rohit Gujarathi 35713f2ef6 cmake: Assembly listing containing all sections
Added support for creating an assembly listing containing all sections
like rodata, data and debug sections, not just those expected to
contain instructions.

Signed-off-by: Rohit Gujarathi <gujju.rohit@gmail.com>
2020-05-08 09:03:18 -04:00
Bilal Wasim 54550c04eb net: qemu: Adding support for User Networking
Added support for Qemu User Networking and tested with
qemu_x86 model. The support is kept simple assuming that
the TAP interface will always be preferred for more
sophisticated / practical use cases.

QEMU User Networking is implemented using "slirp", which
provides a full TCP/IP stack within QEMU and uses that
stack to implement a virtual NAT'd network. As this
support is built into QEMU, it can be used with any model
and requires no admin privileges on the host machine,
unlike TAP.

Added documentation to facilitate the user.

Signed-off-by: Bilal Wasim <bilalwasim676@gmail.com>
2020-05-08 10:47:38 +02:00
Abhishek Shah 2f85c01eaa arch: arm: aarch64: Add Cortex-A72 config
Add Cortex-A72 config in order to set "-mcpu" correctly.

Signed-off-by: Abhishek Shah <abhishek.shah@broadcom.com>
2020-05-08 10:46:23 +02:00
Stephanos Ioannidis 2c00c8e504 cmake: emu: Support QEMU semihosting console emulation
The QEMU '-semihosting' option enables the emulation of the semihosting
mechanism that can be used to interface the Zephyr RTOS to the host
operating system.

In order to support semihosting console output, the QEMU semihosting
feature is enabled and its console is connected to the console backend
chardev.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-05-07 23:33:38 -05:00
Martí Bolívar 14d55bcad8 cmake: host-tools fixes for DTC
1. Fix the regular expression used to parse version numbers. This uses
\. and . to parse literal dots; the second one matches any character.
Just use [.] instead in both cases.

2. Don't error out if the installed dtc is too old. It's optional, so
we should just proceed without it. Print a warning instead, and make
it so dts.cmake won't do anything with the installed dtc.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-05 11:05:58 -05:00
Martí Bolívar 53f6aaee2e cmake: host-tools cosmetics
Align the comment styles for each tool.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-05 11:05:58 -05:00
Anas Nashif 800c960d0d build: reports: add puncover target
puncover is a footprint and stack analysis tool in python, see

https://github.com/HBehrens/puncover

Add custom target puncover which launches puncover with the right
options.

Launch for example with:

west  build -b frdm_k64f samples/hello_world/ -t puncover

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-05-04 17:33:56 -04:00
Stephanos Ioannidis 0e6ede8929 kconfig: Rename CONFIG_FLOAT to CONFIG_FPU
This commit renames the Kconfig `FLOAT` symbol to `FPU`, since this
symbol only indicates that the hardware Floating Point Unit (FPU) is
used and does not imply and/or indicate the general availability of
toolchain-level floating point support (i.e. this symbol is not
selected when building for an FPU-less platform that supports floating
point operations through the toolchain-provided software floating point
library).

Moreover, given that the symbol that indicates the availability of FPU
is named `CPU_HAS_FPU`, it only makes sense to use "FPU" in the name of
the symbol that enables the FPU.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-04-27 19:03:44 +02:00
Corey Wharton c8f7cd5462 kconfig: Make the CPU_HAS_FPU_DOUBLE_PRECISION option global.
This option now applies to the RISC-V architecture and is no longer
a ARM only configuration.

Signed-off-by: Corey Wharton <coreyw7@fb.com>
2020-04-22 16:39:48 -07:00
Corey Wharton 22c52846a5 riscv: Set mabi and march flags for floating point
Adds handling of the FLOAT_64BIT option when determining the ISA
flags as well as introduces a new Kconfig option to enable/disable
the hard-float calling convention.

Signed-off-by: Corey Wharton <coreyw7@fb.com>
2020-04-22 16:39:48 -07:00
Stephanos Ioannidis 1d9b08aef5 arch: arm: Remove -march compiler flag
The ARM GCC `-march` compiler flag is completely redundant when the
`-mcpu` flag is specified, since the `-mcpu` selects the target ARM
architecture as well as CPU-specific optimisations.

In fact, it is disadvantageous to specify both `-march` and `-mcpu`
flags because the `-march` flag overrides and disables any CPU-specific
optimisations enabled by the `-mcpu` flag.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-04-22 09:43:24 +02:00
Stephanos Ioannidis df4fdeed97 arch: arm: aarch64: Force LP64 ABI
This commit adds the GCC `-mabi=lp64` flag to force the LP64 (64-bit
long and pointer) ABI, which is mandatory for running the Zephyr
AArch64 architecture port.

Note that this flag is, strictly speaking, not necessary in most cases
because the AArch64 GCC defaults to using the LP64 ABI. This flag is
required, however, if compiling Zephyr with a GCC that is configured
with `--with-abi=ilp32`, which makes ILP32 the default ABI.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-04-21 18:26:52 +02:00
Torsten Rasmussen 94de3e9f60 cmake: FindPython3: Adjust python3 program search
Fixes: #24340

Using find_package(Python3 3.6) will select the highest available
python3.

This means that in case user has:
/usr/bin/python  --> python2.7
/usr/bin/python3 --> python3.6
/usr/bin/python3.6
/usr/bin/python3.8

then CMake will choose python 3.8.
This commit changes that behavior, so that in the above scenario, then
Python 3.6 will be preferred.

It also adds the following, python will be preferred over python3, if
both meets the minimum requirement.
For example:
/usr/bin/python  --> python3.6
/usr/bin/python3 --> python3.7
then Python 3.6 is prefered.

It further introduces PYTHON_PREFER variable, which can be used to
further control the behavior.
As example -DPYTHON_PREFER=python3.7 will choose Python 3.7 if
installed.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-04-16 07:43:14 -04:00
Kumar Gala 9aefdaff2e cmake: kconfig: pass EXTRA_DTC_FLAGS to kconfig for EDT init
Pass EXTRA_DTC_FLAGS to kconfig so the EDT object we have in
kconfigfunctions can use that to set warn_reg_unit_address_mismatch
properly.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-16 06:07:24 -05:00
Stephanos Ioannidis a1e838872c arch: arm: Remove extraneous root cmake files
The ARM architecture root directory contains `aarch32.cmake` and
`aarch64.cmake` files whose contents are better suited to go into other
more purpose-specific files.

This commit removes the aforementioned files and moves their contents
to other files following the convention used by other architectures.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-04-15 11:23:56 +02:00
Torsten Rasmussen b5a612d7bc cmake: now using find_package(python3) from CMake to located python3
Fixes: #23922, #24252, #11103

This commit switches to use the find_package(Python3) introduced with
CMake 3.12.

This removes the need for a Zephyr backport of Python detection module.

The search order for Python3 is following CMake search order and can be
controlled through CMake flags (See CMake documentation).

Default it will use the Python version found in PATH.
If multiple Python3 versions are found in PATH, the newest version will
be selected (Can be controlled using `Python3_FIND_STRATEGY`)

Using find_package(Python3) also ensures Python2.7 will never be
selected, issue #11103, which was re-introduced in Zephyr.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-04-13 15:34:35 -04:00
Martí Bolívar ee955c28c4 cmake: re-run if gen_defines changes
Since gen_defines.py is run using execute_process() at CMake time, the
entire build system must be regenerated if it changes. Add the
dependency tracking to make this possible.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-04-13 08:22:46 -05:00
Kumar Gala 86887dafde dts: Remove conf file generation support
The last user of the .conf file format DTS data has been removed.  We
can now remove the generation and associated support for the .conf file.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-12 09:49:16 -05:00
Torsten Rasmussen b6c18dde1f cmake: board alias message when hiding existing board
This commit will print a CMake notice if a user defines a board alias
that is identical to an existing board name.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-04-09 14:38:36 +02:00
Peter A. Bigot c790783c2e cmake: add support for user-defined board aliases
Zephyr board names must be globally unique which requires that they
encode all necessary information to identify a specific target.
Typing in these names can be inconvenient to developers working on
multiple targets within a single workspace.

Extend the cmake infrastructure to read an optional board aliases file
that will map custom aliases to the corresponding canonical Zephyr
board name.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-04-09 14:38:36 +02:00
Håkon Øye Amundsen 42f75fc1a4 cmake: fix bug in generated runners.yaml
If a runner had no args, the format of the generated runners.yaml
was invalid due to missing indentation.

This commit fixes this issue by adding the required indentation.

This fixes issue #24215

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2020-04-09 14:04:27 +02:00
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