Makefile 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #
  2. # Copyright (C) 2006-2015 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. include $(INCLUDE_DIR)/image.mk
  9. DROP_SECTIONS:=.reginfo .mdebug .comment .note .pdr .options .MIPS.options
  10. OBJCOPY_SREC:=$(TARGET_CROSS)objcopy -S -O srec $(addprefix --remove-section=,$(DROP_SECTIONS))
  11. LOADADDR:=0x94600000
  12. KERNEL_ENTRY:=0x94100000
  13. RAMSTART:=0x94000000
  14. RAMSIZE:=0x00100000
  15. EVA_LOADADDR := 0x94100000
  16. LOADER_MAKEOPTS= \
  17. KDIR=$(KDIR) \
  18. LOADADDR=$(LOADADDR) \
  19. KERNEL_ENTRY=$(KERNEL_ENTRY) \
  20. RAMSTART=$(RAMSTART) \
  21. RAMSIZE=$(RAMSIZE)
  22. CFLAGS := -D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -Os \
  23. -fno-strict-aliasing -fno-common -fomit-frame-pointer -G 0 -mno-abicalls -fno-pic \
  24. -pipe -mlong-calls -fno-common \
  25. -mabi=32 -march=mips32 -Wa,-32 -Wa,-march=mips32 -Wa,-mips32 -Wa,--trap \
  26. -DLOADADDR=$(LOADADDR)
  27. define Build/Clean
  28. $(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean
  29. endef
  30. define Image/Prepare
  31. cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
  32. $(STAGING_DIR_HOST)/bin/lzma2eva $(EVA_LOADADDR) 0x$${shell $(TARGET_CROSS)nm $(KDIR)/vmlinux | grep -w kernel_entry | cut -d' ' -f1} $(KDIR)/vmlinux.lzma $(KDIR)/loader.eva
  33. $(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader \
  34. $(LOADER_MAKEOPTS) \
  35. clean compile
  36. $(OBJCOPY_SREC) $(KDIR)/loader.elf $(KDIR)/loader.srec
  37. $(OBJCOPY_SREC) $(KDIR)/vmlinux.elf $(KDIR)/vmlinux.srec
  38. srec2bin $(KDIR)/loader.srec $(KDIR)/loader.bin
  39. srec2bin $(KDIR)/vmlinux.srec $(KDIR)/vmlinux.bin
  40. ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
  41. $(OBJCOPY_SREC) $(KDIR)/vmlinux-initramfs.elf \
  42. $(KDIR)/vmlinux-initramfs.srec
  43. srec2bin $(KDIR)/vmlinux-initramfs.srec $(KDIR)/vmlinux-initramfs.bin
  44. endif
  45. endef
  46. define align/jffs2-64k
  47. bs=65536 conv=sync
  48. endef
  49. define align/jffs2-128k
  50. bs=131072 conv=sync
  51. endef
  52. define align/squashfs
  53. endef
  54. define Image/Build/CyberTAN
  55. (dd if=/dev/zero bs=16 count=1; cat $(BIN_DIR)/$(IMG_PREFIX)-$(1).bin) | \
  56. $(STAGING_DIR_HOST)/bin/addpattern -p $(3) -o $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(4)-code.bin
  57. endef
  58. define Image/Build/Titan
  59. $(STAGING_DIR_HOST)/bin/mktitanimg -o $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(4)-code.bin -i $(KDIR)/loader.bin $(KDIR)/root.$(1) -a 0x10000 0x10000 -h 2 -p 0x4C575943 -s 0x0b010000
  60. $(STAGING_DIR_HOST)/bin/mktitanimg -o $(BIN_DIR)/$(IMG_PREFIX)-$(2)-na-$(4)-code.bin -i $(KDIR)/loader.bin $(KDIR)/root.$(1) -a 0x10000 0x10000 -h 2 -p 0x4D575943 -s 0x0b010000
  61. endef
  62. define Image/Build/AudioCodes
  63. ( dd if=$(KDIR)/vmlinux.elf bs=64k conv=sync ; dd if=$(KDIR)/root.$(1) ) > $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).bin
  64. endef
  65. #define Image/Build/sErCoMm
  66. # cat sercomm/adam2.bin "$(BIN_DIR)/$(IMG_PREFIX)-$(1).bin" > "$(KDIR)/dgfw.tmp"
  67. # dd if=sercomm/$(2) of="$(KDIR)/dgfw.tmp" bs=$$$$((0x3e0000 - 80)) seek=1 conv=notrunc
  68. # $(STAGING_DIR_HOST)/bin/dgfirmware -f -w "$(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(3).img" "$(KDIR)/dgfw.tmp"
  69. # rm -f "$(KDIR)/dgfw.tmp"
  70. #endef
  71. define Image/Build/EVA
  72. dd if=$(KDIR)/loader.eva $(call align/$(1)) > $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(KERNEL)-$(1).bin
  73. cat $(KDIR)/root.$(1) >> $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(KERNEL)-$(1).bin
  74. $(call prepare_generic_squashfs,$(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(KERNEL)-$(1).bin)
  75. endef
  76. define Image/Build/Initramfs
  77. $(CP) $(KDIR)/vmlinux-initramfs.bin $(BIN_DIR)/$(IMG_PREFIX)-initramfs.bin
  78. endef
  79. ifeq ($(CONFIG_AR7_TI),y)
  80. define Image/Build
  81. dd if=$(KDIR)/loader.bin $(call align/$(1)) > $(BIN_DIR)/$(IMG_PREFIX)-$(1).bin
  82. cat $(KDIR)/root.$(1) >> $(BIN_DIR)/$(IMG_PREFIX)-$(1).bin
  83. $(call prepare_generic_squashfs,$(BIN_DIR)/$(IMG_PREFIX)-$(1).bin)
  84. $(call Image/Build/CyberTAN,$(1),AG1B,AG1B,$(1))
  85. $(call Image/Build/CyberTAN,$(1),AG1A,AG1A,$(1))
  86. $(call Image/Build/CyberTAN,$(1),WA21,WA21,$(1))
  87. $(call Image/Build/CyberTAN,$(1),WA22,WA22,$(1))
  88. $(call Image/Build/CyberTAN,$(1),WAG2,WAG2,$(1))
  89. $(call Image/Build/CyberTAN,$(1),AG310,AV2A -b -r 1.0,$(1))
  90. $(call Image/Build/CyberTAN,$(1),AG241v2,AG3A -b -r 2.0,$(1))
  91. $(call Image/Build/CyberTAN,$(1),AG241v2b,AG3B -b -r 2.0,$(1))
  92. $(call Image/Build/CyberTAN,$(1),AG241v1,AG3A -b,$(1))
  93. $(call Image/Build/CyberTAN,$(1),WAG54GP2v1,ATWL -b,$(1))
  94. $(call Image/Build/CyberTAN,$(1),WAG54GP2v2,CTWL -b,$(1))
  95. $(call Image/Build/CyberTAN,$(1),WA31,WA31 -b,$(1))
  96. $(call Image/Build/CyberTAN,$(1),WA32,WA32 -b,$(1))
  97. $(call Image/Build/CyberTAN,$(1),WA7A,WA7A -b,$(1))
  98. $(call Image/Build/CyberTAN,$(1),WA7B,WA7B -b,$(1))
  99. # $(call Image/Build/sErCoMm,$(1),dg834,$(1))
  100. # $(call Image/Build/sErCoMm,$(1),jdr454wb,$(1))
  101. $(call Image/Build/EVA,$(1),EVA)
  102. $(call Image/Build/Titan,$(1),Titan,Titan,$(1))
  103. ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
  104. $(call Image/Build/Initramfs)
  105. endif
  106. endef
  107. endif
  108. ifeq ($(CONFIG_AR7_AC49X),y)
  109. define Image/Build
  110. # $(call prepare_generic_squashfs,$(BIN_DIR)/$(IMG_PREFIX)-$(1).bin)
  111. $(call Image/Build/AudioCodes,$(1),mp202,$(1))
  112. ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
  113. $(call Image/Build/Initramfs)
  114. endif
  115. endef
  116. endif
  117. $(eval $(call BuildImage))