Commit graph

24187 commits

Author SHA1 Message Date
Xiang Xiao
18156742f1 Revert "Use small lock to protect resources related to i2c master and slave."
This reverts commit 2c4fe28d4e.
2025-02-13 14:15:43 +08:00
Xiang Xiao
61620affe6 Revert "Use small lock to protect resources related to i2c."
This reverts commit 919ed2e3d4.
2025-02-13 14:15:43 +08:00
Xiang Xiao
43a47f49dc Revert "Use small lock to protect resources related to irq in arch ARM."
This reverts commit c754019f5a.
2025-02-13 14:15:43 +08:00
Xiang Xiao
2f7120e4bc Revert "Fix compile error."
This reverts commit 60df0cd6da.
2025-02-13 14:15:43 +08:00
Xiang Xiao
83c2bcb33a Revert "Use small lock to protect resources related to ethernet."
This reverts commit 60125038fc.
2025-02-13 14:15:43 +08:00
Xiang Xiao
259f25b2ce Revert "Fix wrong variable name. lock -> eth_lock"
This reverts commit c8f8a61f89.
2025-02-13 14:15:43 +08:00
Jacob Dahl
3dcedd507b h7: eth: add checks for PHYID in stm32_phyinit
Fixes bug where stm32_phyinit will succeed even when no PHY is connected. This is because there is no check that a PHY is actually communicating and returning data.

Update include/nuttx/net/mii.h

Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com>
2025-02-12 15:00:19 -03:00
Ville Juven
597b3e6ca7 mpfs_i2c: Increase TTOA margin to 1ms
Due to interrupt latencies the i2c transfer done interrupt can get
deferred by a few hunder microseconds. This makes the i2c transfer timeout
way too early, even though the i2c IP block is already done.

Fix this by adding a significant amount of margin (1ms) to the timeout
value.
2025-02-12 10:37:03 -03:00
Ville Juven
255d8c57c0 mpfs_i2c: Clean up the logic in i2c_transfer
This removes several error conditions that can be present after a failed
i2c transaction. The most important of them is the priv->sem_isr semaphore
which can be signaled due to a race condition.

This also ensures the i2c device itself is in idle state before futzing
around with it.

Also, add a comment about the SI-flag in the I2C CTRL register; it has
a hidden dual meaning. Not only does it clear a pending interrupt, it
also moves the I2C IP state machine forward. This requires extra logic
in the driver to cope.
2025-02-12 10:37:03 -03:00
Ramin Seyed-Moussavi
381d3fe64f arch/arm/max326xx: add max32690 icc updates
Add updates for MAX32690 Instruction Cache Controller to enhance device support in NuttX architecture.
2025-02-11 12:27:10 -03:00
Ramin Seyed-Moussavi
e99c516a91 arch/arm/max326xx: add max32690 memorymappings
Adds memory mappings for the MAX32690 to extend support for this device in the NuttX architecture.
2025-02-11 12:27:10 -03:00
Ramin Seyed-Moussavi
a691ed84d2 arch/arm/max326xx: add max32690 global control bit definitions
Adds definitions for the global control bits of the MAX32690 to improve support for this device in the NuttX architecture.
2025-02-11 12:27:10 -03:00
Ramin Seyed-Moussavi
a4cfd5f9da arch/arm/max326xx: add max32690 irq and peripheral clock definitions
Add IRQ and peripheral definitions for MAX32690 to enhance device support in NuttX architecture.
2025-02-11 12:27:10 -03:00
Yanfeng Liu
35e5612bce arch/armv7-r: select ARM_THUMB
This selects ARM_THUMB for ARMV7R per ARM document:
https://developer.arm.com/documentation/dui0471

Thanks to hujun260 for spotting this, now ostest works.

Why it helps is still to be clarified, the `arm_signal_handler.S`
might require this THUMB option.

To keep ARM_THUMB as option, this only selects it for
PROTECTED as per anchao's suggestion.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-02-11 19:37:14 +08:00
Yanfeng Liu
ab877b5c93 arm/qemu-armv7r: add heap alloc
This adds up_allocate_heap() support for PROTECTED mode so that
kernel and user heap sizes match memory.ld linker script.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-02-11 19:37:14 +08:00
Yanfeng Liu
79c2f4f394 arch/armv7-r: fix SYS_task_start
This fixes task start syscall in PROTECTED mode, following that
of armv7-m so that hello and getprime programs can run smoothly.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-02-11 19:37:14 +08:00
Yanfeng Liu
b7fc3aa034 arch/qemu: cortex-r5 PROTECTED support
This adds MPU and userspace handling in QEMU chips so that to
boot PROTECTED target qemu-armv7r:pnsh.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-02-11 19:37:14 +08:00
Yanfeng Liu
1cecf6791d arch/armv7-r: add undefined mpu_region_s
This copies struct mpu_region_s from armv7-m to fix PROTECTED mode
build error: `invalid use of undefined type 'struct mpu_region_s'`

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-02-11 19:37:14 +08:00
Yanfeng Liu
f1957845b9 arch/armv7-r: fix undefined ARCH_DATA_RESERVE
This fixes undefined 'ARCH_DATA_RESERVE' in arm_syscall.c:382 so
that to build qemu-armv7r:pnsh. Per nuttx/addrenv.h, that macro
is defined for BUILD_KERNEL, we need use BUILD_PROTECTED now.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-02-11 19:37:14 +08:00
Yanfeng Liu
b1bd1b292e arch/armv7-r: fix irq.h for PROTECTED mode
This fixes below issues when building for PROTECTED mode:
- `common/arm_fork.c:223 'struct xcpt_syscall_s' has no member 'cpsr'`
- `armv7-r/arm_syscall.c:454 'xcptcontext' has no member 'sigreturn'`

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-02-11 19:37:14 +08:00
Laczen JMS
eba0362bde esp32: Add support for espnow based pktradio
Espnow is a connectionless WiFi communication protocol that can be used
to exchange information between esp nodes.

A espnow pktradio driver is proposed that allows building a 6lowpan
network of nodes.

The driver has been evaluated using udpclient & server running on
different devices.

Solves #15347

Signed-off-by: Laczen JMS <laczenjms@gmail.com>
2025-02-10 16:15:25 -03:00
Michal Lenc
ef469bac7f samv7: ensure the correct location of message RAM
The message RAM does not behave correctly if lower 16 bits of
buffer address overflow (upper 16 bits are set once in matrix driver
for the entire CAN driver). For example message RAM starting at
0x2040fc20 would not work for buffers that go beyond 0x20410000 and
MCAN would sent data located at 0x20400000 to the network. The same
issue would occur even if TX buffers would start directly at 0x20410000.
The upper 16 bits would still have 0x2040 value because of RX buffers
located in 0x2040ffff range.

This commit ensures the RAM is always located at the beginning of
the data section and thus the overflow mentioned above should never occur.
The alternative would be to use larger alignment, but the message RAM
can have up to 4352 words and this would cause a significant padding.

The RAM is also initialized to zero to ensure valid parity/ECC checksums.
The address issue is not described anywhere in the manual, so it is
possible this is caused by some incorrect configuration, but the context
of the registers looks valid.

This commit also fixes the compilation errors when the driver is run
without data cache.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2025-02-10 15:43:54 -03:00
Stepan Pressl
d269c0f350 arch/arm/src/samv7/sam_tc_lowerhalf.c: do not set the CPCSTOP bit
The CPCSTOP has a negative effect on the periodic timer operation.
This causes the timer to stop when an overrun occurs.
Timer must be then restarted in the interrupt. However, as interrupts
are not infinitely fast, this prolongs the next timeout.

Signed-off-by: Stepan Pressl <pressl.stepan@gmail.com>
2025-02-08 10:44:28 -03:00
Yanfeng Liu
ac4b5395f1 qemu/armv7-r: add poweroff
This adds poweroff function to qemu-armv7r:nsh using
semihosting based approach.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-02-08 19:38:56 +08:00
Yanfeng Liu
20098f3b34 arch/arm: add semihosting poweroff
This adds semihosting based poweroff to arm/common. It uses
semihosting operation SYS_EXIT (0x18) with parameter AppExit
(0x20026).

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-02-08 19:38:56 +08:00
Kyle Wilson
7b3b24d9f6 Added missing UARTs and USARTs to STM32H56xx pinmap. Fixed UART IRQ definitions. Added missing rx and tx buffers. 2025-02-08 14:17:29 +08:00
Jukka Laitinen
ca6f5db6fc arch/risc-v/Kconfig: Select ARCH_RV_CPUID_MAP for all mpfs targets
The default mapping functions are needed for mpfs

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2025-02-07 23:46:40 +08:00
zouboan
22f2d39e21 arch/zynq-mpsoc improve the ethernet driver
1. Changes the phyadd to 0xC to speed up the training of phyadd.
2. Set RX DMA buffer size configureable.
3. Create netnsh configs as ethernet boot from QSPI FLASH.
4. Fix some typo in #15720 which is nonsynchronous with local code.
2025-02-07 20:21:18 +08:00
chao an
e06d8575c0 cmake/pic: sync pic related compiler flags from makefile
PIC(Position-Independent-Code) board could work on cmake:

cmake -B ap -DBOARD_CONFIG=mps3-an547:ap -GNinja

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-02-07 17:41:04 +08:00
Neo Xu
ca92c208c1 arch/arm64: generate error if context size is not aligned to 16bytes
Make sure the registers context size is aligned to 16bytes as required by armv8-a.
This issue has been reported earlier, thus make sense to make sure it won't happen in future.

Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
2025-02-05 19:28:03 +08:00
zouboan
586b9c54ac arch/arm64 Fix the SP unalignment issues
zynq-mpsoc and zcu111 borad was broken by #15437, because #15437 changes
ARM64_CONTEXT_REGS from 36 to 37, resulting in the stack no longer being
16-byte aligned which appears to violate the ARMv8-A architecture's
requirement for 16-byte stack alignment. this commit changes ARM64_CONTEXT_REGS
to 38 to fix this issues.
2025-02-04 13:18:32 +08:00
zouboan
934c93be93 arch/arm64/zynq-mpsoc: add support for ethernet gem
Zynq MPSOC The processing system (PS) is equipped with four gigabit
Ethernet controllers.Each  controller can be configured independently.
Each controller uses a reduced gigabit media independent interface (RGMII)
v2.0. This commit add support for ethernet of ZYNQ MPSOC.
2025-02-02 14:17:45 +08:00
Huang Qi
e043658d1e arch/xtensa: Add --print-memory-usage to LDFLAGS in Toolchain.defs
Summary:
- Added `--print-memory-usage` to `LDFLAGS` in `Toolchain.defs` for both `lx6` and `lx7` architectures
- This flag enables memory usage reporting during the linking phase, providing better visibility into memory allocation

Impact:
- No functional changes - the flag only adds additional debug information during the build process
- Improves debugging and optimization capabilities by providing detailed memory usage statistics
- Maintains compatibility with existing build configurations and toolchains

Testing:
Test result on esp32s3:
```
Memory region         Used Size  Region Size  %age Used
             ROM:      556116 B   16777184 B      3.31%
     iram0_0_seg:       23296 B       304 KB      7.48%
     irom0_0_seg:      621652 B   16777184 B      3.71%
     dram0_0_seg:       85780 B       288 KB     29.09%
     drom0_0_seg:      157180 B   16777184 B      0.94%
    rtc_iram_seg:           0 B       8168 B      0.00%
    rtc_data_seg:           0 B       8168 B      0.00%
rtc_reserved_seg:           0 B         24 B      0.00%
    rtc_slow_seg:           0 B         8 KB      0.00%
```

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-02-01 13:20:12 -03:00
Xiang Xiao
dc2ae56098 arch: Remove the abuse of spinlock in smp boot
What's really need is a done signal sent from the secondary
cpu to the boot cpu, so let's simplify the logic by:
1.Change the spinlock to a bool flag
2.Set the flag to true in the secondary cpu
3.Wait the flag set in the boot cpu before continue booting

This also remove all bad usage of spinlock from the code base:
1.Lock spinlock in one thread, but unlock in a different thread
2.Lock spinlock twice in one thread, but unlock only once

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2025-01-31 23:19:44 +08:00
Jukka Laitinen
80e545aedd arch/risc-v/src/common/riscv_backtrace.c: Fix "error: pointer of type 'void *' used in arithmetic"
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2025-01-31 00:58:54 +08:00
Jukka Laitinen
ef875d7d9e arch/risc-v/src/mpfs/mpfs_ddr.c: Re-try DDR training on any error
Also errors which currently return other than -EAGAIN, are typically
recoverable with retraining. So just re-try trainining 20 times on any
error, resetting the controller in between.

Only reset if it is not recovered in this time.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2025-01-30 13:55:27 +08:00
Jukka Laitinen
107b29ee67 arch/risc-v/src/mfs_start.c: After failed DDR training, reset with WDT
Resetting via WDT leaves more proper reset reason in SYSREG_RESET_SR
than resetting via soft reset.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2025-01-30 13:55:27 +08:00
Jari Nippula
f3b0e68124 arch/risc-v/src/mpfs: Add hardware/mpfs_wdog.h 2025-01-30 13:55:27 +08:00
Michal Lenc
7af7655234 samv7/serial: allow TX/RX DMA for UART drivers
So far only USART drivers could use TX/RX DMA. This commit adds the
support for UART drivers as well (with the exception of serial console).

UART peripheral does not have timeout interrupt, so external polling
is required to flush the RX data from DMA buffers even if the buffer
is not yet full. The board layer can do this by calling
sam_serial_dma_poll function.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2025-01-30 13:55:13 +08:00
Jukka Laitinen
f53afd174e arch/risc-v/src/mpfs/mpfs_cache.c: Move l2zerodevice to use cache ways starting from 0
If scratchpad is being used, the cache way 0, which is automatically
enabled at boot, needs to be re-configured as part of scratchpad memory
Otherwise there is a possibility of random memory corruption in the
scratchpad
area due to cache eviction from way 0.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2025-01-30 13:48:15 +08:00
Huang Qi
a2e8bb83a4 sim: Align LLVM target info across CMake and Makefile
Summary:
- Unified the specification of LLVM architecture and ABI types across the CMake and Makefile configurations.
- Introduced `LLVM_ARCHTYPE` and `LLVM_CPUTYPE` variables in the CMake configuration to match the Makefile's approach.
- Standardized the ABI type (`LLVM_ABITYPE`) to `sysv` for both Linux and macOS host configurations.

Impact:
- Ensures consistent LLVM target definitions across build systems (CMake and Makefile).
- Simplifies future maintenance by avoiding divergence in LLVM-related configurations.
- No functional changes to the build output; only the internal representation of LLVM target information is aligned.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-01-28 16:43:37 +08:00
Kyle Wilson
689aa55e01 Initial STM32H5 USB Commit
Progress in USB driver

Nothing is working yet. But just getting this in here so it is saved.

Minor changes with USB power enabled

Serial over USB is working now.

Removed stm32_usbdev.c, added stm32_usbfs.c. Still needs review before pull-request.

Rewrote VDDUSB valid check to use register definitions. Wait for USB33RDY before moving on. Also style updates.

Renamed stm32_usbdev files to stm32_usbfs. Renamed STM32H5 configuration options from STM32H5_USB to STM32H5_USBFS. Properly named REGDEBUG defines. Added STM32H5_USB_REGDEBUG to Kconfig and updated stm32_usbfs.c to use it. TRACE functionality still needs work.

Updated REGDEBUG for 32-bit register accesses.

More style updates.

Added usbnsh defconfig to nucleo-h563zi

Update to allow 16 buffers (max for 8 endpoints). Renamed lpinterrupt and lptransfer. Changed board.h to use SYNCSRC_USB only if USB is enabled.

Buffer size is still set to max packet size of 64 bytes, because we are using a full-speed peripheral. It is unclear to me whether having a buffer larger than the max packet size has any benefit. Double buffering is a way to increase throughput, though that still needs to be implemented.

Adapted USBFS Buffer table for 32-bit accesses.

Style updates

Build stm32_hsi48.c based on CONFIG_STM32H5_HAVE_HSI48.

Change LPMODE CNTR bit to SUSPRDY.
2025-01-28 16:43:07 +08:00
chao an
20f45f907f arm/armv7: update percpu task only for co-processor
fix smp crash on sabre-6quad/smp, regression from:

|commit 1e49cb4828
|Author: hujun5 <hujun5@xiaomi.com>
|Date:   Thu Dec 5 16:58:17 2024 +0800
|
|    armv7-a/armv7-r/armv8-r: percpu reg store this_task
|
|    This is continue work of https://github.com/apache/nuttx/pull/13726
|
|    We can utilize percpu storage to hold information about the
|    current running task. If we intend to implement this feature, we would
|    need to define two macros that help us manage this percpu information
|    effectively.
|
|    up_this_task: This macro is designed to read the contents of the percpu
|    register to retrieve information about the current
|    running task.This allows us to quickly access
|    task-specific data without having to disable interrupts,
|    access global variables and obtain the current cpu index.
|
|    up_update_task: This macro is responsible for updating the contents of
|    the percpu register.It is typically called during
|    initialization or when a context switch occurs to ensure
|    that the percpu register reflects the information of the
|    newly running task.
|
|    Signed-off-by: hujun5 <hujun5@xiaomi.com>

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-01-27 23:35:07 +08:00
zouboan
1452f32b14 zynq-mpsoc: add support for pll 2025-01-27 10:13:30 +08:00
Huang Qi
fe0949ad38 tools/x86_64: Add LLVM target definitions
Summary:
- Added LLVM target definitions (`LLVM_ARCH`, `LLVM_CPU`, `LLVM_ABI`) to `arch/x86_64/src/cmake/Toolchain.cmake` and `arch/x86_64/src/common/Toolchain.defs`
- These definitions are necessary for compatibility with LLVM-based toolchains and ensure proper target architecture, CPU, and ABI settings

Impact:
- Enables support for LLVM-based toolchains when building for x86_64 architecture
- No functional changes for existing GNU-based toolchains
- Improves maintainability by centralizing LLVM-specific configurations in the toolchain files

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-01-27 02:28:29 +08:00
Huang Qi
7ffea386e6 x86/Toolchain.defs: Add LLVM target definitions
Summary:
- Added LLVM target definitions (`LLVM_ARCHTYPE`, `LLVM_CPUTYPE`, `LLVM_ABITYPE`) to the x86 toolchain configuration file
- These definitions are necessary for compatibility with LLVM-based toolchains

Impact:
- Enables support for LLVM toolchains when building for x86 targets
- No functional changes for existing GCC-based toolchains
- Improves cross-compilation flexibility by supporting additional toolchain options

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-01-27 02:28:29 +08:00
wangzhi16
c8f8a61f89 Fix wrong variable name. lock -> eth_lock
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-24 13:40:55 +08:00
wangzhi16
60125038fc Use small lock to protect resources related to ethernet.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-24 12:13:28 +08:00
wangzhi16
60df0cd6da Fix compile error.
CC: socket/listen.c chip/lpc17_40_i2c.c: In function 'lpc17_40_i2cbus_initialize': chip/lpc17_40_i2c.c:534:29: warning: 'priv' is used uninitialized [-Wuninitialized]
534 | flags = spin_lock_irqsave(&priv->spinlock);
| ^~~~~~~~~~~~~~~
chip/lpc17_40_i2c.c:529:29: note: 'priv' was declared here
529 | struct lpc17_40_i2cdev_s *priv;
| ^~~~

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-24 11:29:58 +08:00
wangzhi16
c754019f5a Use small lock to protect resources related to irq in arch ARM.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-24 02:05:35 +08:00