Commit graph

22998 commits

Author SHA1 Message Date
hujun5
34e79f9618 spinlock: use spin_lock_init replace spin_initialize
reason:
1: spin_lock_init and spin_initialize have similar functionalities.
2: spin_lock and spin_unlock should be called in matching pairs.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-26 00:02:44 +08:00
hujun5
03f430edf7 fix some build error
hujun5@hujun5-OptiPlex-7070:~/downloads1/vela_sim/nuttx$ make -j12
chip/qemu_boot.c: In function 'up_cpu_start':
chip/qemu_boot.c:102:3: warning: implicit declaration of function 'sched_note_cpu_start' [-Wimplicit-function-declaration]
  102 |   sched_note_cpu_start(this_task(), cpu);
      |   ^~~~~~~~~~~~~~~~~~~~
chip/qemu_boot.c:102:24: warning: implicit declaration of function 'this_task' [-Wimplicit-function-declaration]
  102 |   sched_note_cpu_start(this_task(), cpu);
      |                        ^~~~~~~~~

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-25 17:10:50 +08:00
hujun5
fccd908114 arch/arm64: syscall SYS_switch_context and SYS_restore_context use 0 para
reason:
simplify context switch
sys_call0(SYS_switch_context)
sys_call0(SYS_restore_context)

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-23 12:22:21 +08:00
hujun5
f4d212fd6d arm64: remove up_set_current_regs/up_current_regs
reason:
up_set_current_regs initially had two functions:

1: To mark the entry into an interrupt state.
2: To record the context before an interrupt/exception. If we switch to
a new task, we need to store the upcoming context regs by calling up_set_current_regs(regs).

Currently, we record the context in other ways, so the second function is obsolete. Therefore,
we need to rename up_set_current_regs to better reflect its actual meaning, which is solely to mark an interrupt.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-23 02:05:56 +02:00
cuiziwei
8e58245524 sim: Fix sim m32 start up crash issue.
After compilation, when starting nsh, the following crash occurs.
==2500151==Shadow memory range interleaves with an existing memory mapping. ASan cannot proceed correctly. ABORTING.
==2500151==ASan shadow was supposed to be located in the [0x1ffff000-0x3fffffff] range.
==2500151==Process memory map follows:
0x30000000-0x33dd4000 /nuttx/nuttx

To avoid overlaps, change the starting address of the text segment.

Using Ttext-segment=0x30000000 causes a crash when starting the 32-bit SIM.
Using -Ttext-segment=0x50000000 causes a crash when starting the 64-bit SIM.
Setting -Ttext-segment=0x40000000 resolves all issues perfectly.

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-11-23 01:47:34 +08:00
yinshengkai
0194c2f88a gcov: update gcov compilation parameters
profile-generate is used to generate compilation feedback optimization data, not just code coverage data

It will rely on the toolchain library:
nuttx/libs/libc/misc/lib_utsname.c:94:(.text.uname+0x2c): undefined reference to `__gcov_indirect_call_profiler_v4'
arm-none-eabi-ld: nuttx/libs/libc/misc/lib_utsname.c:113:(.text.uname+0x178): undefined reference to `__gcov_indirect_call'
arm-none-eabi-ld: nuttx/libs/libc/misc/lib_utsname.c:113:(.text.uname+0x188): undefined reference to `__gcov_time_profiler_counter'
arm-none-eabi-ld: nuttx/staging/libc.a(lib_utsname.o):(.data..LPBX0+0x30): undefined reference to `__gcov_merge_time_profile'

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-11-22 19:08:08 +08:00
wangmingrong1
1f2d1e97e8 x86-64: Added KASan compilation options
Sorry for this commit: 6cd43777c3
This is the real x86-64 modification, and this patch is x86
Fortunately, except for the error in the previous modification, the actual architecture is supported

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-22 15:06:02 +08:00
simbit18
d16de91e39 [MSYS2] CMake+Ninja Fix arm-none-eabi-ar: Argument list too long
This issue is related to the Arm toolchain for Windows which is available for x86 host architecture only (compatible with x86_64)

Windows (mingw-w64-i686) hosted cross toolchains
AArch32 bare-metal target (arm-none-eabi)

Issue
/bin/sh: line 1: /home/nuttx/nuttxnew/tools/gcc-arm-none-eabi/bin/arm-none-eabi-ar: Argument list too long

On Windows, arm-none-eabi-ar can only accept strings up to a maximum length of 32,768 characters.

We could suppress the 32K include string limitation by setting the CMake variable CMAKE_NINJA_FORCE_RESPONSE_FILE to ON.

This is unfortunately not enough!!! ): In the build phase this error comes out

$ cmake --build build
[2/1025] Building ASM object arch/CMakeFiles/arch.dir/arm/src/armv7-m/arm_exception.S.obj
FAILED: arch/CMakeFiles/arch.dir/arm/src/armv7-m/arm_exception.S.obj
/home/nuttx/nuttxnew/tools/gcc-arm-none-eabi/bin/arm-none-eabi-gcc.exe @arch/CMakeFiles/arch.dir/arm/src/armv7-m/arm_exception.S.obj.rsp -MD -MT arch/CMakeFiles/arch.dir/arm/src/armv7-m/arm_exception.S.obj -MF arch/CMakeFiles/arch.dir/arm/src/armv7-m/arm_exception.S.obj.d -o arch/CMakeFiles/arch.dir/arm/src/armv7-m/arm_exception.S.obj -c /home/nuttx/nxninja/nuttx/arch/arm/src/armv7-m/arm_exception.S
C:/msys64/home/nuttx/nxninja/nuttx/arch/arm/src/armv7-m/arm_exception.S:42:10: fatal error: nuttx/config.h: No such file or directory
   42 | #include <nuttx/config.h>
      |          ^~~~~~~~~~~~~~~~
compilation terminated.

The Workround I found to solve this problem is to overwrite
the responsible file flag CMAKE_${lang}_RESPONSE_FILE_FLAG with $DEFINES $INCLUDES $FLAGS

Maybe there is a better solution but this one it works. :)
2024-11-21 19:18:38 -03:00
wangmingrong1
6cd43777c3 x86-64: Support symbol table and kasan global variables cross-border detection
1. Add kasan compilation options
2. Modify the link process to support symbol tables and kasan global variables cross-border detection

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-22 00:01:36 +08:00
Jouni Ukkonen
085830612c arch/arm64/imx9: Fix cntfrq_el0 to correct value
Read base frequency from system counter0 and write it
to arm core register. This corrects timers to work properly
Then enable counting.

Signed-off-by: Jouni Ukkonen <jouni.ukkonen@unikie.com>
2024-11-21 11:26:45 -03:00
guoshichao
f6cfcfa39f armv6-m: fix the incorrect stub-function entry address of svc call
the stub-function entry address is stored in r4, we should branch to the
stub-function with blx r4, not r5

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2024-11-21 20:08:42 +08:00
Peter Bee
3e6913775d fix(rp2350): should copy data before init clock
Signed-off-by: Peter Bee <peter@PeterdeMac-mini.local>
2024-11-21 20:00:17 +08:00
cuiziwei
f0e03f6c3c Unify the linking options for 32-bit and 64-bit to text-segment=0x30000000.
In order to be compatible with 32-bit and 64-bit compilation, set the text-segment to 0x30000000.

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-11-21 16:13:52 +08:00
cuiziwei
feb38c43f2 sim/m64: Fix ld error.
/usr/bin/ld: nuttx.rel: relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: failed to set dynamic section sizes: bad value

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-11-21 12:13:14 +08:00
stbenn
9cd0ea32ea arch/stm32h5: Add timer register hardware file
This commit adds register definitions for advanced, basic, and general purpose timers. Formatting convention was taken from the H7 hardware timer header.
2024-11-21 10:54:10 +08:00
simbit18
7df0e945ad Fix Kconfig style
Remove spaces from Kconfig files
Add TABs
Replace help => ---help---
Remove extra TABs
Add comments
2024-11-20 16:45:40 -03:00
Peter Bee
c0f776dbc3 follow upstream change & fix minor things
Signed-off-by: Peter Bee <pbjd97@gmail.com>
2024-11-20 16:32:05 -03:00
Peter Bee
48ded21e30 refine driver
Signed-off-by: Peter Bee <pbjd97@gmail.com>
2024-11-20 16:32:05 -03:00
Marco Casaroli
c5b81401d8 arch(rp23xx): add files 2024-11-20 16:32:05 -03:00
Marco Casaroli
047b832f24 rp23xx: add pico-sdk files
These files were copied from a config of pico-sdk 2.0.0.

They provide struct address mapped access to peripherals, along
with register definitions. It also provides some compiler helpers
that are partially used by the port.
2024-11-20 16:32:05 -03:00
Jouni Ukkonen
9aa9ee28cd arch/arm64/imx9/lspi: improve spi initialization
Hardware initialization is based refcount, not
spi enable bit and add interface to unitialize bus

Signed-off-by: Jouni Ukkonen <jouni.ukkonen@unikie.com>
2024-11-20 12:49:12 -03:00
Huang Qi
fb92b60000 arch/risc-v: Minor document improvement
Add function description for function prototype of `riscv_jump_to_user`
to make it easier to read, and fix some inconsistent comment style in
`riscv_internal.h`.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2024-11-20 20:40:09 +08:00
Huang Qi
3a6de58904 riscv/syscall.h: Update comment for syscall
Change RV64GC to RISC-V since this file is for all RISC-V based platform.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2024-11-20 10:50:50 +01:00
YAMAMOTO Takashi
788f8fc495 esp32s3_partition.c: Appease a compiler warning (-Wdiscarded-qualifiers) 2024-11-20 17:43:12 +08:00
Jukka Laitinen
b088369014 arch/arm64/src/imx9/imx9_lpi2c.c: Clear NACK properly on last RX byte
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2024-11-20 17:36:00 +08:00
Jukka Laitinen
02a3437289 arch/arm64/src/imx9/imx9_lpi2c.c: Add error recovery on timeout
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2024-11-20 17:36:00 +08:00
Jukka Laitinen
3afa58cdda arch/arm64/src/imx9/imx9_lpi2c.c: Clean up the irq handling logic
Both RX and TX interrupts can be enabled after the setup of the transfer; the TX interrupt
must be enabled after queuing the first byte as done before. It is not possible to miss the
RX interrupts, as it pends as long as the byte gets read from the FIFO

When starting the TX, the first byte can be queued instantly, it won't be sent out to the
bus if there is NACK to the address. This also prevents spurious TX interrupts in error
cases, since the TX queue is not empty after initiating a transfer.

In some error cases controller sends STOP by itself even if AUTOSTOP is disabled.
It is better to tell the controller to ABORT, which will also generate STOP only when needed.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2024-11-20 17:36:00 +08:00
wangmingrong1
d41e3da911 Fix ALIGN_UP duplicate definition error
ALIGN_UP has been defined in nuttx.h

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-20 14:51:54 +08:00
Ville Juven
3146ea04b8 risc-v/up_testset: Implement test-and-set with AMOSWAP
It should be a bit more efficient to do compared to the LR/SC pair.
2024-11-20 13:27:40 +08:00
stbenn
8def1764a4 arch/stm32h5: add basic ADC support
Adds ADC support with minimal feature set (no DMA or Timers etc). A new nucleo-h563zi configuration was added to
provide easy testing with the adc example NSH addon.

Fix Kconfig spacing to tabs
2024-11-20 08:51:27 +08:00
BitBender334
bd7074460c arch/risc-v/src/mpfs/mpfs_irq.c: Default global interrupt priorities 2024-11-19 22:24:39 +08:00
liamHowatt
27e587b179 arch/esp32s3: fb add pandisplay
Signed-off-by: liamHowatt <liamjmh0@gmail.com>
2024-11-19 20:51:50 +08:00
chao an
f8ccfc3f7f arm/efm32: fix regression by PR#14810
itm syslog should use syslog_write() not up_putc()

Signed-off-by: chao an <anchao@lixiang.com>
2024-11-19 20:50:33 +08:00
chao an
c328650aa5 arm/cortex-m: itm syslog should select SYSLOG_REGISTER
Signed-off-by: chao an <anchao@lixiang.com>
2024-11-19 20:50:33 +08:00
chao an
5582134c04 arm/efm: fix build warning
chip/efm32_start.c:150:3: warning: implicit declaration of function 'itm_syslog_initialize';
                                   did you mean 'syslog_initialize'? [-Wimplicit-function-declaration]
  150 |   itm_syslog_initialize();
      |   ^~~~~~~~~~~~~~~~~~~~~
      |   syslog_initialize

Signed-off-by: chao an <anchao@lixiang.com>
2024-11-19 20:50:33 +08:00
SPRESENSE
f142d04b91 arch: cxd56xx: Fix compile error of cxd56_gnss.c
Fix error: 'g_rtc_enabled' undeclared (first use in this function).
2024-11-19 15:37:42 +08:00
Masayuki Ishikawa
1d6ece71b8 arch: arm: Fix cxd56xx for SMP
Summary:
- In https://github.com/apache/nuttx/pull/14465,
  atomic_compare_exchange_weak_explicit() was newly introduced
  in semaphore. However, cxd56xx has an issue with the API
  if SMP is enabled (see up_testset2 in cxd56_testset.c).
- This commit fixes the issue by using LIBC_ARCH_ATOMIC.

Impact:
- Only cxd56xx SoCs in SMP mode.

Testing:
- Tested with spresense:smp, spresense:wifi_smp
- NOTE: If DEBUG_ASSERTIONS is enabled assert would be happend.
  I think this might be another issue.

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2024-11-19 15:17:28 +08:00
YAMAMOTO Takashi
ae5df0e06c esp32s3_serial.c: make a comment match the code 2024-11-18 19:10:24 +08:00
YAMAMOTO Takashi
fd6eccb00e arch/xtensa/src/esp32/esp32_serial.c: fix a comment 2024-11-18 19:10:24 +08:00
ligd
a88652fe53 arm64: fix compile failed 'tpidr_el1' undeclared
time/lib_localtime.c: In function 'tz_lock':
time/lib_localtime.c:396:7: error: 'tpidr_el1' undeclared (first use in this function)
  396 |   if (up_interrupt_context() || (sched_idletask() && OSINIT_IDLELOOP()))
      |       ^~~~~~~~~~~~~~~~~~~~

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-11-17 20:03:44 +08:00
Xiang Xiao
b41d96ea67 sim/win: Replace nuttx_mode_t with int
align with the posix implementation

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-11-17 08:31:08 -03:00
guoshichao
2d7b19b359 ghs: add thumb mode detection support for ghs compiler
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2024-11-17 15:43:18 +08:00
hujun5
707f0ce719 arm64: remove unused code
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-17 10:07:27 +08:00
stbenn
caaee545b1 arch/stm32h5: Simplify PLL configuration.
The PLL clock configuration was simplified on the assumption the clocks are correctly set in the board.h file. Instead of seperate conditions
for register components, assume the relevant PLL registers are fully defined in board.h. This should result in easier to understand defines in board.h
and simpler code flow in the standard clock configuration function.

Changes were mad in the board file alongside changing the arch files. Changes to board/stm32h5:
  - PLL1 has been configured to use integer instead of fractional mode to reach the 250 MHz target. PLL2 and PLL3 configurations were
    removed since they are currently unused in the H5 configuration.
  - PLL1 output was verified by testing for changes in serial baud rate.
2024-11-16 01:55:32 +08:00
chao an
238cddde3a drivers/syslog: remove implement of syslog_putc()
syslog_putc() have a lot of duplicate logic with syslog_write().
remove syslog_putc() and reuse syslog_write() to simplify syslog printing.

Signed-off-by: chao an <anchao@lixiang.com>
2024-11-15 19:46:36 +08:00
hujun5
19b4911d7f arch: remove up_current_regs in common code
reason:

When entering an exception or interrupt, there are two sets of registers:
one is the "running regs", which we need to save,
and the other is the "ready to running regs", which we may soon use.
For consistency in logic, we can always store the "running regs" in the regs field of g_running_tasks,
otherwise it may lead to errors in the storage location of the "running regs."

When we need to access the "running regs," we should uniformly retrieve them from the regs field of g_running_tasks.

As the next step, we will rename the set_current_regs/up_current_regs functions
for each architecture to more appropriate names, solely for the purpose of identifying interrupts.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-15 18:25:35 +08:00
hujun5
5300d77398 fix some arch miss update g_running_tasks
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-15 18:25:35 +08:00
Takuya Miyasita
2275138dcf arch_atomic : Introduce CONFIG_LIBC_ARCH_ATOMIC
Some armv7-m-based SoCs do not work with atomic instructions,
even though armv7-m supports them.

To avoid using atomic instructions generated by gcc,
CONFIG_LIBC_ARCH_ATOMIC is newly introduced with which
arch_atomic.c is linked explicitly.

However, the function names need to be changed to avoid
build errors, since the functions described in stdatomic.h
are gcc built-in and inlined when the code is compiled.

About libcxx with CONFIG_LIBC_ARCH_ATOMIC, it still
does not work. It is also needed to call nx_atomic_ ver
instead of __atomic ver in
libcxx/include/__atomic/cxx_atomic_lmpl.h.

Signed-off-by: Takuya Miyasita <Takuya.Miyashita@sony.com>
2024-11-15 14:01:56 +08:00
Eero Nurkkala
f2949f84a3 arm64/imx9: add imx93-evk ddr training
This performs the DDR training for imx93-evk. In addition to the source code,
it downloads binaries which are included in the final image. The bootloader
must be ARCH_CORTEX_A53 instead of A55 due to atomic instructions that don't
work with the OCRAM / EL3 combination.

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
2024-11-15 09:56:31 +08:00
Pressl, Štěpán
fe4f7a3a16 arch/arm/src/samv7/sam_afec.c: AFEC1 actually has 12 physical inputs
This commit adds a max_pins field into the private struct.
AFEC0 has 11, AFEC1 has 12. The 12th pin of AFEC0 is an internal
pin connected to a temperature sensor, which we don't use.

Signed-off-by: Stepan Pressl <pressste@fel.cvut.cz>
2024-11-15 08:43:07 +08:00