Commit graph

25099 commits

Author SHA1 Message Date
AlmAck
784c6519de arch/arm/nrf53: enable the application core flash cache
The nRF5340 application core comes out of reset with its flash cache
disabled and nothing in the tree turns it on.  nrf53_start() does call
nrf53_enable_icache(), but that drives NVMC ICACHECNF and is gated on
NRF53_FLASH_PREFETCH, which depends on NRF53_NETCORE -- so it is not
even compiled for an application core build.

The nRF5340 places the application core cache in a separate CACHE
peripheral at 0x50001000.  NRF53_CACHE_BASE is already defined in
hardware/nrf53_memorymap_cpuapp.h, but there was no register header and
no enable.  Add both, behind a new NRF53_CACHE option.

The option defaults to n, matching ARMV7M_ICACHE and
ARMV8M_ICACHE/DCACHE, so that upgrading does not silently change the
behaviour of an existing configuration.

Measured on nrf5340-dk at 64 MHz with apps/benchmarks/scbench:

  protected-build syscall round trip   64.1 us -> 29.6 us
  userspace sem wait + post pair       4.75 us -> 1.95 us

Flat builds benefit equally; the gain is on any flash-resident code
path.

Per the nRF5340 Product Specification, 'CACHE - Instruction and data
cache', 'both instruction and data accesses towards flash memory or XIP
code regions are cached'.  The cache does not observe NVMC programming,
so nrf53_flash.c has to account for it: both up_progmem_eraseblock() and
up_progmem_write() read back what they just programmed to verify it, and
up_progmem_ispageerased() reads a whole page, so lines covering the
region being programmed are commonly resident.  Bypass the cache for the
duration of an erase or a write and invalidate it before re-enabling, so
the verify reads the array and later readers do too.  That file is built
only when NRF53_PROGMEM is selected, which is not the default.

Signed-off-by: AlmAck <gluca86@gmail.com>
2026-09-04 13:50:15 -03:00
jsanchez-2g
b75b93fd32 stm32g0: Fix erase bank selection after bank swap
The flash page number follows the logical memory mapping, but BKER selects a physical flash bank. Account for the nSWAP_BANK option when selecting BKER so erasing a logical address targets the corresponding physical bank after a swap.

Assisted-by: OpenAI Codex <codex@openai.com>
Signed-off-by: jsanchez-2g <jsanchez@2g-eng.com>
2026-09-04 13:44:51 -03:00
Felipe Moura
673b4245f7 xtensa/esp32s3: Fix CONSOLE_DEV clobbered by USBSERIAL macro.
When a real UART (CONFIG_UARTx_SERIAL_CONSOLE) is selected as the
system console while CONFIG_ESP32S3_USBSERIAL is also enabled (e.g. to
keep /dev/ttyACM0 available as a secondary device alongside an
external console UART), the unconditional

  #ifdef CONFIG_ESP32S3_USBSERIAL
  #  define CONSOLE_DEV g_uart_usbserial
  #endif

block silently redefines CONSOLE_DEV, clobbering the correct earlier
definition that pointed it at the chosen UART device.

Confirmed on real hardware (Seeed XIAO ESP32-S3): with UART0 selected
as console and USBSERIAL also enabled, the board boot-looped on
RTCWDT_RTC_RST every ~8s, never reaching NSH. With this fix, NSH comes
up normally over UART0 and /dev/ttyACM0 remains available.

Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
Assisted-by: Claude:claude-sonnet-5
2026-09-04 17:51:16 +08:00
Megha Rajput
907a521b15 arch/risc-v: assign per-cpu data by logical cpu
Some checks are pending
Build Documentation / build-html (push) Waiting to run
MemBrowse Memory Report / changes-filter (push) Waiting to run
MemBrowse Memory Report / load-targets (push) Waiting to run
MemBrowse Memory Report / identical (push) Blocked by required conditions
MemBrowse Memory Report / analyze (push) Blocked by required conditions
Assign the per-CPU area using the HART to CPU mapping instead of the
order in which HARTs register. This keeps interrupt stack assignment
consistent with the logical CPU and avoids incorrect per-CPU IRQ stack
selection when HART boot order differs.

Signed-off-by: Megha Rajput <i.meghar.2408@gmail.com>
2026-09-02 12:00:45 -03:00
Xiang Xiao
83b4239e1d arch/sim: switch nonblock setup to ioctl FIONBIO
Update host_uart_start() to set stdin/stdout nonblocking via ioctl.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-09-02 09:02:09 -03:00
ligd
ae666954e6 sim/hostuart: set stdout to O_NONBLOCK to prevent blocking
When NuttX sim is connected via pipe (e.g. by an automation tool),
if the host side does not read stdout in time, the pipe buffer fills
up and write(1, ...) blocks the entire sim process. This happens
inside host_uninterruptible (irq disabled), so the NuttX scheduler
is completely frozen and all threads stop.

Set fd=1 (stdout) to O_NONBLOCK so that write() returns EAGAIN
instead of blocking. The TX data stays in the NuttX xmit buffer
and sim_tty_work retries every 1ms until the pipe has space.

Signed-off-by: ligd <liguangdi1@xiaomi.com>
2026-09-02 09:02:09 -03:00
chenzihan1
60ac52c4b9 sim_hostuart.c: add nonblock flags for /dev/console
to avoid the blocking indefinitely when the host
uart is not ready to read/write data.

Signed-off-by: chenzihan1 <chenzihan1@xiaomi.com>
2026-09-02 09:02:09 -03:00
p-szafonimateusz
3038df4179 arch/x86_64: add support for xAPIC
Add support for legacy xAPIC alongside x2APIC.
This way we can run nuttx x86_64 on qemu without the --enable-kvm option

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2026-09-02 18:22:34 +08:00
Jacob Dahl
65d0b3f1ce arch/arm/stm32: set F412 SRAM1_END to 256KiB
The F412 has 256KiB of system SRAM at 0x20000000 and no CCM. The F2/F4
heap map had no F412 entry, so it used the 128KiB default at
0x20020000 and left the upper half unused.

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-09-02 15:17:37 +08:00
dechao_gong
c36e45eb6f arch/arm/rtl8721f: add timer driver support
Wire the RTL8721F (amebagreen2) into the shared Ameba timer driver
(arch/arm/src/common/ameba/ameba_timer.c), registered at /dev/timer0
(TIM1) and /dev/timer1 (TIM2).  Only the per-chip base addresses, RCC
masks and IRQs differ, so this adds a small ameba_timer_chip.h (the two
32-bit basic LTIM timers at 0x40819200 / 0x40819400, 32.768 kHz,
APBPeriph_LTIM1/2, IRQ_TIMER1/2, verified against the SoC hal_platform.h
/ sysreg_lsys.h / vector table) plus the Make.defs/CMakeLists build
hooks, the fwlib ram_common/ameba_tim.c RAM source (now also pulled in
by CONFIG_AMEBA_TIMER, matching the PWM rule), the board bring-up
registration and a timer defconfig.  The shared driver is unchanged.

TIM0 is left untouched because the boot ROM claims it as the always-on
system timer; reprogramming it would break every SDK delay.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
2026-09-01 17:41:14 +08:00
dechao_gong
2ddabb216a arch/arm/rtl8720f: add timer driver support
Wire the RTL8720F into the shared Ameba timer driver
(arch/arm/src/common/ameba/ameba_timer.c), registered at /dev/timer0
(TIM1) and /dev/timer1 (TIM2).  Only the per-chip base addresses, RCC
masks and IRQs differ, so this adds a small ameba_timer_chip.h (the two
32-bit basic LTIM timers at 0x40808200 / 0x40808400, 32.768 kHz,
APBPeriph_LTIM1/2, IRQ_TIMER1/2, verified against the SoC hal_platform.h
/ sysreg_lsys.h / vector table) plus the Make.defs/CMakeLists build
hooks, the fwlib ram_common/ameba_tim.c RAM source (now also pulled in
by CONFIG_AMEBA_TIMER, matching the PWM rule), the board bring-up
registration and a timer defconfig.  The shared driver is unchanged.

TIM0 is left untouched because the boot ROM claims it as the always-on
system timer; reprogramming it would break every SDK delay.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
2026-09-01 17:41:14 +08:00
dechao_gong
2cc38e43fb arch/arm/rtl8721dx: add shared Ameba timer driver
Add a parameterised NuttX timer lower-half for the Realtek Ameba
general-purpose timers, sitting on the SDK fwlib RTIM register layer and
registered at /dev/timerN.  The shared driver
(arch/arm/src/common/ameba/ameba_timer.c) reads a per-chip instance
table (ameba_timer_chip.h) for each timer's base, input clock, RCC gate
masks and IRQ; the period is programmed directly in microseconds and
converted to the 32-bit auto-reload with one clkfreq formula.

On the pke8721daf two of the 32.768 kHz "basic" (LTIM) timers are
exposed: /dev/timer0 is TIM1 and /dev/timer1 is TIM2.  TIM0 is left
untouched because the boot ROM claims it as the always-on system timer
(SYSTIMER); reprogramming it would break every SDK delay.  The RTIM
time-base entry points resolve to ROM, while the interrupt-clear and
period-change helpers come from the fwlib RAM source ameba_tim.c (shared
with the PWM driver).

Verified on hardware with examples/timer against both devices: the
update interrupt fires at the requested 1 s interval (measured with the
independent ROM SYSTIMER = 32768 ticks = 1.000 s).

Also whitelist the vendor RTIM_ symbol prefix in tools/nxstyle.c,
alongside the existing RCC_/SYSTIMER_ Ameba SDK entries.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
2026-09-01 17:41:14 +08:00
Jacob Dahl
3e2f28ef68 net, arch: Fix nxstyle errors in files the CAN ioctl merge touches.
Whitespace only: blank lines after declarations, misindented switch
bodies and brace alignment. nxstyle runs over the whole of any file a
change touches, and merging the CAN ioctl options renames a config in
every SocketCAN driver.

Assisted-by: Claude:claude-fable-5
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-09-01 17:40:47 +08:00
Jacob Dahl
eb40eed248 arch/arm/src/imxrt: Unify FlexCAN TX work and add SIOCGCANERRORS.
TX-complete and the deadline watchdog each queued their own callback on
the same work_s, and work_queue() cancels whatever is pending when a
work_s is reused, so whichever ran second was dropped: deadlines were
left set, the TX interrupt mask stayed off, or expired frames were never
aborted. Both now queue imxrt_tx_work(), which retires completions
before it aborts expired mailboxes.

Add SIOCGCANERRORS so a socket can read fault confinement, TEC/REC, a
monotonic bus error count and the RX mailbox overrun count. SIOCGCANSTATE
reports sleep/operational, not fault confinement, hence a new command.
The error count is sampled from the clear-on-read ESR1 error flags at
every driver entry rather than from ERRINT, which fires per error frame
and storms at bus rate once the bus is dead. Frames the CAN socket layer
drops for want of an IOB now count as rx_dropped in the netdev
statistics as well as in the global CAN statistics.

Tested on an i.MX RT1176 (ARK FMU-v6XRT) running PX4 with two DroneCAN
nodes: unplugging one node the ioctl reports error-passive, TEC 128,
REC 0 and a monotonic error count, matching ECR/ESR1 read over SWD at
20 Hz, while the other interface stays error-active with zero errors.

Assisted-by: Claude:claude-fable-5
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-09-01 17:40:47 +08:00
Jacob Dahl
60ef78f042 net/netdev: Combine the per-command CAN ioctl options into NETDEV_CAN_IOCTL
NETDEV_CAN_BITRATE_IOCTL, NETDEV_CAN_FILTER_IOCTL and
NETDEV_CAN_STATE_IOCTL guarded identical option blocks, and every
SIOCxCANxxx case in netdev_ifr_ioctl() forwarded a member of the same
ifr_ifru union to d_ioctl(). One option and one case block now cover
all of the CAN commands; drivers and defconfigs are updated to the
new name.

Assisted-by: Claude:claude-fable-5
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-09-01 17:40:47 +08:00
Jacob Dahl
fbe3468703 arch/arm/src/stm32h7: Remove broken FDCAN filter ioctl stubs.
The SIOCxCANxxFILTER cases in fdcan_netdev_ioctl() call
stm32_addextfilter(), stm32_delextfilter(), stm32_addstdfilter() and
stm32_delstdfilter(), none of which exist anywhere in the tree. The
block only ever compiled because no stm32h7 config enables
NETDEV_CAN_FILTER_IOCTL; enabling it breaks the link. The commands now
fall through to the existing -ENOTSUP default, which is also what a
caller observed before.

Assisted-by: Claude:claude-fable-5
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-09-01 17:40:47 +08:00
Jacob Dahl
4fa0319f1c arch/arm/stm32f4: add STM32F412CG chip selection
48-pin 1MB F412. CE was the only 48-pin part listed, so boards using
STM32F412CGU6 had to select a 512KB chip. Feature counts are identical
to CE, so it shares the block.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-09-01 17:40:30 +08:00
Jacob Dahl
fcad1ef21d arch/arm/stm32f4: add STM32F412VG chip selection
100-pin 1MB F412 (LQFP/UFBGA). Without this, boards using
STM32F412VGH6 have to select the 48-pin 512KB CE.

STM32_NGPIO is 113 rather than the real 81 I/Os because
STM32_NGPIO_PORTS is (N+15)>>4 and 81 yields six ports A-F, so
PH0/PH1 could not be configured. 113 matches ZG and gives A-H.

CE/ZG chip.h counts and the family HAVE_* list are corrected in
the same change: CE has no FSMC, the die has TIM6/7/9-14 and
SPI4/5, ZG USART is 4, I2S is 5. FSMC is only bonded on 100/144-pin,
so HAVE_FSMC is selected on VG/ZG and not on CE.

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-09-01 17:40:30 +08:00
Felipe Moura
3026e322d8 esp32s3_tickless: fix 32-bit overflow in NSEC_2_CTICK/SEC_2_CTICK/USEC_2_CTICK
Some checks are pending
MemBrowse Memory Report / changes-filter (push) Waiting to run
MemBrowse Memory Report / load-targets (push) Waiting to run
MemBrowse Memory Report / identical (push) Blocked by required conditions
MemBrowse Memory Report / analyze (push) Blocked by required conditions
CONFIG_ESP32S3_TICKLESS hangs forever the first time a task calls a
sleep/timeout with a fractional-second component of roughly 134ms or
more (e.g. usleep(500000)) while another task is also pending a
timeout.

Root cause: NSEC_2_CTICK() computes ((nsec) * CTICK_PER_USEC) /
NSEC_PER_USEC. `nsec` (struct timespec's tv_nsec) is a 32-bit `long`,
and CTICK_PER_USEC is 16 (the S3's systimer runs at 16MHz), so the
multiplication overflows a 32-bit signed int for any tv_nsec at or
above INT32_MAX / 16 (~134,217,728 ns). The overflowed (negative)
result then gets added into up_timer_start()'s `uint64_t cpu_ticks`,
wrapping around to a value near UINT64_MAX. tickless_setcounter()
then programs the systimer alarm that many ticks in the future --
effectively never -- so nxsched_process_timer() is never called and
the waiting task sleeps forever.

Reproduced on real esp32s3-xiao hardware: apps/testing/ostest hung
indefinitely right after starting user_main(), whose first statement
is usleep(500000). Instrumented up_timer_start() to print its inputs
and observed exactly the described overflow (cpu_ticks close to
UINT64_MAX for tv_nsec=510000000). Confirmed root cause is the
concurrent-timeout case specifically: user_main's usleep() alone
works, and ostest_main's own usleep() alone works, but the two
together (matching ostest's actual task_create() + concurrent
usleep() pattern) reproduce the hang every time.

Fix: cast to uint64_t before multiplying in all three *_2_CTICK
macros, forcing 64-bit arithmetic throughout, matching how the
CTICK_2_* (division) macros are already overflow-safe.

Validated on esp32s3-xiao: with the fix, the full ostest suite (built
with CONFIG_ESP32S3_TICKLESS=y) runs past the point it used to hang
and completes end to end.

Note: while testing, ostest's own round-robin test (rr_test) failed
near the end of the run -- the two same-priority SCHED_RR threads did
not appear to interleave under tickless. That looks like a separate,
likely more architectural issue (time-slice preemption needs its own
periodic re-arm, independent of one-shot sleep timeouts) and is not
addressed by this fix; filing separately.

Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
2026-09-01 13:38:56 +08:00
zhangyu117
5a42393acf arch/tricore: fix bug about less ')" in makefile
error: Makefile:241: *** unterminated call to function "call": missing ")". Stop.

Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
2026-09-01 12:23:32 +08:00
zhangyu117
ab59b095a7 arch/tricore: Simplify header files and implementation in FPU
1. replace __mtcr/mfcr with arch's tricore_mtcr/tricore_mfcr, donot dependon illd
2. Simplify header files
3. define registers address self

Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
2026-09-01 12:23:32 +08:00
zhangyu117
1af57bb1b9 arch/tricore: drop mpu iLLD dependency and use raw register access
Replace iLD union types and __mfcr/__mtcr intrinsics with uint32_t
and tricore_mfcr/tricore_mtcr. Replace the iLD-specific
to HW full capacity (8 sets / 24 data / 16 code regions).

Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
2026-09-01 12:23:14 +08:00
zhangyu117
4afb7f91ad arch/tricore: mpu: per-set flags array and cpuset in mpu_region_s
Refactor kflags/uflags into a per-set flags[] array indexed by set
number, and add a cpuset field to filter regions per CPU. Rewrite
mpu_initialize to loop over all protection sets.

Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
2026-09-01 12:23:14 +08:00
AlmAck
b496611b7f arch/arm/nrf53: fix nxstyle errors in nrf53_gpiote.c
Some checks are pending
MemBrowse Memory Report / changes-filter (push) Waiting to run
MemBrowse Memory Report / load-targets (push) Waiting to run
MemBrowse Memory Report / identical (push) Blocked by required conditions
MemBrowse Memory Report / analyze (push) Blocked by required conditions
Pre-existing violations in this file, reported by checkpatch because the
preceding commit touches it:

  nrf53_gpiote.c:185: Missing blank line after declarations
  nrf53_gpiote.c:213: Bad alignment
  nrf53_gpiote.c:216: Bad alignment
  nrf53_gpiote.c:259: Bad right brace alignment

Add the blank line after the declarations in the channel-callback block,
indent the two `break;` statements into their case bodies, and align the
brace closing the per-port `for` loop with its opening at line 209 (it
sat at seven spaces, so neither the loop's eight nor anything else).

Whitespace only — no functional change, brace count unchanged.

Signed-off-by: AlmAck <gluca86@gmail.com>
2026-08-31 09:15:28 +08:00
AlmAck
28f0a27dd2 arch/arm/nrf53: fix inverted GPIOTE per-instance channel index
The driver presents a single channel space of GPIOTE_CHANNELS entries
across the application core's two GPIOTE peripherals, and splits it:

  inst  = (channel < GPIOTE_PER_CHANNEL) ? 0 : 1;
  rchan = (inst == 1) ? channel : (channel - GPIOTE_PER_CHANNEL);

rchan is the channel index within the selected instance, used to build
the per-channel register offsets, so it must be

  rchan = channel - GPIOTE_PER_CHANNEL * inst

The ternary has the two arms the other way round: a channel on instance
0 gets rchan = channel - GPIOTE_PER_CHANNEL, which is negative, and a
channel on instance 1 gets an index still offset by a full instance.

The interrupt handler in this same file already applies that mapping in
the opposite direction, converting a per-instance channel back to the
global one:

  off = i + GPIOTE_PER_CHANNEL * inst;

so the two were inconsistent, and it is the rchan sites that were wrong.

Per the nRF5340 Product Specification, 'GPIOTE - GPIO tasks and
events', the application core has two GPIOTE instances, GPIOTE0 (secure,
base 0x5000D000) and GPIOTE1 (non-secure, base 0x4002F000), each with
eight channels and its own CONFIG[n] array at offset 0x510 + 4n for
n = 0..7.  This matches GPIOTE_PER_CHANNEL == 8, the two base addresses
in hardware/nrf53_memorymap_cpuapp.h, and NRF53_GPIOTE_CONFIG_OFFSET()
in hardware/nrf53_gpiote.h, so rchan is required to be in 0..7 and a
negative value cannot address a CONFIG register.

With a negative rchan the CONFIG register write for a channel on
instance 0 lands below the instance base instead of in CONFIG[n], so the
channel is never configured and its GPIOTE interrupt is never enabled.
On nrf5340-dk this makes the board buttons dead.

Both call sites are corrected.

Signed-off-by: AlmAck <gluca86@gmail.com>
2026-08-31 09:15:28 +08:00
Jacob Dahl
e1ac5079d2 arch/arm/stm32f4: fudge STM32F411VE NGPIO so GPIOH is enabled
STM32_NGPIO_PORTS is (N+15)>>4. 81 (the real pin count) yields six
ports A-F, so PH0/PH1 cannot be configured. 113 matches the F40x
100-pin entries and gives A-H.

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-08-30 10:46:28 -03:00
alexcekay
8affe54985 arch/arm/stm32: Fix Ethernet code style issues
Fixed all the issues reported by checkpatch.sh in stm32_eth_m3m4_v1.c,
stm32f7/stm32_ethernet.c, stm32h5/stm32_ethernet.c, stm32h7/stm32_ethernet.c

Signed-off-by: alexcekay <alexander@auterion.com>
2026-08-29 11:13:56 -03:00
alexcekay
6742f6328c arch/arm/stm32: Make Ethernet TX watchdog timeout configurable
The STM32 Ethernet MAC drivers hard-code a 60-second TX watchdog
timeout. While this is a reasonable general default, certain board
designs and use-cases require a shorter or longer value.

Introduce CONFIG_STM32_ETH_TXTIMEOUT via the shared Kconfig.eth
with a #ifndef fallback. The default is kept at 60 seconds
to preserve existing behavior.

Assisted-by: Claude Code:claude-sonnet-5
Signed-off-by: alexcekay <alexander@auterion.com>
2026-08-29 11:13:56 -03:00
Lwazi Dube
f3805fb222 arch/mips/jz4780: Add HDMI EDID parsing and dynamic display modes
This commit introduces EDID reading and parsing to the JZ4780 display
driver, replacing hardcoded resolution limits with dynamic mode selection
based on the connected display's capabilities.

Specific changes include:
  - Implemented I2C DDC master communication for the HDMI controller to
    read EDID blocks from monitors.
  - Added dynamic mode selection to calculate bandwidth and pick the best
    supported resolution, prioritizing the EDID preferred mode.
  - Dynamically allocated framebuffer bounds (g_planeinfo and g_videoinfo)
    based on parsed EDID dimensions.
  - Configured GPIO pin multiplexing for HDMI power, DDC, and control pins
    (POWER_EN, CEC, SCL, SDA) to enable display power and communication
    on the CI20 board.

Signed-off-by: Lwazi Dube <lwazeh@gmail.com>
2026-08-29 11:08:25 -03:00
dechao_gong
15678acf6f arch/arm/rtl8721f: add watchdog driver support
Wire the RTL8721F (amebagreen2) into the shared Ameba watchdog driver
(arch/arm/src/common/ameba/ameba_wdg.c), registered as /dev/watchdog0.
Only the per-chip base address and IRQ differ, so this adds a small
ameba_wdg_chip.h (WDG2 non-secure system watchdog at 0x4080AD80,
CPU0_NS_WDG IRQ 69, verified against the SoC hal_platform.h and
ameba_vector_table.h) plus the Make.defs/CMakeLists build hooks, the
board bring-up registration, and a wdg defconfig.  The shared driver is
unchanged.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
2026-08-29 00:08:03 +08:00
dechao_gong
ceea742239 arch/arm/rtl8720f: add watchdog driver support
Wire the RTL8720F into the shared Ameba watchdog driver
(arch/arm/src/common/ameba/ameba_wdg.c), registered as /dev/watchdog0.
Only the per-chip base address and IRQ differ, so this adds a small
ameba_wdg_chip.h (WDG2 non-secure system watchdog at 0x40801D80,
KM4TZ_NS_WDG IRQ 52, verified against the SoC hal_platform.h and
ameba_vector_table.h) plus the Make.defs/CMakeLists build hooks, the
board bring-up registration, and a wdg defconfig.  The shared driver is
unchanged.

Also corrects the RTL8720F row in the rtl8721dx chip-header reference
table (the non-secure system WDG IRQ is KM4TZ_NS_WDG = 52).

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
2026-08-29 00:08:03 +08:00
dechao_gong
a25fbba5a5 arch/arm/rtl8721dx: add shared Ameba watchdog driver
Add a NuttX watchdog lower-half for the Ameba KM4 non-secure system
watchdog (WDG2), registered as /dev/watchdog0.  The fwlib WDG API is
ROM-resident, so no board.mk change is needed.

The hardware cannot be stopped once enabled, so stop() is emulated via
the early interrupt (EI) auto-refreshing the counter, and capture()
delivers a pre-timeout callback through the same EI.  The EI has a
three-part timing contract, all handled here: it must be armed with
EIMOD=ENABLE at WDG_Init, its EIE gate only takes effect after
WDG_Enable, and -- because the EI is level-based -- a pure capture path
must mask EIE after the one-shot callback to avoid re-entrant storming
while the reset is pending.  The EI flag is cleared twice per the slow
WDG clock.

Per-chip base address and IRQ live in ameba_wdg_chip.h so the shared
driver needs no change to port to another Ameba IC.

Verified on pke8721daf: timeout reset (BOOT REASON WDG2), stop()
suppressing the reset, and capture() firing ~EICNT ms before the reset.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
2026-08-29 00:08:03 +08:00
Marco Casaroli
55a5c6628e arch/xtensa: Provide vfork().
Xtensa selected neither fork primitive, so vfork() was simply absent.  This
wires it onto the two-primitive semantics.

There is no assembly entry point and none is needed.  Every exception entry
already runs SPILL_ALL_WINDOWS, so the whole context of the calling thread is
in its exception frame and copying its stack copies a complete frame chain.
A flat build reaches that frame through SYS_save_context, issued inline so
that the recorded stack pointer belongs to a frame that stays alive for the
whole operation; a build with syscalls reaches it through xcp.sregs, recorded
by xtensa_swint() for the duration of the call.

The stack copy needs more than a relocated stack pointer here.  A windowed
ABI stores each frame's caller stack pointer absolutely, in the base save
area below the frame, so a copy taken at a different address still names the
parent throughout and the child's first retw would underflow onto the
parent's stack.  xtensa_fork_rebase() walks that chain and adds the
relocation offset to each link.  The copy also starts one base save area
below the stack pointer rather than at it, because the frame the child
resumes into keeps its caller's spilled a0-a3 there.

Ported from the per-architecture work, reduced to the two primitives.

Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com>
Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-08-28 23:08:31 +08:00
rongbaichuan
1401179f85 arch/sim: make nuttx link target depend on staging libraries
The nuttx link target only listed libarch.a, board lib, arch objects and
nuttx-names.dat as prerequisites, so rebuilding an app or system library
(staging/libapps.a etc.) did not trigger a relink and the change never
reached the binary.

Add the staging libraries passed in via LINKLIBS to the prerequisite
list, matching the pattern used by arch/arm/src/Makefile.

Signed-off-by: rongbaichuan <rongbaichuan1027@163.com>
2026-08-28 11:40:08 -03:00
Liam Howatt
0795d9a647 arch/arm/stm32h5: Add PM stop and standby support.
Some checks failed
MemBrowse Memory Report / changes-filter (push) Waiting to run
MemBrowse Memory Report / load-targets (push) Waiting to run
MemBrowse Memory Report / identical (push) Blocked by required conditions
MemBrowse Memory Report / analyze (push) Blocked by required conditions
Docker-Linux / push (push) Has been cancelled
Implement PM STANDBY. Loosely based on stm32h7 with
simpler registers.

Implement PM STOP. Using a similar parameter to stm32h7's
LPDS mode bool. There is no LPDS on stm32h5 but there is
the same lower-power voltage scaling value, so rename the parameter
for stm32h5 and use SVOS5 without LPDS present.

Add arm_pminitialize implementation with default
pm subsystem initialization.

Co-authored-by: Austin.Chen <Austin.Chen@wnc.com.tw>
Signed-off-by: Liam Howatt <liamhowatt@geotab.com>
2026-08-28 09:27:32 -03:00
Kaben
9c467c5114 fs/hostfs: fix pre-existing nxstyle issues in touched files
Add missing blank lines after declarations and fix one bad alignment
in hostfs/rpmsgfs-related files. These are pre-existing style issues
flagged by CI's whole-file nxstyle check when our PR touches these
files. No logic change (git diff -w is blank-line-only additions).

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-08-28 18:35:37 +08:00
zhengyu16
86193c95ca fs/hostfs: add link, symlink, readlink and lstat support
Implemented link(), symlink(), readlink() and lstat() in hostfs.

Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com>
2026-08-28 18:35:37 +08:00
dechao_gong
cc5c6ba501 arch/arm/rtl8721f: use RTL8721F_NOR flash profile for cmake
The SDK ships no bare RTL8721F.rdev profile (unlike RTL8721Dx /
RTL8720F); it splits by flash type into RTL8721F_NOR.rdev /
RTL8721F_NAND.rdev.  The default (AMEBA_PY_SOC = RTL8721F) therefore
failed the cmake `flash` target with "profile not found:
RTL8721F.rdev".

Override AMEBA_FLASH_PROFILE to RTL8721F_NOR to match the EVB flash
type and boards/arm/rtl8721f/rtl8721f_evb/scripts/Make.defs.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
2026-08-28 08:41:39 +08:00
dechao_gong
3485dcb14c arch/arm/common/ameba: fix self-referential python shim symlink loop
ameba_setup_env.sh resolved the system interpreter via `command -v
python3`.  Once a previous run put $SHIMBIN at the front of PATH, that
lookup returned $SHIMBIN/python3 and `ln -sf shim shim` created a
self-referential symlink, breaking every subsequent cmake reconfigure
with "Too many levels of symbolic links".

Scan PATH for the first python3 that is not inside $SHIMBIN and
canonicalise it with readlink -f, so the shim always points at a real
interpreter.  Idempotent across reconfigures.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
2026-08-28 08:41:39 +08:00
dechao_gong
597fc8c93b arch/arm/ameba: fix CMake link for rtl8721f (multi ROM ld)
The shared CMake build hardcoded a single ROM symbol linker script
(ameba_rom_symbol_acut_s.ld), so a CMake build of rtl8721f failed to
link: __rom_bss_start_ns__ / __rom_bss_end_ns__ and the rtw_* WiFi ROM
symbols were left undefined.  The make build already appends rtl8721f's
four ROM symbol scripts (secure + wifi + os + NS) in
arch/arm/src/rtl8721f/ameba_board.mk; the CMake path did not.

Make the ROM symbol script set per-IC:

- ameba_gen_ldscript.sh now takes one or more ROM ld files as trailing
  arguments and cat's them in order (was a single fixed argument).
- ameba_board.cmake keeps the previous single-script default and lets an
  arch CMakeLists override it via AMEBA_ROM_LDS; the list is resolved to
  full paths and passed to the generator.
- rtl8721f/CMakeLists.txt sets AMEBA_ROM_LDS to its four ROM symbol
  scripts, matching its ameba_board.mk cat order.

rtl8721dx and rtl8720f are unchanged (still the single default script).
Verified on rtl8721f: the nsh CMake build now links the nuttx ELF
cleanly with no undefined NS-BSS or rtw_* symbols.

Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
Assisted-by: Claude <noreply@anthropic.com>
2026-08-28 08:41:39 +08:00
DuoYuWang
519c9a4b8b stm32h7: Keep protected user SRAM non-shareable.
The generic ARMv7-M user SRAM helper marks memory shareable.  STM32H7
Protected user data and heaps can reside in cacheable AXI or D2 SRAM, where
userspace synchronization needs LDREX/STREX to use the CPU-local exclusive
monitor.

Map protected user SRAM as Normal, cacheable, and non-shareable.  Dual-core
RPTUN SRAM remains unaffected because it is mapped separately with explicit
shareable attributes.

Tested by booting a Protected image and running user and kernel work-queue
stress tests on an STM32H7 PX4 FMUv6C.

Assisted-by: Codex:GPT-5
Signed-off-by: DuoYuWang <thirteenking.wang@gmail.com>
2026-08-28 08:40:21 +08:00
DuoYuWang
b1a4d858dd stm32h7: Use the selected SRAM end for the protected user heap.
up_allocate_heap() calculates the available user heap from SRAM_END but
previously placed the aligned region relative to SRAM123_END.  That mixes
the selected primary SRAM with a fixed D2 SRAM boundary and leaves
SRAM123_END undefined for dual-core M7 and M4 configurations.

Place the user heap relative to SRAM_END so its size, MPU alignment, and
location all refer to the SRAM region selected by the chip configuration.

Tested by building and booting a Protected image on an STM32H7 PX4 FMUv6C.

Assisted-by: Codex:GPT-5
Signed-off-by: DuoYuWang <thirteenking.wang@gmail.com>
2026-08-28 08:40:21 +08:00
jsanchez-2g
292b22f9d8 arm/stm32: Preserve ICACHE state when reading UID
The unique ID on STM32 Cortex-M33 parts is stored in flash information
memory, which cannot be accessed while the instruction cache is enabled.

Add an ICACHE state helper, temporarily disable the instruction cache
while reading the UID using 32-bit accesses, and restore it only when it
was originally enabled. This preserves the caller's cache state and
prevents a bus fault during UID access.

Assisted-by: Codex:gpt-5

Signed-off-by: jsanchez-2g <jsanchez@2g-eng.com>
2026-08-28 08:10:28 +08:00
Sounak Ranjan Das
be5c9b243b arch/arm/stm32h5: Add WWDG support.
Add WWDG driver support for STM32H5.
Enable the WWDG peripheral clock when WWDG is enabled.

It's based on STM32H7. This contribution has been
reduced to the minimum number of changes from the
H7 version.

Signed-off-by: Liam Howatt <liamhowatt@geotab.com>
Co-authored-by: Liam Howatt <liamhowatt@geotab.com>
2026-08-28 08:10:17 +08:00
zhangyu117
850805d70c arch/arm/src: realize atomic for cxd56, rp2040 and lc823450
Some checks are pending
MemBrowse Memory Report / changes-filter (push) Waiting to run
MemBrowse Memory Report / load-targets (push) Waiting to run
MemBrowse Memory Report / identical (push) Blocked by required conditions
MemBrowse Memory Report / analyze (push) Blocked by required conditions
Add per-chip atomic hwspinlock device definitions for cxd56, rp2040,
and lc823450. Replace CXD56_TESTSET with CXD56_ATOMIC_WITH_HWSEM
which selects LIBC_ATOMIC_HWSPINLOCK.

RP2040: Cortex-M0+ no atomic, IRQ for non-SMP, hwspinlock for SMP.
CXD56XX: CXD56_USE_SYSBUS controls hwsem usage in SMP.
LC823450: toolchain supports atomic, hwspinlock optional for SMP.

Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
2026-08-27 11:13:29 +08:00
zhangyu117
b25f6f8a86 libc/machine: realize atomic based on hwspinlock
Implement atomic_lock/atomic_unlock using hwspinlock when
CONFIG_LIBC_ATOMIC_HWSPINLOCK is selected, and using up_irq_save/
up_irq_restore when CONFIG_LIBC_ATOMIC_IRQ is selected. Rename
arch_atomic_irq.c to arch_atomic.c.

The 64-bit atomic operations use spinlock (spin_lock_irqsave)
regardless of the selected backend, ensuring multi-core safety.

Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
2026-08-27 11:13:29 +08:00
zhangyu117
86498c58e1 arch/arm/src: add hwspinlock driver for cxd56, rp2040 and lc823450
Add hardware spinlock driver implementations for cxd56, rp2040, and
lc823450 chips. These drivers provide the hwspinlock_ops_s interface
used by the atomic hwspinlock backend.

Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
2026-08-27 11:13:29 +08:00
dechao_gong
49f87935e5 arch/arm/rtl8721f: add RTC driver support
Wire the shared Ameba RTC driver (arch/arm/src/common/ameba/ameba_rtc.c)
into RTL8721F (amebagreen2).  The driver is chip-agnostic and reads only
per-chip macros from ameba_rtc_chip.h; RTL8721F differs from amebadplus
only in the RTC interrupt vector (RTL8721F_IRQ_RTC, vector 41).  The
APBPeriph_RTC masks and RTC_BASE_YEAR (1900) are identical across all
current Ameba chips.

 - ameba_rtc_chip.h: per-chip RTC IRQ / clock masks / base year
 - Make.defs, ameba_board.mk: compile ameba_rtc.c and the fwlib RAM
   RTC source when CONFIG_AMEBA_RTC=y
 - board: rtl8721f_rtc.c registers /dev/rtc0 from bringup
 - configs/rtc: examples/alarm profile

Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
Assisted-by: Claude <noreply@anthropic.com>
2026-08-27 01:09:15 +08:00
dechao_gong
01041d2b1a arch/arm/rtl8720f: add RTC driver support
Wire the shared Ameba RTC driver (arch/arm/src/common/ameba/ameba_rtc.c)
into RTL8720F.  The driver is chip-agnostic and reads only per-chip macros
from ameba_rtc_chip.h; RTL8720F differs from amebadplus only in the RTC
interrupt vector (RTL8720F_IRQ_RTC, vector 33).  The APBPeriph_RTC masks
and RTC_BASE_YEAR (1900) are identical across all current Ameba chips.

 - ameba_rtc_chip.h: per-chip RTC IRQ / clock masks / base year
 - Make.defs, ameba_board.mk: compile ameba_rtc.c and the fwlib RAM
   RTC source when CONFIG_AMEBA_RTC=y
 - board: rtl8720f_rtc.c registers /dev/rtc0 from bringup
 - configs/rtc: examples/alarm profile

Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
Assisted-by: Claude <noreply@anthropic.com>
2026-08-27 01:09:15 +08:00
dechao_gong
2b65c77adb arch/arm/rtl8721dx: add shared Ameba RTC driver
Expose the Ameba on-chip RTC as a NuttX date/time RTC at /dev/rtc0
(rdtime/settime) with a single one-shot alarm (setalarm/rdalarm/
cancelalarm/setrelative) that fires the RTC interrupt and the upper-half
callback.  The same hardware also backs the arch date/time RTC hooks
(up_rtc_initialize/getdatetime/settime, g_rtc_enabled) so the NuttX
system time is seeded from it.

The driver sits on the SDK fwlib RTC API (mirrored structures + local
externs, no vendor headers pulled into the NuttX include world).  The
fwlib RTC API lives in the RAM source ameba_rtc.c, so it is added to the
board fwlib build under CONFIG_AMEBA_RTC.  The hardware keeps a year plus
a day-of-year (no month/day register); the driver bridges that to the
NuttX month/day calendar with the libc UTC routines (timegm/gmtime_r),
which is exact and reversible.

The only per-chip fact -- the RTC interrupt vector -- lives in the
per-chip ameba_rtc_chip.h; the shared driver is never edited for a new
Ameba chip.  A configs/rtc profile (examples/alarm) is added for
verification.

Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
Assisted-by: Claude <noreply@anthropic.com>
2026-08-27 01:09:15 +08:00