Created
May 3, 2024 22:53
-
-
Save lupyuen/acb19827f55d91bca96ef76ddd778b71 to your computer and use it in GitHub Desktop.
Rust Apps for Apache NuttX RTOS: Build NuttX for QEMU. See https://github.com/lupyuen/nuttx-rust-app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mkdir nuttx | |
$ cd nuttx | |
$ git clone https://github.com/apache/nuttx nuttx | |
$ git clone https://github.com/apache/nuttx-apps apps | |
$ cd nuttx | |
$ tools/configure.sh rv-virt:nsh64 | |
$ make menuconfig | |
## TODO: Enable "Hello Rust" Example App | |
## https://github.com/lupyuen2/wip-nuttx/blob/rust/boards/risc-v/qemu-rv/rv-virt/configs/nsh64/defconfig | |
## Build NuttX with Tracing Enabled | |
$ make --trace | |
## Compile "hello_main.c" with GCC Compiler | |
riscv64-unknown-elf-gcc \ | |
-march=rv64imafdc \ | |
-mabi=lp64d \ | |
-c \ | |
-fno-common \ | |
-Wall \ | |
-Wstrict-prototypes \ | |
-Wshadow \ | |
-Wundef \ | |
-Wno-attributes \ | |
-Wno-unknown-pragmas \ | |
-Wno-psabi \ | |
-Os \ | |
-fno-strict-aliasing \ | |
-fomit-frame-pointer \ | |
-ffunction-sections \ | |
-fdata-sections \ | |
-g \ | |
-mcmodel=medany \ | |
-isystem /Users/Luppy/riscv/nuttx/include \ | |
-D__NuttX__ \ | |
-DNDEBUG \ | |
-pipe \ | |
-I "/Users/Luppy/riscv/apps/include" \ | |
-Dmain=hello_main hello_main.c \ | |
-o hello_main.c.Users.Luppy.riscv.apps.examples.hello.o | |
## Compile "hello_rust_main.rs" with Rust Compiler | |
rustc \ | |
--target riscv64i-unknown-none-elf \ | |
--edition 2021 \ | |
--emit obj \ | |
-g \ | |
-C panic=abort \ | |
-O \ | |
hello_rust_main.rs \ | |
-o hello_rust_main.rs.Users.Luppy.riscv.apps.examples.hello_rust.o | |
error: Error loading target specification: Could not find specification for target "riscv64i-unknown-none-elf". Run `rustc --print target-list` for a list of built-in targets | |
make[2]: *** [/Users/Luppy/riscv/apps/Application.mk:275: hello_rust_main.rs.Users.Luppy.riscv.apps.examples.hello_rust.o] Error 1 | |
make[1]: *** [Makefile:51: /Users/Luppy/riscv/apps/examples/hello_rust_all] Error 2 | |
make: *** [tools/LibTargets.mk:232: /Users/Luppy/riscv/apps/libapps.a] Error 2 | |
$ rustup target add riscv64gc-unknown-none-elf | |
$ pushd ../apps/examples/hello_rust | |
$ rustc \ | |
--target riscv64gc-unknown-none-elf \ | |
--edition 2021 \ | |
--emit obj \ | |
-g \ | |
-C panic=abort \ | |
-O \ | |
hello_rust_main.rs \ | |
-o hello_rust_main.rs.Users.Luppy.riscv.apps.examples.hello_rust.o | |
$ popd | |
$ make |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment