Commit graph

24131 commits

Author SHA1 Message Date
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
xuxingliang
cdd8032cb9 arch/armv8-m: Fix IRQ number corruption in exception_direct with O2 optimization
When compiling with O2 optimization, the compiler optimizes the code
in a way that causes irq variable to be corrupted. The getipsr()
function reads IPSR into r0, but the subsequent inline assembly that
sets FPSCR also uses r0 without declaring it as clobbered. This causes
the compiler to reuse r0 for the immediate value (0x40000), overwriting
the IRQ number read from IPSR.

The issue manifests as:
- getipsr() correctly reads IPSR (e.g., 0xf for IRQ 15)
- Compiler optimizes and reuses r0 for ARM_FPSCR_LTPSIZE_NONE (0x40000)
- irq variable gets the wrong value 0x40000 instead of actual IRQ number
- This leads to assertion failures in irq_dispatch due to invalid IRQ

Root cause analysis from disassembly:
  mrs r0, IPSR          ; Read IPSR to r0
  mov.w r0, #262144     ; Compiler overwrites r0 with 0x40000!
  vmsr fpscr, r0        ; Set FPSCR
  str r0, [sp, #4]      ; Store corrupted 0x40000 as irq
  ...
  ldr r0, [sp, #4]      ; Load corrupted value
  bl irq_dispatch       ; Call with wrong IRQ number 0x40000

Fix by adding r0 to the clobber list in the inline assembly, which
forces the compiler to save irq value before using r0 for FPSCR setup.

This issue only occurs at O2 optimization level and affects ARMv8-M
architecture with FPU enabled.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2025-12-29 19:15:21 +08: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
zhanghongyu
ac3a7da8ed sim_netdriver: add addmac/rmmac support
Avoid PACKET_ADD_MEMBERSHIP calls returning errors.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-25 10:01:43 +08:00
yezhonghui
ba681d3ddf sim_uart: used wd timer to process transmit
used wdt thread process event

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-24 22:50:24 +08:00
yezhonghui
276095dc77 sim_rptun: used wd timer to process transmit
used wdt thread process event

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-24 22:50:24 +08:00
yezhonghui
aeda575c5b sim_hcisock: used wd timer to process transmit
used wdt thread to process event

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-24 22:50:24 +08:00
yezhonghui
93bf613505 sim/loop: delete sim loop theads at bringup
wdt thread replace sim loop thread

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-24 22:50:24 +08:00
yezhonghui
0e6afae4f2 usbhost: used wd timer to process loop event
used wdt thread process event

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-24 22:50:24 +08:00
yezhonghui
bb304441db foc: used wd timer to process loop event
used wdt thread process event

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-24 22:50:24 +08:00
yezhonghui
a536ea8569 usbdev: used wd timer to process loop event
used wdt thread process event

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-24 22:50:24 +08:00
yezhonghui
e2ca205f12 camera: used wd timer to process loop event
used wdt thread process event

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-24 22:50:24 +08:00
yezhonghui
954122641a audio: used wd timer to process loop event
used wdt thread process event

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-24 22:50:24 +08:00
yezhonghui
bbcf8fe30b usrsock: used wd timer to process loop event
used wdt thread process event

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-24 22:50:24 +08:00
yezhonghui
c594616e99 netdriver: used wd timer to process netdata
used wdt thread to process loop event

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-24 22:50:24 +08:00
yezhonghui
c385d74669 lcd/fb: sim used wd timer to process loop event
used wdt thread to process event

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-24 22:50:24 +08:00
yezhonghui
6b1f484bbd input: change wd timer to precoss input device event
used wdt threads process event

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-24 22:50:24 +08:00
anjiahao
28298b9d5e armv-m/syscall:use cfi to debug syscall
armv8m:use ip save pc
armv7m:use ip save pc, r11 save sp

nsh_main backtrace before:
```
0  nxsem_wait_slow (sem=0x10001e0 <g_uart0port+32>) at semaphore/sem_wait.c:202
1  0x0000882c in nxsem_wait (sem=0x10001e0 <g_uart0port+32>) at semaphore/sem_wait.c:270
2  0x0000e7e2 in uart_read (filep=0x608037d4, buffer=0x60c013eb " h\024\300`", buflen=1)
   at serial/serial.c:1203
3  0x0001aad4 in file_readv_compat (filep=0x608037d4, uio=0x60c01344) at vfs/fs_read.c:81
4  0x0001abae in file_readv (filep=0x608037d4, uio=0x60c01344) at vfs/fs_read.c:165
5  0x0001ac2e in nx_readv (fd=0, iov=0x60c01388, iovcnt=1) at vfs/fs_read.c:256
6  0x0001ac84 in readv (fd=0, iov=0x60c01388, iovcnt=1) at vfs/fs_read.c:318
7  0x0001acca in read (fd=0, buf=0x60c013eb, nbytes=1) at vfs/fs_read.c:352
8  0x000100ea in STUB_read (nbr=56, parm1=0, parm2=1623200747, parm3=1) at stubs/STUB_read.c:9
9  0x000014d2 in dispatch_syscall () at armv8-m/arm_svcall.c:82
```

nsh_main backtrace after:

```
0  nxsem_wait_slow (sem=0x10001f0 <g_uart0port+32>) at semaphore/sem_wait.c:202
1  0x000088c0 in nxsem_wait (sem=0x10001f0 <g_uart0port+32>) at semaphore/sem_wait.c:270
2  0x0000e882 in uart_read (filep=0x6080380c, buffer=0x60c013eb " h\024\300`", buflen=1)
   at serial/serial.c:1203
3  0x0001ab74 in file_readv_compat (filep=0x6080380c, uio=0x60c01344) at vfs/fs_read.c:81
4  0x0001ac4e in file_readv (filep=0x6080380c, uio=0x60c01344) at vfs/fs_read.c:165
5  0x0001acce in nx_readv (fd=0, iov=0x60c01388, iovcnt=1) at vfs/fs_read.c:256
6  0x0001ad24 in readv (fd=0, iov=0x60c01388, iovcnt=1) at vfs/fs_read.c:318
7  0x0001ad6a in read (fd=0, buf=0x60c013eb, nbytes=1) at vfs/fs_read.c:352
8  0x0001018a in STUB_read (nbr=56, parm1=0, parm2=1623200747, parm3=1) at stubs/STUB_read.c:9
9  0x00001ece in dispatch_syscall () at armv8-m/arm_dispatch_syscall.S:111
10 0x2000a874 in read (parm1=0, parm2=0x60c013eb, parm3=1) at proxies/PROXY_read.c:9
11 0x20001152 in readline_getc (vtbl=0x60c01468) at readline_fd.c:73
12 0x20003994 in readline_common (vtbl=0x60c01468, buf=0x60c017f8 "\n", buflen=80)
   at readline_common.c:513
13 0x200012ec in readline_fd (buf=0x60c017f8 "\n", buflen=80, infd=0, outfd=1) at readline_fd.c:236
14 0x200010a8 in nsh_session (pstate=0x60c01540, login=1, argc=1, argv=0x60c00548)
   at nsh_session.c:229
15 0x20000eb0 in nsh_consolemain (argc=1, argv=0x60c00548) at nsh_consolemain.c:75
16 0x20000e4c in nsh_main (argc=1, argv=0x60c00548) at nsh_main.c:74
17 0x20000062 in nxtask_startup (entrypt=0x20000e11 <nsh_main>, argc=1, argv=0x60c00548)
   at sched/task_startup.c:72
18 0x00009ac4 in nxtask_start () at task/task_start.c:106
19 0x60c00548 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
```

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-12-24 09:49:52 +08:00
wangchen
d59cf4a91c sim_wifidriver.c:resolve issue in wapi save_config & wapi reconnect command
resolove issue wapi save_config & wapi reconnect command in sim

Signed-off-by: wangchen <wangchen41@xiaomi.com>
2025-12-23 09:06:11 -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
ouyangxiangzhen
e5db83d7db sched/sched: Remove nxsched_alarm_expiration
This commit removed nxsched_alarm_expiration to simplify the timer
expiration.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-12-22 21:17:13 +08:00
anjiahao
530a7aab0e arch:remove struct tcb_s cast
Just remove cast

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-12-22 17:55:45 +08: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
simbit18
e5a0c3e7d7 arch/arm: Aligned Cmake with Make
- use chip specific vectors to allow smpcall update regs apache#14363

Signed-off-by: simbit18 <simbit18@gmail.com>
2025-12-21 14:13:52 -05:00
Alan Carvalho de Assis
30a7420349 boards/esp32: Add initial support to heltec_wifi_lora32
This commit adds basic/initial support to Heltec WiFi LoRa32 board.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2025-12-21 15:18:08 -03:00
Alan Carvalho de Assis
3bf8b55d64 arch/xtensa/esp32: Add CONFIG_ESP32_IGNORE_CHIP_REVISION_CHECK
This commit add the option that was missing in the esp32_start.c
to ignore the chip version for boards with old ESP32 silicon tape out.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2025-12-21 15:18:08 -03:00
yezhonghui
1fe3de379a sim/spi: delete invaild cs change with ioctl transfer
delete invaild cs

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-21 06:37:39 +08:00
yezhonghui
96db23e7df sim/spi: ioctl stytemcall use host_uninterruptible
syscall use macro host_uninterruptible

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-21 06:37:39 +08:00
dirksavage88
c792601963 imxrt/serial: Fix uart registration order when no console defined.
* Explicit registration of ttys0 when no console defined
* Fixes overwriting registration of lpuart1 on ttys1 when no console on ttys0
* Change regstration logic to check for console assignment
* See issue 17116

Signed-off-by: dirksavage88 <dirksavage88@gmail.com>
2025-12-20 11:12:04 +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
fb8da4b89d mps3-an547:support protect mode
add mps3-an547:knsh configs

./tools/configure.sh mps3-an547:knsh
make -j20
qemu-system-arm -M mps3-an547 -m 2G -device loader,file=nuttx.hex -device loader,file=nuttx_user.hex -gdb tcp::1129 -nographic

nsh>ostest

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-12-18 22:19:44 +08:00
guohao15
635d81a76b cmake:add missing cflag "-D_FILE_OFFSET_BITS=64" of sim
The -D_FILE_OFFSET_BITS=64 parameter is missing
during the CMake compilation of the sim (simulator) build,
which causes incorrect version invocations of interfaces
such as hostfs_stat.

Signed-off-by: guohao15 <guohao15@xiaomi.com>
2025-12-18 22:18:49 +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
anjiahao
431cffa5d8 x86_64:fix syscall type mismatch
/home/ajh/work/vela_system/nuttx/include/arch/syscall.h:181: Error: operand type mismatch for `movq'

`rax`: Used in 64-bit mode, suitable for storing 64 bits of data.

`eax`: In 64-bit mode, typically used for operating on 32-bit data. When writing to `eax`, the high 32 bits of `rax` are automatically cleared to zero.

`nbr` is an unsigned int, is 32-bit.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-12-18 06:31:43 +01:00
Yanfeng Liu
495f6cc31f arch/Toolchain.defs: use _start entry
This adjusts more archs to use _start as ELF entry.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-12-16 13:07:37 -03: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
yangsong8
3a76917058 sim/usbdev: Process all pending data at once
After processing a packet of data, do not exit interrupt, but continues
to check whether there is data to be processed. If there is, continue
processing.

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-12 09:35:26 +08:00
ligd
6736558d10 sim_usb: fix host function caused up_interrupt_context() failed
use host_uninterruptible to protect some system functions

Signed-off-by: ligd <liguiding1@xiaomi.com>
2025-12-12 09:35:26 +08:00
yangsong8
8bf88945ce sim/usbdev: Supports registering multiple USB devices on a same host
when start multiple sim, the host refuses to recognize multiple USB
devices, and the prompt message is as follows:
[365652.175289] UDC core: USB Raw Gadget: couldn't find an available UDC or it's busy
[365652.175304] misc raw-gadget: fail, usb_gadget_probe_driver returned -16

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-12 09:35:26 +08:00
yangsong8
3a0d2cbd41 sim_usb: fix dev function caused up_interrupt_context() failed
use host_uninterruptible to protect some system functions.

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-12 09:35:26 +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
8f42a6f6d7 arch/xtensa: add critical section on e-fuse bringup
The efuse initialization requires critical section to avoid a very
hidden corner case when flash encryption is enabled.

Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
2025-12-11 11:29:26 +01:00
Filipe Cavalcanti
151776f0a5 arch/xtensa: change .bss clear location on start
Moves the clearing of global variables to the very start
of the chip start up process. This avoids clearing some
globals that are initialized between the new location and
previous location.

Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
2025-12-11 11:29:26 +01:00
Filipe Cavalcanti
3a74b82e09 arch/xtensa: flash encryption support for ESP32|S2|S3
Deprecates ESP32_STORAGE_MTD_ENCRYPT and ESP32_OTA_PARTITION_ENCRYPT options.
Add ESPRESSIF_SECURE_FLASH_ENC_ENABLED Kconfig option.
Updates SPI Flash driver to handle encryption automatically.

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
Jiri Vlasak
af205ebd39 arm/kinetis: Fix warning
8th bit of SCGC3 is NFC, see K60 Reference Manual
(K60P144M150SF3RM.pdf, 12.2.11).

Signed-off-by: Jiri Vlasak <jiri.vlasak@posteo.net>
2025-12-10 11:40:36 +01:00
Jiri Vlasak
5090572b2a arm/kinetis: K60 has SPI1, SPI2, improve errors
K60 family has support for SPI1 and SPI2.

Signed-off-by: Jiri Vlasak <jiri.vlasak@posteo.net>
2025-12-10 11:40:36 +01:00