首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >根据xargo,我的代码已经成功构建,但是目标中没有二进制,为什么?

根据xargo,我的代码已经成功构建,但是目标中没有二进制,为什么?
EN

Stack Overflow用户
提问于 2017-11-18 15:34:38
回答 1查看 294关注 0票数 0

我是铁锈的新手,所以如果我还不懂行话/工具,请原谅我。我试图让一个STM32F4闪烁一个发光二极管,我认为代码是正确的,但当我构建它时,xargo不会产生二进制或任何类型的错误。我的代码是:

代码语言:javascript
运行
复制
#![feature(proc_macro)] // <- IMPORTANT! Feature gate for procedural macros
#![no_std]

extern crate cortex_m;
extern crate cortex_m_rtfm as rtfm;
extern crate stm32f40x;

use cortex_m::peripheral::SystClkSource;
use rtfm::{app, Threshold};

app! {
    device: stm32f40x,
    resources: {},
    tasks: {
        SYS_TICK: {
            path: toggle,
            resources: [GPIOC],
        },
    },
}

fn init(p: init::Peripherals, _r: init::Resources) {
    // TODO: initialize the GPIO
    p.SYST.set_clock_source(SystClkSource::Core);
    p.SYST.set_reload(8_000_000); // 1s?
    p.SYST.enable_interrupt();
    p.SYST.enable_counter();
}

fn idle() -> ! {
    loop {
        rtfm::wfi();
    }
}

fn toggle(_t: &mut Threshold, r: SYS_TICK::Resources) {
    **r.GPIOC.odr.modify(|r, w| w.odr13().bit(!r.odr13().bit()));
}

Cargo.toml文件是

代码语言:javascript
运行
复制
[package]
name = "sign_firmware"
version = "0.0.1"
authors = ["teryret"]
categories = ["embedded", "no-std"]
description = "With any luck this will cause an STM32F4 based board to drive a few thousand LEDs."
keywords = ["arm", "cortex-m"]
license = "MIT OR Apache-2.0"
repository = "TODO"
[dependencies]
cortex-m = "*"
cortex-m-rt = "*"
cortex-m-rtfm = "*"
stm32f40x = "*"

[profile]
[profile.release]
debug = true
lto = true

[target.arm-none-linux-gnueabihf]
ar = "arm-linux-gnueabihf-gcc-ar"
linker = "arm-linux-gnueabihf-gcc"

当我在docker映像中运行xargo build --release时,我设置为包含所有的依赖项和诸如此类的东西,它说:

代码语言:javascript
运行
复制
teryret@bee ~/d/rtfm> ./build 
   Compiling core v0.0.0 (file:///usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore)
    Finished release [optimized + debuginfo] target(s) in 12.82 secs
    Updating git repository `https://github.com/rust-lang-nursery/compiler-builtins`
   Compiling compiler_builtins v0.1.0 (https://github.com/rust-lang-nursery/compiler-builtins#f5532b22)
    Finished release [optimized + debuginfo] target(s) in 2.12 secs
warning: unused manifest key: target.arm-none-linux-gnueabihf.ar
warning: unused manifest key: target.arm-none-linux-gnueabihf.linker
 Downloading cortex-m-rtfm v0.2.1
 Downloading stm32f40x v0.5.0
 Downloading cortex-m-rt v0.3.6
 Downloading cortex-m v0.3.1
 Downloading rtfm-core v0.1.0
 Downloading static-ref v0.2.1
 Downloading cortex-m-rtfm-macros v0.2.0
 Downloading error-chain v0.10.0
 Downloading quote v0.3.15
 Downloading rtfm-syntax v0.1.0
 Downloading syn v0.11.11
 Downloading unicode-xid v0.0.4
 Downloading synom v0.11.3
 Downloading volatile-register v0.2.0
 Downloading bare-metal v0.1.1
 Downloading aligned v0.1.1
 Downloading vcell v0.1.0
 Downloading r0 v0.2.2
   Compiling r0 v0.2.2
   Compiling libc v0.2.33
   Compiling vcell v0.1.0
   Compiling quote v0.3.15
   Compiling cc v1.0.3
   Compiling sign_firmware v0.0.1 (file:///usr/src/myapp)
   Compiling cortex-m-rt v0.3.6
   Compiling cortex-m-rtfm v0.2.1
   Compiling cfg-if v0.1.2
   Compiling rustc-demangle v0.1.5
   Compiling bare-metal v0.1.1
   Compiling unicode-xid v0.0.4
   Compiling aligned v0.1.1
   Compiling cortex-m v0.3.1
   Compiling static-ref v0.2.1
   Compiling volatile-register v0.2.0
   Compiling synom v0.11.3
   Compiling rtfm-core v0.1.0
   Compiling syn v0.11.11
   Compiling stm32f40x v0.5.0
   Compiling backtrace-sys v0.1.16
   Compiling backtrace v0.3.4
   Compiling error-chain v0.10.0
   Compiling rtfm-syntax v0.1.0
   Compiling cortex-m-rtfm-macros v0.2.0
    Finished release [optimized + debuginfo] target(s) in 47.2 secs

虽然很多东西是在目标中生成的/没有一个是二进制的,我可以在板上闪现。知道为什么吗?我的意思是,这肯定是很简单的事情,但我没有经验知道去哪里找。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-11-18 16:12:36

您所遵循的教程中,所有的示例位于“示例”目录中。。您可以使用--example参数构建这些参数,如本教程所示:

代码语言:javascript
运行
复制
xargo build --example hello

但是,如果这是您的主要程序,则需要将您的代码放在"src/main.rs",中,只允许:

代码语言:javascript
运行
复制
xargo build

如果您有多个可执行文件,则可以使用还请指定

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47367793

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档