Commit graph

598 commits

Author SHA1 Message Date
Flavio Ceolin 18d96436a0 compiler: clang: Include missing target
Adding baremetal target when using clang/llvm.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2019-03-06 22:40:25 -05:00
Jacob Siverskog 99074fc75e toolchain: Fix typo and grammar in error message
Minor grammatical changes.

Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
2019-03-05 08:28:40 -05:00
Jacob Siverskog 5105947924 toolchain: Improve error message on mismatching SDK version
Add useful information to the error message printed when the installed
SDK does not fulfill version requirements.

Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
2019-03-05 08:28:40 -05:00
Sebastian Bøe 6d4ba3490f cmake: Deprecate 'set_conf_file'
In-tree, all usage of 'set_conf_file' is implementing the same
pattern (with some inconsequential differences).

To reduce copy-paste and get closer to dropping support for
'set_conf_file', we include this pattern into the built-in set of
patterns.

'set_conf_file' is causing issues for future extensions,
e.g. multi-image support, and is also the source of a lot of
duplicated code.

Note support for 'set_conf_file' is not dropped, it is only marked as
deprecated.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-03-01 09:44:09 +01:00
Andy Ross fe04adf99b lib/os: Conditionally eliminate alloca/VLA usage
MISRA rules (see #9892) forbid alloca() and family, even though those
features can be valuable performance and memory size optimizations
useful to Zephyr.

Introduce a MISRA_SANE kconfig, which when true enables a gcc error
condition whenever a variable length array is used.

When enabled, the mempool code will use a theoretical-maximum array
size on the stack instead of one tailored to the current pool
configuration.

The rbtree code will do similarly, but because the theoretical maximum
is quite a bit larger (236 bytes on 32 bit platforms) the array is
placed into struct rbtree instead so it can live in static data (and
also so I don't have to go and retune all the test stack sizes!).
Current code only uses at most two of these (one in the scheduler when
SCHED_SCALABLE is selected, and one for dynamic kernel objects when
USERSPACE and DYNAMIC_OBJECTS are set).

This tunable is false by default, but is selected in a single test (a
subcase of tests/kernel/common) for coverage.  Note that the I2C and
SPI subsystems contain uncorrected VLAs, so a few platforms need to be
blacklisted with a filter.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-02-28 10:06:35 -08:00
Sebastian Bøe ea57a9fb7d cmake: Omit comments that are either redunant or wrong
Drop these CMake comments. It is redundant with a below comment to
describe 'app', and it is incorrect to state that omitting
boilerplate.cmake is permitted/supported.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-02-27 08:50:59 -06:00
Sebastian Bøe 1108e38a01 cmake: Omit if statement that is always true
We had an if-statement around policy 79 because we used to need to
support CMake versions before 3.13.0. But now 3.13.1 is the minimum
required version so the if statement always evaluates to true and can
be omitted.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-02-27 08:50:59 -06:00
Marc Herbert f085647521 cmake: more deterministic git describe --abbrev=12
Hardcode --abbrev=12 not to depend on personal git config preference.
12 is deemed large enough for the Linux kernel which should leave some
room:
https://public-inbox.org/git/xmqq37knwcf4.fsf@gitster.mtv.corp.google.com/

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-02-27 10:27:47 +01:00
Anas Nashif ee11592186 toolchain: Do not hardcode where the toolchain was installed
Contrary to all other toolchains, the xcc toolchain had a hardocded
installation path. Replace this with XTENSA_TOOLCHAIN_PATH so users can
install in different locations.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-26 02:58:07 +01:00
Daniel Leung 336d3d3adc xtools: exclude "sources" when searching xtools output dir
When using xtools as toolchain, cmake searches the toolchain home
directory. However, if the first toolchain directory does not
begin with any character before "s", "sources" (if exists) would
become the first directory being probed. Since it does not
conform to "arch-vendor-abi" naming, cmake would fail.
So exclude "sources" from the list to avoid this issue.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-02-26 02:28:38 +01:00
Anas Nashif aa049e5d8f toolchain: abstract setting -nostdinc
- newlib needs c standard includes (so no -nostdinc)
- xcc needs toolchain headers (so no -nostdinc)
- with host gcc:
  - x86_64 should not build with standard includes (-nostdinc needed)
  - native_posix should build with standard include (no -nostdinc)
..
..

To simplify, abstract this and move it to compilers/toolchains and still
depend on what the application wants.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-24 17:48:10 -05:00
Anas Nashif 6cd15825e1 compiler: add xcc as a standalone compiler
XCC is based on xcc, but is nothing like gcc and his many differences.
Instead of ifdeffing the gcc code with Xcc specifics, maintain it
standalone.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-24 17:48:10 -05:00
Mark Ruvald Pedersen cb0fd451c2 cmake: Toolchain abstraction: Assembly
Introduce toolchain_cc_asm macro to capture toolchain specific flags
related to assembly.

-D_ASMLANGUAGE is kept common for all, assuming -D as define flag is
supported by all compilers (which is almost the case).

No functional change expected.

Clang's flags are compatible with gcc, and are thus inherited.

This is motivated by the wish to abstract Zephyr's usage of toolchains,
permitting easier porting to other (commercial) toolchains.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-02-23 07:41:46 -05:00
Kumar Gala 830ec0285c cmake: toolchain: zephyr-0.10.0: Fix setting of SYSROOT_DIR on xtensa
We need to set SYSROOT_DIR as the last thing we do on target.cmake so
we reset how its set for xtensa.  Otherwise when we build with newlib
we will not get the proper path to newlib headers in the toolchain.

This matches the behavior of 0.9.5/target.cmake

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-21 15:06:19 -05:00
Kumar Gala 5a0fec4c26 cmake: toolchain: zephyr-0.9.5: Fix setting of TOOLCHAIN_HAS_NEWLIB
There was an oversight and the Zephyr SDK 0.9.5 toolchain should report
itself as supporting newlib.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-21 07:44:46 -05:00
Kumar Gala 9c2ac77861 cmake: Fix setting of -nostdinc
We where defining the variable NOSTDINC_F after we tried to use it.
Move the definition before the first reference fixes things.  When
-nostdinc now enabled we need to explicitly add the compiler include
path for x86_64 based builds (x86_64 and ARCH_POSIX).

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-20 12:13:45 -06:00
Mark Ruvald Pedersen 63df409906 cmake: Toolchain abstraction: C++
Introduce toolchain_cc_cpp_*-family of macros.

Move the following into the toolchain_cc_cpp_* macros:
 * Common base set of flags
 * C++ standard version
 * RTTI
 * Exceptions

These macros must be implemented by every compiler port.
These macros set the respective flags, but leaves logic and control to
the root CMakeLists.txt file.

No functional change expected.

Clang's C++ flags are compatible with gcc, and are thus
inherited.

This is motivated by the wish to abstract Zephyr's usage of toolchains,
permitting easier porting to other (commercial) toolchains.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-02-19 12:33:19 -05:00
Anas Nashif f9e73c90f2 sanitycheck: do no overide OVERLAY_CONFIG
We have been overriding OVERLAY_CONFIG coming from tests. Concat all
files and create one variable that we pass to kconfig as list.

Fixes #13320

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-18 10:49:08 -05:00
Mark Ruvald Pedersen 0b3c65feea cmake: Toolchain abstraction: optimizations
Introduce toolchain_cc_optimize_for_* family of macros.
Each macro represents a general optimization class.
Each macro is then responsible for setting an output variable to that
class-of-optimization's flag.
The names of these output variables are decided from the root
CMakeLists.txt.

No functional change expected.

Clang's optimization flags are compatible with gcc, and are thus
inherited.

This is motivated by the wish to abstract Zephyr's usage of toolchains,
permitting easier porting to other (commercial) toolchains.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-02-18 08:22:42 -05:00
Sebastian Bøe 1ca1075b20 cmake: kconfig: pass GENERATED_DTS_BOARD_CONF on to kconfig
Make kconfigfunctions.py agnostic to where GENERATED_DTS_BOARD_CONF is
located.

We don't want to encode the path of GENERATED_DTS_BOARD_CONF into more
places than necessary. Also, re-using GENERATED_DTS_BOARD_CONF makes
it easier to change where generated_dts_board.conf is located.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-02-12 20:16:47 -05:00
Anas Nashif 33ca224ffd x86_64: use host toolchain
We were select host compiler from the generic gcc compiler section which
is used for cross toolchains. This arch should use the host-gcc compiler
definition instead.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-10 11:57:17 -06:00
Anas Nashif 839db87bb8 toolchain: host toolchain does not support newlib
The host toolchain does not support newlib.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-10 11:57:17 -06:00
Torsten Rasmussen 7e9d1bdda4 CMake/Kconfig: CMake and Kconfig build integration
This commit allows for Zephyr modules to be natively integrated into
the build system with CMakeLists.txt and Kconfig files.

The sourcing of module files are done in following order:
- If <module>/zephyr/module.yml exists, use cmake and kconfig settings
  for sourcing of additional file
- Else if <module>/zephyr/CMakeLists.txt exists, source this file into
  CMake build tree and add <module>/zephyr/Kconfig as osource

If none of the above files are present, the project is considered to
not be a Zephyr module

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2019-02-08 22:47:02 -05:00
Ioannis Glaropoulos e029d08628 soc: arm: Kconfig option to indicate double-precision FP
This commit introduces a Kconfig option for ARM SoCs, to signify
that the SoC implements a double-precision floating point unit.
The option is utilized in cmake/fpu-for-gcc-m-cpu to select the
appropriate GCC compile option flag for FPU.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-02-08 14:09:18 -06:00
Anas Nashif fc3d8ac863 toolchain: espressif: mark newlib support false
newlib is not supported with this toolchain, so mark it as such and
filter tests based on the variable defined in the toolchain file.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-07 22:46:10 -06:00
Klaus Petersen c66cb76fed Build: Added support for out-of-tree Arch
Introduces the ARCH_ROOT argument, similar to BOARD_ROOT and SOC_ROOT.
This enables support for out-of-tree architectures.

The ARCH_ROOT out-of-tree layout is expected to be the following:
 * ${ARCH_ROOT}/arch/${ARCH}/
 * ${ARCH_ROOT}/include/arch/${ARCH}/ (Optional)

Signed-off-by: Klaus Petersen <kape@oticon.com>
2019-02-07 17:00:43 -05:00
Kumar Gala 40e0a2e9da cmake: kconfig: Expose ZEPHYR_TOOLCHAIN_VARIANT to Kconfig
Expose ZEPHYR_TOOLCHAIN_VARIANT so that Kconfig can make choices based
on how its set.  For example we RISCV_GENERIC_TOOLCHAIN if the variant
is 'zephyr'.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-06 14:25:47 +01:00
Anas Nashif 2b9458c378 doc: restructure and create index pages
Move all lead pages to be index pages and create redirect rules from the
old pointers.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-05 07:04:40 -05:00
Kumar Gala 4b4b9bc49b cmake: Run dts before kconfig
Based on work from Sebastian Bøe and updated to current tree.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-01 10:16:06 -06:00
Kumar Gala 7e0107b7bc cmake: export PROJECT_BINARY_DIR variable to kconfig
Expose PROJECT_BINARY_DIR to kconfig since we will we looking for
generated files from dts pass in the future and need to know the
location of those files.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-01 10:16:06 -06:00
Kumar Gala e11314a21f cmake: Fix how usage finds board names
We had been search for <BOARD>.yaml, however its possible that doesn't
match anything and we actually use <BOARD>_defconfig in
boilerplate.cmake.  So search for *_defconfig instead of *.yaml to
generate the <BOARD> list.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-01-31 03:17:19 -06:00
Marc Herbert e526a2b80a host-gcc: exclude -lgcc to fix -mx32 [qemu_]x86_64 regression
PR #9522 series ending with commit c2c9265b7d ("tests: cmsis: Disable
two cmsis portability tests on x86_64") added -mx32 support for the
x86_64 ARCH and qemu_x86_64. While this was implemented in
"compiler/gcc/target.cmake" as fall back from cross-compilation to the
host compiler, it worked with a direct ZEPHYR_TOOLCHAIN_VARIANT=host
too.

Later, -lgcc was added to "compiler/host-gcc/target.cmake" by PR #12674
to fix the -m32 x86 build. This broke the x86_64 build when using
ZEPHYR_TOOLCHAIN_VARIANT=host because even "multilib" packages usually
don't feature the -mx32 version of libgcc.

Fix this by excluding -lgcc in compiler/host-gcc/target.cmake just like
compiler/gcc/target.cmake always did for x86_64.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-01-30 22:08:30 -05:00
Mark Ruvald Pedersen 01592071f1 cmake: Toolchain abstraction: security
Introduce the first of the toolchain_cc-family of macros:
toolchain_cc_security_fortify and toolchain_cc_security_canaries.

No functional change expected.

Fortify source is not supported by Clang, but this commit retains
current behavior.

This is motivated by the wish to abstract Zephyr's usage of toolchains,
permitting easier porting to other (commercial) toolchains.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-01-30 08:42:11 -05:00
Carles Cufi 1b5bed04e2 cmake: Use west installation directly
Since we install west from pip and it becomes an executable, use it
directly assuming it's in the user's PATH.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
2019-01-29 10:15:01 +01:00
Marc Herbert aa4ed2ae8c host-gcc: TOOLCHAIN_LIBS += libgcc (copied from compiler/gcc/)
Add missing -lgcc when compiling with ZEPHYR_TOOLCHAIN_VARIANT=host
merely copying some existing code from
'compiler/{clang,gcc}/target.cmake'.

This fixes compilation for the following boards with an x86
microprocessor:

 galileo, minnowboard, qemu_x86, qemu_x86_nommu, up_squared,
 up_squared_sbl

Compilation of the following boards with an X86_IAMCU microcontroller
still fail with a "cannot find -lgcc" error:

 arduino_101, qemu_x86_iamcu, quark_d2000_crb, quark_se_c1000_devboard,
 tinytile

This is _not_ a regression because these boards _already_ failed with
"undefined reference to __udivdi3" and other libgcc symbols.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-01-26 12:06:04 -05:00
Marc Herbert 5ac9cfd131 host-gcc: add missing set(CMAKE_ASM_FLAGS -m32)
This fixes the following error on all x86 BOARDs (qemu_x86,
galileo,... see "make usage" for the complete list) when compiling
assembly files with ZEPHYR_TOOLCHAIN_VARIANT=host:

 cc1: error: CPU you selected does not support x86-64 instruction set

This also fixes the following error when compiling minnowboard,
up_squared and up_squared_sbl boards with ZEPHYR_TOOLCHAIN_VARIANT=host:

  cc1: error: -mpreferred-stack-boundary=2 is not between 3 and 12

This fix alone is not enough to compile any of these boards; however it
moves compilation much further to the next, unrelated failure(s),
namely: 'undefined __udivdi3' and other libgcc symbols for all x86
boards; + some other, additional issues for some boards. See next
commit.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-01-26 12:06:04 -05:00
Kumar Gala 0d744c9a08 cmake: dtc: silence output from check_dtc_flag
We'd get output from a cmake build that would have lines like:

Version: DTC 1.4.7
Version: DTC 1.4.7

This was a side effect of check_dtc_flag.  Add the OUTPUT_QUIET option
to execute_process to supress this output.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-01-25 23:14:54 -05:00
Marti Bolivar 4d36c23060 cmake: gcc.cmake: allow users to influence CMAKE_REQUIRED_FLAGS
A GCC-based toolchain may require additional, toolchain-specific
values in CMAKE_REQUIRED_FLAGS to perform compiler checks properly,
but gcc.cmake clobbers any values the user provides.

Preserve them instead, allowing users to give their own compiler
checking flags at generation time.

The details for the particular issue that inspired this are described
in https://github.com/pulp-platform/pulpino/issues/240.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-01-25 11:59:46 -05:00
Sebastian Bøe 04857d0d59 cmake: Rebuild when DTS sources are modified
Ensure that changes to DeviceTree sources cause CMake to be re-run
when make/ninja is invoked.

Note that this is not perfect, as it does not cover files that are
\#included, but it will cover most DT changes.

This fixes #12692

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-01-25 03:02:58 -06:00
Sebastian Bøe c23cc26c73 DeviceTree: Convert 'generated_dts_board.h' into a source file
extract_dts_includes.py has been generating DT output and then
concatenating it with fixup header files to create
'generated_dts_board.h'.

In this patch we instead introduce a source file named
'generated_dts_board.h' and have it \#include the appropriate DT
output and fixup files.

This results in a simpler system because users can now read
'generated_dts_board.h' as C source code to see how fixup files and
generated DT output relate to each other. Whereas before they would
have to either read documentation or python code to gain the same
understanding.

Also, it reduces the scope and complexity of one of our most bloated
python scripts, extract_dts_includes.py.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-01-25 03:02:33 -06:00
Kumar Gala 67e098ab3e cmake: dts: Fix building with dtc 1.4.6
dtc 1.4.6 doesn't support the -Wno-unique_unit_address flag.  We need to
check that the flag is supported before using it on pre dtc-1.4.7
versions.

Fixes #12685

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-01-24 19:13:32 -05:00
Anas Nashif 114a1154ef toolchain: Support multiple versions of the Zephyr SDK
Depending on the installed and enabled SDK, we now load the right
configuration allowing people to migrate gracefully to the new SDK.

The selection is done based on the version of the SDK. Minimal required
SDK is still kept as 0.9.5.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-24 10:51:14 -06:00
Anas Nashif 55cf16a524 toolchains: move zephyr sdk host tools to toolchain folder
Should be part of other files related to the Zephyr SDK.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-24 10:51:14 -06:00
Kumar Gala 717aa9cea7 cmake: dts: Tweak warning flags for unit_address check
In Zephyr we have dts in which multiple peripherals can be at the same
MMIO address.  So we want to disable the `unique_unit_address` check via
(-Wno-unique_unit_address).  However, newer dtc support a check that
makes sure if we have duplicate unit-address devices that only one is
enabled.  So if the dtc flag is supported we enable
(-Wunique_unit_address_if_enabled).

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-01-23 09:43:53 -06:00
Kumar Gala 1718b07a91 cmake: dtc: Add ability to check of dtc flag is valid
Add a function that let's us check if a given dtc flag can be used with
the version of dtc we have.  This lets us utilize specific warning flags
that might not exist in older dtc versions and still have things work
properly.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-01-23 09:43:53 -06:00
Sebastian Bøe 1b86fb9da3 cmake: Use variables for target names
There is an effort underway to make most of the Zephyr build script's
reentrant. Meaning, the build scripts can be executed multiple times
during the same CMake invocation.

Reentrancy enables several use-cases, the motivating one is the
ability to build several Zephyr executables, or images, for instance a
bootloader and an application.

For build scripts to be reentrant they cannot be directly referencing
global variables, like target names, but must instead reference
variables, which can vary from entry to entry.

Therefore, in this patch, we replace global targets with variables.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-01-19 07:21:55 -05:00
Erwan Gouriou 0115c47b69 cmake: dts: move to specifying shield on the command line
Rather than specifying SHIELD via Kconfig, we move it to being
specified via the command line, similar to board.

So we can do:

  -DSHIELD=x_nucleo_iks01a1

or, for multiple shields:

  -DSHIELD="x_nucleo_iks01a1 frdm_kw41z"

Following cmake change, update x_nucleo_iks01a1 sample in order
not to enable CONFIG option anymore but set SHIELD cmake option.

Last, update documentation to reflect this change.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-01-18 13:20:59 -06:00
Håkon Øye Amundsen 120aaae268 cmake: Remove kconfig-usage target
This target uses a file which no longer exists.
Invoking it results in an error.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2019-01-14 10:01:19 -05:00
Dawid Wojciechowski 92156642d2 sanitycheck: Add Renode cmake configuration
By default Renode is searched for in the system PATH.
The PID is stored in renode.pid - the application must be killed with a
signal after a test.

With the XWT gui layer disabled all UART output is directed to the
stdout.

Signed-off-by: Dawid Wojciechowski <dwojciechowski@internships.antmicro.com>
Signed-off-by: Jan Kowalewski <jkowalewski@antmicro.com>
Signed-off-by: Piotr Zierhoffer <pzierhoffer@antmicro.com>
2019-01-14 09:12:07 -05:00
Andy Ross b69d0da82d arch/x86_64: New architecture added
This patch adds a x86_64 architecture and qemu_x86_64 board to Zephyr.
Only the basic architecture support needed to run 64 bit code is
added; no drivers are added, though a low-level console exists and is
wired to printk().

The support is built on top of a "X86 underkernel" layer, which can be
built in isolation as a unit test on a Linux host.

Limitations:

+ Right now the SDK lacks an x86_64 toolchain.  The build will fall
  back to a host toolchain if it finds no cross compiler defined,
  which is tested to work on gcc 8.2.1 right now.

+ No x87/SSE/AVX usage is allowed.  This is a stronger limitation than
  other architectures where the instructions work from one thread even
  if the context switch code doesn't support it.  We are passing
  -no-sse to prevent gcc from automatically generating SSE
  instructions for non-floating-point purposes, which has the side
  effect of changing the ABI.  Future work to handle the FPU registers
  will need to be combined with an "application" ABI distinct from the
  kernel one (or just to require USERSPACE).

+ Paging is enabled (it has to be in long mode), but is a 1:1 mapping
  of all memory.  No MMU/USERSPACE support yet.

+ We are building with -mno-red-zone for stack size reasons, but this
  is a valuable optimization.  Enabling it requires automatic stack
  switching, which requires a TSS, which means it has to happen after
  MMU support.

+ The OS runs in 64 bit mode, but for compatibility reasons is
  compiled to the 32 bit "X32" ABI.  So while the full 64 bit
  registers and instruction set are available, C pointers are 32 bits
  long and Zephyr is constrained to run in the bottom 4G of memory.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-01-11 15:18:52 -05:00
Andy Ross ff0ab5dc7a cmake/compiler/gcc: Fall back to host compiler for x86_64
If we don't have a detected cross compiler for x86_64, use the host
compiler instead.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-01-11 15:18:52 -05:00
Andy Ross 9c24867512 arch/x86_64: cmake: Make libgcc detection optional
Host toolchains don't tend to provide an x32 libgcc.  But we don't
actually need one for existing code.  This is fragile, but better to
work for all but obscure cases than break outright.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-01-11 15:18:52 -05:00
Mark Ruvald Pedersen 2cf134f797 cmake: Introduce host toolchain for POSIX arch
Make POSIX's host toolchain follow convention of other toolchains.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2019-01-10 14:56:32 -05:00
Tomasz Bursztyka 05368dc16c cmake: Enable server/client rules in case of 802.15.4 UPIPE driver
Networking apps may require these rules (as echo apps) even on
non-Ethernet based configuration.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-01-08 11:25:33 +02:00
Anas Nashif 857644997e xtools: support xtensa hal
Xtensa toolchain has a HAL library that needs to be compiled in similar
to how we do this with the Zephyr SDK.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-04 14:32:30 -05:00
Anas Nashif 5060ca6a30 cmake: increase minimal required version to 3.13.1
Move to latest cmake version with many bug fixes and enhancements.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-01-03 11:51:29 -05:00
Mark Ruvald Pedersen 55d6b4cd7c cmake: boilerplate: Move out finding git+python to separate cmake files
Follow the same convention as that of ccache.
Improve readability of boilerplate.cmake file.
Move inclusion of version.cmake up to satisfy git.cmake dependency.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2018-12-27 19:24:51 -05:00
Sebastian Bøe 56d144cd70 cmake: Fixed python detection bug
Fixed a bug where an old version of python on path would break the
python detection mechanism.

This fixes #12066

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-12-21 11:13:03 +01:00
Mark Ruvald Pedersen 0efad5f7fd cmake: Whitespace and commentary fixes
Cosmetics, no functional change expected.
Fixed leading space alignment.
Replaced tabs with spaces.
Emulation error message output is now aligned.

To locate tabs in cmake, the following bash is useful:
grep -PRil "\t" * | grep -i cmake | grep -v ^sanity

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2018-12-20 12:23:50 +01:00
Mark Ruvald Pedersen 6e158b1794 cmake: Document CMAKE_SYSTEM_-variables, and add CMAKE_SYSTEM_VERSION
Aid user in understanding what CMake expects of:

 * Document and add CMAKE_SYSTEM_VERSION
 * Document CMAKE_SYSTEM_NAME
 * Document CMAKE_SYSTEM_PROCESSOR
 * Document BUILD_SHARED_LIBS
 * Document Policies CMP0002, CMP0079

CMAKE_SYSTEM_VERSION is required officially by CMake, but appears
unused -- at least now we are compliant.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2018-12-20 11:15:20 +01:00
Mark Ruvald Pedersen 94a9d8086c cmake: boilerplate: move compiler-flag checks into boilerplate
CheckCCompilerFlag and CheckCXXCompilerFlag does not belong to
extensions.cmake since they are standard CMake files. Boilerplate
seems more appropriate.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2018-12-20 11:14:20 +01:00
Mark Ruvald Pedersen 5e90da7bef cmake: Remove setting CMAKE_FIND_ROOT_PATH_MODE_* variables
These variables affect how CMake locates programs, libraries, include
files, and CMake packages. But the defaults are sufficient for Zephyr.

NEVER: Only host system's root will be searched.
ONLY: Only the paths specified by a variable will be searched. Typically
      these paths point to cross-compilers.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2018-12-20 11:14:02 +01:00
Mark Ruvald Pedersen 722f86652c cmake: boilerplate: Move app-library to be with its documentation
Move documentation and declaration to be in the same place.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2018-12-20 11:13:44 +01:00
Sebastian Bøe a0a63ac344 cmake: Split toolchain configuration into pre-and post-DT
Split up the toolchain configuration into two phases, generic and
target. The 'generic' phase configures the toolchain just enough to be
able to preprocess DT files. The 'target' phase completes the
configuration with target-specific configuration.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-12-14 13:16:28 +01:00
Sebastian Bøe 3e4b9ded0b cmake: clang: Add the runtime library to the link command
When building with clang symbols from the runtime library, like
__divdi3 were not being resolved. To fix this we add the "library path
for the currently used compiler runtime library" to the link path.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-12-13 08:36:58 -06:00
Sebastian Bøe ef5cdbb390 cmake: toolchain: clang: Use 'find_program' and TOOLCHAIN_HOME
Align 'clang' with 'gcc' by having it also use 'find_program' instead
of 'set' to assign toolchain paths.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-12-13 08:36:58 -06:00
Sebastian Bøe ab2139a90f cmake: toolchain: llvm: Move the compiler assignment into 'compiler'
Align 'clang' with gcc by having it also set CMAKE_C_COMPILER in the
'compiler' build script instead of the 'toolchain' build script.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-12-13 08:36:58 -06:00
Sebastian Bøe bb278b688e cmake: toolchain: Change the names of 'clang' and 'llvm'
The 'llvm' and 'clang' build scripts have been named strangely. It is
more natural for 'clang' to be the compiler, and 'llvm' to be the
toolchain.

This commit rectifies this by renaming the files.

This also fixes #11187

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-12-13 08:36:58 -06:00
Sebastian Bøe 2192302c04 cmake: DT: Introduce 'DT_' symbols into the CMake namespace
CMake parses the Kconfig output for 'CONFIG_*' symbols and adds them
to the CMake namespace.

It does the same for DT, but has only been including 'CONFIG_' symbols
and been ignoring the 'DT_' symbols.

For DeviceTree to be useful, it's information needs to be accessible
from CMake, just like Kconfig is.

To this end we also introduce the 'DT_' symbols into the CMake
namespace.

This resolves #11109

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-12-13 07:33:08 -06:00
Sebastian Bøe c842fb88d7 cmake: import_kconfig: Generalize 'import_kconfig' to support DT
Generalize 'import_kconfig' to support parsing symbols with other
prefixes than 'CONFIG_'. This will eventually allow us to also import
'DT_' symbols into the CMake namespace.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-12-13 07:33:08 -06:00
Sebastian Bøe 667d6c97b0 cmake: Minor refactoring of 'import_kconfig'
Minor refactoring of 'import_kconfig' in preparation of resolving

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-12-13 07:33:08 -06:00
Sebastian Bøe 8c1ed47803 cmake: Fixed a bug in 'cmake -DCONFIG_'
Due to popular demand there exists an experimental feature with
undefined and undocumented semantics that permits Kconfig option to be
specified on the CMake CLI.

Like so:

cmake -DCONFIG_BUILD_OUTPUT_BIN=y

This patch fixes a bug where it was possible to have a mismatch
between the build/zephyr/.config file and the CMake namespace of
'CONFIG_' values.

We now pop all CLI Kconfig symbols from the CMakeCache.txt and then
push only the CLI Kconfig symbols that exist in the active .config
file.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-12-12 23:05:33 +01:00
Sebastian Bøe 8077b10165 cmake: PythonInterp: Fixed a bug related to python detection
Fixed #11980, a bug where a build failure occured when 'python' was
not on path.

There was a bug in the implementation where it failed to detect that
'python' was not on path. This is now fixed.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-12-11 12:26:48 +01:00
Sebastian Bøe 87858fd4e2 cmake: toolchain: Minor refactoring
Fixed whitespace such that 'XTOOLS_TOOLCHAIN_PATH' is vertically
aligned.

Also, combined two cmake invocations of 'list' into one.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-12-07 12:53:20 -05:00
Sebastian Bøe e9a49047a0 cmake: Remove unnecessary comments
Remove unnecessary comments.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-12-07 12:53:20 -05:00
Sebastian Bøe 75811428c3 cmake: toolchain: Use ARCH instead of CONFIG_ARCH
ARCH is available before CONFIG_ARCH, and is otherwise identical. So
it is better to use ARCH than CONFIG_ARCH as this allows the code to
be moved around more freely.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-12-07 12:53:20 -05:00
Sebastian Bøe 4f61c2a58d xcc: Drop the seemingly unused XCC_BUILD variable
Drop the seemingly unused XCC_BUILD variable because it depends on
Kconfig and we need to cut the toolchain's dependency on Kconfig.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-12-07 12:53:20 -05:00
Sebastian Bøe 9de5bc9109 cmake: FindPythonInterp: Prioritize 'python' from path the highest
Users expect that not just "some" compatible python is detected, but
also that it will be the 'python' executable from PATH, at least when
this executable is valid.

To this end rewrite FindPythonInterp to give this executable the
highest priority.

This fixes #11857

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-12-07 11:33:17 -05:00
Sebastian Bøe dc04f552b0 cmake: Fix warning related to policy CMP0079
In CMake 3.13 a warning is produced if one does not explicitly state
what the policy for CMP0079 should be. To resolve this warning we set
policy CMP0079 to OLD.

This is expected to have no semantical change. When we want a
semantical change we can flip the policy and port the build scripts to
the new behaviour.

This fixes #11794

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-12-07 11:32:08 -05:00
Adithya Baglody 62e152a8f0 cmake: Added rule and helper functions for code relocation.
This patch creates a rule in the cmake to trigger the generation
of linker_relocate.ld and code_relocation.c files.
The linker_relocate.ld will create appropriate sections and will
link the required functions or variables from all the selected
files.
The code_relocation.c will have code that is needed for
initializing data sections and copy of text sections(if XIP).
Also this will contain code that is needed for zeroing of bss.

The procedure to invoke this feature is:
1. Enable CONFIG_CODE_RELOCATION in the prj.conf

2. Inside CMakeList.txt in the project we need to mention
   all the files that needs to get relocated.

   zephyr_kernel_code_relocate(src/*.c SRAM2)

   Where the first argument is the file/files and the second
   argument is the memory where it has be placed.
   NOTE: The file argument supports glob expressions.

NOTE: Step 2 can be done as many times as required. And relative
paths can be given here.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2018-12-07 10:32:41 -05:00
Sebastian Bøe b0938569f4 cmake: Move libapp.a into it's own directory
Move libapp.a into it's own directory. This would make it's placement
consistent with how zephyr.elf is placed.

E.g. it might now look like:

ls b/*

b/build.ninja  b/CMakeCache.txt  b/cmake_install.cmake  b/rules.ninja

b/app:
libapp.a

b/CMakeFiles:
3.12.0   cmake.check_cache  CMakeOutput.log  TargetDirectories.txt
app.dir  CMakeError.log     CMakeTmp

b/zephyr:
arch                 kernel                       subsys
boards               lib                          tests
cmake                liboffsets.a                 zephyr.bin
CMakeFiles           libzephyr.a                  zephyr.elf
cmake_install.cmake  linker.cmd                   zephyr.hex
ext                  linker_pass_final.cmd        zephyr.map
include              linker_pass_final.cmd.dep    zephyr_prebuilt.elf
isrList.bin          misc                         zephyr.stat

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-12-07 10:21:16 -05:00
Håkon Øye Amundsen 0da5d24c36 cmake: flash: Conditional dependency to 'mergehex'
This patch adds a dependency from the 'flash' target to
the 'mergehex' target IF files to be merged are configured.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2018-12-05 12:14:38 -05:00
Aurelien Jarno c6727d49b7 arch: ARM: set -mthumb, -mcpu, -mfpu and -mfloat-abi in linker flags
Some toolchains are built with multilib enabled in order to provide
multiple versions of the same library, optimized for different ABI
or architecture. They require the the ABI/architecture/CPU selection
options to be passed at linked time. This is important for example
when linking with newlib.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-12-04 19:40:39 -05:00
Håkon Øye Amundsen 81c6662d23 cmake: flash: scripts: Include externally built hex files
Allow user to add externally built hex files to the cmake property
HEX_FILES_TO_MERGE. The hex files in this list will be merged
with the hex file generated when building the zephyr application.

This allows users to leverage the application configuration
available in Kconfig and CMake to help decide what hex file
should be merged with the zephyr application.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2018-12-04 19:04:13 +01:00
Henrik Brix Andersen 9e8c9ca8fb subsys: fb: add support for generating CFB font headers at build time
Add script and cmake functions for automatically generating Character
Frame Buffer (CFB) font header files from image files, TrueType, or
OpenType font files.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2018-11-28 11:46:00 +01:00
Sebastian Bøe 8037c89606 cmake: Align the DT build logs with Kconfig
Align how DT and Kconfig print log output to be more consistent.

For instance, Kconfig does not state which header file it generates,
so we remove this from DT.

Also, Kconfig states which sources it uses, which is useful to know
when there is a build failure, so we align with Kconfig by printing
the DT source and overlay files.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-11-21 09:43:21 -05:00
Sebastian Bøe 985b93a367 cmake: Fix python version detection
The 'FindPythonInterp' that is distributed with CMake 3.8 is affected
by bug: https://github.com/zephyrproject-rtos/zephyr/issues/11103

To work around this, until we upgrade to 3.13, we copy and patch the
3.8 version of 'FindPythonInterp' into the Zephyr repository.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-11-20 19:37:57 +01:00
Sebastian Bøe db63841210 cmake: Copy CMake's FindPythonInterp.cmake into the repo
Copy the 3.8.2 version of FindPythonInterp.cmake into the repo so that
we can patch it and fix #11103.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-11-20 19:37:57 +01:00
Sebastian Bøe 8ba5aff8c0 kconfig: Drop support for specifying CROSS_COMPILE through Kconfig
When we move DT infront of Kconfig we are going to need access to a C
toolchain before Kconfig is evaluated. This means it will not be
possible to specify the toolchain used through Kconfig.

To deal with this we ...

Drop support for specifying CROSS_COMPILE through Kconfig. Still
available is the ability to specify CROSS_COMPILE through the
environment or through a CMake variable.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-11-19 15:04:13 -05:00
Sebastian Bøe 84fe1ec63f cmake: Don't remember misnamed boards
CMake prints a helpful error message with all the boards supported
when a board name has been misspelled. But CMake also
remembers (caches) the corrupted board name and refuses to change it
until the board directory has been cleared.

CMake is rightly hesitant to change the board, as other cached
variables depend on what the board is. But it is safe to change the
board just after it has been selected, because we verify it's
correctness before using it to calculate other variables.

So to support the use-case of changing a misspelled board
name (without clearing the build directory) we unset the cached board
when it is invalid.

Also; change the now unused (in-tree) macro 'assert_with_usage' to
'print_usage'.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-11-19 11:42:25 -05:00
Bobby Noelte 098dbfd185 dts: scan application dir for files included by dts
In addition to zephyr/include and zephyr/dts also scan
the dts directory within the application source directory
for files included by the DTS.

Allows to have application specific DTS includes. This
is especially useful for out of tree drivers.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2018-11-19 11:41:42 -05:00
Carles Cufi 8ba60342cf cmake: Set PYTHON_EXECUTABLE env var with kconfig
In order to be able to invoke Python from Kconfig files,
set the path to the Python executable (which can be python,
python3, py -3, etc) as an environment variable so that
Kconfig shell invocations can use it like:

config MY_OPTION
       string "My option string"
       default "$(shell,$(PYTHON_EXECUTABLE) \
	          $(ZEPHYR_BASE)\scripts\script.py)"

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-11-16 13:26:24 -05:00
Marti Bolivar c9a4058605 cmake: fix dts fixup file location for external SOC
The board is done correctly, but there's a missing SOC_DIR.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-11-14 23:32:23 +01:00
Andrzej Głąbek a7c430f36f scripts: dts: Use DT_ prefix in generated labels
Almost all labels generated by the extracting script are now prefixed
with DT_. The only exceptions are:
- stuff with 'base_label' specified in yaml bindings
- items specified by 'regs_config' and 'name_config' dictionaries
  in globals.py module
- FLASH related labels generated by flash.extract() called separately
  from generate_node_definitions(), e.g. FLASH_WRITE_BLOCK_SIZE -
  these are used directly, not through fixups, from existing code
  so I didn't want to touch them now

Labels generated for aliases are additionally prefixed with information
from the 'compatible' property, e.g. DT_GPIO_LEDS_LED0_* is generated
instead of LED0_*. To provide backward compatibility for code that uses
LEDx_* and SWx_* labels in their previous forms, a command line option
named 'old-alias-names' is added to the extraction script. This option
causes that the labels for aliases are generated in both old and new
forms. Currently this option is always enabled in dts.cmake.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-11-13 10:44:42 -06:00
Sebastian Bøe 5a2ddf37d9 msys: Drop support for building in an MSYS environment
MSYS support was added as a stop-gap while native windows support was
unsupported. Now that Native windows support is stable we can drop
support for MSYS.

Dropping support for MSYS fixes #11260 and allows us to spend more
resources on native windows support.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-11-13 10:28:33 +01:00
Jukka Rissanen 421505c7e3 net: qemu: Allow SLIP or normal ethernet connectivity
Introduce new Kconfig option for selecting either slip or ethernet
connectivity to host.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-11-10 09:13:45 -05:00
Henrik Brix Andersen 0d412ab20e cmake: fix code section ordering
Order the code sections according to their numbering in the table of
contents.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2018-11-06 16:54:54 -05:00
Sebastian Bøe 9296fdc45e cmake: Abort early if Python3 is not found
When Python3 is not found the build system will warn the user and then
continue. Python3 is required and continuing can only confuse the user
with new off-topic error messages.

This patch denotes Python3 as required to resolve this.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-11-06 16:31:51 -05:00
Sebastian Bøe 075525cfe7 cmake: Add support for out-of-tree shields
Add support for out-of-tree shields. Out-of-tree shields can now be
stored in out-of-tree board directories.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-11-06 16:16:01 -05:00
Anas Nashif 91401aa7f4 sdk: require Zephyr SDK 0.9.4
Due to changes to Qemu and DTC, we do require at least SDK version 0.9.4
now.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-11-05 11:00:38 -05:00
Daniel Leung 2ce9d81a88 cmake: xcc: fix compile warnings and errors
XCC does not support the "-undef" flag so set NOSYSDEF_CFLAGS to
empty string to fix compile warning.

Also, XCC does not supply the macro __SIZEOF_LONG__ which breaks
the build. So define it.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2018-11-01 16:30:02 -04:00
Daniel Leung 3829cb5c41 cmake: parameterized flags to not include standard defines/files
Not all compiles/linkers support the GCC flags to not include standard
defines, include files and libraries. So make these parameters such
that the toolchain can define them when supported.

Also, according to documentation, -nostdlib does the same for both
-nostartfiles and -nodefaultlibs. So remove the redundant ones.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2018-11-01 16:30:02 -04:00
Sebastian Bøe 0f1b6ffbdd cmake: Make the target name generation code re-usable
The CMake extension 'generate_inc_file_for_target()' has some code for
generating a unique target name that is needed elsewhere, for instance
by DeviceTree.

Make the code re-usable by refactoring it out into it's own function.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-11-01 09:14:22 -04:00
Sebastian Bøe d5754d3d0d cmake: Enforce that the DTC is at least 1.4.6
The Zephyr SDK distributes a device-tree-compiler with version
"1.4.6-dirty". As of recently, we have started using flags that are
only present in recent versions of dtc. Like the flag "-E
unit_address_vs_reg".

Users that are opting out of using the Zephyr SDK's host tools are
reporting obscure error messages.

To avoid this we use an appropriate error message when the detected
version is unsupported.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-19 16:12:42 -04:00
Sebastian Bøe e7dcc9dec3 cmake: Re-write the capability database to avoid file appends
CI sometimes fails with a temporarily corrupted toolchain capabilitiy
database file. Although not proven, there is evidence that CMake's
file(APPEND does not work atomically when there are concurrent writes
and reads of a certain size.

To avoid file appending, we re-write the key-value database
implementation to store keys in filenames and values in individual
single-byte files.

This is (most likely) fixes #9992.

NB: Users that have been overriding the database file location with
the CMake variable ZEPHYR_TOOLCHAIN_CAPABILITY_CACHE must now specify
a directory with the variable ZEPHYR_TOOLCHAIN_CAPABILITY_CACHE_DIR.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-19 16:12:18 -04:00
Istvan Bisz 26e6162a82 cmake: Eclipse CDT4 generator amendment
1. The generator handles just the COMPILE_DEFINITIONS.
   (See: __ZEPHYR_SUPERVISOR__)
   For the defines in INTERFACE_COMPILE_DEFINITIONS
   a special handling is necessary.

   Solution:
   The amendment function generates a macro header file
   ${CMAKE_BINARY_DIR}/zephyr/include/generated/cmake_intdef.h
   based on INTERFACE_COMPILE_DEFINITIONS and appends the
   defines from the file to
   CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS.

2. Eclipse CDT4 indexer has problems with CMake 'Eclipse CDT4 - x'
   generator projects that use mixed C/C++.
   The Eclipse CDT4 indexer is showing a lot of unresolved symbol
   errors, when the project was created with CMake generator and
   the code is a mix of C and C++.
   The root cause of the problem is the g++ built-in __cplusplus macro,
   that is passed by CMake generator in the '.cproject' file.
   The defines in '.cproject' are always the same for C and C++.
   In mixed C/C++ projects, the header files often contain the following
   lines to let C++ code call the C functions:

   #ifdef __cplusplus
   extern "C" {
   #endif

   < header content >

   #ifdef __cplusplus
   }
   #endif

   Whenever the Eclipse CDT4 indexer compiles the code for
   code analysis, it has the macro __cplusplus set,
   independent of whether standard C or C++ source files are compiled.
   The 'extern "C"' confuses the standard C compilation and the indexer
   is messed up.

   Solution:
   The amendment function deletes the __cplusplus entry from
   CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS.

3. The amendment function appends the defines from
   ${CMAKE_BINARY_DIR}/zephyr/include/generated/autoconf.h to
   CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS.

Signed-off-by: Istvan Bisz <istvan.bisz@t-online.hu>
2018-10-17 18:16:55 -04:00
Sebastian Bøe 7f99086d64 cmake: Fix 'run' command of native_posix
The 'run' target was missing it's dependency on the executable and
thereby behaving incorrectly.

This fixes #10639 .

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-16 10:50:29 -04:00
Sebastian Bøe 92efb09a33 cmake: Fix minor typo in docs
Fix a minor copy-paste error in the help text.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-15 09:57:28 -04:00
François Delawarde c11e96d9b8 cmake: Support custom out-of-tree toolchains
Add a new optional TOOLCHAIN_ROOT cmake and environment variable to
specify an alternative location for toolchain cmake files.

When set, Zephyr will look for a toolchain cmake file located in:
${TOOLCHAIN_ROOT}/cmake/toolchain/${ZEPHYR_TOOLCHAIN_VARIANT}.cmake

Signed-off-by: François Delawarde <fnde@oticon.com>
2018-10-08 12:43:32 -04:00
Sebastian Bøe d0fc988e9f cmake: Error-out when dts.fixup files are detected
The filename dts.fixup is deprecated, dts_fixup.h should be used
instead. This commit detects when fixup files have not been renamed
and errors out with a warning.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-08 11:38:56 -04:00
Sebastian Bøe 8eb734cd82 DT: Rename from dts.fixup to dts_fixup.h
The Zephyr configuration system uses many different files in many
different formats. It makes it a lot easier for users to understand
what these files do if when we use the correct file extensions.

To this end we rename the dts.fixup files to the correct file
extension '.h'.

This is a breaking change for out-of-tree fixup files. Such files will
be detected and given an appropriate error message.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-08 11:38:56 -04:00
Kumar Gala c361405e90 dts: Reduce include paths for building dts
Drop a few paths from when we preprocess the dts.  This is to reduce
creep of where #defines might get resolved from.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-10-04 07:48:05 -05:00
Sebastian Bøe f612c3c167 dts: Allow users to pass extra flags to DTC
Allow application build scripts to pass extra flags to DTC, this could
for instance be done to enable/disable warnings.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-03 08:22:44 -05:00
Sebastian Bøe e8b501976c dts: Treat a missing 'reg property warning' as an error
As far as testing can tell, all occurences of the "Node has a unit
name, but no reg property" warnings have been fixed. To prevent them
from re-appearing we turn the warning into an error.

This is a breaking change for out-of-tree boards that are affected by
the warning.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-03 08:22:44 -05:00
Sebastian Bøe 6da970e593 revert: print a note about the changed 'default' behavior"
The deprecation warning has existed for 1 release and 3 months, giving
users plenty of time to be warned.

This reverts commit 9c93e8e87b.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-02 14:06:02 -07:00
Sebastian Bøe d6de4c7a99 cmake: Fall back to ZEPHYR_BASE when the board is not in BOARD_ROOT
It is very inconvenient to maintain an application that both runs on a
Zephyr board and an out-of-tree board.

It forces one to write build scripts like this in the app:

if(BOARD STREQUAL my_out_of_tree_board)
  set(BOARD_ROOT some/out/of/tree/board/path)
endif()

To avoid this we change the semantics of BOARD_ROOT. Instead of it
being a path to the board root it is now a prioritized list of board
root directories. Zephyr will append ZEPHYR_BASE to BOARD_ROOT.

This ensures that Zephyr boards can be used when the out-of-tree board
directory can not supply the requested board.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-01 09:46:46 -04:00
Sebastian Bøe fd8022ae16 cmake: Misc. cleanups of how BOARD_ROOT and BOARD_DIR are used
Misc. refactorings that clean up how BOARD_ROOT and BOARD_DIR are
used.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-01 09:46:46 -04:00
Sebastian Bøe 669781f2be cmake: version: Misc. refactorings for readability
Misc. refactorings to increase the readability of cmake/version.cmake.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-01 09:16:05 -04:00
Sebastian Bøe 8ade26267f kconfig: Change the format of KERNELVERSION
Change the format of KERNELVERSION as it exists in Kconfig to match
it's format elsewhere. Specifically, change from a string format
"1.10.3" to a numerical format.

This format change is a backwards-incompatible change. Any out-of-tree
Kconfig sources that were accessing KERNELVERSION with
$(KERNELVERSION) will need to be ported.

This change is to fix a bug. KERNELVERSION should have always been in
a numerical format. It should have been in a numerical format because;

KERNELVERSION is in a numerical format as a CMake variable and as a C
macro.

The purpose of having KERNELVERSION available in Kconfig is to have
configuration depend on the version, but this is only possible if it
exists in a numerical format[0].

[0] A string comparison of two semver strings does not always result
in a correct version comparison.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-01 09:16:05 -04:00
Sebastian Bøe 4dfd3114aa kconfig: Don't set the deprecated env var KCONFIG_AUTOHEADER
KCONFIG_AUTOHEADER is an environment variable that was used by the C
Kconfig tools to determine where the autconf.h file is. After the
migration to python this environment variable became unused.

This patch removes the deprecated env var.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-09-30 12:09:08 -04:00
Sebastian Bøe 20b28ba6e1 misc: mic
misc

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-09-30 12:09:08 -04:00
Yasushi SHOJI c0ff084f74 cmake: Do not abort even if git describe failed
The commit 1b80f00f56 made git describe
failure as fatal.  But a failure can happens when no tag is in a
repository.  And such a repository might exist for a internal build
system or some test environments.

Zephyr's build system is capable building without a commit hash.

This commit makes it non-fatal again and inform users that the build
system is failed to execute "git describe" but continues building with
KERNEL_VERSION_STRING.

Signed-off-by: Yasushi SHOJI <y-shoji@ispace-inc.com>
2018-09-26 15:11:37 +02:00
Maureen Helm ab67639403 cmake: Add build system target for west attach command
Adds a build system target for the west attach command, which starts a
debugging session without programming the flash.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2018-09-26 08:06:41 +05:30
Marti Bolivar 55b462cdfa scripts: update west to latest upstream version.
Update to the latest west. This includes a new 'attach' command. There
are also multi-repo commands, but those won't get exposed to the user
unless they install Zephyr using "west init" + "west fetch" (and not,
say, "git clone").

Replace the launchers; they now detect whether zephyr is part of a
multi-repo installation, and run the west code in its own repository
if that is the case.

This also requires an update to:

- the flash/debug CMakeLists.txt, as the new west package is no longer
  executable as a module and must have its main script run by the
  interpreter instead.

- the documentation, to reflect a rename and with a hack to fix
  the automodule directive in flash-debug.rst for now

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-09-25 17:51:22 +02:00
Björn Stenberg 4e61ccd1f0 cmake: Add quotes to handle missing ZEPHYR_TOOLCHAIN_VARIANT variable
If this environment variable is missing, the user gets a rather
confusing cmake error message about "STREQUAL" "gccarmemb" from the
lines below.

Adding quotes to the check makes cmake handle it better and instead
report the problem in the later ASSERT.

Signed-off-by: Björn Stenberg <bjorn@haxx.se>
2018-09-24 15:57:09 +02:00
Sebastian Bøe 350c3d7734 dts: Simplify overlay build scripts
Miscellaneous refactorings to simplify the overlay build scripts.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-09-21 18:51:26 -04:00
Erwan Gouriou 6af514b67f build: enable shields dir treatment
In dts.cmake, build shield list. For each shield, check if
associate KCONFIG is enabled and if it is, add matching files
to following new cmake variables:
-DTC_SHIELD_OVERLAY_FILE
-DTC_SHIELD_FIXUP
Then, consume these variables when needed.

Shield overlay is conceived as the very first overlay applied
to the board dts. It intends to build a new board that should
then behave as any other board versus common or user's overlay.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-09-21 18:51:26 -04:00
Sebastian Bøe 89a197be84 cmake: Re-direct KCONFIG_ROOT when convention is used
Automatically detect the Kconfig file in it's conventional placement
${APPLICATION_SOURCE_DIR}/Kconfig and set KCONFIG_ROOT accordingly.

'Convention over configuration' is an imporant principle for
minimizing metadata and keeping things consistent. We use this
principle for instance with the file prj.conf.

This commit applies this principle to also re-direrct KCONFIG_ROOT.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-09-21 13:37:21 -04:00
Sebastian Bøe b6a65a97aa kconfig: Make CONIG_FP_SOFTABI generate floating point instructions
This re-applies a patch that was merged in pr #6989, but then
accidentally reverted in a bad merge conflict resolution in pr #6842.

The actual behaviour of CONIG_FP_SOFTABI has not been matching the
documenation. The Kconfig documentation states that floating point
instructions should be generated, but this Kconfig option has been
turning off floating point instructions instead.

This commit causes floating point instructions to be generated when
CONFIG_FP_SOFTABI is enabled, as was originally intended and
documented.

This commit can cause regressions if users have been relying on the
actual behaviour instead of the documented behaviour.

Kconfig documentation:

config FP_SOFTABI
	help
	  This option selects the Floating point ABI in which hardware
	  floating point instructions are generated but soft-float calling
	  conventions.

GCC documentation:

Specifying ‘soft’ causes GCC to generate output containing library
calls for floating-point operations. ‘softfp’ allows the generation of
code using hardware floating-point instructions, but still uses the
soft-float calling conventions. ‘hard’ allows generation of
floating-point instructions and uses FPU-specific calling conventions.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-09-19 10:13:30 -04:00
Sebastian Bøe 1b80f00f56 cmake: Suppress the stderr from 'git describe' on successfull runs
A confusing warning has popped up since 3.13. It can be observed as
so:

Zephyr version: 1.13.99
Parsing Kconfig tree in /home/sebo/zephyr/Kconfig
Merging /home/sebo/zephyr/samples/hello_world/prj.conf
warning: tag 'zephyr-v1.13.0' is really 'v1.13.0' here
-- Generating zephyr/include/generated/generated_dts_board.h

This warning is more confusing than useful so we suppress stderr from
'git describe' when the command runs successfully.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-09-19 09:12:25 -04:00
Carles Cufi d3390305d1 cmake: menuconfig: Fix missing SOC_DIR macro
menuconfig was being invoked without an initialized SOC_DIR, leading to
errors when parsing the top-level Kconfig.zephyr file.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-09-13 08:58:20 -04:00
Anas Nashif 96455d5881 build: support out of tree SoC definition
Add the glue to make this work with SoC code outside of the tree.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-09-13 00:56:48 -04:00
Anas Nashif 66b524a62a soc: support out of dir soc code
Just like boards, support also SoCs out of the tree.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-09-13 00:56:48 -04:00
Anas Nashif 3d1252ff2d soc: adapt Kconfig/CMake for soc in top /
Change build system to point to soc/ in the top directory rather than
under arch/

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-09-13 00:56:48 -04:00
Anas Nashif 81b272119a docs: fixed documenation pointers
Fixed URL to documentation, now latest docs are under /latest/..
Fixes #9932

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-09-12 12:03:18 -04:00
Sebastian Bøe 1d90bcdc75 cmake: Use find_program on CMAKE_CXX_COMPILER
'find_program' should be used instead of 'set' for determining the
paths of host programs. It resolves #9582 and various other issues.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-09-12 09:36:33 -04:00
Ulf Magnusson d0e8752a52 Kconfig: Rename $ENV_VAR_{ARCH,BOARD_DIR} to $ARCH/$BOARD_DIR
The prefixes might be a leftover from the old 'option env="..."' symbols
(which are no longer needed). Since environment variables can be
referenced directly now, there's no point in having a prefix.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-09-11 19:17:25 -04:00
Sebastian Bøe 19845a7489 cmake: Don't use the environment variable CFLAGS
Some distros set the environment variable CFLAGS, this will
accidentally affect Zephyr builds.

To fix this we clear the environment variable from within the Zephyr
build system for the duration of the CMake execution.

Until now we have been instructing the user to clear it, but it is
easier for the user if we clear it for him.

The same applies to CXXFLAGS.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-09-05 18:40:32 -04:00
Bobby Noelte 5a16b9020f dts: bindings: scan application dir for bindings
In addtion to zephyr/dts/bindings als scan the dts/bindings
directory within the application source directory for bindings.

Allows to have application specific bindings and drivers.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2018-08-27 12:50:13 -04:00
Anas Nashif 1d4e089498 qemu: support alternate path of qemu binaries
Support using an alternate QEMU path for when we want to use a qemu
version not available in the SDK.

To use the alternate qemu version, export QEMU_BIN_PATH and point it
to the bin directory which contains the qemu executables.

For example:

export QEMU_BIN_PATH=/usr/local/bin

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-08-22 15:44:53 -07:00
Sebastian Bøe 6682652a2f cmake: change policy CMP0000 to NEW
Change CMake policy CMP0000 from OLD to NEW to resolve #8355.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-08-15 04:06:50 -07:00
Sebastian Bøe 83d2a47d9b cmake: Don't propagate zephyr_library_compile_options
zephyr_library_compile_options will apply compile options to a library
with high priority. Due to bug #8438 these compile options have been
applied not only to the library, but also to it's public interface and
therefore to any library that has been linking with the library.

To resolve #8438 we use PRIVATE linking instead of PUBLIC linking.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-08-13 18:43:53 -07:00
Ulf Magnusson 9c93e8e87b Kconfig: Have CMake print a note about the changed 'default' behavior
Always print the note to make sure it isn't missed, but make it easy to
disable (by creating an empty file).

The note will be removed later.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 12:38:28 -07:00
Sebastian Bøe b9e8cd1133 cmake: Refactor usage of target_link_libraries on Zephyr libraries
CMake has several prototypes/signatures for the function
'target_link_libraries'. This commit migrates the usage of
'target_link_libraries' on Zephyr CMake libraries from the old 'plain'
signature to the new '<PRIVATE|PUBLIC|INTERFACE>' signature.

For technical reasons the two signatures can not be mixed. Each
library must exclusively use either the old or new signature.

The 'old' plain signature is equivalent to using the PUBLIC
signature. Migrating to use 'PUBLIC' is therefore expected to be a
safe change.

After the migration it will be possible to use the PRIVATE and
INTERFACE signatures on Zephyr CMake libraries. This is useful for
instance to fix issue 8438.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-08-09 14:03:10 +02:00
Carles Cufi 957262e37d build: Replace GCC ARM Embedded with GNU Arm Embedded
The old GCC ARM Embedded website on launchpad
(https://launchpad.net/gcc-arm-embedded) has been superseeded by the new
GNU Arm Embedded one
(https://developer.arm.com/open-source/gnu-toolchain/gnu-rm).

This also means a change of name from "GCC" to "GNU". Reflect this in
the enviroment variables so that the proper term is used henceforth.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-08-09 13:57:55 +02:00
Ulf Magnusson a500e7e069 cmake: kconfig: Fix broken menuconfig due to misspelling
Due to a misspelling in the existence check for the stored checksum
file, zephyr/.config was always regenerated from the config fragments
(e.g. prj.conf), overwriting any custom zephyr/.config configuration
done in e.g. menuconfig.

This bug was introduced by commit 5402662dd9 ("cmake: kconfig: Fix
rerunning cmake after Kconfig warnings").

Fixes: #9270

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-03 18:41:43 +02:00
Ulf Magnusson 5402662dd9 cmake: kconfig: Fix rerunning cmake after Kconfig warnings
Commit b3d165f ("scripts: kconfig: Handle warnings generated
during evaluation") made it common for kconfig.py to fail after writing
zephyr/.config. This confuses the configuration fragment checksum logic
in cmake/kconfig.cmake, because it expects the saved checksum file to
exist if zephyr/.config exists.

The end result is a CMake error when rerunning the configuration after
non-whitelisted Kconfig warnings.

Fix it by only writing zephyr/.config (and zephyr/include/autoconf.h) in
kconfig.py if there are no warnings-turned-errors.

Also check if the saved checksum file exists in kconfig.cmake before
trying to open it. Normally this shouldn't happen though.

Move the writing of the checksum file to before writing zephyr/.config
as well. That way, zephyr/.config only gets written if the other
operations succeed.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-02 19:15:26 +02:00
Sebastian Bøe c1bf7350b1 cmake: Improve the error message when the compiler is not executable
When the SDK/toolchain has been incorrectly installed such that the
user does not have permissions to execute it an incomprehensible
errror message occurs.

This patch tests that executing 'gcc --version' does not give an error
code and errors out with an appropriate error message if it does.

This fixes #8977

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-07-31 12:40:37 -04:00
Anas Nashif 7ce9615a2b nsim: add run target
Support 'make run' with this target rather than using 'flash' which
might be confusing.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-19 18:59:07 -04:00
Anas Nashif 93ca721c48 xtools: set toolchain vendor to zephyr
For xtools, we set the vendor to zephyr directly and do not get it from
a variable.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-13 16:17:23 -05:00
Carles Cufi 45d58a7bb1 cmake: Rename process.cmake to reflect contents
Rename process.cmake to reflect its contents: executing the CMake
command "execute_process".

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-07-12 23:11:46 -04:00
Carles Cufi b8dd6ac741 cmake: util: Add fmerge.cmake script
In order to merge multiple files into a single one, this convenience
script is provided to be able to do so at build time in a manner
compatible with all operating systems.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-07-12 01:26:05 +02:00
Carles Cufi ff5452ef5c cmake: util: Add process.cmake script
In order to be able to execute a process at build time (and not at
configure time) in a cross-platform manner while at the same time
redirecting stdout and stderr to files, add a script that wraps CMake's
execute_process() command.

The script can be invoked with identical parameters to execute_process()
but at build time, allowing CMake users to store stdout and stderr in
files in a way that works on all operating systems.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-07-12 01:26:05 +02:00
Anas Nashif 6f29dac25a toolchain: require Zephyr SDK 0.9.3
SDK 0.9.3 has been out for a while, to avoid inconsistency and false
positive when filing bugs, require the latest version.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-08 15:39:35 -04:00
Anas Nashif 0009df8212 toolchains: fix multilib libc linking with xtools
Fixed linking with multilib toolchains by adjust the path to sysroot.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-08 15:39:35 -04:00
Anas Nashif 458fe44692 toolchain: iamcu support with xtools toolchain
Support both x86 and iamcu variants of the toolchain.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-08 15:39:35 -04:00
Anas Nashif 7c15934b53 toolchains: add xtools support for ARC
Latest crosstools NG supports ARC, so add it here for those who build
their own toolchains using xtools-ng or use the scripts from sdk-ng repo
in the zephyr project.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-08 15:39:35 -04:00
Henrik Brix Andersen ff6dbc599c build: fix git describe call on older Git versions
Older Git versions still do not support the -C argument for specifying
the working directory. Switch to using cmake WORKING_DIRECTORY instead.

This fixes #7287 again after commit 5e7e1cb.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2018-07-03 12:49:45 -05:00
Ioannis Glaropoulos 059952c8e1 arch: arm: update compile options for DSP
This commit updates the compile options in cmake to distinguish
between ARMv8-M Mainline MCUs with or withouth the optional DSP
extension. A new Kconfig option: ARMV8_M_DSP, is introduced, to
signify the use of an ARMv8-M MCU with DSP support.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-07-03 12:17:13 -05:00
Anas Nashif 72edc4e15f clang/llvm: add initial configuration file for clang
Add an LLVM backend and a clang toolchain variant to support building
with llvm coming with popular Linux distributions.

This has been tested with X86 boards:
- quark_d2000_crb
- quark_se_c1000_devboard/Arduino 101

Use:

export ZEPHYR_TOOLCHAIN_VARIANT=clang

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-01 22:58:09 +02:00
Sebastian Bøe 608778a4de cmake: Support specifying Kconfig options on the CLI
This resolves #5723 by adding support for assigning to Kconfig options
from the CMake CLI.

CMake CLI Kconfig options can be specified like so:

'cmake -DCONFIG_ASSERT=y'

The lifetime of such an option is the same as the lifetime of a CMake
cache variable, and in principle any method of populating the
CMakeCache could be used, such as cmake-gui.

This has been implemented by scanning the CMakeCache variables before
Kconfig is executed and writing any that are prefixed with 'CONFIG_'
to a new Kconfig fragment in the build directory that is merged in
with a high precedence.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-06-20 15:40:24 -04:00
Marti Bolivar 5e7e1cba69 cmake: fix git describe command line
The "git describe" call for setting the boot banner is broken. The
--work-tree option sets the checked out work tree, not the directory
containing .git, which is where git describe needs to look for
information on tags.

Use -C instead so it's as if Git were run from the zephyr base
directory instead.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-06-19 17:45:45 -04:00
Alex Tereschenko 3c1a78ea0d cmake: replace PROJECT_SOURCE_DIR with ZEPHYR_BASE
Both variables were used (with the same value) interchangeably
throughout CMake files and per the discussion in GH issue,
ZEPHYR_BASE is preferred.

Also add a comment with explanation of one vs. the other.

Tested by building hello_world for several boards ensuring no errors.

Fixes #7173.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2018-06-18 15:25:55 -04:00
Michael R Rosen 025a1e9086 cmake: fix CONF_FILE parsing to allow for cmake lists
Modify CONF_FILE variable treatment in the cmake infrastructure
to enable the use of CMake lists and semicolon-separated strings
in setting the CONF_FILE list for multiple configuration files.
This change does not impact the current method of using
single-space-separated strings for multiple files.

Signed-off-by: Michael R Rosen <michael.r.rosen@intel.com>
2018-06-11 17:26:39 -04:00
Adithya Baglody 4a693c3c38 boards: common: bossac: Fix bossac flash script.
The flash script was broken after the cmake changes.
Updated the path needed for the flash scripts.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2018-06-04 12:15:31 -05:00
Paul Sokolovsky 420bfc1f2d cmake: toolchain: Don't warn of both ZEPHYR_*_VARIANT envvars defined
Someone doing bisects on Zephyr will have to have both older
ZEPHYR_GCC_VARIANT and newer ZEPHYR_TOOLCHAIN_VARIANT environment
variables defined. Then warning about ZEPHYR_GCC_VARIANT is
confusing. Issue it if only ZEPHYR_GCC_VARIANT is defined, and
ZEPHYR_TOOLCHAIN_VARIANT isn't.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-06-01 10:34:25 -04:00
Adithya Baglody 5d22834e9a cmake: extensions: Remove macro zephyr_library_ifdef.
This cmake macro was changing the control flow of the cmake files.
It is not advisable to modify the callee control flow from inside
a cmake macro.
Hence removing all instances of this macro from the build system.

Fixes: GH-7565

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2018-05-28 13:23:13 -04:00
Sebastian Bøe cde6bef778 kconfig: Drop support for CONFIG_TOOLCHAIN_VARIANT
The Kconfig option TOOLCHAIN_VARIANT (not to be confused with
ZEPHYR_TOOLCHAIN_VARIANT) is a legacy configuration option that has
very few use-cases and can easily be dropped.

It's functionality is easily covered by CONFIG_X86_IAMCU and
ZEPHYR_TOOLCHAIN_VARIANT.

This commit removes all references of it from Zephyr.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-05-22 11:15:36 -04:00
Marti Bolivar 5317f76dec scripts: west: introduce common runner configuration
Continue better integration of the runner subpackage into west by
moving the common runner configuration options into the command
core. This allows commands like "west flash -h" to display help for
common overrides like --kernel-hex.

Adjustments needed to make this happen are:

- Change the build system to separate common configuration values from
  runner-specific options and arguments

- Prepare the runner core by defining a new RunnerConfig class that
  represents the common configuration, and accepting that from a new
  create() method, which replaces create_from_args().

- Convert all concrete runner classes to use the new style of
  argument parsing and initialization.

- Group the command options appropriately for help output readability

There's still a bit of tool-specific stuff in the common
configuration (gdb and openocd configuration in particular); a more
generic way to deal with that will be necessary to better support
things like non-GDB debuggers, but that's out of scope of this patch.

All the runner-specific options are still in the runner packge, which
currently prevents them from being included in "west flash -h" etc.
Fixing that is also out of scope of this patch.

This has the ancillary benefit of getting rid of the legacy 'debug'
argument to ZephyrBinaryRunner, which is no longer appropriate since
verbose debug logging is handled by log.py in west.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-05-19 07:01:39 +03:00
Marti Bolivar fbd2e92b42 scripts: remove zephyr_flash_debug.py
Since, by design, the west 'flash', 'debug', and 'debugserver'
commands operate the same way as the Makefile targets when given no
arguments, so just delegate to west from cmake/flash/CMakeLists.txt
instead of invoking zephyr_flash_debug.py by hand.

Removing the old script is the first step towards being able to clean
up the command line argument handling in the runner package, which was
always kind of a hack and can be improved now that runner is part of a
larger tool.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-05-19 07:01:39 +03:00
Marti Bolivar 9e7d16acd9 scripts: make runner a west subpackage
This is a stepping-stone to adding runner functionality into west
itself.

Since all of the runner tools assume a Zephyr build directory layout,
this doesn't put anything generic into a Zephyr-specific tool.

Make minimal adjustments to zephyr_flash_debug.py to keep existing
build system targets working unmodified.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-05-19 07:01:39 +03:00
Marti Bolivar 64badd97cd cmake: flash: save runner configuration to CMake cache
Persist all the important information needed by the runner package to
the CMake cache. This serves as a parseable record for various tools
which need to understand how to run the binary.

In particular, it will be used by the west tool, which will be
introduced in subsequent patches.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-05-19 07:01:39 +03:00
Kumar Gala cc8b726517 cmake: Add new generate_inc_file_for_gen_target function
Add a variant on generate_inc_file_for_target in which the user can
specify the target that the generated file will depend on.  This allows
exposing that target to other possible places where a dependency on the
generated file existing might be needed.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-05-17 15:07:48 -05:00
Andrew Boie 47fa8eb98c userspace: generate list of kernel object sizes
This used to be done by hand but can easily be generated like
we do other switch statements based on object type.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-05-16 17:32:59 -07:00
Adithya Baglody c674167fea cmake: extensions: Added a new macro zephyr_library_ifdef
Checks if a certain Kconfig is enabled and then do the same
operation as zephyr_library.
If it finds that the Kconfig is not set it will not
create a new library and will stop processing the rest of
the CMakeFile.txt. Usefull in processing the driver Cmake
files.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2018-05-15 17:48:18 +03:00
Wayne Ren 6307b8b97d arch: arc: refactor the soc part of em_starterkit
The original em7d, em9d and em11d are different configurations of
em_starterkit. They have the same peripherals, e.g. uart, spi, gpio
, ddr. The differences of them are in arc core configurations, interrupt
number assignment.

So em7d, em9d and em11d can be viewed in the same SoC family or SoC
series.

Referring other arch's implementation, this commit merges em7d, em9d
and em11d into the same SoC, named snps_emsk. This will eliminate
unnecessary duplication and make it easier for future maintainment.

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-05-15 09:48:11 +02:00
Ulf Magnusson 11952a60bf kconfig: Remove the C Kconfig implementation
Remove the C Kconfig tools and various scripts associated with them.

scripts/kconfig/diffconfig is popular, so keep it.

I don't know whether anyone is using scripts/kconfig/config. Remove it
and see if anyone screams.

scripts/kconfig/streamline_config.pl deals with modules ('m' values) and
can safely be removed. Zephyr's Kconfig files do not use modules.

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-05-07 21:53:37 +02:00
Ulf Magnusson 890a5a5aa1 kconfig: Remove targets specific to the C implementation
They will no longer be available once the C Kconfig implementation is
removed.

oldconfig and allno/yesconfig implementations are available for
kconfiglib and could be added later if needed. savedefconfig (minimal
configuration generation) is available from the menuconfig.py
configuration interface.

cmake/usage/kconfig-usage.cmake becomes kinda pointless after this
change, so merge it into cmake/usage/usage.cmake.

Remove the kconfig_target, COMMAND_FOR_*, and COMMAND_RUNS_ON_WIN_*
CMake variables, as there's just the 'menuconfig' target now.

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-05-07 21:53:37 +02:00
Ulf Magnusson 7229a9a560 scripts: kconfig: Switch 'menuconfig' over to menuconfig.py
Make 'make/ninja menuconfig' run menuconfig.py instead of mconf from the
C Kconfig tools. Get rid of the 'pymenuconfig' target.

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-05-07 21:53:37 +02:00
Sebastian Bøe aa90d72116 cmake: Introduce a key version to invalidate corrupted caches
When a bug in the caching mechanism is detected the cache format must
be bumped to ensure that we no longer get a cache hit on old corrupted
keys.

This fixes #7246 when the cache is corrupted.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-05-02 10:16:24 -04:00
Sebastian Bøe 5f08b106a8 cmake: Suppress messages about compiler checks
Messages about compiler checks are very verbose so we disable them by
default. They have always been undesirably verbose, but introducing
CMAKE_REQUIRED_FLAGS into the 'check' string made them unacceptably
so.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-05-02 10:16:24 -04:00
Sebastian Bøe 632fe1d411 cmake: check_compiler_flag: Fix bug where checks were aliased
Fix a bug where different compiler checks were aliased and therefore
the test results were incorrectly re-used.

The 'check' string is used by CMake internally to cache test results,
but when testing linker flags the check string has been aliased
between the different linker checks. To fix the aliasing issue we add
the CMAKE_REQUIRED_FLAGS variable to the 'check' string. The aliasing
issue disappears because the linker flag-under-test is in
'CMAKE_REQUIRED_FLAGS'.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-05-02 10:16:24 -04:00
Rajavardhan Gundi 08172cdf83 xtensa: provide XCC compiler support for Xtensa
This patchset provides Xtensa's xcc compiler support for Xtensa
projects in Cmake. This requires the below environment variables
to be defined aptly. The appropriate xcc license information also
need to be supplied.

ZEPHYR_GCC_VARIANT=xcc
TOOLCHAIN_VER=RF-2015.3-linux
XTENSA_CORE=cavs21_LX6HiFi3_RF3_WB16
XTENSA_SYSTEM=/opt/xtensa/XtDevTools/install/tools/
		RF-2015.3-linux/XtensaTools/config/
XTENSA_BUILD_PATHS=/opt/xtensa/XtDevTools/install/builds/

Change-Id: Ib3c10e8095439b0e32276ff37c00eca8420773ec
Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-01 16:46:41 -04:00
Henrik Brix Andersen 9fbdab528e build: fix git describe call on older Git versions
Older Git versions do not support the -C argument for specifying the
working directory. Switch to using --work-tree instead.

This fixes #7287.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2018-05-01 16:33:21 -04:00
Ulf Magnusson 73549ad852 scripts: kconfig: Add a Python menuconfig implementation
This commit adds a Kconfiglib-based menuconfig implementation, built
with the standard Python 'curses' module. A new 'pymenuconfig' target is
added to run it.

The C tools are kept for now. Removing them separately allows testing of
pymenuconfig alongside the C tools, and keeps changes small and focused.

A feature is planned for later that shows all symbols -- including those
that aren't currently visible -- along with a search and "jump to"
feature. Loading of arbitrary .config files will be supported later as
well (as opposed to always loading .config/KCONFIG_CONFIG). Those
features are all connected implementation-wise.

For Windows, the wheels at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses provide the curses
implementation. They use the standard Python curses module
(_cursesmodule.c), linked against PDCurses.

Running 'python -VV' gives the Python version and bitness, to know which
wheel to install. User documentation will be added once the C tools are
removed and the 'pymenuconfig' target is moved over to 'menuconfig'.

The CMake parts are originally by Sebastian Bøe.

Description, taken from the menuconfig.py docstring:

    Overview
    ========

    A curses-based menuconfig implementation. The interface should feel
    familiar to people used to mconf ('make menuconfig').

    Supports the same keys as mconf, and also supports a set of
    keybindings inspired by Vi:

      J/K     : Down/Up
      L       : Enter menu/Toggle item
      H       : Leave menu
      Ctrl-D/U: Page Down/Page Down
      G/End   : Jump to end of list
      g/Home  : Jump to beginning of list

    The mconf feature where pressing a key jumps to a menu entry with
    that character in it in the current menu isn't supported. A search
    feature with a "jump to" function for jumping directly to a
    particular symbol regardless of where it is defined will be added
    later instead.

    Space and Enter are "smart" and try to do what you'd expect for the
    given menu entry.

    Running
    =======

    menuconfig.py can be run either as a standalone executable or by
    calling the menu.menuconfig() function with an existing Kconfig
    instance. The second option is a bit inflexible in that it will
    still load and save .config, etc.

    When run in standalone mode, the top-level Kconfig file to load can
    be passed as a command-line argument. With no argument, it defaults
    to "Kconfig".

    The KCONFIG_CONFIG environment variable specifies the .config file
    to load (if it exists) and save. If KCONFIG_CONFIG is unset,
    ".config" is used.

    $srctree is supported through Kconfiglib.

    Other features
    ==============

      - Seamless terminal resizing

      - No dependencies on *nix, as the 'curses' module is in the Python
        standard library

      - Unicode text entry

      - Improved information screen compared to mconf:

          * Expressions are split up by their top-level &&/|| operands
            to improve readability

          * Undefined symbols in expressions are pointed out

          * Menus and comments have information displays

          * Kconfig definitions are printed

    Limitations
    ===========

      - Python 3 only

        This is mostly due to Python 2 not having curses.get_wch(),
        which is needed for Unicode support.

      - Doesn't work out of the box on Windows

        Has been tested to work with the wheels provided at
        https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses though.

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-05-01 20:51:11 +02:00
Ulf Magnusson a4381d9ea6 kconfig.cmake: Consistently use ZEPHYR_BASE
I found the mixing of ZEPHYR_BASE and PROJECT_SOURCE_DIR confusing. They
are synonyms.

Related issue: https://github.com/zephyrproject-rtos/zephyr/issues/7173

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-05-01 20:51:11 +02:00
Anas Nashif f8c1cc175a toolchain: update xtools config
Add placeholders for all possible xtools toolchains.

Fixes #6911

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-30 12:54:35 -04:00
Anas Nashif 33d87efda5 build: simplify git describe call
Instead of using a module that tries to do too many things that break
in different places, keep it simple and just call git describe.

This fixes #7044 and fixes #7207.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-30 10:16:40 -04:00
Sebastian Bøe 8bcf30e21a cmake: posix: Use absolute paths for toolchain paths
Make posix align with non-posix platforms by having CMAKE_C_COMPILER
and friends use absolute paths.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-04-27 12:06:02 +02:00
Sebastian Bøe 71b849f18c cmake: Port Zephyr to use zephyr_check_compiler_flag
This commit ports nearly all usage of check_c_compiler_flag,
check_cxx_compiler_flag, and check_compiler_flag to use
zephyr_check_compiler_flag instead.

This has a significant CMake configure-time performance impact.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-04-27 12:06:02 +02:00
Sebastian Bøe 84475810ec cmake: Introduce zephyr_check_compiler_flag()
zephyr_check_compiler_flag is introduced to resolve
https://github.com/zephyrproject-rtos/zephyr/issues/5633

The time spent when invoking CMake is halved with a warm cache.

See the API documentation for details.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-04-27 12:06:02 +02:00
Sebastian Bøe a7c3f4ed25 cmake: toolchain: Checksum the toolchain to uniquely identify it
This commit introduces TOOLCHAIN_SIGNATURE. A CMake variable that is
defined like this:

Toolchains with the same signature will always support the same set of
flags.

Currently it is implemented by MD5summing the CC binary.

This is useful for instance if the build system needs to determine if
it has seen the toolchain before, e.g. in a caching use-case.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-04-27 12:06:02 +02:00
Sebastian Bøe c95c6bef04 cmake: check_compiler_flag: Support empty-string options
This commits allows check_compiler_flag to accept the empty string as
an option. There are several use-cases for accepting no flag, one of
which is testing the toolchain itself.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-04-27 12:06:02 +02:00
Sebastian Bøe 709daa20e9 cmake: Find a directory that could be used to cache files
To improve the build system's "clean build" runtime we need to cache
files in a directory outside of the build directory.

Caching files outside of the build directory is is already being done
to a certain degree today. For instance, if a user has installed
ccache it will cache files in $HOME/.ccache/.

This commit locates a directory that is suitable for caching files in
a cross-platform way. For instance on Linux this is believed to be
$HOME, on Windows this is believed to be %LOCALAPPDATA%.

If for whatever reason no environment variables are are found to be
suitable we fall back to using $ZEPHYR_BASE/.cache/. For users that
often use 'git -clean' the caching mechanism will not work as well,
but it will at least be better than no caching at all.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-04-27 12:06:02 +02:00
Sebastian Bøe 6c3a94c01f cmake: Add function for checking if a directory is write-able
Added a CMake extention for determining if a directory is write-able
by the build system. To determine this, we attempt to 'touch' a file
in the directory and check the return code of this command.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-04-27 12:06:02 +02:00
Leandro Pereira 39dc7d03f7 scripts: gen_kobject_list: Generate enums and case statements
Adding a new kernel object type or driver subsystem requires changes
in various different places.  This patch makes it easier to create
those devices by generating as much as possible in compile time.

No behavior change.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-04-26 02:57:12 +05:30
Håkon Øye Amundsen 6779d3f356 cmake: Fix printed list of supported boards.
Fixes issue #7184.

Use $BOARD_ROOT to find correct list of supported boards.
This is needed since the user can set this variable to any directory.
Pass $BOARD_ROOT to usage.cmake where it is called.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2018-04-25 17:36:58 +05:30
Sebastian Bøe f10fddeb56 cmake: toolchain: Improve error feedback when toolchain is not found
Improve the error feedback when the toolchain is not found.

Currently, for some setups, presumably primarily SDK-less setups,
users can get an error message like this for certain types of
misconfigurations:

CMake Error at zephyr/cmake/extensions.cmake:984 (message):
  No such file or directory: CMAKE_READELF: 'CMAKE_READELF-NOTFOUND'
Call Stack (most recent call first):
  zephyr/cmake/compiler/gcc.cmake:14 (assert_exists)
  zephyr/cmake/toolchain.cmake:38 (include)
  zephyr/cmake/app/boilerplate.cmake:243 (include)
  CMakeLists.txt:1 (include)

This commit will improve the error feedback to give a explanation for
what kind of failure has occured and will also dump relevant variables
to ease debugging.

This fixes #7075

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-04-19 12:53:43 -07:00
Anas Nashif daf7716ddd build: use git version and hash for boot banner
This uses the version and hash (git describe) and replaces the timestamp
currently used in the boot banner. This works much better than using
timestamps. It lets us point to the exact commit being used to run a
certain application or test.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-10 10:57:50 -04:00
Sebastian Bøe 9be27f73db kconfig: Make CONIG_FP_SOFTABI generate floating point instructions
The actual behaviour of CONIG_FP_SOFTABI has not been matching the
documenation. The Kconfig documentation states that floating point
instructions should be generated, but this Kconfig option has been
turning off floating point instructions instead.

This commit causes floating point instructions to be generated when
CONFIG_FP_SOFTABI is enabled, as was originally intended and
documented.

This commit can cause regressions if users have been relying on the
actual behaviour instead of the documented behaviour.

Kconfig documentation:

config FP_SOFTABI
	help
	  This option selects the Floating point ABI in which hardware
	  floating point instructions are generated but soft-float calling
	  conventions.

GCC documentation:

Specifying ‘soft’ causes GCC to generate output containing library
calls for floating-point operations. ‘softfp’ allows the generation of
code using hardware floating-point instructions, but still uses the
soft-float calling conventions. ‘hard’ allows generation of
floating-point instructions and uses FPU-specific calling conventions.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-04-10 08:36:28 -05:00
Tomasz Bursztyka 1134393ac1 scripts/dts: Make extract_dts_includes generating both files by itself
Thus no need to parse twice the .dtsi, .dts and .yaml files.
Simplify provided arguments relevancy, letting argparse generating usage
message by itself.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-03-26 14:48:49 -04:00
Anas Nashif 993c350b92 cleanup: replace old jira numbers with GH issues
Replace all references to old JIRA issues (ZEP) with the corrosponding
Github issue ID.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-03-26 13:13:04 -04:00
Marti Bolivar 98456b30f8 cmake: fix set_ifndef() usage patterns
If the value argument to set_ifndef() may be unset, the entire value
must be double-quoted to avoid a CMake syntax error.

Fix call sites which don't handle this, or which otherwise make
non-idiomatic use of this function.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-03-23 05:32:44 -04:00
Sebastian Bøe 777e0a1b86 cmake: Support UTF-8 characters in Kconfig values
We are using the CMake command 'file(STRINGS' (which defaults to only
decoding ASCII) to read Kconfig configurations. When UTF-8 characters
are detected they are treated as newlines.

This behaviour has caused issues when users have input UTF-8
characters into Kconfig values. E.g. USB device descriptor strings.

This commit adds the flag 'ENCODING "UTF-8"' to the 'file(STRINGS'
command so that UTF-8 characters are correctly passed through the
build system.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-03-21 19:11:19 -04:00
Sebastian Bøe 87031e3cf9 cmake: Find out earlier whether ccache is to be used or not
Moving the ccache build script earlier in allows us to export ccache
to external projects. Using ccache with external projects, such as
OpenThread, can significantly speed up the build time.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-03-02 07:13:21 +01:00
Kumar Gala d2e89856cc cmake: dts: Fix usage of BOARD vs BOARD_FAMILY
We assumed that ${BOARD} and ${BOARD_FAMILY} are always the same and
thus interchangeable.  That isn't always the case so use ${BOARD} proper
for when we mean the exact BOARD name we are building for vs the
BOARD_FAMILY.

We also add .dts files for board variants within a board family, such
that we have a .dts matching each board name.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-02-27 19:56:47 -06:00
Ioannis Glaropoulos 5343f8973d cmake: indicate single precision floating-point for Cortex-M33
ARM Cortex-M33 may implement an optional Floating Point Unit
(FPU) supporting single-precision arithmetic. This commit
modifies the respective GCC_M_CPU flag to comply with Cortex-M33.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-02-23 21:42:22 -06:00
Kumar Gala b328ec51ac cmake: dts.cmake: Use SOC_PATH to find soc/dts.fixup
Per arch the path to the SOC dir that we would find dts.fixup varies
between being ${CONFIG_SOC_FAMILY}/${CONFIG_SOC_SERIES} and just
${CONFIG_SOC}.  The ${SOC_PATH} var handles defining this correct so
use it instead when we define DTS_SOC_FIXUP_FILE.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-02-22 10:14:02 -06:00
Kumar Gala 440cc18d1b cmake: Move SOC_* var defines to cmake/app/boilerplate.cmake
We need access to SOC_PATH in dts.cmake so we need to move the
definitions of SOC_NAME, SOC_SERIES, SOC_FAMILY, and SOC_PATH out of the
toplevel CMakeLists.txt and into cmake/app/boilerplate.cmake.  We place
them before we include cmake/dts.cmake so they will be available to use
in it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-02-22 10:14:02 -06:00
Pedro Martucci a495b31ee0 sample: net: RPL mesh sample over QEMU
Create a net sample to setup a multi-node RPL mesh network using QMEU.
To enable this, it was necessary implement a hw filter on IEEE 802.15.4
UART Pipe driver and create a QEMU pipe management on cmake.

This sample use a tool developed on zephyr net-tools repository called
virtual-hub.

Signed-off-by: Pedro Martucci <pedropaulomartucci@gmail.com>
2018-02-20 14:47:14 +02:00
Anas Nashif e172fa3b52 build: support out-of-tree custom boards
This is one way we can support out of tree board definitions. Basically
all this needs is a board definition in the application source directory
that follows the same structure we have in the main Zephyr tree (also
allowing multiple custom boards). An application tree would look like
this for example:

boards/
CMakeLists.txt
prj.conf
README.rst
src/

with boards following the same structure as in Zephyr:

.
├── boards
│   └── x86
│       └── arduino_101
│           ├── doc
│           │   └── img
│           └── support
└── src

To use this, you need to specify the BOARD_ROOT variable on the command
line when building:

cmake -DBOARD=<board name> -DBOARD_ROOT=<path to boards> ..

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-14 19:20:29 -05:00
Anas Nashif 622ab2f6fd toolchain: organise toolchain/compiler files
Move toolchain definitions into toolchain/ and move compilers to
compilers/
Usage of toolchain- for everything was confusing, there are the actual
compiler related definitions and there is the toolchain/SDK related
configs, so keeping them separate helps understand the different and
prevents confusion.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-13 07:44:45 -08:00
Anas Nashif 7ee8bb9677 build: deprecate ZEPHYR_GCC_VARIANT
We want to support other toolchain not based on GCC, so the variable is
confusing, use ZEPHYR_TOOLCHAIN_VARIANT instead.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-13 07:44:45 -08:00
Carles Cufi 72684ef815 dts: mcuboot: Support for common overlays and mcuboot
When the Kconfig BOOTLOADER_MCUBOOT is selected, an overlay to place the
image at the slot0 location is required. In order to avoid having to do
this manually for all samples when targetting MCUboot, include the logic
inside the dts.cmake script to prepend a new common.dts file that then
conditionally includes mcuboot.overlay.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-02-09 09:11:13 -05:00
Carles Cufi 06b9841675 dts: Move dts.cmake to cmake/
Move the DTS CMake file to the cmake/ folder, where all other .cmake
files live.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-02-09 09:11:13 -05:00
Carles Cufi 1cce63ae8f cmake: dts: Allow multiple overlay files
This patch changes the manner in which we collect DTS overlay files so
that they comply with the same approach taken for configuration fragment
files (.conf).

Additionally it also documents the usage of those files in the
Application Developer Guide.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-02-05 14:09:43 -05:00
Marti Bolivar 461511e1fc cmake: fix 'ninja flash' et al with multiple boards plugged in
Fixes: 5958

Ninja by default will suppress command output and input. This is a
problem for the 'flash', 'debug', etc. targets, which may need to
interact with the user (and which display interactive output like
progress bars).

To fix this, add the USES_TERMINAL option to their target
definitions. This puts them in the console pool on Ninja, allowing the
commands to interact with the console.

References:

https://ninja-build.org/manual.html#_the_literal_console_literal_pool
https://cmake.org/cmake/help/v3.8/command/add_custom_target.html

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-02-02 19:04:00 +01:00
Patrick Boettcher 55109ae5fb cmake: give an assert a useful message
When the ZEPHYR_GCC_VARIANT-variable is not set properly no
message is printed, whereas this small change will help users
to easier understand why things are not working. Here: they forgot
to set an ENV-variable.

Signed-off-by: Patrick Boettcher <patrick.boettcher@posteo.de>
2018-01-29 14:32:01 +01:00
Anas Nashif de311407bd scripts: fix ram_reports and generate bin file if missing
Some boards do not generate .bin files by default, this file is however
needed when generating ram/rom reports, so in case it is not present,
create it.

Fixes #5784

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-29 05:16:52 +05:30
Jimmy Huang 4a243ffce9 arch: arc: use default optimization flag
The work-around previously setting ARC builds to use -O2 to fix an
ADC bug #3797 is no longer needed, we should this patch and revert
to the default -Os flag to optimize for smaller size.

Signed-off-by: Jimmy Huang <jimmy.huang@intel.com>
2018-01-25 07:56:58 +05:30
Ding Tao d187da4922 cmake: Fix missing braces around interface
Error occurred when using target_link_libraries in CMakeLists.txt:

Cannot specify link libraries for target "interface" which is not built
by this project.

Replace "interface" with "${interface}".

Signed-off-by: Ding Tao <miyatsu@qq.com>
2018-01-23 17:42:05 +05:30
Sebastian Bøe 690bea3a3c cmake: Fix "make usage" regression from the ZEPHYR_BASE change
$ENV{ZEPHYR_BASE} was recently search-replaced with ${ZEPHYR_BASE},
but some CMake code, like usage.cmake, is run by a seperate CMake
build system that does not have access to the CMake variable
ZEPHYR_BASE.

This patch reverts the usage of ${ZEPHYR_BASE} back to use
$ENV{ZEPHYR_BASE} in usage.cmake.

This has been proven to work on both Windows and Linux.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-18 10:44:19 -05:00
Sebastian Bøe 2c8aa87138 kconfig: Revert back to old behaviour pre-kconfiglib.py
Run Kconfig on every reconfigure but with different fragments
depending on the situation.

When .config is missing or when a file from merge_config_file has been
modified use the merge_config_file's as input, otherwise use .config
as input.

This should match the behaviour before kconfiglib.py was introduced
and fixes #5673.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-17 07:39:28 -05:00
Sebastian Bøe db31de5df6 Revert "cmake: kconfig: Run Kconfig on every reconfiguration"
This reverts commit a8b361b176.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-17 07:39:28 -05:00
Anas Nashif 54bdccc5bc cmake: do not error on missing 'config'
'conf' is part of the zephyr SDK or need to be built and installed in
the path. We now using python for Kconfig processing, so this is not a
strict requirement and we should be able to build without it. If the
binary is not found, just go on with our business.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-16 17:03:48 -05:00
Marti Bolivar 70a40813df cmake: add optional app_set_runner_args()
Due to a chicken-and-egg problem, it's not possible to call
board_runner_args() directly from an application CMakeLists.txt and
have it take effect:

  - if the board_runner_args() call appears before including the
    boilerplate file, then the function is undefined and an error
    occurs.

  - if the call appears after including the boilerplate file, then
    board_finalize_runner_args() has already been called by the
    relevant runner.board.cmake file, so it won't take effect.

Similarly to the way set_conf_file() works, allow applications to
declare additional runner args by checking if they have provided a
macro named app_set_runner_args(), which contains calls to
board_runner_args(). Using a macro means that we can invoke it with
the definition of board_runner_args() in scope.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-01-15 16:21:28 -05:00
Sebastian Bøe 8b6d3ad69b cmake: Improve error messages for detecting libgcc
Use two different variables for the distinct values LIBGCC_FILE_NAME
and LIBGCC_DIR and assert that each of them exists.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-12 08:37:41 -05:00
Sebastian Bøe 15ca6da4c8 cmake: Re-introduce support for CROSS_COMPILE
CROSS_COMPILE is a KBuild feature that was dropped during the CMake
migration. It is now re-introduced. Documentation for it is still
lacking, but at least it now behaves as expected.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-12 08:37:41 -05:00
Sebastian Bøe a896be1192 cmake: toolchain: Misc. comment cleanups
Sync the outdated comments with the code. E.g. there is no
toolchain-clang.cmake, but there is a toolchain-host-gcc.cmake.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-12 08:37:41 -05:00
Sebastian Bøe 4b61bd1b7a kconfig: Prune kconfig files that don't match the ARCH or BOARD
When Kconfiglib was introduced it caused a significant performance
issue. This patch uses pruning to mitigate the performance issue.

The pruning exploits the fact that before the Kconfig database is
parsed we already know what ARCH and BOARD has been selected. So in
theory we could prune away all Kconfig sources that are not related to
the current ARCH or BOARD. In practice, it is only the Kconfig sources
in zephyr/arch/$ARCH and zephyr/board/$ARCH/ that are easy to prune.

Still, that is quite a few Kconfig sources. For qemu_x86 this patch
reduced the number of parsed Kconfig source files from 632 to
272. This pruning resulted in a incremental reconfiguration (time
cmake ..) speedup of 21% (0.56s to 0.46) and a clean build speedup of
4% (Using board qemu_x86 and sample hello_world).

Furthermore, it should be easier to maintain ARCH's and BOARD's
out-of-tree since the user now has a mechanism to redirect where
Kconfig sources are found. But this has not been explored.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-12 07:29:05 -05:00
Sebastian Bøe a8b361b176 cmake: kconfig: Run Kconfig on every reconfiguration
Kconfiglib does not support merging fragments without parsing the
entire Kconfig "database". For Zephyr this means we no longer get a
performance gain from splitting up the fragment-merging and the
.config generation.

This patch removes the seperated merge step and it's associated
caching mechanism. Now we do a full Kconfig execution on every
reconfiguration.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-12 07:29:05 -05:00
Carles Cufi d92769b849 scripts: kconfig: Replace Kconfig exectuables with Python
We have been using a fork of the Linux kernel's Kconfig system to
configure the Zephyr tree. The issue is that this is a native tool
written in C that is not easy to compile for Windows. This patch
replaces the use of the conf executable with kconfig.py, a script that
uses Kconfiglib to generate the .config and autoconf.h files required to
compile Zephyr.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-01-12 07:29:05 -05:00
Carles Cufi 07a64f19ed cmake: Use find_program() to locate the toolchain
Instead of hard-coding the path use find_program(), since that allows
CMake to sort out platform-specific details such as .exe extensions on
Windows.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-01-11 16:05:05 -05:00
Carles Cufi 7d764b35f3 cmake: Use path-corrected version of ZEPHYR_BASE
Instead of accessing the environment variable ZEPHYR_BASE every time we
require accessing the source code root, use an intermediate variable
that has OS path separators correctly set to '/' to avoid issues on
Windows.

Note: This removes the ZEPHYR_SOURCE_DIR CMake variable. External
applications using that will need to change to use the new ZEPHYR_BASE
variable.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-01-11 14:59:03 -05:00
Sebastian Bøe daa39867b8 cmake: sdk: Improve error message when INSTALL_DIR is wrong
Add an assertion that verifies the user has not misconfigured
ZEPHYR_SDK_INSTALL_DIR.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-11 06:39:12 -05:00
Sebastian Bøe c6f367d251 cmake: Give descriptive error to user when cloned with core.autocrlf
Windows users have on multiple occasions cloned Zephyr using a Windows
git client. It seems that the windows git client defaults to
converting line endings from LF to CRLF when cloning repo's. This
breaks at least one of Zephyr's tools (Kconfig).

This patch introduces a sanity check of the environment for MSYS
users.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-10 22:12:27 -05:00
Carles Cufi e29744c0cd cmake: Require 3.8.2 on all platforms, including MSYS2
Now that MSYS2 ships with CMake 3.9.6 there's no need anymore to
downgrade the minimum required CMake version for it.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-01-08 11:01:47 -05:00
Anas Nashif 33592e8aa8 cmake: remove IS_TEST handling
Depending on a path inside the Zephyr tree to determine if we are a test
does not scale. Also some samples were marked as TEST while they are
not, just to get some options defined for tests.

Idenitfying a test will be addressed in another patch introducing
CONFIG_TEST.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-08 10:03:57 -05:00
Anas Nashif f746cb3aeb version: fix version handling without extra_version set
Without extra_version, we had an extra - at the end of the version
string.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-08 08:08:45 -05:00
Sebastian Bøe 5d25497f90 cmake: zephyr_get_*: Add support for SKIP_PREFIX
Usually the zephyr_get_* API returns values prefixed with tokens like
-I -system, -D. But sometimes we need the values without these
prefixes, so we introduce the optional SKIP_PREFIX argument.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-04 00:03:25 -05:00
Sebastian Bøe 3c8331d390 cmake: Introduce Zephyr interface libraries
Introduce Zephyr interface libraries to fix #5351.

From the documentation:

A Zephyr interface library is a thin wrapper over a CMake INTERFACE
library. The most important responsibility of this abstraction is to
ensure that when a user KConfig-enables a library then the header
files of this library will be accessible to the 'app' library.

This is done because when a user uses Kconfig to enable a library he
expects to be able to include it's header files and call it's
functions out-of-the box.

A Zephyr interface library should be used when there exists some
build information (include directories, defines, compiler flags,
etc.) that should be applied to a set of Zephyr libraries and 'app'
might be one of these libraries.

Zephyr libraries must explicitly call
zephyr_library_link_libraries(<interface_library>) to use this build
information. 'app' is treated as a special case for usability
reasons; a Kconfig option (CONFIG_APP_LINK_WITH_<interface_library>)
should exist for each interface_library and will determine if 'app'
links with the interface_library.

This API has a constructor like the zephyr_library API has, but it

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-02 22:09:01 -05:00
Sebastian Bøe d5fe808a09 cmake: net: qemu: Don't pass "-serial none" to qemu
I don't know why we have been passing "-serial none" to qemu but it
does not seem to be doing anything useful. So I propose we remove it.

According to the qemu documenation it should be disabling all serial
ports;

"-serial dev
Redirect the virtual serial port to host character device dev. The
default device is vc in graphical mode and stdio in non graphical
mode.

This option can be used several times to simulate up to 4 serial
ports.

Use -serial none to disable all serial ports."

But when we use "-serial none", we always combine it with "-serial
pipe", or "-serial unix", to redirect the serial port, so clearly it
is not disabling all serial ports as it attempting to do.

"-serial none" was first introduced to Zephyr in this commit:
0b54f984b8

As far I can tell, pinging an echo_server works fine without it, so I
suspect that our second -serial flag is overriding it and that it has
no effect.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-02 09:41:54 -05:00
Sebastian Bøe dfe5cb731c cmake: qemu: Don't use the '\$' hack with Ninja
Using the '\$' technique to accept make variables corrupts Ninja build
systems, so avoid using it when generating Ninja files. Not using it
with Ninja means we need to come up with some other mechanism to
support build-time configuration of the QEMU CLI with Ninja.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-30 11:29:24 -05:00
Sebastian Bøe c14013ca2d cmake: generate_inc: Change how the target name is constructed
The generate_inc_file_for_target() extension is a useful wrapper
around the more low-level generate_inc_file(). It takes care of
ensuring that the generated file correctly depends on it's source.

To do so it needs to name and define a custom_target, the name must be
unique, so it was constructed based on the path to the generated file,
but this caused multiple issues.

The intention was that the path of the file would help identify the
target, in hindsight, identifying the target has proven to not be
important.

This patch fixes #5466 by using a random string to construct the
target name instead of the path to the generated file.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-28 18:23:19 -05:00
Sebastian Bøe 5fb5adb34f cmake: Fix target_ld_options()
target_ld_options() was only testing whether a flag could be passed to
the compiler driver when it was compiling an object file. Not whether
a flag could be passed to the compiler driver when it was linking an
elf file.

For most flags, these tests would have the same result, but it does
not for flags like -Wl,--print-memory-usage or -Wl,notaflag.

This patch fixes #5488 by re-using the method from #5459.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-28 11:37:09 -05:00
Sebastian Bøe 4b77b4ad92 cmake: usage: Added posix to list of arch's with boards
Added posix to the list of arch's with boards. Usage will now show
native_posix as one of the available boards.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-28 11:24:21 -05:00
Anas Nashif 4592ff2d5a native: build zephyr.exe for posix arch
To indicate the generated binary is executable on the host, add .exe
extension to the generated ELF file.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-27 14:16:08 -05:00
Anas Nashif fd276aeb42 cmake: cleanup qemu runner configuration
All runner logic was implemented in qemu.cmake, remove the generic stuff
and make qemu.cmake qemu specific.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-27 14:16:08 -05:00
Anas Nashif e32a656962 posix: native: support native runner
This adds support of 'make run' to the native port allowing us to run
applications natively on the host instead of qemu.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-27 14:16:08 -05:00
Anas Nashif c15d3c9126 cmake: support other emulation platforms/runners
Right now we are hardcoded to only qemu, with the native port, we make
this more generic and support this in a plugin mode where a running has
its own cmake definitons implementing the various targets.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2017-12-27 14:16:08 -05:00
Alberto Escolar Piedras 76f7644118 arch: native: Run Zephyr natively in a POSIX OS
A new arch (posix) which relies on pthreads to emulate the context
switching
A new soc for it (inf_clock) which emulates a CPU running at an
infinely high clock (so when the CPU is awaken it runs till completion
in 0 time)
A new board, which provides a trivial system tick timer and
irq generation.

Origin: Original

Fixes #1891

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-27 14:16:08 -05:00
Anas Nashif 2bbe6af07c cmake: add zephyr_link_libraries_ifdef
Link libraries only when config is defined.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-27 14:16:08 -05:00
Anas Nashif 2e9064b7d6 cmake: replace @ in path with _
To avoid warnings from cmake such as:

  'path' is reserved or not valid for certain CMake features, such as
  generator expressions, and may result in undefined behavior.

This can be seen in Jenkins for example where @ is used when multiple
jobs are run on the same machine.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-23 09:13:44 -05:00
Sebastian Bøe fa53e89419 cmake: boilerplate: Define properties earlier
The properties definitions were not doing much because they were
defined after they were used. They were actually overriding the true
properties with "".

Moving them earlier ensures that the properties behave as expected, as
documented global mutable variables.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-19 17:01:47 -05:00
Marti Bolivar 8447b5ea2e cmake: flash: support verbose output toggle
If CMAKE_VERBOSE_MAKEFILE is defined, make flashing and debugging more
verbose.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2017-12-15 09:57:30 -05:00
Marti Bolivar 7a3462de7a scripts: runner: use arguments, not environment vars
The various runners (flash/debug scripts) use environment variables to
take arguments. This is legacy behavior which is not desirable.

Use command line arguments instead.

Note: this leaves more general environment variables with publicly
      documented behavior in place for now, for compatibility, e.g.:

      ZEPHYR_FLASH_OVER_DFU, OPENSDA_FW, ESP_IDF_PATH, PYOCD_DAPARG

For example, when using dfu-util to flash arduino_101, instead of
setting DFUUTIL_PID, DFUUTIL_ALT, and DFUUTIL_IMG environment
variables, have the script invocation look like this:

  python3 .../zephyr_flash_debug.py dfu-util flash \
          [common arguments omitted] \
          --pid=8087:0aba --alt=x86_app \
          --img=.../build/zephyr/zephyr.bin

Make similar changes for other runners (openocd, etc.) and
targets (debug, debugserver).

To implement this in the scripts:

  - have the individual scripts/support/runner/some-runner.py files
    register their own command line arguments

  - teach them to construct instances from arguments, not the
    environment

  - have zephyr_flash_debug.py request runners to register command
    line argument parsers, and handle arguments

In the build system:

  - add a new board_runner_args() extension function that board.cmake
    files can use to add to the zephyr_flash_debug.py command line

  - adjust cmake/flash/CMakeLists.txt to invoke with arguments

  - add new helper include files for each runner (like
    boards/common/dfu-util.board.cmake, etc.), which add default
    options as needed and then add on overrides from
    board_runner_args() calls

  - update board.cmake files to use the new includes and extension

This implied some tweaking when using openocd to make the CMake string
escaping and unescaping work properly.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2017-12-15 09:57:30 -05:00
Marti Bolivar 94290ee189 cmake: extensions: support list arguments to set_ifndef()
I keep tripping over not being able to use set_ifndef to set a value
to a list, like this:

set_ifndef(VARIABLE value1 value2 value3...)

Allow that to work without changing its existing behavior when called
with one argument.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2017-12-15 09:57:30 -05:00
Marti Bolivar e33ec242fd scripts: refactor flash/debug scripts to remove "shell"
The Python-based runners have replaced the old shell scripts. Refactor
the build system accordingly:

- FLASH_SCRIPT is now BOARD_FLASH_RUNNER
- DEBUG_SCRIPT is now BOARD_DEBUG_RUNNER

The values, rather than being the names of files, are now the names of
runners in scripts/support/runner. They are still short, descriptive
names like "openocd", "jlink", "em-starterkit", etc.

Adjust the zephyr_flash_debug.py call and runner internals
accordingly. Have each runner class report a name and the commands it
can handle. This lets us move some boilerplate from each do_run()
method into the common run() routine, and enables further improvements
in future patches.

The handles_command() method is temporary, and will be replaced by a
more general mechanism for describing runner capabilities in a
subsequent patch. The initial use case for extending this is to add
device tree awareness to the runners.

To try to avoid user confusion, abort the configuration if an
xxx_SCRIPT is defined.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2017-12-15 09:57:30 -05:00
Marti Bolivar f8e0a0c519 cmake: extensions: add assert_not()
To be used in a later patch.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2017-12-15 09:57:30 -05:00
Sebastian Bøe 11c020ebf7 cmake: Support installing toolchains in "Program Files"
Support installing toolchains in "Program Files", or more generally,
in paths that contain whitespace. This is a common bug for new users
to discover.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-12 11:53:45 -06:00
Sebastian Bøe c87d262295 size_report: Use the CMake-discovered toolchain instead of ENV vars
size_report was using the environment variables NM and OBJDUMP to find
it's toolchain dependencies. It is not clear how well this will work
on different platforms; OSX, Windows. So we now pass the paths of
these dependencies from the build system to the script.

PS: This ensures that size_report uses the cross-compiler's GNU bin
tool instead of the host GNU bin tools. This is presumably beneficial
as it has been required for other GNU bin tools like GDB.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-12 11:42:05 -05:00
Sebastian Bøe 6a2a94b124 cmake: qemu: Allow -kernel to be overridden
This is needed by platforms like jailhouse.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Signed-off-by: Gustavo Lima Chaves <gustavo.lima.chaves@intel.com>
2017-12-12 09:31:31 -05:00
Sebastian Bøe e0e7a7d852 cmake: Reorganize how qemu is found
We don't want to pollute core-infrastructure with board-specific code,
so we move the qemu discovery to after board.cmake has been executed,
and we introduce the overridable QEMU_binary_suffix CMake variable.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-12 09:31:31 -05:00
Gustavo Lima Chaves fb7f914cc7 cmake: call the right QEMU binary on Jailhouse's make run target
In that case, QEMU is emulating the base (root system) that will be
partitioned to receive Zephyr as one of the cells/guests, not the direct
system Zephyr will run on. We need this one more level of indirection,
otherwise it's impossible to attest Zephyr is running in a virtualized
environment in QEMU.

Fix QEMU binary to point to the x86_64 version, then, once Jailhouse is
targeted at that architecture.

Finally, don't pass QEMU the -kernel flag in this case, since Zephyr has
to loaded manually, from inside QEMU, for Jailhouse's make run target.

Signed-off-by: Gustavo Lima Chaves <gustavo.lima.chaves@intel.com>
2017-12-12 09:31:31 -05:00
Sebastian Bøe b0c4316190 cmake: Show usage when an invalid board is given
Print the usage when an invalid board is given, this somewhat
allievates the catch-22 where you need to run CMake to know what
boards exist, but you need a board to run CMake.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-10 19:51:21 -05:00
Sebastian Bøe 6c8ebab183 cmake: Added assert that will show usage
There is a catch-22 in that you need to run CMake to get a build
system that can show you usage, but you need to know the usage to be
able to get a build system.

This assert could be used to improve the usability somewhat. When
invalid usage is detected it can be used to print the usage.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-10 19:51:21 -05:00
Sebastian Bøe 6a61d5f82c cmake: Fix the dependency between qemu and the elf file
I can't explain why "make run" worked before, but after this patch it
should definitely work.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-07 08:09:12 -06:00
Sebastian Bøe 89516fbc25 cmake: Change the zephyr_get_* API to be LANG-aware
When exporting flags to an external build system we need to deal with
the fact that we sometimes use generator expressions. Specifically, we
use generator expressions that look like this:

$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>

This patch replaces the old API with a new one where users can ask for
compile options for specific languages, like this:

zephyr_get_compile_options_for_lang_as_string(CXX x)

The existing API would have either crashed or silently omitted flags
when a COMPILE_LANG generator expression was present.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-05 10:08:40 -05:00
Sebastian Bøe abbdd88683 cmake: Fix EXTRA_LDFLAGS feature
It is supported to add give extra flags to the linker from the
commandline like this:

cmake -DEXTRA_LDFLAGS=-Lmy_dir path

But unfortunately this was broken during the CMake
migration. Interestingly, the reason that it was broken is that KBuild
was also partially broken. KBuild would pass on EXTRA_LDFLAGS when
object files were linked together into built-in.o files, but it would
not use EXTRA_LDFLAGS for the final link into an elf file.

This patch fixes EXTRA_LDFLAGS.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-05 08:39:43 -05:00
Sebastian Bøe 13a6840261 cmake: Re-organize syscall generation wrt. the build system
This commit fixes
https://github.com/zephyrproject-rtos/zephyr/issues/5008.

It does so by splitting up gen_syscalls.py into two scripts with a
json metadata file to communicate syscall metadata between them. The
parsing script parses header files from include/ and writes syscall
metadata to a file if the contents changed. The generation script
reads from the json file and generates syscall code.

The build system DAG now looks like this:

always_rebuild -> json -> syscalls -> offset.o

The script for generating json will do so only if the content changes,
this ensures that the entire DAG does not always do a full rebuild.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-04 10:51:07 -08:00
Sebastian Bøe 2ead15de8d cmake: Move syscall_macros.h generation into the build stage
This fixes https://github.com/zephyrproject-rtos/zephyr/issues/5186

The script that generates syscall_macros.h is moved from Configuration
time to build time. This allows us to express to the build system that
syscall_macros.h depends on the script that generates it.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-11-30 06:49:33 -05:00
Sebastian Bøe bc2404aa4d Revert "cmake: add zephyr_cc_option_nocheck"
This reverts commit a01f2de734.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-11-29 09:51:55 -05:00
Anas Nashif a01f2de734 cmake: add zephyr_cc_option_nocheck
Support adding options without checking them with the compiler. In some
cases the simple check routine fails due to missing symbols.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-28 16:48:41 -05:00
Paul Sokolovsky 83cf82b7a8 cmake: qemu: Restore QEMU_PTY/QEMU_PIPE option handling.
Both options were originally parameters to *make*, not cmake, so people
can augment QEMU ibocation from run to run, not from complete rebuild
to complete rebuild. Make them such again.

However, just in case, ability to set "default" value for those options
on CMake level is preserved.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-11-27 22:33:56 -05:00
Sebastian Bøe f71c3fa665 cmake: Extend cc-option support to C++
The target_cc_option[_fallback]() CMake extentions are now C++
aware. This means that they will now test options with both C and C++
compiler and include flags appropriately.

This fixes a warning that was issued when -Wno-pointer-sign was used
 with .cpp files.

cc1plus: warning: command line option ‘-Wno-pointer-sign’ is valid for
C/ObjC but not for C++

NB: This patch is designed to only affect CONFIG_CPLUSPLUS builds in
case there are any adverse affects with using generator expressions.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-11-27 22:21:47 -05:00
Sebastian Bøe 935e95be41 cmake: extensions: Add check_compiler_flag function
This function has presents an easy-to-use interface that wraps the two
CMake built-in functions check_c_compiler_flag() and
check_cxx_compiler_flag().

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-11-27 22:21:47 -05:00
Paul Sokolovsky 5539047d93 cmake: qemu: Restore QEMU_INSTANCE option handling.
QEMU_INSTANCE should be a parameter to *make*, not cmake, so people
can run few instances of the same sample without building each of
them separately in separate dirs.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-11-24 08:28:20 -05:00
Sebastian Bøe 96e7df466a cmake: Give zephyr_library_* flags precedence over zephyr_* flags
This fixes https://github.com/zephyrproject-rtos/zephyr/issues/5097.

The desired behaviour is that when a flag that is given through the
zephyr_* API conflicts with the zephyr_library_* API then precedence
will be given to the zephyr_library_* API. In other words, local
configuration overrides global configuration.

We choose to rely upon the compiler for sane behaviour when flags are
in conflict. Compilers generally give precedence to flags given late
on the command line. So to ensure that zephyr_library_* flags are
placed late on the command line we create a dummy interface library
and link with it to obtain the flags.

Other options were considered, source file properties would also have
higher priority. But that would have required some kind of
post-processing stage that applies all the source file properties.

Linking with a dummy interface library will place flags later on the
command line than the the flags from zephyr_interface because
zephyr_interface will be the first interface library that flags are
taken from.

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-23 09:18:24 -05:00
Sebastian Bøe e51ce4d34d cmake: Generate POST_BUILD items based on KConfig
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-22 13:29:37 -05:00
Anas Nashif be25936bb2 release: make cmake happy about version
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-19 23:16:03 -05:00
Anas Nashif 388286663a cmake: fixed version handling
Use VERSION in top directory to specify version

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-19 23:16:03 -05:00
Sebastian Bøe ce2bfcdb96 cmake: Remove the PREBUILT_HOST_TOOLS variable
The PREBUILT_HOST_TOOLS variable was used during the CMake migration
but is no longer documented or needed. As the docs demonstrate, adding
tools to path is an easy way to find prebuilt host tools.

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-17 17:55:26 -05:00
Sebastian Bøe 9f59045546 cmake: Refactored EXTRA_FLAGS code into a dedicated script
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-15 19:47:44 -05:00
Kumar Gala 999b658f76 cmake: flash: Remove fake path to zephyr_flash_debug.py
We append a path to the FLASH_SCRIPT/DEBUG_SCRIPT that was bogus and not
really needed by zephyr_flash_debug.py.  So lets remove it since its
just confusing.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-11-14 12:07:44 -06:00
Luiz Augusto von Dentz 3eaeeb82ab net: Only enable QEMU_NET_STACK with CONFIG_NET_SLIP_TAP
If CONFIG_NET_SLIP_TAP is not selected QEMU_NET_STACK will not work
which happen when CONFIG_NET_L2_BT is selected.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-11-14 09:52:13 -08:00
Sebastian Bøe 8d0a80c6a9 cmake: Fix SDK-less builds
This change changes the semantics of the environment variable
ZEPHYR_SDK_INSTALL_DIR to allow the use of 3rd party toolchains
alongside the Zephyr SDK's host tools.

Specifically, setting ZEPHYR_SDK_INSTALL_DIR now indicates that the
Zephyr SDK host tools are to be used. But not necessarily that the
Zephyr SDK's toolchain is to be used.

The documentation is also changed to explain this behaviour.

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-13 13:14:32 -05:00
Anas Nashif 539d2af654 flash: support flashing multiple configurations of a single board
Some boards define multiple configuration which all are maintained under
the same board directory. The flasher was looking for an openocd.cfg
based on the board name, which can't be found for such boards.

Use the variable BOARD_DIR provided by cmake instead of trying to
assemble the board directory location on our own.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-13 10:55:26 -05:00
Sebastian Bøe 709cff1b60 cmake: Fail when zephyr_sources() is called on a directory
https://github.com/zephyrproject-rtos/zephyr/issues/4864 revealed that
calling zephyr_sources() on a directory will silently omit the
directory. This is a clear user error and should be immediately
flagged as such.

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-10 11:57:28 -05:00
Sebastian Bøe f0346bfac0 flash: Change type of FLASH_SCRIPT_ENV_VARS
The old way of constructing FLASH_SCRIPT_ENV_VARS was corrupting the
values that were passed to the flasher. This new method is the
standard way of creating a dictionary/hashmap in CMake and does not
suffer from the same problem.

This fixes
https://github.com/zephyrproject-rtos/zephyr/issues/4844#event-1334599401

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-10 07:54:54 -05:00
Sebastian Bøe 8dd3bb8666 flash: Pass env var OPENOCD_DEFAULT_PATH to flasher
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-10 07:54:54 -05:00
Jukka Rissanen ede10b96e4 cmake: Set proper QEMU options for networking applications
If compiling networking application for QEMU, then serial ports
must be set properly for QEMU<->host connectivity using SLIP.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-11-10 14:52:53 +02:00
Anas Nashif 446503dc50 cmake: Support disjoint toolchain and SDK locations
Make more toolchains use the tools provided by the Zephyr SDK.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-09 23:22:11 -05:00
Leandro Pereira 114f6032fe cmake: Support disjoint toolchain and SDK locations
Some toolchains, such as the one provided by Espressif for the ESP32,
or ISSM provided by Intel, will contain only the compiler, linker, and
supporting tools.  Other binaries needed by the build system that are
provided by the Zephyr SDK need to be found somewhere else.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-11-09 19:52:25 -05:00
Sebastian Bøe eb8e7b7969 cmake: Fixed openocd
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Sebastian Bøe c7832bd343 cmake: Use -serial bt-server when CONFIG_BT
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Sebastian Bøe 4449bef955 cmake: Pass GDB env var to flasher script
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Anas Nashif adb988a577 cmake: fixed version handling
Use VERSION in top directory to specify version

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-08 20:00:22 -05:00
Sebastian Bøe 12f8f76165 Introduce cmake-based rewrite of KBuild
Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.

Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.

This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.

For users that just want to continue their work with minimal
disruption the following should suffice:

Install CMake 3.8.2+

Port any out-of-tree Makefiles to CMake.

Learn the absolute minimum about the new command line interface:

$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..

$ cd build
$ make

PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00