sifiveu: add new target for SiFive U-based boards
[openwrt/staging/pepe2k.git] / target / linux / sifiveu / image / Makefile
1 # SPDX-License-Identifier: GPL-2.0-only
2 #
3 # Copyright (C) 2022 Toco Technologies <info@toco.ae>
4 #
5 include $(TOPDIR)/rules.mk
6 include $(INCLUDE_DIR)/image.mk
7
8 FAT32_BLOCK_SIZE=1024
9 FAT32_BLOCKS=$(shell echo $$(($(CONFIG_SIFIVEU_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
10
11 KERNEL_LOADADDR:=0x80200000
12
13 define Build/riscv-sdcard
14 rm -f $@.boot #$(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img
15 mkfs.fat $@.boot -C $(FAT32_BLOCKS)
16
17 mcopy -i $@.boot $(STAGING_DIR_IMAGE)/$(DEVICE_NAME)-boot.scr ::boot.scr
18 mcopy -i $@.boot $(DTS_DIR)/$(DEVICE_DTS).dtb ::dtb
19 mcopy -i $@.boot $(IMAGE_KERNEL) ::Image
20
21 ./gen_sifiveu_sdcard_img.sh \
22 $@ \
23 $@.boot \
24 $(IMAGE_ROOTFS) \
25 $(CONFIG_SIFIVEU_SD_BOOT_PARTSIZE) \
26 $(CONFIG_TARGET_ROOTFS_PARTSIZE) \
27 $(STAGING_DIR_IMAGE)/$(DEVICE_NAME)-u-boot.itb \
28 $(STAGING_DIR_IMAGE)/$(DEVICE_NAME)-u-boot.itb-spl
29 endef
30
31 define Device/Default
32 PROFILES := Default
33 KERNEL_NAME := Image
34 KERNEL := kernel-bin | libdeflate-gzip
35 IMAGES := sdcard.img.gz
36 IMAGE/sdcard.img.gz := riscv-sdcard | append-metadata | gzip
37 endef
38
39 define Device/sifive_unleashed
40 DEVICE_VENDOR := SiFive
41 DEVICE_MODEL := Unleashed (FU540)
42 DEVICE_DTS := sifive/hifive-unleashed-a00
43 UBOOT := sifive_unleashed
44 endef
45 TARGET_DEVICES += sifive_unleashed
46
47 define Device/sifive_unmatched
48 DEVICE_VENDOR := SiFive
49 DEVICE_MODEL := Unmatched (FU740)
50 DEVICE_DTS := sifive/hifive-unmatched-a00
51 DEVICE_PACKAGES += kmod-eeprom-at24 kmod-hwmon-lm90
52 UBOOT := sifive_unmatched
53 endef
54 TARGET_DEVICES += sifive_unmatched
55
56 $(eval $(call BuildImage))