022661623a993eaa8a1913192c80ea5c48777ca9
[openwrt/staging/wigyori.git] / target / linux / rockchip / image / Makefile
1 #
2 # This is free software, licensed under the GNU General Public License v2.
3 # See /LICENSE for more information.
4 #
5 include $(TOPDIR)/rules.mk
6 include $(INCLUDE_DIR)/image.mk
7
8 DEVICE_VARS += UBOOT_DEVICE_NAME
9
10 define Build/Compile
11 $(CP) $(LINUX_DIR)/COPYING $(KDIR)/COPYING.linux
12 endef
13
14 ### Image scripts ###
15 define Build/boot-common
16 # This creates a new folder copies the dtb (as rockchip.dtb)
17 # and the kernel image (as kernel.img)
18 rm -fR $@.boot
19 mkdir -p $@.boot
20
21 $(CP) $(DTS_DIR)/$(DEVICE_DTS).dtb $@.boot/rockchip.dtb
22 $(CP) $(IMAGE_KERNEL) $@.boot/kernel.img
23 endef
24
25 define Build/boot-script
26 # Make an U-boot image and copy it to the boot partition
27 mkimage -A arm -O linux -T script -C none -a 0 -e 0 -d $(if $(1),$(1),mmc).bootscript $@.boot/boot.scr
28 endef
29
30 define Build/pine64-img
31 # Creates the final SD/eMMC images,
32 # combining boot partition, root partition as well as the u-boot bootloader
33
34 # Generate a new partition table in $@ with 32 MiB of
35 # alignment padding for the idbloader and u-boot to fit:
36 # http://opensource.rock-chips.com/wiki_Boot_option#Boot_flow
37 #
38 # U-Boot SPL expects the U-Boot ITB to be located at sector 0x4000 (8 MiB) on the MMC storage
39 $(SCRIPT_DIR)/gen_image_generic.sh \
40 $@ \
41 $(CONFIG_TARGET_KERNEL_PARTSIZE) $@.boot \
42 $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS) \
43 32768
44
45 # Copy the idbloader and the u-boot image to the image at sector 0x40 and 0x4000
46 dd if="$(STAGING_DIR_IMAGE)"/$(UBOOT_DEVICE_NAME)-idbloader.img of="$@" seek=64 conv=notrunc
47 dd if="$(STAGING_DIR_IMAGE)"/$(UBOOT_DEVICE_NAME)-u-boot.itb of="$@" seek=16384 conv=notrunc
48 endef
49
50 ### Devices ###
51 define Device/Default
52 PROFILES := Default
53 KERNEL := kernel-bin
54 IMAGES := sysupgrade.img.gz
55 DEVICE_DTS = rockchip/$$(SOC)-$(lastword $(subst _, ,$(1)))
56 endef
57
58 include $(SUBTARGET).mk
59
60 $(eval $(call BuildImage))