Commit Graph

6094 Commits

Author SHA1 Message Date
wangjianyu3 176516cbd6 tools/refresh.sh: Add log for progress
Log

  $ ./tools/refresh.sh --silent --defaults arch:risc-v
  Normalizing all boards in arch: risc-v !
    [1/227] Normalize arty_a7/nsh
    [2/227] Normalize arty_a7/netnsh
    [3/227] Normalize arty_a7/knsh
    # ... ...

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-04-27 09:55:47 +08:00
wangjianyu3 48d35efaca tools/refresh.sh: Should continue to refresh other configs when matching debug configs
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-04-27 09:50:24 +08:00
Alin Jerpelea 8e7c8b6c82 fs: migrate to SPDX identifier
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2026-04-27 09:45:00 +08:00
fangpeina 7b9e985cee Revert "tools: Add cmux command line tool"
This reverts commit c57a6f55cd39d56295cdbd459b745d9bebbfbd14.

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2026-04-21 01:36:10 +08:00
fangpeina 6beb510e29 tools: Add GSM 07.10 multiplexer tool.
Add GSM 07.10 multiplexer tool supporting two operating modes:

  python (default):
    Pure Python implementation using PTY virtual serial ports.
    No kernel modules required.

  kernel:
    Uses Linux n_gsm line discipline to create /dev/ttyGSM<N>
    device nodes. Includes retry mechanism for link establishment.

Usage:
  # Python mode (default, no kernel module required)
  python3 tools/gsmmux.py -d /dev/ttyUSB0 -n 3
  python3 tools/gsmmux.py -d /dev/ttyUSB0 -n 3 -b 115200
  python3 tools/gsmmux.py -d /dev/ttyUSB0 -n 3 -r raw.log
  python3 tools/gsmmux.py -d /dev/ttyUSB0 -n 3 --debug dbg.log
  python3 tools/gsmmux.py -d /dev/ttyUSB0 -n 3 -x hex.log
  python3 tools/gsmmux.py -d /dev/ttyUSB0 -n 3 --show-raw-data

  # Kernel mode (requires n_gsm kernel module)
  python3 tools/gsmmux.py --mode kernel -d /dev/ttyUSB0 -n 3
  python3 tools/gsmmux.py --mode kernel -d /dev/ttyUSB0 -n 3 -b 115200
  python3 tools/gsmmux.py --mode kernel -d /dev/ttyUSB0 -n 3 -l 21

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2026-04-21 01:36:10 +08:00
zhangyu117 3baaf08639 nuttx/atomic.h: use _Atomic define atomic_t.
1. use _atomic as wrapper because if _Atomic empty, may affects the compilation of other files:
   https://builder95.pt.miui.com/job/vela_test_task/792878/

2. for clang builtin function, it donot accept param with keyword "_Atomic"

Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
2026-04-21 01:36:04 +08:00
anjiahao 96cd406a3d Improve: Improve the accuracy of abi_check checks
1. use DW_AT_linkage_name find function, if die have "DW_AT_linkage_name".
2. Check die have parent to skip Rust lib function.
3. Update find file path.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:35:54 +08:00
v-tangmeng 0863a37436 tools/ci/testlist: remove some dat test
nuttx/include/arch/chip/chip.h:55:2: error: #error CONFIG_ARM64_GIC_VERSION should be 2, 3 or 4
  55 | #error CONFIG_ARM64_GIC_VERSION should be 2, 3 or 4

Signed-off-by: v-tangmeng <v-tangmeng@xiaomi.com>
2026-04-21 01:35:50 +08:00
v-tangmeng e7956722cc tools/ci/testlist: remove some dat test
nuttx/include/nuttx/lib/math32.h:50:19: error: missing binary operator before token "("
   50 | #if UINTPTR_MAX > UINT32_MAX

Signed-off-by: v-tangmeng <v-tangmeng@xiaomi.com>
2026-04-21 01:35:50 +08:00
v-tangmeng bd9682048a tools/ci/testlist: remove some dat test
clang toolchain led to compile error

Signed-off-by: v-tangmeng <v-tangmeng@xiaomi.com>
2026-04-21 01:35:49 +08:00
v-tangmeng 387d28ca70 tools/ci/testlist: remove some dat test
Signed-off-by: v-tangmeng <v-tangmeng@xiaomi.com>
2026-04-21 01:35:49 +08:00
xuxingliang 7ecd7b61f6 nxgdb: set trust read only on
So GDB will load readonly data from elf directly, instead of gdbserver.
It can also bypass the issue that some dump file includes wrong text section data

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2026-04-21 01:35:48 +08:00
guoshengyuan1 5055c14b2c tools/nxgdbmcp: remove some legacy code
nxgdbmcp contains some legacy code. This is because in its earliest
design, nxgdbmcp had the ability to actively launch a GDB child process
to hijack its stdio interaction, thus performing more complex actions.

However, now it can only interact with GDB through gdbrpc, so some
actions should be assumed to have been performed by the user.

We found that adapting for each command results in significant token consumption for users.

Firstly, the native command support for GDB can be removed.
Secondly, regarding the nxgdb part, we need the nxgdb developers to write better help information so that the model can accurately understand it.

Signed-off-by: guoshengyuan1 <guoshengyuan1@xiaomi.com>
2026-04-21 01:35:48 +08:00
cuiziwei 79cc889099 feat(gdb/binder): refactor binderdump command with improved architecture
Refactor binder debugging module with better separation of concerns
and improved code quality.

Major changes:

1. Architecture improvements:
   - Separate data retrieval logic (module-level functions) from
     presentation layer (BinderDump class methods)
   - Add reusable helper functions: get_servicemanager(),
     get_binder_device(), get_process_self(), get_services(),
     get_proc_list()
   - Remove private method naming (leading underscores) for public API

2. Enhanced service listing:
   - get_services() now returns complete service information including
     binder pointer, isolation permission, dump priority, and PID
   - Improved output formatting with aligned columns

3. Iterator pattern for thread frame traversal:
   - Convert get_thread_frames() to generator using yield
   - Support flexible argument types: gdb.InferiorThread, int, or gdb.Value
   - Cleaner iteration without manual list accumulation

4. Code quality improvements:
   - Remove unnecessary try-except blocks
   - Add get_proc_list() to eliminate code duplication
   - Fix variable naming conflicts in dump_driver()
   - Improve type annotations (list[dict] instead of list[tuple])

5. Enhanced filesystem filtering:
   - fstype_filter() now supports both mountpoint filesystem types
     and inode types (e.g., "DRIVER", "BLOCK")

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2026-04-21 01:35:47 +08:00
xuxingliang d120498523 tools/pynuttx: add cycle detection to list iterators
Add cycle detection mechanism to NxList iterator to prevent
infinite loops when traversing corrupted linked lists.

When memory corruption causes a cycle in the list, the iterator
now tracks visited node addresses and stops iteration with a
warning message instead of hanging indefinitely.

Changes:
- Add _visited set to track traversed node addresses
- Check for cycles in __next__ before processing each node
- Print warning when cycle is detected and raise StopIteration

This fix applies to NxList, NxSQueue, and NxDQueue through
inheritance.

E.g.:
(gdb) wdog
Warning: cycle detected in list at node 0x42034678
WDog@0x42034b38: tick: 3896988          0x40270a71 <nxsig_timeout> arg: 0x42034ae0
WDog@0x41d32658: tick: 3897074          0x40269a59 <nxsem_timeout> arg: 0x41d32600

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2026-04-21 01:35:47 +08:00
xuxingliang 5e243fafa9 nxgdb: Add string parsing mode to setregs command
- Create parseregs.py with parse_registers() function to parse register
  values from string format (e.g., 'PC: 0x1234 SP: 5678')
- Enhance setregs command with -s/--string flag to support parsing
  registers from string instead of loading from memory
- Make colon separator optional to support space-separated format
  (e.g., 'PC 0x1234 SP 5678') in addition to colon format

Usage: setregs -s "PC: 0x1234 SP 5678 LR: 0xABC"
  setregs tcb->xcp.regs
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2026-04-21 01:35:44 +08:00
xuxingliang b21ac6fff6 gdbstub: return error packet when target doesn't support 'cont'
When the target doesn't support the 'cont' operation (continuing execution),
the GDB stub should return an error packet to GDB instead of indicating
the operation is unsupported. This allows GDB to properly handle the error
condition rather than treating it as an unsupported feature.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2026-04-21 01:35:43 +08:00
xuxingliang a33daf1984 sched/misc: fix stack dump format and update parser
Add colon separator after address in stack dump output to improve
readability and distinguish the address field from stack values.
Update the nxstub parser regex to handle flexible whitespace before
the address, ensuring it correctly parses the updated stack dump
format.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2026-04-21 01:35:42 +08:00
zhangyu117 6eccaee440 nuttx: skip mixed case for "apps/crypto/openssl_mbedtls_wrapper"
Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
2026-04-21 01:35:39 +08:00
anjiahao 543ce496ab mksyscall:The compiler determines whether parameters and return values are passed via pointers.
etc sigqueue:

STUB:

/#define RET_REF (sizeof(int) > sizeof(uintptr_t))
/#define PARM1 (sizeof(int) > sizeof(uintptr_t) ? (*(FAR int *)parm1) : ((int)parm1))
/#define PARM2 (sizeof(int) > sizeof(uintptr_t) ? (*(FAR int *)parm2) : ((int)parm2))
/#define PARM3 (*(FAR const union sigval *)(parm3))
uintptr_t STUB_sigqueue(int nbr, uintptr_t parm1, uintptr_t parm2, uintptr_t parm3, uintptr_t ret)
{
/#ifdef CONFIG_SCHED_NOPREEMPT_KERNEL
  sched_lock();
/#endif

  sched_note_syscall_enter(SYS_sigqueue, 3, PARM1, PARM2, PARM3);
  if (RET_REF)
    {
      *(FAR int *)ret = sigqueue(PARM1, PARM2, PARM3);
    }
  else
    {
      ret = (uintptr_t)sigqueue(PARM1, PARM2, PARM3);
    }

  sched_note_syscall_leave(SYS_sigqueue, (uintptr_t)ret);
/#ifdef CONFIG_SCHED_NOPREEMPT_KERNEL
  sched_unlock();
/#endif
  return ret;
}
/#undef RET_REF
/#undef PARM1
/#undef PARM2
/#undef PARM3

PROXY:

/#define RET_REF (sizeof(int) > sizeof(uintptr_t))
/#define PARM1 (sizeof(int) > sizeof(uintptr_t) ? (uintptr_t)(&parm1) : (uintptr_t)(parm1))
/#define PARM2 (sizeof(int) > sizeof(uintptr_t) ? (uintptr_t)(&parm2) : (uintptr_t)(parm2))
/#define PARM3 (uintptr_t)(&parm3)

int sigqueue(int parm1, int parm2, const union sigval parm3)
{
  int ret;

  if (RET_REF)
    {
      sys_call4(SYS_sigqueue, PARM1, PARM2, PARM3, (uintptr_t)&ret);
    }
  else
    {
      ret = (int)sys_call3(SYS_sigqueue, PARM1, PARM2, PARM3);
    }

  return ret;
}
/#undef RET_REF
/#undef PARM1
/#undef PARM2
/#undef PARM3

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:35:38 +08:00
anjiahao 4d7d58c0c3 Revert "syscall: fixed union illegal type for cast"
This reverts commit 500428a87813f71b3e3754b8de49548d84e13b74.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:35:38 +08:00
anjiahao 4a01a723d2 Revert "[BUGFIX]:Syscall parameter and return value truncation"
This reverts commit a9cb604f0cede2bb785af1a9da9ed27986ac7c80.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:35:38 +08:00
xuxingliang 134cf54610 nxgdb/target: fix misjudment of arch parameter
When file name contains '-a', e.g. arm-v7a/nuttx, it's misjudged as arch parameter.
Use ' -a ' instead can fix it.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2026-04-21 01:35:34 +08:00
xuxingliang 1378a307f4 nxgdb/thread: ignore registers cannot be loaded
So setregs command can try to set all registers even if some failed.
This may happen when for example setting arm CPSR failed.

Optimize setregs command to access any type of GDB value as argument.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2026-04-21 01:35:34 +08:00
anjiahao 4a2970f652 wraps:remove unnecessary sed entries and directly define --wrap=xxx
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:35:31 +08:00
anjiahao 3c688c3629 elf_fixup.py:hack tasking phdr
Because the data copy generated by tasking does not conform to the ELF standard,
we will not use the original ELF phdr. Instead, we will generate the corresponding phdr based on the section.
[.section.symbol] is used to record the PhysAddr of the section. It needs to be copied to the
address of the .section; this address will be used as the VirtAddr. If there are sections that can be merged, we will merge them.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:35:31 +08:00
anjiahao e3f70ba7a7 elf_fixup.py:Modify link method
Linking twice: the first time yields the actual size,
allowing the second link to find the correct starting position.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:35:30 +08:00
xuxin19 10cf63f4d8 build.sh[bugfix]: use envsetup and lunch&m as internal implement
as we keep build.sh temporarily in opensource,
we'll empty the internals of build.sh.

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2026-04-21 01:35:29 +08:00
v-tangmeng 0b86c4533d citest: temp delete some test dat for ci
Signed-off-by: v-tangmeng <v-tangmeng@xiaomi.com>
2026-04-21 01:35:26 +08:00
anjiahao 6d9849b204 wrapsymbol:support build with Cmake and Makefile
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:35:06 +08:00
anjiahao 89b5335c71 Use wrapsymbol.c to use the wrap function and avoid compiler dependencies.
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:35:06 +08:00
anjiahao e13f87d75a elf_fixup.py:support tasking toolchian
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:35:06 +08:00
anjiahao 516b9bb7b7 elf_fixup.py:abstracting the behavior of the toolchain
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:35:06 +08:00
wangmingrong1 4c89e094b5 trace.py: Fix the issue of nev_data not being parsed
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2026-04-21 01:34:56 +08:00
xuxingliang bfcce97be3 nxgdb/memdump: fix regular expression for byte sequence
Use pythons' built-in bytes.find instead of re since the it treats value as string representation.
This fixed the issue of

memfind 0x3c452838
Searching for pattern b'3828453c' in memory
Error: missing ), unterminated subpattern at position 1
Traceback (most recent call last):
  File "/home/neo/.local/lib/python3.10/site-packages/nxgdb/utils.py", line 361, in wrapper
    func(self, args, from_tty)
  File "/home/neo/.local/lib/python3.10/site-packages/nxgdb/memdump.py", line 1088, in invoke
    pattern = re.compile(re.escape(value))
  File "/usr/lib/python3.10/re.py", line 251, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python3.10/re.py", line 303, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/lib/python3.10/sre_compile.py", line 788, in compile
    p = sre_parse.parse(p, flags)
  File "/usr/lib/python3.10/sre_parse.py", line 955, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
  File "/usr/lib/python3.10/sre_parse.py", line 444, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
  File "/usr/lib/python3.10/sre_parse.py", line 843, in _parse
    raise source.error("missing ), unterminated subpattern",
re.error: missing ), unterminated subpattern at position 1

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2026-04-21 01:34:55 +08:00
xuxingliang 72f54b35c0 nxgdb/mm: merge overlapping memory regions
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2026-04-21 01:34:55 +08:00
guoshengyuan1 6b9bb46ab2 tools/nxgdbmcp: disable automatic registration of nxthread unless explicity enable by user
Sometimes AI confuses thread and nxthread.
So perhaps we need to encourage users to use gdbserver as much as possible.

Signed-off-by: guoshengyuan1 <guoshengyuan1@xiaomi.com>
2026-04-21 01:34:53 +08:00
guoshengyuan1 7f851ed7a8 tools/nxgdbmcp: make the tools expression parameter of the value submodule support the int type
Because sometimes, after receiving a decimal integer, AI will start
performing operations such as reading memory.

Signed-off-by: guoshengyuan1 <guoshengyuan1@xiaomi.com>
2026-04-21 01:34:53 +08:00
guoshengyuan1 67325c80de tools/nxgdbmcp: adding parameter comments to help the AI understand the parameters of some tools.
We found that AI may be using incorrect types of parameters when calling some tools with
Therefore, we should add some comments, which were previously considered
unnecessary.

Signed-off-by: guoshengyuan1 <guoshengyuan1@xiaomi.com>
2026-04-21 01:34:53 +08:00
xuxingliang 7fd29fbdfb nxgdb/noteram: exit when failed to parse args
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2026-04-21 01:34:51 +08:00
cuiziwei daa42b68a7 nuttx/tools: Fixes the issue that the libcxx GDB pretty printer was imported but not actually registered.
register_libcxx_printer_loader only monitor event of new_objfile to register the printers, thus it's not registered if we firstly load objfile, then source gdbinit.py.

This patch manually register LibcxxPrettyPrinter anyway.

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2026-04-21 01:34:50 +08:00
simbit18 bec0bc4800 arm/rp2040: CMake build for Raspberry Pi RP2040 implemented
- CMake added board Raspberry Pi Pico

- Added the entry:

     CMake,raspberrypi-pico:bmp280

   to the file arm-06.dat.

- Moved the search for the Python 3 interpreter to the
  root CMakefile to avoid unnecessary repetition.

Signed-off-by: simbit18 <simbit18@gmail.com>
2026-04-21 01:34:48 +08:00
Bowen Wang 7077541ee7 tools/mksyscall.c: fix the bug for inline stub
g_stubstream should be assigned at the first open and closed at
the end of function.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-04-21 01:34:48 +08:00
xuxingliang 033e47dc6e gdbrpc: add more examples
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2026-04-21 01:34:44 +08:00
xuxingliang 6900b0cda2 gdbrpc/server: add GdbThread for backward compatibility with older GDB
In newer GDB versions (>= 14.1), gdb.Thread is available as a subclass
of threading.Thread that automatically blocks signals. For older versions,
we implement GdbThread ourselves that uses gdb.blocked_signals() when
available (GDB >= 13.1) or falls back to regular threading.

This ensures the gdbrpc server works correctly across different GDB versions.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2026-04-21 01:34:42 +08:00
anjiahao b5df9b523b addrenv:wraps and task_start need include addrenv
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:34:40 +08:00
guoshengyuan1 fe9e87c58c pynuttx: use dynamic version numbers instead of statice ones
setuptools_scm will generate it by commit information.

  1. If the commit be marked as pynuttx-0.1.0, it will use 0.1.1
  2. If the commit is a regular commit, it will look up the major version number and use .dev.number.commit hash as a version number suffix.

Signed-off-by: guoshengyuan1 <guoshengyuan1@xiaomi.com>
2026-04-21 01:34:38 +08:00
wangmingrong1 afd9f52c26 t32/term: Supports serial port interaction terminals based on the trace32 term protocol.
To use this feature, enable CONFIG_OTHER_SERIAL_CONSOLE and open CONFIG_SERIAL_T32TERM_CONSOLE. Then, run the t32term.cmm script in the trace32 software to achieve serial terminal interaction based on trace32.

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2026-04-21 01:34:37 +08:00
anjiahao f11f21ba6c syscall:add up_addrenv api to wraps syscall to access kernel
ssize_t UP_WRAPSYM(write)(int parm1, FAR const void * parm2, size_t parm3)
{
  ssize_t result;
  ssize_t UP_REALSYM(write)(int, FAR const void *, size_t);

  up_addrenv_enter_kernel();
  result = UP_REALSYM(write)(parm1, parm2, parm3);
  up_addrenv_leave_kernel();

  return result;
}

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:34:30 +08:00
anjiahao 02e47fa72e elf_fixup.py:disable gc-section for elf_fixup
if use gc-section, elf_fixup.o will be optimization

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:34:29 +08:00