1 | NAME= hello_world_flash
|
2 |
|
3 | # Abkürzungen, die anstatt der hinteren Befehle genommen werden
|
4 | CC = arm-elf-gcc #GNU-Compiler
|
5 | LD = arm-elf-ld -v #GNU-Linker
|
6 | AR = arm-elf-ar #
|
7 | AS = arm-elf-as #GNU-Assembler
|
8 | CP = arm-elf-objcopy #GNU Object utility Binary File erzeugen
|
9 | OD = arm-elf-objdump #
|
10 |
|
11 | # Optionen mit denen der Compiler, Linker, assembler gestartet werden
|
12 | # arm-elf-...
|
13 | #-O3 Codeoptimierung
|
14 | CFLAGS = -I./ -c -fno-common -O0 -g
|
15 | AFLAGS = -ahls -mapcs-32 -o crt.o
|
16 | LFLAGS = -Map main.map -T hello_world_linker_flash.cmd
|
17 | CPFLAGS = --output-target=binary
|
18 | ODFLAGS = -x --syms
|
19 |
|
20 | #Objekte, Libraries
|
21 | #Reihenfolge beachten, den in dieser wird in den Speicher geschrieben.
|
22 |
|
23 | OBJECTS = crt.o main.o system.o
|
24 |
|
25 |
|
26 | # alle mit make erzeugten Files löschen (Project -> Clean)
|
27 | clean:
|
28 | @ echo ---------------------------------------
|
29 | @ echo Vorher erzeugte Dateien werden gelöscht
|
30 | @ echo ---------------------------------------
|
31 | #das Minuszeichen vor rm unterdrückt Fehlermeldungen
|
32 | -rm $(OBJECTS) main.lst system.lst \
|
33 | main.out main.bin main.hex \
|
34 | main.map main.dmp crt.lst
|
35 | @ echo ---------------------------------------
|
36 | @ echo Vorher erzeugte Dateien wurden gelöscht
|
37 | @ echo ---------------------------------------
|
38 |
|
39 | # Zieldateien erzeugen, verlinken (Project -> Build Project)
|
40 | all: main.out
|
41 | @ echo "...copying" #erscheint in der Konsole
|
42 | $(CP) $(CPFLAGS) main.out main.bin
|
43 | $(OD) $(ODFLAGS) main.out >main.dmp
|
44 |
|
45 | # Libraries einbinden
|
46 | main.out: $(OBJECTS) hello_world_linker_flash.cmd
|
47 |
|
48 | @ echo ---------------------------------------
|
49 | @ echo *.o werden verlinkt
|
50 | @ echo ---------------------------------------
|
51 |
|
52 | $(LD) $(LFLAGS) -o main.out $(OBJECTS) libc.a libm.a libgcc.a
|
53 |
|
54 | @ echo ---------------------------------------
|
55 | @ echo *.o wurden verlinkt
|
56 | @ echo ---------------------------------------
|
57 |
|
58 |
|
59 | crt.o: crt.s
|
60 | @ echo ".assembling"
|
61 | $(AS) $(AFLAGS) crt.s > crt.lst
|
62 |
|
63 | # Programmteile compilieren
|
64 | @ echo ---------------------------------------
|
65 | @ echo *.c werden compiliert
|
66 | @ echo ---------------------------------------
|
67 | main.o: main.c
|
68 | @ echo ".compiling"
|
69 | $(CC) $(CFLAGS) main.c
|
70 |
|
71 | system.o: system.c
|
72 | @ echo ".compiling"
|
73 | $(CC) $(CFLAGS) system.c
|
74 | @ echo ---------------------------------------
|
75 | @ echo *.c wurden compiliert
|
76 | @ echo ---------------------------------------
|
77 |
|
78 | # **********************************************************************************************
|
79 | # FLASH PROGRAMMING
|
80 | #
|
81 | # Alternate make target for flash programming only
|
82 | #
|
83 | # You must create a special Eclipse make target (program) to run this part of the makefile
|
84 | # (Project -> Create Make Target... then set the Target Name and Make Target to "program")
|
85 | #
|
86 | # OpenOCD is run in "batch" mode with a special configuration file and a script file containing
|
87 | # the flash commands. When flash programming completes, OpenOCD terminates.
|
88 | #
|
89 | # Note that the script file of flash commands (script.ocd) is part of the project
|
90 | #
|
91 | # Programmers: Martin Thomas, Joseph M Dupre, James P Lynch
|
92 | # **********************************************************************************************
|
93 |
|
94 | # specify output filename here (must be *.bin file)
|
95 | TARGET = main.bin
|
96 |
|
97 | # specify the directory where openocd executable and configuration files reside (note: use forward slashes /)
|
98 | OPENOCD_DIR = 'd:/Programme/openocd-2007re204/bin/'
|
99 |
|
100 | # specify OpenOCD executable (pp is for the wiggler, ftd2xx is for the USB debuggers)
|
101 | #OPENOCD = $(OPENOCD_DIR)openocd-pp.exe
|
102 | OPENOCD = $(OPENOCD_DIR)openocd-ftd2xx.exe
|
103 |
|
104 | # specify OpenOCD configuration file (pick the one for your device)
|
105 | #OPENOCD_CFG = $(OPENOCD_DIR)at91sam7s256-wiggler-flash-program.cfg
|
106 | #OPENOCD_CFG = $(OPENOCD_DIR)at91sam7s256-jtagkey-flash-program.cfg
|
107 | #OPENOCD_CFG = $(OPENOCD_DIR)at91sam7s256-armusbocd-flash-program.cfg
|
108 | OPENOCD_CFG = $(OPENOCD_DIR)at91sam7s64-armusbocd.cfg
|
109 |
|
110 | # program the AT91SAM7S256 internal flash memory
|
111 | program: $(TARGET)
|
112 | @echo "Flash Programming with OpenOCD..." # display a message on the console
|
113 | $(OPENOCD) -f $(OPENOCD_CFG) # program the onchip FLASH here
|
114 | @echo "Flash Programming Finished." # display a message on the console
|