2013-09-24 13:17:38 +00:00
|
|
|
#
|
2010-04-12 23:15:56 +00:00
|
|
|
# Copyright (C) 2006-2010 OpenWrt.org
|
2006-06-27 00:35:46 +00:00
|
|
|
#
|
|
|
|
# This is free software, licensed under the GNU General Public License v2.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
2006-06-21 03:13:25 +00:00
|
|
|
include $(TOPDIR)/rules.mk
|
2006-06-21 02:32:39 +00:00
|
|
|
include $(INCLUDE_DIR)/image.mk
|
2006-06-15 21:43:59 +00:00
|
|
|
|
2013-09-24 13:17:38 +00:00
|
|
|
LOADADDR = 0x81000000 # RAM start + 16M
|
2006-06-15 21:43:59 +00:00
|
|
|
KERNEL_ENTRY = 0x80101000
|
|
|
|
RAMSIZE = 0x00100000 # 1MB
|
|
|
|
IMAGE_COPY = 1
|
|
|
|
|
|
|
|
LOADER_MAKEOPTS= \
|
2017-01-05 16:22:16 +00:00
|
|
|
CROSS_COMPILE="$(TARGET_CROSS)" \
|
|
|
|
PATH="$(TARGET_PATH)" \
|
|
|
|
CC="$(TARGET_CC)" \
|
2006-06-15 21:43:59 +00:00
|
|
|
KDIR=$(KDIR) \
|
|
|
|
LOADADDR=$(LOADADDR) \
|
|
|
|
KERNEL_ENTRY=$(KERNEL_ENTRY) \
|
|
|
|
RAMSIZE=$(RAMSIZE) \
|
|
|
|
IMAGE_COPY=$(IMAGE_COPY)
|
|
|
|
|
2017-01-05 16:22:16 +00:00
|
|
|
|
|
|
|
LOADER_DIR = $(GENERIC_PLATFORM_DIR)/image/lzma-loader
|
|
|
|
|
|
|
|
define Build/lzma-loader-elf
|
|
|
|
rm -rf $@.loader
|
|
|
|
mkdir -p $@.loader
|
|
|
|
$(CP) $(LOADER_DIR)/src/* $@.loader/
|
|
|
|
$(CP) $@ $@.loader/vmlinux.lzma
|
|
|
|
$(MAKE) -C $@.loader $(LOADER_MAKEOPTS)
|
|
|
|
cp $@.loader/lzma.elf $@
|
|
|
|
rm -rf $@.loader
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Device/nand
|
2019-10-15 20:06:10 +00:00
|
|
|
DEVICE_VENDOR := MikroTik
|
|
|
|
DEVICE_MODEL := RouterBOARD 532
|
2017-01-05 16:22:16 +00:00
|
|
|
CMDLINE := ubi.mtd=1 ubi.block=0,rootfs root=/dev/ubiblock0_1
|
|
|
|
BOARD_NAME := rb532
|
|
|
|
SUPPORTED_DEVICES := rb532
|
|
|
|
KERNEL_INITRAMFS := append-kernel | patch-cmdline | lzma | lzma-loader-elf
|
|
|
|
KERNEL := $$(KERNEL_INITRAMFS) | kernel2minor -s 2048 -i 0 -c
|
|
|
|
IMAGES := sysupgrade.bin
|
|
|
|
FILESYSTEMS := squashfs
|
|
|
|
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
|
|
|
|
endef
|
|
|
|
|
|
|
|
TARGET_DEVICES := nand
|
|
|
|
|
2006-06-15 21:43:59 +00:00
|
|
|
define Build/Clean
|
2006-12-18 18:30:29 +00:00
|
|
|
$(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean
|
2006-06-15 21:43:59 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Image/Prepare
|
2007-08-07 00:04:25 +00:00
|
|
|
cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
|
2007-01-10 21:52:28 +00:00
|
|
|
$(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean compile
|
2013-09-26 19:16:19 +00:00
|
|
|
ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
|
|
|
|
$(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR)/vmlinux-initramfs '$(strip $(call Image/cmdline/yaffs2)) '
|
2016-12-24 04:35:57 +00:00
|
|
|
cat $(KDIR)/vmlinux-initramfs | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
|
2013-09-26 19:16:19 +00:00
|
|
|
$(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean compile
|
|
|
|
$(CP) $(KDIR)/loader.elf $(KDIR)/loader-initramfs.elf
|
|
|
|
endif
|
2006-06-15 21:43:59 +00:00
|
|
|
endef
|
|
|
|
|
2011-05-04 08:47:00 +00:00
|
|
|
VMLINUX:=$(BIN_DIR)/$(IMG_PREFIX)-vmlinux-kernel
|
|
|
|
|
2006-06-15 21:43:59 +00:00
|
|
|
define Image/BuildKernel
|
2011-05-04 08:47:00 +00:00
|
|
|
$(CP) $(KDIR)/loader.elf $(VMLINUX)
|
2013-09-26 19:16:19 +00:00
|
|
|
ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
|
|
|
|
$(CP) $(KDIR)/loader-initramfs.elf $(BIN_DIR)/$(IMG_PREFIX)-vmlinux-initramfs
|
2013-06-27 19:58:31 +00:00
|
|
|
endif
|
2006-06-15 21:43:59 +00:00
|
|
|
endef
|
|
|
|
|
2007-07-20 14:33:15 +00:00
|
|
|
define Image/cmdline/yaffs2
|
2009-05-14 10:20:53 +00:00
|
|
|
root=/dev/mtdblock1 rootfstype=yaffs2
|
2007-07-19 14:53:24 +00:00
|
|
|
endef
|
|
|
|
|
2015-03-27 21:22:17 +00:00
|
|
|
define Image/Build/squashfs
|
2017-01-05 17:01:36 +00:00
|
|
|
dd if=/dev/zero bs=128k count=1 >> $(KDIR)/root.squashfs
|
2015-03-27 21:22:17 +00:00
|
|
|
endef
|
|
|
|
|
2006-10-26 01:08:41 +00:00
|
|
|
define Image/Build
|
2015-03-27 21:22:17 +00:00
|
|
|
$(call Image/Build/$(1),$(1))
|
2010-04-12 23:15:56 +00:00
|
|
|
$(CP) $(KDIR)/vmlinux.elf $(BIN_DIR)/$(IMG_PREFIX)-$(1).kernel
|
2017-01-05 17:01:36 +00:00
|
|
|
$(STAGING_DIR_HOST)/bin/patch-cmdline $(BIN_DIR)/$(IMG_PREFIX)-$(1).kernel 'root=/dev/sda2 '
|
2019-03-28 15:02:22 +00:00
|
|
|
./gen_image.sh $(BIN_DIR)/$(IMG_COMBINED)-$(1).bin \
|
2017-09-17 18:32:42 +00:00
|
|
|
6 $(BIN_DIR)/$(IMG_PREFIX)-$(1).kernel \
|
2015-03-27 21:22:17 +00:00
|
|
|
$(CONFIG_TARGET_ROOTFS_PARTSIZE) $(KDIR)/root.$(1) \
|
|
|
|
128
|
2006-06-15 21:43:59 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
$(eval $(call BuildImage))
|