Make sure the flags in EXTRA_DTC_FLAGS are valid for the version of dtc
we have and only invoke dtc with flags it supports.
Fixes#32644
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Fixes: #32269
This commit is a followup to #31877 where the `${shield_dir}/${s_dir}`
was adjusted to `${SHIELD_DIR_${s}}` to ensure only including shields
and not boards in list of known shields.
An `if(EXISTS ${shield_dir}/${s_dir}...)` was missed in this process
which causes #32269. This is corrected in this commit.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Several variables must be set by the time boilerplate.cmake is run.
This includes BOARD, SHIELD, CONF_FILE, and DTC_OVERLAY_FILE.
It's not always clear to users that this is the case, and we sometimes
see attempts to modify these variables in app CMakeLists.txt files
after find_package(Zephyr ...) lines, where they will have no effect.
This causes confusion.
Add a new extension function, zephyr_boilerplate_watch(), which traps
attempts to set these variables and prints a noisy warning. Use it
from boilerplate.cmake on the variables mentioned above.
This will hopefully make it clearer at build time why the changes are
being ignored.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Add ability to build a UF2 (https://github.com/Microsoft/uf2)
image as an additional output type. This leverages the code
partition offset for the UF2 base address, and a configurable
UF2 family ID.
Includes an unmodified (except for headers for licensing, pylit
disabling) version of the uf2conv.py script copied the UF2
format specification repository, used to convert the bin to UF2.
Origin: UF2 file format specification reference utilies
License: MIT
URL: https://github.com/microsoft/uf2/blob/master/utils/uf2conv.py
commit: 587abb8b909266e9b468d6284f2fbd425235d1b5
Signed-off-by: Pete Johanson <peter@peterjohanson.com>
Treat shield directories containing a dts subdirectory as a DTS root
directory.
This allows shield specific devicetree include files and bindings to be
stored under the shield dts subdirectory.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
The following two lines are duplicated in boilerplate.cmake
```
zephyr_file(APPLICATION_ROOT BOARD_ROOT)
list(APPEND BOARD_ROOT ${ZEPHYR_BASE})
```
This commit removes one set of the duplicated lines.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
'-Wexpansion-to-defined'
Warn whenever 'defined' is encountered in the expansion of a macro
(including the case where the macro is expanded by an '#if'
directive). Such usage is not portable. This warning is also
enabled by '-Wpedantic' and '-Wextra'.
This is enabled by default in llvm but not in gcc. Given that it is 'not
portable', lets disallow this in gcc and keep both compilers in sync.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Fixes: #23449
This commit adds additional OUTPUT and BYPRODUCTS to custom command
and targets in the Zephyr build system.
This ensures that files produced during the build will be removed again
when invoking ninja clean / make clean.
The generated syscalls headers include folder is added to the syscall
target using ADDITIONAL_CLEAN_FILES property.
However, this property is new in CMake 3.15, so will not work when using
older CMake with ninja.
For CMake versions <=3.15 the ADDITIONAL_MAKE_CLEAN_FILES property is
used. However, this only supports Makefile generator.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #30713
Now using the common script `verify-toolchain.cmake` for verifying
toolchain settings.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Since EXTRA_DTC_FLAGS will be ';' seperated if we pass that as is if
there are multiple items in the list we'll get an error. Sanitize
EXTRA_DTC_FLAGS by replacing ';' with ' ' before we call gen_defines.py
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This allows users to overrule a module from command line.
As example, the Zephyr build system loads the module FOO from
`modules/FOO`, but user has a custom FOO locally at `custom/FOO` and
would like to use this module instead of manifest specified.
If user does `-DZEPHYR_EXTRA_MODULES=custom/FOO` the following error
will be seen:
```
The binary directory
build/modules/FOO
is already used to build a source directory. It cannot be used to build
source directory
custom/FOO
Specify a unique binary directory name.
```
Removing duplicates from the list allows a user to use
`-DZEPHYR_EXTRA_MODULES=custom/FOO` and thus replace `modules/FOO` for
the current build.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #26522
Now searching for Kconfig.shield instead of recursively looking for
overlay files.
Globbing recursively for overlay files also picks up board overlays,
which leads to errors in the shield handling, as user could wrongly
specify certain boards as shields.
Also it led to wrongly list some board as shields, as reported
in #26522.
The folder containing a Kconfig.shield is then used when looking up
overlay files, as all overlay files in that folder represents a shield.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This is a follow-up to commit 77ecd6837d.
Add missing check that looks for a revision specific overlay located
in the `<app>/boards/` directory similar to how overlays and Kconfig
fragments are handled.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #30553
The `;` in a list must be escaped when used as for execute_process and
add_custom_target, as those functions are using `cmake -E env` to setup
correct environment before executing kconfig and menuconfig.
This commits escapes `SHIELD_AS_LIST` variable list correctly before
using it.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Calling cmake/pristine.cmake now requires SOURCE_DIR and BINARY_DIR as
arguments.
This ensures that pristine.cmake can evaluate if pristine is requested
on in-source builds, and bail out in such case with an error message.
All uses of `pristine.cmake` has been updated to use the new arguments.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This adds the correct compiler and linker flags to
support software floating point operations. The flags
need to be added to TOOLCHAIN_*_FLAGS for GCC to find
the correct library (when calling GCC with
--print-libgcc-file-name).
Note that software floating point needs to be turned
on for Newlib. This is due to Newlib having floating
point numbers in its various printf() functions which
results in floating point instructions being emitted
from toolchain. These instructions are placed very
early in the functions which results in them being
executed even though the format string contains
no floating point conversions. Without using CONFIG_FPU
to enable hardware floating point support, any calls to
printf() like functions will result in exceptions
complaining FPU is not available. Although forcing
CONFIG_FPU=y with newlib is an option, and because
the OS doesn't know which threads would call these
printf() functions, Zephyr has to assume all threads
are using FPU and thus incurring performance penalty as
every context switching now needs to save FPU registers.
A compromise here is to use soft float instead. Newlib
with soft float enabled does not have floating point
instructions and yet can still support its printf()
like functions.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
The introduction of Zephyr module glue code in the Zephyr repository
introduces a Kconfig variable in the form of:
`config ZEPHYR_<MODULE_NAME>_MODULE`.
All Kconfig variables go into `autoconf.h`, therefore it is necessary
to sanitize the Kconfig variable, so that it does not contain special
characters. To ensure consistent variable name, then the module name
will be sanitized in all variable use in both Kconfig and CMake.
The sanitization is done be replacing all special characters with an
underscore, `_`.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #28847
This commit fixes two places that was causing gen_relocate_app to fail
in windows.
gen_relocate_app.py now splits only on first `:` in
`<MEM_REGION>:<file>`.
Windows contains `:` in path, thus only first `:` is valid for splitting
mem region and file path.
Second part of the issue is fixed in CMake where `'` was used for
quoting of command arguments.
This causes a file not found on Windows because the final `'` would be
treated as part of the filename. Similar the first `'` would be treated
as path of the mem region name.
This is fixed by using `"` for quoting, which works correctly on all
platforms.
gen_relocate_app.py:403: UserWarning: File: .../kernel/sem.c' Not found
Note the stray `'` ^^^
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
In bash a '&&' cannot follow directly after a '&'. So a task that is
run in the background should be enclosed in (curly) braces.
This:
```
west build -b qemu_x86 -d build/server samples/net/sockets/echo_server\
-- -DOVERLAY_CONFIG=overlay-qemu_802154.conf -DPCAP=capture.pcap
west build -t server -d build/server
```
works correctly after this fix.
Fixes#29793
Signed-off-by: Daniel Noom <ggatw@outlook.com>
This commit introduces MODULE_EXT_ROOT which allows CMake and Kconfig
glue code to be placed outside of the Zephyr module repository.
This allows for placing glue code in Zephyr, but also allows users to
specify custom MODULE_EXT_ROOTs for glue code using either
`-DMODULE_EXT_ROOT` or `zephyr/module.yml` with
`build:settings:module_ext_root` settings.
MODULE_EXT_ROOT' is a list of directories, similar to other roots such
as BOARD_ROOT, DTS_ROOT, etc.
The Zephyr repo folder ${ZEPHYR_BASE} is always to the MODULE_EXT_ROOT
list as lowest priority.
For each MODULE_EXT_ROOT, the file
`<module_ext_root>/modules/modules.cmake` will be processed.
In Zephyr repo, the folder `modules/<module>/` contains CMakeLists.txt
and Kconfig glue code for the Zephyr module.
A Zephyr module can specify that CMakeLists.txt and Kconfig glue code is
placed in an external module root by specifying:
```
build:
cmake-ext: True
kconfig-ext: True
```
It is still possible to place the CMakeLists.txt and Kconfig files
directly in the Zephyr module using the existing:
```
build:
cmake: <path>
kconfig: <file>
```.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Remove the boards and shields lists from the 'usage' target output.
That might have been readable at some point long ago in Zephyr's
history, when only a few boards were available, but right now it's
obscuring the high level targets we really want 'usage' to print.
Instead, add 'boards' and 'shields' targets which the user can run to
get those lists, and reference them from the 'usage' output. This
makes 'usage' squintable again. We use the new list_boards.py script
from the 'boards' target.
Reference the 'help' target from 'usage' as well, and drop the
recommendation that people run '--target help' from the 'west build
--help' output for the 'west build --target' option. The canonical
place to look is 'usage' now.
Use the new list_boards.py code from 'west boards' as well, which
allows us to add the board's directory as a format string key, in
addition to its name and architecture.
Keep west-completion.bash up to date. While doing that, I noticed that
a bunch of references to this file refer to a stale location, so fix
those too.
Finally, the 'usage' output is what we print for a failed board or
shield lookup, so that needs to be updated also. Handle that by
invoking boards.cmake and a new shields.cmake in CMake script mode to
print the relevant output.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
We compile objects with -mcmodel=medany. Now also give -mcmodel=medany
to the GCC front-end when linking to pick up the corresponding
multilibs.
Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
Generate a header (device_extern.h) that handles extern of possible
device structs that would come from devicetree. This removes the need
for DEVICE_DT_DECLARE and DEVICE_DT_INST_DECLARE which we can remove.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
-Hnocopyr option suppress copyright message in case of LDAC linker
but in case of LLDAC linker somehow it leads to partial linking
and generation output file with relocations. Looks like we
are converting MWDT option to LLVM option incorrectly in this
case. Among the partial linking itself it may cause build errors
when 'elf.get_dwarf_info' from 'gen_kobject_list.py' meets the
arch-specific relocation which isn't supported by 'elftools'
It requires future investigation, let's disable -Hnocopyr for now
to have elf image linked correctly.
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
We're well past Zephyr v1.16 (which turned out to be v2.1,
since v1.14 was followed by v2.0), so remove a message about a
variable that's been obsolete for two versions before that.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
The toolchain variant per SoC is not always the soc name, so set this
per SoC and use this in the SDK instead of hardcoding the soc name.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Compound assigments like x |= y to volatile qualified values are
deprecated in C++20. This idiom is common in CMSIS headers for
manipulating peripheral registers. Since these headers are core they
are likely to be included indirectly in C++ modules; since they are in
vendor-provided headers we can't "fix" them.
Disable the warning when building for C++.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit contains some additional review comments that was posted
after board revision PR #29990 was merged.
The follow-up changes are:
- Fixed typo: REVIVISION --> REVISION
- Renaming leftover in print message:
zephyr_check_board_revision --> board_check_revision
- Fixed regex, to allow revision 10, 20, 30, 40, etc.
- digits --> number in comment
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Depending whether doorbell or plain versions are enabled, it will set
the right flags to qemu.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit introduces support for versioning of boards.
The existing board handling is limited in such a way that it is not
possible to support a specific board in multiple variants.
This commit introduces versioning of board revisions so that it is
possible to support minor variations to a board without having to
defining a completely new board.
This can be done by adding a revision.cmake file in the board folder:
boards/<arch>/<board-dir>/revision.cmake
Depending on the revision format chosen, additional configuration files
for each revision available must also be added, those have the form:
boards/<arch>/<board-dir>/<board>_<revision>.conf
Examples:
boards/<arch>/<board-dir>/<board>_defconfig: Common board settings
Revision format: MAJOR.MINOR.PATCH
boards/<arch>/<board-dir>/<board>_0_5_0.conf: Revision 0.5.0
boards/<arch>/<board-dir>/<board>_1_0_0.conf: Revision 1.0.0
boards/<arch>/<board-dir>/<board>_1_5_0.conf: Revision 1.5.0
Revision format: LETTER
boards/<arch>/<board-dir>/<board>_A.conf: Revision A
boards/<arch>/<board-dir>/<board>_B.conf: Revision B
The `board_check_revision` function is available in `extensions.cmake`
to facilitate board revision handling in `revision.cmake`.
User select the board revision using: `-DBOARD=<board>@<revision>`, as
example `-DBOARD=plank@0.5.0`.
If a shield, test, sample, or application needs to specify DTS overlay
or Kconfig fragments, this can be done by adding revision specific
configuration files in the sample/test/shield folder, like this:
<shield/sample-path>/boards/<board>.conf
<shield/sample-path>/boards/<board>_<revision>.conf
or if there is there is only a need for adjusting on a given board
revision:
<shield/sample-path>/boards/<board>_<revision>.conf
Similar for DTS overlay files:
<shield-path>/boards/<board>.overlay
<shield-path>/boards/<board>_<revision>.overlay
or:
<shield-path>/boards/<board>_<revision>.conf
For test/samples/apps:
<sample-path>/<board>.overlay
<sample-path>/<board>_<revision>.overlay
or:
<sample-path>/<board>_<revision>.overlay
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit extends zephyr_file(<mode>) to support `CONF_FILES` which
allows for finding and appending Zephyr Kconfig fragments and DTS
overlays.
Introducing mode:CONF_FILES allows have a uniform way of looking up
<board>.conf and <board>.overlay, and ensure that extending such
functionality keeps identical behaviour in shields, tests, and samples.
Using zephyr_file(CONF_FILES) a lot of duplicated code can be removed.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit fixes an issue where specifying a build type config file
in a subfolder named: `prj_<something>` would cause a wrong match and
fail to find Kconfig fragments, as example:
Working: `-DCONF_FILE=myconfigs/prj_debug.conf` would correctly add
myconfigs/boards/<board>_debug.conf to list of conf files.
Failing: `-DCONF_FILE=prj_configs/prj_debug.conf` would fail to locate
prj_configs/boards/<board>_debug.conf, and thus the board specific
config fragment was not added to the list of config files.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Currently only BOARD is printed when running CMake.
This commit prints shields together with board, if one or more shields
are specified.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Cleanup board and shield cmake code so that code duplication is reduced.
Before this commit, the code for verifying if BOARD or SHIELD user input
had changed was almost identical.
The common code has been made into a Zephyr extension function so that
all part of Zephyr build system can have a uniform way of checking if
sticky arguments has changed, and print user warning in a uniform way.
This also fixes an undiscovered flaw, where changing a shield is not
possible if a shield was defined at first CMake invocation, but in case
no shield had been specified at all, then build system would wrongly
allow specifying and changing shields, for example doing:
cmake -DBOARD=nrf52840dk_nrf52840 -DSHIELD=sparkfun_sara_r4 <sample>
cmake -DSHIELD=wnc_m14a2a
results correctly in:
> CMake Warning at zephyr/cmake/app/boilerplate.cmake:287 (message):
> The build directory must be cleaned pristinely when changing shields
and correctly keep existing SHIELD settings.
but doing:
cmake -DBOARD=nrf52840dk_nrf52840 <sample>
cmake -DSHIELD=sparkfun_sara_r4
cmake -DSHIELD=wnc_m14a2a
would not result in any warning, because `CACHED_SHIELD` was not
correctly checked in this case.
Changing shield is not a supported feature as it have unknown behavior.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #30712
Now using zephyr_get_compile_options_for_lang_as_string for makefile
export of Zephyr build flags.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #30531
Now using MD5 sum of CMAKE_C_COMPILER (path), CMAKE_C_COMPILER_ID and
CMAKE_C_COMPILER_VERSION variables as part of the TOOLCHAIN_SIGNATURE.
Moved MD5 calculation of executable into
cmake/target_toolchain_flags.cmake to have common location, as
CMAKE_C_COMPILER_ID and CMAKE_C_COMPILER_VERSION are not available until
project() has executed.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Previously, `cmake/app/boilerplate.cmake` evaluated
ZEPHYR_EXTRA_MODULES on line ~548 *after* `zephyr_module.cmake`
was included on line ~168.
This change ensures that modules defined in `ENV{ZEPHYR_EXTRA_MODULES}`
are processed properly through `zephyr_module.cmake`.
Fixes#30673
Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
This change adds full shared floating point support for the SPARC
architecture.
All SPARC floating point registers are scratch registers with respect
to function call boundaries. That means we only have to save floating
point registers when switching threads in ISR. The registers are
stored to the corresponding thread stack.
FPU is disabled when calling ISR. Any attempt to use FPU in ISR
will generate the fp_disabled trap which causes Zephyr fatal error.
- This commit adds no new thread state.
- All FPU contest save/restore is synchronous and lazy FPU context
switch is not implemented.
Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
The use of zephyr_get_<flags>_for_lang_as_string will now use space as
delimiter, this will allow for existing used of the
zephyr_get_<flags>_for_lang_as_string() to return a string with spaces
instead of semicolons as a quoted list.
Note, in most situations it is prefered to have a proper CMake list
returned, in which case zephyr_get_<flags>_for_lang() is probably the
correct function to use.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The current zephyr_get_compile_<type> flags returns compile / include
flags based on generator expressions.
But they also included a space.
This have the unintended side-effect that when the properties are
fetched into another variable and later appended to lists in order to
finally be used in a CMake target function / custom command, then CMake
in some cases will quote the string, creating a quoted argument like:
"arg0 arg1 arg2: instead of individual arguments like: "arg0" "arg1"
"arg2".
By using $<SEMICOLON>, then arguments are seperated correctly.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #30232
This is a workaround for #30232.
During Zephyr CMake invocation a plain C compiler is used for DTS.
This results in the internal `CheckCompilerFlag.cmake` being included
by CMake
Later, when the full toolchain is configured, then
`CMakeCheckCompilerFlag.cmake` is included.
This overloads the `cmake_check_compiler_flag()` function, thus
causing #30232.
By manualy loading `CMakeCheckCompilerFlag.cmake` then
`CheckCompilerFlag.cmake` will overload the functions (and thus win the
battle), and because `include_guard(GLOBAL)` is used in
`CMakeCheckCompilerFlag.cmake` this file will not be re-included later.
It also prints a warning informing the user of the issue.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Ensure > is an independent argument.
The ; will ensure that the `>` and `outfile` are given as two arguments
and thus ensure correct behavior in all cases.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>