This repository has been archived by the owner on Nov 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
68 lines (54 loc) · 2.34 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
#
# Makefile - build a kernel+filesystem image for stand-alone Linux booting
#
# Copyright (C) 2012 ARM Limited. All rights reserved.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE.txt file.
# VE
PHYS_OFFSET := 0x80000000
UART_BASE := 0x1c090000
SYSREGS_BASE := 0x1c010000
GIC_DIST_BASE := 0x2c001000
GIC_CPU_BASE := 0x2c002000
CNTFRQ := 0x01800000 # 24Mhz
#INITRD_FLAGS := -DUSE_INITRD
CPPFLAGS += $(INITRD_FLAGS)
BOOTLOADER := boot.S
MBOX_OFFSET := 0xfff8
KERNEL := Image
KERNEL_OFFSET := 0x80000
LD_SCRIPT := model.lds.S
IMAGE := linux-system.axf
FILESYSTEM := filesystem.cpio.gz
FS_OFFSET := 0x10000000
FILESYSTEM_START:= $(shell echo $$(($(PHYS_OFFSET) + $(FS_OFFSET))))
FILESYSTEM_SIZE := $(shell stat -Lc %s $(FILESYSTEM) 2>/dev/null || echo 0)
FILESYSTEM_END := $(shell echo $$(($(FILESYSTEM_START) + $(FILESYSTEM_SIZE))))
FDT_SRC := foundation-v8.dts
FDT_INCL_REGEX := \(/include/[[:space:]]*"\)\([^"]\+\)\(".*\)
FDT_DEPS := $(FDT_SRC) $(addprefix $(dir $(FDT_SRC)), $(shell sed -ne 'sq$(strip $(FDT_INCL_REGEX)q\2q p' < $(FDT_SRC))))
FDT_OFFSET := 0x08000000
BOOTARGS := "console=ttyAMA0 mem=2048M devtmpfs.mount=1 earlyprintk rw init=/bin/sh root=/dev/vda"
CHOSEN_NODE := chosen { \
bootargs = \"$(BOOTARGS)\"; \
linux,initrd-start = <$(FILESYSTEM_START)>; \
linux,initrd-end = <$(FILESYSTEM_END)>; \
};
CROSS_COMPILE ?= aarch64-linux-gnu-
CC := $(CROSS_COMPILE)gcc
LD := $(CROSS_COMPILE)ld
DTC := $(if $(wildcard ./dtc), ./dtc, $(shell which dtc))
all: $(IMAGE)
clean:
rm -f $(IMAGE) boot.o model.lds fdt.dtb
$(IMAGE): boot.o model.lds fdt.dtb $(KERNEL) $(FILESYSTEM)
$(LD) -o $@ --script=model.lds
boot.o: $(BOOTLOADER) Makefile
$(CC) $(CPPFLAGS) -DCNTFRQ=$(CNTFRQ) -DUART_BASE=$(UART_BASE) -DSYSREGS_BASE=$(SYSREGS_BASE) -DGIC_DIST_BASE=$(GIC_DIST_BASE) -DGIC_CPU_BASE=$(GIC_CPU_BASE) -c -o $@ $(BOOTLOADER)
model.lds: $(LD_SCRIPT) Makefile
$(CC) $(CPPFLAGS) -DPHYS_OFFSET=$(PHYS_OFFSET) -DMBOX_OFFSET=$(MBOX_OFFSET) -DKERNEL_OFFSET=$(KERNEL_OFFSET) -DFDT_OFFSET=$(FDT_OFFSET) -DFS_OFFSET=$(FS_OFFSET) -DKERNEL=$(KERNEL) -DFILESYSTEM=$(FILESYSTEM) -E -P -C -o $@ $<
fdt.dtb: $(FDT_DEPS) Makefile
( echo "/include/ \"$(FDT_SRC)\"" ; echo "/ { $(CHOSEN_NODE) };" ) | $(DTC) -O dtb -o $@ -
# The filesystem archive might not exist if INITRD is not being used
.PHONY: all clean $(FILESYSTEM)