|
|
4 недель назад | |
|---|---|---|
| .. | ||
| core | 4 недель назад | |
| docs | 4 недель назад | |
| examples | 4 недель назад | |
| rt_macros | 1 месяц назад | |
| tools | 1 месяц назад | |
| Kconfig | 1 месяц назад | |
| README.md | 1 месяц назад | |
| README_zh.md | 4 недель назад | |
| SConscript | 1 месяц назад | |
RT-Thread's general-purpose Rust component for the RTOS, with automatic detection of multiple architectures.
rust/
├── README.md # Project documentation
├── Kconfig # Configuration options
├── SConscript # Top-level build script
├── core/ # Core Rust library
│ ├── Cargo.toml # Rust project config
│ ├── SConscript # Core library build script
│ ├── rust_cmd.c # MSH command registration
│ └── src/ # Source directory
│ ├── lib.rs # Library entry
│ ├── init.rs # Component initialization
│ ├── allocator.rs # Memory allocator
│ ├── panic.rs # Panic handler
│ ├── bindings/ # RT-Thread API FFI bindings
│ ├── api/ # RT-Thread API Rust wrappers
│ ├── prelude/ # Common imports
│ ├── thread.rs # Thread operations
│ ├── mutex.rs # Mutex
│ ├── sem.rs # Semaphore
│ ├── queue.rs # Message queue
│ ├── time.rs # Time functions
│ ├── fs.rs # Filesystem
│ ├── libloader.rs # Dynamic library loading
│ ├── param.rs # Parameter passing
│ └── out.rs # Output functions
├── rt_macros/ # Rust procedural macros
│ ├── Cargo.toml # Macros crate config
│ └── src/ # Macros source
│ ├── lib.rs # Macros crate entry
│ └── macros/ # Macro implementations
│ ├── mod.rs # Module definitions
│ ├── main.rs # main macro
│ ├── component.rs # component export macro
│ ├── app.rs # application export macro
│ └── cmd.rs # command export macro
├── examples/ # Example code
│ ├── Kconfig # Examples config
│ ├── SConscript # Examples build scripts
│ ├── application/ # Application examples
│ ├── component/ # Component examples
│ └── modules/ # Dynamic module examples
├── docs/ # Detailed documentation
└── tools/ # Build tools
├── build_support.py # Build support functions
├── build_component.py # Component build tool
├── build_usrapp.py # User app build tool
├── feature_config_component.py # Component feature config
└── feature_config_examples.py # Example feature config
Install Rust:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Add target platforms (choose according to your architecture):
# RISC-V64 (soft-float)
rustup target add riscv64imac-unknown-none-elf
# ARM Cortex-M4
rustup target add thumbv7em-none-eabi
# Add other targets that match your toolchain/ABI as needed
# Enable the Rust component in menuconfig
scons --menuconfig
# Navigate to: Rust Component Support → Enable
# Build
scons
# Clean
scons -c
| Architecture | Target | Auto-detect |
|---|---|---|
| Cortex-M3 | thumbv7m-none-eabi | ✓ |
| Cortex-M4/M7 | thumbv7em-none-eabi | ✓ |
| Cortex-M4F/M7F | thumbv7em-none-eabihf | ✓ |
| ARMv7-A | armv7a-none-eabi | ✓ |
| AArch64 | aarch64-unknown-none | ✓ |
| RISC-V32 | riscv32ima[f]c-unknown-none-elf | ✓ |
| RISC-V64 | riscv64[gc/imac]-unknown-none-elf | ✓ |
The build system will automatically determine the correct target from the RT-Thread configuration.
rust_param_demo — Parameter passing demorust_thread_demo — Thread demorust_mutex_demo — Mutex demorust_queue_demo — Queue demorust_sem_demo — Semaphore demorust_dl_demo — Dynamic module loading demorust_fs_demo — File and logging operations demo (requires logging component)Available in menuconfig:
RT_USING_RUST - Enable/disable the Rust componentRT_RUST_CORE - Enable/disable the core support libraryRUST_INIT_COMPONENT - Initialize automatically at startupRT_USING_RUST_EXAMPLES
RT_RUST_BUILD_APPLICATIONS: Enable/disable user applicationsRT_RUST_BUILD_COMPONENTS: Enable/disable componentsRT_RUST_BUILD_MODULES: Enable/disable building dynamic modulesRUST_DEBUG_BUILD - Enable/disable debug build#![no_std] environment..a library files.If you encounter the error "can't link double-float modules with soft-float modules":
-mabi flag matches the Rust target.If a target is reported as not installed:
rustup target add <target-name>
If the target architecture cannot be detected:
rtconfig.py.Apache-2.0