2006-06-27 00:35:46 +00: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 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
|
|
|
|
|
|
|
|
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
|
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
|
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
|
2007-11-10 23:08:11 +00:00
|
|
|
$(OBJCOPY_SREC) $(BIN_DIR)/openwrt-$(BOARD)-vmlinux.elf $(BIN_DIR)/openwrt-$(BOARD)-vmlinux.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
|
2007-11-10 23:08:11 +00: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-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))
|