EmuFlight icon indicating copy to clipboard operation
EmuFlight copied to clipboard

Emuflight 1.0.0 master rust

Open saidinesh5 opened this issue 1 year ago • 7 comments

Here's a pull request for how to get started with Rust Integration in EmuFlight 1.0.0 . The code size is still slightly higher (~1kb) But overall, the integration was smooth. The idea is we move more and more functions to the rustemu crate (and delete them from the C codebase)

To test this out,

  • Make sure you have Rust installed ( https://www.rust-lang.org/tools/install )
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  • Restart the terminal to make sure your PATH variable can use the rustup command and make sure to install the bare metal arm toolchain for rust installed:
rustup target add thumbv7em-none-eabihf
  • Then you can build emuflight using the regular Makefile
make TARGET=STM32F411

Let me know if there are any issues, so I can fix them before this is merged.

saidinesh5 avatar Sep 13 '22 16:09 saidinesh5

@saidinesh5 , does make EXTRA_FLAGS=-Werror test-all work for you locally? This may or may not be external to the rust mods.

nerdCopter avatar Sep 16 '22 13:09 nerdCopter

@nerdCopter this is weird error still. Makefile automatically deciding to compile the generated rustemu.h and failing..

$ make EXTRA_FLAGS=-Werror test-all
make: *** No rule to make target 'test-all'.  Stop.

saidinesh5 avatar Sep 16 '22 13:09 saidinesh5

without rust installed locally, i do sill have the test-all rule; albeit failing obviously

## emuflight-1.0.0-master-rust
$ make EXTRA_FLAGS=-Werror test-all
cd src/test && make test-all
make[1]: Entering directory '/media/disk2/SYNC/nerdCopter-GIT/EmuFlight_nerdRepo/src/test'
Falling back to 'clang'.
CC version: Debian clang version 11.0.1-2 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin
CXX version: Debian clang version 11.0.1-2 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin
compiling ../main/sensors/boardalignment.c 
compiling ../main/common/sensor_alignment.c 
compiling ../main/common/maths.c 
cd ../../src/rustemu && cargo +nightly build --release
/bin/sh: 1: cargo: not found
make[1]: *** [Makefile:682: ../../src/rustemu/target/x86_64-unknown-linux-gnu/release/librustemu.a] Error 127
make[1]: Leaving directory '/media/disk2/SYNC/nerdCopter-GIT/EmuFlight_nerdRepo/src/test'
make: *** [Makefile:715: test-all] Error 2

nerdCopter avatar Sep 16 '22 14:09 nerdCopter

Yeah you need to install rust first. It is complaining about missing cargo command. For me locally the rust side builds just fine. the tests are another story though

saidinesh5 avatar Sep 16 '22 14:09 saidinesh5

@nerdCopter what would it take to get this merged? This I do believe would become a big point that would help separate us from other firmware.

Quick-Flash avatar Oct 03 '22 19:10 Quick-Flash