• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
2#
3# This program is free software; you can redistribute it and/or
4# modify it under the terms of the GNU General Public License
5# as published by the Free Software Foundation; either version 2
6# of the License, or (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
16
17include cfg.mk
18
19export CROSS_COMPILE := $(shell pwd)/../../../../../../../prebuilts/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-
20
21export CC := $(CROSS_COMPILE)gcc
22export AR := $(CROSS_COMPILE)ar
23export RANLIB := $(CROSS_COMPILE)ranlib
24export LD := $(CROSS_COMPILE)ld
25export OBJCOPY := $(CROSS_COMPILE)objcopy
26export OBJDUMP := $(CROSS_COMPILE)objdump
27
28CSRC  = $(wildcard *.c)
29SSRC  = $(wildcard *.S)
30
31OBJS := $(patsubst %.c,%.o,$(CSRC) )
32OBJS += $(patsubst %.S,%.o,$(SSRC) )
33
34export CFLAGS := -fno-builtin -fno-common
35CFLAGS += -Wall -D__KERNEL__ -DTEXT_BASE=$(TEXT_BASE)
36CFLAGS += -I$(PWD)/include/
37
38CFLAGS += -march=armv7-a
39CFLAGS += -mno-unaligned-access
40
41CFLAGS += -c
42
43CFLAGS += -O2
44
45TARGET = ddr_init
46
47LDSCRIPT := linker.lds
48LDFLAGS := -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE)
49LDFLAGS += drv/libdrv.a
50
51.SILENT:
52
53default:
54	make -C drv/
55	make -C boot/
56	sed -e 's/RAM_BASE/$(RAM_BASE)/' \
57		$(LDSCRIPT).mk > $(LDSCRIPT)
58
59	echo "  LD    $(OBJS) -Map $(TARGET).map -o $(TARGET)"
60	$(LD) $(OBJS) $(LDFLAGS) -Map $(TARGET).map -o $(TARGET)
61	$(OBJCOPY) -O binary $(TARGET) $(TARGET).bin
62
63	mkdir -p ./out
64	$(OBJDUMP) -D $(TARGET) > deasm.s
65	cp $(TARGET).map ./out
66	mv deasm.s ./out
67
68clean:
69	echo "  rm    boot/*.o"
70	make -C boot/ clean
71	echo "  rm    drv/*.o libdrv.a"
72	make -C drv/ clean
73	echo "  rm    $(TARGET) $(TARGET).bin* ./out"
74	rm -rf $(TARGET) $(TARGET).map $(TARGET).bin* ./out
75
76