Makefile 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #
  2. # Copyright (C) 2006-2010 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. JFFS2_BLOCKSIZE = 128k
  8. include $(TOPDIR)/rules.mk
  9. include $(INCLUDE_DIR)/image.mk
  10. LOADADDR = 0x81000000 # RAM start + 16M
  11. KERNEL_ENTRY = 0x80100000
  12. RAMSIZE = 0x00100000 # 1MB
  13. FLASH_KERNEL := 0xBFD00000
  14. FLASH_FS := 0xBE000000
  15. LOADER_MAKEOPTS= \
  16. KDIR=$(KDIR) \
  17. LOADADDR=$(LOADADDR) \
  18. KERNEL_ENTRY=$(KERNEL_ENTRY) \
  19. RAMSIZE=$(RAMSIZE)
  20. define Build/Clean
  21. $(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean
  22. endef
  23. DROP_SECTIONS := .reginfo .mdebug .comment .note .pdr .options .MIPS.options
  24. OBJCOPY_SREC := $(TARGET_CROSS)objcopy -S -O srec $(addprefix --remove-section=,$(DROP_SECTIONS))
  25. OBJCOPY_BIN := $(TARGET_CROSS)objcopy -S -O binary $(addprefix --remove-section=,$(DROP_SECTIONS))
  26. define Image/Prepare
  27. cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
  28. # Build RAM image
  29. $(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader \
  30. $(LOADER_MAKEOPTS) \
  31. clean compile
  32. $(OBJCOPY_SREC) $(KDIR)/loader.elf $(KDIR)/kernel.ram.srec
  33. # Build Flash image
  34. $(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader \
  35. $(LOADER_MAKEOPTS) \
  36. IMAGE_COPY=1 \
  37. LOADER_ENTRY=$(FLASH_KERNEL) \
  38. LOADER_TYPE=_flash \
  39. clean compile
  40. $(OBJCOPY_SREC) $(KDIR)/loader_flash.elf $(KDIR)/kernel.flash.srec
  41. $(OBJCOPY_BIN) $(KDIR)/loader_flash.elf $(KDIR)/kernel.flash.bin
  42. endef
  43. define Image/Build/Initramfs
  44. $(OBJCOPY_SREC) $(KDIR)/vmlinux-initramfs.elf $(BIN_DIR)/$(IMG_PREFIX)-vmlinux-initramfs.srec
  45. endef
  46. define Image/Build
  47. $(SCRIPT_DIR)/srecimage.pl $(KDIR)/root.$(1) $(KDIR)/root.$(1).srec $(FLASH_FS)
  48. grep -v S7 $(KDIR)/root.$(1).srec > $(BIN_DIR)/$(IMG_PREFIX)-$(1).srec
  49. grep -v S0 $(KDIR)/kernel.flash.srec >> $(BIN_DIR)/$(IMG_PREFIX)-$(1).srec
  50. $(INSTALL_BIN) $(KDIR)/kernel.flash.bin $(BIN_DIR)/$(IMG_PREFIX)-vmlinux.bin
  51. $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1).fs
  52. $(CP) $(KDIR)/kernel.flash.srec $(BIN_DIR)/$(IMG_PREFIX)-vmlinux-flash.srec
  53. $(CP) $(KDIR)/kernel.ram.srec $(BIN_DIR)/$(IMG_PREFIX)-vmlinux-ram.srec
  54. $(CP) $(BIN_DIR)/$(IMG_PREFIX)-$(1).fs $(TMP_DIR)/$(IMG_PREFIX)-root.fs
  55. tar -C $(BIN_DIR) -cvzf $(BIN_DIR)/$(IMG_PREFIX)-$(1)-sysupgrade.bin \
  56. $(IMG_PREFIX)-vmlinux.bin -C $(TMP_DIR) $(IMG_PREFIX)-root.fs
  57. ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
  58. $(call Image/Build/Initramfs)
  59. endif
  60. endef
  61. $(eval $(call BuildImage))