Skip to content

Instantly share code, notes, and snippets.

@lixingcong
Created March 1, 2017 06:50
Show Gist options
  • Save lixingcong/9e381f80364d03a142c916d2f2d55fa2 to your computer and use it in GitHub Desktop.
Save lixingcong/9e381f80364d03a142c916d2f2d55fa2 to your computer and use it in GitHub Desktop.
gcc-arm-none-eabi on windows
diff --git a/Makefile b/Makefile
index cd97f5b..128ed69 100644
--- a/Makefile
+++ b/Makefile
@@ -3,22 +3,22 @@
include Makefile.common
LDFLAGS=$(COMMONFLAGS) -fno-exceptions -ffunction-sections -fdata-sections -L$(LIBDIR) -nostartfiles -Wl,--gc-sections,-Tlinker.ld
LDFLAGS_USE_NEWLIB=--specs=nano.specs -lc -lnosys
-LDLIBS+=-lstm32
+LDLIBS+="libs\libstm32.a"
all: libs src
- $(CC) -o $(PROGRAM_NAME).elf $(LDFLAGS) \
+ "$(CC)" -o $(PROGRAM_NAME).elf $(LDFLAGS) \
-Wl,--whole-archive src/app.a \
-Wl,--no-whole-archive \
$(LDLIBS) $(LDFLAGS_USE_NEWLIB)
#Extract info contained in ELF to readable text-files:
# arm-none-eabi-readelf -a $(PROGRAM_NAME).elf > $(PROGRAM_NAME).info_elf
- $(SIZE_ARM) -d -B $(PROGRAM_NAME).elf > $(PROGRAM_NAME).info_size
+ "$(SIZE_ARM)" -d -B "$(PROGRAM_NAME).elf" > "$(PROGRAM_NAME).info_size"
# arm-none-eabi-objdump -S $(PROGRAM_NAME).elf > $(PROGRAM_NAME).info_code
# arm-none-eabi-nm -t d -S --size-sort -s $(PROGRAM_NAME).elf > $(PROGRAM_NAME).info_symbol
# binary execute hex and bin
- $(OBJCOPY) -O ihex $(PROGRAM_NAME).elf $(PROGRAM_NAME).hex
+ "$(OBJCOPY)" -O ihex "$(PROGRAM_NAME).elf" "$(PROGRAM_NAME).hex"
# $(OBJCOPY) -O binary $(PROGRAM_NAME).elf $(PROGRAM_NAME).bin
- @cat $(PROGRAM_NAME).info_size
+ @cat "$(PROGRAM_NAME).info_size"
.PHONY: libs src clean tshow cleanall
diff --git a/Makefile.common b/Makefile.common
index af98935..8a30e0c 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -2,18 +2,18 @@
#This file is included in the general Makefile, the libs Makefile and the src Makefile
-TOP=$(shell readlink -f "$(dir $(lastword $(MAKEFILE_LIST)))")
-PROGRAM_NAME=bin/main
-LIBDIR=$(TOP)/libs
-STMLIB=$(LIBDIR)/STM32_USB-FS-Device_Lib_V4.0.0/Libraries
-
-TC=/mydata/toolchain/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi
-CC=$(TC)-gcc
-LD=$(TC)-ld -v
-OBJCOPY=$(TC)-objcopy
-AR=$(TC)-ar
-GDB=$(TC)-gdb
-SIZE_ARM=$(TC)-size
+TOP=E:\20170210\stm32-project\stm32-24L01
+PROGRAM_NAME=$(TOP)\bin\main
+LIBDIR=E:\20170210\stm32-project\stm32-24L01\libs
+STMLIB=$(LIBDIR)\STM32_USB-FS-Device_Lib_V4.0.0\Libraries
+
+TC=C:\gcc-arm-none-eabi\bin\arm-none-eabi
+CC=$(TC)-gcc.exe
+LD=$(TC)-ld.exe -v
+OBJCOPY=$(TC)-objcopy.exe
+AR=$(TC)-ar.exe
+GDB=$(TC)-gdb.exe
+SIZE_ARM=$(TC)-size.exe
# Device
#STM32F103RBT (128KB FLASH, 20KB RAM) --> STM32F10X_MD
@@ -24,20 +24,20 @@ TypeOfMCU=STM32F10X_MD
#========================================#
# supported device for JLinkExe (Linux)
-# https://www.segger.com/jlink_supported_devices.html
-JLINKEXE_SCRIPT=/tmp/JLinkExe.script
+# https:\\www.segger.com\jlink_supported_devices.html
+JLINKEXE_SCRIPT=\tmp\JLinkExe.script
SUPPORTED_DEVICE=STM32F103C8
#SUPPORTED_DEVICE=STM32F103ZE
# include path
INCLUDE+=-I.
-INCLUDE+=-I/mydata/toolchain/gcc-arm-none-eabi-5_3-2016q1/arm-none-eabi/include
-INCLUDE+=-I$(STMLIB)/CMSIS/Include
-INCLUDE+=-I$(STMLIB)/CMSIS/Device/ST/STM32F10x/Include
-INCLUDE+=-I$(STMLIB)/CMSIS/Device/ST/STM32F10x/Source/Templates
-INCLUDE+=-I$(STMLIB)/STM32F10x_StdPeriph_Driver/inc
-INCLUDE+=-I$(STMLIB)/STM32_USB-FS-Device_Driver/inc
-INCLUDE+=-I$(TOP)/src/drivers -I$(TOP)/src/stack -I$(TOP)/src/drivers/nrf24l01 -I$(TOP)/src/drivers/pc_control -I$(TOP)/src/drivers/route_table -I$(TOP)/src/demo -I$(TOP)/src/drivers/usb -I$(TOP)/src/drivers/lmx2581
+INCLUDE+=-I"C:\gcc-arm-none-eabi\arm-none-eabi\include"
+INCLUDE+=-I"$(STMLIB)\CMSIS\Include"
+INCLUDE+=-I"$(STMLIB)\CMSIS\Device\ST\STM32F10x\Include"
+INCLUDE+=-I"$(STMLIB)\CMSIS\Device\ST\STM32F10x\Source\Templates"
+INCLUDE+=-I"$(STMLIB)\STM32F10x_StdPeriph_Driver\inc"
+INCLUDE+=-I"$(STMLIB)\STM32_USB-FS-Device_Driver\inc"
+INCLUDE+=-I"$(TOP)\src\drivers" -I"$(TOP)\src\stack" -I"$(TOP)\src\drivers\nrf24l01" -I"$(TOP)\src\drivers\pc_control" -I"$(TOP)\src\drivers\route_table" -I"$(TOP)\src\demo" -I"$(TOP)\src\drivers\usb" -I"$(TOP)\src\drivers\lmx2581"
# symbols or marcos defined
SYMBOLS_DEFINE = -DUSE_GCC_FOR_ARM -DLRWPAN_DEFAULT_START_CHANNEL=44
diff --git a/src/Makefile b/src/Makefile
index 75716df..7fe3148 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -22,16 +22,16 @@ CFLAGS_USE_NEWLIB=-ffunction-sections -fdata-sections -fno-builtin
#OBJS+=usb_1.o
#OBJS+=timer2.o
-#VPATH+=drivers/pc_control
+#VPATH+=drivers\pc_control
#OBJS+=usart_scanf_irq.o
#OBJS+=execute_PC_cmd.o
#OBJS+=parse_PC_cmd.o
-#VPATH+=drivers/a7190
+#VPATH+=drivers\a7190
#OBJS+=exti8_irq.o
#OBJS+=A7190.o
-#VPATH+=drivers/nrf24l01
+#VPATH+=drivers\nrf24l01
#OBJS+=nrf24l01.o
#VPATH+=stack
@@ -42,11 +42,11 @@ CFLAGS_USE_NEWLIB=-ffunction-sections -fdata-sections -fno-builtin
#OBJS+=route_AP_level.o
#OBJS+=route_ping.o
-#VPATH+=drivers/lmx2581
+#VPATH+=drivers\lmx2581
#OBJS+=lmx2581.o
#OBJS+=ctl_lmx2581.o
-#VPATH+=drivers/usb
+#VPATH+=drivers\usb
#OBJS+=usb_desc.o
#OBJS+=usb_prop.o
#OBJS+=usb_pwr.o
@@ -68,9 +68,9 @@ all: src
src: app.a
app.a: $(OBJS)
- cd startup && $(AR) cr ../app.a $(OBJS)
+ cd startup && "$(AR)" cr "../app.a" $(OBJS)
$(OBJS):%.o: %.c
- $(CC) -c $< -o startup/$*.o $(CFLAGS) $(CFLAGS_USE_NEWLIB)
+ "$(CC)" -c $< -o "startup/$*.o" $(CFLAGS) $(CFLAGS_USE_NEWLIB)
.PHONY: src clean tshow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment