-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
164 lines (149 loc) · 5.62 KB
/
Makefile
File metadata and controls
164 lines (149 loc) · 5.62 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
CROSS_COMPILER ?= arm-linux-
CFLAGS = -Wall -O0 -g -std=c99
BOOT ?= nand
EMPTY :=
ifeq ($(BOOT), nand)
LINKSCRIPT = links_nand.lds
TARGET = bare2440_nand_boot
ENTRYADDR = 0x0(SRAM) and 0x30100000(SDRAM)
NANDBOOTSRC = 3_level/bsp/nand/nand_boot.c
else
LINKSCRIPT = links_nor.lds
TARGET = bare2440_nor_boot
ENTRYADDR = 0x30080000(SDRAM)
NANDBOOTSRC = $(EMPTY)
CFLAGS += -DBOOTING_FROM_NORFLASH
endif
SRC = ./3_level/s3c2440/s3c2440_startup.S
SRC += $(NANDBOOTSRC)
SRC += \
./3_level/s3c2440/s3c2440.c \
./3_level/s3c2440/s3c2440_it.c \
./3_level/s3c2440/s3c2440_misc.S \
./3_level/s3c2440/s3c2440_new_vector.S \
./3_level/bsp/gpio/led.c \
./3_level/bsp/gpio/key.c \
./3_level/bsp/uart/uart0.c \
./3_level/bsp/timer/timer0.c \
./3_level/bsp/timer/timer4.c \
./3_level/bsp/nand/nand.c \
./3_level/bsp/lcd/lcd.c \
./3_level/bsp/tinyusb/host/usbh.c \
./3_level/bsp/tinyusb/host/ohci/ohci.c \
./3_level/bsp/tinyusb/host/hub.c \
./3_level/bsp/tinyusb/class/usbtmc/usbtmc_device.c \
./3_level/bsp/tinyusb/class/net/net_device.c \
./3_level/bsp/tinyusb/class/bth/bth_device.c \
./3_level/bsp/tinyusb/class/vendor/vendor_host.c \
./3_level/bsp/tinyusb/class/vendor/vendor_device.c \
./3_level/bsp/tinyusb/class/hid/hid_host.c \
./3_level/bsp/tinyusb/class/hid/hid_device.c \
./3_level/bsp/tinyusb/class/dfu/dfu_rt_device.c \
./3_level/bsp/tinyusb/class/midi/midi_device.c \
./3_level/bsp/tinyusb/class/cdc/cdc_device.c \
./3_level/bsp/tinyusb/class/cdc/cdc_rndis_host.c \
./3_level/bsp/tinyusb/class/cdc/cdc_host.c \
./3_level/bsp/tinyusb/class/msc/msc_device.c \
./3_level/bsp/tinyusb/class/msc/msc_host.c \
./3_level/bsp/tinyusb/device/usbd.c \
./3_level/bsp/tinyusb/device/usbd_control.c \
./3_level/bsp/tinyusb/tusb.c \
./3_level/bsp/tinyusb/common/tusb_fifo.c \
./1_level/main.c \
./1_level/public/clib.c \
./1_level/public/crc.c \
./1_level/public/delay.c \
./2_level/printf/printf.c \
./2_level/shell/shell.c \
INC = \
-I./1_level \
-I./1_level/public \
-I./2_level/printf \
-I./2_level/shell \
-I./3_level/s3c2440 \
-I./3_level/bsp/gpio \
-I./3_level/bsp/uart \
-I./3_level/bsp/nand \
-I./3_level/bsp/timer \
-I./3_level/bsp/lcd \
-I./3_level/bsp/tinyusb/host/ehci \
-I./3_level/bsp/tinyusb/host/ohci \
-I./3_level/bsp/tinyusb/host \
-I./3_level/bsp/tinyusb/class/usbtmc \
-I./3_level/bsp/tinyusb/class/net \
-I./3_level/bsp/tinyusb/class/audio \
-I./3_level/bsp/tinyusb/class/bth \
-I./3_level/bsp/tinyusb/class/vendor \
-I./3_level/bsp/tinyusb/class/hid \
-I./3_level/bsp/tinyusb/class/dfu \
-I./3_level/bsp/tinyusb/class/midi \
-I./3_level/bsp/tinyusb/class/cdc \
-I./3_level/bsp/tinyusb/class/msc \
-I./3_level/bsp/tinyusb/device \
-I./3_level/bsp/tinyusb/osal \
-I./3_level/bsp/tinyusb \
-I./3_level/bsp/tinyusb/common
# you may need to add some archive lib here
SLIB = \
`$(CC) -print-file-name=libc.a` \
`$(CC) -print-file-name=libgcc.a`
AS = $(CROSS_COMPILER)gcc
CC = $(CROSS_COMPILER)gcc
LD = $(CROSS_COMPILER)ld
NM = $(CROSS_COMPILER)nm
SIZE = $(CROSS_COMPILER)size
OBJCOPY = $(CROSS_COMPILER)objcopy
OBJDUMP = $(CROSS_COMPILER)objdump
TARGET_ELF = $(TARGET).elf
TARGET_DIS = $(TARGET).dis
TARGET_BIN = $(TARGET).bin
OBJ = $(patsubst %.c, %.o, $(patsubst %.S, %.o, $(SRC)))
$(TARGET): $(OBJ) Makefile howtoburn
@$(LD) -T$(LINKSCRIPT) $(OBJ) $(SLIB) -o $(TARGET_ELF)
@$(OBJCOPY) -O binary -S $(TARGET_ELF) $(TARGET_BIN)
@$(OBJDUMP) -D -m arm $(TARGET_ELF) > $(TARGET_DIS)
@echo "$(TARGET_BIN) is ready, it's entry address is $(ENTRYADDR)"
%.o: %.c
@$(CC) $(CFLAGS) $(INC) -o $@ -c $<
@echo " CC "$<
%.o: %.S
@$(AS) $(CFLAGS) $(INC) -o $@ -c $<
@echo " AS "$<
howtoburn:
@echo
@echo "how to burn the image:"
ifeq ($(BOOT), nand)
@echo " 1. push the board's boot switch button to nor boot then power up."
@echo " 2. enter backspace in your serial terminal to let u-boot stay in command line."
@echo " 3. enter 'n' to u-boot menu in your serial terminal."
@echo " 4. start dnw, USB Port--->Transmit, don't need to care about the Configuration."
@echo " 5. push the board's boot switch button to nand boot then repower up. you may need to wait for a while for the board's booting."
@echo " 6. done."
else
@echo " 1. push the board's boot switch button to nor boot then power up."
@echo " 2. enter backspace in your serial terminal to let u-boot stay in command line."
@echo " 3. enter 'd' to u-boot menu in your serial terminal."
@echo " 4. start dnw, Configuration--->Options--->Download Address 0x30080000, USB Port--->Transmit."
@echo " 5. done."
endif
@echo "prerequisite:"
@echo " * the u-boot firmware(can be found in 'tools/dnw/u-boot.bin') in norflash. if negative, you may need to burn it into your board by OpenJTAG+OpenOCD."
@echo " * dnw, windows version."
@echo " * a serial terminal."
@echo
@echo "note:"
@echo " * it's forbidden to set the entry address to 0x30000000 in the link script, cause that's the MMU memory map table."
@echo " * the image generated by option: 'make BOOT=nor' is just running on SDRAM, which means it won't last if the board repower."
@echo " * you need to input 'make BOOT=nor clean' to clean the build targets after you compiled with 'make BOOT=nor'."
@echo
clean:
@rm -f $(TARGET_ELF) $(TARGET_DIS) $(TARGET_BIN) $(OBJ)
@rm -f boot_nand/s3c2440_startup.o
@rm -f boot_nor/s3c2440_startup.o
help:
@echo "Usage: make [BOOT=nand|nor] [CROSS_COMPILER=<CROSS_COMPILER's prefix>] [clean] [help]"
@echo " BOOT the booting flash, default: nand."
@echo " CROSS_COMPILER the prefix of user's cross-compiler. default: 'arm-linux-'."
@echo " clean clean all files generated by buid."
@echo " help print help message."
.PHONY: clean help howtoburn