Due to the new changes for the subsys/app_memory we need to
have the script for smem run before any elf is created.
This is needed because the compiled code will have references to
certain linker variables that will be created by
gen_app_partitions.py.
Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
The scripts for app_smem need to be ready before the script for
privilaged stack is run. This is needed because there is a small
possibility that the stacks get aligned (due to app_smem)
after privilaged stack script is run. This causes the gperf
to create an incorrect hash.
Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
When checking availability of soc/${ARCH}/CMakeLists.txt,
we should use ${ZEPHYR_BASE} as path base.
Fixes#9956
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This rewrites the implementation of the APP_INPUT_SECTION and
KERNEL_INPUT_SECTION macros such that an unbounded amount of
kernelspace libraries can be used.
This resolves#7703
The new implementation has a caveat/limitation; the linker script
developer must invoke APP_INPUT_SECTION before KERNEL_INPUT_SECTION.
All in-tree linker scripts happened to already be doing this so no
in-tree porting was necessary.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
This feature was failing on a default ARM core MPU. The linker
script that was getting created was not able to align the required
partitions at prebuilt time.
The old implementation relied on the prebuilt to finish then
extract the size information which was then used to align the regions.
This fails because the size of the alignment and the fill in the
linker needs to be available at prebuilt time else it cant manage
the final elf file generation. We cant have 2 different sizes of
prebuilt and final elf file.
This implementation will get the alignment requirements met at
prebuilt time.
Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
Remove the usage of --start-group and --end-group. Perhaps it had a
function previously, but as it is used here it has no effect.
--start-group and --end-group is used to designate that a set of libs
should be searched repeatedly until all unresolved references among
them are resolved. From the documentation:
--start-group archives --end-group
The specified archives are searched repeatedly until no
new undefined references are created. Normally, an
archive is searched only once in the order that it is
specified on the command line. If a symbol in that
archive is needed to resolve an undefined symbol
referred to by an object in an archive that appears
later on the command line, the linker would not be able
to resolve that reference. By grouping the archives,
they all be searched repeatedly until all possible
references are resolved.
Using this option has a significant performance cost.
It is best to use it only when there are unavoidable
circular references between two or more archives.
Currently it is used on the 'ZEPHYR_LIBS_PROPERTY' libs, but this has
no effect, because they are being --whole-archive'd anyway. It is also
used on 'kernel' and 'OFFSETS_O_PATH'. But these libraries have no
circular references, so this has no effect either.
Consequently, removing these two flags is expected to simplify the
link command line and have no adverse effects.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
There's no particularly good reason to have one kind of
output from this script to be sent to stdout instead of
a filename specified by parameter, and it makes it
annoying to add debug print() statements.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Summary: revised attempt at addressing issue 6290. The
following provides an alternative to using
CONFIG_APPLICATION_MEMORY by compartmentalizing data into
Memory Domains. Dependent on MPU limitations, supports
compartmentalized Memory Domains for 1...N logical
applications. This is considered an initial attempt at
designing flexible compartmentalized Memory Domains for
multiple logical applications and, with the provided python
script and edited CMakeLists.txt, provides support for power
of 2 aligned MPU architectures.
Overview: The current patch uses qualifiers to group data into
subsections. The qualifier usage allows for dynamic subsection
creation and affords the developer a large amount of flexibility
in the grouping, naming, and size of the resulting partitions and
domains that are built on these subsections. By additional macro
calls, functions are created that help calculate the size,
address, and permissions for the subsections and enable the
developer to control application data in specified partitions and
memory domains.
Background: Initial attempts focused on creating a single
section in the linker script that then contained internally
grouped variables/data to allow MPU/MMU alignment and protection.
This did not provide additional functionality beyond
CONFIG_APPLICATION_MEMORY as we were unable to reliably group
data or determine their grouping via exported linker symbols.
Thus, the resulting decision was made to dynamically create
subsections using the current qualifier method. An attempt to
group the data by object file was tested, but found that this
broke applications such as ztest where two object files are
created: ztest and main. This also creates an issue of grouping
the two object files together in the same memory domain while
also allowing for compartmenting other data among threads.
Because it is not possible to know a) the name of the partition
and thus the symbol in the linker, b) the size of all the data
in the subsection, nor c) the overall number of partitions
created by the developer, it was not feasible to align the
subsections at compile time without using dynamically generated
linker script for MPU architectures requiring power of 2
alignment.
In order to provide support for MPU architectures that require a
power of 2 alignment, a python script is run at build prior to
when linker_priv_stacks.cmd is generated. This script scans the
built object files for all possible partitions and the names given
to them. It then generates a linker file (app_smem.ld) that is
included in the main linker.ld file. This app_smem.ld allows the
compiler and linker to then create each subsection and align to
the next power of 2.
Usage:
- Requires: app_memory/app_memdomain.h .
- _app_dmem(id) marks a variable to be placed into a data
section for memory partition id.
- _app_bmem(id) marks a variable to be placed into a bss
section for memory partition id.
- These are seen in the linker.map as "data_smem_id" and
"data_smem_idb".
- To create a k_mem_partition, call the macro
app_mem_partition(part0) where "part0" is the name then used to
refer to that partition. This macro only creates a function and
necessary data structures for the later "initialization".
- To create a memory domain for the partition, the macro
app_mem_domain(dom0) is called where "dom0" is the name then
used for the memory domain.
- To initialize the partition (effectively adding the partition
to a linked list), init_part_part0() is called. This is followed
by init_app_memory(), which walks all partitions in the linked
list and calculates the sizes for each partition.
- Once the partition is initialized, the domain can be
initialized with init_domain_dom0(part0) which initializes the
domain with partition part0.
- After the domain has been initialized, the current thread
can be added using add_thread_dom0(k_current_get()).
- The code used in ztests ans kernel/init has been added under
a conditional #ifdef to isolate the code from other tests.
The userspace test CMakeLists.txt file has commands to insert
the CONFIG_APP_SHARED_MEM definition into the required build
targets.
Example:
/* create partition at top of file outside functions */
app_mem_partition(part0);
/* create domain */
app_mem_domain(dom0);
_app_dmem(dom0) int var1;
_app_bmem(dom0) static volatile int var2;
int main()
{
init_part_part0();
init_app_memory();
init_domain_dom0(part0);
add_thread_dom0(k_current_get());
...
}
- If multiple partitions are being created, a variadic
preprocessor macro can be used as provided in
app_macro_support.h:
FOR_EACH(app_mem_partition, part0, part1, part2);
or, for multiple domains, similarly:
FOR_EACH(app_mem_domain, dom0, dom1);
Similarly, the init_part_* can also be used in the macro:
FOR_EACH(init_part, part0, part1, part2);
Testing:
- This has been successfully tested on qemu_x86 and the
ARM frdm_k64f board. It compiles and builds power of 2
aligned subsections for the linker script on the 96b_carbon
boards. These power of 2 alignments have been checked by
hand and are viewable in the zephyr.map file that is
produced during build. However, due to a shortage of
available MPU regions on the 96b_carbon board, we are unable
to test this.
- When run on the 96b_carbon board, the test suite will
enter execution, but each individaul test will fail due to
an MPU FAULT. This is expected as the required number of
MPU regions exceeds the number allowed due to the static
allocation. As the MPU driver does not detect this issue,
the fault occurs because the data being accessed has been
placed outside the active MPU region.
- This now compiles successfully for the ARC boards
em_starterkit_em7d and em_starterkit_em7d_v22. However,
as we lack ARC hardware to run this build on, we are unable
to test this build.
Current known issues:
1) While the script and edited CMakeLists.txt creates the
ability to align to the next power of 2, this does not
address the shortage of available MPU regions on certain
devices (e.g. 96b_carbon). In testing the APB and PPB
regions were commented out.
2) checkpatch.pl lists several issues regarding the
following:
a) Complex macros. The FOR_EACH macros as defined in
app_macro_support.h are listed as complex macros needing
parentheses. Adding parentheses breaks their
functionality, and we have otherwise been unable to
resolve the reported error.
b) __aligned() preferred. The _app_dmem_pad() and
_app_bmem_pad() macros give warnings that __aligned()
is preferred. Prior iterations had this implementation,
which resulted in errors due to "complex macros".
c) Trailing semicolon. The macro init_part(name) has
a trailing semicolon as the semicolon is needed for the
inlined macro call that is generated when this macro
expands.
Update: updated to alternative CONFIG_APPLCATION_MEMORY.
Added config option CONFIG_APP_SHARED_MEM to enable a new section
app_smem to contain the shared memory component. This commit
seperates the Kconfig definition from the definition used for the
conditional code. The change is in response to changes in the
way the build system treats definitions. The python script used
to generate a linker script for app_smem was also midified to
simplify the alignment directives. A default linker script
app_smem.ld was added to remove the conditional includes dependency
on CONFIG_APP_SHARED_MEM. By addining the default linker script
the prebuild stages link properly prior to the python script running
Signed-off-by: Joshua Domagalski <jedomag@tycho.nsa.gov>
Signed-off-by: Shawn Mosley <smmosle@tycho.nsa.gov>
When compiling for native, some glibc versions has a check on the
use of _FORTIFY_SOURCE without optimizations enabled and gives a
preprocessor warning.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Add "gap-fill 0xFF" option for the CMAKE_OBJCOPY command,
in order to reduce the flash programming time for some boards,
such as cc2650.
Signed-off-by: Walter Xie <41377148@qq.com>
Previously the syscall list was generated only from the include
folder. This is a limitation when the application tries to create
system calls. This patch create a simple way to include these
new syscalls without the application touching the kernel.
This can be enabled by a Kconfig CONFIG_APPLICATION_DEFINED_SYSCALL.
Once enabled the application source directory will be scanned to
find all application defined syscalls.
Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
The entry point can and therefore should be set by linker
scripts. Whenever possible one should express things in the source
language, be it .c or .ld, and not in code generators or in the build
system.
This patch removes the flag -eCONFIG_KERNEL_ENTRY from the linker's
command line and replaces it with the linker script command
ENTRY(CONFIG_KERNEL_ENTRY)
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Add an LLVM backend and a clang toolchain variant to support building
with llvm coming with popular Linux distributions.
This has been tested with X86 boards:
- quark_d2000_crb
- quark_se_c1000_devboard/Arduino 101
Use:
export ZEPHYR_TOOLCHAIN_VARIANT=clang
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Python scripts should be executed indirectly by the python
interpreter, not directly in a CMake COMMAND. This is for portability
reasons.
Directly executing a python script depends on non-portable shebang
logic and/or "default application" behaviour.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Fixes: #8380
This commit fixes the side-effect of PR #8211 where a 'ninja clean'
would try to remove dependency folders.
Changes:
- Symlinks are created during build and CMake targets now depends on
the symlinks. Thus, same behavior is achived with regards to
dependency handling, while at the same time, the output can be
cleaned as the dependencies are now attached to the symlinks.
- Dependencies have been changed so that generation of json files
depends on the trigger file and CMake depends upon the subdir txt
file. This prevents additional CMake runs after a clean.
Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
Both variables were used (with the same value) interchangeably
throughout CMake files and per the discussion in GH issue,
ZEPHYR_BASE is preferred.
Also add a comment with explanation of one vs. the other.
Tested by building hello_world for several boards ensuring no errors.
Fixes#7173.
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Zephyr currently allows users to choose a compiler optimization
between -O0, -Og and -Os, the default being the latter as it offers a
good compromise between speed and flash usage. In cases the speed
matters and/or the flash usage doesn't, optimizing for speed with -O2
is another alternative. For example in case of a simple application
doing cryptographic signature validation with mbedtls, the flash size
increase by about 15% compared to -Os, while it provides a 15% speed
boost for a RSA signature and 30% speed boost for a ECC signature.
This patches therefore adds a new option CONFIG_SPEED_OPTIMIZATIONS
corresponding to the -O2 flag, but keep the default set to
CONFIG_SIZE_OPTIMIZATIONS.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
It is currently not possible to define multiple compiler options using
the CONFIG_COMPILER_OPT Kconfig option. The string is interpreted as a
single quoted option, for example "-opt1 -opt2".
This patch fixes that by splitting the CONFIG_COMPILER_OPT string into
multiple options using the separate_arguments cmake function.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Fixes: #8210
Following changes has been made to ensure correct behavior on different
system:
- Python script to detect changes to directories, including empty ones.
When files are modified the list is updated
If sub-directories are added / removed a trigger file is touched to
notify cmake to re-run
- Windows: To detect changes to header files in include for
parse_syscalls.py all files must be individual monitored.
Hence all headers are globbed added to dependencies.
CMake configure depends on the folders so the added /
removed files are picked up.
- Other: Folders are monitored through the python list file so that
added / remove / modified
Added / removed sub-directories are detected through trigger
file in order to re-run cmake.
Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
Fixes: #8210
This commit removes the need for always rebuild when generating the
syscalls.json.
It find the files and subfolders of the include directory and makes
syscalls depends on those.
To find added files / subfolders on all platforms CMake configure
is also depending on the folders found.
This ensures that added files / folders will also be detected at later
stages.
Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
Users are sometimes mistakenly invoking cmake with $ZEPHYR_BASE set as
the source directory.
This user-error can occur if the user believes that the toplevel
CMakeLists.txt file is at the root of the repo, or if the user uses
the wrong path when invoking cmake.
The error given when this user-error occurs is cryptic and undefined,
so we replace it with what should be an easy-to-understand error
message.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
This commit provides a minor fix to a CMake output text which
warns the user that ASSERT() statements are enabled.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
We haven't ever really had a Kconfig symbol to enable the support
related to DEBUG_SECTION_MISMATCH. Thus this isn't really used by
anyone and we will remove it.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This patch fixes the dependency chain for priviliged stack
generation. This fixes a problem when compiling after making
significant changes that would shift the privileged stack area.
Signed-off-by: Andy Gross <andy.gross@linaro.org>
This patchset provides Xtensa's xcc compiler support for Xtensa
projects in Cmake. This requires the below environment variables
to be defined aptly. The appropriate xcc license information also
need to be supplied.
ZEPHYR_GCC_VARIANT=xcc
TOOLCHAIN_VER=RF-2015.3-linux
XTENSA_CORE=cavs21_LX6HiFi3_RF3_WB16
XTENSA_SYSTEM=/opt/xtensa/XtDevTools/install/tools/
RF-2015.3-linux/XtensaTools/config/
XTENSA_BUILD_PATHS=/opt/xtensa/XtDevTools/install/builds/
Change-Id: Ib3c10e8095439b0e32276ff37c00eca8420773ec
Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This reverts commit d9ac1d4b4a.
This option can be compiler specific and is not required anymore.
Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit ports nearly all usage of check_c_compiler_flag,
check_cxx_compiler_flag, and check_compiler_flag to use
zephyr_check_compiler_flag instead.
This has a significant CMake configure-time performance impact.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Adding a new kernel object type or driver subsystem requires changes
in various different places. This patch makes it easier to create
those devices by generating as much as possible in compile time.
No behavior change.
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
Driver APIs might not implement all operations, making it possible for
a user thread to get the kernel to execute a function at 0x00000000.
Perform runtime checks in all the driver handlers, checking if they're
capable of performing the requested operation.
Fixes#6907.
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
This is required to have BUILD_ASSERT() from toolchain/common.h to
work without issuing a warning.
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
Specifying a custom linker script is supposed to be supported through
Kconfig, but evidently this has been unused and 100% broken at least
since the CMake migration.
This commit fixes
https://github.com/zephyrproject-rtos/zephyr/issues/6983
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
This uses the version and hash (git describe) and replaces the timestamp
currently used in the boot banner. This works much better than using
timestamps. It lets us point to the exact commit being used to run a
certain application or test.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Moving the ccache build script earlier in allows us to export ccache
to external projects. Using ccache with external projects, such as
OpenThread, can significantly speed up the build time.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
We need access to SOC_PATH in dts.cmake so we need to move the
definitions of SOC_NAME, SOC_SERIES, SOC_FAMILY, and SOC_PATH out of the
toplevel CMakeLists.txt and into cmake/app/boilerplate.cmake. We place
them before we include cmake/dts.cmake so they will be available to use
in it.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This patch adds an additional constraint to make sure that we only
do the application memory sizing if it is really necessary.
Signed-off-by: Andy Gross <andy.gross@linaro.org>
We want to support other toolchain not based on GCC, so the variable is
confusing, use ZEPHYR_TOOLCHAIN_VARIANT instead.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
To enable using application-defined sections in linker scripts, the
application source directory must be included in the search path when
running the preprocessor to generate linker scripts.
This prevents build failures when using any of the configuration options
CONFIG_CUSTOM_RODATA_LD, CONFIG_CUSTOM_RWDATA_LD and
CONFIG_CUSTOM_SECTIONS_LD.
Signed-off-by: Kristian Klomsten Skordal <kristian.skordal@nordicsemi.no>
In a scenario where a platform harbours multiple interrupts to the
extent the core cannot support it, an interrupt controller is added
as an additional level of interrupt. It typically combines several
sources of interrupt into one line that is then routed to the parent
controller.
Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
This patch adds the generation and incorporation of privileged stack
regions that are used by ARM user mode threads. This patch adds the
infrastructure for privileged stacks. Later patches will utilize the
generated stacks and helper functions.
Signed-off-by: Chunlin Han <chunlin.han@linaro.org>
Signed-off-by: Andy Gross <andy.gross@linaro.org>
This patch adds application data section alignment constraints
to match the region definition requirements for ARM MPUs. Most MPUs
require a minimum of 32 bytes of alignment for any regions, but some
require power of two alignment to the size of a region.
This requires that the linker align the application data section to
the size of the section. This requires a linker pass to determine the
size. Once this is accomplished the correct value is added to a linker
include file that is utilized in subsequent linker operations.
Signed-off-by: Andy Gross <andy.gross@linaro.org>
This patch changes the way the custom linker function works. It uses
names instead of numbers to denote the name of the file and applies
the correct LINKER_PASS variable for the final linker pass.
Signed-off-by: Andy Gross <andy.gross@linaro.org>
We need to allocate extra memory region for the hash function
that the gperf generates. The linker will need to maintain
the same location counter between multiple linker stages. Reserving
memory will help in maintaing correct location counters between
multiple stages. The required memory varies with optimization level.
In order to keep the size of the compiled object consistent,
the kobject_hash.c is always compiled with -Os.
fixes#5226
Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
This patch does several things, most notably it changes the semantics
of CONFIG_DEBUG. CONFIG_DEBUG continues to behave as a vaguely defined
"debug mode" that enables printf's, -Og, etc. but now the user may
choose to be in "debug mode" while using a different optimization
level than -Og.
Tp support this a new config is defined to enable -Og;
CONFIG_DEBUG_OPTIMIZATIONS.
Additionally CONFIG_SIZE_OPTIMIZATIONS is introduced to allow the user
to explicitly request optimizing for size instead of relying on
defaulting to it.
The three config's {NO,SIZE,DEBUG}_OPTIMIZATIONS are now organized in
a Kconfig choice to ensure that at most one can be enabled at a time.
Finally, selected users of CONFIG_DEBUG have been ported to use one of
the optimizations configs when it was clear from usage that the
intention was to behave differently when using a different
optimization level and not when in "debug mode".
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Added a new config option which lowers the compiler
optimizations to -O0 independently of other flags.
CONFIG_COVERAGE uses it now instead of having its own
choice in CMakeLists.txt
Fixes#5720
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
CMake's custom_command support is not great. It is technically
supported, but it is not easy to get it right.
As explained in "5. File-level dependencies of custom targets are not
propagated" from http://bit.ly/2GvwwEy. When a custom_command uses a
custom_target as input, the custom_command must DEPEND on both the
custom_target and the underlying file.
Longterm we need to do something more sofisticated to prevent these
issues from popping up. Like add some static analysis to detect badly
written CMake code or introduce an abstraction for custom commands
that is not affect by this issue.
This fixes#5881
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>