ipq40xx: Add ipq-aux-loader
[openwrt/staging/lynxis.git] / target / linux / ipq40xx / image / ipq-aux-loader / src / openwrt / Makefile
1 #
2 # Auxiliary kernel loader for Qualcom IPQ-4XXX/806X based boards
3 #
4 # Copyright (C) 2019 Sergey Sergeev <adron@mstnt.com>
5 #
6 # Some parts of this code was based on the OpenWrt specific lzma-loader
7 # for the Atheros AR7XXX/AR9XXX based boards:
8 # Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
9 #
10 # This program is free software; you can redistribute it and/or modify it
11 # under the terms of the GNU General Public License version 2 as published
12 # by the Free Software Foundation.
13 #
14
15 include $(TOPDIR)/rules.mk
16
17 LOADER_NAME := $(basename $(notdir $(LOADER)))
18
19 ifeq ($(TARGET_DIR),)
20 TARGET_DIR := $(KDIR)
21 endif
22
23 LOADER_ELF := $(TARGET_DIR)/$(LOADER_NAME).elf
24 LOADER_UBI := $(TARGET_DIR)/$(LOADER_NAME).ubi
25
26 PKG_NAME := ipq-aux-loader
27 PKG_BUILD_DIR := $(KDIR)/$(PKG_NAME)
28
29 .PHONY : loader-compile loader.elf
30
31 $(PKG_BUILD_DIR)/.prepared:
32 mkdir $(PKG_BUILD_DIR)
33 $(CP) ./src/* $(PKG_BUILD_DIR)
34 touch $@
35
36 CPU_TYPE := UNKNOWN
37
38 ifeq ($(PLATFORM),mikrotik-ipq4xxx)
39 CPU_TYPE := IPQ4XXX
40 TEXT_BASE := 0x84800000
41 TEXT_BASE2 := 0x01100000
42 FAT_SIZE_START := 5000000
43 TEXT_BASE2_FAT := 0x00000000
44 endif
45
46 loader-compile: $(PKG_BUILD_DIR)/.prepared
47 $(MAKE) -C $(PKG_BUILD_DIR) CROSS_COMPILE="$(TARGET_CROSS)" \
48 TEXT_BASE=$(TEXT_BASE) TEXT_BASE2=$(TEXT_BASE2) \
49 FAT_SIZE_START=$(FAT_SIZE_START) \
50 TEXT_BASE2_FAT=$(TEXT_BASE2_FAT) \
51 CPU_TYPE=$(CPU_TYPE) KERNEL_IMAGE=$(LOADER_DATA) \
52 BLOCKSIZE=$(BLOCKSIZE) PAGESIZE=$(PAGESIZE) \
53 clean $(LOADER_TYPE)
54
55 loader.elf: $(PKG_BUILD_DIR)/bin/loader.elf
56 $(CP) $< $(LOADER_ELF)
57
58 loader.ubi: $(PKG_BUILD_DIR)/bin/loader.ubi
59 $(CP) $< $(LOADER_UBI)
60
61 download:
62 prepare: $(PKG_BUILD_DIR)/.prepared
63 compile: loader-compile
64
65 install:
66
67 clean:
68 rm -rf $(PKG_BUILD_DIR)