Merge branch 'edge' into track_allocs
[clinton/Smoothieware.git] / makefile
1 # Copyright 2011 Adam Green (http://mbed.org/users/AdamGreen/)
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 PROJECT=main
15 GCC4MBED_DIR=./gcc4mbed
16 INCDIRS=
17 LIBS_PREFIX=
18 LIBS_SUFFIX=
19 SRC=./src
20
21 #GCC4MBED_TYPE=Debug
22 #GCC4MBED_TYPE=Release
23 GCC4MBED_TYPE=Checked
24
25 # Set to 1 to tag each heap allocation with the caller's return address.
26 HEAP_TAGS=1
27
28 # Set to 1 configure MPU to disable write buffering and eliminate imprecise bus faults.
29 WRITE_BUFFER_DISABLE=1
30
31 # Set to 1 to allow MRI debug monitor to take full control of UART0 and use it
32 # as a dedicated debug channel. If you are using the USB based serial port for
33 # the console then this should cause you no problems. Set MRI_BREAK_ON_INIT to
34 # 0 if you don't want to break into GDB at startup.
35 ENABLE_DEBUG_MONITOR?=0
36
37 # Set to non zero value if you want checks to be enabled which reserve a
38 # specific amount of space for the stack. The heap's growth will be
39 # constrained to reserve this much space for the stack and the stack won't be
40 # able to grow larger than this amount.
41 STACK_SIZE=3072
42
43 ifeq "$(ENABLE_DEBUG_MONITOR)" "1"
44 # Can add MRI_UART_BAUD=115200 to next line if GDB fails to connect to MRI.
45 # Tends to happen on some Linux distros but not Windows and OS X.
46 MRI_UART=MRI_UART_0
47 MRI_BREAK_ON_INIT=1
48 MRI_SEMIHOST_STDIO=1
49 else
50 MRI_UART=MRI_UART_0 MRI_UART_SHARE
51 MRI_BREAK_ON_INIT=0
52 MRI_SEMIHOST_STDIO=0
53 endif
54
55 CONSOLE=/dev/ttyUSB0
56
57 include ./gcc4mbed/build/gcc4mbed.mk
58
59 .PHONY: debug-store flash upload debug console
60
61 debug-store: $(PROJECT).elf
62 cp $(PROJECT).elf $(PROJECT)_lastupload.elf
63
64 flash: $(PROJECT).hex debug-store
65 lpc21isp $< $(CONSOLE) 115200 12000
66
67 upload: $(PROJECT).bin debug-store
68 dfu-util -d 1d50:6015 -R -D $<
69
70 debug: $(PROJECT)_lastupload.elf
71 arm-none-eabi-gdb $< -ex "set target-charset ASCII" -ex "set remotelogfile mri.log" -ex "target remote $(CONSOLE)"
72
73 console:
74 stty raw ignbrk -echo 2000000 < $(CONSOLE)
75 ( cat <&3 & cat >&3 ; kill %% ) 3<>$(CONSOLE)