forked from ayufan-rock64/linux-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.uboot.mk
88 lines (76 loc) · 3.2 KB
/
Makefile.uboot.mk
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
UBOOT_OUTPUT_DIR ?= $(CURDIR)/tmp/u-boot-$(BOARD_TARGET)
UBOOT_LOADER ?= out/u-boot-$(BOARD_TARGET)/idbloader.img
UBOOT_MAKE ?= make -C $(UBOOT_DIR) KBUILD_OUTPUT=$(UBOOT_OUTPUT_DIR) BL31=$(realpath $(BL31)) \
CROSS_COMPILE="ccache aarch64-linux-gnu-"
UBOOT_PACKAGE ?= u-boot-$(BOARD_TARGET)-$(RELEASE_NAME)_all.deb
tmp/u-boot-$(BOARD_TARGET)/.config: $(UBOOT_DIR)/configs/$(UBOOT_DEFCONFIG)
$(UBOOT_MAKE) $(UBOOT_DEFCONFIG)
$(UBOOT_LOADER): tmp/u-boot-$(BOARD_TARGET)/.config $(BL31)
$(UBOOT_MAKE) -j $$(nproc)
$(UBOOT_MAKE) -j $$(nproc) u-boot.itb
mkdir -p out/u-boot-$(BOARD_TARGET)
ifneq (,$(USE_UBOOT_SPL))
$(UBOOT_OUTPUT_DIR)/tools/mkimage -n $(BOARD_CHIP) -T rksd -d $(UBOOT_OUTPUT_DIR)/spl/u-boot-spl.bin [email protected]
else ifneq (,$(USE_UBOOT_TPL))
$(UBOOT_OUTPUT_DIR)/tools/mkimage -n $(BOARD_CHIP) -T rksd -d $(UBOOT_OUTPUT_DIR)/tpl/u-boot-tpl.bin [email protected]
cat $(UBOOT_OUTPUT_DIR)/spl/u-boot-spl.bin >> [email protected]
else ifeq (rock64,$(BOARD_TARGET))
$(UBOOT_OUTPUT_DIR)/tools/mkimage -n $(BOARD_CHIP) -T rksd -d $(DDR) [email protected]
cat $(UBOOT_OUTPUT_DIR)/spl/u-boot-spl.bin >> [email protected]
else ifeq (rockpro64,$(BOARD_TARGET))
$(UBOOT_OUTPUT_DIR)/tools/mkimage -n $(BOARD_CHIP) -T rksd -d $(DDR) [email protected]
cat $(UBOOT_OUTPUT_DIR)/spl/u-boot-spl.bin >> [email protected]
else
@echo "Invalid $(BOARD_TARGET)"
@exit 1
endif
dd if=$(UBOOT_OUTPUT_DIR)/u-boot.itb [email protected] seek=$$((0x200-64)) conv=notrunc
mv [email protected] $@
.PHONY: u-boot-menuconfig # edit u-boot config and save as defconfig
u-boot-menuconfig:
$(UBOOT_MAKE) ARCH=arm64 $(UBOOT_DEFCONFIG)
$(UBOOT_MAKE) ARCH=arm64 menuconfig
$(UBOOT_MAKE) ARCH=arm64 savedefconfig
mv $(UBOOT_OUTPUT_DIR)/defconfig $(UBOOT_DIR)/configs/$(UBOOT_DEFCONFIG)
.PHONY: u-boot-build # compile u-boot
u-boot-build:
rm -f $(UBOOT_LOADER)
make $(UBOOT_LOADER)
.PHONY: u-boot-clear
u-boot-clear:
rm -rf $(UBOOT_LOADER)/..
out/u-boot/%/boot.scr: blobs/%.cmd
mkdir -p $$(dirname $@)
mkimage -C none -A arm -T script -d $< $@
out/u-boot/%/boot.img: out/u-boot/%/boot.scr
dd if=/dev/zero of=$@ bs=1M count=2
mkfs.vfat -n "u-boot-script" $@
mcopy -sm -i $@ $< ::
u-boot-%-$(BOARD_TARGET).img: out/u-boot/%/boot.img $(UBOOT_LOADER)
build/mk-image.sh -c $(BOARD_CHIP) -d out/u-boot-$(BOARD_TARGET) -t system -s 128 -b $< -o "[email protected]"
mv "[email protected]" $@
$(UBOOT_PACKAGE): u-boot-package $(UBOOT_LOADER)
fpm -s dir -t deb -n u-boot-$(BOARD_TARGET) -v $(RELEASE_NAME) \
-p $@ \
--deb-priority optional --category admin \
--force \
--depends debsums \
--depends mtd-utils \
--deb-compression bzip2 \
--deb-field "Multi-Arch: foreign" \
--after-install u-boot-package/scripts/postinst.deb \
--before-remove u-boot-package/scripts/prerm.deb \
--url https://gitlab.com/ayufan-rock64/linux-build \
--description "Rock64 U-boot package" \
-m "Kamil Trzciński <[email protected]>" \
--license "MIT" \
--vendor "Kamil Trzciński" \
-a all \
u-boot-package/root/=/ \
$(UBOOT_LOADER)=/usr/lib/u-boot-$(BOARD_TARGET)/idbloader.img
.PHONY: u-boot-package
u-boot-package: $(UBOOT_PACKAGE)
.PHONY: u-boot-flash-spi-$(BOARD_TARGET)
u-boot-flash-spi-$(BOARD_TARGET): u-boot-flash-spi-$(BOARD_TARGET).img.xz
.PHONY: u-boot-erase-spi-$(BOARD_TARGET)
u-boot-erase-spi-$(BOARD_TARGET): u-boot-erase-spi-$(BOARD_TARGET).img.xz