forked from ubitux/archlinuxarm-nanopi-neo2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
103 lines (85 loc) · 3.05 KB
/
Makefile
File metadata and controls
103 lines (85 loc) · 3.05 KB
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
# User configuration
SERIAL_DEVICE = /dev/ttyUSB0
WGET = wget
MINITERM = miniterm.py
#CROSS_COMPILE ?= arm-unknown-eabi-
CROSS_COMPILE ?= arm-linux-gnueabi-
PYTHON ?= python2
BLOCK_DEVICE ?= /dev/null
FIND ?= find
UBOOT_SCRIPT = boot.scr
UBOOT_BIN = u-boot-sunxi-with-spl.bin
ARCH_TARBALL = ArchLinuxARM-armv7-latest.tar.gz
DTB = sun8i-h3-usbhost2.dtb sun8i-h3-usbhost3.dtb
DTS = sun8i-h3-usbhost2.dts sun8i-h3-usbhost3.dts
UBOOT_VERSION = 2018.01
UBOOT_TARBALL = u-boot-v$(UBOOT_VERSION).tar.gz
UBOOT_DIR = u-boot-$(UBOOT_VERSION)
MOUNT_POINT = mnt
ifeq ($(EXPANSION), true)
all: $(ARCH_TARBALL) $(UBOOT_BIN) $(UBOOT_SCRIPT) $(DTB)
else
all: $(ARCH_TARBALL) $(UBOOT_BIN) $(UBOOT_SCRIPT)
endif
uboot: $(UBOOT_BIN) $(UBOOT_SCRIPT) $(DTB)
$(UBOOT_TARBALL):
$(WGET) -nc https://github.com/u-boot/u-boot/archive/v$(UBOOT_VERSION).tar.gz -O $@
$(UBOOT_DIR): $(UBOOT_TARBALL)
tar xf $<
$(ARCH_TARBALL):
$(WGET) http://archlinuxarm.org/os/$@
$(UBOOT_BIN): $(UBOOT_DIR)
ifeq ($(EXPANSION), true)
cd $< && grep -q -F 'CONFIG_OF_LIBFDT_OVERLAY' configs/orangepi_zero_defconfig || echo 'CONFIG_OF_LIBFDT_OVERLAY=y' >> configs/orangepi_zero_defconfig
endif
cd $< && $(MAKE) orangepi_zero_defconfig && $(MAKE) CROSS_COMPILE=$(CROSS_COMPILE) PYTHON=$(PYTHON)
cp $</$@ .
# Note: non-deterministic output as the image header contains a timestamp and a
# checksum including this timestamp (2x32-bit at offset 4)
$(UBOOT_SCRIPT): boot.txt
mkimage -A arm -O linux -T script -C none -n "U-Boot boot script" -d $< $@
boot.txt:
$(WGET) https://raw.githubusercontent.com/archlinuxarm/PKGBUILDs/master/alarm/uboot-sunxi/$@
ifeq ($(EXPANSION), true)
patch boot.txt boot.patch
endif
$(DTS):
$(WGET) -nc https://raw.githubusercontent.com/armbian/sunxi-DT-overlays/master/sun8i-h3/$@
$(DTB): $(DTS)
dtc -I dts -O dtb -o $@ $<
mkscr:
$(WGET) https://raw.githubusercontent.com/archlinuxarm/PKGBUILDs/master/alarm/uboot-sunxi/mkscr
define part1
/dev/$(shell basename $(shell $(FIND) /sys/block/$(shell basename $(1))/ -maxdepth 2 -name "partition" -printf "%h"))
endef
install: $(ALL) fdisk.cmd mkscr
ifeq ($(BLOCK_DEVICE),/dev/null)
@echo You must set BLOCK_DEVICE option
else
sudo dd if=/dev/zero of=$(BLOCK_DEVICE) bs=1M count=8
sudo fdisk $(BLOCK_DEVICE) < fdisk.cmd
sync
partprobe $(BLOCK_DEVICE)
sleep 10 #Partiton may not appear immediately, part1 call may fail
sudo mkfs.ext4 $(call part1,$(BLOCK_DEVICE))
mkdir -p $(MOUNT_POINT)
sudo umount $(MOUNT_POINT) || true
sudo mount $(call part1,$(BLOCK_DEVICE)) $(MOUNT_POINT)
sudo tar --warning=no-unknown-keyword -xpf $(ARCH_TARBALL) -C $(MOUNT_POINT)
sudo cp mkscr boot.txt $(UBOOT_SCRIPT) $(MOUNT_POINT)/boot
ifeq ($(EXPANSION), true)
sudo mkdir $(MOUNT_POINT)/boot/dtbs/overlay
sudo cp $(DTB) $(MOUNT_POINT)/boot/dtbs/overlay
endif
sync
sudo umount $(MOUNT_POINT) || true
rmdir $(MOUNT_POINT) || true
sudo dd if=$(UBOOT_BIN) of=$(BLOCK_DEVICE) bs=1024 seek=8
endif
serial:
$(MINITERM) --raw --eol=lf $(SERIAL_DEVICE) 115200
clean:
$(RM) $(ALL)
$(RM) $(UBOOT_TARBALL) $(DTS) $(DTB) mkscr
$(RM) -r $(UBOOT_DIR)
.PHONY: all serial clean install