Commit graph

2109 commits

Author SHA1 Message Date
wangchengdong
15f6e399b8 nuttx/arch: merge tickless and tick process
merge nxsched_timer_expiration() into nxsched_process_timer()
    to improve code efficient

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-12 16:20:42 +08:00
Justin Erenkrantz
220263e7c4 risc-v/litex: Update docs for vexriscv invalidate and no-op flush.
Per further feedback from Litex community, the vexriscv cache is
write-through so no flush is required - therefore, make it a nop.

And add a pointer to vexriscv invalidation magic instr docs.

Signed-off-by: Justin Erenkrantz <justin@erenkrantz.com>
2026-01-08 09:21:50 +08:00
simbit18
35c7aa214e arch/risc-v: Fix Kconfig style
- Replace help => ---help---

- Remove TAB

Signed-off-by: simbit18 <simbit18@gmail.com>
2026-01-06 06:35:08 +08:00
ENJOU1224
73b9bced17 boards/risc-v: Enable VPU initialization for QEMU RV
The riscv_vpuconfig() was defined but never called in qemu_rv_start. This caused mstatus.VS to remain disabled, leading to Illegal Instruction exceptions when the OS attempted to use vector registers. This patch adds the missing initialization call.

Signed-off-by: ENJOU1224 <enjou1224@outlook.com>
2026-01-06 02:32:48 +08:00
ENJOU1224
e072356182 arch/risc-v: Fix incompatible pointer types in vector context switching
The riscv_savevpu/restorevpu functions were using 'uintptr_t *' for vector registers, but 'tcb->xcp.vregs' is defined as 'uintreg_t *'. This mismatch caused compilation errors on GCC 13+ due to incompatible pointer types. This patch aligns the parameter types to 'uintreg_t *'.

Signed-off-by: ENJOU1224 <enjou1224@outlook.com>
2026-01-05 15:08:03 -03:00
Justin Erenkrantz
7298977894 risc-v/litex: Add 64-bit S-mode vexiiriscv support for litex.
Most of the peripheral support matches litex vexriscv-smp.

* arch/risc-v/Kconfig: Defer RV32 selection to core as litex board can do RV64.
* arch/risc-v/src/litex/Make.defs
  arch/risc-v/src/litex/hardware/litex_clint.h
  arch/risc-v/src/litex/hardware/litex_memorymap.h
  arch/risc-v/src/litex/hardware/litex_plic.h
  arch/risc-v/src/litex/litex_irq.c
  arch/risc-v/src/litex/litex_irq_dispatch.c: Add CONFIG_LITEX_CORE_VEXIIRISCV
  conditional where vexriscv_smp conditionals are.
* boards/risc-v/litex/arty_a7/configs/nsh-vexii/defconfig: New config.
* boards/risc-v/litex/arty_a7/include/vexii_irq.h: vexiiriscv irq defintion.
* boards/risc-v/litex/arty_a7/include/vexii_memorymap.h: vexiiriscv memory map.
* boards/risc-v/litex/arty_a7/scripts/ld.script: Define __global_pointer for
  toolchain happiness matching other RISC-V linker scripts.

(This commit was written with assistance from Claude Code.)

Signed-off-by: Justin Erenkrantz <justin@erenkrantz.com>
2025-12-30 10:18:57 -03:00
Justin Erenkrantz
f10cf58d6b risc-v/litex: Implement up_flush_dcache_all when CONFIG_ARCH_DCACHE is defined.
This duplicates the up_invalidate_dcache_all as vexriscv's DBUS cache
does not distinguish between flushing and invalidation.

Signed-off-by: Justin Erenkrantz <justin@erenkrantz.com>
2025-12-27 07:00:29 -03:00
hujun5
c55954d56c barrier: add UP_RMB UP_WMB
This commit added linux-style UP_RMB() and UP_WMB().

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-12-22 10:22:06 -03:00
anjiahao
0a2b01950c sched:use tcb_s inside of task_tcb_s , remove all cast
Simplify the code and remove different tcb

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-12-22 17:55:45 +08:00
Justin Erenkrantz
18a1d159a7 risc-v/litex: For vexriscv_smp, match default FDT address in upstream opensbi.
The default opensbi fw_jump.bin expects to see the FDT in 0x40EF0000 per FW_JUMP_FDT_ADDR.

Definitions:

https://github.com/litex-hub/opensbi/blob/0.8-linux-on-litex-vexriscv/platform/litex/vexriscv/config.mk
https://github.com/litex-hub/opensbi/blob/1.3.1-linux-on-litex-vexriscv/platform/litex/vexriscv/objects.mk

Signed-off-by: Justin Erenkrantz <justin@erenkrantz.com>
2025-12-20 11:09:38 +08:00
anjiahao
b623c781c5 arch:use ARCH_64BIT to mark arch is support 64bit
Add ARCH_64BIT macro to indicate architectures with 64-bit support,
improving portability and conditional compilation.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-12-18 22:05:12 +08:00
Lars Kruse
ec906cfb0b rp2040,rp23xx,rp23xx-rv: allow up to 32 PIO instructions
Previously only up to 31 PIO instructions were accepted.
But the hardware allowed 32 instructions.

Now we accept 32 instructions.

See the corresponding commit in the pico-sdk repository:

  6f7dc67791

Signed-off-by: Lars Kruse <devel@sumpfralle.de>
2025-12-15 18:01:27 +01:00
anjiahao
b95cfa1b14 risc-v:need add crt0 to LDELFFLAG
riscv64-unknown-elf-ld: warning: cannot find entry symbol __start; defaulting to 0000000000000000

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-12-15 17:35:44 +08:00
zhanghongyu
aa8ffea3cf netdev_upperhalf: convert Kconfig to variable
Upperhalf supports multiple working modes at the same time,
which is specified by NIC when register

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-14 10:01:22 +08:00
Filipe Cavalcanti
49d6177c68 espressif: automate build system for flash enc
Modifies Kconfig and build tools to support flash encryption
and E-Fuse burning when flash encryption is enabled.

Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
2025-12-11 11:29:26 +01:00
Filipe Cavalcanti
0835b345e8 arch/risc-v: flash encryption support for ESP32-C3|C6|H2
Add Kconfig option to enable flash encryption.
Default E-Fuse state is now VIRTUAL.
Modifies SPI Flash driver for encrypted operation.
Limitations:
- Requires MCUBoot
- Flash fully encrypted (no unencrypted MTD part. support)

Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
2025-12-11 11:29:26 +01:00
Yanfeng Liu
c38042941f arch/crt0.c: revert entry _start
This reverts crt0.c entry name to _start to fix LTO issue/17443,
needs apps/ side pull/3235.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
2025-12-10 19:06:04 +08:00
Filipe Cavalcanti
6ccc5847fb arch/risc-v/esp32c3: rename ESP32-C3 Generic configs
- ARCH_CHIP_ESP32C3_LEGACY created
- ARCH_CHIP_ESP32C3_GENERIC is now ARCH_CHIP_ESP32C3

This is part of deprecating esp32c3-devkit as esp32c3-legacy and
using esp32c3-generic (now esp32c3-devkit) instead.

Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
2025-12-03 13:45:13 +08:00
Filipe Cavalcanti
0158eda813 arch/risc-v/espressif: add PWM capture getedges function
Create esp_capture_getedges function which was missing from
the capture API.

Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
2025-12-03 13:44:25 +08:00
Jukka Laitinen
5ae35b619a arch/mpfs/mpfs_ddr.c: Improve CA training validity check heuristics
Update the CA training result check to match the HSS reference code.

The original check which required phase delays to be 5 taps separated was wrong.
This has also been removed from the HSS.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2025-12-02 02:36:55 +08:00
Jukka Laitinen
3560a28eef arch/mpfs/mpfs_ddr.c: Make sure eye doesn't grow past the window end
The window is 32 taps, so in order to the eye to be completely inside the window,
the (offset + width) has to be less or equal than (32 - margin).

Add this additional sanity check in the mpfs_training_verify.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2025-12-02 02:36:55 +08:00
Eren Terzioglu
d4c76b1f60 arch/risc-v/esp32[-c3|-c6|-h2]: Add deep sleep support
Add deep sleep support for risc-v based Espressif devices

Signed-off-by: Eren Terzioglu <eren.terzioglu@espressif.com>
2025-11-29 14:35:34 +08:00
Eren Terzioglu
8417cf0c83 arch/risc-v/esp32[-c3|-c6|-h2]: Add PM support
Add PM support for esp32[-c3|-c6|-h2]

Signed-off-by: Eren Terzioglu <eren.terzioglu@espressif.com>
2025-11-29 14:35:34 +08:00
ouyangxiangzhen
a923cfe4ed arch/riscv: Fix bl602 start_absolute.
This commit fix bl602 start_absolute.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-11-24 19:43:07 +08:00
ouyangxiangzhen
b1dd15e6e5 arch/riscv: Remove kmalloc.h for mtime driver.
This commit removed kmalloc.h for mtime driver.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-11-24 19:43:07 +08:00
ouyangxiangzhen
ee32bd44e0 arch/risc-v: Add clkdev drivers for esp32 timers.
This commit added clkdev drivers for esp32 timers.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-11-24 19:43:07 +08:00
ouyangxiangzhen
882c663a4f arch/riscv: Add clkdev driver for esp32c3-legacy.
This commit added clkdev driver for esp32c3-legacy.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-11-24 19:43:07 +08:00
ouyangxiangzhen
f9e894e490 arch/riscv: Add clkdev driver for bl602 timer.
This commit added clkdev driver for bl602 timer.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-11-24 19:43:07 +08:00
ouyangxiangzhen
a5e64a0a5c arch/riscv: Add CONFIG_ONESHOT condition for riscv_mtimer.c.
This commit added CONFIG_ONESHOT condition for riscv_mtimer.c

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-11-24 19:43:07 +08:00
ouyangxiangzhen
2227f232f0 arch/risc-v: Add clkdev driver for mtime.
This commit added clkdev driver for risc-v machine timer.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-11-24 19:43:07 +08:00
ouyangxiangzhen
b2fc959e40 risc-v/bl602: Fix boot issue caused by atomic instructions.
Since the bl602 do not support the atomic extention, we should compile
it with `-march=rv32imfc`, or it will fail to boot when executing the
`lr.w` instruction.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-11-24 19:43:07 +08:00
ouyangxiangzhen
fd4d93e928 arch/risc-v: Ensure the timer setting atomicity on 32-bit platforms.
This commit guaranteed the timer setting atomicity on 32-bit platforms.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-11-24 19:43:07 +08:00
v-tangmeng
a221df7175 arch/xtensa/esp32[-s2|-s3]: add USE_NXTMPDIR_ESP_REPO_DIRECTLY
Directly downloading the Git repository is inconvenient for local debugging.
This will allow to automatically download external packages from the Internet.
If not set, the repo need to be download will need to provide them manually,
otherwise an error will occur and the build will be aborted.

Add `USE_NXTMPDIR_ESP_REPO_DIRECTLY`, with this we can use
`USE_NXTMPDIR_ESP_REPO_DIRECTLY=y make` which can directly use esp-hal-3rdparty
under nxtmpdir without CLONE, CHECK_COMMITSHA, reset, checkout and update. Just
`cp -rf nxtmpdir/esp-hal-3rdparty chip/$(ESP_HAL_3RDPARTY_REPO)`.

Signed-off-by: v-tangmeng <v-tangmeng@xiaomi.com>
2025-11-18 21:46:50 +08:00
ouyangxiangzhen
fc28b93224 timers/oneshot: Remove all callback and args.
This commit remove all callback and args in the APIs.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-11-18 13:02:29 +01:00
ouyangxiangzhen
5c113f79b7 timers/oneshot: Remove all private callback.
This commit removed all private callback and handle it on the upperhalf
of oneshot.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-11-18 13:02:29 +01:00
ouyangxiangzhen
f70ec7384b arch/risc-v: revert oneshot drivers to timespec API.
This commit reverted oneshot drivers to timespec API.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-11-18 13:02:29 +01:00
ouyangxiangzhen
9364d0aa37 arch/risc-v: simplify mtimer driver.
This commit simplified RISC-V mtimer driver.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-11-17 10:25:37 +08:00
haitomatic
6b45617064 arch/risc-v/mpfs: Remove strict CAN frame data length check.
In MSS CAN transmit function, the check of net pkt data len is not neccessary. Since there are cases that the pkt len can exceed the expected 16 bytes of can_frame but the pkt is still valid. Such a case is when CONFIG_NET_CAN_RAW_TX_DEADLINE is enabled which has pkt len to become 32 bytes due to cmsghdr overhead.

Signed-off-by: haitomatic <hai.to@unikie.com>
2025-11-11 22:16:51 +08:00
haitomatic
e7ad870f18 arch/risc-v/mpfs: Add MSS CAN driver.
Refactor to  become lower half driver.

Signed-off-by: Hai To <hai.to@tii.ae>
2025-11-03 17:14:53 -03:00
haitomatic
967238ba2c arch/risc-v/mpfs: Add MSS CAN driver.
The Nuttx MSS CAN driver has an exclusive interface to the integrated MSS CAN peripheral residing in Polarfire SoC FPGAs. There are two CAN block 0 and 1 that can be configured for use. In normal mode (non AMP), CAN0 and CAN1 block base register addresses are 0x2010C000UL and 0x2010D000UL.

Signed-off-by: Hai To <hai.to@tii.ae>
2025-11-03 17:14:53 -03:00
Filipe Cavalcanti
4ccae59e69 arch/risc-v: update SPI Flash driver for ESP32-C3|C6|H2
Updates the SPI Flash driver used for user storage MTD.
Updates board linker script and bring up.

Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
2025-10-29 09:44:55 -04:00
simbit18
bbe1d420a7 arch/risc-v/rp23xx-rv: CMake build implemented for Raspberry Pi RP2350 RISCV
- added Raspberry Pi RP2350 RISCV (Hazard3 RISC-V cores)

Signed-off-by: simbit18 <simbit18@gmail.com>
2025-10-22 09:01:39 -04:00
Eren Terzioglu
7aaac3ed8e arch/risc-v/esp32[c6]: Add multiple ULP bin support for esp32c6
Add multiple ULP bin support for esp32c6

Signed-off-by: Eren Terzioglu <eren.terzioglu@espressif.com>
2025-10-21 06:32:32 -03:00
Eren Terzioglu
24eeff91c0 arch/xtensa/esp32[-s2|-s3]: Add multiple ULP RISC-V bin support
Add multiple ULP RISC-V bin support for esp32s2 and esp32s3

Signed-off-by: Eren Terzioglu <eren.terzioglu@espressif.com>
2025-10-21 06:32:32 -03:00
Eren Terzioglu
7403177473 arch/risc-v/espressif: Add ULP as char device to support multiple ULP bins
Add ULP as char device to change binary that runs on ULP

Signed-off-by: Eren Terzioglu <eren.terzioglu@espressif.com>
2025-10-21 06:32:32 -03:00
wangchengdong
fca1010a5b arch/risc-v: remove duplicated nxsched_switch_context() call
The nxsched_switch_context() function should only be called
    when a task switch actually occurs. The RISC-V architecture
    already performs this call in riscv_perform_syscall(),
    so this PR removed the redundant nxsched_switch_context() call in
    up_switch_context().

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2025-10-21 01:05:33 +08:00
Tiago Medicci Serrano
fcb96babc5 risc-v/espressif/spi: Update common source code functions
Updates the common source code for the SPI peripheral used by
Espressif's RISC-Vs SoCs. This enables newer SoCs to be supported
in the future while maintaining backwards compatibility.

Signed-off-by: Tiago Medicci Serrano <tiago.medicci@espressif.com>
2025-10-21 01:03:36 +08:00
Tiago Medicci Serrano
fb93a9e4d0 arch/risc-v/espressif/i2s: Fix common driver issues
This commit refactors the I2S common driver for Espressif's RISC-V
SoCs. Previously, the peripheral was not working as expected.

Along with the new I2S character driver, this new I2S lower-half
driver can be easily tested using internal loopback between the
transmitter and receiver channels.

Signed-off-by: Tiago Medicci Serrano <tiago.medicci@espressif.com>
2025-10-17 17:05:38 -03:00
chao an
87f134cfaa sched/sleep: replace all Signal-based sleep implement to Scheduled sleep
Nuttx currently has 2 types of sleep interfaces:

1. Signal-scheduled sleep: nxsig_sleep() / nxsig_usleep() / nxsig_nanosleep()
Weaknesses:
a. Signal-dependent: The signal-scheduled sleep method is bound to the signal framework, while some driver sleep operations do not depend on signals.
b. Timespec conversion: Signal-scheduled sleep involves timespec conversion, which has a significant impact on performance.

2. Busy sleep: up_mdelay() / up_udelay()
Weaknesses:
a. Does not actively trigger scheduling, occupy the CPU loading.

3. New interfaces: Scheduled sleep: nxsched_sleep() / nxsched_usleep() / nxsched_msleep() / nxsched_ticksleep()
Strengths:
a. Does not depend on the signal framework.
b. Tick-based, without additional computational overhead.

Currently, the Nuttx driver framework extensively uses nxsig_* interfaces. However, the driver does not need to rely on signals or timespec conversion.
Therefore, a new set of APIs is added to reduce dependencies on other modules.

(This PR also aims to make signals optional, further reducing the code size of Nuttx.)

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-10-17 14:05:02 +08:00
guoshengyuan1
79711737bc arch/init: call up_color_intstack before up_irq_enable
Make sure interrupt stack is colored before IRQ is enabled.

Currently, after calling irq_initialize in nx_start to
enable interrupts, there is still a period of execution
path before the interrupt stack is colored.

Signed-off-by: guoshengyuan1 <guoshengyuan1@xiaomi.com>
2025-10-14 17:42:01 +08:00