Commit graph

24187 commits

Author SHA1 Message Date
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
f8501fa3ea arch/x86_64: 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
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
hujun5
aa9f366eec x86_64: fix regression https://github.com/apache/nuttx/pull/15651
reason:
In x86_64, tcb->xcp.regs is always valid, and we obtain the location
where the context is saved through irq_xcp_regs every time an interrupt occurs.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-23 21:46:27 +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
914ae532e6 sched: remove csection and reduce the interrupt disabling time in sched_[un]lock
reason:
1 Accelerated the implementation of sched_lock, remove enter_critical_section in sched_lock and
only enter_critical_section when task scheduling is required.
2 we add sched_lock_wo_note/sched_unlock_wo_note and it does not perform instrumentation logic

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-23 19:58:49 +08:00
chao an
801cd455ef sim/posix/uart: add host_printf() to debug some critical issue
Sometimes we need to bypass the system to debug some issue in critical sections

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-01-23 16:14:36 +08:00
chao an
cefb6cbd00 sim/rpmsg_uart: add sim rpmsg uart support
add sim_rpmsg_port_uart.c to verify the rpmsg port uart wrapper layer,

The physical transport layer could be:
1. SIM_RAM_UART(current)
2. SIM_UART(through "socat" virtual "/dev/pts/*", "socat" could monitor the bus data)

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-01-23 10:41:38 +08:00
chenxiaoyi
de55f64a7f xtensa: inline up_cpu_index
Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2025-01-23 10:24:43 +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
Ville Juven
aefafc45e9 riscv/context_switch: Set tp when a context switch occurs
This removes the need to call nxsched_self upon exception return. Later
with a bit of added logic, it is possible to use tp in kernel to store and
read the current tcb.

Note: setting tp in riscv_restorecontext is too late for this, as
this_task() points to the (next) ready-to-run task, thus tp should be
updated when the rtr list is updated (via up_update_task, which does not
exist for risc-v yet)
2025-01-22 20:34:25 +08:00
wangzhi16
099801630d Use small lock to protect resources related to irq in arch risc-V and xtensa.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-22 20:30:20 +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
Eero Nurkkala
9424abf3d6 risc-v/mpfs: ddr: lock segmentation registers
Set the LOCKED bit when the final ddr segmentatition is
in place. Otherwise the system is prone to potential
security issues if the config is altered later. Once the
LOCKED bit is set, the register may no longer be changed.

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
2025-01-22 20:29:43 +08:00
Jukka Laitinen
20f15130aa arch/arm64/src/imx9/imx9_lpuart.c: Call uart_xmitchars when txint is enabled
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2025-01-22 16:53:45 +08:00
liwenxiang1
7eccf4493a arch/x86_64:Adapt coredump
Signed-off-by: liwenxiang1 <liwenxiang1@xiaomi.com>
2025-01-22 16:35:32 +08:00
Jukka Laitinen
c00b5862c7 arch/risc-v/src/mpfs/mpfs_ddr.c: Fix CA training verify step
Corrections to CA training verify step. The original copied from HSS didn't
make sense in all aspects:
- The check is not per lane, so it should be out of the "for (lane_sel" loop.
- The check wasn't proper. The expected outcome is just a vector of increasing numbers
  separated enough

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2025-01-22 16:32:06 +08:00
Jukka Laitinen
6ca6608dea arch/risc-v/src/mpfs/mpfs_ddr.c: Clean up the TXDLY verify step
Just verify that the delay for the selected clock != 0

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2025-01-22 16:32:06 +08:00
Jukka Laitinen
e8cc1d3c4f arch/risc-v/src/mpfs/mpfs_ddr.c: Add read dq/dqs eye centering test
After read training, check also that the eye is centered properly. Sometimes
after the training the width is long enough, but it is not centered.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2025-01-22 16:32:06 +08:00
Jukka Laitinen
f695fc6884 arch/risc-v/src/mpfs: Disable external interrupts on all SMP harts
Interrupts on MPFS platform are currently served on the hart, on
which the up_enable_irq was called.

Call to up_disable_irq may execute on different hart than on which
the up_enable_irq was executed. In this case the interrupt is not
disabled currently.

While there is nothing fancy (irq affinity control or such), an
easy way to fix this is to simply disable the irq on all harts.

This also changes the prototypes of mpfs_plic_get_iebase and
mpfs_plic_get_claimbase to get the hart id as an argument, in
order to accomplish this.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2025-01-22 15:30:32 +08:00
chao an
9db4d327fa sim/virtio: fix typo sim_rpmsg_vritio.c -> sim_rpmsg_virtio.c
Build Error:
CMake Error at arch/sim/src/sim/CMakeLists.txt:278 (target_sources):
  Cannot find source file:

    /home/archer/code/nuttx/n3/nuttx/arch/sim/src/sim/sim_rpmsg_vritio.c

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-01-22 15:28:13 +08:00
wangzhi16
bed3bd0852 Use small lock to protect resources related to irq in arch avr, hc, mips and or1k.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-22 15:27:30 +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
chenwen@espressif.com
1fb09dbb7f xtensa/esp32s3: Fix wrong dummy length in mode register reading
1. Corresponding link: 54a9386b2e
2025-01-21 16:25:33 +08:00
Ville Juven
ddd279d700 mpfs_i2c.c: Replace sem_getvalue with nxsem_getvalue
Because sem_getvalue modifies errno.
2025-01-20 23:55:26 +08:00
wangzhi16
ecaddbb0aa Use small lock to protect resources related to timers in arch risc-v, xtensa and tricore.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-20 09:57:01 -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
656db16ff1 arch/tricore: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
565b0e6eaf arch/ceva: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
e39cb350f1 arch/x86_64: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
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
d3e3993682 arch/riscv: 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
82cf59bff5 arch/arm64: 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
hujun5
7c9c9422d0 fix compile error
common/espressif/esp_pcnt.c: In function 'esp_pcnt_isr_default':
common/espressif/esp_pcnt.c:396:41: warning: passing argument 1 of 'spin_lock_irqsave' makes pointer from integer without a cast [-Wint-conversion]
  396 |           flags = spin_lock_irqsave(unit->lock);
      |                                     ~~~~^~~~~~
      |                                         |
      |                                         spinlock_t {aka unsigned char}
In file included from common/espressif/esp_pcnt.c:44:
/home/hujun5/下载/vela_sim/nuttx/include/nuttx/spinlock.h:507:55: note: expected 'volatile spinlock_t *' {aka 'volatile unsigned char *'} but argument is of type 'spinlock_t' {aka 'unsigned char'}
  507 | irqstate_t spin_lock_irqsave(FAR volatile spinlock_t *lock)
      |                                  ~~~~~~~~~~~~~~~~~~~~~^~~~

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-19 17:04:36 +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
Ville Juven
4c2be5bb7f mpfs_opensbi_setup: Provide hartid and next_addr as parameters
No reason to keep asking for these over and over. Also fix bumping
the CPU booted counter when SBI is enabled.

Must also read g_hart_use_sbi before bumping the CPU booted counter.
2025-01-18 10:11:32 +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
Yanfeng Liu
8f435a2941 arch/Kconfig: allow FLASH config for non-MMU chips
This allows using FLASH_START and FLASH_SIZE config for chips with
no MMU.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-17 16:38:17 +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
chenrun1
118f827103 sim_hostfs:add host_errno_convert API for convert result
Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2025-01-15 23:33:53 +08: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