arm-none-eabi-ld -Tuser/hc32l13x.lds -o grbl_hc32l13x.elf user/interrupts_hc32l13x.o user/system_hc32l13x.o user/main.o user/startup_hc32l13x.o -lm -Map=grbl_hc32l13x.map
arm-none-eabi-ld: cannot find -lm
makefile:33: recipe for target 'link' failed
改為在gcc時傳入-T參數
$(CC)gcc $^ -Tuser/hc32l13x.lds $(LDFLAG) -Map=$(target).map -o $(target).elf
出錯:arm-none-eabi-gcc: error: unrecognized command line option '-Map=grbl_hc32l13x.map'
再次改為:
$(CC)gcc $^ -Tuser/hc32l13x.lds $(LDFLAG) -Wl,-Map=$(target).map -o $(target).elf
編譯通過。
附上.lds:
SECTIONS{. = 0;.text : {user/startup_hc32l13x.o*(.text)}.data : {*(.data)}.bss : {*(.bss)}
}SECTIONS{. = 0;.text : { /*寫成 .text:{ 不對,要有空格。*/*(.text) /*寫成 *{.text} 不對,要為小括號。*/}.data : {*(.data)}.bss : {_sbss = .; /* define a global symbol at bss start */__bss_start__ = _sbss;*(.bss)*(.bss*)*(COMMON). = ALIGN(4);_ebss = .; /* define a global symbol at bss end */__bss_end__ = _ebss;}
}