The C language does reserve the following identifiers starting with:
- two underscores
- an underscore followed by an uppercase letter
- a single underscore at the file scope
These are reserved for internal use by the compiler or implementation.
While not likely to ever actually conflict update the include guard macros
to not be in violation of the reserved naming and bring it inline with the
already established pattern for the Zephyr SOC headers.
Signed-off-by: Dan Kalowsky <dkalowsk@qti.qualcomm.com>
The light sleep exit hook unmasked interrupts before the kernel
accounted the slept ticks. A wake ISR that armed a timeout could
then preempt the idle-exit announce with a stale alarm and drop
the rest of the sleep from the kernel clock.
Fix it by keeping interrupts masked in the exit hook and no
longer selecting PM_STATE_SET_IRQ_UNLOCKED, so the idle thread
unmasks them after the slept ticks are announced. On Xtensa the
exit hook still restores the INTENABLE register saved before
sleep.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
CONFIG_ESP_CONSOLE_UART_NUM default value is `-1`. This value will
not change when USB CDC ACM UART is used, for instance.
Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
An earlier esp_timer alarm is also an RTC timer wake, so closing the
window on every timer wake ends the kernel wait too soon. Keep the
kernel budget from the first fragment, and close on a timer wake only
when that fragment still reaches it.
Assisted-by: Grok:4.7
Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
Light sleep takes its duration from the kernel timeout alone, so an
alarm armed by the Bluetooth controller or Wi-Fi can expire while the
CPU is asleep. Limit the sleep to the next esp_timer alarm, and skip
it when that alarm is already due. Idle enters sleep again after the
callback has run.
Use the kernel timeout for the deep sleep wake. The shortened time
would otherwise wake deep sleep at the next esp_timer alarm, or leave
it unable to wake when that alarm is already due.
Snapshot the low-power counter after the alarm lookup, so that time
is not counted as missed sleep. If the alarm is too short to sleep,
wait for it instead of retrying suspend.
Assisted-by: Grok:4.7
Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
the riscv mashine timer inside this SoC is normally driven by a
external 32768 Hz watch crystal oscillator. All in-tree
boards have that external oscillator and it is also
the value that qemu assumes for the sifive_e board.
Before 07e4ba4240
32768 already was the default value, but got changed there
without reason.
In the manual of the SoC, in the chapter describing the RTC,
it is recommended to use an external 32768 Hz watch crystal oscillator
for the low-frequency clock source. And as the machine timer is driven
by the same clock, it makes sense to set SYS_CLOCK_HW_CYCLES_PER_SEC
accordingly. When the external oscillator not present a internal
oscillator is used instead, which target frequency is ~ 32kHz.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
PM selected UART_INTERRUPT_DRIVEN unconditionally, so disabling serial
creates Kconfig errors because that symbol depends on
SERIAL_SUPPORT_INTERRUPT.
Signed-off-by: Martin Hoff <martin.hoff@silabs.com>
Updating soc.yml to include new psoc6 devices added in the
previous commit. Build tested each with Hello World.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Zayne Stites <Zayne.Stites@infineon.com>
The ke1xz core and bus clocks derive from the LPFLL, which was left
free-running (trimConfig = NULL). A free-running LPFLL only has a
few-percent accuracy, so any clock derived from it is off by that
much. On frdm_ke17z512 this surfaced as a PWM capture failure: the
PWT capture timer is clocked from the LPFLL-derived bus clock while
the FTM generates its waveform from the 8 MHz crystal (SOSC), so the
tests/drivers/pwm/pwm_loopback accuracy subtests measured the period
~2.9% off and exceeded their +/-1% tolerance. The 96 MHz LPFLL range
used by ke17z512 is where the error is largest; the other ke1xz
boards run the 72 MHz range and happen to stay within tolerance, but
the inaccuracy is latent on all of them.
Trim (closed-loop lock) the LPFLL against the SOSC crystal whenever
the SOSC is enabled, so the LPFLL and every clock derived from it
become as accurate as the crystal. The trim reference is predivided
to 2 MHz as the hardware requires. When no SOSC is present the LPFLL
stays free-running exactly as before.
Verified on frdm_ke17z512 (J-Link, PTB14/J3-11 -> PTE11/J2-11
loopback): tests/drivers/pwm/pwm_loopback now reports SUITE PASS
100% (pass=6, fail=0, skip=3) across 6 consecutive runs. frdm_ke17z
and the other SOSC-enabled ke1xz boards build clean.
Assisted-by: Vero-Coder:claude-opus-4-8
Signed-off-by: Holt Sun <holt.sun@nxp.com>
If a wake-up source is high while z_sys_poweroff() clears WUF, it can
mask later wake-up events, and the MCU may never leave Standby (ES0206
2.2.4). Clear WUF with the WKUP pins disabled, as the erratum
workaround describes. A WKUP pin that is still high then sets WUF again
when it is re-enabled, so the device leaves Standby at once instead.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: YunHung Hua <oliverhua.us@gmail.com>
Default RISCV_VECTORED_MODE to enabled when GEN_IRQ_VECTOR_TABLE is
enabled, rather than selecting it.
This allows platforms with a custom vectored interrupt implementation to
disable the standard RISC-V mtvec optional vectored mode while keeping
the existing behavior by default.
For example, AE350 supports the RISC-V privileged architecture but not
the optional mtvec vectored mode, and may use the Andes Vectored PLIC
extension instead.
Signed-off-by: Jimmy Zheng <jimmyzhe@andestech.com>
This adds the necessary bits to enable running LLEXT tests
against board qemu/xtensa/sample_controller32/mpu.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
ESP32-P4 below v3 cannot power down the CPU domain on its own. Disable
ESP32_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP by default on rev 1.3.
Peripheral power down still selects it, because powering down TOP
needs CPU retention. Add flash power down config.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
With peripheral power down enabled, the clock ICG retention entries
gate the flash clocks during the sleep backup, before the SPI memory
registers are saved. The backup then holds zeros, the flash controller
is restored unconfigured on wake, and the first instruction fetch from
flash hangs until the LP watchdog resets the chip.
Set up clock ICG retention only when peripheral power down is
disabled.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
The commit 04d7964252 ("soc: nuvoton: npcx: add unlimited instant
wake-up and sleep substates") added sub-state 2 ("Sleep") to
pm_state_set() but not to pm_state_exit_post_ops(). Leaving that
sub-state therefore falls through to the default branch and never
calls __enable_irq(), so interrupts stay masked after the first
wake-up from Sleep mode.
Add the missing case.
Assisted-by: Copilot:claude-opus-5
Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
Enable multiple platform-level defaults to make video receiver work without
the need to configure every sample.
Also supports shared-multi-heap to be turned off and use memory region
names instead as an option.
Signed-off-by: Josuah Demangeon <me@josuah.net>
On RW6xx the PSA crypto operations performed during SMP pairing
(ECDH P-256 key agreement/DHKey and AES-CMAC) run in the BT RX
thread context and are dispatched to the NXP ELS/PKC PSA crypto
driver. That driver's call chain is significantly deeper than the
software mbedTLS path; a single mcuxClPsaDriver driver_wrapper
computation alone consumes over 700 bytes of stack.
The default BT_RX_STACK_SIZE of 1200 bytes is not enough to hold
these computations on top of the existing SMP call chain, leading
to a stack overflow when raising the security level
(e.g. "bt security 2").
Bump BT_RX_STACK_SIZE to 2800 when BT_SMP is enabled. This default
only applies on RW6xx with the PSA crypto backend
(MBEDTLS_PSA_CRYPTO_C + BT). Measured peak usage is ~2.3KB, so 2800
leaves adequate margin.
Signed-off-by: Miles Wang <linxiao.wang@nxp.com>
PSC3 exposes a single physical flash through CBUS and SAHB address
aliases. Code executes from the CBUS alias, which is what flash0
describes in devicetree, but the device is programmed through the SAHB
alias. The two views sit a constant 0x20000000 apart for both the
secure (0x12000000 -> 0x32000000) and non-secure (0x02000000 ->
0x22000000) banks.
Zephyr linked and loaded PSC3 images at the CBUS alias. The jlink
runner programs zephyr.hex and takes the addresses from the file, so
the records were rejected by the J-Link flash loader, which exposes
the flash at its SAHB programming alias. The erase phase completed and
the program phase failed, leaving the device blank.
Set CONFIG_BUILD_OUTPUT_ADJUST_LMA so the generated image carries
programming-alias addresses, leaving the run address unchanged. This
matches the approach already used by cyw20829 in the same SoC family
and by pse84.
Infineon OpenOCD declares its programmable PSC3 banks at the same SAHB
addresses and maps the CBUS alias onto them as virtual banks, so
kit_psc3m5_evk is unaffected.
Tested on kit_psc3m5_cc2 (jlink) and kit_psc3m5_evk (openocd); both
program and boot.
Assisted-by: Copilot:claude-opus-5
Signed-off-by: Clark Jarvis <Clark.Jarvis@infineon.com>
With CONFIG_ARCH_STACKWALK (-funwind-tables) the compiler emits
.ARM.exidx.ramfunc / .ARM.extab.ramfunc unwind entries for every
__ramfunc function. On MCXN947 FlexSPI flash is at 0x90000000 and
SRAM at ~0x20000000; the 1.75 GB gap exceeds the +-1 GB (31-bit
signed) R_ARM_PREL31 range, causing:
(.ARM.exidx.ramfunc+0x0): relocation truncated to fit:
R_ARM_PREL31 against '.ramfunc'
Add linker.ld, a wrapper that discards the problematic entries in an
early SECTIONS block before including the standard ARM template.
This must precede the template's *(.ARM.exidx*) wildcard; using
zephyr_linker_sources(SECTIONS ...) places snippets after that
wildcard and has no effect.
Fixes#118983
Assisted-by: Claude:claude-sonnet-4-5
Signed-off-by: Jason Yu <zejiang.yu@nxp.com>
The RMII PHY takes its 50 MHz reference clock from the RW6xx ENET
clock output and must be reset while that clock is running. The ENET
clock gate was only opened by the ENET module device, which
initializes after the PHY device, so the PHY driver reset the PHY
without a clock and it stayed unresponsive.
Open the TDDR ENET clock gate in clock_init() together with the
existing ENET setup, as the MCUXpresso SDK does in
BOARD_InitModuleClock().
Signed-off-by: Tobias Frauenschläger <t.frauenschlaeger@me.com>
The current implementation does not follow the LPSPI SCK frequency
restriction. Update the driver to cap the max. frequency which is
allowed for the LPSPI peripheral.
Signed-off-by: Bas van Loon <bas@arch-embedded.com>
USE_SEGGER_RTT depends on HAS_SEGGER_RTT, which each SoC family selects
for itself. PIC32CM SG/GC does not, so CONFIG_USE_SEGGER_RTT=y is
downgraded to n and everything depending on it - SHELL_BACKEND_RTT,
LOG_BACKEND_RTT, RTT_CONSOLE - goes with it. The build succeeds and the
firmware simply has no RTT, which is hard to read from the host: J-Link
binds its RTT telnet port and greets a client whether or not the target
has a control block, so the session looks alive and stays mute.
Nothing about the omission is technical. RTT is a control block in RAM
read out over SWD and needs no SoC feature this family lacks. The
sibling SOC_FAMILY_MICROCHIP_PIC32CX_SG already carries the same line.
With the select in place RTT works on first use on a PIC32CM5112GC: the
control block is found in SRAM and a shell instance on channel 0 answers
over the J-Link while the SERCOM console stays free.
Signed-off-by: Arkadiusz Grzelka <devitwise@gmail.com>
The RISC-V Espressif SoCs enter from their own start code, not
the arch reset path, so tp keeps its reset value of zero until
the first context switch. TLS accesses before that go through a
zero tp: with STACK_CANARIES_TLS the canary store in z_cstart()
faults on the esp32c5, esp32c61 and esp32p4, where address zero
is protected, and silently writes near address zero elsewhere.
Reserve a zeroed boot TLS area on the stack and point tp at it
before the first C call, and load the TLS initializers once the
flash rodata is mapped.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Rename the misspelled `offest` bit-field in `pinctrl_soc.h` together with
its user in the NPCX pinctrl driver, and fix the other spelling errors in
the same files. Both files change in one commit so the tree builds at
every commit.
Assisted-by: Claude:claude-sonnet-5-5 codespell
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
The DPLL ratio, (f_cpu << 5) / 32768, was computed in 32 bits and
overflows above 134217727 Hz: a 200 MHz clock-frequency gave 65.8 MHz.
Compute it in 64 bits.
Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
As currently configured, nordicsemi_nrf71_init was called after
LFXO clock had started. However some LFXO configuration is done in
nordicsemi_nrf71_init, for which the clock must be off.
Signed-off-by: Robert Robinson <robert.robinson@nordicsemi.no>
nRF7120 makes oscillators and regulator registers non-secure by default
to allow Wi-Fi domain to configure PLL. Therefore other calls to
NRF_REGULATORS must be made from the non-secure side.
Signed-off-by: Robert Robinson <robert.robinson@nordicsemi.no>
With MCUboot the 0x200 default fits the image header, but the vector
table at the start of the image must also satisfy the Cortex-M VTOR
alignment of 1 << LOG2CEIL(4 * (16 + NUM_IRQS)), which exceeds 0x200
above 112 interrupts. Many targets carried identical overrides for
this, and targets without one did not work with MCUboot.
Derive the default from NUM_IRQS instead (0x400/0x800/0x1000 tiers,
Cortex-M only). TF-M targets are unaffected: TF-M's own Kconfig fixes
the value for BL2 builds, and SoC-level overrides such as STM32's are
evaluated before this chain. Drop the overrides that
now reproduce the derived value, including the i.MX RT family and
RT700 defaults, whose low-interrupt members move from 0x400 to 0x200;
others with different semantics (i.MX RT boot headers, Espressif,
OpenTitan, ...) are left untouched.
Fixes#91160
Signed-off-by: Mark Tamas <marktamas28@gmail.com>
CONFIG_NUM_IRQS specifies the number of supported IRQs, so the valid
IRQ range ends at CONFIG_NUM_IRQS - 1.
Reject IRQ numbers greater than or equal to CONFIG_NUM_IRQS in IT8XXX2
interrupt controller implementations to prevent out-of-bounds register
access.
Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
The MCXW7x internal flash is ECC-protected with a 16-byte phrase that
may only be programmed once per erase, so a BLE Mesh DFU with an
unaligned chunk size faults without the block cache. Default it on and
set the write block size to 16 when BLOB IO flash is in the build.
Signed-off-by: Axel Le Bourhis <axel.lebourhis@nxp.com>
Update LVGL to 9.6.0
The LVGL module now sources a zephyr/Kconfig.defaults before the
LVGL Kconfig.
The Zephyr tree no longer re-declares or references symbols of the
LVGL module Kconfig. Boards, shields and SoCs set Zephyr owned LV_Z_*
options instead, and Kconfig.defaults in the LVGL module turns them
into defaults of the matching LVGL options.
LVGL 9.6 replaces the color depth option with the
LV_COLOR_FORMAT_DEFAULT choice. The LV_Z_COLOR_FORMAT choice provides
its SoC, board and shield default, with a no default option that
keeps the LVGL default. LV_Z_DPI_DEF and LV_Z_DRAW_BUF_ALIGN have no
prompt and default to 0, which also keeps the LVGL default.
LV_ATTRIBUTE_MEM_ALIGN_SIZE has no LVGL counterpart and becomes
LV_Z_ATTRIBUTE_MEM_ALIGN_SIZE. LV_USE_GPU_NXP_PXP is used by hal_nxp
and keeps its name.
The render buffers are sized from the bits per pixel of
LV_COLOR_FORMAT_DEFAULT unless LV_Z_BITS_PER_PIXEL is set,
and the monochrome buffer layout follows CONFIG_LV_COLOR_FORMAT_I1,
so both follow a color format set by the application.
Logging and the system monitor stay with the LVGL module. The glue
logs through its own log module using the log level template, and
samples using the system monitor enable CPU_LOAD themselves.
Co-authored-by: Fabian Blatz <fabianblatz@gmail.com>
Signed-off-by: Fabian Blatz <fabianblatz@gmail.com>
Signed-off-by: André Costa <andre_miguel_costa@hotmail.com>
Currently, the GPIO hold on the console pins is released only in the
sleep exit hook, so any log or print issued between wake and that
release comes out as garbage. Release the hold right after light sleep
returns, leaving more room in power.c for printing after sleep. This
slightly extends the measured sleep window, but the difference is
negligible for the stats purpose.
Assisted-by: Grok:4.7
Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
stm32u5 set_mode_stop() checked STM32_SYSCLK_SRC_MSI but U5 has no MSI,
it sets STM32_SYSCLK_SRC_MSIS instead. Testing the wrong macro caused
every U5 to wake up on HSI regardless of SYSCLK source.
Use the proper STM32_SYSCLK_SRC and LL_RCC symbols for U5, same as U3.
Signed-off-by: Nicolas Zuluaga <nicolas.zuluaga@rbr-global.com>
Signed-off-by: Eden Frosst <eden.frosst@rbr-global.com>
STM32U0, U3, U5, and C5 power.c all selected the Stop wake-up clock
with `#if{def} STM32_SYSCLK_SRC_xxx` without including the header
they're defined in (stm32_clock_control.h), so the tests were silently
false, causing the part to wake up on the fallback clock (HSI16, or
HSIDIV3 on C5) even when SYSCLK is MSI, MSIS or HSIS.
Similarly, clock_stm32_ll_common.h guarded its declarations with
STM32_*_ENABLED macros, while also missing the same header.
Include the header so the conditions preprocess correctly.
Signed-off-by: Eden Frosst <eden.frosst@rbr-global.com>
MCXA and MCXN include arch_interface.h directly. On Cortex-M, this
can reach kernel/thread.h before k_thread_entry_t is defined. With
CONFIG_THREAD_MONITOR enabled, __thread_entry then fails to compile.
Include kernel.h in both power management sources to establish the
required header order.
Assisted-by: Codex:gpt-6
Signed-off-by: Markus Fuchs <markus.fuchs@sautergroup.com>
The series selects ARMV8_M_DSP but neither of the MVE symbols, so
cmake/gcc-m-cpu.cmake falls through to -mcpu=cortex-m85+nomve and every
build for this part gets scalar code, with __ARM_FEATURE_MVE undefined.
The RA8M1 is the same Cortex-M85 and selects both, and the two parts'
CMSIS core configuration blocks are identical, so this looks like an
omission in a newer port rather than a difference between the devices.
Select them on the CM85 core rather than on the series: the RA8P1 is dual
core and the CM33 alongside it has no Helium.
With this an H.264 decoder carrying Helium kernels builds with
-mcpu=cortex-m85, shrinks by 1168 bytes, and decodes a phone's video
stream on an EK-RA8P1 with 174 MVE instructions in its objects.
Assisted-by: Claude:opus-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Scale, rotate and mirror took PPA_ALPHA_SCALE and wrote the bits of the
float ratio as the alpha multiplier, so a ratio of 0.5 gave alpha 0.
Reject it with ESP_ERR_NOT_SUPPORTED, as blend already does.
An alpha mode or rotation angle outside its enumeration reached the HAL,
which aborts on it, from the interrupt when the request was queued.
Reject those with ESP_ERR_INVALID_ARG.
Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The block offset and size are summed before being compared with the
picture size, so an offset near UINT32_MAX wraps the sum and passes.
The 14-bit descriptor field then truncates the offset and the 2D-DMA
reaches past the picture.
Compare the offset with the picture size first and the block with what
is left of it, as ESP-IDF does. This covers fill, blend and scale,
rotate and mirror alike.
Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The engine scales by an integer part and a number of sixteenths, but the
output block was sized from the float product. For a scale that is not a
multiple of 1/16 the output descriptor then expected more pixels than
the engine writes, 266 columns instead of 250 for 800 scaled by 0.333,
and a block that fits once rounded down was rejected.
Size the block from the programmed factors, as ESP-IDF does, and reject
a scale below 1/16, which the engine would take as zero.
Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The scale, rotate and mirror engine converts YUV 4:2:0 and 4:2:2 input
to RGB itself, but the driver only knew the pixel size of the RGB,
alpha and grey formats and left the engine's YUV range and conversion
standard at their reset values, so a YUV request was rejected.
Give the 2D-DMA the 1.5 and 2 bytes per pixel of those formats, program
the range and the standard from the input picture, and reject odd
geometry the chroma subsampling cannot describe, as ESP-IDF does. A range
or standard the engine has no setting for is rejected too, as the HAL
aborts on it. YUV 4:4:4 still needs the 2D-DMA to convert it first and
is not taken.
Tested on an ESP32-P4 v3.2 converting 800x480 YUV 4:2:0 to RGB565 with
a quarter turn: 64 sampled pixels per picture agree with a software
BT.601 conversion within one step of each channel.
Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
hal_nxp builds the ELS PKC library for cm33_core0 and exports the core0
CPU macro to the application, so on the MCXN947 and MCXN547 CPU1
targets any build with MBEDTLS_PSA_CRYPTO_C gets the core0 device
header and fails the CMSIS MPU, FPU and DSP checks. Select the library
only on the cores it supports.
Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
An application could only run code from IRAM on an Espressif SoC by
marking it with a section attribute, which it cannot do for a library
it did not write. The RAMFUNC_SECTION linker snippets that serve this
elsewhere are placed by arch/common/ramfunc.ld, which these SoCs do not
use, so zephyr_linker_sources(RAMFUNC_SECTION ...) was silently ignored
on them.
Include the snippets in .iram0.text, where IRAM_ATTR code goes, so the
input sections they name run from IRAM.
On an ESP32-P4 this places 38 KB of an H.264 decoder library in IRAM,
where fetching it through the flash cache cost a quarter of the
decoding time with both cores running. The other SoCs were not built.
Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
On STM32U5, transition from LDO to SMPS or vice-versa as VCORE regulator
supply source can take some time (~20 µs). Make sure to wait until the
transition is complete before letting the boot process continue.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Transition from LDO to SMPS or vice-versa as VCORE regulator supply
source can take some time (~20 µs) on STM32WBA. Make sure to wait
until the transition is complete before letting the boot process
continue.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>