Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within:
- `cmake/linker`
- `cmake/linker_script`
Assisted-by: Claude:claude-sonnet-5-5 codespell
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Replace SUBALIGN with ALIGN on the ITCM output section. This mirrors the
DTCM fix in commit de3deb75d4 ("fix: DTCM section alignment for DMA TCD
pool", upstream #107114, issue #107058).
SUBALIGN does not just align the start of the output section. It also
forces every input section assigned to that output section to a 4-byte
alignment boundary. This overrides any stricter or different alignment
requirements specified by the input sections themselves.
Use ALIGN instead so the ITCM output sections still start on a
4-byte boundary while preserving the original alignment requirements of
their input sections.
Signed-off-by: Tobias Aguiar <tobias.aguiarsilvadealmeida@nxp.com>
Skip the ARM-specific chosen ITCM linker group when
the chosen node is already represented through
zephyr,memory-region.
This avoids generating duplicate ITCM execution
regions under armlink for boards that model the same
memory both ways.
Assisted-by: GitHub Copilot:GPT-5.4 [apply_patch] [run_in_terminal]
Signed-off-by: Evan Chen <bugena123@gmail.com>
Add a lean, kernel-only initialization model to replace the kernel's
internal use of SYS_INIT. Kernel init order is fixed at compile time, so
these hooks drop the SYS_INIT level/priority machinery: a subsystem
registers a parameterless init function that the boot path runs at one of
two fixed phases.
K_KERNEL_INIT_PRE(fn) run in z_cstart() before PRE_KERNEL device init
K_KERNEL_INIT_POST(fn) run in bg_thread_main() before POST_KERNEL
device init
Each entry is a single function pointer placed, via an iterable section,
in the registering subsystem's own translation unit. The linker pulls
that unit (and the entry) into the image only when the subsystem is
otherwise referenced, so an init runs only when its subsystem is actually
linked. This preserves the pay-per-use linkage that SYS_INIT provided
while halving the per-entry size (one pointer versus init_entry's two) and
removing the level/priority sort. The boot-path walks reference only the
section bounds, so they never force a subsystem to be linked.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Introduce a first-class value-parameterized test mechanism (ZTEST_P)
that works like GoogleTest TEST_P / INSTANTIATE_TEST_SUITE_P:
- A test body declared with ZTEST_P is executed once per registered
parameter value; inside the body the current value is obtained
through ztest_get_current_param() / ZTEST_GET_PARAM(type).
- The suite fixture returned by setup() is passed as the 'data'
argument and is completely independent from the parameter; it is
never overwritten (root cause of the previous misuse of ZTEST_P).
New public API in ztest_test.h:
struct ztest_param_values -- describes a typed value array
struct ztest_param_inst -- links a value set to a (suite, test) pair
ZTEST_DEFINE_PARAM_VALUES(name, type, ...)
Declare a static value set from literal values.
ZTEST_DEFINE_PARAM_VALUES_ARRAY(name, array)
Declare a static value set from an existing array.
ZTEST_INSTANTIATE_TEST_SUITE_P(inst, suite, fn, values)
Register a ztest_param_inst entry in the ztest_param_inst
linker section; the runner dispatches once per value.
ztest_get_current_param() const void * current value
ZTEST_GET_PARAM_PTR(type) const type * typed pointer
ZTEST_GET_PARAM(type) type typed value
ztest_get_current_param_index() size_t zero-based index
ztest_get_current_param_size() size_t element size
ztest_has_current_param() bool is a param active?
New internals in ztest.c:
struct z_ztest_param_ctx -- per-invocation parameter context global
z_ztest_find_param_inst() -- O(n) lookup over ztest_param_inst section
z_ztest_run_test_dispatch() -- per-test dispatch; loops over values
The fixture-overwrite path ("if (param != NULL) { data = param; }")
is removed; the legacy 'param' argument of z_ztest_run_test_suite
and related internal functions is kept for ABI compatibility but
marked ARG_UNUSED.
The linker script gains Z_LINK_ITERABLE(ztest_param_inst) so the
start/end symbols required by STRUCT_SECTION_FOREACH are emitted.
Assisted-by: GitHub Copilot:claude-sonnet-4-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
When `CONFIG_NULL_POINTER_EXCEPTION_DETECTION_MPU` is enabled,
the null-pointer region `[0x0, PAGE_SIZE)` must not contain
executable code.
The legacy linker flow enforces this via `vector_table_pad.ld`,
but the CMake linker generator does not, allowing `.text` to
start immediately after the vector table (e.g. at `0x3e0`),
inside the protected region. This leads to MPU faults at boot.
Fix by giving `.rom_start` a minimum size up to
`CONFIG_CORTEX_M_NULL_POINTER_EXCEPTION_PAGE_SIZE` when the vector table
starts inside the protected null-pointer page, ensuring `.text` starts
outside the reserved region.
Signed-off-by: Sudan Landge <sudan.landge@arm.com>
Change DTCM sections from SUBALIGN(4) to ALIGN(4) to allow individual
objects within these sections to maintain their own alignment requirements.
This fixes the DMA TCD pool alignment regression where the 32-byte
aligned dma_tcdpool was being placed at 4-byte aligned addresses,
causing assertion failures in EDMA_TcdSetTransferConfig.
Fixes: #107058
Signed-off-by: Stefan Giroux <stefan.g@feniex.com>
Fix the early TLS initialization sequence on RISC-V to correctly set up
the thread pointer (tp) before any C code runs, and save/restore
callee-saved registers as required by the ABI.
Signed-off-by: Mayur Salve <msalve@qti.qualcomm.com>
If CONFIG_ROMSTART_RELOCATION is enabled, create a *separate* load/exec
memory region for the vector table. This must be separate for armlink,
otherwise moving .rom_start changes the LR base and drags .text with it.
Signed-off-by: Sudan Landge <sudan.landge@arm.com>
Commit 388725870f introduced thread-local
storage support for the ARM Cortex-M architecture. As part of this commit,
".TEXT.*" was added as input pattern for the `text` output section in the
Cortex-M architecture linker script, even though such a pattern is not
found in any other architecture.
I suspect this was done as a workaround for a bug in the very same commit:
a missing `#include` in __aeabi_read_tp.S results in the eponymous function
being placed in section `.TEXT.__aeabi_read_tp` (notice uppercase) instead
of `.text.__aeabi_read_tp`, which would trigger an "orphan section" linker
warning without the modified linker script. Over time, this workaround has
unfortunately allowed the same bug to appear in at least another file...
Realign Cortex-M with all other architectures and stop accepting ".TEXT.*"
as valid input section name for the `text` output section. This can be done
safely since all non-compliant code (in tree) has been fixed.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Added missing section k_timer_observer to linker file generator, to fix
missing section definitions for IAR linker.
Signed-off-by: Lars-Ove Karlsson <lars-ove.karlsson@iar.com>
Instead of mirroring the ld linker script, the CMake Linker Generator for
ARM was placing the IDT_LIST region right after the Zephyr SRAM. While this
may work fine in most cases, this scheme leads to build errors on some SoCs
such as STM32WBxx, where there are multiple RAM banks that are contiguous
but split over multiple `zephyr,memory-region`s: in such scenarios, the
IDT_LIST region will overlap with one of these `zephyr,memory-region` and
cause a build failure.
Mimic the IDT_LIST placement found in ld linker script to avoid this issue,
except that the region start address is aligned: 0xFFFF8000 instead of
0xFFFF7FFF. This is required by `gen_isr_tables.py` which otherwise errors
out due to finding one more byte than expected in the .intList section.
(The exact reason is not clear, but aligning the region fixes the issue)
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
The zephyrproject-rtos#91219 missed some entries when doing the clean-up.
This removes some of remaining SUBALIGN entries in the iterable sections.
Fixes CMake Warning:
zephyr_linker_section(NAME ...) given unknown arguments: SUBALIGN 4
Signed-off-by: Joel Schaller <joel.schaller16@gmail.com>
Commit eff5d02872 added
`net_socket_service_desc` to common-rom ld snippet but not to common-rom
CMake linker generator equivalent.
Bring common-rom.cmake up-to-date to ensure `net_socket_service_desc`
works correctly with the linker generator.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Introduce a streaming APIs for ADC devices.
Two new APIs are added to the adc_driver_api: submit and get_decoder.
Added decoder following APIs: get_frame_count, get_size_info, decode,
has_trigger.
Supported triggers are:
- ADC_TRIG_DATA_READY
- ADC_TRIG_FIFO_WATERMARK
- ADC_TRIG_FIFO_FULL
Supported operations to be done on trigger:
- include - whatever data is associated with the trigger
- nop - do nothing with data associated with the trigger
- drop - clear data associated with the trigger
Some changes to the linker scripts were needed to add decoder APIs.
Signed-off-by: Vladislav Pejic <vladislav.pejic@orioninc.com>
Do not use private API prefix and move to architecture interface as
those functions are primarily used across arches and can be defined by
the architecture.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit introduces the SRAM_SW_ISR_TABLE option which is selected by
DYNAMIC_INTERRUPT. It allows splitting the DYNAMIC_INTERRUPT option into
two parts:
- One for the relocation of the ISR vector table in RAM
- One for the inclusion of functions needed to install ISRs dynamically
The goal is to later only select the relocation of the ISR vector table in
RAM and not all the associated functions from the dynamic interrupt
mechanism.
Signed-off-by: Martin Hoff <martin.hoff@silabs.com>
Incorporate the basic RTK API as well as a basic client integration
(serial) as a way to receive and publish the RTK data.
Signed-off-by: Luis Ubieda <luisf@croxel.com>
The #91219 miss some entries when doing the clean-up. This removes
some of remaining SUBALIGN entries in the iterable sections. It do
not consider SECTION_PROLOGUE and zephyr_linker_section entries.
Fixes#92349
Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
struct init_entry may point to a struct device or a struct service,
each ones belonging to device or service iterable section.
Service section being newly added, handling it in cmake relevantly.
Signed-off-by: Tomasz Bursztyka <tobu@bang-olufsen.dk>
This makes c++ sample
`sample.libraries.hash_map.newlib.cxx_unordered_map.djb2`
start working on gcc w. `CMAKE_LINKER_GENERATOR=y`.
Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
SUBALIGN forces alignment to the specified value, even if the object
requires stricter alignment. This causes mis-aligned access when accessing
the resulting value.
Signed-off-by: Keith Packard <keithp@keithp.com>
If this section is placed in FLASH, the section gets marked
as writable even though .tbss values will never be stored there.
Signed-off-by: Keith Packard <keithp@keithp.com>
Add cmake linker generator things for .last_section.
Follow up to #88970. Fixes bug #89719, for gcc/ld & iar
Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
Instead of obscure linker-file hacks providing dummy definitions before
we have the proper generated k-object lookup functions, provide weak
definitions that will be taken out by the real generated implementations
when they are available.
Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
Remove usage of ld-specific ADDR function within the cmake linker
generator scripting. Since the linker generator scripting doesn't
support MPUs, we can simply set the __ramfunc_region_start symbol to be
equal to __ramfunc_start
Fixes#87200
Signed-off-by: Daniel DeGrasse <ddegrasse@tenstorrent.com>
Introduce a new video device structure representing a device in a
video pipeline. Each video device embeds a pointer to its "source"
device and other "video" characteristics.
This structure give the video framework an access to all video features
of the device and a hierachical view of the video pipeline that the
device belongs to.
Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
All in all this makes cmake linker generator able to work for at least
most of the kernel tests and samples, on cortex m4.
Make the cmake linker generator have a file-structure more similar to
the ld-skeletons.
Add or edit groups, sections and logic to make the generator reflect
what the ld-skeletons do, esp. for kobjects and APP_SMEM, nonint and
some other details are also effected.
Use the new zephyr_linker_include_generated() and
zephyr_linker_include_var() functions to to handle
${DEVICE_API_LINKER_SECTIONS_CMAKE}, the kobject-prebuilt-*.h files and
APP_SMEM partition. Essentially the output from gen_app_partitions.py,
gen_kobject_placeholders.py.
Add ALIGN_WITH_INPUT on sections being put into DATA_REGION. This makes
the init layout work for ld.
This leverages the updates in gen_app_partitions.py to generate its
output as cmake linker generator sections too, and puts them into a
group defined in linker.cmake
Setup generator variables for alignment of APP_SMEM. Note that this does
not yet handle MPU_ALIGN which depends on the size of the section...
Fix broken k_object_assignment iterable section
Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
In the linker script generator there was one error checking
construct that used regexp and that ended up in the generated
linker file, which caused parsing problems with the IAR
linker. It was unnecessary. Also updated
common-rom-kernel-devices.ld.
Signed-off-by: Lars-Ove Karlsson <lars-ove.karlsson@iar.com>
Introduce a new field to store device flags. Only device deferred init
flag has been added, replacing usage of linker hackery to know wether a
device requires initialization at boot time or not. This change will be
helpful in the near future as devices will become reference counted, so we
will need to know wether they have been initialized or not.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
It seems ZTEST has been moved to ROM in
86cadf9 and this keeps linker generator
up to date. It is also causing some
issues with IAR toolchain where pbits
are being placed in RAM.
Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
Allow user to specify protocol extensions when receiving data
from Ethernet network. This means that user can register L3
protocol handler using NET_L3_REGISTER() with the desired
protocol type. Ethernet code will then call the handler if
such a protocol type packet is received. This is currently
only implemented for Ethernet. The original IPv4 and IPv6
handling is left intact even if they can be considered to
be L3 layer protocol. This could be changed in the future
if needed so that IPv4 and IPv6 handling could be made
pluggable protocols.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add `zephyr,memory-region-flags` for supporting memory region flags
setting.
For example, when the below node is in the devicetree,
```
test_sram: sram@20010000 {
compatible = "zephyr,memory-region", "mmio-sram";
reg = < 0x20010000 0x1000 >;
zephyr,memory-region = "FOOBAR";
zephyr,memory-region-flags = "rw";
};
```
We get the following line in MEMORY section of linker script.
```
FOOBAR (rw) : ORIGIN = (0x20010000), LENGTH = (0x1000)
```
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
CMAKE_LINKER_GENERATOR common-ram.cmake is out of date.
This updates it to keep it up to date with common-ram.ld
Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
ramfunc region is copied into RAM from FLASH region during XIP init. We
copy from the loadaddr of the region, and were previously loading to the
symbol __ramfunc_start. This is incorrect when using an MPU with
alignment requirements, as the __ramfunc_start symbol may have padding
placed before it in the region. The __ramfunc_start symbol still needs
to be aligned in order to be used by the MPU though, so define a new
symbol __ramfunc_region_start, and use that symbol when copying the
__ramfunc region from FLASH to RAM.
Fixes#75296
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Evaluate CONFIG_LINKER_ITERABLE_SUBALIGN in CMake instead of in the
linker script.
It cannot be assumed that a linker generator implementation is
pre-processed and therefore Kconfig settings cannot be used in those
but must be evaluated in CMake.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Introduce core support for ARM's SCMI (System Control and
Management Interface). This includes:
* shared memory (SHMEM) driver. This consists of a suite
of functions used to interact with the shared memory area.
* shared memory and doorbell-based transport layer driver.
Data is passed between platform and agent via shared
memory. Signaling is done using polling (PRE_KERNEL) and
doorbells (POST_KERNEL). This makes use of Zephyr MBOX API
(for signaling purposes) and the SHMEM driver (for polling
and data transfer).
* core driver - acts as glue between transport and protocol
layers. Provides synchronized access to transport layer
channels and channel assignment/initialization.
* infrastructure for creating SCMI protocols
This is based on ARM's SCMI Platform Design Document: DEN0056E.
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>