This adds support for the PBKDF2 algorithm in the ESP32 crypto
driver. Here, it will take advantage of the hardware-accelerated
implementation of SHA.
Signed-off-by: Vlad Pruteanu <pruteanuvlad1611@yahoo.com>
Add an RP23xx hardware crypto driver for /dev/crypto with SHA-256
support backed by the RP2350 SHA accelerator.
Wire the new driver into the RP23xx ARM build and register
CRYPTO_SHA2_256 through cryptodev.
Also fix the RP23xx SHA256 CSR BSWAP bit definition in both the ARM and
RISC-V RP23xx headers. The previous value used bit 18, but the RP2350
hardware uses bit 12. Without this fix, the accelerator hashed input
words with the wrong byte order and produced incorrect digests.
Signed-off-by: karaketir16 <osmankaraketir@gmail.com>
Remove CONFIG_LCD_PORTRAIT so the ST7789 defaults to landscape
orientation (320x240), matching the GC0308 QVGA output and the
physical screen mounting direction.
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Implement imgdata_ops alloc/free callbacks so the V4L2 framework
can use MMAP mode to allocate frame buffers with proper GDMA
alignment. This lets applications avoid hardcoding platform-
specific alignment values.
- Add esp32s3_cam_alloc() using kmm_memalign with the alignment
derived from the GDMA external memory block size setting.
- Add esp32s3_cam_free() wrapper around kmm_free.
- Introduce ESP32S3_CAM_EXT_MEMBLK / ESP32S3_CAM_DMA_ALIGN macros
so the block size enum and byte alignment are defined in one
place and stay in sync automatically.
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Fix several issues in the ESP32-S3 CAM driver:
- stop_capture: reset DMA channel, CAM module and AFIFO under
spinlock to fully quiesce hardware before returning. Clear
pending VSYNC interrupt to prevent stale ISR firing.
- uninit: reset CAM/AFIFO before releasing DMA to prevent
in-flight transfers after channel detach. Use esp_teardown_irq
with correct peripheral ID (ESP32S3_PERIPH_LCD_CAM) instead of
irq_detach which corrupts the shared IRQ mapping table. Mask
interrupts and clear pending flags under spinlock before
detaching handler.
- uninit: preserve XCLK output so the sensor remains accessible
via I2C for subsequent re-initialization.
- set_buf/uninit: track driver-allocated vs user-provided frame
buffers with fb_allocated flag to prevent double-free when
using V4L2 USERPTR mode.
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Implement get_supported_value, get_value and set_value callbacks
for IMGSENSOR_ID_HFLIP_VIDEO / IMGSENSOR_ID_HFLIP_STILL. This
allows applications to mirror the camera preview horizontally at
runtime via VIDIOC_S_CTRL + V4L2_CID_HFLIP.
The hardware mirror is controlled by register 0x14 (CISCTL_MODE1)
bit[0], which reverses the pixel readout order with zero CPU cost.
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
GC0308 register 0x24 bits[3:0] = 0x06 selects RGB565 output per
datasheet. On an 8-bit DVP bus the high byte is clocked out first,
so the pixel data arrives in memory in big-endian order (RGB565X).
Report V4L2_PIX_FMT_RGB565X so that userspace can detect this and
byte-swap if needed for a little-endian display path.
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
arch/arm/include/imx6/irq.h looks to originally be for i.MX6 Quad
and includes multiple (re)definitions of IRQ names, some of which are
different or don't exist on i.MX6 SoloLite/Solo/Dual/DualLite.
Update irq.h to specify/reserve IRQ names/numbers as defined by the
IM6SDLRM, IMX6DLRM, and IMX6DQRM reference manuals.
Signed-off-by Peter Barada <peter.barada@gmail.com>
Upgrades esptool from v4.8.dev4 to v5.2.0, enabling support for newer chips.
Also adds 'upgrade pip' to allow this upgrade.
Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
The struct stm32_mdio_bus_s aka g_stm32_mdio_bus
has not been referenced at all, because mdio_register()
allocates its own structure. Then lower half drivers
receive only their respective part in mdio_read()
and mdio_write() because MDIO_WRITE/MDIO_READ provides
only d->lower to the specific lower level drivers.
Signed-off-by: Pavel Pisa <pisa@fel.cvut.cz>
Add INIT message which can be used in case ns_announcement isn't
supported on the system.
It unlocks the client flow by calling rpmsg_post() on the semaphore.
Without this or an NS announcement, the client's semaphore will wait
forever.
This is practical when the server side is running from linux userspace
using ioctl where controlling NS announcements is problematic.
Signed-off-by: Andre Heinemans <andre.heinemans@nxp.com>
Move conn_unlock() call outside the if block in psock_udp_sendto()
to ensure the connection lock is always released before returning,
preventing a potential deadlock when the condition is not met.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
Protect the common Espressif Wi-Fi netdev RX queue with a spinlock. The Wi-Fi RX callback enqueues packets while the netdev upper-half RX thread dequeues them, and the IOB queue helpers are not internally serialized.
Under sustained receive traffic that race can corrupt the queue state, strand IOBs, and degrade throughput over time as reported in issue #16915.
Initialize the lock during device setup and use it when clearing the queue on ifup, enqueueing received packets, and dequeuing them for the upper half.
Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
Some compilers (e.g., Tasking) do not allow forced type casting of
unions. When CONFIG_ARCH_TOOLCHAIN_TASKING is enabled, replace the
direct cast with memcpy to copy the union parameter into a local
variable, avoiding the illegal cast while preserving the correct
behavior. Other compilers still use the original cast approach.
Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
On power-up, MX25L25673G uses 3-byte addresses, so only the lower
128Mb (half the memory) can be accessed. This change ensures 4-byte
addresses are used so the whole memory can be used.
Co-Authored-By: Randy Rossi <randyrossi@geotab.com>
Signed-off-by: Carlos Sanchez <carlossanchez@geotab.com>
Align RISC-V timer integration with Xtensa by replacing the
legacy systimer-thread backend with esp_timer adapter layers.
Rename local GPTIMER files to avoid header ambiguity, and
update board/build integration plus sdkconfig timer task
options for HAL compatibility.
Signed-off-by: Tiago Medicci Serrano <tiago.medicci@espressif.com>
arm_dispatch_syscall in armv7-m clobbered r11 with 'mov r11, sp' and the
user-space callee-saved register value leaked back through the exception
frame when SYS_syscall_return restored the context, resulting in corrupted
parameters on subsequent syscalls and system hangs in protected builds.
In armv6-m, r4 was used to load g_stublookup (Thumb-1 cannot use ip for
indexed addressing) but was not restored before SYS_syscall_return,
causing the same class of register corruption.
Fix with minimal changes:
- armv7-m: remove 'mov r11, sp' to stop clobbering user r11
- armv6-m: restore r4 from the stack frame before SYS_syscall_return
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
Add board documentation for the Stellaris LM3S6965 Evaluation Kit
including available configurations (nsh, qemu-flat, qemu-protected,
qemu-kostest, qemu-nxflat) and instructions for running and debugging
with QEMU.
Also add a Supported Boards toctree section to the Tiva platform
index to automatically include board documentation.
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Fix several issues preventing the protected build from booting:
memory.ld: Increase ksram from 16K to 20K to accommodate kernel
BSS and idle thread stack. Rebalance usram to 20K and xsram to
24K accordingly.
defconfig: Remove CONFIG_FS_TMPFS to reduce kernel binary size
so it fits within the 128KB kflash partition.
defconfig: Add CONFIG_TLS_LOG2_MAXSTACK=11 to reduce TLS stack
alignment from 8K(default) to 2K. The default 8K alignment
caused memalign to request oversized allocations from the
user heap, failing the init task stack allocation.
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
debug.h is a NuttX-specific, non-POSIX header. Placing it in the
top-level include/ directory creates naming conflicts with external
projects that define their own debug.h.
This commit moves the canonical header to include/nuttx/debug.h,
following the NuttX convention for non-POSIX/non-standard headers,
and updates all in-tree references.
A backward-compatibility shim is left at include/debug.h that
emits a deprecation #warning and re-includes <nuttx/debug.h>,
allowing out-of-tree code to continue building while migrating.
Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
A signal can arrive before sem_wait transitions the task
to TSTATE_WAIT_SEM. In that window, the wait cannot yet
be aborted by sem_wait_irq(). If sem_wait then blocks
without re-checking unmasked pending signals, it can
sleep indefinitely and miss the interrupt.
Check for unmasked pending signals before touching the
semaphore count and return -EINTR if one is already pending.
Signed-off-by: Shunchao Hu <ankohuu@gmail.com>
This commit modularizes the curve25519 and idgen implementations in the
crypto subsystem.
Previously, curve25519.c and idgen.c were only compiled when
CONFIG_CRYPTO_RANDOM_POOL was enabled. However, cryptosoft.c (used by
software cipher support) has a direct dependency on curve25519 functions.
This caused linker errors (undefined reference to curve25519) when
software crypto was enabled but the random pool was disabled.
Changes:
- Introduce hidden Kconfig options CRYPTO_CURVE25519 and CRYPTO_IDGEN.
- Make CRYPTO_RANDOM_POOL select both CRYPTO_IDGEN and CRYPTO_CURVE25519.
- Make CRYPTO_CRYPTODEV_SOFTWARE_CRYPTO/KEYMGMT select CRYPTO_CURVE25519.
- Update CMakeLists.txt and Makefile to use the new config flags.
This ensures that required algorithms are automatically included in the
build regardless of whether the entropy pool is enabled.
Signed-off-by: karaketir16 <osmankaraketir@gmail.com>
Release nat_lock before returning -ENOENT from the IPv4 and IPv6
outbound NAT paths when NAT entry creation fails.
Signed-off-by: Shunchao Hu <ankohuu@gmail.com>
esp_ws2812.h exposes esp_ws2812_setup() with a struct rmt_dev_s * argument
but did not include esp_rmt.h directly.
After guarding the LIRC board registration path with CONFIG_DRIVERS_RC,
non-RC ESP configs no longer pulled in the RMT type indirectly and CI
started failing with an incomplete struct rmt_dev_s declaration.
Include esp_rmt.h in the Xtensa and RISC-V ws2812 headers.
Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
The common ESP board RMT bring-up files are built whenever ESP_RMT is
enabled, but the esp_lirc declarations are only visible when DRIVERS_RC
is enabled.
Guard the esp_lirc header include and esp_lirc_rx_initialize() /
esp_lirc_tx_initialize() calls with CONFIG_DRIVERS_RC so non-RC ESP
configs continue to build while keeping the LIRC registration path for
the rmt configs.
Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
Add documentation for the RC/LIRC character driver subsystem covering
device registration, the LIRC interface, and usage from user space.
Remove placeholder empty files under drivers/rmt that were left over
from the rmtchar era and are no longer referenced.
Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
Replace the ESP-specific rmtchar upper-half with arch-local esp_lirc
adapters for Xtensa and RISC-V.
This moves the RMT upper-half out of drivers/rmt, registers LIRC
devices from the ESP board bring-up paths, and removes the old common
rmtchar driver and headers.
Also update the ESP Kconfig and build wiring to build esp_lirc when
ESP_RMT and DRIVERS_RC are enabled.
Fixes discovered during hardware validation:
- register TX as /dev/lirc1 so RX and TX do not collide
- parse the RX worker thread argument from the correct argv slot
- keep RX devices from advertising TX capability
Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
For LCD drivers that implement putarea(), use it to copy the entire
rectangle in a single call instead of per-row putrun() calls. This
avoids the per-row overhead of setting the display window
(CASET+RASET over SPI) for every scanline.
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Add board-level support for ES7210 4-ch ADC on lckfb-szpi-esp32s3:
- configs/es7210/defconfig: Board configuration with I2C0, I2S0,
ES7210 driver enabled. I2S pins: BCLK=14, DIN=12, MCLK=38, WS=13,
sample rate 48kHz.
- src/esp32s3_board_es7210.c: Board init registering ES7210 on I2C0
bus with I2S0 as audio transport
- src/esp32s3_bringup.c: Call ES7210 board init on startup; skip
generic I2S audio device registration on I2S0 when ES7210 is
enabled to avoid conflicting audio device on the same port
- src/esp32s3-szpi.h: ES7210 I2C address and device path defines
- src/Make.defs: Build integration for CONFIG_AUDIO_ES7210
Tested: 48kHz/2ch/16bit recording on ESP32-S3 (lckfb-szpi N16R8),
verified with nxrecorder and es7210_test.
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Add ES7210 audio ADC driver for NuttX implementing the audio
lower-half interface. Supports 4-channel recording via I2S with
configurable sample rate, bit depth, and mic gain.
- drivers/audio/es7210.c: Codec driver using LPWORK for async buffer
management, I2C register access, and NuttX audio buffer management
- drivers/audio/es7210.h: Internal register definitions and macros
- include/nuttx/audio/es7210.h: Public header with platform config
structure and es7210_initialize() API
- drivers/audio/Kconfig, Make.defs, CMakeLists.txt: Build system
integration for CONFIG_AUDIO_ES7210
Key implementation details:
- ES7210_SDP_NORMAL (normal I2S) instead of TDM, matching NuttX
I2S standard Philips mode
- ES7210_ADC_PGA_POWER_ON bit in gain registers REG43-46, required
for analog front-end amplifier power-on
- 50ms startup delay in es7210_start for codec clock stabilization
- I2S_IOCTL(AUDIOIOC_STOP) in es7210_stop to notify I2S layer,
preventing DMA from running without buffers after stop
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
The I2S BCLK frequency is calculated as:
bclk = sample_rate * total_slot * data_width
Previously, total_slot was always taken from the static config
(esp_i2s0_config / esp_i2s1_config), which is hardcoded to 2.
This is correct for mono and stereo, but wrong for TDM modes
with more than 2 channels (e.g. 4-channel recording with ES7210).
With 4 channels but total_slot=2, the BCLK is only half of what
it should be, causing the actual sample rate to be half of the
requested rate (e.g. requesting 16 kHz actually samples at 8 kHz).
Replace priv->config->total_slot with MAX(priv->channels, 2) in
all three BCLK calculation sites (i2s_check_mclkfrequency and
i2s_set_clock for both master and slave paths). The MIN of 2
preserves the I2S protocol requirement that at least 2 slots
exist even for mono, while correctly scaling for multi-channel
TDM configurations.
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Fix multiple bugs in the I2S RX receive path on ESP32-S3 with GDMA:
- Set streaming=true in i2s_rxdma_start so completed buffers are not
incorrectly marked AUDIO_APB_FINAL
- Restore up_enable_irq calls for DMA interrupt after esp_dma_load
resets the channel
- Skip i2s_hal_rx_reset/rx_reset_fifo on ESP32-S3 which clears the
TDM slot configuration set by i2s_configure
- Accept 1-16 RX channels on ESP32-S3 (was limited to 2)
- Add getreg32 read-back after DMA start to flush CPU write buffer
- Auto-stop RX channel when no pending buffers remain, preventing
hardware from running without DMA descriptors after stop
- Remove duplicate return OK in i2s_rxdma_start
- Fix i2s_ll_tx_enable_mono_mode to i2s_ll_rx_enable_mono_mode in
i2s_rxchannels
- Fix tx_slot_cfg.std to rx_slot_cfg.std in RX PCM slot config
- Fix DMA direction, peripheral ID, data_width, rx_start sequencing,
and rx_eof_num word count in RX path
- Fix esp32s3_board_i2s.c I2S port index
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Initialize 'ret' to OK to silence -Werror=maybe-uninitialized.
When neither enable_tx nor enable_rx is set, 'ret' was returned
without being assigned.
Signed-off-by: dramalife <yangyongkang@espressif.com>
Move conn_unlock() after the data event handling in can_callback()
and udp_callback(). Previously, the connection lock was released
immediately after devif_conn_event(), leaving the subsequent
can_data_event()/net_dataevent() and read-ahead buffer operations
unprotected. This could lead to a race condition where another
context modifies the connection state while data is being stored.
Hold the lock until the entire callback processing is complete to
ensure thread safety.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
Use static lower-half instances per timer and select the channel
through Kconfig and board data instead of passing runtime PWM
routing into the driver.
This keeps the HT32 PWM support aligned with the existing NuttX
pattern and documents the esk32 single-device TMR3 routing.
Signed-off-by: Felipe Moura <moura.fmo@gmail.com>