forked from inindev/uboot-rockchip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
139 lines (107 loc) · 4.53 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
# Copyright (C) 2024, John Clark <[email protected]>
UBOOT_TAG := v2024.01
RK3568_ATF := ../rkbin/rk3568_bl31_v1.43.elf
RK3568_TPL := ../rkbin/rk3568_ddr_1560MHz_v1.18.bin
RK3588_ATF := ../rkbin/rk3588_bl31_v1.34.elf
RK3588_TPL := ../rkbin/rk3588_ddr_lp4_2112MHz_lp5_2736MHz_v1.08.bin
UBOOT_BRANCH := $(UBOOT_TAG:v%=%)
TARGETS := target_rock-5b target_nanopc-t6 target_nanopi-r6c target_orangepi-5 target_orangepi-5-plus \
target_nanopi-r5c target_nanopi-r5s target_odroid-m1 target_radxa-e25
all: $(TARGETS)
configure: u-boot patch
@echo "\n$(h1)configuring source tree...$(rst)"
@rm -fv "outbin/$(BRD)_idbloader.img" "outbin/$(BRD)_u-boot.itb"
$(MAKE) -C u-boot $(CFG)
build: configure
@echo "\n$(h1)beginning compile...$(rst)"
$(MAKE) -C u-boot -j$$(nproc)
@echo "\n$(h1)success, $(BRD) build complete:$(rst)"
@echo "$(bld)$(red)"
@install -Dvm 644 "u-boot/idbloader.img" "outbin/$(BRD)_idbloader.img";
@install -Dvm 644 "u-boot/u-boot.itb" "outbin/$(BRD)_u-boot.itb"
@echo "$(rst)"
@$(MAKE) --no-print-directory help_block
u-boot: | check_prereqs
git clone --shallow-since=2024-01-07 "https://github.com/u-boot/u-boot.git"
git -C u-boot fetch origin $(UBOOT_TAG)
target_rock-5b:
$(MAKE) CFG=rock5b-rk3588_defconfig BL31=$(RK3588_ATF) ROCKCHIP_TPL=$(RK3588_TPL) BRD=$(@:target_%=%) build
@$(MAKE) --no-print-directory help_spi
target_nanopc-t6:
$(MAKE) CFG=nanopc-t6-rk3588_defconfig BL31=$(RK3588_ATF) ROCKCHIP_TPL=$(RK3588_TPL) BRD=$(@:target_%=%) build
@$(MAKE) --no-print-directory help_spi
target_nanopi-r6c:
$(MAKE) CFG=nanopi-r6c-rk3588s_defconfig BL31=$(RK3588_ATF) ROCKCHIP_TPL=$(RK3588_TPL) BRD=$(@:target_%=%) build
target_orangepi-5:
$(MAKE) CFG=orangepi-5-rk3588s_defconfig BL31=$(RK3588_ATF) ROCKCHIP_TPL=$(RK3568_TPL) BRD=$(@:target_%=%) build
target_orangepi-5-plus:
$(MAKE) CFG=orangepi-5-plus-rk3588_defconfig BL31=$(RK3588_ATF) ROCKCHIP_TPL=$(RK3568_TPL) BRD=$(@:target_%=%) build
target_nanopi-r5c:
$(MAKE) CFG=nanopi-r5c-rk3568_defconfig BL31=$(RK3568_ATF) ROCKCHIP_TPL=$(RK3568_TPL) BRD=$(@:target_%=%) build
target_nanopi-r5s:
$(MAKE) CFG=nanopi-r5s-rk3568_defconfig BL31=$(RK3568_ATF) ROCKCHIP_TPL=$(RK3568_TPL) BRD=$(@:target_%=%) build
target_odroid-m1:
$(MAKE) CFG=odroid-m1-rk3568_defconfig BL31=$(RK3568_ATF) ROCKCHIP_TPL=$(RK3568_TPL) BRD=$(@:target_%=%) build
@$(MAKE) --no-print-directory help_spi
target_radxa-e25:
$(MAKE) CFG=radxa-e25-rk3568_defconfig BL31=$(RK3568_ATF) ROCKCHIP_TPL=$(RK3568_TPL) BRD=$(@:target_%=%) build
patch:
@if ! git -C u-boot branch | grep -q $(UBOOT_BRANCH); then \
git -C u-boot checkout -b $(UBOOT_BRANCH) $(UBOOT_TAG); \
\
patches="$$(find patches -maxdepth 2 -name '*.patch' 2>/dev/null | sort)"; \
test -z "$$patches" || echo "\n$(h1)patching...$(rst)"; \
for patch in $$patches; do \
echo "\n$(grn)$$patch$(rst)"; \
git -C u-boot am "../$$patch"; \
done; \
elif test _$(UBOOT_BRANCH) != _$$(git -C u-boot branch --show-current); then \
git -C u-boot checkout $(UBOOT_BRANCH); \
fi
check_prereqs:
@todo=""; \
for item in screen bc bison flex libssl-dev make python3-dev python3-pyelftools python3-setuptools swig; do \
dpkg -l "$$item" 2>/dev/null | grep -q "ii $$item" || todo="$$todo $$item"; \
done; \
\
if ! test -z "$$todo"; then \
echo "the following packages need to be installed:$(bld)$(yel)$$todo$(rst)"; \
echo " run: $(bld)$(grn)sudo apt update && sudo apt -y install$$todo$(rst)\n"; \
exit 1; \
fi
clean: | $(wildcard u-boot)_clean
@rm -rf outbin
@echo "\nclean complete\n"
u-boot_clean:
@echo "\n$(h1)cleaning...$(rst)"
@rm -f 'u-boot/mkimage-in-simple-bin'*
@rm -f 'u-boot/simple-bin.fit'*
$(MAKE) -C u-boot distclean
@git -C u-boot clean -f
@git -C u-boot checkout master
@-git -C u-boot branch -D $(UBOOT_BRANCH) 2>/dev/null
@git -C u-boot pull --ff-only
help: help_block help_spi
help_block:
@echo "$(cya)"
@echo "copy u-boot to block media (replace sdX)"
@echo " sudo dd bs=4K seek=8 if=idbloader.img of=/dev/sdX conv=notrunc"
@echo " sudo dd bs=4K seek=2048 if=u-boot.itb of=/dev/sdX conv=notrunc,fsync"
@echo "$(rst)"
help_spi:
@echo "$(blu)"
@echo "copy u-boot to spi flash mtd media (apt install mtd-utils)"
@echo " sudo flashcp -Av idbloader.img /dev/mtd0"
@echo " sudo flashcp -Av u-boot.itb /dev/mtd2"
@echo "$(rst)"
.PHONY: all configure build $(TARGETS) patch check_prereqs clean _clean u-boot_clean help help_block help_spi
# colors
rst := [m
bld := [1m
red := [31m
grn := [32m
yel := [33m
blu := [34m
mag := [35m
cya := [36m
h1 := $(blu)==>$(rst) $(bld)