radxa0: factory: also search in vendor/firmware for the bootloader
[GitHub/LineageOS/G12/android_device_radxa_radxa0.git] / factory.mk
1 #
2 # Copyright (C) 2021 The LineageOS Project
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16
17 FACTORY_PATH := device/radxa/radxa0/factory
18
19 PRODUCT_UPGRADE_OUT := $(PRODUCT_OUT)/upgrade
20 PACKAGE_CONFIG_FILE := $(PRODUCT_UPGRADE_OUT)/image.cfg
21 AML_IMAGE_TOOL := $(HOST_OUT_EXECUTABLES)/aml_image_packer$(HOST_EXECUTABLE_SUFFIX)
22
23 INSTALLED_AML_UPGRADE_PACKAGE_TARGET := $(PRODUCT_OUT)/aml_upgrade_package.img
24
25 define aml-symlink-file
26 $(hide) ln -f $(1) $(PRODUCT_UPGRADE_OUT)/$(strip $(if $(2), $(2), $(notdir $(1))))
27 endef
28
29 NEEDED_IMAGES := \
30 boot.img \
31 recovery.img \
32 dtbo.img \
33 vbmeta.img \
34 super.img
35
36 $(INSTALLED_AML_UPGRADE_PACKAGE_TARGET): $(addprefix $(PRODUCT_OUT)/,$(NEEDED_IMAGES)) $(AML_IMAGE_TOOL)
37 $(hide) mkdir -p $(PRODUCT_UPGRADE_OUT)
38 ifneq ("$(wildcard $(FACTORY_PATH)/u-boot.bin)","")
39 $(hide) $(call aml-symlink-file, $(FACTORY_PATH)/u-boot.bin)
40 else ifneq ("$(wildcard vendor/firmware/radxa0/bootloader.img)","")
41 $(hide) $(call aml-symlink-file, vendor/firmware/radxa0/bootloader.img, u-boot.bin)
42 else
43 $(error "no u-boot.bin found in $(FACTORY_PATH)")
44 endif
45 $(hide) $(call aml-symlink-file, $(PRODUCT_OUT)/logo.img)
46 $(hide) $(call aml-symlink-file, $(FACTORY_PATH)/aml_sdc_burn.ini)
47 $(hide) $(call aml-symlink-file, $(FACTORY_PATH)/image.cfg)
48 $(hide) $(call aml-symlink-file, $(FACTORY_PATH)/platform.conf)
49 $(hide) $(call aml-symlink-file, $(PRODUCT_OUT)/boot.img)
50 $(hide) $(call aml-symlink-file, $(PRODUCT_OUT)/recovery.img)
51 $(hide) $(call aml-symlink-file, $(INSTALLED_2NDBOOTLOADER_TARGET), dtb.img)
52 $(hide) $(call aml-symlink-file, $(PRODUCT_OUT)/dtbo.img)
53 $(hide) $(call aml-symlink-file, $(PRODUCT_OUT)/super.img)
54 $(hide) $(call aml-symlink-file, $(PRODUCT_OUT)/vbmeta.img)
55 $(hide) $(AML_IMAGE_TOOL) -r $(PACKAGE_CONFIG_FILE) $(PRODUCT_UPGRADE_OUT)/ $@
56 $(hide) rm -rf $(PRODUCT_UPGRADE_OUT)
57 $(hide) echo " $@ created"
58
59 .PHONY: aml_upgrade
60 aml_upgrade: $(INSTALLED_AML_UPGRADE_PACKAGE_TARGET)