Makefile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. include $(TOPDIR)/rules.mk
  8. include $(INCLUDE_DIR)/image.mk
  9. LOADADDR = 0x81000000 # RAM start + 16M
  10. KERNEL_ENTRY = 0x80101000
  11. RAMSIZE = 0x00100000 # 1MB
  12. IMAGE_COPY = 1
  13. LOADER_MAKEOPTS= \
  14. CROSS_COMPILE="$(TARGET_CROSS)" \
  15. PATH="$(TARGET_PATH)" \
  16. CC="$(TARGET_CC)" \
  17. KDIR=$(KDIR) \
  18. LOADADDR=$(LOADADDR) \
  19. KERNEL_ENTRY=$(KERNEL_ENTRY) \
  20. RAMSIZE=$(RAMSIZE) \
  21. IMAGE_COPY=$(IMAGE_COPY)
  22. LOADER_DIR = $(GENERIC_PLATFORM_DIR)/image/lzma-loader
  23. define Build/lzma-loader-elf
  24. rm -rf $@.loader
  25. mkdir -p $@.loader
  26. $(CP) $(LOADER_DIR)/src/* $@.loader/
  27. $(CP) $@ $@.loader/vmlinux.lzma
  28. $(MAKE) -C $@.loader $(LOADER_MAKEOPTS)
  29. cp $@.loader/lzma.elf $@
  30. rm -rf $@.loader
  31. endef
  32. define Device/nand
  33. CMDLINE := ubi.mtd=1 ubi.block=0,rootfs root=/dev/ubiblock0_1
  34. BOARD_NAME := rb532
  35. SUPPORTED_DEVICES := rb532
  36. KERNEL_INITRAMFS := append-kernel | patch-cmdline | lzma | lzma-loader-elf
  37. KERNEL := $$(KERNEL_INITRAMFS) | kernel2minor -s 2048 -i 0 -c
  38. IMAGES := sysupgrade.bin
  39. FILESYSTEMS := squashfs
  40. IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
  41. endef
  42. TARGET_DEVICES := nand
  43. define Build/Clean
  44. $(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean
  45. endef
  46. define Image/Prepare
  47. cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
  48. $(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean compile
  49. ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
  50. $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR)/vmlinux-initramfs '$(strip $(call Image/cmdline/yaffs2)) '
  51. cat $(KDIR)/vmlinux-initramfs | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
  52. $(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean compile
  53. $(CP) $(KDIR)/loader.elf $(KDIR)/loader-initramfs.elf
  54. endif
  55. endef
  56. VMLINUX:=$(BIN_DIR)/$(IMG_PREFIX)-vmlinux-kernel
  57. define Image/BuildKernel
  58. $(CP) $(KDIR)/loader.elf $(VMLINUX)
  59. ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
  60. $(CP) $(KDIR)/loader-initramfs.elf $(BIN_DIR)/$(IMG_PREFIX)-vmlinux-initramfs
  61. endif
  62. endef
  63. define Image/cmdline/yaffs2
  64. root=/dev/mtdblock1 rootfstype=yaffs2
  65. endef
  66. define Image/Build/squashfs
  67. dd if=/dev/zero bs=128k count=1 >> $(KDIR)/root.squashfs
  68. endef
  69. define Image/Build
  70. $(call Image/Build/$(1),$(1))
  71. $(CP) $(KDIR)/vmlinux.elf $(BIN_DIR)/$(IMG_PREFIX)-$(1).kernel
  72. $(STAGING_DIR_HOST)/bin/patch-cmdline $(BIN_DIR)/$(IMG_PREFIX)-$(1).kernel 'root=/dev/sda2 '
  73. ./gen_image.sh $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).bin \
  74. 5 $(BIN_DIR)/$(IMG_PREFIX)-$(1).kernel \
  75. $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(KDIR)/root.$(1) \
  76. 128
  77. endef
  78. $(eval $(call BuildImage))