Rust STM32F103嵌入式开发教程之问题答疑 Q&A9

博客围绕Rust和STM32在嵌入式开发中遇到的问题展开。涵盖defmt - test编译异常、单元测试异常、找不到链接脚本、烧录错误以及编译警告等问题,并针对每个问题给出了相应的解决办法,如修改配置文件、注释冲突配置等。

defmt-test 编译异常

报错信息

  = note: rust-lld: error: memory.x:4: region 'FLASH' already defined
          >>>   FLASH : ORIGIN = 0x08000000, LENGTH = 64K
          >>>                                         ^

          flip-link: the native linker failed to link the program normally; please check your project configuration and linker scripts

解决方案

在 .cargo/config.toml 文件中包含了两个目标都生效了, 导致 memory.x 被读取了两次。

参考资料:

[target.thumbv7m-none-eabi]
# runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel"
# runner = 'arm-none-eabi-gdb'
rustflags = [
    "-C",
    "linker=flip-link",
    "-C",
    "link-arg=-Tlink.x",
    # This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x
    # See https://github.com/rust-embedded/cortex-m-quickstart/pull/95
    "-C",
    "link-arg=--nmagic",
    "-C",
    "link-arg=-Tdefmt.x",
]

# 该配置只能写一份, 否则 memory.x 会导致异常
# [target.'cfg(all(target_arch = "arm", target_os = "none"))']
# # TODO: replace `$CHIP` with your chip's name (see `probe-run --list-chips` output)
# runner = "probe-run --chip STM32F103C8"
# rustflags = [
#     "-C",
#     "linker=flip-link",
#     "-C",
#     "link-arg=-Tlink.x",
#     "-C",
#     "link-arg=-Tdefmt.x",
#     # This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x
#     # See https://github.com/rus
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值