问题答疑 Q&A
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

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

被折叠的 条评论
为什么被折叠?



