03bd8ee8ebe9b25b0e9c4d324bdf345cf62280fc
[openwrt/openwrt.git] / target / linux / archs38 / image / Makefile
1 #
2 # Copyright (C) 2016 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/image.mk
9
10 # On ARC initramfs is put before entry point and so entry point moves
11 # in memory from build to built. Thus we need to extract EP from vmlinux
12 # every time before generation of uImage.
13 define Build/calculate-ep
14 $(eval KERNEL_ENTRY=$(shell $(KERNEL_CROSS)readelf -h $(LINUX_DIR)/vmlinux | grep "Entry point address" | grep -o 0x.*))
15 endef
16
17 define Build/patch-dtb
18 $(call Image/BuildDTB,../dts/$(DEVICE_DTS).dts,$@.dtb)
19 $(STAGING_DIR_HOST)/bin/patch-dtb $@ $@.dtb
20 endef
21
22 # Shared device definition: applies to every defined device
23 define Device/Default
24 PROFILES = Default $$(DEVICE_PROFILE)
25 KERNEL_DEPENDS = $$(wildcard ../dts/$$(DEVICE_DTS).dts)
26 DEVICE_PROFILE :=
27 DEVICE_DTS :=
28 endef
29 DEVICE_VARS += DEVICE_PROFILE DEVICE_DTS
30
31 define Device/vmlinux
32 KERNEL_SUFFIX := .elf
33 KERNEL_INITRAMFS := kernel-bin | patch-dtb
34 KERNEL_INITRAMFS_NAME = vmlinux-initramfs.elf
35 endef
36
37 define Device/uImage
38 KERNEL_SUFFIX := .bin
39 KERNEL_INITRAMFS := kernel-bin | patch-dtb | calculate-ep | uImage none
40 KERNEL_LOADADDR := 0x80000000
41 endef
42
43 define add_archs38_uImage
44 define Device/$(1)-uImage
45 $(call Device/uImage)
46 DEVICE_PROFILE := $(1)
47 DEVICE_DTS := $(1)
48 endef
49 TARGET_DEVICES += $(1)-uImage
50 endef
51
52 define add_archs38_vmlinux
53 define Device/$(1)-vmlinux
54 $(call Device/vmlinux)
55 DEVICE_PROFILE := $(1)
56 DEVICE_DTS := $(1)
57 endef
58 TARGET_DEVICES += $(1)-vmlinux
59 endef
60
61 # DesignWare AXS103
62 $(eval $(call add_archs38_vmlinux,axs103_idu))
63 $(eval $(call add_archs38_uImage,axs103_idu))
64
65 # nSIM with ARCHS38
66 $(eval $(call add_archs38_vmlinux,nsim_hs_idu))
67 $(eval $(call add_archs38_uImage,nsim_hs_idu))
68
69 $(eval $(call BuildImage))