Skip to content

Look into finding a way to not require target specification files #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dylanmckay opened this issue Aug 23, 2017 · 4 comments
Open

Comments

@dylanmckay
Copy link
Member

Currently, all binaries that use avr-rust need to create a target specification file to instruction Rust to compile for a specific microcontroller.

The specification itself is always identical across devices, with the only difference being the CPU name. This means that if you want to support microcontroller in your executable, you need to create a target specifcation for it.

It might be easier for everyone if there is another method like a command line argument for it. I am not sure of any solutions yet, it needs some investigation.

@shepmaster
Copy link
Member

specification itself is always identical across devices

I'm not sure that I fully agree with that, as I'm pretty sure mine are different from what most other people use (as I avoid the AVR-GCC standard lib).

That being said, it certainly makes sense to have some easier way to deal with this.

@dylanmckay
Copy link
Member Author

dylanmckay commented Aug 23, 2017

rust-arduino-blink-led-no-core-with-cargo/blink/arduino.json

Interesting, that makes sense.

@gergoerdi
Copy link
Collaborator

For what it's worth, I also use a custom target file in chip8: https://github.com/gergoerdi/rust-avr-chip8-avr/blob/f6e1ded1354dce26061c9ef4c2fbd4641aee701b/avr-atmega328p.json

The reasons for that are:

The first should be done for all projects unconditionally until the linked issue is fixed. But I don't know how to do the second correctly. Is there a way to tell Cargo to compile and link in a C source? There must be a solution for this for FFI-using packages, I'd hope.

Alternatively, I could replace those C sources with Rust if we had a way of explicitly marking something (a global const &'static str maybe?) then I wouldn't have the C dependency anymore.

@dylanmckay
Copy link
Member Author

Is there a way to tell Cargo to compile and link in a C source?

Yes. In a build script, you can invoke GCC, generate an object file, and then print a formatted string (something like println!("cargo:link=object=<path>")) and it will do the linking automatically.

The gcc crate will do this all for you though, which makes it easy.

I could replace those C sources with Rust if we had a way of explicitly marking something

Do you mean marking something as living in program memory? If so, we should be able to add a new attribute pretty easily I think. I can't think of any more idiomatic ways of doing it without drastically changing the syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants