Code Sourcery G++ Lite。C compiler: arm-none-eabi-gcc.exe
C++ compiler: arm-none-eabi-g++.exe
Linker for dyn: arm-none-eabi-g++.exe
Linker for static: arm-none-eabi-ar.exe
Debugger: arm-none-eabi-gdb.exe
Resource compiler: arm-none-eabi-windres.exe
Make: make.exe

File → New → Project → ARM Project,選擇上述編譯器。
STM32F10x_StdPeriph_Driver/src 下所有 .c。startup_stm32f10x_md.s(位於 Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/gcc_ride7/)。
Project → Build options → Search directories → Compiler 加入:
Libraries/CMSIS/CM3/CoreSupportLibraries/CMSIS/CM3/DeviceSupport/ST/STM32F10xLibraries/STM32F10x_StdPeriph_Driver/incinc/ 目錄
Linker settings → Other linker options:
-T"${PROJECT_DIR}/STM32F103C8_FLASH.ld"
腳本檔放專案目錄,定義 FLASH/RAM 區塊與區段配置。
Compiler settings → #defines 加入:
STM32F10X_MD
USE_STDPERIPH_DRIVER
-mcpu=cortex-m3 -mthumb
注意:Cortex-M3 僅支援 Thumb 指令集,不可 使用 -mcpu=stm32f103c8(GCC 不認得),正確為 -mcpu=cortex-m3。
arm-none-eabi-objcopy.exe -O ihex $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).hex
arm-none-eabi-size.exe $(TARGET_OUTPUT_FILE)

若使用 __WFI()、__WFE() 內建函式編譯報錯,確認已加 -mcpu=cortex-m3,並包含 <cmsis_gcc.h>(提供內建函式宣告)。
阿莫電子論壇高手指點:https://www.amobbs.com/forum.php?mod=viewthread&tid=5538067