-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
298 lines (253 loc) · 10.3 KB
/
Makefile
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
#
BUILD_OS := $(shell uname)
CONNECTALDIR ?= ../connectal
BRANCH?=connectal-xilinx-v2016.1
ifeq ($(BRANCH),old)
LINUX_KERNEL_BRANCH=connectal-2014.04
DEFCONFIG=xilinx_zynq_portal_atheros_sdio_defconfig
KERNELID=3.9.0-00055-g6f85fcc
DTS_FILENAME=imagefiles/zynq-$(BOARD)-portal.dts
endif
ifeq ($(BRANCH),connectal-xilinx-v2014.4-trd)
LINUX_KERNEL_BRANCH=connectal-xilinx-v2014.4-trd
DEFCONFIG=xilinx_zynq_portal_defconfig
KERNELID=3.17.0-00013-g1a80225
DTS_FILENAME=dts/zynq-$(BOARD).dts
endif
ifeq ($(BRANCH),connectal-xilinx-v2016.1)
LINUX_KERNEL_BRANCH=connectal-xilinx-v2016.1
DEFCONFIG=xilinx_zynq_portal_defconfig
KERNELID=4.4.0-00018-g637e5c4
OS?=ubuntu
DTS_FILENAME=linux-xlnx/arch/arm/boot/dts/zynq-connectal-$(BOARD)-$(OS).dts
endif
INITRD_SIZE=512
ifeq ($(BUILD_OS), Darwin)
MD5PROG = md5
DTC=./bin/dtc
MACHEADERS = HOSTCFLAGS="-I../mac_linux_headers"
else
MD5PROG = md5sum
DTC=./bin/dtc
endif
MKFS=/sbin/mkfs
#BOOTBIN_NDK_OBJDUMP?=arm-none-linux-gnueabi-objdump
BOOTBIN_NDK_OBJDUMP?=$(shell ndk-which objdump)
PREFIX?=$(BOOTBIN_NDK_OBJDUMP:%-objdump=%-)
KERNEL_CROSS?=arm-linux-gnueabi-
DELETE_TEMP_FILES?=1
targetnames = bootbin sdcard all
all:
@echo "Please type one of the following:"
@echo " make sdcard-zynq.zip"
@echo " make bootbin.zedboard"
@echo " make sdcard.zedboard"
@echo " make all.zedboard"
@echo " make bootbin.zc702"
@echo " make sdcard.zc702"
@echo " make all.zc702"
@echo " make bootbin.zc706"
@echo " make sdcard.zc706"
@echo " make all.zc706"
@echo " make bootbin.miniitx100"
@echo " make sdcard.miniitx100"
@echo " make all.miniitx100"
@echo " make bootbin.zybo"
@echo " make sdcard.zybo"
@echo " make all.zybo"
@echo " make zImage"
@echo " make zynqdrivers"
#################################################################################################
# zedboard
zedboardtargets = $(addsuffix .zedboard, $(targetnames))
zedboardtargets: $(zedboardtargets)
$(zedboardtargets):
$(MAKE) BOARD=zedboard real.$(basename $@)
RUNPARAMTEMP=$(subst :, ,$(RUNPARAM):5555)
RUNIP=$(wordlist 1,1,$(RUNPARAMTEMP))
RUNPORT=$(wordlist 2,2,$(RUNPARAMTEMP))
update-adb:
adb connect $(RUNPARAM)
adb -s $(RUNIP):$(RUNPORT) push boot.bin /mnt/sdcard
adb -s $(RUNIP):$(RUNPORT) reboot
#$(CONNECTALDIR)/scripts/cadb $(RUNPARAM) push boot.bin /mnt/sdcard
#$(CONNECTALDIR)/scripts/cadb $(RUNPARAM) reboot
#################################################################################################
# zc702
zc702targets = $(addsuffix .zc702, $(targetnames))
zc702targets: $(zc702targets)
$(zc702targets):
$(MAKE) BOARD=zc702 real.$(basename $@)
#################################################################################################
# zc706
zc706targets = $(addsuffix .zc706, $(targetnames))
zc706targets: $(zc706targets)
$(zc706targets):
$(MAKE) BOARD=zc706 real.$(basename $@)
#################################################################################################
# miniitx100
miniitx100targets = $(addsuffix .miniitx100, $(targetnames))
miniitx100targets: $(miniitx100targets)
$(miniitx100targets):
$(MAKE) BOARD=miniitx100 real.$(basename $@)
#################################################################################################
# zybo
zybo-BITFILE := bitfile/zybo/zybobsd.bit
zybotargets = $(addsuffix .zybo, $(targetnames))
zybotargets: $(zybotargets)
$(zybotargets):
$(MAKE) BOARD=zybo real.$(basename $@)
#################################################################################################
ifdef DAFFODIL
MACBYTE=98
else
MACBYTE?=0x$(shell echo $(USER)$(BOARD) | $(MD5PROG) | cut -c 1-2)
endif
real.all: real.bootbin real.sdcard
clean:
## '"make realclean" to remove downloaded files
rm -fr sdcard-* boot.bin *.tmp *.elf *.gz *.hex *.o foo.map xbootgen canoncpio
realclean: clean
rm -fr filesystems/*
real.bootbin: zcomposite.elf imagefiles/zynq_$(BOARD)_fsbl.elf xbootgen
if [ -f boot.bin ]; then mv -v boot.bin boot.bin.bak; fi
./xbootgen imagefiles/zynq_$(BOARD)_fsbl.elf $($(BOARD)-BITFILE) zcomposite.elf
./update_bootbin_mac.py boot.bin $(MACBYTE)
ifeq ($(DELETE_TEMP_FILES),1)
rm -f zcomposite.elf
endif
# daffodil's zedboard uses this macaddress: 00:e0:0c:00:98:03
# if [ -f $(DTC) ]; then echo $(DTC); else make $(DTC); fi
INVOKE_DTC = $(DTC) -I dts -O dtb -o tmp.dtb $(DTS_FILENAME)
tmp.dtb: $(DTS_FILENAME)
$(INVOKE_DTC) || $(MAKE) $(DTC); $(INVOKE_DTC)
zcomposite.elf: ramdisk tmp.dtb
echo "******** PRINT GCC CONFIGURE OPTIONS *******"
$(PREFIX)gcc -v 2>&1
$(PREFIX)objcopy -I binary -B arm -O elf32-littlearm imagefiles/zImage z.tmp
$(PREFIX)objcopy -I binary -B arm -O elf32-littlearm ramdisk.image.gz r.tmp
$(PREFIX)objcopy -I binary -B arm -O elf32-littlearm tmp.dtb d.tmp
$(PREFIX)gcc -Wall -Werror -c -DBOARD_$(BOARD) -fno-unwind-tables clearreg.c
$(PREFIX)ld -e 0x1008000 -z max-page-size=0x8000 -o zcomposite.elf --script zynq_linux_boot.lds r.tmp d.tmp clearreg.o z.tmp
ifeq ($(DELETE_TEMP_FILES),1)
rm -f z.tmp r.tmp d.tmp clearreg.o c1.tmp clearreg.o ramdisk.image.gz tmp.dtb
endif
canoncpio: canoncpio.c
gcc -o canoncpio canoncpio.c
ramdisk: canoncpio
chmod 644 data/*.rc data/*.prop
cd data; (find . -name unused -o -print | sort | cpio -H newc -o >../ramdisk.image.temp1)
./canoncpio < ramdisk.image.temp1 | gzip -9 -n >ramdisk.image.temp
cat ramdisk.image.temp /dev/zero | dd of=ramdisk.image.gz count=$(INITRD_SIZE) ibs=1024
ifeq ($(DELETE_TEMP_FILES),1)
rm -f ramdisk.image.temp ramdisk.image.temp1
endif
xbootgen: xbootgen.c Makefile reserved_for_interrupts.h
gcc -g -o xbootgen xbootgen.c
ifeq ($(DELETE_TEMP_FILES),1)
rm -f reserved_for_interrupts.h
endif
dumpbootbin: dumpbootbin.c Makefile
gcc -g -o dumpbootbin dumpbootbin.c
reserved_for_interrupts.h: reserved_for_interrupts.S
$(PREFIX)gcc -Wall -Werror -c reserved_for_interrupts.S
$(PREFIX)ld -Ttext 0 -e 0 -o i.tmp reserved_for_interrupts.o
$(PREFIX)objcopy -O binary -I elf32-little i.tmp reserved_for_interrupts.tmp
./bin2header.py reserved_for_interrupts.tmp >reserved_for_interrupts.h
ifeq ($(DELETE_TEMP_FILES),1)
rm -f i.tmp reserved_for_interrupts.o reserved_for_interrupts.tmp
endif
zynqdrivers: zImage zynqdrivers.real
zynqdrivers.real:
[ -d connectal ] || git clone git://github.com/cambridgehackers/connectal
(set -e; cd connectal; git pull origin master; \
DEFCONFIG=$(DEFCONFIG) $(MAKE) zynqdrivers-clean; \
DEFCONFIG=$(DEFCONFIG) $(MAKE) zynqdrivers )
cp connectal/drivers/zynqportal/zynqportal.ko imagefiles
cp connectal/drivers/portalmem/portalmem.ko imagefiles
zImage: bin/dtc
cp linux-xlnx/arch/arm/boot/zImage imagefiles/zImage
real.sdcard: sdcard-$(BOARD)/system.img sdcard-$(BOARD)/userdata.img sdcard-$(BOARD)/boot.bin
cp -v imagefiles/zynqportal.ko imagefiles/portalmem.ko imagefiles/timelimit imagefiles/webserver sdcard-$(BOARD)/
[ -e sdcard-$(BOARD)/$(KERNELID) ] || mkdir sdcard-$(BOARD)/$(KERNELID)
echo "Files for $(BOARD) SD Card are in $(PWD)/sdcard-$(BOARD)"
.PHONY: real.sdcard real.bootbin real.all real.zImage
sdcard-$(BOARD)/boot.bin:
mkdir -p sdcard-$(BOARD)
rm -f boot.bin
$(MAKE) BOARD=$(BOARD) real.bootbin
mv boot.bin sdcard-$(BOARD)/boot.bin
filesystems/system-130710.img.bz2:
mkdir -p filesystems
wget 'https://github.com/cambridgehackers/zynq-boot-filesystems/blob/system-130710/system-130710.img.bz2?raw=true' -O filesystems/system-130710.img.bz2
filesystems/userdata.img.bz2:
mkdir -p filesystems
wget 'https://github.com/cambridgehackers/zynq-boot-filesystems/blob/userdata/userdata.img.bz2?raw=true' -O filesystems/userdata.img.bz2
sdcard-$(BOARD)/system.img: filesystems/system-130710.img.bz2
mkdir -p sdcard-$(BOARD)
bzcat filesystems/system-130710.img.bz2 > sdcard-$(BOARD)/system.img
(cd sdcard-$(BOARD); $(MD5PROG) -c ../imagefiles/filesystems.md5sum)
ifeq ($(shell uname), Darwin)
sdcard-$(BOARD)/userdata.img: filesystems/userdata.img.bz2
mkdir -p sdcard-$(BOARD)
bzcat filesystems/userdata.img.bz2 > sdcard-$(BOARD)/userdata.img
else
sdcard-$(BOARD)/userdata.img:
mkdir -p sdcard-$(BOARD)
# make a 100MB empty filesystem
dd if=/dev/zero bs=1k count=102400 of=sdcard-$(BOARD)/userdata.img
$(MKFS) -F -t ext4 sdcard-$(BOARD)/userdata.img
endif
sdcard-zynq.zip:
$(MAKE) all.zedboard
mv sdcard-zedboard sdcard-zynq
zip sdcard-zynq.zip sdcard-zynq/*.img sdcard-zynq/timelimit sdcard-zynq/webserver
mv sdcard-zynq sdcard-zedboard
bootbin.zip:
echo MACBYTE=$(MACBYTE)
$(MAKE) all.zedboard
rm -f boot.bin
$(MAKE) MACBYTE=$(MACBYTE) bootbin.$(BOARD)
mkdir bootbin-$(BOARD)
mv -v boot.bin bootbin-$(BOARD)
cp -v sdcard-zedboard/*.ko bootbin-$(BOARD)
mkdir bootbin-$(BOARD)/$(KERNELID)
zip bootbin-$(BOARD)-00e00c00$(MACBYTE)03.zip bootbin-$(BOARD)/*
rm -fr bootbin-$(BOARD)
update-zynq-boot-filesystems:
rm -f *.zip
$(MAKE) sdcard-zynq.zip
for b in zedboard zc702 zc706; do $(MAKE) BOARD=$$b bootbin.zip; done
(cd ../zynq-boot-filesystems; git checkout --orphan v$(VERSION))
cp *.zip ../zynq-boot-filesystems
(cd ../zynq-boot-filesystems; git add *.zip; git commit -m "version $(VERSION)")
.PHONY: bin/dtc
bin/dtc:
if [ -d linux-xlnx ]; then true; else git clone git://github.com/cambridgehackers/linux-xlnx.git; \
(cd linux-xlnx; git checkout origin/$(LINUX_KERNEL_BRANCH) -b $(LINUX_KERNEL_BRANCH)) fi
(set -e; cd linux-xlnx; \
git fetch; \
git checkout $(LINUX_KERNEL_BRANCH); \
echo git rebase origin/$(LINUX_KERNEL_BRANCH); \
$(MAKE) ARCH=arm CROSS_COMPILE=$(KERNEL_CROSS) $(MACHEADERS) $(DEFCONFIG); \
$(MAKE) ARCH=arm CROSS_COMPILE=$(KERNEL_CROSS) $(MACHEADERS) zImage; \
$(MAKE) ARCH=arm CROSS_COMPILE=$(KERNEL_CROSS) $(MACHEADERS) modules; \
$(MAKE) ARCH=arm CROSS_COMPILE=$(KERNEL_CROSS) $(MACHEADERS) M=scripts/dtc; \
cp -fv scripts/dtc/dtc ../bin/dtc)
zImage-clean:
if [ -d linux-xlnx ]; then true; else git clone git://github.com/cambridgehackers/linux-xlnx.git; fi
(cd linux-xlnx; \
$(MAKE) ARCH=arm CROSS_COMPILE=$(KERNEL_CROSS) $(MACHEADERS) clean)
webserver:
if [ -d webui ]; then true; else git clone git://github.com/cambridgehackers/webui.git; fi
cd webui; ndk-build
cp webui/libs/armeabi/webserver imagefiles/webserver
parallella-boot: ramdisk tmp.dtb
# create ouput area
mkdir -p parallella-images
# device tree
cp dtp.tmp parallella-images/dtb
# kernel
$(PREFIX)gcc -c -DBOARD_$(BOARD) -fno-unwind-tables clearreg.c
$(PREFIX)ld -e 0x1008000 -O binary -z max-page-size=0x8000 -o zcomposite.elf --script zynq_linux_boot.lds clearreg.o z.tmp
$(PREFIX)objcopy -O binary -B arm -o pImage c.tmp zImage