2006-06-27 08:35:46 +08:00
|
|
|
#
|
|
|
|
# Copyright (C) 2006 OpenWrt.org
|
|
|
|
#
|
|
|
|
# This is free software, licensed under the GNU General Public License v2.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
2006-06-21 11:13:25 +08:00
|
|
|
include $(TOPDIR)/rules.mk
|
2006-06-21 10:32:39 +08:00
|
|
|
include $(INCLUDE_DIR)/image.mk
|
2006-04-11 20:39:33 +08:00
|
|
|
|
2006-11-19 02:04:28 +08:00
|
|
|
LOADADDR = 0x81000000 # RAM start + 16M
|
|
|
|
KERNEL_ENTRY = 0x80100000
|
|
|
|
RAMSIZE = 0x00100000 # 1MB
|
|
|
|
|
|
|
|
FLASH_KERNEL := 0xBFD00000
|
|
|
|
FLASH_FS := 0xBE000000
|
|
|
|
|
|
|
|
LOADER_MAKEOPTS= \
|
|
|
|
KDIR=$(KDIR) \
|
|
|
|
LOADADDR=$(LOADADDR) \
|
|
|
|
KERNEL_ENTRY=$(KERNEL_ENTRY) \
|
|
|
|
RAMSIZE=$(RAMSIZE)
|
|
|
|
|
2006-06-05 05:57:59 +08:00
|
|
|
define Build/Clean
|
2006-12-19 02:30:29 +08:00
|
|
|
$(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean
|
2006-06-05 05:57:59 +08:00
|
|
|
endef
|
2006-04-11 20:39:33 +08:00
|
|
|
|
2006-11-19 02:04:28 +08:00
|
|
|
DROP_SECTIONS := .reginfo .mdebug .comment .note .pdr .options .MIPS.options
|
2006-12-12 09:23:37 +08: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-19 02:04:28 +08:00
|
|
|
|
2006-06-05 05:57:59 +08:00
|
|
|
define Image/Prepare
|
2007-08-07 08:04:25 +08:00
|
|
|
cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
|
2006-11-19 02:04:28 +08:00
|
|
|
|
|
|
|
# Build RAM image
|
2006-12-19 02:30:29 +08:00
|
|
|
$(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader \
|
2006-11-19 02:04:28 +08:00
|
|
|
$(LOADER_MAKEOPTS) \
|
|
|
|
clean compile
|
2006-12-12 09:23:37 +08:00
|
|
|
$(OBJCOPY_SREC) $(KDIR)/loader.elf $(KDIR)/kernel.ram.srec
|
2006-11-19 02:04:28 +08:00
|
|
|
|
|
|
|
# Build Flash image
|
2006-12-19 02:30:29 +08:00
|
|
|
$(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader \
|
2006-11-19 02:04:28 +08:00
|
|
|
$(LOADER_MAKEOPTS) \
|
|
|
|
IMAGE_COPY=1 \
|
|
|
|
LOADER_ENTRY=$(FLASH_KERNEL) \
|
|
|
|
LOADER_TYPE=_flash \
|
|
|
|
clean compile
|
2006-12-12 09:23:37 +08:00
|
|
|
$(OBJCOPY_SREC) $(KDIR)/loader_flash.elf $(KDIR)/kernel.flash.srec
|
|
|
|
$(OBJCOPY_BIN) $(KDIR)/loader_flash.elf $(KDIR)/kernel.flash.bin
|
2006-06-05 05:57:59 +08:00
|
|
|
endef
|
2006-05-31 03:38:38 +08:00
|
|
|
|
2007-05-25 05:57:34 +08:00
|
|
|
define Image/Build/Initramfs
|
2007-11-11 07:08:11 +08:00
|
|
|
$(OBJCOPY_SREC) $(BIN_DIR)/openwrt-$(BOARD)-vmlinux.elf $(BIN_DIR)/openwrt-$(BOARD)-vmlinux.srec
|
2007-05-25 05:57:34 +08:00
|
|
|
endef
|
|
|
|
|
2006-06-05 05:57:59 +08:00
|
|
|
define Image/Build
|
2006-11-19 02:04:28 +08:00
|
|
|
$(TARGET_CROSS)objcopy -O srec -I binary --adjust-vma $(FLASH_FS) $(KDIR)/root.$(1) $(KDIR)/root.$(1).srec
|
2007-11-11 07:08:11 +08:00
|
|
|
grep -v S7 $(KDIR)/root.$(1).srec > $(BIN_DIR)/openwrt-$(BOARD)-$(1).img
|
|
|
|
grep -v S0 $(KDIR)/kernel.flash.srec >> $(BIN_DIR)/openwrt-$(BOARD)-$(1).img
|
|
|
|
$(CP) $(KDIR)/kernel.flash.bin $(BIN_DIR)/openwrt-$(BOARD)-vmlinux.bin
|
|
|
|
$(CP) $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(1).fs
|
|
|
|
$(CP) $(KDIR)/kernel.flash.srec $(BIN_DIR)/openwrt-$(BOARD)-vmlinux-flash.srec
|
|
|
|
$(CP) $(KDIR)/kernel.ram.srec $(BIN_DIR)/openwrt-$(BOARD)-vmlinux-ram.srec
|
2007-05-25 05:57:34 +08:00
|
|
|
ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
|
|
|
|
$(call Image/Build/Initramfs)
|
|
|
|
endif
|
2006-06-05 05:57:59 +08:00
|
|
|
endef
|
2006-04-11 20:39:33 +08:00
|
|
|
|
2006-06-05 05:57:59 +08:00
|
|
|
$(eval $(call BuildImage))
|