Commit Graph

783 Commits

Author SHA1 Message Date
yangkun27 621979ddaf apps/tools/Wasm:fix wasm compile error
1.fix compile error 'Unknown CMake command "nuttx_add_dfx_event"'
2.add libgcc support for wasm compile

Signed-off-by: yangkun27 <yangkun27@xiaomi.com>
2026-04-20 15:20:24 +08:00
Huang Qi f824e6852f apps/rust: makefile updates for unified library build system
Replace individual Rust crate building with unified library approach through
makefile modifications for better build performance and dependency management.

* Updated Application.mk to include Rust.mk and add unified build targets
* Modified top-level Makefile to integrate RUST_BUILD_UNIFIED in build process
* Added RUST_CLEAN_UNIFIED call to Application.mk clean target
* Updated Makefile distclean target to remove rust_unified_lib directory
* Updated example Makefiles to use nuttx_add_rust registration function
* Removed manual EXTRA_LIBS configurations from Rust example Make.defs files
* Added .rdat registry files and rust_unified_lib to gitignore
* Enhanced tools/Rust.mk with unified build system functions

The unified system builds all registered Rust crates together through
makefile integration, improving compilation efficiency and enabling better
dependency management across the NuttX applications framework.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:20:21 +08:00
Huang Qi 55e0f2d13e tools: Fix hyphen handling in Rust unified library generator
Add hyphen-to-underscore conversion when creating module re-exports
in the generated src/lib.rs file. Rust module names must be valid
identifiers, so hyphens in crate names are converted to underscores
to prevent compilation errors.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:20:21 +08:00
Huang Qi 1dad176c8d build: Add NUTTX_BUILD_DIR environment variable to Rust build
Add NUTTX_BUILD_DIR environment variable to the cargo build command
in the Rust unified library build process. This allows Rust code to
access the NuttX build directory path during compilation, enabling
better integration between Rust and NuttX build systems.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:20:21 +08:00
Huang Qi f0193f34a3 tools: Fix target-pointer-width type in x86 target configs
Remove quotes around target-pointer-width values in i486 and x86_64
target configuration files to change from string to numeric type.
This change is required due to recent rustc JSON format modifications
that expect numeric values instead of strings for target-pointer-width.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:20:21 +08:00
pengyinjie 79c616f499 [wasm]: Update CMakeLists.txt for Wasm tool with custom module support
1. Check if CUSTOM_MODULE_PATH exists and add it to CMAKE_MODULE_PATH
2. This allows for custom modules to be included in the build process

Signed-off-by: pengyinjie <pengyinjie@xiaomi.com>
2026-04-20 15:20:15 +08:00
xuxin19 3f3d8c373c wasm:add CUSTOM_MODULE_PATH for wasm build
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2026-04-20 15:20:15 +08:00
chao an c33e23d46f libc/elf: rename modlib to libelf
Renaming "modlib" to "libelf" is more in line with the implementation content,
which makes it easier for individual developers to understand the capabilities of this module.

CONFIG_LIBC_MODLIB -> CONFIG_LIBC_ELF

Signed-off-by: chao an <anchao.archer@bytedance.com>
2026-04-20 15:20:13 +08:00
Huang Qi f5dba8ed46 tools/rust: Add vendored source configuration to generated config.toml
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:19:50 +08:00
Huang Qi 410c2503b7 tools/rust: Use prebuilt std library instead
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:19:50 +08:00
Huang Qi 8a3ea7fa7a cmake/rust: Use abort when panic to save text size
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:19:50 +08:00
Huang Qi b3bbb15284 cmake: Add unified Rust library build support and refactor existing logic
- Add unified Rust library generation tool (generate_rust_unified_lib.py)
- Refactor nuttx_add_rust.cmake to use unified library approach
- Support building multiple Rust crates as a single static library
- Add .config file generation support for unified library
- Update Rust examples to remove duplicate crate-type configuration

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:19:50 +08:00
gaoyuan28 dd04a4072b export NUTTX_APPS_DIR for Rust builds
Signed-off-by: gaoyuan28 <gaoyuan28@xiaomi.com>
2026-04-20 15:19:50 +08:00
yangkun27 94d558fb6c wasm:enhance wasm_build to allow adding wamrc compilation flags
Signed-off-by: yangkun27 <yangkun27@xiaomi.com>
2026-04-20 15:19:43 +08:00
zhuanglin b1fab3242d apps/tools:Add the NUTTX_APPS_DIR environment variable configuration.
add NUTTX_APPS_DIR and add APP_WRCFLAGS for aot compile in function
wasm_add_application

Signed-off-by: zhuanglin <zhuanglin@xiaomi.com>
2026-04-20 15:19:43 +08:00
Huang Qi b46ff92676 apps/tools/Wasm: Add wasm64 support to WASI-SDK CMake configuration
Add support for 64-bit WebAssembly architecture by including
appropriate compiler and optimization flags when CONFIG_ARCH_64BIT
is enabled.

* Add --target=wasm64 compile option for 64-bit builds
* Enable memory64 feature in wasm-opt optimization
* Improve WebAssembly build system compatibility with 64-bit targets

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:19:37 +08:00
Huang Qi 4887af8dda tools: Support passing WOPTFLAGS to wasm-opt
- Update Wasm.mk to pass WOPTFLAGS to wasm-opt invocation in LINK_WASM
- Improve error message for wasm-opt failures
- Enables additional wasm-opt options (e.g., --enable-memory64) to be set via WOPTFLAGS for more flexible optimization and compatibility

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:19:35 +08:00
Huang Qi 0b0b04513e tools: Add asan-% to CFLAGS_STRIP for WASI build
Add the asan-% pattern to CFLAGS_STRIP in WASI-SDK.defs to filter out AddressSanitizer-related flags that are not supported by wasm-clang.
* Prevents unsupported asan flags from being passed to the WASI toolchain
* Improves compatibility and avoids build errors when compiling for WebAssembly

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:19:31 +08:00
Huang Qi b6ba771c5a tools: Export NUTTX_INCLUDE_DIR for Rust builds
Set NUTTX_INCLUDE_DIR in the Rust build commands to include the necessary directories for proper compilation.
* Ensured correct include paths for Rust projects
* Improved build reliability for Rust components

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:19:30 +08:00
xuxin19 899db4adbc kernel build(bugfix): add fake install phase for wasm bin
we exec install phase by default in kernel mod,
which does not apply to wasm bin.

make[3]: *** No rule to make target 'install'.  Stop.
make[1]: *** [Makefile💯 .import] Error 2

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2026-04-20 15:19:29 +08:00
Huang Qi 56e97fa4ea tools/build: Make Rust target triples for x86 use JSON files
X86 support for Rust needs more test and verification, and not
upstreamed to Rust side yet.

It's better to use custom target triples for x86 by json files for now,
and it can be upstreamed to Rust side if stable enough.

Changed the Rust target triples in the CMake configuration to reference JSON files for x86_64 and i486 architectures. This improves the build process by providing more detailed target specifications.
* Added JSON files for i486 and x86_64 targets
* Updated CMake functions to use the new target triples
* Enhanced build directory structure for Rust crates

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:19:22 +08:00
Huang Qi 36f123d167 tools: Enhance WASMLD and LINK_WASM macros for clarity
Refactor the WASMLD and LINK_WASM macros to improve readability and maintainability.
* Added detailed comments explaining the functionality of each macro
* Streamlined the linking process for WebAssembly modules
* Improved error handling during the build process

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:19:21 +08:00
Huang Qi 8c4113cb9d wamr: Enhance WAMR_AOT_COMPILE macro for better clarity
Refactor the WAMR_AOT_COMPILE macro to improve readability and
clarity in its parameters and functionality.

* Added detailed comments explaining parameters and behavior
* Simplified the logic for AOT and XIP compilation
* Improved maintainability of the build process

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:19:21 +08:00
Huang Qi cd2b52c820 tools: Update Wasm.mk to use '%' instead of '#'
Changed the separator in the destination path from '#' to '%'
to improve compatibility with file naming conventions, '#' in file name may lead to file name parse error in Makefile.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:19:21 +08:00
Huang Qi 1767ff7cda tools/Rust: Add support for x86 platform
Summary:
- Added support for x86 and x86_64 architectures in the Rust build system
- Updated `nuttx_rust_target_triple` function in `cmake/nuttx_add_rust.cmake` to handle x86 and x86_64 target triples
- Updated `RUST_TARGET_TRIPLE` macro in `tools/Rust.mk` to include x86 and x86_64 target triples

Impact:
- Enables Rust crate compilation for x86 and x86_64 platforms
- No functional changes for existing architectures (ARM, RISC-V, etc.)
- Improves platform compatibility and expands Rust support in NuttX

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:19:21 +08:00
Huang Qi 098b3a7bdd tools/Rust: Add support for panic_immediate_abort
Summary:
- Added support for `panic_immediate_abort` in Rust builds, which causes the system to abort immediately on panic instead of unwinding the stack
- Enabled `-Zbuild-std-features=panic_immediate_abort` flag for release builds when `CONFIG_DEBUG_FULLOPT` is set
- Updated both CMake and Makefile build systems to include the new flag

Impact:
- Significantly reduces binary size (e.g., from 2270605 to 84987 bytes for riscv64imc)
- Changes panic behavior to immediate abort, which may be preferred for embedded systems
- Improves system reliability by preventing undefined behavior from stack unwinding in constrained environments
- Maintains compatibility with existing Rust code while providing a more deterministic panic handling mechanism

For example, if it is enabled, the system will panic immediately:
```
NuttShell (NSH) NuttX-12.8.0
nsh> hello_rust_cargo
{"name":"John","age":30}
{"name":"Jane","age":25}
Deserialized: Alice is 28 years old
Pretty JSON:
{
  "name": "Alice",
  "age": 28
}
riscv_exception: EXCEPTION: Illegal instruction. MCAUSE: 0000000000000002, EPC: 0000000080027df6, MTVAL: 0000000000000000
riscv_exception: PANIC!!! Exception = 0000000000000002
dump_assert_info: Current Version: NuttX  12.8.0 8e3621e059 Jan 20 2025 14:45:00 risc-v
dump_assert_info: Assertion failed panic: at file: :0 task: hello_rust_cargo process: hello_rust_cargo 0x80020588
/* Stack dump from NuttX */
```
vs the default behavior:
```
NuttShell (NSH) NuttX-12.8.0
nsh> hello_rust_cargo
{"name":"John","age":30}
{"name":"Jane","age":25}
Deserialized: Alice is 28 years old
Pretty JSON:
{
  "name": "Alice",
  "age": 28
}

thread '<unnamed>' panicked at /home/huang/Work/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/src/rust/library/std/src/sys/random/unix_legacy.rs:19:10:
failed to generate random data: Os { code: 2, kind: NotFound, message: "No such file or directory" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
nsh>
```

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:19:17 +08:00
Huang Qi 4329fd1362 examples: New app to build Rust with Cargo
Build Rust applictions with cargo is the most commn way,
and it's more easy to cooporate with Rust ecosystem.

This example shows how to use cargo to build a simple hello world
application.

And please notice that you need to install nighly version of rustc
to support this feature, any version after https://github.com/rust-lang/rust/pull/127755
is merged, can use NuttX as cargo target directly.

Build
-----

To build hello_rust_cargo application, you can use any target that based
on RISCV32IMAC, for example:
```
cmake -B build -DBOARD_CONFIG=rv-virt:nsh -GNinja .
```

And disable ARCH_FPU in menuconfig, since the hard coded target triple
in this demo is `riscv32imac`.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:19:16 +08:00
Huang Qi 192e4eb52d tools: Update WRC path to use WASM_TOOLCHAIN_PATH for wamrc
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:19:13 +08:00
Huang Qi 08c8294ced tools: Support passing WOPTFLAGS to wasm-opt
- Update Wasm.mk to pass WOPTFLAGS to wasm-opt invocation in LINK_WASM
- Improve error message for wasm-opt failures
- Enables additional wasm-opt options (e.g., --enable-memory64) to be set via WOPTFLAGS for more flexible optimization and compatibility

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:19:13 +08:00
Huang Qi 3767f87921 tools: Enable wasm64 target for 64-bit platforms
Support building WASM applications for 64-bit platforms (X64 and ARM64) by setting the target to wasm64.
* WASM_BUILD is no longer forcibly disabled for 64-bit architectures
* WCFLAGS now includes --target=wasm64 for Intel64 and ARM64
* Allows proper WebAssembly builds on supported 64-bit platforms

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:19:13 +08:00
xuxin19 c3e8900fe5 cmake(bugfix):use same DIR environment in Wasm build
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2026-04-20 15:19:12 +08:00
xuxin19 3f6c2c0f53 wasm cmake(bugfix): add missing wamrc x86 arch support
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2026-04-20 15:19:12 +08:00
Huang Qi 984c9377c3 tools/WASI-SDK.defs: Filter out unsupported coverage flags
Summary:
- Updated the `CFLAGS_STRIP` variable to include flags related to code coverage (`-fprofile%`, `-f%coverage%`) in the list of flags to be filtered out when constructing `WCFLAGS`
- This ensures that unsupported flags are not passed to the wasm-clang compiler, which previously caused build errors

Impact:
- No functional changes to the codebase
- Enhances the build process for WebAssembly targets by preventing the inclusion of unsupported compiler flags, thus avoiding build failures and improving compatibility

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:19:08 +08:00
xuxin19 8e824757e3 cmake(bugfix):add gc support for CMake wasm AOT build
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2026-04-20 15:19:05 +08:00
xuxin19 5eeae89ae3 cmake(bugfix):fix NuttX CMake Wasm build multi dirs cannot be identified
System is unknown to cmake, create:
Platform/WASI to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
Your CMakeCache.txt file was copied to CopyOfCMakeCache.txt. Please post that file on discourse.cmake.org.
CMake Error at CMakeLists.txt:100 (add_subdirectory):
  add_subdirectory given source
  "/home/data/vela/tmp/apps/frameworks/security/ta/alipay
  /home/data/vela/tmp/apps/frameworks/security/ta/comsst
  /home/data/vela/tmp/apps/frameworks/security/ta/hello_world
  /home/data/vela/tmp/apps/frameworks/security/ta/pin
  /home/data/vela/tmp/apps/frameworks/security/ta/triad
  /home/data/vela/tmp/apps/frameworks/security/ta/wxcodepay" which is not an
  existing directory.

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2026-04-20 15:19:03 +08:00
xuxin19 dc7de425d2 cmake(bugfix):fix TA wasm bin link entry missing issue
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2026-04-20 15:19:03 +08:00
xuxin19 cc17233608 cmake(bugfix):fix WASM install bin do not define error
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2026-04-20 15:19:02 +08:00
xuxin19 a6fcbb5831 cmake(enhance):Enhanced full WASM library and application compilation
1.add complete compilation FLAGS for wasm toolchain
2.wasm build no longer traverses the native directory, saving build time
3.implement OPT and AOT process actions for wasm files
4.create a bridge interface for navtie build and wasm build

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2026-04-20 15:19:01 +08:00
zhuanglin 857192dfdd tools:Remove the --param compilation option
Clang does not support the --param compilation option

Signed-off-by: zhuanglin <zhuanglin@xiaomi.com>
2026-04-20 15:19:00 +08:00
Xiang Xiao 8b520ef21e tools: Remove the unused mkwamrglue.py.
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-04-20 15:18:59 +08:00
Huang Qi 2bbb2f3943 tools: Optimize size by wasm-opt
dependson:4341795

wasm-opt is from binaryen.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:18:58 +08:00
Eren Terzioglu 8987b318f2 Improve nxdiag example for Espressif devices 2026-04-20 15:18:58 +08:00
Huang Qi 597b1e2116 tools: Add essential math.h for wasm build
Try to fix:
```
cp: cannot create regular file 'xxxx': file exists
```

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-04-20 15:18:57 +08:00
openvela-robot 373ce0a3b0 Merge branch 'master' into vela
apache/nuttx-apps commit id: c5c18a29973802b196e77adf3fd3e6742a269d83

Signed-off-by: ligd <liguiding1@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-04-20 15:18:54 +08:00
openvela-robot 4e0a573f23 nsh: support watch command
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2026-04-20 15:18:53 +08:00
openvela-robot b0d05e45c1 cmake(snyc):fix nuttx-apps CMakeList.txt conflit
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2026-04-20 15:18:51 +08:00
openvela-robot db9da5caee nshlib:Add macro restrictions to code that uses floating point numbers
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-20 15:18:49 +08:00
openvela-robot 7344f54d1a top:fix memleak if ps_recored retrun error
7   534         128     6096556 0x44c43720  [0x0402a5ec0] <mm_zalloc+8>        mm_heap/mm_zalloc.c:45
                                             [0x0402a35ce] <zalloc+18>          umm_heap/umm_zalloc.c:70
                                             [0x0402b72ba] <top_callback+238>   nsh_proccmds.c:733
                                             [0x0402b57f8] <nsh_foreach_direntry+32> nsh_fsutils.c:474
                                             [0x0402b7c86] <cmd_top+562>        nsh_proccmds.c:1252
                                             [0x0402b2496] <nsh_command+70>     nsh_command.c:1262
                                             [0x0402ae9fc] <nsh_execute+60>     nsh_parse.c:717

 7   534         512     6095859 0x44c1e270  [0x0402a5ec0] <mm_zalloc+8>        mm_heap/mm_zalloc.c:45
                                             [0x0402a35ce] <zalloc+18>          umm_heap/umm_zalloc.c:70
                                             [0x0402b72d8] <top_callback+268>   nsh_proccmds.c:741
                                             [0x0402b57f8] <nsh_foreach_direntry+32> nsh_fsutils.c:474
                                             [0x0402b7c86] <cmd_top+562>        nsh_proccmds.c:1252
                                             [0x0402b2496] <nsh_command+70>     nsh_command.c:1262
                                             [0x0402ae9fc] <nsh_execute+60>     nsh_parse.c:717

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-20 15:18:47 +08:00
openvela-robot 552570496c cjson_test:add define CONFIG_CJSON_NESTING_LIMIT
Summary:
 Added a limit to CJSON_NESTING_LIMIT. The default value is 1000, which can cause stack overflow in some test cases.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2026-04-20 15:18:46 +08:00
openvela-robot ce2bf03d31 net: Remove IFF_DOWN flag to compatible with Linux/*BSD
turn off interface by checking IFF_UP flag isn't set:
https://github.com/apache/nuttx/issues/1838

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-04-20 15:18:45 +08:00