34dd81961032203dfd4bbca5ba14a3082b80fece
[openwrt/openwrt.git] / target / linux / ath79 / image / Makefile
1 include $(TOPDIR)/rules.mk
2 include $(INCLUDE_DIR)/image.mk
3
4 KERNEL_LOADADDR = 0x80060000
5
6 DEVICE_VARS += IMAGE_SIZE LOADER_FLASH_OFFS LOADER_TYPE ATH_SOC
7
8 define Build/loader-common
9 rm -rf $@.src
10 $(MAKE) -C lzma-loader \
11 PKG_BUILD_DIR="$@.src" \
12 TARGET_DIR="$(dir $@)" LOADER_NAME="$(notdir $@)" \
13 LZMA_TEXT_START=0x80a00000 LOADADDR=0x80060000 \
14 $(1) compile loader.$(LOADER_TYPE)
15 mv "$@.$(LOADER_TYPE)" "$@"
16 rm -rf $@.src
17 endef
18
19 define Build/loader-kernel
20 $(call Build/loader-common,LOADER_DATA="$@")
21 endef
22
23 define Build/loader-kernel-cmdline
24 $(call Build/loader-common,LOADER_DATA="$@")
25 endef
26
27
28 define Build/loader-okli-compile
29 $(call Build/loader-common,FLASH_OFFS=$(LOADER_FLASH_OFFS) FLASH_MAX=0)
30 endef
31
32 # Arguments: <output name> <kernel offset>
33 define Build/loader-okli
34 dd if=$(KDIR)/loader-$(word 1,$(1)).$(LOADER_TYPE) bs=$(word 2,$(1)) conv=sync of="$@.new"
35 cat "$@" >> "$@.new"
36 mv "$@.new" "$@"
37 endef
38
39 define Build/relocate-kernel
40 rm -rf $@.relocate
41 $(CP) ../../generic/image/relocate $@.relocate
42 $(MAKE) -j1 -C $@.relocate KERNEL_ADDR=$(KERNEL_LOADADDR) CROSS_COMPILE=$(TARGET_CROSS)
43 ( \
44 dd if=$@.relocate/loader.bin bs=32 conv=sync && \
45 perl -e '@s = stat("$@"); print pack("N", @s[7])' && \
46 cat "$@" \
47 ) > "$@.new"
48 mv "$@.new" "$@"
49 rm -rf $@.relocate
50 endef
51
52
53 define Device/Default
54 ATH_SOC :=
55 DEVICE_DTS_DIR := ../dts
56 DEVICE_DTS = $$(ATH_SOC)_$(1)
57 PROFILES = Default
58 MTDPARTS :=
59 BLOCKSIZE := 64k
60 KERNEL := kernel-bin | append-dtb | lzma | uImage lzma
61 KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | uImage lzma
62 COMPILE :=
63 SUPPORTED_DEVICES := $(subst _,$(comma),$(1))
64 IMAGES := sysupgrade.bin
65 IMAGE/sysupgrade.bin = append-kernel | pad-to $$$$(BLOCKSIZE) | \
66 append-rootfs | pad-rootfs | append-metadata | check-size $$$$(IMAGE_SIZE)
67 endef
68
69 ifeq ($(SUBTARGET),generic)
70 include ./generic.mk
71 include ./generic-tp-link.mk
72 include ./generic-ubnt.mk
73 endif
74 ifeq ($(SUBTARGET),tiny)
75 include ./tiny-tp-link.mk
76 endif
77 $(eval $(call BuildImage))