2006-06-27 00:35:46 +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-04-11 12:39:33 +00:00
|
|
|
|
2006-11-18 18:04:28 +00:00
|
|
|
LOADADDR = 0x81000000 # RAM start + 16M
|
|
|
|
KERNEL_ENTRY = 0x80100000
|
|
|
|
RAMSIZE = 0x00100000 # 1MB
|
|
|
|
|
2007-12-20 22:10:19 +00:00
|
|
|
JFFS2_BLOCKSIZE = 128k
|
|
|
|
|
2006-11-18 18:04:28 +00:00
|
|
|
FLASH_KERNEL := 0xBFD00000
|
|
|
|
FLASH_FS := 0xBE000000
|
|
|
|
|
|
|
|
LOADER_MAKEOPTS= \
|
|
|
|
KDIR=$(KDIR) \
|
|
|
|
LOADADDR=$(LOADADDR) \
|
|
|
|
KERNEL_ENTRY=$(KERNEL_ENTRY) \
|
|
|
|
RAMSIZE=$(RAMSIZE)
|
|
|
|
|
2006-06-04 21:57: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-04 21:57:59 +00:00
|
|
|
endef
|
2006-04-11 12:39:33 +00:00
|
|
|
|
2006-11-18 18:04:28 +00:00
|
|
|
DROP_SECTIONS := .reginfo .mdebug .comment .note .pdr .options .MIPS.options
|
2006-12-12 01:23:37 +00:00
|
|
|
OBJCOPY_SREC := $(TARGET_CROSS)objcopy -S -O srec $(addprefix --remove-section=,$(DROP_SECTIONS))
|
|
|
|
OBJCOPY_BIN := $(TARGET_CROSS)objcopy -S -O binary $(addprefix --remove-section=,$(DROP_SECTIONS))
|
2006-11-18 18:04:28 +00:00
|
|
|
|
2006-06-04 21:57:59 +00:00
|
|
|
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
|
2012-07-17 16:47:57 +00:00
|
|
|
|
2006-11-18 18:04:28 +00:00
|
|
|
# Build RAM image
|
2006-12-18 18:30:29 +00:00
|
|
|
$(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader \
|
2006-11-18 18:04:28 +00:00
|
|
|
$(LOADER_MAKEOPTS) \
|
|
|
|
clean compile
|
2006-12-12 01:23:37 +00:00
|
|
|
$(OBJCOPY_SREC) $(KDIR)/loader.elf $(KDIR)/kernel.ram.srec
|
2012-07-17 16:47:57 +00:00
|
|
|
|
2006-11-18 18:04:28 +00:00
|
|
|
# Build Flash image
|
2006-12-18 18:30:29 +00:00
|
|
|
$(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader \
|
2006-11-18 18:04:28 +00:00
|
|
|
$(LOADER_MAKEOPTS) \
|
|
|
|
IMAGE_COPY=1 \
|
|
|
|
LOADER_ENTRY=$(FLASH_KERNEL) \
|
|
|
|
LOADER_TYPE=_flash \
|
|
|
|
clean compile
|
2006-12-12 01:23:37 +00:00
|
|
|
$(OBJCOPY_SREC) $(KDIR)/loader_flash.elf $(KDIR)/kernel.flash.srec
|
|
|
|
$(OBJCOPY_BIN) $(KDIR)/loader_flash.elf $(KDIR)/kernel.flash.bin
|
2006-06-04 21:57:59 +00:00
|
|
|
endef
|
2006-05-30 19:38:38 +00:00
|
|
|
|
2007-05-24 21:57:34 +00:00
|
|
|
define Image/Build/Initramfs
|
2013-06-27 19:58:31 +00:00
|
|
|
$(OBJCOPY_SREC) $(KDIR)/vmlinux-initramfs.elf $(BIN_DIR)/$(IMG_PREFIX)-vmlinux-initramfs.srec
|
2007-05-24 21:57:34 +00:00
|
|
|
endef
|
|
|
|
|
2006-06-04 21:57:59 +00:00
|
|
|
define Image/Build
|
2006-11-18 18:04:28 +00:00
|
|
|
$(TARGET_CROSS)objcopy -O srec -I binary --adjust-vma $(FLASH_FS) $(KDIR)/root.$(1) $(KDIR)/root.$(1).srec
|
2010-04-12 23:15:56 +00:00
|
|
|
grep -v S7 $(KDIR)/root.$(1).srec > $(BIN_DIR)/$(IMG_PREFIX)-$(1).srec
|
|
|
|
grep -v S0 $(KDIR)/kernel.flash.srec >> $(BIN_DIR)/$(IMG_PREFIX)-$(1).srec
|
|
|
|
$(INSTALL_BIN) $(KDIR)/kernel.flash.bin $(BIN_DIR)/$(IMG_PREFIX)-vmlinux.bin
|
|
|
|
$(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1).fs
|
|
|
|
$(CP) $(KDIR)/kernel.flash.srec $(BIN_DIR)/$(IMG_PREFIX)-vmlinux-flash.srec
|
|
|
|
$(CP) $(KDIR)/kernel.ram.srec $(BIN_DIR)/$(IMG_PREFIX)-vmlinux-ram.srec
|
2013-11-07 12:46:16 +00:00
|
|
|
$(CP) $(BIN_DIR)/$(IMG_PREFIX)-$(1).fs $(TMP_DIR)/$(IMG_PREFIX)-root.fs
|
|
|
|
tar -C $(BIN_DIR) -cvzf $(BIN_DIR)/$(IMG_PREFIX)-$(1)-sysupgrade.bin \
|
|
|
|
$(IMG_PREFIX)-vmlinux.bin -C $(TMP_DIR) $(IMG_PREFIX)-root.fs
|
2007-05-24 21:57:34 +00:00
|
|
|
ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
|
|
|
|
$(call Image/Build/Initramfs)
|
|
|
|
endif
|
2006-06-04 21:57:59 +00:00
|
|
|
endef
|
2006-04-11 12:39:33 +00:00
|
|
|
|
2006-06-04 21:57:59 +00:00
|
|
|
$(eval $(call BuildImage))
|