Makefile 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #
  2. # Copyright (C) 2006 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. LOADADDR = 0x80010000 # RAM start + 16M
  10. KERNEL_ENTRY = $(LOADADDR) # Newer kernels add a jmp to the kernel_entry at the start of the binary
  11. RAMSIZE = 0x01000000 # 64MB
  12. LOADER_MAKEOPTS= \
  13. KDIR=$(KDIR) \
  14. LOADADDR=$(LOADADDR) \
  15. KERNEL_ENTRY=$(KERNEL_ENTRY) \
  16. RAMSIZE=$(RAMSIZE)
  17. define trxalign/jffs2-128k
  18. -a 0x20000
  19. endef
  20. define trxalign/jffs2-64k
  21. -a 0x10000
  22. endef
  23. define trxalign/squashfs
  24. -a 1024
  25. endef
  26. define Image/Build/CFE
  27. # Generate the tagged image
  28. $(STAGING_DIR_HOST)/bin/imagetag -i $(KDIR)/vmlinux.lzma.cfe -f $(KDIR)/root.$(1) \
  29. -o $(BIN_DIR)/openwrt-$(2)-$(1)-cfe.bin \
  30. -b $(2) -c $(3) -e $(LOADADDR) -l $(LOADADDR)
  31. # -b $(2) -c $(3) -e $(KERNEL_ENTRY) -l $(LOADADDR)
  32. $(call prepare_generic_squashfs,$(BIN_DIR)/openwrt-$(2)-$(1)-cfe.bin)
  33. endef
  34. define Build/Clean
  35. $(MAKE) -C lzma-loader clean
  36. endef
  37. define Image/Prepare
  38. # Standard LZMA kernel
  39. cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
  40. # CFE is a LZMA nazi! It took me hours to find out the parameters!
  41. # Also I think lzma has a bug cause it generates different output depending on
  42. # if you use stdin / stdout or not. Use files instead of stdio here, cause
  43. # otherwise CFE will complain and not boot the image.
  44. $(STAGING_DIR_HOST)/bin/lzma e -d22 -fb64 -a1 $(KDIR)/vmlinux $(KDIR)/vmlinux.lzma.tmp
  45. # Strip out the length, CFE doesn't like this
  46. dd if=$(KDIR)/vmlinux.lzma.tmp of=$(KDIR)/vmlinux.lzma.cfe bs=5 count=1
  47. dd if=$(KDIR)/vmlinux.lzma.tmp of=$(KDIR)/vmlinux.lzma.cfe ibs=13 obs=5 skip=1 seek=1 conv=notrunc
  48. rm -f $(KDIR)/vmlinux.lzma.tmp
  49. # Build the LZMA loader
  50. rm -f $(KDIR)/loader.gz
  51. $(MAKE) -C lzma-loader \
  52. BUILD_DIR="$(KDIR)" \
  53. TARGET="$(KDIR)" \
  54. clean install
  55. echo -ne "\\x00" >> $(KDIR)/loader.gz
  56. rm -f $(KDIR)/fs_mark
  57. touch $(KDIR)/fs_mark
  58. $(call prepare_generic_squashfs,$(KDIR)/fs_mark)
  59. endef
  60. define Image/Build
  61. $(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/openwrt-$(BOARD)-$(1).trx -f $(KDIR)/loader.gz -f $(KDIR)/vmlinux.lzma $(call trxalign/$(1)) -f $(KDIR)/root.$(1)
  62. $(call Image/Build/CFE,$(1),96345GW2,6345)
  63. $(call Image/Build/CFE,$(1),96348GW,6348)
  64. # Neufbox4
  65. $(call Image/Build/CFE,$(1),96358VW,6358)
  66. # Comtrend 536
  67. $(call Image/Build/CFE,$(1),96348GW-11,6348)
  68. # DG834G
  69. $(call Image/Build/CFE,$(1),96348GW-10,6348)
  70. # Sagem F@ST2404
  71. $(call Image/Build/CFE,$(1),F@ST2404,6348)
  72. endef
  73. $(eval $(call BuildImage))