archs38: set device vendor and model variables
[openwrt/openwrt.git] / target / linux / archs38 / image / Makefile
1 # SPDX-License-Identifier: GPL-2.0-only
2 #
3 # Copyright (C) 2016 OpenWrt.org
4
5 include $(TOPDIR)/rules.mk
6 include $(INCLUDE_DIR)/image.mk
7
8 # On ARC initramfs is put before entry point and so entry point moves
9 # in memory from build to built. Thus we need to extract EP from vmlinux
10 # every time before generation of uImage.
11 kernel_ep = `$(KERNEL_CROSS)readelf -h $(1) | grep "Entry point address" | grep -o 0x.*`
12
13 define Build/patch-dtb
14 $(STAGING_DIR_HOST)/bin/patch-dtb $@ $(DTS_DIR)/$(DEVICE_DTS).dtb
15 endef
16
17 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
18 # Root FS built-in
19 define Device/vmlinux
20 KERNEL_SUFFIX := .elf
21 KERNEL := kernel-bin | patch-dtb
22 KERNEL_INITRAMFS_NAME = vmlinux-initramfs.elf
23 endef
24
25 define Device/nsim_hs
26 $(call Device/vmlinux)
27 DEVICE_VENDOR := Synopsys
28 DEVICE_MODEL := nSIM HS
29 DEVICE_PROFILE := nsim_hs
30 DEVICE_DTS := nsim_hs_idu
31 endef
32 TARGET_DEVICES += nsim_hs
33 endif
34
35 # Root FS on SD-card
36 KERNEL_LOADADDR := 0x90000000
37 DEVICE_DTS_LIST:= axs103_idu nsim_hs_idu hsdk
38 FAT32_BLOCK_SIZE=1024
39 FAT32_BLOCKS=$(shell echo $$(($(CONFIG_AXS10X_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
40
41 define Image/Prepare
42 # Build .dtb for all boards we may run on
43 $(foreach dts,$(DEVICE_DTS_LIST),
44 $(call Image/BuildDTB,$(DTS_DIR)/$(dts).dts,$(DTS_DIR)/$(dts).dtb)
45 )
46 endef
47
48 define Image/Build/SDCard
49 rm -f $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img
50 mkfs.fat $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img -C $(FAT32_BLOCKS)
51 mkimage -C none -A arc -T script -d uEnv.txt $(BIN_DIR)/uEnv.scr
52 mkenvimage -s 0x4000 -o $(BIN_DIR)/uboot.env ./uboot.env.txt
53 mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img $(BIN_DIR)/uEnv.scr ::boot.scr
54 mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img $(DTS_DIR)/*.dtb ::
55 mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img $(BIN_DIR)/$(IMG_PREFIX)-uImage ::uImage
56 mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img $(BIN_DIR)/uboot.env ::uboot.env
57
58 ./gen_axs10x_sdcard_img.sh \
59 $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-sdcard-vfat-$(1).img \
60 $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img \
61 $(KDIR)/root.$(1) \
62 $(CONFIG_AXS10X_SD_BOOT_PARTSIZE) \
63 $(CONFIG_TARGET_ROOTFS_PARTSIZE)
64
65 ifneq ($(CONFIG_TARGET_IMAGES_GZIP),)
66 gzip -f9n $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-sdcard-vfat-$(1).img
67 endif
68 endef
69
70 define Image/BuildKernel
71 # Build unified uImage
72 $(call Image/BuildKernel/MkuImage, \
73 none, $(KERNEL_LOADADDR),$(call kernel_ep,$(KDIR)/vmlinux.elf) , \
74 $(KDIR)/vmlinux, \
75 $(BIN_DIR)/$(IMG_PREFIX)-uImage \
76 )
77 endef
78
79 define Image/Build
80 $(call Image/Build/$(1),$(1))
81 $(call Image/Build/SDCard,$(1))
82 dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
83 $(call Image/Gzip,$(BIN_DIR)/$(IMG_PREFIX)-root.$(1))
84 endef
85
86 $(eval $(call BuildImage))