Commit graph

62748 commits

Author SHA1 Message Date
Alan Carvalho de Assis
edbc03e40a boards: stm32f4discovery: add toybox defconfig
Same shape as boards/sim/sim/sim/configs/toybox: CONFIG_SYSTEM_TOYBOX=y
with CONFIG_INIT_ENTRYPOINT="toybox_main", built on top of the existing
stm32f4discovery:nsh defconfig's board/console setup.

Needs several options nsh's defconfig doesn't, since Toybox's library
code references more of NuttX's libc unconditionally than NSH does:
CONFIG_ALLOW_MIT_COMPONENTS (gates CONFIG_LIBC_REGEX -- grep/sed/etc),
CONFIG_ARCH_SETJMP_H (sigjmp_buf; the REPL's rebound trap uses
sigsetjmp/siglongjmp), CONFIG_LIBC_EXECFUNCS, CONFIG_LIBC_LOCALE,
CONFIG_LIBC_LOCALTIME, CONFIG_PIPES, CONFIG_PSEUDOFS_SOFTLINKS,
CONFIG_FS_NOTIFY (tail -f), CONFIG_SCHED_HAVE_PARENT (waitpid()).

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Assisted-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-14 10:20:52 +08:00
Alan Carvalho de Assis
9f0f886c30 boards: sim: add sim:toybox defconfig
CONFIG_SYSTEM_TOYBOX=y with CONFIG_INIT_ENTRYPOINT="toybox_main":
Toybox as the system's shell instead of NSH. No NSH config is present
-- Toybox has no dependency on it in either direction (see
apps/system/toybox/Kconfig's SYSTEM_TOYBOX_BUILTIN_BRIDGE).

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Assisted-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-14 10:20:52 +08:00
Alan Carvalho de Assis
c1891e07c9 fs: resolve a trailing lone '.' path component
inode_nextname() already skipped a '.' segment mid-path (e.g. "./foo"),
but only checked for a '/' right after it -- a path ending in a bare
'.' (e.g. "/foo/.", or "." itself once AT_FDCWD resolution prepends
$PWD) fell through and was looked up as a literal child named ".",
which no real node is ever named, failing with ENOENT.

This broke every "operate on the current directory" idiom relative
paths rely on: bare `ls`, `stat .`, `cd .`, etc., all failed outright
even though the equivalent absolute path worked fine. Found while
testing the Toybox port's interactive REPL, but this is generic VFS
path resolution, not Toybox-specific.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Assisted-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-14 10:20:52 +08:00
Alan Carvalho de Assis
3cbf6f2168 libc: add wait4()
wait4() is BSD/Linux-standard (used by toybox's "time" applet) but NuttX
only had waitpid()+getrusage() separately. Add it to libs/libc/unistd/
built on top of those two existing primitives, so it needs no syscall
plumbing of its own and works unmodified across flat/protected/kernel
build separation. Prototype added to include/sys/wait.h.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Assisted-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-14 10:20:52 +08:00
Alan Carvalho de Assis
3635004dcd libs/libc/grp: fix getgrbuf_r() pointer-alignment padding
padlen = sizeof(void *) - (addr % sizeof(void *)) never returns 0, even
when addr is already pointer-aligned -- it returns a full alignment unit
instead. Since callers size buflen for zero padding, the subsequent
"buflen < padlen + reqdlen" check then always fails, so getgrgid()/
getgrnam() and their _r variants always return ERANGE.

Found via `id` on sim:toybox, which resolves gid 0 to "root" through
this path.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Assisted-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-14 10:20:52 +08:00
Marco Casaroli
198747322c boards/lm3s6965-ek: Link the protected kernel against kflash.
In a protected build the kernel must stay in the flash half that
memory.ld gives it.  ARCHSCRIPT selected ld.script, which declares the
whole 256 KiB of flash as one region, so nothing held the kernel to its
half.  The kernel image grew past the boundary unseen:  its .data
initialiser ran 1384 bytes into 0x00020000, where the user image is
programmed.

Select memory.ld and kernel-space.ld when CONFIG_BUILD_PROTECTED is set.
The link now fails when the kernel does not fit.

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-08-14 09:49:27 +08:00
Marco Casaroli
3f38ca2729 boards/lm3s6965-ek: Trim qemu-protected to fit the part.
The protected build gives the kernel the first 128 KiB of flash and the
user image the second.  Both halves were full.  The kernel image was
132456 bytes and the user image 130668, which is 1308 bytes more than
the 256 KiB the LM3S6965 has.  The two images overlapped.

Remove from the configuration what QEMU cannot use, and what other
configurations of this board already cover:  MMC/SD over SPI with SSI0,
because the QEMU model has no SSI; semihosting hostfs; the GPIO
interrupt ports, which no driver in this configuration uses; and the
wget example with its web client.

The kernel image is now 124580 bytes and the user image 125500.  Each
half has more than 5 KiB free.

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-08-14 09:49:27 +08:00
raiden00pl
e64b28974b boards/nrf5340-dk: configure HFXO capacitance
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
The nRF5340 DK uses the HFXO internal load capacitors at 7 pF.
Provide the board value so nrf53_oscconfig() programs XOSC32MCAPS
instead of leaving the radio crystal untrimmed.

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-08-13 13:09:35 -03:00
raiden00pl
45657b976b arch/nrf53: fix HFXO trim field extraction
fix HFXO trim field extraction

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-08-13 21:52:30 +08:00
Ricard Rosson
3ac88f0f97 drivers/lcd: honour the LCD_APA102_* settings in the apa102 LCD driver
drivers/lcd/Kconfig offers CONFIG_LCD_APA102_XRES, CONFIG_LCD_APA102_YRES and
CONFIG_LCD_APA102_FREQUENCY under "if LCD_APA102", but apa102_lcd.c tests for
CONFIG_APA102_XRES, CONFIG_APA102_YRES and CONFIG_APA102_FREQUENCY, which no
Kconfig file defines.  The #ifndef fallbacks therefore always win and the
matrix geometry is hard-wired to 16x16 no matter what is configured.  The
frequency setting is doubly dead: even the fallback is unused, because
apa102_configspi() calls SPI_SETFREQUENCY() with APA102_SPI_MAXFREQUENCY from
include/nuttx/leds/apa102.h, which is 100 kHz (its "Default 4MHz" comment
notwithstanding), so the chain is always clocked at 100 kHz.

Use the names the Kconfig actually defines and drive the bus at the
configured frequency.  The fallback definitions are kept for an
out-of-Kconfig build and given the Kconfig defaults; 16x16 keeps the previous
geometry for anyone who never set the options.

Verified on stm32f4discovery:nsh with CONFIG_LCD_APA102_XRES=8,
CONFIG_LCD_APA102_YRES=4 and CONFIG_LCD_APA102_FREQUENCY=4000000: the shadow
framebuffer in g_apa102dev shrinks to 8x4 LEDs and the SPI frequency
argument is 0x003d0900, where before the settings had no effect at all.

Signed-off-by: Ricard Rosson <ricard@groundbits.com>
Assisted-by: Claude Opus 5 (Claude Code)
2026-08-13 09:54:26 -03:00
Ricard Rosson
0735bc16b9 drivers/lcd: rename apa102.c/max7219.c to unique object names
drivers/ is built by a single flat Makefile: every per-directory Make.defs
appends its sources to one CSRCS list and its directory to one VPATH, and the
objects all land in drivers/ named after the source basename.  Two sources
with the same basename in different subdirectories therefore map to the same
object, and make resolves the prerequisite through VPATH, which is searched
in the order drivers/Makefile includes the Make.defs files.  lcd is included
before leds, so drivers/lcd always wins.

Both apa102 and max7219 exist twice, once as an LCD front-end and once as an
LED driver:

  drivers/lcd/apa102.c   CONFIG_LCD_APA102    drivers/leds/apa102.c   CONFIG_LEDS_APA102
  drivers/lcd/max7219.c  CONFIG_LCD_MAX7219   drivers/leds/max7219.c  CONFIG_LEDS_MAX7219

drivers/lcd/Make.defs puts lcd on the VPATH for the whole directory whenever
CONFIG_LCD=y, so selecting only the LED driver still builds apa102.o from
drivers/lcd/apa102.c and the selected LED driver is never compiled at all.
Because the LCD front-ends take their constants from
include/nuttx/lcd/apa102.h and include/nuttx/lcd/max7219.h, which are behind
CONFIG_LCD_APA102 / CONFIG_LCD_MAX7219, the substituted source does not even
compile.  With CONFIG_LCD=y + CONFIG_LEDS_APA102=y and CONFIG_LCD_APA102
unset:

  lcd/apa102.c:701:20: error: 'APA102_BLACK' undeclared (first use in this
  function); did you mean 'APA102_BPP'?

and correspondingly for CONFIG_LEDS_MAX7219 without CONFIG_LCD_MAX7219:

  lcd/max7219.c:773:20: error: 'MAX7219_BLACK' undeclared (first use in this
  function); did you mean 'MAX7219_BPP'?

So neither LED driver can be built together with CONFIG_LCD, and there is no
diagnostic pointing at the real cause.

Give the LCD front-ends distinct basenames.  The LCD side is the adapted use
of these parts (an LED matrix driven as a display), and drivers/lcd already
names such variants for their role, e.g. ht16k33_14seg.c, so the suffix goes
there and the LED drivers keep the plain part names.  The CMake build derives
object paths from the source directory and was never affected; its source
lists are updated to match.

Signed-off-by: Ricard Rosson <ricard@groundbits.com>
Assisted-by: Claude Opus 5 (Claude Code)
2026-08-13 09:54:26 -03:00
Alin Jerpelea
850ac5ca63 Documentation/hpm6360evk: improve readability
separate code sections for better readability

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2026-08-13 08:55:56 -03:00
kay-lambdadelta
ebb9d80bef tools/rust: Fix softfloat abi target spec name
Rename abi "x86-softfloat" to just "softfloat" to enable compatibility
with newer rust nightly versions.

Rust recently changed the name of the softfloat abi to one more unified
across targets, and more recently, removed the compat alias.

Signed-off-by: Kay Lambdadelta <lambdadeltakay@proton.me>
2026-08-13 12:41:54 +02:00
zhangyu117
d4d4db5bb1 arch/tricore: perf.c donot depend on illd
Replace the iLLD helpers IfxCpu_resetAndStartCounters() and
IfxCpu_getClockCounter() in the performance-counter path with direct
CSR accesses via tricore_mtcr()/tricore_mfcr().

tricore_reset_ccnt() disables the CPU cycle counter (CPU_CCTRL), clears
CPU_CCNT, then re-enables it; up_perf_gettime() reads CPU_CCNT directly.
This removes the arch/tricore perf path's dependency on the Infineon
iLLD layer. No behavior change.

Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
2026-08-13 12:38:45 +02:00
zhangyu117
d2c91137e5 arch/tricore: cachecode donot depend on illd
Replace the iLLD register structures (Ifx_CPU_PCON0/1/2, Ifx_CPU_DCON0/1/2)
and the IfxCpu_cfg.h cache-size/line-size macros in the cache path with
direct CSR accesses via tricore_mtcr()/tricore_mfcr() and locally defined
PCON/DCON bit masks.  Also switch __isync()/__dsync() to the UP_ISB()/
UP_DSB() barrier wrappers.

This removes the arch/tricore cache path's dependency on the Infineon
iLLD layer.  No behavior change.

Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
2026-08-13 12:38:45 +02:00
zhangyu117
ffc9846a02 arch/tricore: add tricore_mtcr and tricore_mfcr macros
Add tricore_mtcr()/tricore_mfcr() inline-assembly wrappers for the
MTCR/MFCR (move to/from Core Special Function Register) instructions.
These let arch/tricore code access CSRs directly without relying on the
Infineon iLLD intrinsics, and are used by the following iLLD-removal
change in the performance-counter path.

Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
2026-08-13 12:38:45 +02:00
Javier Alonso
f8cf5f9d4e arch/s32k3xx: initializers clobbering rx_pin instead of enable_high
The `rx_pin` configuration when `CONFIG_S32K3XX_FLEXCAN2` is defined is
overwritten if `PIN_CAN2_ENABLE` is defined, breaking the flexcan config
for S32K3 MCU.

Signed-off-by: Javier Alonso <javieralonso@geotab.com>
2026-08-13 12:29:11 +02:00
Javier Alonso
2a777381d6 arch/kinetis: initializers clobbering rx_pin instead of enable_high
The `rx_pin` configuration when `CONFIG_KINETIS_FLEXCAN2` is defined is
overwritten if `PIN_CAN2_ENABLE` is defined, breaking the flexcan config
for Kinetis MCU. Additionally, the `.enable_high` configuration points to
a non-defined constant/macro (looks like a legacy from the first driver
definition). Based on regularly maintained drivers (such as s32k3), this
was changed to `CAN2_ENABLE_OUT`

Signed-off-by: Javier Alonso <javieralonso@geotab.com>
2026-08-13 12:29:11 +02:00
Javier Alonso
8730a75687 arch/s32k1xx: initializers clobbering rx_pin instead of enable_high
The `rx_pin` configuration when `CONFIG_S32K1XX_FLEXCAN2` is defined is
overwritten if `PIN_CAN2_ENABLE` is defined, breaking the flexcan config
for S32K1 MCU. Additionally, the `.enable_high` configuration points to
a non-defined constant/macro (looks like a legacy from the first driver
definition). Based on regularly maintained drivers (such as s32k3), this
was changed to `CAN2_ENABLE_OUT`

Signed-off-by: Javier Alonso <javieralonso@geotab.com>
2026-08-13 12:29:11 +02:00
raiden00pl
bf45e12fdd Revert "cmake: normalize .config on reconfigure"
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
This reverts commit 9b0d46c222.

This change was made to fix a problem in NTFC with kernel build,
but it introduces an incompatibility with make.

We are reverting this change and the NTFC issue will be resolved
on the NTFC side.

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-08-13 07:54:00 +02:00
Abhishek Mishra
3bc0b17908 Documentation: document supplementary groups and setresuid/setresgid
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
Document CONFIG_SCHED_NGROUPS, setgroups/getgroups/initgroups, and
setresuid/setresgid in the user identity guide.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-08-12 16:06:03 -03:00
Abhishek Mishra
cf3781b7f0 sched: add setresuid and setresgid
Complete the POSIX credential setters for real/effective/saved UID and
GID so login and privilege-drop paths can clear saved-root without
relying on setreuid patterns alone.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-08-12 16:06:03 -03:00
Abhishek Mishra
1014c49881 sched: add supplementary group IDs (setgroups/getgroups/initgroups)
Track supplementary GIDs per task group, wire setgroups/getgroups
syscalls when CONFIG_SCHED_NGROUPS > 0, and honor them in DAC checks
via nxsched_has_gid().  When NGROUPS is 0, libc provides getgroups/
setgroups stubs.  initgroups() fails instead of silently truncating
when membership exceeds CONFIG_SCHED_NGROUPS.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-08-12 16:06:03 -03:00
Alin Jerpelea
563857a4f8 boards/risc-v/hpm6360evk: build fix
switch to flash.script to avoid running out of storage

before:
Register: hello
Register: nsh
Register: sh
LD: nuttx
riscv32-unknown-elf-ld: /nuttx/nuttx section .text will not fit in region ilm
riscv32-unknown-elf-ld: region ilm overflowed by 904 bytes
Memory region         Used Size  Region Size  %age Used
             ilm:      131976 B       128 KB    100.69%
             dlm:       11360 B       128 KB      8.67%
        axi_sram:          0 GB       256 KB      0.00%
axi_sram_noncacheable:          0 GB       256 KB      0.00%
        ahb_sram:          0 GB        32 KB      0.00%
make[1]: *** [Makefile:195: nuttx] Error 1
make: *** [tools/Unix.mk:569: nuttx] Error 2

after:
Register: hello
Register: sh
Register: nsh
LD: nuttx
Memory region         Used Size  Region Size  %age Used
           flash:      145132 B        16 MB      0.87%
             ilm:          0 GB       128 KB      0.00%
             dlm:       11360 B       128 KB      8.67%
        axi_sram:          0 GB       256 KB      0.00%
axi_sram_noncacheable:          0 GB       256 KB      0.00%
        ahb_sram:          0 GB        32 KB      0.00%
CP: nuttx.hex

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2026-08-13 02:41:57 +08:00
Alan Carvalho de Assis
c9a27f00c6 arch/sim: Fix #ifdef/#else on x11 event loop
As suggested by Xiang Xiao, let's fix the identation

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2026-08-12 14:08:34 -03:00
Alan Carvalho de Assis
17025085ea arch/sim: Add support to emulated Mouse
This commit adds support for three buttons Mouse emulation on SIM.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Assisted-by: Claude Code
2026-08-12 14:08:34 -03:00
Alan Carvalho de Assis
42ac826a4c doc/sim: Add Documentation about SIM Input
This commit adds basic information about SIM Input support.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2026-08-12 14:08:34 -03:00
Alin Jerpelea
e2ab02d368 Documentation\hpm6360evk: update guide to match the user experience
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
updated the cross-compiler download, added verification steps and rearanged the
guide

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2026-08-12 17:14:11 +02:00
alexcekay
a450392da5 fs/cromfs: Fix stale cache read in read() fast path.
cromfs_read()'s fast path decompresses a block directly into the
caller's buffer whenever a read reaches a block at its start and the
caller has room for the whole decompressed block, bypassing the
per-file decompression cache (ff_buffer). It nonetheless marked that
block as cached by setting ff_offset, without ever writing ff_buffer
itself.

A later read of the same block that fell onto the slow path trusted
that false cache tag, skipped decompression, and copied from
ff_buffer without it ever having been populated for that block. A
repeated identical fast-path read of the same block hit the same
false tag and skipped decompression entirely, leaving the caller's
buffer untouched and returning whatever was already there.

Fixed by having the fast path only read the cache, never populate it:
reuse ff_buffer when a prior slow-path read already cached the same
block, otherwise decompress straight into the caller's buffer without
touching ff_offset/ff_buffer.

Co-authored-by: Pavlo
Assisted-by: Claude Code:claude-sonnet-5
Signed-off-by: alexcekay <alexander@auterion.com>
2026-08-12 12:12:46 -03:00
Alin Jerpelea
4977c28a3f Documentation: add NuttX 13.0.1 release notes
add release notes for NuttX 13.0.1 release

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2026-08-12 21:53:28 +08:00
zhanghongyu
8422531f93 net/udp: fix d_len corruption for 2nd+ SO_REUSEADDR listener
In udp_input()'s broadcast/multicast fan-out loop, each iteration
calls netdev_iob_replace(dev, iob) to swap in a freshly cloned iob
before handing the packet to the next matching connection. That
function unconditionally sets dev->d_len = iob->io_pktlen, which is
the full frame length (IP + UDP headers + payload), undoing the
'dev->d_len -= udpiplen' done once before the loop to strip the
headers off for udp_input_conn().

As a result, every connection after the first sees a d_len that is
udpiplen (IP+UDP header length, eg 28 bytes for IPv4) too large.
This value flows into udp_datahandler() as buflen (it reads
dev->d_len directly) and is stored as the queued packet's declared
length in the connection's read-ahead iob chain. Once more than one
such oversized entry has queued up in the same chain, the consumer
(udp_readahead() in udp_recvfrom.c) parses the following entry's
metadata starting at the wrong offset, so whatever byte happens to
land on src_addr_size is trusted as-is. That single byte (0-255) is
then used as the length in iob_copyout(srcaddr, iob, src_addr_size,
...), which fills a fixed-size stack buffer with no bounds check
outside a DEBUGASSERT - compiled out in release builds - so an
oversized value overflows that stack buffer.

Re-apply the same '-= udpiplen' header-stripping after each
netdev_iob_replace() call in the loop, matching what's already done
once before the loop for the first connection.

Inside udp_input_conn, d_appdata is always set first, and since neither
the ICMP nor ICMPv6 process accesses d_appdata, the redundant d_appdata
settings have been removed.

Signed-off-by: yi chen <94xhn1@gmail.com>
2026-08-12 09:41:52 -03:00
dechao_gong
0be19937ba Documentation/rtl8721dx,rtl8721f: document the I2C driver
The I2C master driver support for the RTL8721Dx (pke8721daf) and RTL8721F
(rtl8721f_evb) boards was merged without the matching board documentation.
Add the missing I2C entry to each board's Features list and an "i2c"
configuration section describing the /dev/i2cN devices, the board pin
table, and the i2ctool usage, mirroring the existing gpio/uart sections.

Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
Assisted-by: Claude <noreply@anthropic.com>
2026-08-12 08:46:16 -03:00
dechao_gong
af49db4483 arch/arm/rtl8720f: add I2C master driver support
Wire the RTL8720F to the shared Ameba I2C master driver
(arch/arm/src/common/ameba/ameba_i2c.c), reusing it unchanged.

Add the per-chip header arch/arm/src/rtl8720f/ameba_i2c_chip.h supplying
the chip's I2C wiring: two controllers (I2C0/I2C1) on their non-secure
register aliases (0x401c8000 / 0x401c9000), the APBPeriph function/clock
masks, the crossbar SCL/SDA pad-mux codes (59/60 and 61/62), and
AMEBA_I2C_HAS_DMA_FIELDS=1 (the chip's I2C_InitTypeDef carries the DMA
request-level fields).

Add the board glue: rtl8720f_i2c.c registers I2C0 at /dev/i2c0
(PA22/PA23) and I2C1 at /dev/i2c1 (PA24/PA25), plus the build wiring
(Make.defs / CMakeLists.txt / ameba_board.mk pull in the common driver
and the fwlib ram_common/ameba_i2c.c data-table source), the bringup
registration hook and the board header declaration.

Add the i2c defconfig (minimal NSH with the i2ctool) and document the
config in the board index.

Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
Assisted-by: Claude <noreply@anthropic.com>
2026-08-12 08:46:16 -03:00
dechao_gong
18d2ae253c arch/arm/rtl8720f: add UART master driver support
Wire the shared common UART driver
(arch/arm/src/common/ameba/ameba_uart.c) into RTL8720F.  Add an
ameba_uart_chip.h supplying the per-chip UART parameters: two
general-purpose controllers (UART0/UART1), their non-secure register
bases (0x401C3000 / 0x401C4000 -- the fwlib UART_DEV_TABLE points at
the non-secure alias), NVIC vectors, APBPeriph function/clock masks
and the crossbar TX/RX pad-mux function codes.

The fwlib ROM UART routines index data tables (UART_DEV_TABLE,
APBPeriph_UARTx) that live in fwlib ram_common/ameba_uart.c, so that
source is compiled in when CONFIG_AMEBA_UART is set.  Wire
CONFIG_AMEBA_UART into Make.defs/CMakeLists/ameba_board.mk, add the
board port table (UART0 at /dev/ttyS1, PA22 TX / PA23 RX, 115200 8N1)
with bringup registration, a uart config and board documentation.

Hardware-verified on rtl8720f_evb: serialrx/serialblaster over a
PA22-to-PA23 TX/RX loopback transferred all 2600 bytes intact.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
2026-08-12 08:46:16 -03:00
dechao_gong
3197472ad4 arch/arm/rtl8720f: add single-port GPIO support
RTL8720F drives all GPIO through a single 32-pin port A controller
served by one NVIC vector, unlike RTL8721Dx (ports A/B) or RTL8721F
(ports A/B/C).  Add an ameba_gpio_chip.h that configures the shared
common GPIO driver (arch/arm/src/common/ameba/ameba_gpio.c) for a
single port: AMEBA_GPIO_NPORTS=1, AMEBA_GPIO_PORT_IRQS={GPIOA} and
the APBPeriph_GPIO gate bits.

GPIO_INTStatusGet/ClearEdge live in the RTL8720F ROM symbol table, so
no fwlib ram_common object needs compiling in.  Wire CONFIG_AMEBA_GPIO
into Make.defs/CMakeLists/Kconfig, add the board pin table (PA22 out,
PA23 in, PA24 interrupt) with bringup registration and a gpio config.

Hardware-verified on rtl8720f_evb: output, input and (falling-edge)
interrupt all confirmed via a PA22-to-PA24 loopback.

Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
Assisted-by: Claude <noreply@anthropic.com>
2026-08-12 08:46:16 -03:00
Luka Filipović
62b41ad9b4 arch/arm/src/common/stm32: Bound SDIO command response wait by time.
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
stm32_waitresponse() polls SDIO_STA bounded only by an iteration
counter, set to 0x7fffffff for all R1/R1B/R2/R4/R5/R6 commands.  The
hardware CTIMEOUT flag is the intended exit for a missing response,
but it is only generated while the card clock is running and the CPSM
has reached its Wait state.  If the card clock stops or the peripheral
fails, SDIO_STA never updates and the loop spins for INT32_MAX
iterations while holding the FAT filesystem lock, at the caller's
priority-inheritance boosted priority if higher priority tasks block
on the filesystem.  Since the mmcsd layer retries failed commands,
the driver's recovery paths are never reached and the system never
recovers.

Bound the wait by time instead: 250 ms for response-bearing commands
(the largest timeout the SD specification allows for any operation)
and 10 ms for the no-response/R3/R7 cases.  CTIMEOUT remains the
normal error exit within microseconds; the software bound only fires
when the peripheral itself is dead, converting an unbounded spin into
-ETIMEDOUT so the existing mmcsd retry logic can run.

Signed-off-by: Luka Filipović <filipovicluka3@gmail.com>
Assisted-by: Claude Code:claude-fable-5
2026-08-12 15:41:32 +08:00
raiden00pl
9b0d46c222 cmake: normalize .config on reconfigure
olddefconfig only ran when .config was generated from the defconfig,
so changes applied to an existing .config (e.g. with kconfig-tweak)
never got their dependent defaults. Run olddefconfig on reconfigure as
well, as the Make flow does on every build.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-12 14:38:44 +08:00
dechao_gong
30cbb23e6b arch/arm/rtl8721f: add I2C master driver support
Wire the shared Ameba I2C master lower-half (arch/arm/src/common/
ameba/ameba_i2c.c) into the RTL8721F (amebagreen2) build through a
per-chip header (ameba_i2c_chip.h), and register the RTL8721F EVB
buses at /dev/i2cN.

Per-chip differences from the other Ameba SoCs (non-secure register
bases, crossbar pinmux codes, APB clock masks and the fwlib
I2C_InitTypeDef layout) are isolated in ameba_i2c_chip.h; no change to
the shared driver is needed.

Verified end-to-end on hardware against a second Ameba board acting
as an I2C slave: address ACK, register write and read-back over
repeated-START, and bus scan all pass on I2C0 (PA22/PA23).

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
2026-08-12 14:22:00 +08:00
dechao_gong
dfc55c9bbe arch/arm/rtl8721dx: add shared Ameba I2C driver
Add a shared NuttX I2C master lower-half for the Realtek Ameba I2C
controllers (I2C0/I2C1) in arch/arm/src/common/ameba, driven through
the SDK fwlib in polling mode.  Per-chip wiring (controller count,
register bases, clock masks, crossbar pad-mux codes and the fwlib
I2C_InitTypeDef layout) lives in arch/arm/src/rtl8721dx/ameba_i2c_chip.h
so a port to the other Ameba chips only supplies a same-named header.

Each controller registers as /dev/i2cN from pke8721daf bring-up through
the stock I2C character driver; a dedicated `i2c` defconfig drives the
i2ctool for validation.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
2026-08-12 14:22:00 +08:00
Ricard Rosson
9b02dead5d boards/esp32s3-ws-lcd128: use esp_hr_timer_init(), fix Wi-Fi build
esp32s3_bringup.c still guards on CONFIG_ESP32S3_RT_TIMER, includes
"esp32s3_rt_timer.h" and calls esp32s3_rt_timer_init().  None of those
exist any more: c17e16eaed ("xtensa/espressif: Update common-source
integration for Xtensa devices") deleted the chip-specific RT timer and
replaced it with the common-source HR Timer, and updated every other
esp32s3 board's bringup to CONFIG_ESPRESSIF_HR_TIMER /
"espressif/esp_hr_timer.h" / esp_hr_timer_init().  This board was missed.

The stale guard is not dead code: ESPRESSIF_WIRELESS selects
ESP32S3_RT_TIMER (which survives only as a deprecated alias that selects
ESPRESSIF_HR_TIMER), so enabling Wi-Fi on this board turns the guard on and
the build fails outright:

  board/esp32s3_bringup.c:61:12: fatal error: esp32s3_rt_timer.h:
  No such file or directory

No esp32s3-ws-lcd128 defconfig enables Wi-Fi, which is why CI has not
caught it.

Switch to the same guard, include and initializer the other esp32s3 boards
use.  No functional change for the existing defconfigs: they leave both
ESP32S3_RT_TIMER and ESPRESSIF_HR_TIMER unset, so the block stays compiled
out.

Verified with esp32s3-ws-lcd128:nsh plus CONFIG_ESPRESSIF_WIFI=y (and the
Wi-Fi prerequisites the in-tree wifi defconfigs set: SCHED_LPWORK,
DRIVERS_WIRELESS/DRIVERS_IEEE80211, NETDEV_WIRELESS_IOCTL, IOB_NCHAINS,
TLS_TASK_NELEM, TIMER): the fatal error above before the change, a clean
build and image after it, with no other change to the configuration.

Signed-off-by: Ricard Rosson <ricard@groundbits.com>
Assisted-by: Claude Opus 5 (Claude Code)
2026-08-12 08:16:52 +02:00
ganjing
a0fcbb7957 libs/libc/risc-v: Refresh memcpy and memset with XLEN-adaptive loops.
Rewrite arch_memcpy.S and arch_memset.S to be register-width aware on
both RV32 and RV64 using REG_L/REG_S/SZREG macros from asm.h.

memcpy gains:
 - 16xSZREG unrolled main loop (128B/iter on RV64, 64B on RV32).
 - Shift-merge path for misaligned src: reads two aligned words
   straddling each output word and shifts them together, so no load
   or store is ever misaligned.
 - Single SZREG and byte loops for remainder and small copies.

memset gains:
 - 32xSZREG unrolled main loop (256B/iter on RV64, 128B on RV32)
   using Duff's device for non-power-of-two remainders.
 - .option norvc ensures fixed 4-byte instruction width for correct
   jump offset calculation in the Duff's device entry.
 - Zero-length input handled correctly (branch to guarded tail).

The old memcpy always used lw/sw even on RV64, wasting half the
memory bandwidth. The old memset unrolled only 16 bytes per iteration.

Signed-off-by: ganjing <ganjing@xiaomi.com>
2026-08-12 10:24:01 +08:00
ganjing
931d5f50d4 libs/libc/risc-v: Add optimized strlcpy.
Add word-at-a-time strlcpy using DETECTNULL for both the copy phase
and the strlen tail when truncated.  The copy loop aligns src and
processes a register at a time, falling to bytewise for the last word
containing the terminator.  When truncated, the remaining src length
is measured with a second word-at-a-time loop.

strlcpy has 46 call sites in a typical kernel image (more than strcpy)
and is not covered by newlib OPTSPEED, making it a high-value target.

Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: ganjing <ganjing@xiaomi.com>
2026-08-12 10:23:47 +08:00
ganjing
ad9c9d41b0 libs/libc/risc-v: Unroll memcmp with 4-word XOR|OR folding.
Reduce branch overhead in the memcmp main loop by comparing four
words per iteration: XOR each pair, OR the four differences together,
and branch once.  On a mismatch the single-word loop locates the
exact differing word within four words of the fault.

Add a beqz guard at .Lbyte_cmp entry to handle the case where the
4-word loop consumes all remaining bytes exactly.

Measured on QEMU RV32: memcmp(128) 313 -> 271 cycles (13% faster).

Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: ganjing <ganjing@xiaomi.com>
2026-08-12 10:23:47 +08:00
ganjing
9b20c629fe libs/libc/risc-v: Add optimized string and memory functions.
Add assembly-optimized implementations for 14 string/memory functions
using word-at-a-time techniques (DETECTNULL, broadcast+XOR) and
XLEN-adaptive macros for both RV32 and RV64:

 - memmove: direction check + forward tail to memcpy, reverse path
   with 16xSZREG unroll and shift-merge for misaligned src.
 - memcmp: word-granularity compare when both pointers share alignment,
   bytewise fallback for mismatched pointers.
 - memchr: broadcast target byte, XOR with each word, DETECTNULL to
   find matches. Counter-based bounds (no pointer overflow).
 - strlen: DETECTNULL word loop, constants loaded from .srodata.
 - strnlen: strlen with counter-based length limit.
 - strcpy/strncpy: word loop with DETECTNULL, zero-fill remainder
   for strncpy. strncpy reuses strcpy via #define USE_AS_STRNCPY.
 - stpcpy/stpncpy: reuse strcpy/strncpy via #define USE_AS_STPCPY.
 - strchr/strchrnul: broadcast+XOR detecting both target char and
   null simultaneously. strchrnul reuses strchr via #define.
 - strrchr: forward scan recording last match position.
 - strncmp: word-at-a-time compare with null detection and counter.
 - strcat: strlen(dst) then strcpy(dst_end, src) word-at-a-time.

Each function is independently selectable via CONFIG_RISCV_<FUNC>,
or all enabled together with CONFIG_RISCV_STRING_FUNCTION=y.

Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: ganjing <ganjing@xiaomi.com>
2026-08-12 10:23:47 +08:00
Marco Casaroli
5dafb683e4 xtensa/esp32: Let a protected build boot from simple boot.
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
A protected build on the ESP32 could only use the legacy IDF image format.
Kconfig allowed simple boot to be selected with BUILD_PROTECTED, because the
legacy format is only a default and not a select, but the result did not link
and then did not boot.

Simple boot has no second-stage bootloader.  __start() maps the flash itself,
so everything it reaches must already be in RAM.  kernel-space.ld pinned none
of it, and it did not place esp32_start at all, so the entry point went to the
flash the code was about to map.  The chip loaded the RAM segments, jumped to
0x400d0ba4 and took an IllegalInstruction on the first instruction.

So this pins the bootloader, flash, ROM, clock and log objects that
bootloader_init() and map_rom_segments() reach, along with esp32_start itself,
and defines the six _image_* symbols that __start() needs.  All of it is
behind CONFIG_ESPRESSIF_SIMPLE_BOOT, so a legacy build gets the same IRAM it
had before.

kernel-space.ld also had no `#include <nuttx/config.h>'.  It held no
conditionals until now, so nothing showed the omission:  the new blocks
compiled away silently and the link failed as if the file had not been
changed.

The default is unchanged.  A protected build still selects the legacy format
unless the user clears CONFIG_ESP32_APP_FORMAT_LEGACY.

Verified on an ESP32-DevKitC V4, ESP32-D0WD-V3 revision 3.1, with
esp32-devkitc:knsh and the legacy format turned off.  The kernel flashes at
0x1000 and the user image at 0x90000, with no bootloader and no partition
table.  It maps seven segments, reaches NSH, and runs ostest to the same point
as the legacy build.

Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-08-12 00:37:18 +08:00
Marco Casaroli
46528ea5ee xtensa/esp32s3: Let a protected build boot from simple boot.
BUILD_PROTECTED defaults ESP32S3_APP_FORMAT_LEGACY to y, so a protected build
has always needed the ESP-IDF second-stage bootloader.  Nothing about the
protected layout requires it:  the kernel and user images are described
entirely by ESP32S3_KERNEL_OFFSET, ESP32S3_KERNEL_IMAGE_SIZE and
ESP32S3_KERNEL_RAM_SIZE, and esp32s3_userspace() maps the user image itself.
Three obstacles stood in the way.

Those three symbols were gated on ESP32S3_APP_FORMAT_LEGACY, but
protected_memory.ld needs all of them for KIROM, KDROM, UIROM, UDROM, KDRAM
and UDRAM.  Without them the region lengths underflow to 2**64-1 and the
kernel/user RAM split lands nowhere, which the hardware reports as a DRAM0
PMS monitor violation once the first user process runs.  The offset becomes
0x0 for simple boot, where the image is flashed at the start of the device.

protected_memory.ld had no case for a 32 MB part, so FLASH_SIZE was
undefined there and ROM, UIROM and UDROM underflowed the same way.
flat_memory.ld has had the case all along.

kernel-space.ld defined none of the symbols simple boot needs
(_image_irom_*, _image_drom_*, _bss_*), and kept none of the early code
resident.  __start() runs bootloader_init() and map_rom_segments() before any
flash mapping exists, so everything they reach has to be in RAM -- including
map_rom_segments() itself, which unmaps the MMU it is running from, and
nuttx_enter_critical(), reached from rtc_clk_init() by way of regi2c.  These
mirror what esp32s3_sections.ld already does for the flat build.

Verified on an ESP32-S3-WROOM-2 (32 MB octal flash), esp32s3-devkit:knsh with
FLASH_MODE_OCT:  boots to NSH and runs ostest, where it reaches the same
timedmutex abort as every other target.  The legacy path is untouched.

Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-08-11 23:49:21 +08:00
guanyi
83e4b6065a drivers/devfreq: add missing governor_data field and ondemand declaration
The ondemand governor (devfreq_ondemand.c) references dev->governor_data
to store its private state, and defines devfreq_ondemand(), but neither
the field in struct devfreq_s nor the function declaration were present
in include/nuttx/devfreq.h.  As a result, building with
CONFIG_DEVFREQ_GOV_ONDEMAND=y failed to compile.

These two definitions were originally introduced by a downstream commit
that was not part of the devfreq upstreaming series, so the gap only
surfaced when the ondemand governor is enabled (which additionally
requires !CONFIG_SCHED_CPULOAD_NONE and is off by default).

Add the governor_data field to struct devfreq_s and declare
devfreq_ondemand() alongside the other governors.

Signed-off-by: guanyi <guanyi@xiaomi.com>
2026-08-11 12:40:27 -03:00
raiden00pl
481d1697a8 arch/x86_64: align the user signal frame and skip the ABI red zone
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
The signal frame was built inside the 128 byte red zone of the
interrupted user code and inherited its stack alignment, so a leaf
function could lose live data to the siginfo copy and the handler
could fault on an SSE access. Build the frame below the red zone,
16 byte aligned; the naked trampoline calls the handler itself and
its call provides the return address slot.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-11 22:06:32 +08:00
raiden00pl
2c79c9951b arch/x86_64: run the signal trampoline on the thread kernel stack
For a thread interrupted in user mode the trampoline ran on the user
stack, where the signal handler then grows over its frame. Run it on
the thread kernel stack, unused while the thread is in user mode. The
stack cannot be selected from the saved CS: up_initial_state() records
the caller CS, a kernel selector even for user threads.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-11 22:06:32 +08:00
raiden00pl
4405b12155 arch/x86_64: restore the kernel stack when a signal handler returns
SYS_signal_handler_return restored RSP from saved_rsp, which is not
written when a task signals itself: synchronous dispatch skips
up_schedule_sigaction(), so the kernel stack pointer was set to zero
and the next push faulted. Save the kernel stack pointer at dispatch
in xcp.kstkptr, as risc-v does, and restore that.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-11 22:06:32 +08:00