1
0

common-tp-link.mk 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. DEVICE_VARS += LOADER_FLASH_OFFS TPLINK_BOARD_ID TPLINK_FLASHLAYOUT TPLINK_HEADER_VERSION TPLINK_HWID TPLINK_HWREV
  2. # Arguments: <output name> <kernel offset>
  3. define Build/loader-okli
  4. dd if=$(KDIR)/loader-$(word 1,$(1)).$(LOADER_TYPE) bs=$(word 2,$(1)) conv=sync of="$@.new"
  5. cat "$@" >> "$@.new"
  6. mv "$@.new" "$@"
  7. endef
  8. define Build/loader-okli-compile
  9. $(call Build/loader-common,FLASH_OFFS=$(LOADER_FLASH_OFFS) FLASH_MAX=0 KERNEL_CMDLINE="$(CMDLINE)")
  10. endef
  11. # combine kernel and rootfs into one image
  12. # mktplinkfw <type> <optional extra arguments to mktplinkfw binary>
  13. # <type> is "sysupgrade" or "factory"
  14. #
  15. # -a align the rootfs start on an <align> bytes boundary
  16. # -j add jffs2 end-of-filesystem markers
  17. # -s strip padding from end of the image
  18. # -X reserve <size> bytes in the firmware image (hexval prefixed with 0x)
  19. define Build/mktplinkfw
  20. -$(STAGING_DIR_HOST)/bin/mktplinkfw \
  21. -H $(TPLINK_HWID) -W $(TPLINK_HWREV) -F $(TPLINK_FLASHLAYOUT) -N libreCMC -V $(REVISION) \
  22. -m $(TPLINK_HEADER_VERSION) \
  23. -k $(IMAGE_KERNEL) \
  24. -r $@ \
  25. -o $@.new \
  26. -j -X 0x40000 \
  27. -a $(call rootfs_align,$(FILESYSTEM)) \
  28. $(wordlist 2,$(words $(1)),$(1)) \
  29. $(if $(findstring sysupgrade,$(word 1,$(1))),-s) && mv $@.new $@ || rm -f $@
  30. endef
  31. define Build/uImageArcher
  32. mkimage -A $(LINUX_KARCH) \
  33. -O linux -T kernel \
  34. -C $(1) -a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
  35. -n '$(call toupper,$(LINUX_KARCH)) libreCMC Linux-$(LINUX_VERSION)' -d $@ $@.new
  36. @mv $@.new $@
  37. endef
  38. define Device/tplink
  39. TPLINK_HWREV := 0x1
  40. TPLINK_HEADER_VERSION := 1
  41. IMAGES := sysupgrade.bin factory.bin
  42. endef
  43. define Device/tplink-lzma
  44. $(Device/tplink)
  45. KERNEL := kernel-bin | patch-cmdline | lzma
  46. KERNEL_INITRAMFS := kernel-bin | patch-cmdline | lzma | tplink-v1-header
  47. IMAGE/sysupgrade.bin := append-rootfs | mktplinkfw sysupgrade
  48. IMAGE/factory.bin := append-rootfs | mktplinkfw factory
  49. endef
  50. define Device/tplink-nolzma
  51. $(Device/tplink)
  52. LOADER_TYPE := gz
  53. LOADER_FLASH_OFFS := 0x22000
  54. COMPILE := loader-$(1).gz
  55. COMPILE/loader-$(1).gz := loader-okli-compile
  56. KERNEL_NAME := vmlinux.bin.lzma
  57. KERNEL := kernel-bin | uImage lzma -M 0x4f4b4c49 | loader-okli $(1) 7680
  58. KERNEL_INITRAMFS_NAME := vmlinux-initramfs.bin.lzma
  59. KERNEL_INITRAMFS := kernel-bin | loader-kernel-cmdline | tplink-v1-header
  60. IMAGE/sysupgrade.bin := append-rootfs | mktplinkfw sysupgrade
  61. IMAGE/factory.bin := append-rootfs | mktplinkfw factory
  62. endef
  63. define Device/tplink-safeloader
  64. $(Device/tplink)
  65. KERNEL := kernel-bin | patch-cmdline | lzma | tplink-v1-header
  66. IMAGE/sysupgrade.bin := append-rootfs | tplink-safeloader sysupgrade | \
  67. append-metadata | check-size $$$$(IMAGE_SIZE)
  68. IMAGE/factory.bin := append-rootfs | tplink-safeloader factory
  69. endef
  70. define Device/tplink-4m
  71. $(Device/tplink-nolzma)
  72. TPLINK_FLASHLAYOUT := 4M
  73. IMAGE_SIZE := 3904k
  74. endef
  75. define Device/tplink-8m
  76. $(Device/tplink-nolzma)
  77. TPLINK_FLASHLAYOUT := 8M
  78. IMAGE_SIZE := 7936k
  79. endef
  80. define Device/tplink-4mlzma
  81. $(Device/tplink-lzma)
  82. TPLINK_FLASHLAYOUT := 4Mlzma
  83. IMAGE_SIZE := 3904k
  84. endef
  85. define Device/tplink-8mlzma
  86. $(Device/tplink-lzma)
  87. TPLINK_FLASHLAYOUT := 8Mlzma
  88. IMAGE_SIZE := 7936k
  89. endef
  90. define Device/tplink-16mlzma
  91. $(Device/tplink-lzma)
  92. TPLINK_FLASHLAYOUT := 16Mlzma
  93. IMAGE_SIZE := 15872k
  94. endef