1
0

common-tp-link.mk 3.3 KB

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