-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
213 lines (170 loc) · 6.32 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
# Note: This isn't really a build system
# It's a bunch of command lines encoded
# in a Makefile so I don't have to remember
# multi part processes
BBBUILDROOT=$(shell realpath ./bbbuildroot)
M5BUILDROOT=$(shell realpath ./m5buildroot)
OUTPUTS=$(shell realpath ./outputs/)
BUILDROOT=$(BBBUILDROOT)/buildroot
.PHONY: toolchain \
buildroot_bb \
buildroot_m5 \
buildroot-gw30x \
uboot_bb \
uboot-generic \
uboot-gw302 \
uboot_m5 \
linux \
outputsdir \
kernel_m5.fit \
kernel_breadbee.fit \
rtk \
squeekyclean \
nor_ipl \
patchpushpreflight
CROSS_COMPILE=arm-buildroot-linux-gnueabihf-
all: toolchain nor_ipl spl_padded
outputsdir:
mkdir -p $(OUTPUTS)
# Prepare the environment
DEFAULT_BRANCH_LINUX=mstar_v5_12_rebase
DEFAULT_BRANCH_UBOOT=mstar_rebase_mainline
bootstrap:
git clone git@github.com:fifteenhex/linux.git
git -C linux checkout --track origin/$(DEFAULT_BRANCH_LINUX)
cp linux.config linux/.config
git clone git@github.com:breadbee/u-boot.git
git -C u-boot checkout --track origin/$(DEFAULT_BRANCH_UBOOT)
git clone git@github.com:breadbee/breadbee_buildroot.git $(BBBUILDROOT)
$(MAKE) -C $(BBBUILDROOT) bootstrap
git clone git@github.com:fifteenhex/mstarblobs.git
git clone git@github.com:fifteenhex/buildroot_mercury5.git $(M5BUILDROOT)
$(MAKE) -C $(M5BUILDROOT) bootstrap
# We need an ARM toolchain to build stuff so build one
# in the breadbee buildroot
toolchain:
if [ ! -e $(BUILDROOT)/output/host/bin/arm-buildroot-linux-gnueabihf-gcc ]; then \
$(MAKE) buildroot; \
fi
# We have two copies of build root here:
# one is the breadbee version with the bits it needs
# the other is the m5 version that is basically stock.
buildroot_bb:
$(MAKE) -C $(BBBUILDROOT)
buildroot_bb_clean:
$(MAKE) -C $(BBBUILDROOT) clean
buildroot_bb_config:
$(MAKE) -C $(BBBUILDROOT) buildroot_config
buildroot_bb_linux_update:
$(MAKE) -C $(BBBUILDROOT) linux_update
$(MAKE) -C $(BBBUILDROOT) linux_clean
buildroot_m5:
$(MAKE) -C $(M5BUILDROOT)
# We might want a generic rootfs to embed into a kernel,
# so copy that into the outputs dir
cp $(M5BUILDROOT)/buildroot/output/images/rootfs.cpio $(OUTPUTS)/m5_rootfs.cpio
buildroot_m5_config:
$(MAKE) -C $(M5BUILDROOT) buildroot_config
buildroot_m5_linux_config:
$(MAKE) -C $(M5BUILDROOT) buildroot_linux_menuconfig
buildroot_m5_linux_update:
$(MAKE) -C $(M5BUILDROOT) linux_update
$(MAKE) -C $(M5BUILDROOT) linux_clean
buildroot_m5_clean:
$(MAKE) -C $(M5BUILDROOT) clean
LINUX_ARGS=ARCH=arm -j8 CROSS_COMPILE=$(CROSS_COMPILE)
linux:
- rm linux/arch/arm/boot/zImage
PATH=$(BUILDROOT)/output/host/bin:$$PATH \
$(MAKE) -C linux DTC_FLAGS=--symbols \
W=1 \
$(LINUX_ARGS) \
zImage dtbs
# these are for booting with the old mstar u-boot that can't load a dtb
#cat linux/arch/arm/boot/zImage linux/arch/arm/boot/dts/msc313d-mc400l.dtb > \
# $(OUTPUTS)/zImage.msc313d
linux_internalinitramfs:
- rm linux/arch/arm/boot/zImage
PATH=$(BUILDROOT)/output/host/bin:$$PATH \
$(MAKE) -C linux DTC_FLAGS=--symbols \
$(LINUX_ARGS) \
CONFIG_INITRAMFS_SOURCE=../outputs/m5_rootfs.cpio \
zImage dtbs
# these are for booting with the old mstar u-boot that can't load a dtb
#cat linux/arch/arm/boot/zImage linux/arch/arm/boot/dts/msc313d-mc400l.dtb > \
# $(OUTPUTS)/zImage.msc313d
linux_config:
PATH=$(BUILDROOT)/output/host/bin:$$PATH \
$(MAKE) -C linux $(LINUX_ARGS) menuconfig
linux_clean:
PATH=$(BUILDROOT)/output/host/bin:$$PATH \
$(MAKE) -C linux $(LINUX_ARGS) clean
# uboot targets, only for breadbee and m5 for now
uboot-generic: outputsdir
$(MAKE) -C u-boot clean
PATH=$(BUILDROOT)/output/host/bin:$$PATH \
$(MAKE) -C u-boot mstarv7_defconfig
PATH=$(BUILDROOT)/output/host/bin:$$PATH \
$(MAKE) -C u-boot CROSS_COMPILE=$(CROSS_COMPILE) -j8
cp u-boot/ipl $(OUTPUTS)/generic-ipl
uboot_clean:
PATH=$(BUILDROOT)/output/host/bin:$$PATH \
$(MAKE) -C u-boot clean
# this is a nor sized image (because flashrom doesn't support writing partial images)
# that starts with the mstar IPL
nor_ipl: uboot_bb kernel_breadbee.fit
rm -f nor_ipl
dd if=/dev/zero ibs=1M count=16 | tr "\000" "\377" > nor_ipl
##dd conv=notrunc if=IPL.bin of=nor_ipl bs=1k seek=16
dd conv=notrunc if=mstarblobs/ipl_ddr3.bin of=nor_ipl bs=1k seek=16
dd conv=notrunc if=$(IPL_BB) of=nor_ipl bs=1k seek=64
dd conv=notrunc if=$(UBOOT_BB) of=nor_ipl bs=1k seek=128
dd conv=notrunc if=$(OUTPUTS)/dev_kernel_breadbee.fit of=nor_ipl bs=1k seek=512
mv nor_ipl $(OUTPUTS)/nor_ipl
# this is a nor sized image that starts with the u-boot SPL. This will require the
# SPL do the DDR setup etc.
nor: uboot_bb
rm -f nor
dd if=/dev/zero ibs=1M count=16 | tr "\000" "\377" > nor
dd conv=notrunc if=u-boot/spl/u-boot-spl.bin of=nor bs=1k seek=16
dd conv=notrunc if=u-boot/u-boot.img of=nor bs=1k seek=128
# This builds a FIT image with the kernel and right device tree for m5
kernel_m5.fit: buildroot_m5 outputsdir linux
mkimage -f kernel_m5.its \
$(OUTPUTS)/dev_$@
# This builds a FIT image with the kernel and the right device trees for breadbee.
kernel_breadbee.fit: outputsdir linux
$(BBBUILDROOT)/buildroot/output/host/bin/mkimage -f kernel_breadbee.its \
$(OUTPUTS)/dev_$@
chmod go+r $(OUTPUTS)/dev_$@
# This builds kernel image with the DTB appended to the end for the mcf50 with
# vendor u-boot
kernel_mcf50: outputsdir linux buildroot_m5
cat linux/arch/arm/boot/zImage linux/arch/arm/boot/dts/infinity6b0-ssc337de-mcf50.dtb > \
$(OUTPUTS)/$@
clean: linux_clean
rm -rf kernel_m5.fit kernel_breadbee.fit nor nor_ipl
push_linux_config:
cp linux/.config ../breadbee_buildroot/br2breadbee/board/thingyjp/breadbee/linux.config
push_linux_m5_config:
PATH=$(BUILDROOT)/output/host/bin:$$PATH \
$(MAKE) -C linux DTC_FLAGS=--symbols \
ARCH=arm -j8 CROSS_COMPILE=$(CROSS_COMPILE) savedefconfig
cp linux/defconfig $(M5BUILDROOT)/br2midrive08/board/70mai/midrive08/linux.config
squeekyclean:
$(MAKE) -C $(BBBUILDROOT) clean
run_tftpd: buildroot_bb
$(MAKE) -C $(BBBUILDROOT) run_tftpd
cleanuplinuxtree:
make -C linux clean
git -C linux clean -fd
patchpushpreflight: cleanuplinuxtree linux
checkdtbindings:
pip3 install git+https://github.com/devicetree-org/dt-schema.git@master
PATH=~/.local/bin/:$(PATH) $(MAKE) -C linux clean
PATH=~/.local/bin/:$(PATH) $(MAKE) -C linux dt_binding_check -j12
mainlining_generate_series:
git -C linux format-patch --cover-letter -v2 torvalds/master
include ssd20xd.mk
include breadbee.mk
include mercury5.mk