rust-embed | Rust Macro which loads files
kandi X-RAY | rust-embed Summary
kandi X-RAY | rust-embed Summary
Rust Custom Derive Macro which loads files into the rust binary at compile time during release and loads the file from the fs during dev. You can use this to embed your css, js and images into a single executable which can be deployed to your servers. Also it makes it easy to build a very small docker image for you to deploy.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of rust-embed
rust-embed Key Features
rust-embed Examples and Code Snippets
Community Discussions
Trending Discussions on rust-embed
QUESTION
I'm cross compiling bare metal 32-bit code for x86 with Rust and I'm facing the problem, that the final object file is empty, if the entry function is not exactly called _start
; the linker throws all code away because it sees it as dead. I'm familiar with the fact, that _start
is a well-known entry point name, but the question is still:
What part in Rust, LLVM or Linker forces this? Also attributes like extern "C" fn ...
, #[no_mangle]
or #[export_name = "foobar"]
do not work (get thrown away by the linker). My guess is, that it's not the Rust compiler but the linker. As you can see, I use rust-lld
as linker and ld.lld
as linker-flavor in my case (see below).
- Where does the required
_start
-come from? Why does the linker throw my other code away? - Whats the best option to specify my custom entry point to the linker?
x86-unknown-bare_metal.json
...ANSWER
Answered 2021-Jun-10 at 12:17New Answer [Solution]
The real solution is quite simple but was hard to find, because it's hard to digg for possible options and solutions in this relatively undocumented field. I found out, that llvm-ld
uses the same options, as GNU ld
. So I checked against the GNU ld
link options and found the solution. It has to be
QUESTION
I'm currently trying to learn Rust (for embedded specifically), coming from a background of C for embedded systems and Python. So far, I've been reading Rust Programming Language and Rust for Embedded, and read a few blog posts on the web.
I want my first project to be a simple "Blinky", where an LED blinks infinitely. I've got an STM32L152CDISCOVERY board with an STM32L152 chip in it (basically same as STM32L151), which is a Cortex M3.
Instead of implementing everything from scratch, I want to leverage existing crates and HALs. I've found two that seem promising: stm32l1 and stm32l1xx-hal. I've tried to read the documentation of each of them and also part of the source code, but I still can't figure out how to use them correctly.
Got a few questions about Rust and about the crates:
I see that
stm32l1xx-hal
has a dependency onstm32l1
. Do I need to add both as a dependency in myCargo.toml
file? Or will that create problems related to ownership?Is this the correct way to add them? Why is the second one added like that
...[dependencies.stm32l1]
?
ANSWER
Answered 2021-May-29 at 19:32I got some help from a Discord community. The answers were (modified a bit by me):
stm32l1xx-hal
already depends onstm32l1
as seen here. There's no need to import it twice. It is enough to add to Cargo.toml:
QUESTION
The built in targets that Rust supports have target specifications that can be printed as described here. You can add more targets using a JSON file, but I can't find any JSON files for the existing targets.
Where are the built in target specifications found in the Rust source code?
...ANSWER
Answered 2021-Mar-29 at 13:07The builtin targets are not defined as JSON (because there's no reason to and that would just slow down the compiler for no reason): https://github.com/rust-lang/rust/tree/master/compiler/rustc_target/src/spec
You can actually find that information in the rustc devguide, in the "Adding a new target" page.
As that document shows, you can also ask rustc to export an existing target as JSON:
QUESTION
I'm using Rust 1.51 and this minimal crate:
...ANSWER
Answered 2021-Mar-28 at 10:41In Rust 1.51 (and below) functions like sin
, cos
, or log10
are not part of the core library (core::
) but only the standard library (std::
), therefore they are not available.
A practical solution is to use the crate libm
which offers typical mathematic functions for no_std
-environments.
QUESTION
I am working on an embedded rust project using msp430 controllers (MSP430G2553 - LaunchPad).
I have boilerplate code up and running from the msp430 quickstart repo
However, for my project, I need to run hmac, so I found a no_std
compatible crate. I have tried roughly 10 other crates as well without luck.
I believe I need to specify some flags for the linker, but I do not know which I am missing. I currently have rust the following rustflag set in .cargo/config
:
ANSWER
Answered 2021-Mar-17 at 13:05It seems that you are linking to the wrong memory spec file.
I would recommend to ensure that this file exists link-arg=-Tlink.x
, otherwise switch it to the correct file.
Rust embedded named their memory file memory.x, and I assume have followed the steps. So changing the flag to link-arg=-Tmemory.x
should fix it.
QUESTION
I'm looking at the documentation for gpio_cdev on docs.rs.
One of the optional features for that crate is async-tokio
, which allows you to write async code to check GPIO pins. There is an example of this on the gpio_cdev
github front page using AsyncLineEventHandle
.
The problem I'm seeing is that the docs.rs documentation has absolutely no mention of AsyncLineEventHandle
, or anything to do with Async.
Is there a button on the docs.rs website to show documentation for optional features? Are optional features never documented on docs.rs? Or is this up to the developer to include the documentation for optional features on docs.rs? Should I be filing a bug report for this?
I assume I'm able to see the documentation if I locally generate it using cargo doc
(though I haven't tried this). Is this the only option?
Edit: Confirmed that as long as I have the feature enabled, locally generating docs does show the async parts.
...ANSWER
Answered 2021-Mar-08 at 01:08Documentation in docs.rs is built ahead of time. It isn't generated on the fly. Because of this, there isn't a button.
Features being on or off during documentation building will depend on the crate author to specify that the feature be used and on for document compilation in docs.rs. Take a look at the Cross-compiling section on the About/Builds page and perhaps maybe send in a PR to gpio_cdev
to turn on all the features during documentation build in docs.rs?
QUESTION
I'm trying to use the RustEmbed crate to embed some svg icons into my executable. I don't see any documentation on how to turn the data returned from Asset::get("icons/some.svg")
into an actual image. My GUI library is fltk, and I want to create an fltk::image::SvgImage
using Asset
but SvgImage::new()
loads an svg from a path, not raw byte data. Because it loads the svg from a path and not from raw byte data, does that mean I can't use RustEmbed for embedding the icons into my target build?
I want to do this because I feel like embedding my image assets into the executable will help avoid IO errors when the path of my executable is changed during deployment/install/build. I thought this one of the intentions of the RustEmbed crate.
...ANSWER
Answered 2021-Mar-06 at 18:39Turns out that fltk::image::SvgImage has a from_data()
function. This can be used create load the svg from byte data:
QUESTION
I am new to rust and embedded systems. I was reading and going along "The Discovery Book" and I can't seem to figure out the errors below.
I have placed this in my main.rs
:
ANSWER
Answered 2021-Mar-01 at 13:14From the following page, "The Led and Delay abstractions", it looks like this is the set of imports that you need.
QUESTION
I'm learning how to use OpenOCD and GDB according to the Rust Embedded Book.
There is a moment when you connect to the running OpenOCD:
...ANSWER
Answered 2021-Jan-15 at 16:39When you connect to the target with target remote
GDB asks the target for its current register state, including the $pc
value. GDB does NOT (at that point) modify the remote state in any way.
When you first connected the remote reported a $pc
value of 0x0
. If the remote changed state for some reason, lets say, you ran something on the remote, then the $pc
value might change, say to 0x08000bbe
.
If you then disconnect and reconnect the remote target might still have a $pc
value of 0x08000bbe
which is what GDB will see.
As was mentioned in the comments, GDB is just trying to map the $pc
value onto the debug information in your program. The ??
shows that GDB can't find any symbols at address 0x0
. While GDB did find the symbol __c_m_sh_syscall
near to address 0x08000bbe
. However, this is information doesn't mean much at this point, you've not yet loaded anything onto the target, so you're not really in the function __c_m_sh_syscall
, it's just the current address of the remote.
When you do the load
command this is when GDB loads the executable onto the target, and writes to the $pc
.
TL;DR; If your work flow is target remote
then load
, don't worry about the state of the target immediately after the target remote
, this is just whatever random state happens to be in the target when you connect.
QUESTION
I am following the guide from the last rust newsletter: https://rust-embedded.github.io/embedonomicon/custom-target.html and encounter an issue related to soft/hard float configuration.
I created my new target by merging the mipsel-unknown-linux-uclibc.json with the arm-unknown-linux-gnueabihf.json to obtain the following result:
...ANSWER
Answered 2020-Oct-31 at 13:48I believe you just need to use arm-unknown-linux-gnueabihf
for the llvm-target
. The VFP error is related to the floating-point instruction set available (i.e. the hf in eabihf stands for Hard Float). I'm working on getting the armv7-unknown-linux-uclibceabihf
target working in rust. I received the same VFP error while getting the armv7-unknown-linux-uclibceabihf
target to work in rust and it turned out I just needed to use armv7-unknown-linux-gnueabihf
for the llvm-target
.
Also, here's my spec file for armv7-unknown-linux-uclibceabihf
for comparison:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install rust-embed
Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page