Commit graph

15939 commits

Author SHA1 Message Date
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
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
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
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
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
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
wangzhi16
919ed2e3d4 Use small lock to protect resources related to i2c.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-24 01:38:16 +08:00
Michal Lenc
758b3baef0 samv7/adc: fix handling of ANIOC_TRIGGER ioctl
ADC peripheral can be configured also for PWM trigger, so the ifdef
should depend only on CONFIG_SAMV7_AFEC_SWTRIG. Also handle the
situation when ANIOC_TRIGGER is called and the peripheral is not
configured for SW trigger (but the other one may be, so config option
is set).

Trigger values saved to the private structure are also changed to
enums for better code clarity.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2025-01-24 01:29:44 +08:00
wangzhi16
2c4fe28d4e Use small lock to protect resources related to i2c master and slave.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-24 01:29:27 +08:00
buxiasen
a0fdb7f63b arm/goldfish: add ARCH_HAVE_ELF_EXECUTABLE
Able to support kernel build apps debug

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2025-01-23 23:29:51 +08:00
wangzhi16
b0af946b7a Because sched_lock is now called in spin_lock_irqsave, there is no need to call it explicitly.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-23 20:43:51 +08:00
hujun5
a095b1d6a6 arch: set (*running_task)->xcp.regs to NULL when exit from irq/exception
reason:
(*running_task)->xcp.regs is invalid when in threadcontext, we marke it as NULL to avoid misusage

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-22 23:52:17 +08:00
wangzhi16
0b542ff824 Use small lock to protect resources related to lpi2c.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-22 20:30:15 +08:00
wangmingrong1
5918335b7f armv8m: Default open hardware stack check
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-01-21 11:55:10 -03:00
lipengfei28
4b91d76869 warning: #include outside of 'Included Files' section
Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2025-01-20 20:13:07 +08:00
lipengfei28
6949c82310 arch/arm:use UP_DSB, UP_DMB, UP_ISB as barrier standard API
Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2025-01-20 20:13:07 +08:00
lipengfei28
2d1af01d44 mem barrier: use UP_DMP UP_DSP as barriers standard API
Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2025-01-20 20:13:07 +08:00
wangzhi16
8b5ea40a2b Use small lock to protect resources related to cpufifo.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-20 20:03:24 +08:00
wangzhi16
5f77da4c51 Use small lock to protect timer related resources in arch ARM.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-20 17:02:30 +08:00
wangzhi16
e177ff9c0c Use small lock to protect usbdev and endpoint in arch ARM.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-20 11:47:19 +08:00
Ian Douglas Scott
806c063223 arm/rp2040,rp2350: Allow configuring XOSC startup delay
This follows the formula in the "Startup Delay" section of the
datasheets, where `BOARD_XOSC_STARTUPDELAY` is the time in milliseconds,
which is then multiplied by the clock fequency in kHz, divided by 256
cycles, and rounded up.

This differs from `pico-sdk`, which just multiplied the value of the
expression it previously used by a `PICO_XOSC_STARTUP_DELAY_MULTIPLIER`.
This seems less correct, though it should be essentially the same except
rounding. (`BOARD_XOSC_STARTUPDELAY_MULTIPLIER` also wouldn't fit nicely
the way the `#define`s are aligned.)

This sets `BOARD_XOSC_STARTUPDELAY` to `1` for all boards, so this will
produce the same output and not change behavior.

Signed-off-by: Ian Douglas Scott <ian@iandouglasscott.com>
2025-01-18 21:05:07 +08:00
Ian Douglas Scott
4401036406 arm/rp2040,rp2350: Use BOARD_XOSC_FREQ for calculating startup delay
Previously this used a hard-coded value of 12 MHz, but this presumably
should use `BOARD_XOSC_FREQ`. Similarly to how it is done in pico-sdk.

It looks like all boards are currently defined to use 12 MHz XOSC
clocks, so this won't change behavior with any of them.

Signed-off-by: Ian Douglas Scott <ian@iandouglasscott.com>
2025-01-18 21:05:07 +08:00
Yanfeng Liu
55e1e11f1e arm/chip/qemu: add chip QEMU_CORTEXR5
This adds support for QEMU Cortex-R5 virtual processor on existing QEMU
Cortex-A7 code base with profile support in `armv7-r/` and `armv7-a/`.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-17 17:50:33 -03:00
Yanfeng Liu
3f85df583c arch/armv7-r: revise headers to support QEMU armv7-r
This revise armv7-r/ header files needed to support QEMU cortex-r5
virtual process for armv7-r family.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-17 17:50:33 -03:00
Yanfeng Liu
1bfff5a38d arch/armv7-r: fix gic.h build error
This fixes compilation error:

```
/tmp/nuttx/arch/arm/src/armv7-r/gic.h:699:17: error:
'GIC_ICDSGIR_NSATT_GRP1' undeclared; did you mean 'GIC_ICDSGIR_NSATT'?
```

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-17 19:01:22 +08:00
stbenn
b561b4459b Add uid file needed for ethernet
copied over files, not modified properly yet

Squashing lots of define errors to get ethernet.c working

quick path rename

Fix STM32_EMAC_BASE (and ICACHE/DCACHE Bases). Enable ETH, ETHTX, and ETHRX with CONFIG_STM32H5_ETHMAC (like H7 does).

Fixed stm32_get_uniqueid

Previously, an exception occurred as a result of calling this function. The problem turned out to be this line: uniqueid[i] = *((uint8_t *)(STM32_SYSMEM_UID) + i);. Dereferencing a 32-bit register as a 8-bit register seemed to be causing this issue. I think this function is better anyway, fewer register accesses and loop iterations.

Turn on SBS peripheral when using Ethernet

The SBS peripheral is required to be turned on because the ETH_SEL_PHY bits need to be set. Without turning this on, RMII mode is not possible. MII may not work either.

Style Updates
2025-01-16 18:48:57 -03:00
Yanfeng Liu
ad7198069d arm/qemu: select PSCI at processor level
This moves ARM_HAVE_PSCI selection to virtual processor level as
armv7-r chips like Cortex-R5 doesn't have it.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-15 12:23:09 -03:00
hujun5
61f0c97193 wqueue: wqueue remove csection
reason:
We decouple semcount from business logic
by using an independent counting variable,
which allows us to remove critical sections in many cases.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-15 17:26:07 +08:00
hujun5
e908fb6d51 armv7a/r: fix regression from https://github.com/apache/nuttx/pull/14596
reason:
In kernel mode, sighand_test() may failed.
because nxsig_unmask_pendingsignal may change tcb->xcp.regs,and we should update return value(regs).

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-15 17:13:29 +08:00
Yanfeng Liu
95f11e02c1 arch/arm/qemu: select NEON at processor level
This moves ARM_HAVE_NEON from QEMU ARM family level down to the
processor level as not all processors have it (e.g. Cortex R5).

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-15 16:54:10 +08:00
Kyle Wilson
9701b0f660 Fix memory map for EMAC, ICACHE, and DCACHE.
It was dis overed during debug of the ethernet driver that the EMAC base was incorrect. After examination, it was determined that ICACHE and DCACHE also had incorrect base addresses. This commit fixes the base addresses according to the reference manual.
2025-01-15 00:07:43 +08:00
Yanfeng Liu
d385d9f7d2 arm/common: fix KERNEL build vfork
This fixes vfork test for kernel build, checked with qemu-armv7a:nsh
and qemu-armv7a:knsh

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-14 20:12:31 +08:00
chenrun1
a87c194b40 goldfish_memorymap:Resize VIRT_FLASH_PSECTION
Sumamry:
  Adjust VIRT_FLASH_PSECTION from 0x00000000-0x08000000 -> 0x00600000-0x08000000
  The above changes avoid the problem of directly restarting when the process accesses/executes at address 0x0 without causing assert

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2025-01-14 19:28:54 +08:00
wangmingrong1
df7d062713 kasan/kconfig: Add config CONFIG_MM_KASAN_INSTRUMENT
It will be used to distinguish between hardware KASan and software KASan. Hardware KASan does not need to use plug-in

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-01-14 14:01:48 +08:00
chao an
c94a99326e arch/arm: read STM32L4_GTIM_CNT_OFFSET should use same lock
Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-01-14 08:38:06 +08:00
chao an
c6126bcdc4 arch/arm: fix regression by spinlock change
| commit c96b8cdfdd
| Author: hujun5 <hujun5@xiaomi.com>
| Date:   Mon Dec 23 16:59:20 2024 +0800
|
|     use small lock in following files:

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-01-14 08:38:06 +08:00
chao an
3d3db4a375 arm/imx9: sched_unlock should called after spin_unlock()
fix deadlock if sched_unlock switch out to other task

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-01-14 08:36:53 +08:00
hujun5
bac838b888 armv7a: Amp mode support
reason:
In AMP mode, we can also use SGI as an inter-core interrupt,
and ensure that arm_gic0_initialize is called only once.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-14 00:50:59 +08:00
Ian Douglas Scott
351db57e35 arch/arm/rp23xx: Set priority for svcall exception
Fixes https://github.com/apache/nuttx/issues/15503.

Signed-off-by: Ian Douglas Scott <ian@iandouglasscott.com>
2025-01-13 12:38:43 +08:00
wangmingrong1
2149d89336 macro/align: Use ALIGN_UP and ALIGN_DOWN uniformly
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-01-12 16:48:35 +08:00
Yanfeng Liu
ff488133c9 qemu-armv7a: allows ELF_EXECUTABLE
This allows using BINFMT_ELF_EXECUTABLE for qemu-armv7a target.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-11 18:54:36 +08:00
Yanfeng Liu
48846954d8 arm/Toolchain.defs: skip -r for ELF_EXECUTABLE
This avoids using `-r` option when linking executable programs.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-11 18:54:36 +08:00
Kyle Wilson
558fe83f6d Add Timer Support to STM32H5 ADC Driver
Added support for using timers with ADCs. Updated Kconfig to support TRGO2, although driver support for TRGO and TRGO2 not developed yet. Updated hardware/stm32_tim.h with missing CCER bits needed for compilation.
2025-01-11 12:04:48 +08:00
hujun5
69ee240b45 rp2040_pio: remove spin_lock_irqsave(NULL) in arch/arm/src/rp2040/rp2040_pio.c
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-10 22:35:14 +08:00
wangzhi16
b9837bed08 use small lock to protect g_ram_vectors, involving armv6-m, armv7-m, armv8-m.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-10 21:33:23 +08:00
wangzhi16
d84ba608a1 use small lock in following files:
arch/arm/src/am335x/am335x_can.c
    arch/arm/src/am335x/am335x_gpio.c
    arch/arm/src/am335x/am335x_i2c.c
    arch/arm/src/am335x/am335x_irq.c
    arch/arm/src/am335x/am335x_serial.c
    arch/arm64/src/imx9/imx9_gpio.c
    arch/arm64/src/imx9/imx9_lpi2c.c
    arch/arm64/src/imx9/imx9_lpspi.c
    arch/arm64/src/imx9/imx9_usbdev.c
    arch/x86_64/src/intel64/intel64_tsc_tickless.c

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-10 21:32:23 +08:00