2022년에 개발자로 근무할 때 설치했던 Ubuntu-20.04가 호환성 문제로 너무 많은 시간을 잡아먹어서 그냥 싹 다 삭제하고 재설치하기로 마음을 먹었다.
PowerShell 기준
wsl --unregister Ubuntu-20.04
- Arch : x86_65
- sub : ?
- vendor : ?
- sys : linux (window wsl을 통한 Ubuntu 24.04(?))
- env : ?


내가 사용하는 보드에 맞는 것들을 찾아야 한다.
Board : STM3F103C8T6
[DataSheet]
1. Arm 32-bit Cortex-M3 CPU core
2. Mem : 64 or 128Kbytes of Flash memory, 20Kbytes of SRAM
- Clock, reset and supply management
Cortex-M3
- Architecture : Armv7-M
- ISA Support : Thumb or Thumb-2
-> thumbv7m-none-eabi 설치해야 함.
thumbv7m-none-eabi : Tier 2 -> Bare-metal target for CPUs in the Armv7-M arch family.
어떻게 코드가 마이크로컨트롤러 메모리맵에 적절하게 배치되는가?
-> cortex-m-rt crate를 통해 배치된다!!
which includes 'linker script' that works with any cortex-m based licenses.
cortex-m-rt Features
This crates takes care of:
- The memory layout of the program. In particular, it populates the vector table so the device can boot correctly, and properly dispatch exceptions and interrupts.
- Initializing static variables before the program entry point.
- Enabling the FPU before the program entry point if the target is -eabihf.
This crate also provides the following attributes:
- #[entry] to declare the entry point of the program
- #[exception] to override an exception handler. If not overridden all exception handlers default to an infinite loop.
또한, Rust Compiler에게 프로젝트를 다시 build할 때마다 Linker Script를 실행해야 한다고 알려줘야 하며, 이를 위해 some Arguments를 넘겨준다.
-> 하지만 매번 그렇게 하면 피곤하니까, 정리 작업을 하자.
mkdir .cargo
[config.toml] file
[build]
target = "thumbv7m-none-eabi"
[target.thumbv7m-none-eabi]
rustflags = ["-C", "link-arg=-Tlink.x"]
이제 Cargo build를 할 때마다 그 대상과 compiler flag가 자동으로 적용될 것이다.