Commit graph

189 commits

Author SHA1 Message Date
Alberto Escolar Piedras 9bb708eb7d init_priorities: Fix for native_simulator based targets
Fix the init_prioties related cmake targets so they also
work with native_simulator based build targets.
Mostly this consists of pointing to the right file
(final build result instead of intermediate elf library)
and setting the dependency to that final build result.

Note that for the native_simulator based targets
the init priorities check can only be run on build
if we are building the final image (not just a partial
prelinked library),
and we are not assembling several images together
into one executable.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-27 12:19:03 +00:00
Fabio Baltieri 702399080e Kconfig: drop COMPAT_INCLUDES
Last reference of this was dropped in 01b7800bc8, almost 2y ago.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-11-09 11:22:40 +01:00
Fabio Baltieri 2a70c31945 scripts: check_init_priorities: drop the same priority check
Since bb590b5b6e introduced ordinals in the priority sequence, the "same
priority" case cannot happen anymore, furthermore the priority value in
the script is now the position of the function in the init sequence, so
if two devices have the same priority there's something real bad going
on.

Drop all the "same priority" handling code and tests, convert the case
into ane exception instead. Drop the init stubs as well from the test,
they are not required anymore.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-11-03 11:45:23 +01:00
Krzysztof Chruscinski dfb3674c4c linker: Add devnull memory for cortex_m and riscv32
Added memory region which is intended to be removed from the final
binary but may be using in byproduct to extract data used by the
host tools (e.g. strings used by logging).

Add devnull region to Cortex-M and RISCV linker scripts.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-10-27 11:42:21 +02:00
Keith Packard be4b76fea2 Kconfig.zephyr: Add NATIVE_LIBC and NATIVE_LIBCPP
These are set when building against the host C or C++ libraries. This
allows filtering tests that require use of a C library that sits atop
Zephyr OS APIs.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-10-25 08:32:06 +02:00
Fabio Baltieri 4a556a925c cmake: skip build time priority checking with armclang
The script does not play well with armclang binariest at the moment.
Disable the automatic invocation when running with armclang, at least
until this is investigated and fixed.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-09-20 20:24:46 +01:00
Fabio Baltieri 5212a4c619 scripts: check_init_priorities: use the Zephyr executable file
Rework check_init_priorities to use the main executable file instead of
the individual object files for discovering the devices.

This should make the script more robust in case of stale files in the
build directory, and also makes it work with LTO object files.

Additionally, keep track of the detected init calls, and add a handy
"-i" option to produce a human readable print of the initcalls in the
call sequence, which can be useful for debugging initialization problems
due to odd SYS_INIT and DEVICE interactions.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-09-20 20:24:46 +01:00
Fabio Baltieri 058f256ea1 Kconfig.zephyr: check priorities by default
Enable build time initialization priority check by default.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-24 15:35:37 +02:00
Daniel DeGrasse d8bdddd52f arch: arm: aarch32: introduce CONFIG_BUILD_ALIGN_LMA
Introduce CONFIG_BUILD_ALIGN_LMA. When enabled, this symbol will add a
padding section after the final read only data section in the image.
This padding section will ensure that the LMA of the data sections
follows the same alignment restrictions as the VMA does. This LMA alignment
is needed for objcopy to adjust the LMA address of the output ELF file.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-08-16 14:53:58 +02:00
Jonathan Rico cc57633447 Build system: disable OUTPUT_DISASSEMBLY by default
This on-by-default option takes the majority of "link" time.
If people need the disassembly, they can turn it on.

Incremental builds of the bluetooth tester app:

```bash
west build -b nrf52840dk_nrf52840 zephyr/tests/bluetooth/shell
touch zephyr/subsys/bluetooth/shell/bt.c
time west build -b nrf52840dk_nrf52840
```

Before:
real    0m6,621s
user    0m6,430s
sys     0m0,175s

After:
real    0m1,011s
user    0m0,840s
sys     0m0,170s

```bash
rm -rf build
time west build -p -b nrf52840dk_nrf52840 zephyr/tests/bluetooth/shell
```

Before:
real    0m9,726s
user    0m11,735s
sys     0m2,665s

After:
real    0m4,545s
user    0m8,006s
sys     0m2,723s

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-08-09 08:36:19 +00:00
Erwan Gouriou 16d9d4d1a5 Kconfig: Provide name to orphan configuration choice symbol
Kconfig choice section for LINKER_ORPHAN configuration has no name.
This prevents configuring a default value in .defconfig files and
constrain to set in _defconfig /.prj files.
Then it is not possible to generalize this setting to a whole set of
boards (soc series for instance) or make it dependent on another symbol.
Provide it a name to add this flexibility.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2023-07-27 13:59:49 +00:00
Marek Matej 6b57b3b786 soc: xtensa,riscv: esp32xx: refactor folder structure
Refactor the ESP32 target SOCs together with
all related boards. Most braking changes includes:

- changing the CONFIG_SOC_ESP32* to refer to
  the actual soc line (esp32,esp32s2,esp32s3,esp32c3)
- replacing CONFIG_SOC with the CONFIG_SOC_SERIES
- creating CONFIG_SOC_FAMILY_ESP32 to embrace all
  the ESP32 across all used architectures
- introducing CONFIG_SOC_PART_NUMBER_* to
  provide a SOC model config
- introducing the 'common' folder to hide all
  commonly used configs and files.
- updating west.yml to reflect previous changes in hal

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2023-07-25 18:12:33 +02:00
Filip Kokosinski 7388a07701 kconfig: expand the CLEANUP_INTERMEDIATE_FILES symbol description
Y-selecting CLEANUP_INTERMEDIATE_FILES negatively impacts tools/commands
that depend on the build artifacts being present. One such case is the
`west spdx` command used for Software Bill of Material generation.

If CLEANUP_INTERMEDIATE_FILES is y-selected, build files are removed from
the `cfgTarget.target.artifacts` list. This in turn causes the
`addBuildFile` function to nod add them to `pkg`, so `pkg.targetBuildFile`
is `None` in `scripts/west_commands/zspdx/walker.py`.

This commit expands the help message for the CLEANUP_INTERMEDIATE_FILES
symbol to inform the user of the possible negative impact of selecting this
symbol.

Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
2023-07-19 20:46:51 -04:00
Kevin Townsend f68cee9405 kconfig: Set BOOTLOADER_SRAM_SIZE default to 0
The current default value for `BOOTLOADER_SRAM_SIZE` is set to an
arbitrary-seeming value of `16`, which feels like a random magic
number.

Given that adding an offset in SRAM for a bootloader should always be
a conscious choice for a specific platform, this PR sets the default
to `0`. An appropriate value can be set at the SoC or board level,
overriding this default.

Signed-off-by: Kevin Townsend <kevin.townsend@linaro.org>
2023-07-17 10:13:33 +00:00
Alberto Escolar Piedras 56dc20eb1d Kconfig: Tidy up dependants of NATIVE_APPLICATION
So they depend or select on the right NATIVE_BUILD
instead of NATIVE_APPLICATION.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-05 07:01:19 -04:00
Alberto Escolar Piedras 2eb14f1469 Kconfig: Add new NATIVE_LIBRARY and NATIVE_BUILD options
To differentiate builds which will produce a native executable
as direct output from the Zephyr build,
or a library which can be used later.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-05 07:01:19 -04:00
Daniel Leung 80e78208e6 kernel: syscalls: no need to include all syscalls in binary
The syscall generation phase parses all header files to look
for potential syscalls, and emits all the relevant files to
enable syscalls. However, this results in all the syscall
marshalling functions being included in the final binary.
This is due to these functions being referred to inside
the dispatch list, resulting in ineffective garbage
collection during linking. Previous commits allows each
drivers and subsystems to specify which header files
containing syscalls are relevant. So this commit changes
the syscall generation to only include the syscalls needed
for the build in the syscall dispatch list and removing
various bits related to that. This allows the linker to
garbage collect unused syscall related function, and thus
reducing final binary size.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Marek Matej 4796746b5e soc: esp32: MCUboot support
This make MCUboot build as Zephyr application.
Providing optinal 2nd stage bootloader to the
IDF bootloader, which is used by default.
This provides more flexibility when building
and loading multiple images and aims to
brings better DX to users by using the sysbuild.
MCUboot and applications has now separate
linker scripts.

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2023-05-25 16:15:54 +02:00
Fabio Baltieri 2264c14fdf Kconfig.zephyr: add an option for checking build time init priority
Add an option for running the build time initialization priority check
as part of the build.

By default the build is going to fail if any error is reported
(dependent devices, inverted priority), optionally it can also be failed
on warnings (dependent devices, same priority).

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-05-25 15:40:07 +02:00
Carles Cufi 837245fcec mcuboot: move the MCUboot kconfig file to modules/
After the MCUboot configuration options were moved out of the main
Kconfig.zephyr they were placed in a new Kconfig.mcuboot in the root of
the repo. This is not right, and the file belongs in the modules/
folder.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-05-18 14:09:00 -04: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
Dominik Ermel 865f801470 kconfig: Separate MCUboot options to Kconfig.mcuboot
Move Kconfig options related to MCUboot to Kconfig.mcuboot

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-05-12 10:00:23 +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
Kumar Gala e268f8eb4f lib: cpp: Introduce FULL_LIBCPP_SUPPORTED similar to C version
Introduce Kconfig symbol FULL_LIBCPP_SUPPORTED that is similar to the
C version FULL_LIBC_SUPPORTED.  This way we can utilize the same
pattern in tests and samples to filter for when a full libc++ is
needed.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-05-03 10:01:05 +02:00
Keith Packard 214a3c5fa8 lib/libc: Add FULL_LIBC_SUPPORTED helper Kconfig symbol
This symbol is selected when the target has any full libc available. This
allows tests to filter on this condition. It doesn't depend on whether the
application actually selects that library, only whether requesting a full C
library would work.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-27 20:18:11 +09:00
Keith Packard 6c5d806bcb toolchain: Add COMPILER_FREESTANDING to control use of -ffreestanding
Add an explicit compiler configuration, COMPILER_FREESTANDING, which
controls whether the compiler should operate in freestanding or hosted mode
(according to the C and C++ language specifications.

This depends on having a C library which conforms with the language
specification, and the minimal C library does not. Have the minimal C
library select COMPILER_FREESTANDING to continue using freestanding mode
with that library.

For other C libraries, leave this disabled by default while allowing users
to enable it if they want to go back to the previous configuration.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-14 21:36:31 +09:00
Martin Jäger a0ffaa763c cmake: strip paths in build output based on Kconfig option
Add CONFIG_BUILD_OUTPUT_STRIP_PATHS to allow keeping absolute paths
in the build output.

This can be helpful for IDEs to detect links in a console output and
jump to the code location (e.g. when running tests in native_posix
locally).

Debuggers usually have a path mapping feature to ensure the files are
still found.

Signed-off-by: Martin Jäger <martin@libre.solar>
2023-04-04 18:02:05 +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
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
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
Henrik Brix Andersen 26ebceed55 kconfig: add note about increasing default stack sizes for -O0
Add a note about increasing default stack sizes to the
CONFIG_NO_OPTIMIZATIONS help text.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-03-22 08:10:53 -04:00
Sylvio Alves 839b97e7c5 kconfig: add esp32s3 into configuration
Add ESP32-S3 information into Espressif's Kconfig
definitions.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2023-02-27 19:41:33 +01:00
Fabio Baltieri 9b30667c77 build: drop LEGACY_INCLUDE_PATH support
LEGACY_INCLUDE_PATH has been defaulting to "n" and marked as deprecated
in both v3.2 and v3.3. Drop the option entirely for v3.4.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-02-21 15:06:48 +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
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
Guillaume Gautier 3d4232290f Kconfig.zephyr: Update UF2 ID for STM32F4 series
Update UF2 family ID for the entire STM32F4 series, except STM32F407xx
which have their own dedicated IDs.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2022-12-22 10:57:49 +01:00
Sebastian Bøe 02b83892d2 mcuboot: doc: Define MCUBOOT_EXTRA_IMGTOOL_ARGS more clearly
imgtool could be used for many things, but
CONFIG_MCUBOOT_EXTRA_IMGTOOL_ARGS, despite it's generic name, is only
applied when signing. Make it even more clear in the prompt and help
text that it's limited to signing.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2022-12-21 16:39:19 +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
Torsten Rasmussen c107827bb7 linker: correct linker script _flash_used calculation
Linker scripts contains a `.last_section` section that is placed in rom
region as NOLOAD for the purpose of retrieve the actual number of bytes
contained in the image. See d85efe0b10

However, a previous section may cause the location counter to be
incremented for alignment purposes. This can result in the size of the
image to be 0x10FA but location counter to be 0x1100 because it has been
aligned for next section placement.

Therefore, two new Kconfig settings are introduced.
Those settings request the linker to will write a pattern in
`.last_section`. Together with removing NOLOAD and writing a patten to
the section then we ensure that data is written after alignment of
location counter, and thereby forces the image size to be in sync with
the location counter.

The default pattern used will be 0xE015 (end of last section).

Some systems may fill up the flash completely, or simply write data at
the end of the flash, which in both cases can result in overflow.
Therefore, the new settings can be disabled.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-10-03 13:13:46 +00:00
Krzysztof Chruscinski 2735a3a2fa testsuite: ztress: Use XOSHIRO generator when ztress is used
Use XOSHIRO random number generator if target has entropy generator.
Some entropy generators may have limitations (e.g. only thread context)
which would conflict with ztress usage.

Added Kconfig.defconfig for testsuite.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-09-08 05:43:17 -04:00
Carles Cufi d800ccc644 blobs: Introduce TAINT and TAINT_BLOBS Kconfig options
In order to ensure that builds properly reflect the use of binary blobs,
it is important to markt the build as tainted. For that purpose
introduce two new Kconfig options that ultimately will be reflected in
the build image itself.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-29 15:57:59 +02:00
Martí Bolívar 2bc25deb07 Kconfig: fix "flag LEGACY_INCLUDE_PATH as deprecated"
Commit cd7c44a152
("Kconfig: flag LEGACY_INCLUDE_PATH as deprecated") forgot to select
DEPRECATED when deprecating a Kconfig option. Fix it.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-19 08:13:32 +00:00
Kumar Gala 52a3ec9df3 kconfig: Move Kconfig.dts sourcing earlier
Move Kconfig.dts before modules so that any of the auto generated
symbols will be available to module Kconfigs.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-17 08:06:55 +00:00
Fabio Baltieri f9447aeff6 Kconfig: flag LEGACY_INCLUDE_PATH as deprecated
Deprecate the LEGACY_INCLUDE_PATH so that it can be removed down the
road.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-08-05 13:03:54 +02:00
Fabio Baltieri 855216f582 kconfig: default to LEGACY_INCLUDE_PATH=n
Change the default config for LEGACY_INCLUDE_PATH to 'n'.

This makes any test or sample fail CI if there's any #include missing
the "zephyr/" prefix.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-08-02 16:41:41 +01:00
Torsten Rasmussen 6066ab43b3 kconfig: add support for warnings when enabling deprecated features
This adds two new Kconfig settings.

The first setting `DEPRECATED` which is a promptless symbol.
This symbol must be selected by any deprecated setting when enabled.

The second setting is `WARN_DEPRECATED` which is a user controlled
setting that configures the build system to print a warning when a
deprecated feature is enabled.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-07-15 09:53:08 -05: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
Nicolas Pitre 0a386dbe6c build: make Zephyr stdint convention enforcing configurable
There are  few cases where removing this enforcement is desirable:

- linking against binary C++ libs with incompatible type mangling

- linking against system provided headers i.e. native_posix

- compiling with legacy code that assumes a different convention

So let's create a Kconfig symbol for it. This is IMHO a good compromize
compared to using the %"PRId32" abomination everywhere otherwise.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-06-22 12:26:46 +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 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