-
Notifications
You must be signed in to change notification settings - Fork 22
/
makefile.bat
111 lines (90 loc) · 2.61 KB
/
makefile.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
@echo off
setlocal ENABLEDELAYEDEXPANSION
rem DS203 Win32 GCC support by valky.eu
rem USER DEFINED VALUES
rem ===================================================
set CBASE=C:\arm_toolchain\arm-2011.03\bin\
set TARGET=E:\
set TFILE=APP_G251
set APP=1
rem ===================================================
Echo DS203 Build tool by valky.eu
Echo Target slot: !APP!
Echo DFU Drive: !TARGET!
call :CheckSpaces "%CD%" %CD%
set CROSS=!CBASE!arm-none-eabi-
set CC=!CROSS!gcc
set OBJCOPY=!CROSS!objcopy
set LD=!CROSS!ld
set AS=!CROSS!as
set STRIP=!CROSS!strip
if not exist !CC!.* (
echo Compiler not found !
goto :eof
)
set INTERMEDIATE=Bin
set STM_INC=..\FWLib\inc
set STM_SRC=..\FWLib\src
set STM_ASM=..\FWLib\asm
set SRC_SRC=..\App\src
set SRC_INC=..\App\inc
set SRC_LDS=..\App\lds
set SRC_ASM=..\App\asm
set CFLAGS=-Wunreachable-code -Wall -Os -Werror -fno-common -mcpu=cortex-m3 -mthumb -msoft-float -fomit-frame-pointer -MD -I !STM_INC! -I !SRC_INC! -I !SRC_SRC!
set AFLAGS=-mcpu=cortex-m3 -mthumb
set LDFLAGS=-nostartfiles -mcpu=cortex-m3 -mthumb -march=armv7 -mfix-cortex-m3-ldrd -msoft-float
set OBJS=Calibrat.o Draw.o Files.o Function.o ^
Interrupt.o Main.o Menu.o Process.o startup.o ^
stm32f10x_nvic.o cortexm3_macro.o
set SRCS= !SRC_SRC!\Calibrat.c !SRC_SRC!\Draw.c !SRC_SRC!\Files.c !SRC_SRC!\Function.c !SRC_SRC!\Interrupt.c ^
!SRC_SRC!\Main.c !SRC_SRC!\Menu.c !SRC_SRC!\Process.c !SRC_SRC!\startup.c ^
!STM_SRC!\stm32f10x_nvic.c
if exist *.elf del *.elf
if exist *.hex del *.hex
if exist *.bin del *.bin
echo Compiling...
if not exist !INTERMEDIATE! mkdir !INTERMEDIATE!
cd !INTERMEDIATE!
!CC! !AFLAGS! -c !STM_ASM!\cortexm3_macro.s -o cortexm3_macro.o
!CC! !AFLAGS! -c !SRC_ASM!\bios.S -o bios.o
!CC! !CFLAGS! -c !SRCS!
echo Linking...
!CC! -o !TFILE!_!APP!.elf !LDFLAGS! -T !SRC_LDS!\app!APP!.lds !OBJS!
!OBJCOPY! -O binary !TFILE!_!APP!.elf !TFILE!.bin
!OBJCOPY! -O ihex !TFILE!_!APP!.elf !TFILE!.hex
rem del *.d *.o
if not exist !TFILE!.hex (
echo Build failed
goto :eof
) else (
echo Build succeed !
)
if not exist !TARGET! (
echo Target device not ready
goto :eof
)
if exist !TARGET!\*.WPT (
echo Please start the device in DFU mode
echo ^(Hold the first button while powering on^)
goto :eof
)
Echo Downloading...
copy !TFILE!.hex !TARGET!!TFILE!.hex
rem del *.elf *.hex *.bin
Echo Waiting for the device...
:loop
if exist !TARGET!!TFILE!.not (
echo Failed to download
goto :eof
)
if exist !TARGET!!TFILE!.rdy (
echo Download ok
goto :eof
)
goto loop
:CheckSpaces
if not %1=="%2" (
echo.
echo Your current path contains spaces, it can cause some problems...
pause
)