Commit graph

1497 commits

Author SHA1 Message Date
Naveen Saini 0b1dd29799 gcc/target.cmake: fix build with gcc-13
Configuration error:
| -- Configuring done (4.9s)
| CMake Error in CMakeLists.txt:
|   Target "zephyr_interface" contains relative path in its
|   INTERFACE_INCLUDE_DIRECTORIES:
|
|     "include-fixed"

With GCC-13, limits.h and syslimits.h header files
are always being installed to include folder.
https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=be9dd80f933480

Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
2023-06-13 08:28:57 -04:00
Madhurima Paruchuri a19d905cc4 USB-C: genVIF: Cleanup and add support to pick static data from input
Removed few VIF properties which are being hardcoded
Updated the script to parse source VIF XML and add information to
the output
Added optional Kconfig option to configure custom source VIF XML path
Cleaned up the code

Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com>
2023-05-26 13:54:43 -04:00
Yuval Peress ed380de152 sensors: Add new async one-shot reading API
Add a new async API based on the RTIO subsystem. This new API allows:
1. Users to create sampling configs (telling the sensor which channels
   they want to sample together).
2. Sample data in an asynchronous manner which provides greater control
   over the data processing priority.
3. Fully backwards compatible API with no driver changes needed for
   functionality (they are needed to improve performance).
4. Helper functions for processing loop.

Signed-off-by: Yuval Peress <peress@google.com>
2023-05-26 11:04:54 -05:00
Michał Szprejda bdf02ff5d6 Twister: Add integration with renode-test
Add support for calling the `renode-test` command from west and twister.
Enable running Robot Framework tests suites in Renode.

Signed-off-by: Michał Szprejda <mszprejda@antmicro.com>
Signed-off-by: Mateusz Hołenko <mholenko@antmicro.com>
2023-05-26 09:43:49 -04:00
Jamie McCrae 7e47ac881b cmake: mcuboot: Add warning if missing Kconfig signing options
Adds a warning if neither Kconfig is enabled to generate an
unsigned image or a signing key are set, this is not an error but
warns the user in case they have forgot to set these modes or if
they have been set manually and have been cleared by a cmake
rebuild occurring (e.g. when bisecting).

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-26 09:07:49 -04:00
Torsten Rasmussen ba48dd8763 cmake: support snippets scope for zephyr_get()
Fixes: #57139

Snippets provides the possibility of defining EXTRA_DTC_OVERLAY_FILE and
EXTRA_CONF_FILE in snippets.
Snippets must co-exist with existing infrastructure of
EXTRA_DTC_OVERLAY_FILE and EXTRA_CONF_FILE, and a user specifying a
snippet must be able to specify extra files for adjusting the snippet.

This means that if the following is specified:
`-DSNIPPET=some_snippet -DEXTRA_CONF_FILE=extra.conf`
then `extra.conf` may contain adjustments to the snippet.
Similar to sysbuild. Imagine a sysbuild controlled image uses a default
snippet for building, by ensuring that any extra
`-D<image>_EXTRA_CONF_FILE=extra.conf` arguments takes precedence over
the snippet we allow users to make adjustments if they need.

This commit introduces a snippets scope where snippet scoped variables
can be set with `zephyr_set()` and then `zephyr_get()` will take the
snippet scoped variables into consideration before returning.

Adjust calls to `zephyr_get(EXTRA_DTC_OVERLAY_FILE)` and
`zephyr_get(EXTRA_CONF_FILE)` to use `MERGE` to ensure all scopes are
considered.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-05-25 13:31:53 +00:00
Torsten Rasmussen a6d9105d51 cmake: create Zephyr scope functions for variables
zephyr_get() supports multiple scopes when returning variables.
Variables are returned based on the scope's priority.

To facilitate creation of more scopes in Zephyr for variable handling
additional functions are introduced.
- zephyr_create_scope(<scope>)
    creates a new scope
- zephyr_set(<var> <val>... SCOPE <scope>)
    set the value of a variable in the specified scope.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-05-25 13:31:53 +00:00
Torsten Rasmussen fd526cc4b2 cmake: add reverse option to zephyr_get(... MERGE)
Adding the possibility to have the list returned in reversed order when
using `zephyr_get(... MERGE).

`zephyr_get(... MERGE)` creates a list which populates the content based
on variable settings in the following scopes, in this order:
sysbuild, cache, environment, local.

This works well for lists where content first in list has highest
precedence, such as ROOTs settings.
However, for settings where the value last in the list will overwrite
values earlier in the list, we want the list to be reversed, examples
of such can be CONF_FILE, OVERLAY_CONFIG, DTC_OVERLAY_FILE, where the
content of the file last in the list will overrule the content from an
earlier file.
So to ensure that a DTC_OVERLAY_FILE defined as cache takes precedence
over an env or local scope variable the possibility of reversing the
list must be available.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-05-25 13:31:53 +00:00
Torsten Rasmussen 5c71e68607 kconfig: provide an option for enforcing Kconfig settings
This commit introduces an internal FORCE_CONF_FILE CMake setting which
allows higher order build systems to generate a configuration file
which will always take precedence.

This means that in case a user tries to change any setting to be
different than the defined value in the FORCE_CONF_FILE provide file(s),
then a warning will be printed and the setting will be reset to the
value given in the FORCE_CONF_FILE file.

Example of such warning:
   <path>/.config.sysbuild:1: warning: BOOTLOADER_MCUBOOT
   (defined at Kconfig.zephyr:766) set more than once.
   Old value "n", new value "y".

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-05-25 14:57:41 +02:00
Torsten Rasmussen a88502783b cmake: align Zephyr module variable to EXTRA_ZEPHYR_MODULES
Align Zephyr modules with other user facing variables where settings
can be defined or extended, meaning Zephyr modules now supports:
ZEPHYR_MODULES and EXTRA_ZEPHYR_MODULES.

Support for ZEPHYR_EXTRA_MODULES is kept foir backward compatibility.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-05-23 16:40:21 +02:00
Torsten Rasmussen ca76349d24 cmake: update package helper description to use EXTRA_CONF_FILE var
Update package_helper.cmake to use EXTRA_CONF_FILE instead of deprecated
OVERLAY_CONFIG variable.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-05-23 16:40:21 +02:00
Torsten Rasmussen 384fb1e478 cmake: introduce EXTRA_DTC_OVERLAY_FILE for devicetree
This commit introduces EXTRA_DTC_OVERLAY_FILE.

This allows users to specify additional devicetree overlays in addition
to a sample / board specific default devicetree overlay files.

It also allows snippets to provide extra devicetree overlays on addition
to sample / board specific overlays.

The name EXTRA_DTC_OVERLAY_FILE clearly indicates the purpose and
follows the naming scheme of EXTRA_ in front of variable name.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-05-23 16:40:21 +02:00
Torsten Rasmussen 3a345682ba cmake: introduce EXTRA_CONF_FILE and deprecate OVERLAY_CONFIG
This commit introduces EXTRA_CONF_FILE and deprecates OVERLAY_CONFIG.

It has often caused confusion that OVERLAY_CONFIG adds extra
configuration fragments to the value of CONF_FILE (default: prj.conf),
but the similar named variable DTC_OVERLAY_FILE replaces the default
dtc overlay file used by the build system.

To remove such confusion, this commit introduces the EXTRA_ prefix in
front of CONF_FILE to clearly indicate it's purpose.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-05-23 16:40:21 +02:00
Torsten Rasmussen 8460d91e32 cmake: extend zephyr_get() to support fetching of multiple variables
This commit extends zephyr_get() to support multiple variable names to
be fetched into a single variable.

Example:
  zephyr_get(FOO VAR FOO_A FOO_B FOO_C)

will lookup each FOO_A, FOO_B, FOO_C for supported scopes and return
the value in FOO of the first scope encountered having one of the
variables defined.

If MERGE is specified, then all scopes for all vars are looped and the
variable values are merged into FOO and returned.

This functionality will allow to deprecate user-facing settings while
ensuring that both the new and deprecated variables are considered
in zephyr_get() and also taking into consideration the scope with
highest precedence.

This allows Zephyr CMake to do:
  zephyr_get(FOO VAR FOO DEPRECATED_FOO)

  zephyr_get(BAR MERGE VAR BAR DEPRECATED_BAR)

This allows support of old and new setting for a given number of
releases.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-05-23 16:40:21 +02:00
Marc Herbert 4975c94845 west.cmake: make MIN_WEST_VERSION catch up with requirements-base.txt
Also add a comment in each file reminding to keep them the same.

Fixes 251f269e23 ("west: v0.14.0 is required now (and soon, v1.1")

Confusing error message before this commit:

```
-- Found west (found suitable version 0.13.1, minimum required is 0.7.1)
CMake Error at SOF/zephyr/cmake/modules/zephyr_module.cmake:77 (message):
  Traceback (most recent call last):

    File "SOF/zephyr/scripts/zephyr_module.py", line 733, in <module>
      main()
    File "SOF/zephyr/scripts/zephyr_module.py", line 678, in main
      west_projs = west_projects()
                   ^^^^^^^^^^^^^^^
    File "SOF/zephyr/scripts/zephyr_module.py", line 536, in west_projects
      from west.configuration import MalformedConfig

  ImportError: cannot import name 'MalformedConfig'
                      from 'west.configuration'
  (west/src/west/configuration.py)
```

Clearer error message after this commit:

```
CMake Error at SOF/zephyr/cmake/modules/west.cmake:68 (message):
  The detected west version, 0.13.1, is unsupported.

    The minimum supported version is 0.14.0.
    Please upgrade with:
        /usr/bin/python3.11 -m pip install --upgrade west
```

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-05-22 10:17:11 +02:00
Evgeniy Paltsev 15b46039b8 ARC: used 64bit MDB binary by default.
This significantly improve user experience as 32 bit mdb binary
require to install multiple libraries before it can be used on
modern linux distros.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-05-22 10:16:28 +02:00
Jamie McCrae 0972cb9d87 cmake: kconfig: Configure KCONFIG_ROOT variable
This configures the KCONFIG_ROOT variable to perform variable
substitution, this allows external applications/modules to supply
variables for this when will then be correctly used.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-17 16:14:49 +02:00
Torsten Rasmussen 49389b546a west: sign: Add Kconfig with application version
Adds a Kconfig option which controls the version of the application
to use when the image is signed using imgtool.

When an application VERSION file is present, the default value will be
identical to the application version, else it will be 0.0.0+0, but a
project may still decide another value, if it so prefers.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-05-17 13:56:58 +02:00
Torsten Rasmussen 2c757f9e7a cmake: generalize VERSION infrastructure for better reuse
Generalize the VERSION and version.h generation so that the same
infrastructure can be reused for generating other version related
header files, such as an application version header.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-05-17 13:56:58 +02:00
Jamie McCrae a41f44b8db cmake: extensions: Fix missing quotes for zephyr_get function
Fixes a string comparison which is missing quotes, this works
on the first invocation but fails on the second if quotes are
not present.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-15 09:17:01 +02:00
Gerard Marull-Paretas d0e58ad0a6 device: use iterable sections
Use iterable sections to handle devices list. This simplifies devices
implementation by using standard APIs.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-12 12:01:10 +02:00
Gerard Marull-Paretas a7e8b3afcb cmake: extensions: add NUMERIC support to zephyr_iterable_section
Add a new flag to zephyr_iterable_section, NUMERIC, that configures
sorting to be numeric (up to 2 digits), that is, 2 comes before e.g. 10.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-12 12:01:10 +02:00
Evgeniy Paltsev 4e81b0e081 linker: restore CREATE_OBJ_LEVEL wildcard pattern
The 2c98a001a4 (#57597) cause
regression with ARC MWDT toolchain.

Restore CREATE_OBJ_LEVEL wildcard pattern to be suitable for
both GNU and MWDT toolchains. We return asterisk symbol which
was dropped in 2c98a001a4
(but keep rest of the changes to wildcard pattern).

Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2023-05-11 19:44:37 +02:00
Manoel Brunnen 3953de793f cmake: Fix USER_CACHE_DIR path generation
When the optional env_suffix_${env_var} was not set, USER_CACHE_DIR was
slightly malformed and had double slashes,
e.g. /home/user/.cache//zephyr.

To fix it string(JOIN ...) is used, which only sets slashes when
necessary.

Signed-off-by: Manoel Brunnen <mb@lee-brunnen.de>
2023-05-10 15:27:54 +02:00
Jamie McCrae 87f50bb72b cmake: extensions: Do not clear variable in zephyr_get MERGE mode
Fixes a regression whereby the variable would be cleared prior to
being used in MERGE mode.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-10 12:05:51 +02:00
Kumar Gala ca4dc50ec1 libc: Move strnlen into common
Move the strnlen implementation into common so its available to any
libc that may not implement strnlen.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-05-08 09:59:27 +02:00
Gerard Marull-Paretas 99ebe39289 compiler: add CONFIG_COMPILER_TRACK_MACRO_EXPANSION
Add a new compiler option to control tracking locations of tokens across
macro expansions. It may be useful to disable it when debugging long
macro expansion chains.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-05 12:08:48 +02:00
Grzegorz Swiderski af23628e43 sysbuild: Add SB_OVERLAY_CONFIG
This fixes a minor issue in sysbuild, where `-DOVERLAY_CONFIG=...` would
be applied not only to the main application, but also sysbuild itself.
This was incorrect, because sysbuild imports a different Kconfig tree
than normal Zephyr builds, so the same Kconfig fragment file would not
necessarily be valid for both.

This adds a new variable SB_OVERLAY_CONFIG to resolve this ambiguity.
It functions along the lines of SB_CONF_FILE, with both being sysbuild-
specific versions of existing variables.

To ensure that OVERLAY_CONFIG is still passed on to the main application
verbatim, its value is now loaded in `configuration_files.cmake`, rather
than `kconfig.cmake`. This is because the former file is not imported by
sysbuild, and it is where the related variables, such as CONF_FILE and
DTC_OVERLAY_FILE, are loaded as well.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2023-05-05 09:42:10 +02:00
Jamie McCrae cd9465ac94 sysbuild: Fix issue with *_ROOT values not propagating
Fixes an issue where variables like BOARD_ROOT would be provided
to sysbuild but would then be lost on target images.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-03 14:25:33 +02:00
Kumar Gala b07be57875 logging: Use TYPE_SECTION macros for log dynamic
Clean up log_dynamic to utilize macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-05-03 10:43:31 +02:00
Kumar Gala bae0a5b8b6 logging: Use TYPE_SECTION macros for log const
Clean up log_const to utilize macros for handling sections.

Update database_gen.py to match naming convention change.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-05-03 10:43:31 +02:00
Kumar Gala f5eada5553 cmake: linker: arm: put RAM sections in RAM region
Cleanup RAM layout so that the RAM_REGION is now in the RAM memory
region.  Put .bss in RAM_REGION.

This means we have a proper program header for the RAM region.

As part of this extend zephyr_linker_symbol to allow it to take
an OBJECT paramater to specify the region to associate a symbol to.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-05-03 17:07:47 +09:00
Nikolay Agishev 0d8292ab6b ARC: Add HS4x support
Minimal HSDK4xD support

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
2023-05-02 16:54:24 +02:00
Alberto Escolar Piedras 6758156c09 nrf52_bsim: Find simulator thru west as fallback
For developers ease, let's try to find the simulator
thru west if the environment variables that tell where
the simulator is are not set.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-04-28 13:57:21 +02:00
Kumar Gala f30235f56a cmake: armclang: Handle -mfpu=auto used by cortex-m55
arm-clang utilizes the gcc fpu flags, however -mfpu=auto is not a
supported option in arm-clang.  For arm-clang we can mimic the auto
behavior by just not setting the -mfpu option.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-27 14:16:52 +02:00
Keith Packard 28209a9069 cmake/toolchain: Add Kconfig setting for toolchains with newlib
Label espressif, gnuarmemd and xtools toolchains with newlib support using
the Kconfig variable rather than relying on the TOOLCHAIN_HAS_NEWLIB
value.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-27 20:18:11 +09:00
Keith Packard 02262d7367 lib/libc: Replace SUPPORT_MINIMAL_LIBC with MINIMAL_LIBC_SUPPORTED
Clean up libc-related symbols to use a common pattern.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-27 20:18:11 +09:00
Keith Packard 638842c598 cmake: Compute TOOLCHAIN_HAS_NEWLIB at cmake time
Switch from using a generator expression to computing the value with a
conditional so that it is available during the execution of kconfig instead
of only being available while generating the build script.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-27 20:18:11 +09:00
Kumar Gala 91919d3e2d armclang: Fix setting CMAKE_SYSTEM_PROCESSOR for mps2_an521
On mps2_an521 GCC_M_CPU gets set to cortex-m33+nodsp, however that is
not a valid setting for CMAKE_SYSTEM_PROCESSOR.  We need to strip the
extra options (+<OPTION>) from GCC_M_CPU so that we get just cortex-m33.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-26 12:55:34 +02:00
Kumar Gala 30653bfbed console: uart_mux: Use TYPE_SECTION macros for uart_mux
Clean up uart_mux to utilize TYPE_SECTION macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-21 12:55:38 +02:00
Kumar Gala caea9dc196 logging: Use TYPE_SECTION macros for log strings
Clean up log_strings to utilize macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-20 10:52:07 +02:00
Kumar Gala 301d0c4712 net: buf: cleanup net_buf_pool use of iterable section
Cleanup linker scripts for net_buf_pool section to use the linker
script related iterable section macros.

Also replace _net_buf_pool_list with macro's instead to complete
iterable section usage.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-20 10:50:04 +02:00
Marc Herbert acb7f71ae5 cmake: sparse: fix handling of (deprecated) -DSPARSE=garbage
Due to many layers of indirections (Github Actions, Docker scripts, SOF
build scripts, etc.), thesofproject/sof/pull/7452's first attempt to
turn off VLAs ended up setting `-DSPARSE=gar bage`:

  west build ...  -- '-DSPARSE=y -DCONFIG_LOG_USE_VLA=n'

Quoting issues are typical when trying to pass parameters through too
many layers of indirections. In this case, the mistake set the $SPARSE
variable to the 'y -DCONFIG_LOG_USE_VLA=n' garbage which printed this
confusing and time-consuming error message:

    Setting SPARSE=y -DCONFIG_LOG_USE_VLA=n is deprecated.

Worse: this enabled sparse (!) while silently ignoring the garbage
trailing after "y".

1. Enable sparse only when $SPARSE is equal to "y" and nothing
   else. This stops enabling sparse when `-DSPARSE=gar bage` which draws
   more attention to the warning and gives a little more incentive to
   leave the deprecated option behind. Don't make any difference between
   the "n" and "gar bage" values because $SPARSE is deprecated so not
   worth that much CMake code.

2. Add quotes in the deprecation message to make garbage values more
   obvious, now:

    Setting SPARSE='y -DCONFIG_LOG_USE_VLA=n' is deprecated.

Fixes: 60196ca112 ("cmake: sparse: deprecate old sparse support")

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-04-20 10:49:23 +02:00
Kumar Gala eec299c130 pm: Use TYPE_SECTION macros for pm_device_slots
Clean up pm_device_slots to utilize TYPE_SECTION macros for handling
sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-19 17:15:29 +02:00
Kumar Gala 47cf00058e fb: cfb: Use TYPE_SECTION macros for cfb_fonts
Clean up cfb_fonts to utilize TYPE_SECTION macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-19 17:14:54 +02:00
Kumar Gala 7469ad426a drivers: pcie: Use TYPE_SECTION macros for irq_alloc
Clean up irq_alloc to utilize TYPE_SECTION macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-19 17:14:46 +02:00
Kumar Gala 5b5fbc4c11 shell: remove dead linker section for shell
The initshell sections in the linker scripts where associated with theo
old shell code.  The old shell code has been removed for some time so
remove references to initshell in the linker scripts and size_calc.py

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-19 17:14:37 +02:00
Kumar Gala 46a2df35be shell: remove duplicate linker section for shell_root_cmds
We have an entry for shell_root_cmds using zephyr_iterable_section so
remove duplicate handling of shell_root_cmds.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-19 03:46:54 -04:00
Kumar Gala 6b5139c4bb shell: Convert to using iterable sections
Convert handling of shell_root_cmds, shell_subcmds, and
shell_dynamic_subcmds to use iterable section macros.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-18 12:48:16 +02:00
Keith Packard 87a30609da cmake: Add zephyr_libc_link_libraries function
This function allows subsystems to define libraries which get added to the
link command after all other libraries and modules. It's useful when using
a toolchain library, like libc or libgcc, as those can get added when
processing the 'lib' directory, before any module libraries and hence might
not get used to resolve symbols from modules.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-17 11:13:17 +02:00
Martí Bolívar dc4eac4198 cmake: follow-up zephyr_dt_preprocess() fixes
Follow-up fixes to 64c7f50229
("cmake: extensions: fix zephyr_dt_preprocess() CPP handling") that
weren't urgent enough for the hotfix, or didn't get noticed:

- error out on missing CPP argument again (this regression was
  introduced in 64c7f50229)
- use a UNIX manpage style argument arity format (formatting issues
  were present when the function was introduced)
- fix incorrect signature comment: the CPP arguments are the
  preprocessor and its arguments, not CMAKE_DTS_PREPROCESSOR
  (this was present when the function was introduced)

Fixes: 64c7f50229
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-04-14 11:19:47 -07:00
Keith Packard 70fdd9e4e1 compilers: Remove -Wno-main and -Wno-main-return-type compiler flags
These flags were added to avoid warnings when main was declared to return
void. Now that main returns int, those warnings will flag errors.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-14 07:49:41 +09:00
Martí Bolívar 64c7f50229 cmake: extensions: fix zephyr_dt_preprocess() CPP handling
This option argument needs to be able to accept a list of arguments.
One use case is the way CMAKE_DTS_PREPROCESSOR is set in
cmake/compiler/armclang/generic.cmake.

Reported-by: Kumar Gala <kumar.gala@intel.com>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-04-13 13:05:37 +09:00
Daniel Leung 2a76637963 cmake: toolchain: cache property GNULD_LINKER_IS_BFD
Cache the property GNULD_LINKER_IS_BFD between cmake invocations.
It is observed that, in repeated builds (2nd time and later),
this property becomes true even for non-bfd compatible linker.
So cache it to avoid any surprises.

Fixes #56501

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-04-12 10:25:41 -04:00
Martí Bolívar d395719adc cmake: modules: dts: extract preprocessing helper extension
Tighten up the interface boundaries by adding an extension function
that separates *how* we preprocess the DTS from *what* DTS files we
are preprocessing. This involves a functional change to the pre_dt
module.

This is useful cleanup but is also groundwork for relying on this
helper function when adding system devicetree support.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-04-12 13:04:31 +02:00
Martí Bolívar c3004a10f9 cmake: modules: dts: extract overlay helper function
This list processing procedure will be useful elsewhere, so prep for
not repeating ourselves. Put it in a new zephyr_list() function whose
signature has room to grow if we keep adding list processing
extensions.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-04-12 13:04:31 +02:00
Martí Bolívar f680c9db8d cmake: modules: dts: document outcome
When the build system was being split up into modules under
cmake/modules, most of the resulting cmake modules had their inputs
and outputs documented in top-of-file comments. The dts module is an
exception, which makes it harder to use since its contracts aren't
defined. Fix this by adding a contract.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-04-12 13:04:31 +02:00
Martí Bolívar a619f9e36e cmake: modules: add pre_dt
Create a separate module that sets up all our devicetree handling, by
setting up common variables that would apply to any and all DT
processing. This is then included in the regular dts module that we
include in zephyr_default.cmake.

The separation of this code from dts.cmake is groundwork for enabling
system devicetree in Zephyr, which will need the same definitions
included into its scope.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-04-12 13:04:31 +02:00
Martí Bolívar 53ab5fcf1c cmake: modules: add generated_file_directories
Due to Hyrum's Law, there are users out in the wild depending on this
directory existing to place their own generated files, so it'd break
things unnecessarily to not do this if we don't have a DTS, as
explained in a source code comment.

However, this doesn't really have anything to do with DTS processing,
so split it into its own module to separate concerns. This isn't
really a CMake module in the usual sense of something that defines
functions you can use, and is therefore a form of technical debt. The
decision was made to accept this because fixing this is a larger task
for the files in cmake/modules/, since there are multiple other
examples of this in here.

This also paves the way for inserting another module in between the
generated_file_directories and dts modules that itself depends on
these directories existing.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-04-12 13:04:31 +02:00
Martí Bolívar 977a915c25 cmake: extensions: fix comment
The name of each commented section should match the name in the "table
of contents", for consistency and so people can jump from contents to
implementations more easily with their editors' search functions.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-04-12 13:04:31 +02:00
Huifeng Zhang 9012223839 cmake: armfvp: enable SMSC_91C111 when it needed
Enable the SMSC_91C111 component for Arm FVP when
the 'CONFIG_ETH_SMSC91X' option is selected.

Signed-off-by: Huifeng Zhang <Huifeng.Zhang@arm.com>
2023-04-11 11:27:05 +02:00
Kumar Gala 5c4d184016 emul: Use STRUCT_SECTION macros for emul devices
Clean up emulator code to utilize macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-08 12:33:54 +02:00
Tomasz Bursztyka 7a8a5f4a30 cmake: Add Qemu NVMe emulated device
As it is meant to be used on the tests/drivers/disk test case, it will
currently create a dummy 1Mb image on a fixed path to serve as a NVMe
disk.

It could be made of an alternate path and size, if necessary.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2023-04-07 13:28:47 +02:00
Gerard Marull-Paretas c2a51fd336 cmake: dts: remove generation of legacy device_extern.h
device_extern.h was still generated with an #error directive, not really
useful was it was never designed to be included directly, but via
device.h.

Fixes #56425

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-05 19:32:43 +02:00
Torsten Rasmussen d6dfacc9c6 cmake: add CMake configure dependency for VERSION file
Fixes: #56235

Changes to the Zephyr VERSION file is not picked up by CMake and thus
not picked up by Kconfig which may rely on the KERNELVERSION setting.

Fix this by setting CMAKE_CONFIGURE_DEPENDS on the Zephyr VERSION file.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-04-04 17:27:38 +02:00
Kumar Gala 9a77f3d4a0 linker: Fix handling of log_backend iterable section
The log_backed section is now using the iterable section macros so
we should be using zephyr_iterable_section() in common-rom.cmake
so the generation of the linker script is correct for arm clang
compiles.

Fixes #56440

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-04 13:49:27 +02:00
Kumar Gala ddddfd5e88 linker: Add missing rom iterable sections
Add missing users of ITERABLE_SECTION_ROM* macros that should exist
in common-rom.cmake so that linker script generation for arm clang
works for those users.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-04 13:49:27 +02:00
Kumar Gala aefe5ea1cd linker: Add missing ram iterable sections
Add missing users of ITERABLE_SECTION_RAM* macros that should exist
in common-ram.cmake so that linker script generation for arm clang
works for those users.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-04 13:49:27 +02:00
Abe Levkoy c9190960a2 cmake: emu: qemu: Create pipe file before using
For run_qemu and qemu_debugserver, the targets that use QEMU_PIPE,
ensure that the QEMU_PIPE file exists before passing the path to QEMU as
an argument.

Signed-off-by: Abe Levkoy <alevkoy@google.com>
2023-04-04 13:35:03 +02:00
Fabio Baltieri 3f8f7130e7 kconfig,toolchain: add an option for compiler save-temps
Add a Kconfig option to set the compiler save-temps flag and set the GCC
implementation. This is very useful for troubleshooting macro expansion
issues, having an option allows a user to set it like any other config
option.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-04-02 22:07:22 -04:00
Evgeniy Paltsev 1f57517e2c ARC: ARCMWDT: check METAWARE_ROOT if ARCMWDT_TOOLCHAIN_PATH missing
ARC MWDT toolchain installation provides METAWARE_ROOT environment
variable. Let's check METAWARE_ROOT environment variable if
zephyr-specific option ARCMWDT_TOOLCHAIN_PATH missing.

That improves user experience.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-03-30 13:49:40 +02:00
Daniel Leung c9d70bb986 linker: ld: include crt{begin,end}.o if LIBGCC_DIR is defined
Only include crtbegin.o and crtend.o when LIBGCC_DIR is defined.
Since LIBGCC_DIR is not defined when compiling for posix
architecture, crt{begin,end}.o cannot be referred to via
LIBGCC_DIR.

Also note that, when using llvm/clang, crt{begin,end}S.o are
automatically for native_posix which collide with symbols in
crt{begin,end}.o. So there is no point in making LIBGCC_DIR
available for native_posix under llvm/clang.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Daniel Leung 5d9079ba6d linker: ld: lld: do not do RELRO when using llvm/clang
GNU ld and LLVM lld both complain under C++:
  error: section: init_array is not contiguous with other relro sections

So do not create RELRO program header.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Daniel Leung 81c3b3152c cmake: linker: make passing -no-pie configurable
This adds a new linker property specifically for passing
"-no-pie" to linker. Older binutils' LD (<= 2.36) do not
support this flag and will behave erratically if set. It
would parse "-no-pie" separately as "-n" and "-o-pie",
which would result in the output file being "-pie"
instead of "zephyr*.elf". Moreover, LLVM lld does not
support -no-pie but --no-pie (note the extra hyphen).
By having no-pie as a linker property, we can pass
correct no-pie flag to these linkers (or none at all).

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Daniel Leung 04fd862f68 linker: ld: GNULD_LINKER_IS_BFD to indicate if ld.bfd is used
This adds a new output variable to FindGnuLd.cmake to indicate
if ld.bfd is found. Since we now ask the compilers for their
preferred ld.bfd linker, it may not match using the existing
string equal test to ${CROSS_COMPILE}ld.bfd. So set the new
variable GNULD_LINKER_IS_BFD to true if ld.bfd, and use it to
pass an extra argument to compiler to make it use ld.bfd.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Daniel Leung fb350bca10 toolchain: llvm: defer setting target triple to target.cmake
Since kconfigs are not available when generic.cmake is parsed.
Setting the target triple for x86 needs to be deferred to
target.cmake as it needs to know whether CONFIG_64BIT is
enabled. This also moves the ARM triple to target.cmake as
triple is needed for target tools.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Daniel Leung aa8f812118 linker: lld: see if clang has a preferred linker
This asks the clang if it has its own preference for ld.lld.
This is to mirror what we are doing to find GNU ld, and to
make sure we are using the linker clang is using.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Daniel Leung 0e00c3da5c linker: ld: see if compiler has a preferred linker
This asks the compiler if it has its own preference for ld.bfd.
This is useful for LLVM (when CONFIG_LLVM_USE_LD=y) so we know
which linker clang is using.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Daniel Leung a5cc22b2a9 toolchain: defer setting variable LINKER till target tools
The variable LINKER is dependent on CONFIG_LLVM_USE_LLD
or CONFIG_LLVM_USE_LD, and these kconfigs are not
available when toolchain/llvm/generic.cmake is parsed.
So setting LINKER needs to be deferred to target.cmake
where kconfigs are available.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Daniel Leung 41f015b39b linker: use find_package() to find LLVM lld
This introduces a new cmake module FindLlvmLld.cmake to do
the work to discover LLVM lld linker.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Daniel Leung 29a67d1f2e linker: use find_package() to find GNU ld
This introduces a new cmake module FindGnuLd.cmake to do
the work to discover GNU ld (of binutils).

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Daniel Leung 4d914f4f89 toolchain: move CONFIG_LLVM_USE_LD into cmake/toolchain/llvm
This moves CONFIG_LLVM_USE_LD into cmake/toolchain/llvm as this
is a toolchain kconfig. Also make it a choice to allow the use
of LLVM's lld as linker.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Daniel Leung 7864caba1b linker: llvm: provide a default config file for clang
Some distros may provide config files for clang to change its
default behavior. We need to override that, or else developers
may be using different defaults and we will have confusing
bug reports in the future.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-29 19:48:47 -04:00
Pete Dietl fd94ca7e78 cmake: modules: Make modules.cmake check more precise
When checking that modules contain a file `modules/modules.cmake`,
the CMake file only actually checked for the existence of the module
root, not the `modules/modules.cmake` file inside of it.

Signed-off-by: Pete Dietl <pete.dietl@worldcoin.org>
2023-03-27 22:15:59 +00:00
Kumar Gala 672aeace88 libc: share time() between minimal libc and armclang libc
Introduce a place to share implementations of libc functions that
are needed by different libc versions.  Place time() in this common
location so it can be shared when building for either minimal libc or
armclang libc.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-03-27 09:49:40 +02:00
Marti Bolivar 06c9bf47b3 snippets: initial snippet.yml support
Add a new script, snippets.py, which is responsible for searching
SNIPPET_ROOT for snippet definitions, validating them, and informing
the build system about what needs doing as a result.

Use this script in snippets.cmake to:

- validate any discovered snippet.yml files
- error out on undefined snippets
- add a 'snippets' build system target that prints all snippet
  names (analogous to 'boards' and 'shields' targets)
- handle any specific build system settings properly,
  by include()-ing a file it generates

With this patch, you can define or extend a snippet in a snippet.yml
file anywhere underneath a directory in SNIPPET_ROOT. The snippet.yml
file format has a schema whose initial definition is in a new file,
snippet-schema.yml.

This initial snippet.yml file format supports adding .overlay and
.conf files, like this:

  name: foo
  append:
    DTC_OVERLAY_FILE: foo.overlay
    OVERLAY_CONFIG: foo.conf
  boards:
    myboard:
      append:
        DTC_OVERLAY_FILE: myboard.overlay
        OVERLAY_CONFIG: myboard.conf
    /my-regular-expression-over-board-names/:
      append:
        DTC_OVERLAY_FILE: myregexp.overlay
        OVERLAY_CONFIG: myregexp.conf

(Note that since the snippet feature is intended to be extensible, the
same snippet name may appear in multiple files throughout any
directory in SNIPPET_ROOT, with each addition augmenting prior ones.)

This initial syntax aligns with the following snippet design goals:

- extensible: you can add board-specific support for an existing
  snippet in another module

- able to combine multiple types of configuration: we can now apply a
  .overlay and .conf at the same time

- specializable: this allows you to define settings that only apply
  to a selectable set of boards (including with regular expression
  support for matching against multiple similar boards that follow
  a naming convention)

- DRY: you can use regular expressions to apply the same snippet
  settings to multiple boards like this: /(board1|board2|...)/

This patch is not trying to design and implement everything up front.
Additional features can and will be added to the snippet.yml format
over time; using YAML as a format allows us to make
backwards-compatible extensions as needed.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-03-26 16:12:41 +02:00
Marti Bolivar 80ca540522 snippets: basic build system boilerplate
Basic things needed to integrate the new 'snippets' feature into the
build system. The main CMake variable which controls snippets is
SNIPPET. It is a whitespace-or-semicolon-separated list of snippet
names.

- Add minimal new cmake module for processing snippets. This just has
  basic infrastructure for processing a SNIPPET variable into
  SNIPPET_AS_LIST, and warning the user if they try to change it too
  late.

- Integrate the new module into the build system, via
  zephyr_default.cmake

This is anologous to the shields and boards modules' boilerplate and
input variables.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-03-26 16:12:41 +02:00
Dominik Ermel 1cc7e41438 cmake: mcuboot: Add Kconfig for passing west sign arguments
The commit adds CONFIG_MCUBOOT_CMAKE_WEST_SIGN_PARAMS Kconfig
option to allow passing arguments to west sign.
The option is used to pass arguments that immediately follow
west sign in cmake invocations and replaces hardcoded
"--quiet" parameter, but defaults to the "--quiet" value to
keep current behaviour.
New Kconfig option allows to pass arguments to west sign
without modifying cmake/mcuboot.cmake.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-03-24 09:04:49 +01:00
Kumar Gala 32a48f2f55 armclang: Fix building cortex-m4 w/o floating point
When we build for a SoC that has a cortex-m4 w/o a FPU that
utilizes CMSIS headers with armclang (like mec1501modular_assy6885)
we get the following warning:

modules/hal/cmsis/CMSIS/Core/Include/core_cm4.h:93:8: warning:
   "Compiler generates FPU instructions for a device without
    an FPU (check __FPU_PRESENT)" [-W#warnings]
   #warning "Compiler generates FPU instructions for a device
   without an FPU (check __FPU_PRESENT)"

Fix the by setting -mfloat-abi=soft for such cases that don't have FPU
enabled.

Fixes #56068

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-03-22 09:58:52 +01:00
Jamie McCrae 20ab0578d2 cmake: Change prj_<board>.conf deprecation location
Moves the deprecation notice for prj_<board>.conf files to the
proper location where other deprecation notices are located.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-22 08:58:14 +00:00
Kumar Gala 61f9d4ba40 linker: Fix handling of _static_thread_data section
_static_thread_data should be in ROM as its static data.  So move
it from common-ram.cmake to common-rom.cmake and fix it the params
we call zephyr_iterable_section with.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-03-20 13:38:23 +01:00
Jamie McCrae fbdd4ee379 cmake: Add warning when using prj_<board>.conf file
Adds a warning that this method of configuration is deprecated.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-20 10:18:32 +01:00
Jamie McCrae f9d0e38376 cmake: Throw error if no prj.conf file is in the app config dir
This now throws an error if there is no prj.conf file located in a
user-specified APPLICATION_CONFIG_DIR, which otherwise would have
used an empty configuration and not included board-specific files.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-17 11:49:27 +01:00
Kumar Gala f18ae82f96 oneapi: disable use of libirc when building C++
When building with C++ the icx compiler will try to utilize optimized
versions of memset/memcpy that are provided as part of libirc.  However
libirc also has dependencies on things likes getenv/setenv, etc that
are expect in a linux host environment.  So disable use of libirc
via compiler flag -no-intel-lib=libirc.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-03-16 09:16:03 +01:00
Torsten Rasmussen 3d76ee8f25 cmake: provide CMake helper macros for argument validation
This commit provides a number of helper macros for verifying arguments
passing to function:
- zephyr_check_flags_required
- zephyr_check_arguments_required
- zephyr_check_arguments_required_all
- zephyr_check_flags_exclusive
- zephyr_check_arguments_exclusive

which facilitates checking whether a required argument or flag has been
given or if mutual exclusive arguments are given.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-03-11 19:53:40 +01:00
Jamie McCrae df9027a64a sysbuild: support Zephyr modules
This commit extends the Zephyr module yaml scheme with additional
entries for sysbuild in the build section.

This allows for Zephyr modules to extend the sysbuild infrastructure
by providing additional CMake and Kconfig files to be included in
sysbuild.

The new settings are:
build:
  sysbuild-cmake: <path>
  sysbuild-kconfig: <path>/<file>
  sysbuild-ext: <true>|<false>
  sysbuild-kconfig-ext:  <true>|<false>

those settings follow the same pattern as the equivalent Zephyr build
settings but are processed by sysbuild.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-03-09 09:25:00 +01:00
Jamie McCrae 8cc716792a cmake: zephyr_module: Rename internal variables to lower case
Rename internals variables to lower case to distinguish those
variables from variables intended to be globally available.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-09 09:25:00 +01:00
Martí Bolívar 0a1a5f8ab8 cmake: modules: west: allow custom MIN_WEST_VERSION
Different users of the Zephyr CMake package may have different minimum
required versions of west. One important in-tree example is the
documentation, which must either be built with the latest version of
west, or with no west installed at all.

Make the MIN_WEST_VERSION variable configurable to support use cases
like this.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-03-08 14:16:53 -08:00
Torsten Rasmussen 3a9b2a3e83 cmake: recommend CMake >=3.20.5 as minimum CMake version
CMake versions <3.20.5 contains the following bug:
https://gitlab.kitware.com/cmake/cmake/-/issues/22310

This bug was fixed in CMake 3.20.5:
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/6232

Generally Zephyr can build with CMake >=3.20.0, however the
`cmake/package_helper.cmake` is impacted by the above issue.

Therefore, specifically request CMake >=3.20.5 for package helper
and update documentation to recommend CMake version 3.20.5 in order
to minimize risk of users being impacted by this bug.

Users invoking package helper with CMake 3.20.0-3.20.4 will see:
> CMake Error at cmake/package_helper.cmake:45 (cmake_minimum_required):
>  CMake 3.20.5 or higher is required.  You are running version 3.20.x

Rest of Zephyr still builds with CMake versions >=3.20.0.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-03-07 18:15:58 +01:00
Torsten Rasmussen 599886a9d3 cmake: prefix local version of return variable
Fixes: #55490
Follow-up: #53124

Prefix local version of the return variable before calling
`zephyr_check_compiler_flag_hardcoded()`.

This ensures that there will never be any naming collision between named
return argument and the variable name used in later functions when
PARENT_SCOPE is used.

The issue #55490 provided description of situation where the double
de-referencing was not working correctly.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-03-07 12:10:18 +01:00
Marcin Niestroj b03d27cca3 toolchain: esp32: support esp32s3 in 'espressif' toolchain
CROSS_COMPILE_TARGET is defined based on CONFIG_SOC selected. So far
'esp32s3' SoC was not taken into account, so building Zephyr with
'espressif' toolchain (the only one supported for now) is was not possible
out of the box.

Add 'CROSS_COMPILE_TARGET_xtensa_esp32s3' CMake variable, same as it is
done for other SoC specific variables. That way toolchain paths are
automatically figured out and building succeeds.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2023-03-06 13:52:55 +01:00
Jamie McCrae 349a645e0f cmake: FindZephyr-sdk: Find newest SDK version
This improves the version checking for the zephyr SDK by searching
for newer versions that the version that was detected. This works
around the issue whereby the versions are contained in files with
MD5 hashes which might be in any order.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-06 13:51:36 +01:00
Torsten Rasmussen 45b25e5508 cmake: dereference ${check} after zephyr_check_compiler_flag() call
Follow-up: #53124

The PR#53124 fixed an issue where the variable `check` was not properly
dereferenced into the correct variable name for return value storage.
This was corrected in 04a27651ea.

However, some code was passing a return argument as:
`zephyr_check_compiler_flag(... ${check})`
but checking the result like:
`if(${check})`
thus relying on a faulty behavior of code updating `check` and not the
`${check}` variable.

Fix this by updating to use `${${check}}` as that will point to the
correct return value.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-03-06 13:51:09 +01:00
Andy Ross 728230a241 cmake/compiler: Limit warning flag usage to compatible toolchains
New C++ versions have deprecated "register" variables and restricted
"volatile" semantics, so new gcc's will emit warnings when they see
that syntax.  Zephyr uses both in our C headers (though we should
probably get rid of register and unify with C++'s volatile model), so
we're disabling the resulting warnings.

But OLD gcc variants (like xcc, sigh) don't understand new -Wvolatile
and -Wregister on the command line, so they get confused.  Limit the
uses to the standard versions for which gcc would emit warnigns; xcc
doesn't support those anyway.

Signed-off-by: Andy Ross <andyross@google.com>
2023-03-01 19:42:32 -05:00
Torsten Rasmussen 04a27651ea cmake: fix variable de-referencing in zephyr_check_compiler_x functions
Fixes: #53124

Fix de-referencing of check and exists function arguments by correctly
de-referencing the argument references using `${<var>}`.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-03-01 14:08:46 +01:00
Kumar Gala 27ed6cce01 armclang: Add version check for armclang toolchain
The toolchain support was developed and tested against arm clang
version 6.17.  So add a check to ensure we are utilizing 6.17 or
newer.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-02-28 13:54:56 +01:00
Martí Bolívar 13a8e35222 cmake: modules: dts: refactor for readability
Improve comments, rearrange variable definitions to better match the
control flow of the module, and avoid nesting by adding a return()
statement.

No functional changes expected.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-02-27 06:57:17 -08:00
Kumar Gala 2d12766e78 toolchain: oneApi: Fix support and update for 2023.0.0 release
The oneApi support has bit rotten since it was first introduced.  Update
the support to function with the latest 2023.0.0 release and add a
check to only support that version or newer for now.  Versions before
2021.2.0 have linker script failures.

Various fixes made:
* In the 2023.0.0 release, various binaries are in a llvm-bin path so
  add support to search in that path.  This replaces the python search
  path that much older versions needed.
* newlib isn't supported with oneApi so set TOOLCHAIN_HAS_NEWLIB to
  OFF to match that.
* 2023.0.0 doesn't back llvm-nm, so use binutils version.  This
  is expected to be fixed in 2023.1.0 release so add a check to
  handle either case.
* Update compiler flag check based on clang to also support
  CMAKE_C_COMPILER_ID of "IntelLLVM" as that is how the oneApi toolchain
  reports itself.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-02-23 14:30:03 -05:00
Daniel Leung 4683c8d4d5 linker: introduce profile xt-ld
Xtensa toolchain has its own linker, xt-ld, which is based on
binutils' ld. There are, of course, Xtensa specific options.
But mostly it is based on old version of ld. It would be
better to detach it from the ld profile to avoid any
incompatible changes there.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-02-22 08:35:46 -05:00
Daniel Leung 53316d5c8e toolchain: rename xcc-clang to xt-clang
This reflects the actual compiler executable name of the Xtensa
LLVM/Clang compiler.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-02-22 08:35:46 -05:00
Peter Johanson 26a04adb8b west: runners: uf2: Add new UF2 runner.
Add a new UF2 runner, supporting only the flash capability.

Searches for FAT partitions containing `INFO_UF2.TXT` files,
and can optionally filter on a matching `Board-ID` value in
that file.

Signed-off-by: Peter Johanson <peter@peterjohanson.com>
2023-02-20 12:50:38 +01:00
Keith Packard 0f692f5b84 compiler/clang: ignore main-return-type warning for clang
Unlike gcc, clang splits out the flag controlling warnings about the return
type of `main' from other warnings related to that function. Add the extra
-Wno-main-return-type flag to mask these warnings when building Zephyr
without -ffreestanding, as when using picolibc.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-02-20 09:50:59 +01:00
Alp Sayin a01877c6e0 cmake: emu: qemu: start QEMU gdbserver only if relevant Kconfig is set
This removes the enforced `-s` option and only passes in a `-gdb` only if
CONFIG_QEMU_GDBSERVER_LISTEN_DEV is set. When unset, it allows users to
utilize QEMU_EXTRA_FLAGS from environment preventing a clash that occurs
if `-s` and `-gdb` are both passed to QEMU invocation.

Signed-off-by: Alp Sayin <alpsayin@gmail.com>
2023-02-20 09:48:52 +01:00
Nikolay Agishev 0dec4cf927 toolchain: Move extra warning options to toolchain abstraction
Move extra warning option from generic twister script into
compiler-dependent config files.
ARCMWDT compiler doesn't support extra warning options ex.
"-Wl,--fatal-warnings". To avoid build fails flag
"disable_warnings_as_errors" should be passed to twister.
This allows all warning messages and make atomatic test useles.

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
2023-02-19 20:34:13 -05:00
Aastha Grover 5144e78070 xcc-clang: add default C includes when build C++ code
nostdinc_include flag needs to contain path to llvm libraries
and remove other relative paths. Change compiler flag to add
default C includes on building C++ code using xcc-clang compiler.

Fixes #54730

Signed-off-by: Aastha Grover <aastha.grover@intel.com>
2023-02-10 18:05:14 -06:00
Marc Herbert 774330f3fa cmake: provide a useful error msg when native compiler is missing
This avoids a cryptic DTC failure when compiling trying to compile
native_posix with a missing gcc or clang.

REQUIRED is available since CMake 3.18

Example with clang, cryptic error without this commit:

```
ZEPHYR_TOOLCHAIN_VARIANT=llvm west build            \
        -p -b native_posix samples/hello_world/
-- Found toolchain: host (clang/ld)    <= this is wrong
-- Found Dtc: /usr/bin/dtc (found suitable version "1.6.1", minimum ...
-- Found BOARD.dts: zephyr/boards/posix/native_posix/native_posix.dts
CMake Error at /zephyr/cmake/modules/dts.cmake:191 (message):
  command failed with return code: No such file or directory
Call Stack (most recent call first):
  zephyr/cmake/modules/zephyr_default.cmake:113 (include)
  zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
  zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boil...
  CMakeLists.txt:5 (find_package)
```

Well hidden behind the scenes, dts.cmake fails above because it invokes
`CMAKE_C_COMPILER-NOTFOUND`

With this commit:

```
ZEPHYR_TOOLCHAIN_VARIANT=llvm west build            \
        -p -b native_posix samples/hello_world/
-- Found toolchain: host (clang/ld)    <= this is still wrong
CMake Error at zephyr/cmake/compiler/clang/generic.cmake:7 (find_program):
  Could not find CMAKE_C_COMPILER using the following names: clang
```

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-02-09 22:10:16 +09:00
Keith Packard a20566789c compiler/clang: Erase 'no_printf_return_value' prop for clang
Clang does not have printf return value optimizations like GCC, so there's
no flag to turn them off when building against a non-standard printf
implementation (e.g., picolibc without float support).

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-02-06 10:05:57 +01:00
Torsten Rasmussen 60196ca112 cmake: sparse: deprecate old sparse support
Deprecate old sparse support as Zephyr now provides a proper
infrastructure for SCA tools. Set ZEPHYR_SCA_VARIANT to sparse if user
is using deprecated way.

This allows to cleanup sparse code in various places and thus have a
cleaner build system.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-01-27 20:28:58 +09:00
Torsten Rasmussen 91902c5fd4 cmake: add sparse support to the new SCA infrastructure
Sparse support was original introduced in #43776.

This commit introduces sparse support as part of Zephyr SCA tool
infrastructure.

The implementation in this commit has some benefits over existing
support:
- It does not required users to set `REAL_CC` in environment before
  invoking build command.
  This reduces risk of user mistakes, such as
  - REAL_CC being different from CMAKE_C_COMPILER.
  - User running CMake in one terminal / environment where REAL_CC is
    defined but invoking the build command in a different terminal /
    environment where REAL_CC is not defined or defined differently.
- It improve user experience as the user no longer has to define /
  re-define REAL_CC when building for different architecture, like
  switching from arm to xtensa, as this is now handled in CMake.
- CMAKE_C_COMPILER is not overwriting, this can be important for other
  tools which calls the C compiler for pre-processing purposes, such
  as devicetree and linker script generation.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-01-27 20:28:58 +09:00
Torsten Rasmussen cb690ec56e cmake: implement build infrastructure for supporting SCA tools.
Static code analyser (SCA) tools are important in software development.

CMake offers built-in support for some tools, such as cppcheck and
clang-tidy.

Other tools, such as sparse, are not directly supported.

This commit provides a uniform way for users to specify a supported
SCA using `ZEPHYR_SCA_VARIANT=<tool>` which is consistent with how
toolchains are specified.
ZEPHYR_SCA_VARIANT can be set using `-D` or in environment.

Support for an SCA tool is done in `cmake/sca/<tool>/sca.cmake`.
SCA_ROOT can be used to specify additional search paths when looking up
implementation for a tool. SCA_ROOT can also be specified in
`zephyr/module.yml` as setting. This makes it possible to provide SCA
tool implementation as part of a Zephyr module.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-01-27 20:28:58 +09:00
Flavio Ceolin ac5d45a080 build: userspace: No merge globals
Add a compiler option to not merge globals. gen_kobject_list.py
is not capable of distinguish addresses of merged objects. The script
itself does not look wrong. The dward specification says that the
attribute DW_AT_location with opcode DW_OP_addr encodes a machine
address and whose size is the size of an address on the target machine
but for merged objects the address is longer, not clear why.

Disable global merge when userspace is enabled to avoid this problem.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-01-26 14:56:10 -05:00
Jan Malek 477b9af568 renode: Implement Renode script overlays
Add support for Renode script overlays allowing
to tune simulation parameters for selected samples/tests.

Signed-off-by: Jan Malek <jmalek@internships.antmicro.com>
Signed-off-by: Mateusz Holenko <mholenko@antmicro.com>
2023-01-25 14:02:29 -08:00
Keith Packard 5acd82e8df cmake/gcc: Don't use -nostdinc with toolchain picolibc
When using picolibc from the toolchain, we need to use the standard include
paths to make sure the library headers are found, especially for libstdc++.

Add toolchain picolibc to the list of cases for which this is the case.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-01-20 09:03:25 +01:00
Daniel DeGrasse 10e85bf764 cmake: update API for zephyr_code_relocate to support relocating libraries
Update API for zephyr_code_relocate to support cmake generator expressions,
as well as relocating libraries.

zephyr_code_relocate can now accept a target name to the LIBRARY argument,
which will be converted into a set of source files from that
target to relocate.

Alternatively, files can be passed as a space separated list
or CMake generator expression. This allows users more
flexibility when relocating files. Glob matching functionality is still
available, although the preferred method to do this would now be:

file(GLOB relocate_sources "src/*.c")
zephyr_code_relocate(FILES ${relocate_sources} LOCATION <location>)

Note! This commit breaks support for zephyr_code_relocate until in tree
usages of the API are updated to the new format.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-01-17 18:08:37 +01:00
Flavio Ceolin 56ec06f344 kconfig: linker: Add --no-relax build option
In some architectures the linker performs global optimization relaxing
address modes and changing intructions in the output object file. This
is a problem when userspace is enabled since it assumes that addresses
won't change after certain build stage. In no supported architectures
this option is ignored.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-01-16 11:20:32 +00:00
Stephanos Ioannidis 404e7a9bf7 treewide: Use CONFIG_CPP_EXCEPTIONS instead of CONFIG_EXCEPTIONS
This commit updates all in-tree code to use `CONFIG_CPP_EXCEPTIONS`
instead of `CONFIG_EXCEPTIONS`, which is now deprecated.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2023-01-13 17:42:55 -05:00
Stephanos Ioannidis 4a64bfe351 treewide: Use CONFIG_CPP instead of CONFIG_CPLUSPLUS
This commit updates all in-tree code to use `CONFIG_CPP` instead of
`CONFIG_CPLUSPLUS`, which is now deprecated.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2023-01-13 17:42:55 -05:00
Torsten Rasmussen fe3efbc6a2 cmake: BOARD_REVISION_CONFIG setting for Kconfig revision fragments
Fixes: #53696

Create a BOARD_REVISION_CONFIG setting to be consistent with the
BOARD_DEFCONFIG setting.

This allows systems which re-uses the Kconfig module to overrule the
file to be used as BOARD_REVISION_CONFIG in same way as is done for
the BOARD_DEFCONFIG file.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-01-11 08:10:45 -08:00
Marti Bolivar 951664749b cmake: fix and clean up some module doc comments
The boards, shields, and zephyr_module CMake modules have some issues
in their comments that can be trivially fixed up.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-11 09:40:14 +01:00
Yasushi SHOJI 4f7e2bb658 cmake: Fix typo by replacing zephyr_library_add_sources
There is no function called zephyr_library_add_sources().  This must be
zephyr_library_sources().

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2023-01-09 19:20:56 +01:00
Ambroise Vincent 562069d4ed cmake: armfvp: allow for extra arguments
Taking example on the qemu cmake file.

Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
2022-12-29 10:12:33 +01:00
Jamie McCrae d7557102c0 mgmt: mcumgr: Add iterable section to register MCUmgr handlers
This replaces the requirement for applications to manually
register MCUmgr handlers by having an iterable section which
then automatically registers the handlers at boot time.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-22 11:03:04 +01:00
Marc Herbert 3ec1bb2776 cmake: log ${CMAKE_VERSION}
Different CMake versions can have very subtle differences, for
instance CMake 3.21 links object files in a different order compared
to CMake 3.20; this produces different binaries.

CMAKE_VERSION is required information to track binary differences
between two build systems.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-12-22 10:55:28 +01:00
Ming Shao 632972459a cmake: fix a typo in zephyr_linker_arg_val_list() macro
The CMake list delimiter is ";" rather than ":".

Signed-off-by: Ming Shao <smrtos@163.com>
2022-12-21 16:24:37 +01:00
Martí Bolívar ba059ff9b5 cmake: shields: documentation fixes
- Fix commit b2520b09a7 ("devicetree:
  drop support for dts_fixup.h files"), which removed support for
  shield-related fixups but forgot to update the module-level
  documentation comment.

- Fix commit 61453e4a58 ("cmake: Zephyr
  CMake package and CMake modules"), which contained some
  BOARD-related copy/paste errors and omitted documentation for
  the SHIELD_DIRS output variable (this is used in the dts
  cmake module, so it's part of the shield module's contract)

- Add some other clarifying remarks and comments

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-12-19 11:54:25 +01:00
Martí Bolívar 23b947532c cmake: modules: extensions: fix a section header
The table of contents at the top of the file has 'Devicetree
extensions' as the name of the section containing... those things.

The actual place in the file where they are defined has a different
title, though, defeating searching in the file for that section name.

Fix it.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-12-19 11:54:25 +01:00
Martí Bolívar 9812447449 cmake: extensions: clarify zephyr_file() behavior
"Populate" is ambiguous here: does that mean set, or append? The
answer is "append", so use that to be clearer. Be extra clear where
we're looking in as well.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-12-19 11:54:25 +01:00
Torsten Rasmussen 0b845cd28c cmake: update FindDeprecated for SOURCES
PR#51049 deprecated SOURCES but placed it below the
Deprecated_FIND_COMPONENTS check causing following message to be printed
when building for the unit_testing board:
-- The following deprecated component(s) could not be found: SOURCES

Fix this by placing the deprecated SOURCES handling at proper location
and append SOURCES to Deprecated_FIND_COMPONENTS list.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-12-05 11:03:02 +01:00
Madhurima Paruchuri fa738b0f74 usb-c: Generate USB-C connector VIF policies XML file
Generates XML file containing VIF policies by reading the device tree
using EDT.pickle generated during build
This script writes a subset of general and sink-pdo VIF policies in
output file
This script gets invoked during build if enabled through kconfig
The generated XML containing USB-C VIF policies could be used by
USB PD/Type-C analysers/testers to understand USB-C properties and
perform tests accordingly

Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com>
2022-12-02 08:46:04 -06:00
Evgeniy Paltsev ae79de1930 ARC: MWDT add TLS support
Add thread local storage support for ARC MWDT toolchain.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2022-11-29 09:48:23 +01:00
Evgeniy Paltsev 619c21ecfe ARC: MWDT: bump toolchain version
Bump minimal ARC MWDT version to 2022.09

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2022-11-29 09:48:16 +01:00
Evgeniy Paltsev 94b87c6422 ARC: arcmwdt: fix & rework inclusion of C/C++ headers
Currently we try to manually specify C/C++ headers locations
with -isystem flag which lead to issues with "include_next"
directive which is used in C/C++ headers. As advised by MWDT
R&D team let's rely on the default C/C++ include locations
which are provided by MWDT if we do build with MW C / C++
libraries. For that case we still need to manually specify
header directory to ASM builds which bay use 'stdbool.h'

In case of building with minimal libc (provided by Zephyr)
we rely on minimal libc headers and manually specify
toolchain's C header directory (as minimal libc still uses some
toolchain's C headers.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2022-11-29 09:48:08 +01:00
Yuval Peress 49ca6f8f7d unittest: add support for coverage
Some missing features for getting coverage data for unit tests:
- Setting the unit_testing board to have coverage support and native
  application.
- Fixing the CONFIG_COVERAGE check

Signed-off-by: Yuval Peress <peress@google.com>
2022-11-28 16:26:02 -05:00
Christian Taedcke 1fde62ef35 cmake: linker: lld: add missing -no-pie flag
See also
https://github.com/zephyrproject-rtos/zephyr/pull/38903

This is required when building tests for native_posix on ubuntu 22.04 using
clang-14 from the normal deb repository.

Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
2022-11-22 13:02:44 +09:00
Yuval Peress fae9923ff2 unittest: update coverage library non gcc toolchains
When building with clang, the unittests were giving us an error:
```
error: undefined symbol: llvm_gcda_start_file
```

This seems to be from linking in `gcov` regardless of the toolchain.
It appears that clang doesn't need any special library for coverage.
With this change the following now produce identical coverage reports:

```
$ ZEPHYR_TOOLCHAIN_VARIANT=zephyr ./scripts/twister -p unit_testing \
  --coverage -i -T tests/unit/intmath/
$ ZEPHYR_TOOLCHAIN_VARIANT=host ./scripts/twister -p unit_testing \
  --coverage -i -T tests/unit/intmath/
$ ZEPHYR_TOOLCHAIN_VARIANT=llvm ./scripts/twister -p unit_testing \
  --coverage -i --coverage-tool lcov                              \
  --gcov-tool $(pwd)/scripts/utils/llvm-gcov.sh                   \
  -T tests/unit/intmath/
```

Signed-off-by: Yuval Peress <peress@google.com>
2022-11-21 16:09:46 -05:00
Nikolay Agishev 9f33342602 compiler: arcmwdt: Remove unsupported compile flags (-fno-pic, -fno-pie)
Clang version used by ARCMWDT does not support -fno-pic and -fno-pie
flags.
Flags were added into arcmwdt branch by
commit 8259931fce ("xcc-clang: Do not used unavailable options").
Initially they were set in common CMakeLists.txt via
zephyr_cc_option() function, which filtered them out, and they
did not used in builing process.

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
2022-11-17 19:21:23 +09:00
Stephanos Ioannidis a9d85ae472 cmake: Deprecate 'xtools' toolchain variant
The `xtools` toolchain variant (aka. Crosstool-NG) was originally
introduced to be used with the Crosstool-NG-based Zephyr SDK
toolchains (i.e. sdk-ng).

This is no longer necessary because the current Zephyr SDK (sdk-ng)
already has its own `zephyr` toolchain variant, which fully replaces
the `xtools` toolchain variant, and the `xtools` toolchain variant
serves no purpose at all.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-11-17 15:42:48 +09:00
Tom Burdick e3d877f811 rtio: Userspace support
Add support for userspace with RTIO by making rtio and rtio_iodev
k_objects. As well as adding three syscalls for copying in submissions,
copying out completions, and starting tasks with submit.

For the small devices Zephyr typically runs on one of the most important
attributes tends to be low memory usage. To maintain the low footprint of
RTIO and its current executor implementations the rings are not shared with
userspace. Sharing the rings it turns out would require copying submissions
before working with them to avoid TOCTOU issues.

The API could still support shared rings in the future so that a
kernel thread could directly poll, copy, verify, and start the submitted
work. This would require a third executor implementation that maintains its
own copy of submissions similiar to how io_uring in Linux works.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-11-08 10:44:03 +01:00
Henrik Brix Andersen b3b64e9ede cmake: emu: qemu: do not enable CAN bus on NIOS2 and LEON3
QEMU for NIOS2 and LEON3 do not provide support for the "can-bus" object
type. Skip configuring CAN bus command line arguments for these.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-11-02 22:10:05 +09:00
Torsten Rasmussen e0fb04458f cmake: sysbuild: import image kconfig settings to image target
Load image kconfig setting into image target properties.
This allows sysbuild to evaluate and check image configuration as part
of CMake invocation.

sysbuild_get() is updated to support reading of CMake cache or Kconfig
settings for an image.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-11-02 15:42:23 +09:00
Torsten Rasmussen 430370c4e4 cmake: fix <keys> argument in import_kconfig()
The signature of import_kconfig() take two mandatory arguments and one
optional:
> import_kconfig(<prefix> <kconfig_fragment> [<keys>])

but has been implemented in such a way that it loops all arguments after
the two mandatory args and sets the same list on those.

Fix this error by only setting the created variables on the third and
optional argument if it exists.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-11-02 15:42:23 +09:00
Henrik Brix Andersen abf82013ac drivers: can: add support for configuring CAN emulation in QEMU
Add support for configuring CAN emulation support in QEMU. For now, the
only supported CAN controller is the single-channel Kvaser PCIcan PCI card.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2022-11-01 15:22:31 -04:00
Torsten Rasmussen 1ee86a883d cmake: lookup strip tool and set CMAKE_STRIP for host-gnu target
Fixes: #51821

Set CMAKE_STRIP using `find_program(CMAKE_STRIP strip)` to support
strip when building on native posix.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-11-01 11:59:19 +01:00
Yuval Peress ffb861d1a3 unittest: warn users of deprecated SOURCES
If users set SOURCES before find_package for unit tests, we'll warn them
that this code path will no longer be supported and provide the correct
way of doing things moving forward.

Signed-off-by: Yuval Peress <peress@google.com>
2022-10-31 17:01:59 +01:00
Yuval Peress 9cebf732ee unittest: Only add main.c if it exists
Downstream it's easier to write tests that use target_sources after
including the unittest package instead of specifying a list of sources
before. But if we do that, currently, main.c is added and the build
breaks because it doesn't exist.

Signed-off-by: Yuval Peress <peress@google.com>
2022-10-31 17:01:59 +01:00
Keith Packard 62bc9bf3e5 cmake: Allow selection of libc API overflow detection mode
This adds a choice of three different libc API buffer overflow detection
modes:

 * None
 * Compile-time
 * Compile-time and Run-time

These correspond with the clang/gcc _FORTIFY_SOURCE modes (0/1/2).
_FORTIFY_SOURCE depends on compiler optimizations and require libc support
which the minimal C library doesn't include, so _FORTIFY_SOURCE is disabled
by default in those cases. Native tooling might also enable
_FORTIFY_SOURCE, so don't enable it by default in that case either.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-10-31 23:23:27 +09:00
Maureen Helm eee3d8f566 drivers: sensor: Add sensor info iterable section
Adds an iterable section in ROM to hold constant information, such as
vendor and model name, for all enabled sensor driver instances. This
will be used by the future sensor subsystem to enumerate all available
sensors in the system.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-10-31 11:21:37 +01:00
Keith Packard b3073f0099 gcc/picolibc: Disable -fprintf-return-value when printf is not complete
GCC will compute expected sprintf (et al) return values internally and use
them in place of the actual return value. When the printf implementation
has reduced functionality, gcc may compute a different value.

For picolibc, this means disabling the optimization unless floating point
output is enabled.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-10-31 17:17:42 +09:00
Nikolay Agishev 75bb8ce382 compiler: arcmwdt: Fix ccac version checking
Regexp suggested in #50173 PR is too strictly and
needs to be corrected. Previous regexp declines
engineering MWDT versions
(pattern ENG-2022.12-D1039-C39098348").

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
2022-10-28 22:06:49 +09:00
Keith Packard 57bb7d86a8 cmake/target_arm: Use NO_SPLIT for TOOLCHAIN_LD_FLAGS
The whole set of architecture flags must be specified together as
they might not make sense in isolation, e.g. -mfloat-abi=hard requires
a -mcpu value that might have an FPU. Use the NO_SPLIT feature to
bind all of the linker options together so that the linker can
compute the correct linker paths for toolchain-provided libraries like
libc and libgcc.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-10-27 15:38:41 +02:00
Daniel DeGrasse a13e5d0a2d cmake: emu: ensure that QEMU_PIPE is set when using sysbuild
Ensure that QEMU_PIPE variable is set when using sysbuild. This is required
because twister will use the "main" sysbuild application as the target for
"ninja run" when testing QEMU targets, which means that the "main" build
must be aware of any QEMU_PIPE setting passed by twister at build time.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-10-26 08:48:37 -04:00
Keith Packard fc3f1480c5 arch/arc: Add -mcpu flag to TOOLCHAIN_LD_FLAGS
Make sure the linker knows what the target is, in case it needs to find
additional target-specific libraries (like picolibc).

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-10-25 10:51:46 +02:00
Kumar Gala 2f031efea8 cmake: sim: Update simulator related cmake to use CONFIG_MP_MAX_NUM_CPUS
Update cmake related files that are used by simulators to use
CONFIG_MP_MAX_NUM_CPUS instead of CONFIG_MP_NUM_CPUS as we work to
phase out CONFIG_MP_NUM_CPUS.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-19 16:01:10 +02:00
Stephanos Ioannidis 9f652ea04a cmake: gcc: Fix Cortex-R52 FPU type
The commit f10fa0dea8 mapped the
Cortex-R52 processor type to use the "VFPv3" FPU type, but the
toolchain requires the "FPv5" FPU type and refuses to assemble
floating-point instructions when the "VFPv3" FPU type is specified.

This commit updates the build script to specify the FPU type of
`fpv5-sp-d16` when the processor is configured with a single-precision
FPU, and `neon-fp-armv8` when the processor is configured with a
double-precision + Advanced SIMD-capable FPU.

Note that the `fp-armv8` FPU type is an alias for double-precision FPv5
with 32 double-precision registers (refer to the GCC
`gcc/config/arm/arm-cpus.in` for more details); NEON is always
specified in case of a double-precision configuration because the
Cortex-R52 can only be configured as such.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-10-19 00:28:33 +09:00
Torsten Rasmussen d79d80518b cmake: test_sysbuild() function
Introduce a `test_sysbuild()` function.

This function is intended to be used by samples that are dependent on
sysbuild. This function allows such samples to test if sysbuild was used
in the build process, and when sysbuild is not used, then print a
warning to the user, or even fail the build.

This is useful for samples that have two parts to function properly, for
example samples that needs to be build and flash on two or more cores.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-10-18 14:13:27 +02:00
Torsten Rasmussen 303c1eb60c sysbuild: support sample configuration of extra images
This commit introduces the possibility of a sample to locate
configuration files for extra images that are used when building with
MCUboot.

This allows use-cases where a sample, A, want to include MCUboot but has
adjustments to the default MCUboot configuration.

By adding a Kconfig fragment `<sample>/sysbuild/mcuboot.conf`, then that
fragment will be used together with the default configuration for
MCUboot.

It is also possible to completely replace the MCUboot configuration.
This is done by creating `<sample>/sysbuild/mcuboot/` folder.
This folder will then be used as the `APPLICATION_CONFIG_DIR` when
building MCUboot.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-10-18 14:13:27 +02:00
Gregory Shue cfcf630184 build: Overlay build vars expand ${ZEPHYR_<module>_MODULE_DIR}
Support referencing module directories by name in CONF_FILE,
OVERLAY_CONFIG, and DTC_OVERLAY_FILE so that projects can reference
overlay files in arbitrary modules.

Verified by passing all the following tests:
  ./scripts/twister -T tests/cmake/overlays/

Fixes #41830

Signed-off-by: Gregory Shue <gregory.shue@legrand.us>
2022-10-13 12:04:38 +02:00
Gerard Marull-Paretas e42f58ec94 init: s/ARCH/EARLY, call it just before arch kernel init
The `ARCH` init level was added to solve a specific problem, call init
code (SYS_INIT/devices) before `z_cstart` in the `intel_adsp` platform.
The documentation claims it runs before `z_cstart`, but this is only
true if the SoC/arch takes care of calling:

```c
z_sys_init_run_level(_SYS_INIT_LEVEL_ARCH);
```

Which is only true for `intel_adsp` nowadays. So in practice, we now
have a platform specific init level. This patch proposes to do things in
a slightly different way. First, level name is renamed to `EARLY`, to
emphasize it runs in the early stage of the boot process. Then, it is
handled by the Kernel (inside `z_cstart()` before calling
`arch_kernel_init()`). This means that any platform can now use this
level. For `intel_adsp`, there should be no changes, other than
`gcov_static_init()` will be called before (I assume this will allow to
obtain coverage for code called in EARLY?).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-12 17:16:27 +09:00
Anas Nashif e8395351e6 kernel: init: introduce a new init level: ARCH
We have cases where some devices needs to be initialized very early and
before c_start is call, i.e. to setup very early console or to setup
memory. Traditionally this would be hardcoded as part of the soc layer
and not using device model or the init levels.

This patch adds a new level ARCH, which will be called in early
architecture code and before we jump to the kernel code.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-10-11 08:28:25 -04:00
Stephanos Ioannidis 0a63ca6131 cmake: clang: Disable deprecated non-prototype warning
Clang 15 added a new warning type `-Wdeprecated-non-prototype` that
warns about the functions without prototypes, which have been
deprecated since the C89 and will not work in the upcoming C2x.

This commit disables the warning because Zephyr deliberately makes use
of the functions without prototypes to allow the use of a "generic"
function pointer (notoriously in the cbprintf implementation) and
Zephyr will not move to the C2x in the foreseeable future.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-10-03 17:56:26 +09:00
Peter Marheine 5eb75b81f7 arm: rename default RAM region from 'SRAM' to 'RAM'
It's useful for RAMABLE_REGION to have a uniform name when
CODE_DATA_RELOCATION is supported, because otherwise the build system
needs to be aware of how the region name differs between architectures.
Since architectures tend to prefer one of 'SRAM' or 'RAM' for that
region, prefer to use 'RAM' as the more general term.

Signed-off-by: Peter Marheine <pmarheine@chromium.org>
2022-10-03 10:09:53 +02:00
Stephanos Ioannidis ed13880f1d linker: Remove k_mem_pool section
This commit removes the `k_mem_pool` section for the memory pool API,
which was removed in the v2.5.0 release.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-09-28 14:24:34 +00:00
Torsten Rasmussen 4ced8de50c cmake: propagate endianess to CMake CMAKE_<lang>_BYTE_ORDER setting
Fixes: #45270

Zephyr Kconfig defines the settings BIG_ENDIAN.
Propagate this setting to the corresponding CMAKE_C_BYTE_ORDER and
CMAKE_CXX_BYTE_ORDER variables.

This also ensures that the CMake function 'is_big_endian()' reports the
correct endianess.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-26 15:09:38 +00:00
Torsten Rasmussen fd9e5429a3 cmake: detect sysroot for cross-compile toolchains
Fixes: #49587

Try to detect sysroot for cross-compile toolchain if not specified by
the user with `-DSYSROOT_DIR=<path>`.

First, the C compiler is asked if it knows its sysroot, some C compilers
are able to return the sysroot, as an example:
> $ arm-none-eabi-gcc -print-sysroot
> <path>/bin/../arm-none-eabi
> $

but majority of gcc-based C compilers seems to return empty string:
> $ arm-zephyr-eabi-gcc --print-sysroot
> $

in such cases, the cross-compiler target CMake file will try to discover
the sysroot by searching for libc.a, starting one level up from the
compiler location.

If no sysroot candidate is found, a warning will be printed to the user.
If a single sysroot candidate is found, this candidate will be selected.
If multiply sysroot candidates are found, a warning is printed, and the
first candiate in the list is selected. User may select another
candidate with `-DSYSROOT_DIR=<use-this>`.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-23 16:37:44 +02:00
Torsten Rasmussen af4a87af8e cmake: support relocating of a board folder
Fixes: #49116

During development of out-of-tree boards and applications it is not
uncommon to refactor / restructure code.

To allow developers more freedom, let's check that board's defconfig
still exists during a CMake re-run.
If the defconfig no longer exists, either because it's been moved or
deleted, then warn the user and set BOARD_DIR to NOTFOUND.

The NOTFOUND will request CMake to search for the new location in all
board roots. If the board has not been found, as example it's deleted,
then the existing error is printed later.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-22 17:14:20 +02:00
Marc Herbert 3ebb18b882 cmake: fix utterly cryptic error handling in the -DSPARSE=y build
Fixes commit 7a85ff7683 ("add sparse support")

The sparse build needs (at least) two things:
1. sparse to be in the PATH
2. the environment variable REAL_CC to be defined and to match the
   value expected by CMake

Fix error messages when either condition is wrong.

- New error message when 1. is not satisfied:
```
CMake Error at zephyr/cmake/compiler/gcc/target.cmake:12 (find_program):
  Could not find CMAKE_C_COMPILER using the following names: cgcc
```

- Previous error "message" when 1. is not satisfied:
```
CMake Error at zephyr/cmake/compiler/gcc/target.cmake:17 (message):
  C compiler
  ZSDK/xtensa-intel_s1000_zephyr-elf/bin/xtensa-intel_s1000_zephyr-elf-gcc
  not found - Please check your toolchain installation
```
Note the "not found" cross-compiler actually exists!

- New error message when 2. is not satisfied:
```
Kconfig header saved to 'ws/build-tgl/zephyr/include/generated/autoconf.h'
-- Found sparse: /home/user/sparse/cgcc
CMake Error at ws/zephyr/cmake/compiler/gcc/target.cmake:25 (message):
  The only way to override its 'cc' default when cross-compiling with
  sparse is unfortunately an environment variable.  So you _must_ set
  REAL_CC at both configuration time and build time to:
  $ZSDK/xtensa-intel_s1000_zephyr-elf/bin/xtensa-intel_s1000_zephyr-elf-gcc

```

- Previous error "message" when 2. is not satisfied:
```
modules/hal/xtensa/include/xtensa/config/core.h:54:10:
    error:unable to open 'core-isa.h'`
```

Also: stop using the same name REAL_CC for both the internal CMake
variable and the external sparse parameter; they're two different
things so name them differently. Environment variable messes are
complicated enough.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-09-22 15:12:22 +00:00
Nikolay Agishev df7beca2eb compiler: arcmwdt: Add ccac version checking
After recent changes Zephyr became incompatible with old
MWDT versions (older than 2022.06).
Version checking may help to avoid build errors
related this incompatibility.

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
2022-09-20 09:02:38 +00:00
Torsten Rasmussen c2974e22d4 cmake: test format options together
Fixes: #47588

Use `check_set_compiler_property(... "SHELL:-Wformat -W<format-option>")`
to ensure that compiler options requiring `-Wformat` to work properly
are tested with said option.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-14 09:37:59 +00:00
Torsten Rasmussen c32e4a71bf cmake: support grouping of compile options for compiler testing
Fixes: #47588

Kitware decided to fail compiler tests of single options if the
compiler reported only a warning and not an error:
github.com/Kitware/CMake/commit/f745e0497ee71d35fd1b3524b1636a72da76c266
which affects CMake 3.23.0 and 3.23.1

This change was later reverted in CMake >=3.23.2 and >=3.24.0
github.com/Kitware/CMake/commit/4941887d7defecb3016d2bd94d3a45754251ca56

Although the immediate issue is related to CMake, and has been fixed
reverted in later releases, then it still makes sense to be able to
group compiler options together that generally are depending on each
other to function correctly.

This commit introduces the possibility to group compiler options which
must be tested together.
It uses same approach as
> add_compile_options("SHELL:<option1> <option2> ...")

Usage:
> check_set_compiler_property(PROPERTY <property>
>                             "SHELL:<option1> <option2> ..."
> )

Will test the option together.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-14 09:37:59 +00:00
Jeremy Bettis 878edeb6ff cmake: Add -gdwarf-4 at link time for gcc
Add a linker option for gcc to force dwarf symbols to be version 4.

Fixes #50106

Signed-off-by: Jeremy Bettis <jbettis@google.com>
2022-09-13 17:05:57 -05:00
Huifeng Zhang dab22aac7a cmake: armfvp: permit run zephyr together with tf-a
As the TF-A was integrated into zephyr as a module. This adds necessary
CMake scripts to load BL1 and FIP binary built from TF-A.

Signed-off-by: Huifeng Zhang <Huifeng.Zhang@arm.com>
2022-09-09 16:36:37 +00:00
Torsten Rasmussen a0a72b9a96 cmake: create test_interface interface library
Creating a test_interface allows more complex unittest projects to
create additional libraries, for example mock libs, that can be re-used
between test projects.

To support the possibility of such libs to build with same flags as the
testbinary the test_interface is now populated with the public compile
and include flags from testbinary.

testbinary has been updated to use test_interface.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-09 10:06:19 +02:00
Keith Packard 1dfc469bd5 toolchain/cross-compile: Allow TLS support selection.
Add a user-settable configuration value indicating whether the toolchain
selected by the cross-compile variant supports thread local storage, using
the default 'n' value to preserve compatibility with existing uses.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-09-08 21:36:37 +00:00
Keith Packard 7052d52b3b toolchain/xtools: Crosstools-ng supports TLS by default
The Zephyr cross tools configuration which the 'xtools' variant supports
enables TLS, so set TOOLCHAIN_SUPPORTS_THREAD_LOCAL_STORAGE when using it.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-09-08 21:36:37 +00:00
Nikolay Agishev a56777263e compiler: gcc: add support for tuning mcpu option for ARC targets
ARC processors are highly configurable, so ARC toolchain supports
big amount of mcpu options for all that HW configurations.
As difference in many configurations among the same processor
family usually doesn't affect Zephyr code we don't want
to create Kconfig option for each possible CPU configuration
(just to map Kconfig option to correspondent mcpu value
in 'cmake/gcc-m-cpu.cmake').
Instead we prefer being able to set proper mcpu value
individually for any ARC SoC and using 'cmake/gcc-m-cpu.cmake'
just for reasonable defaults.

To apply SoC-related changes for build-options on early stages of building
'tune_build_ops.cmake' should be created in appropriate SoC directory.
Example:
 ./soc/arc/snps_qemu/tune_build_ops.cmake
File content:
 set(GCC_ARC_TUNED_CPU hs4xd)

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
2022-09-08 10:39:21 +02:00
Torsten Rasmussen a5cd394758 cmake: improve warning deprecation message
The current deprecation warning could give the impression that
CROSS_COMPILE is deprecated, which is not the case.

Instead it is the behavior of defaulting to `cross-compile` when
setting CROSS_COMPILE in environment without setting
ZEPHYR_TOOLCHAIN_VARIANT that is deprecated.
Not the use of `CROSS_COMPILE` setting itself.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-07 15:38:36 +02:00
Stephanos Ioannidis 9d0ec5dcd6 cmake: bintools: gnu: Do not use gdb-multiarch
The commit c2419fc006 introduced a change
to the CMake toolchain detection routine in which it attempts to use
the distro-provided `gdb-multiarch` GDB executable when the target-
specific GDB executable cannot be found (i.e. fallback to
`gdb-multiarch`).

This can cause many problems for the Zephyr users because the distro-
provided GDB does not contain any Zephyr-specific patches and it may
misbehave under various conditions (e.g. negative tid/pid being
displayed, Xtensa debugging mysteriously failing, ARC debugging not
working).

This commit removes the fallback mechanism to the distro-provided
`gdb-multiarch` because it is better to display an error message saying
GDB is not found than to use a wrong GDB that can give out very
confusing and misleading error messages to users.

Moreover, this fallback mechanism is no longer necessary because the
Zephyr SDK is now available on all major host operating systems and it
provides the target-specific custom GDB that contains all Zephyr-
specific patches.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-09-07 09:27:16 +00:00
Stephanos Ioannidis 3363c64abc cmake: bintools: gnu: Update GDB executable names for Zephyr SDK 0.15
The Zephyr SDK 0.15.0 release has changed the default GDB executable to
be Python-less and introduced an alternate Python-capable variant
called `gdb-py` (note that the Zephyr SDK previously provided
`gdb-no-py` instead).

This commit updates the CMake toolchain detection routine to attempt
using the Python-capable GDB variant (gdb-py) first and, if it is not
available or fails to launch due to a missing libpython dependency,
use the Python-less GDB variant (gdb).

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-09-07 09:27:16 +00:00
Torsten Rasmussen b066ae906b cmake: fix improper use of separate_arguments
The use of `separate_arguments()` in extra_flags.cmake and
unittest.cmake prevents the use of proper CMake lists.

A CMake list can be specified on command line as:
`-DMY_LIST="itemA;itemB;itemC"`

Users are expected to be able to provide extra compile flags using CMake
lists, like `-DEXTRA_CFLAGS="--flag1;--flag2"` but also using space
separated lists, like: `-DEXTRA_CFLAGS="--flag1 --flag2"`.

However, the way FLAGS was passed to separate_arguments() would result
in a list being treated as extra arguments to the function and thus
result in a CMake error.

To allow the use of CMake lists, the length of the argument as a CMake
list is tested. This ensures that when the argument contains a
single `;` then the length is >1 and no conversion is needed.

This allows a user to freely choose between the two forms:
- `-DFLAGS="--flag1 --flag2"`
- `-DFLAGS="--flag1;--flag2"`

or when passing flags which themselves contains spaces, like:
- `-DFLAGS="--flag1 \"val1 val2\""`
- `-DFLAGS="--flag1;val1 val2"`

Note that the extra escaped qouting is no longer needed for proper CMake
lists as the `;` itself informs the system that spaces are to be kept as
spaces.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-05 10:22:05 +02:00
Torsten Rasmussen 88ae9cbb9d cmake: extend zephyr_get() to handle build configurations from sysbuild
Enhance sysbuild controlled configurations.

The current scheme of passing settings using `-D` on the CMake
invocation is vulnerable to quoting and lists.

With `zephyr_get()` in place as a uniform way of handling user
controlled settings (CMake cache / environment / CMake local variable)
we have a mechanism in place for a cleaner handling of sysbuild
controlled settings.

This improves the robustness of variable passing and add the same cleans
up and simplifies the logic in sysbuild.

The Kconfig Zephyr CMake module has been updated accordingly so that
CONFIG settings are taken from the sysbuild shadow cache when sysbuild
is used as higher level build system.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-02 15:16:50 +02:00
Torsten Rasmussen 44a05e4439 cmake: update common Zephyr build settings to use zephyr_get()
Fixes: #40389

This commit aligns the use of the following Zephyr build variables:
- CONF_FILE
- DTC_OVERLAY_FILE
- OVERLAY_CONFIG
- WEST_DIR
- ZEPHYR_BOARD_ALIASES
- ZEPHYR_EXTRA_MODULES
- ZEPHYR_MODULES

so that they can be set in same manner and with same order of
preference.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-02 15:16:50 +02:00
Torsten Rasmussen 6d1f6c2d4e cmake: improved variable handling in zephyr_check_cache()
A cache variable specified by the user as `-DVAR=value` will have the
type UNINITIALIZED in the CMake cache.

Later CMake re-runs will execute the line:
set(${variable} ${CACHED_${variable}} CACHE STRING
    "Selected ${variable_text}" FORCE)

This will update the cache type from UNINITIALIZED to STRING and thus
may be picked up by other tools as a change.

To ensure the type is initialized to string, this is added:
set(${variable} ${${variable}} CACHE STRING "Selected ${variable_text}")

This code will not change the value of an existing CMake cache variable
because there is no FORCE, but what it will do is to update the cache
variable type to STRING.

As part of this, include the existing parent scope setting of variable
inside the `if(DEFINED ...)` as there is no reason to clear a variable
there is not having a value.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-02 15:16:50 +02:00
Torsten Rasmussen 56c827ac2c cmake: use zephyr_get in toolchains to ensure identical behavior.
Fixes: #40389

Update toolchain handling to use zephyr_get() to ensure consistent
handling of CMake cache variables, environment variable, and CMake
local variables.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-02 15:16:50 +02:00
Torsten Rasmussen 9913fd4f42 cmake: remove deprecated GCCARMEMB_TOOLCHAIN_PATH
Remove deprecated GCCARMEMB_TOOLCHAIN_PATH.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-02 15:16:50 +02:00
Torsten Rasmussen 90e236581e cmake: implement zephyr_get(<variable>) function
Fixes: #40389

This commit implements zephyr_get(<variable>).

The purpose of zephyr_get(<variable>) is to ensure a uniform way to
handle variables which can be defined as:
- CMake cache variable, for example `-D<var>=<value>`.
- Environment variable
- Locally in CMakeLists.txt file before `find_package(Zephyr)`

It furthermore ensures that if an environment setting hides a local
setting then a warning is printed.

using
zephyr_get(<var>)

removes the need for constructs like:
set_ifndef(<var> "$ENV{<var>}")
set(<var> ${<var>} CACHE PATH "")

if(NOT DEFINED <var>)
  set(<var> $ENV{<var>})
endif()

if (NOT DEFINED ENV{<var>})
  message(FATAL_ERROR <error>)
endif()

and also ensures identical preference order for variables used in Zephyr
1. cache
2. environment
3. local scope var

It also ensures the variables supported through environment can also be
set using `-D<var>=<value>`

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-02 15:16:50 +02:00
Mateusz Sierszulski 6c888b2db1 soc: telink_b91: Fix ROM region section overlap
Place vector sections after ROM_START sections.
Also add init.ld script that will prevent overlapping .init sections
in telink_b91 SoC.

Fixes #49036.

Signed-off-by: Mateusz Sierszulski <msierszulski@antmicro.com>
2022-09-02 14:19:53 +02:00
Torsten Rasmussen f6979306bc cmake: locate Zephyr SDK before locating other host tools.
Follow-up: #49672

Zephyr SDK and host tools detection was reworked in #49672.

That rework accidentally changed the lookup order from:
- Zephyr SDK
- Other host tools
- Generic (host) C compiler

into
- Other host tools
- Zephyr SDK
- Generic (host) C compiler

this causes host tools shipped with Zephyr SDK, such as openocd to not
be discovered unless in path.

Restore the original order so that Zephyr SDK is located first so that
host tools from the SDK can be found without having them in path.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-02 19:41:15 +09:00
Torsten Rasmussen 980c22c92d cmake: move deprecated code to FindDeprecated.cmake
Move deprecated XCC_USE_CLANG setting to deprecated module.

Deprecated and move the use of CROSS_COMPILE to deprecated module as we
have had ZEPHYR_TOOLCHAIN_VARIANT==cross-compile for a long time.

Deprecated code is now loaded with a single line:
> find_package(Deprecated COMPONENTS XCC_USE_CLANG CROSS_COMPILE)

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-01 15:59:43 +02:00
Torsten Rasmussen 2f1637c4b4 cmake: introduce Deprecated module
The deprecated CMake module allows Zephyr to move deprecated code to a
centralized location from where it's both easy to get an overview of
deprecated code, and remove the code when it has been deprecated long
enough.

It further improve existing code, as the real CMake code now can be
changed from n-lines of deprecated code into a single line of the form:
find_package(Deprecated COMPONENTS <deprecated_name>)

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-01 15:59:43 +02:00
Torsten Rasmussen 7131d02fa4 cmake: rework of target toolchain handling
Follow-up: #41301

This commit is a rework and cleanup of the target toolchain handling in
Zephyr CMake build system.

Instead of directly loading code a CMake modules for target toolchain
lookup, the target toolchain now follows the CMake `find_package()`
pattern for finding the target toolchain.

This makes it more clear which modules are responsible for finding tools
and which modules provides build integration / features.

The following tools can now be found using `find_package()`:
- Target toolchain: find_package(TargetTools)

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-01 15:59:43 +02:00
Torsten Rasmussen 8d2998d4f9 cmake: rework of host tools and generic toolchain handling
Follow-up: #41301

This commit is a rework and cleanup of the tools handling in Zephyr
CMake build system.

Instead of directly loading code a CMake modules for tool lookup, the
host tools now follows the CMake `find_package()` pattern for finding
programs / tools in module mode.

This makes it more clear which modules are responsible for finding tools
and which modules provides build integration / features.

The following tools can now be found using `find_package()`:
- Zephyr-sdk        : find_package(Zephyr-sdk <version>)
- Generic host tools: find_package(HostTools)

This further allows us to decouple the `verify-toolchain` CMake script
part required by `twister` into a tool lookup module and a dedicated
CMake script which utilizes the lookup module.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-01 15:59:43 +02:00
Torsten Rasmussen 2bace34be3 cmake: remove unreachable Zephyr-SDK lookup code
Removing Zephyr-SDK code for searching and printing messages when Zephyr
SDK is not found in the system.

After Zephyr SDK has been made available on all platforms, including
MacOS and Windows, then `find_package(Zephyr-sdk)` is always invoked
and thus either `find_package(Zephyr-sdk)` will fail or
ZEPHYR_TOOLCHAIN_VARIANT will be defined.

Meaning the removed code block in this commit can no longer be reached.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-01 15:59:43 +02:00
Torsten Rasmussen 8f8f6cfde3 cmake: cleanup search for devicetree compiler, dtc
Cleanup CMake code by moving devicetree compiler detection to dedicated
FindDtc.cmake module.

This allows us to re-use existing CMake find_package() functionality in
module mode and thus reduce CMake logic.

It further has the benefit of being able to directly specify dtc version
like this:
> find_package(Dtc 1.4.6)

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-01 15:59:43 +02:00
Torsten Rasmussen 9a12f8b68b cmake: move testing of compile flag in environment to top CMakeLists.txt
This moves the test of compile flags set in environment from generic
toolchain to top-level ${ZEPHYR_BASE}/CMakeLists.txt.

In order to cleanup and make Zephyr CMake modules more generic then
the testing of specific compile flags and warn user is not really a
toolchain module responsible but a implementation detail of the project
itself as to how compile flags should be applied in a project.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-01 15:59:43 +02:00
Stephanos Ioannidis cedaa6a2e5 cmake: Fix Zephyr SDK download URL
This commit fixes the outdated Zephyr SDK download URL in the toolchain
verification script.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-08-29 16:57:18 +02:00
Stephanos Ioannidis 30af51fc5e cmake: Set minimum required Zephyr SDK version to 0.15
This commit sets the minimum required Zephyr SDK version to 0.15, which
is required to build the current Zephyr codebase due to the following
breaking changes:

* RISC-V ISA spec change to 20191213 requiring the Zicsr and Zifencei
  extensions to be specified to the `-march` flag
* ARC64 output format name change to `elf64-littlearc64`

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-08-29 16:57:18 +02:00
Carlo Caione 6503795dc1 riscv: Introduce BitManip extensions
Add Zba, Zbb, Zbc and Zbs BitManip extensions.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-08-29 16:57:18 +02:00
Carlo Caione 5fece03d7d riscv: Introduce Zicsr and Zifencei extensions
And enable the new extensions on all the SoCs.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-08-29 16:57:18 +02:00
Kai Vehmanen 99bab75a69 cmake: fix use of unsupported -fno-pie with xcc
The commit 8259931fce ("xcc-clang: Do not used unavailable options")
has a side-effect that builds with xcc default to use -fno-pie. This
is not a supported compiler option for xcc, resulting in failing builds.

Use same configuration for xcc as is in place for xcc-clang, and
do not use -fno-pie.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-08-29 08:40:29 -04:00
Mahesh Mahadevan c029b081cc cmake: Add support to add symbols to nocache section
This PR allows the user to add symbols to the nocache
section. The use for this could be as follows

zephyr_linker_sources_ifdef(CONFIG_NOCACHE_MEMORY
  NOCACHE_SECTION
  nocache.ld
)

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

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

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2022-08-29 11:19:48 +02:00
Torsten Rasmussen 4cb2ef83bf cmake: kconfig: preserved quotes for Kconfig string values
Fixes: #48950

Kconfig requires quoted strings in its configuration files, like this:
> CONFIG_A_STRING="foo bar"

But CMake requires expects that strings are without additional qoutes,
and therefore qoutes are stripped when loading Kconfig config filers
into CMake.

This is particular important when the string in Kconfig is a path to a
file. In this case, not stripping the quotes leads to an error as the
file cannot be found.

When users pass a string to Kconfig through CMake, they are expected to
pass it so that qoutes are correct seen from Kconfig, that is:
> cmake -DCONFIG_A_STRING=\"foo bar\"

In CMake, those qoutes are written as-is to Kconfig extra config file,
and then removed in the CMake cache.
After Kconfig processing, the Kconfig settings are read back to CMake
but without quotes. Settings that was passed through the CMake cache,
for example using `-D` are written back to the cache, but this time
without the qoutes. This results in Kconfig errors on sub-sequent CMake
runs.

Instead of writing the Kconfig value setting back to the CMake cache,
introduce an internal shadow symbol in the cache prefixed with `CLI_`.
This allows the CMake cache to keep the value correctly formatted for
Kconfig extra config creation, while at the same time keep existing
behavior for CONFIG_ symbols read from Kconfig.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-25 17:53:11 -07:00
Carles Cufi 33211b3fb4 cmake: Bump the minimum required Python version to 3.8
Given that 3.6 is now several years old and the current and previous
Ubuntu LTS ship with 3.8 or later, upgrade the minimum required Python
version from 3.6 to 3.8.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-24 18:35:57 +02:00
Peter Marheine d400b8135c arch/riscv: support CONFIG_CODE_DATA_RELOCATION
This implements support for relocating code to chosen memory regions via
the `zephyr_code_relocate` CMake function for RISC-V SoCs. ARM-specific
assumptions that were made by gen_relocate_app.py need to be corrected,
in particular not assuming any particular name for the default RAM
section (which is 'SRAM' for most ARM pltaforms) and not assuming 32-bit
pointers (so the test works on RV64).

Signed-off-by: Peter Marheine <pmarheine@chromium.org>
2022-08-24 10:08:06 +02:00
Flavio Ceolin 8259931fce xcc-clang: Do not used unavailable options
xcc-clang in based on clan-10 and does not support -fno-pic and
-fno-pie.

clang-10: warning: argument unused during compilation: '-fno-pic'
[-Wunused-command-line-argument]
[147/148] Linking C executable zephyr/zephyr.elf
clang-10: warning: argument unused during compilation: '-no-pie'
[-Wunused-command-line-argument]

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-08-23 10:13:43 +02:00
Andy Ross 74cc534758 cmake: Update CONFIG_ASAN support
This had bitrotten a bit, and didn't build as shipped.  Current
libasan implementations want -fsanitize=address passed as a linker
argument too.  We have grown a "lld" linker variant that needs the
same cmake treatment as the "ld" binutils one, but never got it.  But
the various flags had been cut/pasted around to different places, with
slightly different forms.  That's really sort of a mess, as sanitizer
support was only ever support with host toolchains for native_posix
(and AFAICT no one anywhere has made this work on cross compilers in
an embedded environment).  And the separate "gcc" vs. "llvm" layers
were silly, as there has only ever been one API for this feature (from
LLVM, then picked up compatibly by gcc).

Pull this stuff out and just do it in one place in the posix arch for
simplicity.

Also recent sanitizers are trying to add instrumentation padding
around data that we use linker trickery to pack tightly
(c.f. SYS_INIT, STRUCT_SECTION_ITERABLE) and we need a way
("__noasan") to turn that off.  Actually for gcc, it was enough to
just make the records const (already true for most of them, except a
native_posix init struct), but clang apparently isn't smart enough.

Finally, add an ASAN_RECOVER kconfig that enables the use of
"halt_on_error=0" in $ASAN_OPTIONS, which continues execution past the
first error.

Signed-off-by: Andy Ross <andyross@google.com>
2022-08-19 08:30:01 +02:00
Andy Ross d6297988be cmake/llvm: Improve tool detection
On Debian, llvm-obj{copy,dump} tools are installed with a version
suffix.  Look first for a version that matches our compiler when
probing for tool paths before trying the bare version, or falling back
to GNU binutils.

Signed-off-by: Andy Ross <andyross@google.com>
2022-08-19 08:30:01 +02:00
Daniel Leung 1ace8efb8a cmake: extend linker snippets for pinned sections
This extends the linker snippet code to cover pinned
sections.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-08-18 17:23:18 +02:00
Torsten Rasmussen 7a65bdbd64 cmake: kconfig: introduce dedicated unit testing board
This commit introduces a dedicated unit testing board.

Today, a dedicated Zephyr unit testing scheme exists but is different
from how a Zephyr build generally works.

For example Kconfig is not possible, resulting on various different
hacks to pass Kconfig settings from test cases / testcase.yaml through
CMake to the code.
Some directly as compile definitions, some as header files with forced
inclusion on sources, some with wrapper flags which again results in
different define being enabled. There is even cases where a second
forced header inclusion undefines previous defines.

Unit test often does a manual check for the right boards, like this:
> if (NOT BOARD STREQUAL unit_testing)
>    message(FATAL_ERROR "This project can only be used with...")
> endif()

Introducing a dedicated unit_testing board under `tests/root` allows
us to use Kconfig in unit test samples, and thus proper `prj.conf` and
extra Kconfig fragments.
Generation of autoconf.h so the overall architecture follows regular
Zephyr builds.

Proper and uniform error messages when invalid board is selected.

The unit_testing board and arch is located under: `subsys/testsuite` so
that it is only available when find_package(Zephyr COMPONENTS unittest)
is used, and not available for regular Zephyr builds.

Kconfig generates autoconf.h which is applied as compile flag to
test binary which means that kconfig defines placed in ztest.h can now
be removed.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-18 14:29:14 +02:00
Torsten Rasmussen a450c663f2 cmake: define and create KCONFIG_BINARY_DIR if it doesn't exists
The Zephyr CMake module kconfig.cmake will create files inside
KCONFIG_BINARY_DIR.

In a default Zephyr build setup, this directory is created by Zephyr
CMake module zephyr_module.cmake. But Zephyr CMake modules are modular
and thus it must be possible to use kconfig module without
zephyr_module.

Thus kconfig.cmake must set and create KCONFIG_BINARY_DIR if it does not
already exists.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-18 14:29:14 +02:00
Torsten Rasmussen c3620c8a8e scripts: remove ZEPHYR_BASE as default root for board listing
Remove ZEPHYR_BASE as default root in list_boards.py.

This allows list_boards.py to be used to only print boards at given
root(s) without printing Zephyr default boards.

Secondly it remove the need in list_boards.py to have any knowledge of
ZEPHYR_BASE.

The `west boards` command already has ZEPHYR_BASE knowledge and can
easily add ZEPHYR_BASE to the list of roots it is already constructing,
thus removing the need for knowing that ZEPHYR_BASE is always added.

Update boards.cmake to pass ZEPHYR_BASE as an additional arch root, as
arch.cmake has not yet been processed,which means ZEPHYR_BASE is missing
in ARCH_ROOT list at this point in time.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-18 14:29:14 +02:00
Abe Levkoy 63d75cc26d cmake: Fix typo in common-rom.cmake
ALIGN_WITH_INPUT is an argument for zephyr_linker_section, not
zephyr_linker_section_configure. Fix the calls for section .emulators
accordingly.

Signed-off-by: Abe Levkoy <alevkoy@google.com>
2022-08-17 15:47:52 +00:00
Felipe Neves 6ba5b21337 soc: xtensa: esp32_net: update kconfig
specific of soc to make it compatible to the new toolchain.

Signed-off-by: Felipe Neves <felipe.neves@linaro.org>
2022-08-16 18:06:02 +02:00
Felipe Neves 382b4144e3 soc: xtensa: esp32: fix app cpu boot
procedure by setting its PC to 0 before reset.

Signed-off-by: Felipe Neves <felipe.neves@linaro.org>
2022-08-16 18:06:02 +02:00
Felipe Neves bb6e656ec0 soc: esp32_net: added esp32_net as an option
to use esp32 core 1 as a separate CPU, also
provide infrastructure to load firmware to
that CPU

Signed-off-by: Felipe Neves <felipe.neves@linaro.org>
2022-08-16 18:06:02 +02:00
Fabio Baltieri 0226e53e23 Restore "cmake: remove device_extern.h logic"
This reverts commit 87c6789355, restoring
commit 3b341085a2.

Restore the original change now that the underlying issue has been fixed
in 6cfb18686e.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-08-12 07:45:01 +01:00
Fabio Baltieri 87c6789355 Revert "cmake: remove device_extern.h logic"
This reverts commit 3b341085a2.

Seems to be breaking CI for few qemu platforms.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-08-11 17:21:46 -05:00
Stephanos Ioannidis 4d36e8f693 cmake: compiler: arcmwdt: Add no_strict_aliasing flag
This commit adds the `no_strict_aliasing` flag, which disables
the strict aliasing rule, for the ARC MetaWare compiler.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-08-11 17:45:58 +02:00
Stephanos Ioannidis 1f2c1c6278 cmake: compiler: gcc: Add no_strict_aliasing flag
This commit adds the `no_strict_aliasing` flag, which disables
the strict aliasing rule, for the GCC compiler and its derivatives.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-08-11 17:45:58 +02:00
Stephanos Ioannidis 9672858c19 cmake: compiler: Add flag template for disabling strict aliasing rule
This commit adds a template for specifying the C/C++ compiler flag for
disabling the strict aliasing rule.

It also enables this flag globally because the Zephyr codebase does not
strictly adhere to the aliasing rules specified by the C/C++ standards
and the optimisation strategies that assume these rules may end up
generating invalid code.

For instance, GCC 11 and above tend to optimise more aggressively
assuming the strict adherence to the standard aliasing rules and may
generate invalid code, when compiling Zephyr with `-fstrict-aliasing`,
that results in various run-time failures.

Note that the footprint and performance ramifications of disabling the
strict aliasing rule are negligible.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-08-11 17:45:58 +02:00
Gerard Marull-Paretas d322adc66f devicetree: s/devicetree_unfixed/devicetree_generated
Because the fixup files do not exist anymore, stop using "unfixed"
naming in favor of "generated".

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-11 12:17:02 +02:00
Gerard Marull-Paretas b2520b09a7 devicetree: drop support for dts_fixup.h files
Devicetree fixup files existed previous to the current stable Devicetree
API. While they served their purpose, they are no longer necessary nor
used in-tree. This patch drops support for this legacy feature.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-11 12:17:02 +02:00
Yuval Peress 84dfb8edf8 ztest: allow asserts anywhere
Updates the ztest_test_fail() function to allow failures in setup.
When executed, a failed assert will fail every test in the suite owning
the setup function. This was verified by adding a suite which asserts
in the setup function and has a test that should pass. During
exeuction, ztest marks the test as failing.

In order to verify exection I also added 2 new APIs:
- ZTEST_EXPECT_FAIL(suite_name, test_name)
- ZTEST_EXPECT_SKIP(suite_name, test_name)

Signed-off-by: Yuval Peress <peress@google.com>
2022-08-09 13:30:15 -04:00
Martí Bolívar 3b341085a2 cmake: remove device_extern.h logic
This file is no longer used by device.h, so let's avoid spending time
generating the content formerly in it.

In order to leave a pointer in place for users who are expecting to
see it or are pulling it into their own builds, however, replace its
contents with an #error directive that tells them what happened. This
can be removed later on when we expect people are used to the
transition.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-08 10:44:41 +02:00
Jeremy Bettis d7727b9415 cmake: Use cmake var not env for sdk
ZEPHYR_SDK_INSTALL_DIR is set from the env if it is not passed
explicitly to cmake, but one usage was reading directly from the env,
not allowing passing the var to cmake instead.

Change find_package of Zephyr-sdk to read from cmake var not env var.

Signed-off-by: Jeremy Bettis <jbettis@google.com>
2022-08-05 14:03:15 +02:00
Dat Nguyen Duy 8e55e59c59 arch: introduce config DCLS
Some processors support Dual-redundant Core Lock-step
DCLS) topology but the processor still can be ran in
split-lock mode (by default or changed at flash time).
So, introduce config DCLS that is enabled by default if
config CPU_HAS_DCLS is set, it should be disabled if
processor is used in split-lock mode.

Signed-off-by: Dat Nguyen Duy <dat.nguyenduy@nxp.com>
2022-08-04 12:51:25 +09:00
Torsten Rasmussen 542aad5ac3 cmake: kconfig: allow to set Kconfig targets externally
This commit allows a project to specify a given set of Kconfig targets
prior to sourcing kconfig.cmake.

This allows for greater flexibility when re-using kconfig.cmake in
other projects.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-03 16:05:07 +02:00
Torsten Rasmussen 796474e366 cmake: kconfig: allow for Kconfig CONFIG namespace
This commit allows for specifying a dedicated Kconfig namespace, for
example: <namespace>_CONFIG

This namespace will then be used for handling loading of configuration
files into CMake configure scope, as well as handling of CMake cache
variables when set using `-D<namespace>_CONFIG_<var>=<value>`.

This allows greater flexibility when re-using the cmake/kconfig.cmake
in other projects.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-03 16:05:07 +02:00
Torsten Rasmussen a3a0112e03 cmake: kconfig: allow build systems to decide defconfig
Allow build system to define an alternative defconfig file.
This allows reusing the existing kconfig.cmake file in other projects,
such as multi image builds.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-03 16:05:07 +02:00
Manuel Arguelles f10fa0dea8 cmake: allow Cortex-R52 to configure VFP
The Cortex-R52 processor supports single-precision
floating-point instructions and can optionally support
the double-precision floating-point instructions.

Signed-off-by: Manuel Arguelles <manuel.arguelles@nxp.com>
2022-07-26 08:48:07 +02:00
Kumar Gala c9aa63c0dc dts: Introduce Kconfig.dts
Introduce a generated Kconfig.dts that sets a Kconfig symbol for
every compatible.

* We set DT_HAS_<compat>_ENABLED if the devicetree has a node with
  <compat> enabled. (status is okay...)

We can then use the Kconfig symbol in driver Kconfig to determine
if the driver should be available, and thus enabled by default.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-19 09:39:49 -07:00
Evgeniy Paltsev ec075ebf60 ARC: MWDT: add missing options to generate symbol file
Fix for #47353 where we add and enable symbol generation,
but miss to add proper options for ARCMWDT toolchain.

Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2022-07-13 12:00:39 -04:00
Anas Nashif 01582f80b7 scripts: move gen_cfb_font_header.py to scripts/build
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

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

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

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

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

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

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

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

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

Fixes #47420

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

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

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

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

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

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

Update the npcx9m6f_evb instructions now that the filename is implicit.

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

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

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

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

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

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

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

This is a continued fix for #43835

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

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

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

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

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

- ISA and extensions settings are moved to SoC configuration files

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

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

Fixes #44108

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

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

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

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

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

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

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

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

The following changes are introduced by this commit:

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

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

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

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

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

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

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

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

Fixes #44108

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

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

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

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

zephyr_linker_sources_ifdef(CONFIG_ARCH_HAS_RAMFUNC_SUPPORT
  RAMFUNC_SECTION
  quick_access_code.ld
)

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

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

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

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

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

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

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

Issue #41543

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

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

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

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

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

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

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

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

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

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

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

[MEM]:[FILE]:[COPY]

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

Move the COPY/NOCOPY to:

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

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

Fixes #43950

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Example:
west build -t tfm_rom_report

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

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

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

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

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

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

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

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

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-03-07 16:35:54 +01:00