ath79: Ubiquiti Airmax M: add relocate-kernel to invalidate cache
[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 += CMDLINE CONSOLE IMAGE_SIZE BOARDNAME 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 BOARD="$(BOARDNAME)" \
14 LZMA_TEXT_START=0x80a00000 LOADADDR=0x80060000 \
15 $(1) compile loader.$(LOADER_TYPE)
16 mv "$@.$(LOADER_TYPE)" "$@"
17 rm -rf $@.src
18 endef
19
20 define Build/loader-kernel
21 $(call Build/loader-common,LOADER_DATA="$@")
22 endef
23
24 define Build/loader-kernel-cmdline
25 $(call Build/loader-common,LOADER_DATA="$@" KERNEL_CMDLINE="$(CMDLINE)")
26 endef
27
28
29 define Build/loader-okli-compile
30 $(call Build/loader-common,FLASH_OFFS=$(LOADER_FLASH_OFFS) FLASH_MAX=0 KERNEL_CMDLINE="$(CMDLINE)")
31 endef
32
33 define Build/loader-okli
34 dd if=$(KDIR)/loader-$(1).gz bs=7680 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 define Build/copy-file
53 cat "$(1)" > "$@"
54 endef
55
56 define Device/Default
57 ATH_SOC :=
58 BOARDNAME :=
59 DEVICE_PROFILE = $$(BOARDNAME)
60 DEVICE_DTS_DIR := ../dts
61 DEVICE_DTS = $$(ATH_SOC)_$(1)
62 PROFILES = Default Minimal $$(DEVICE_PROFILE)
63 MTDPARTS :=
64 BLOCKSIZE := 64k
65 CONSOLE = ttyS0,115200
66 CMDLINE = $$(if $$(BOARDNAME),board=$$(BOARDNAME)) $$(if $$(MTDPARTS),mtdparts=$$(MTDPARTS)) $$(if $$(CONSOLE),console=$$(CONSOLE))
67 KERNEL := kernel-bin | append-dtb | lzma | uImage lzma
68 KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | uImage lzma
69 COMPILE :=
70 IMAGES := sysupgrade.bin
71 IMAGE/sysupgrade.bin = append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs
72 endef
73
74 ifeq ($(SUBTARGET),generic)
75 include ./tp-link.mk
76 include ./generic.mk
77 include ./generic-ubnt.mk
78 endif
79 $(eval $(call BuildImage))