Makefile 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234
  1. #
  2. # Copyright (C) 2008-2011 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. IMAGE_PROFILE:=$(if $(PROFILE),$(PROFILE),Default)
  10. JFFS2_BLOCKSIZE = 64k 128k 256k
  11. rootfs_type=$(patsubst jffs2-%,jffs2,$(patsubst squashfs-%,squashfs,$(1)))
  12. # $(1): rootfs type.
  13. # $(2): board name.
  14. define imgname
  15. $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(call rootfs_type,$(1))
  16. endef
  17. define rootfs_align
  18. $(patsubst %-256k,0x40000,$(patsubst %-128k,0x20000,$(patsubst %-64k,0x10000,$(patsubst squashfs%,0x4,$(patsubst root.%,%,$(1))))))
  19. endef
  20. define sysupname
  21. $(call imgname,$(1),$(2))-sysupgrade.bin
  22. endef
  23. define factoryname
  24. $(call imgname,$(1),$(2))-factory.bin
  25. endef
  26. COMMA:=,
  27. define mkcmdline
  28. $(if $(1),board=$(1) )$(if $(2),console=$(2)$(COMMA)$(3))
  29. endef
  30. define mtdpartsize
  31. $(shell sz=`echo '$(2)' | sed -ne 's/.*[:$(COMMA)]\([0-9]*\)k[@]*[0-9a-zx]*($(1)).*/\1/p'`; [ -n "$$sz" ] && echo $$(($$sz * 1024)))
  32. endef
  33. SINGLE_PROFILES:=
  34. # $(1) : name of image build method to be used, e.g., TPLINK-LZMA, AthLzma.
  35. # $(2) : name of the build template to be used, e.g. 64k, 64kraw, 128k, etc.
  36. # $(3) : name of the profile to be defined.
  37. # $(4) : board name.
  38. # $(5)~$(7) : arguments for $(mkcmdline)
  39. # board=$(1) console=$(2),$(3)
  40. # $(8)~$(14): extra arguments.
  41. define SingleProfile
  42. # $(1): action name, e.g. loader, buildkernel, squashfs, etc.
  43. define Image/Build/Profile/$(3)
  44. $$(call Image/Build/Template/$(2)/$$(1),$(1),$(4),$$(call mkcmdline,$(5),$(6),$(7)),$(8),$(9),$(10),$(11),$(12),$(13),$(14))
  45. endef
  46. SINGLE_PROFILES += $(3)
  47. endef
  48. # $(1), name of the MultiProfile to be added.
  49. # $(2), name of Profiles to be included in the MultiProfile.
  50. define MultiProfile
  51. define Image/Build/Profile/$(1)
  52. $(foreach p,$(2),
  53. $$(call Image/Build/Profile/$p,$$(1))
  54. )
  55. endef
  56. endef
  57. LOADER_MAKE := $(NO_TRACE_MAKE) -C lzma-loader KDIR=$(KDIR)
  58. KDIR_TMP:=$(KDIR)/tmp
  59. VMLINUX:=$(BIN_DIR)/$(IMG_PREFIX)-vmlinux
  60. UIMAGE:=$(BIN_DIR)/$(IMG_PREFIX)-uImage
  61. # $(1): input file.
  62. # $(2): output file.
  63. # $(3): extra arguments for lzma.
  64. define CompressLzma
  65. $(STAGING_DIR_HOST)/bin/lzma e $(1) -lc1 -lp2 -pb2 $(3) $(2)
  66. endef
  67. define PatchKernel
  68. cp $(KDIR)/vmlinux$(3) $(KDIR_TMP)/vmlinux$(3)-$(1)
  69. $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR_TMP)/vmlinux$(3)-$(1) "$(strip $(2))"
  70. endef
  71. define PatchKernel/initramfs
  72. $(call PatchKernel,$(1),$(2),-initramfs)
  73. cp $(KDIR_TMP)/vmlinux-initramfs-$(1) $(call imgname,initramfs,$(1)).bin
  74. endef
  75. # $(1): board name.
  76. # $(2): kernel command line.
  77. # $(3): extra argumetns for lzma.
  78. # $(4): name suffix, e.g. "-initramfs".
  79. define PatchKernelLzma
  80. cp $(KDIR)/vmlinux$(4) $(KDIR_TMP)/vmlinux$(4)-$(1)
  81. $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR_TMP)/vmlinux$(4)-$(1) "$(strip $(2))"
  82. $(call CompressLzma,$(KDIR_TMP)/vmlinux$(4)-$(1),$(KDIR_TMP)/vmlinux$(4)-$(1).bin.lzma,$(3))
  83. endef
  84. define PatchKernelGzip
  85. cp $(KDIR)/vmlinux$(3) $(KDIR_TMP)/vmlinux$(3)-$(1)
  86. $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR_TMP)/vmlinux$(3)-$(1) "$(strip $(2))"
  87. gzip -9 -c $(KDIR_TMP)/vmlinux$(3)-$(1) > $(KDIR_TMP)/vmlinux$(3)-$(1).bin.gz
  88. endef
  89. ifneq ($(SUBTARGET),mikrotik)
  90. # $(1): compression method of the data.
  91. # $(2): extra arguments.
  92. # $(3): input data file.
  93. # $(4): output file.
  94. define MkuImage
  95. mkimage -A mips -O linux -T kernel -a 0x80060000 -C $(1) $(2) \
  96. -e 0x80060000 -n 'MIPS libreCMC Linux-$(LINUX_VERSION)' \
  97. -d $(3) $(4)
  98. endef
  99. # $(1): board name.
  100. # $(2): kernel command line.
  101. # $(3): extra arguments for lzma.
  102. # $(4): name suffix, e.g. "-initramfs".
  103. # $(5): extra arguments for mkimage.
  104. define MkuImageLzma
  105. $(call PatchKernelLzma,$(1),$(2),$(3),$(4))
  106. $(call MkuImage,lzma,$(5),$(KDIR_TMP)/vmlinux$(4)-$(1).bin.lzma,$(KDIR_TMP)/vmlinux$(4)-$(1).uImage)
  107. endef
  108. define MkuImageLzma/initramfs
  109. $(call PatchKernelLzma,$(1),$(2),$(3),-initramfs)
  110. $(call MkuImage,lzma,$(4),$(KDIR_TMP)/vmlinux-initramfs-$(1).bin.lzma,$(call imgname,initramfs,$(1))-uImage.bin)
  111. endef
  112. define MkuImageGzip
  113. $(call PatchKernelGzip,$(1),$(2))
  114. $(call MkuImage,gzip,,$(KDIR_TMP)/vmlinux-$(1).bin.gz,$(KDIR_TMP)/vmlinux-$(1).uImage)
  115. endef
  116. define MkuImageGzip/initramfs
  117. $(call PatchKernelGzip,$(1),$(2),-initramfs)
  118. $(call MkuImage,gzip,,$(KDIR_TMP)/vmlinux-initramfs-$(1).bin.gz,$(call imgname,initramfs,$(1))-uImage.bin)
  119. endef
  120. define MkuImageOKLI
  121. $(call MkuImage,lzma,-M 0x4f4b4c49,$(KDIR)/vmlinux.bin.lzma,$(KDIR_TMP)/vmlinux-$(1).okli)
  122. endef
  123. endif
  124. # $(1): name of the 1st file.
  125. # $(2): size limit of the 1st file if it is greater than 262144, or
  126. # the erase size of the flash if it is greater than zero and less
  127. # than 262144
  128. # $(3): name of the 2nd file.
  129. # $(4): size limit of the 2nd file if $(2) is greater than 262144, otherwise
  130. # it is the size limit of the output file
  131. # $(5): name of the output file.
  132. # $(6): padding size.
  133. define CatFiles
  134. if [ $(2) -eq 0 ]; then \
  135. filename="$(3)"; fstype=$$$${filename##*\.}; \
  136. case "$$$${fstype}" in \
  137. "jffs2-64k") bs=65536;; \
  138. "jffs2-128k") bs=131072;; \
  139. "jffs2-256k") bs=262144;; \
  140. *) bs=`stat -c%s $(1)`;; \
  141. esac; \
  142. ( dd if=$(1) bs=$$$${bs} conv=sync; cat $(3) ) > $(5); \
  143. if [ -n "$(6)" ]; then \
  144. case "$$$${fstype}" in \
  145. squashfs*) \
  146. padjffs2 $(5) $(6); \
  147. ;; \
  148. esac; \
  149. fi; \
  150. if [ `stat -c%s $(5)` -gt $(4) ]; then \
  151. echo "Warning: $(5) is too big (> $(4) bytes)" >&2; \
  152. rm -f $(5); \
  153. fi; \
  154. else if [ $(2) -gt 262144 ]; then \
  155. if [ `stat -c%s "$(1)"` -gt $(2) ]; then \
  156. echo "Warning: $(1) is too big (> $(2) bytes)" >&2; \
  157. else if [ `stat -c%s $(3)` -gt $(4) ]; then \
  158. echo "Warning: $(3) is too big (> $(4) bytes)" >&2; \
  159. else \
  160. ( dd if=$(1) bs=$(2) conv=sync; dd if=$(3) ) > $(5); \
  161. fi; fi; \
  162. else \
  163. ( dd if=$(1) bs=$(2) conv=sync; dd if=$(3) ) > $(5); \
  164. if [ `stat -c%s $(5)` -gt $(4) ]; then \
  165. echo "Warning: $(5) is too big (> $(4) bytes)" >&2; \
  166. rm -f $(5); \
  167. fi; \
  168. fi; fi
  169. endef
  170. # $(1): rootfs type.
  171. # $(2): board name.
  172. # $(3): kernel image size limit.
  173. # $(4): rootfs image size limit.
  174. # $(5): padding argument for padjffs2.
  175. Sysupgrade/KR=$(call CatFiles,$(2),$(3),$(KDIR)/root.$(1),$(4),$(call sysupname,$(1),$(5)))
  176. Sysupgrade/KRuImage=$(call CatFiles,$(KDIR_TMP)/vmlinux-$(2).uImage,$(3),$(KDIR)/root.$(1),$(4),$(call sysupname,$(1),$(2)),$(5))
  177. Sysupgrade/RKuImage=$(call CatFiles,$(KDIR)/root.$(1),$(4),$(KDIR_TMP)/vmlinux-$(2).uImage,$(3),$(call sysupname,$(1),$(2)))
  178. # $(1): ubinize ini file
  179. # $(2): working directory
  180. # $(3): output file
  181. # $(4): physical erase block size
  182. # $(5): minimum I/O unit size
  183. # $(6): custom options
  184. define ubinize
  185. $(CP) $(1) $(2)
  186. ( cd $(2); $(STAGING_DIR_HOST)/bin/ubinize -o $(3) -p $(4) -m $(5) $(6) $(1))
  187. endef
  188. #
  189. # Embed lzma-compressed kernel inside lzma-loader.
  190. #
  191. # $(1), suffix of output filename, e.g. generic, lowercase board name, etc.
  192. # $(2), suffix of target file to build, e.g. bin, gz, elf
  193. # $(3), kernel command line to pass from lzma-loader to kernel
  194. # $(4), unused here
  195. # $(5), suffix of kernel filename, e.g. -initramfs, or empty
  196. define Image/BuildLoader
  197. -rm -rf $(KDIR)/lzma-loader
  198. $(LOADER_MAKE) LOADER=loader-$(1).$(2) KERNEL_CMDLINE="$(3)"\
  199. LZMA_TEXT_START=0x80a00000 LOADADDR=0x80060000 \
  200. LOADER_DATA="$(KDIR)/vmlinux$(5).bin.lzma" BOARD="$(1)" \
  201. compile loader.$(2)
  202. -$(CP) $(KDIR)/loader-$(1).$(2) $(KDIR)/loader-$(1)$(5).$(2)
  203. endef
  204. #
  205. # Build lzma-loader alone which will search for lzma-compressed kernel identified by
  206. # uImage header with magic "OKLI" at boot time.
  207. #
  208. # $(4), offset into the flash space to start searching uImage magic "OKLI".
  209. # $(5), size of search range starting at $(4). With 0 as the value, uImage
  210. # header is expected to be at precisely $(4)
  211. define Image/BuildLoaderAlone
  212. -rm -rf $(KDIR)/lzma-loader
  213. $(LOADER_MAKE) LOADER=loader-$(1).$(2) KERNEL_CMDLINE="$(3)" \
  214. LZMA_TEXT_START=0x80a00000 LOADADDR=0x80060000 \
  215. BOARD="$(1)" FLASH_OFFS=$(4) FLASH_MAX=$(5) \
  216. compile loader.$(2)
  217. endef
  218. define Build/Clean
  219. $(LOADER_MAKE) clean
  220. endef
  221. alfa_ap96_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,256k(u-boot-env)ro,13312k(rootfs),2048k(kernel),512k(caldata)ro,15360k@0x80000(firmware)
  222. alfa_mtdlayout_8M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,6144k(rootfs),1600k(kernel),64k(nvram),64k(art)ro,7744k@0x50000(firmware)
  223. alfa_mtdlayout_16M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,15936k(firmware),64k(nvram),64k(art)ro
  224. all0258n_mtdlayout=mtdparts=spi0.0:256k(u-boot),64k(u-boot-env),6272k(firmware),1536k(failsafe),64k(art)
  225. all0315n_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,256k(u-boot-env),13568k(firmware),2048k(failsafe),256k(art)ro
  226. ap81_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,5120k(rootfs),2688k(kernel),64k(art)ro,7808k@0x50000(firmware)
  227. ap83_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,128k(u-boot-env)ro,4096k(rootfs),3648k(kernel),64k(art)ro,7744k@0x60000(firmware)
  228. ap96_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(u-boot-env)ro,6144k(rootfs),1728k(kernel),64k(art)ro,7872k@0x40000(firmware)
  229. ap113_mtd_layout=mtdparts=spi0.0:64k(u-boot),3008k(rootfs),896k(uImage),64k(NVRAM),64k(ART),3904k@0x10000(firmware)
  230. ap121_mtdlayout_2M=mtdparts=spi0.0:64k(u-boot)ro,1216k(rootfs),704k(kernel),64k(art)ro,1920k@0x10000(firmware)
  231. ap121_mtdlayout_4M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,2752k(rootfs),896k(kernel),64k(nvram),64k(art)ro,3648k@0x50000(firmware)
  232. carambola2_mtdlayout_16M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,16000k(firmware),64k(art)ro
  233. ap132_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,1408k(kernel),6400k(rootfs),64k(art),7808k@0x50000(firmware)
  234. ap135_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,14528k(rootfs),1472k(kernel),64k(art)ro,16000k@0x50000(firmware)
  235. ap136_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,6336k(rootfs),1408k(kernel),64k(mib0),64k(art)ro,7744k@0x50000(firmware)
  236. bxu2000n2_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,1408k(kernel),8448k(rootfs),6016k(user),64k(cfg),64k(oem),64k(art)ro
  237. cameo_ap81_mtdlayout=mtdparts=spi0.0:128k(u-boot)ro,64k(config)ro,3840k(firmware),64k(art)ro
  238. cameo_ap91_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(nvram)ro,3712k(firmware),64k(mac)ro,64k(art)ro
  239. cameo_ap99_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(nvram)ro,3520k(firmware),64k(mac)ro,192k(lp)ro,64k(art)ro
  240. cameo_ap121_mtdlayout=mtdparts=spi0.0:64k(u-boot)ro,64k(art)ro,64k(mac)ro,64k(nvram)ro,192k(language)ro,3648k(firmware)
  241. cameo_ap121_mtdlayout_8M=mtdparts=spi0.0:64k(u-boot)ro,64k(art)ro,64k(mac)ro,64k(nvram)ro,256k(language)ro,7680k@0x80000(firmware)
  242. cameo_db120_mtdlayout=mtdparts=spi0.0:64k(uboot)ro,64k(nvram)ro,15936k(firmware),192k(lang)ro,64k(mac)ro,64k(art)ro
  243. cameo_db120_mtdlayout_8M=mtdparts=spi0.0:64k(uboot)ro,64k(nvram)ro,7872k(firmware),128k(lang)ro,64k(art)ro
  244. cap4200ag_mtdlayout=mtdparts=spi0.0:256k(u-boot),64k(u-boot-env),320k(custom)ro,1536k(kernel),12096k(rootfs),2048k(failsafe),64k(art),13632k@0xa0000(firmware)
  245. cpe510_mtdlayout=mtdparts=spi0.0:128k(u-boot)ro,64k(pation-table)ro,64k(product-info)ro,1536k(kernel),6144k(rootfs),192k(config)ro,64k(ART)ro,7680k@0x40000(firmware)
  246. eap300v2_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env),320k(custom),13632k(firmware),2048k(failsafe),64k(art)ro
  247. db120_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,6336k(rootfs),1408k(kernel),64k(nvram),64k(art)ro,7744k@0x50000(firmware)
  248. dgl_5500_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(nvram)ro,15296k(firmware),192k(lang)ro,512k(my-dlink)ro,64k(mac)ro,64k(art)ro
  249. cameo_ap94_mtdlayout=mtdparts=spi0.0:256k(uboot)ro,64k(config)ro,6208k(firmware),64k(caldata)ro,1600k(unknown)ro,64k@0x7f0000(caldata_copy)
  250. cameo_ap94_mtdlayout_fat=mtdparts=spi0.0:256k(uboot)ro,64k(config)ro,7808k(firmware),64k(caldata)ro,64k@0x660000(caldata_orig),6208k@0x50000(firmware_orig)
  251. esr900_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(u-boot-env)ro,1408k(kernel),13248k(rootfs),1024k(manufacture)ro,64k(backup)ro,320k(storage)ro,64k(caldata)ro,14656k@0x40000(firmware)
  252. esr1750_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(u-boot-env)ro,1408k(kernel),13248k(rootfs),1024k(manufacture)ro,64k(backup)ro,320k(storage)ro,64k(caldata)ro,14656k@0x40000(firmware)
  253. ew-dorin_mtdlayout_4M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env),3712k(firmware),64k(art)
  254. ew-dorin_mtdlayout_16M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env),16000k(firmware),64k(art)
  255. dlrtdev_mtdlayout=mtdparts=spi0.0:256k(uboot)ro,64k(config)ro,6208k(firmware),64k(caldata)ro,640k(certs),960k(unknown)ro,64k@0x7f0000(caldata_copy)
  256. dlrtdev_mtdlayout_fat=mtdparts=spi0.0:256k(uboot)ro,64k(config)ro,7168k(firmware),640k(certs),64k(caldata)ro,64k@0x660000(caldata_orig),6208k@0x50000(firmware_orig)
  257. dragino2_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,16000k(firmware),64k(config)ro,64k(art)ro
  258. hiwifi_hc6361_mtdlayout=mtdparts=spi0.0:64k(u-boot)ro,64k(bdinfo)ro,1280k(kernel),14848k(rootfs),64k(backup)ro,64k(art)ro,16128k@0x20000(firmware)
  259. pb92_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,2752k(rootfs),896k(kernel),64k(nvram),64k(art)ro,3648k@0x50000(firmware)
  260. planex_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7744k(firmware),128k(art)ro
  261. ubntxm_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7552k(firmware),256k(cfg)ro,64k(EEPROM)ro
  262. uap_pro_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,1536k(kernel),14208k(rootfs),256k(cfg)ro,64k(EEPROM)ro,15744k@0x50000(firmware)
  263. ubdev_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7488k(firmware),64k(certs),256k(cfg)ro,64k(EEPROM)ro
  264. whrhpg300n_mtdlayout=mtdparts=spi0.0:248k(u-boot)ro,8k(u-boot-env)ro,3712k(firmware),64k(art)ro
  265. wlr8100_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(u-boot-env)ro,1408k(kernel),14080k(rootfs),192k(unknown)ro,64k(art)ro,384k(unknown2)ro,15488k@0x40000(firmware)
  266. wndap360_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,1728k(kernel),6016k(rootfs),64k(nvram)ro,64k(art)ro,7744k@0x50000(firmware)
  267. wnr2200_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7808k(firmware),64k(art)ro
  268. wnr2000v3_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,3712k(firmware),64k(art)ro
  269. wnr2000v4_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(u-boot-env)ro,3776k(firmware),64k(art)ro
  270. wndr3700_mtdlayout=mtdparts=spi0.0:320k(u-boot)ro,128k(u-boot-env)ro,7680k(firmware),64k(art)ro
  271. wndr3700v2_mtdlayout=mtdparts=spi0.0:320k(u-boot)ro,128k(u-boot-env)ro,15872k(firmware),64k(art)ro
  272. r6100_mtdlayout=mtdparts=ar934x-nfc:128k(u-boot)ro,256k(caldata),256k(caldata-backup),512k(config),512k(pot),2048k(kernel),122240k(ubi),25600k@0x1a0000(firmware),2048k(language),3072k(traffic_meter)
  273. wndr4300_mtdlayout=mtdparts=ar934x-nfc:256k(u-boot)ro,256k(u-boot-env)ro,256k(caldata),512k(pot),2048k(language),512k(config),3072k(traffic_meter),2048k(kernel),23552k(ubi),25600k@0x6c0000(firmware),256k(caldata_backup),-(reserved)
  274. zcn1523h_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,6208k(rootfs),1472k(kernel),64k(configure)ro,64k(mfg)ro,64k(art)ro,7680k@0x50000(firmware)
  275. mynet_n600_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,64k(devdata)ro,64k(devconf)ro,15872k(firmware),64k(radiocfg)ro
  276. mynet_rext_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,7808k(firmware),64k(nvram)ro,64k(ART)ro,6848k@0x130000(filesystem)
  277. zyx_nbg6716_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(env)ro,64k(RFdata)ro,-(nbu);ar934x-nfc:2048k(zyxel_rfsd),2048k(romd),1024k(header),2048k(kernel),-(ubi)
  278. qihoo_c301_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env),64k(devdata),64k(devconf),15744k(firmware),64k(warm_start),64k(action_image_config),64k(radiocfg)ro;spi0.1:15360k(upgrade2),1024k(privatedata)
  279. define Image/BuildKernel
  280. cp $(KDIR)/vmlinux.elf $(VMLINUX).elf
  281. cp $(KDIR)/vmlinux $(VMLINUX).bin
  282. dd if=$(KDIR)/vmlinux.bin.lzma of=$(VMLINUX).lzma bs=65536 conv=sync
  283. dd if=$(KDIR)/vmlinux.bin.gz of=$(VMLINUX).gz bs=65536 conv=sync
  284. $(call MkuImage,gzip,,$(KDIR)/vmlinux.bin.gz,$(UIMAGE)-gzip.bin)
  285. $(call MkuImage,lzma,,$(KDIR)/vmlinux.bin.lzma,$(UIMAGE)-lzma.bin)
  286. cp $(KDIR)/loader-generic.elf $(VMLINUX)-lzma.elf
  287. -mkdir -p $(KDIR_TMP)
  288. $(call Image/Build/Profile/$(IMAGE_PROFILE),buildkernel)
  289. ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
  290. cp $(KDIR)/vmlinux-initramfs.elf $(VMLINUX)-initramfs.elf
  291. cp $(KDIR)/vmlinux-initramfs $(VMLINUX)-initramfs.bin
  292. dd if=$(KDIR)/vmlinux-initramfs.bin.lzma of=$(VMLINUX)-initramfs.lzma bs=65536 conv=sync
  293. dd if=$(KDIR)/vmlinux-initramfs.bin.gz of=$(VMLINUX)-initramfs.gz bs=65536 conv=sync
  294. $(call MkuImage,gzip,,$(KDIR)/vmlinux-initramfs.bin.gz,$(UIMAGE)-initramfs-gzip.bin)
  295. $(call MkuImage,lzma,,$(KDIR)/vmlinux-initramfs.bin.lzma,$(UIMAGE)-initramfs-lzma.bin)
  296. cp $(KDIR)/loader-generic-initramfs.elf $(VMLINUX)-initramfs-lzma.elf
  297. $(call Image/Build/Initramfs)
  298. endif
  299. endef
  300. Image/Build/WRT400N/buildkernel=$(call MkuImageLzma,$(2),$(3))
  301. define Image/Build/WRT400N
  302. $(call Sysupgrade/KRuImage,$(1),$(2),1310720,6488064)
  303. if [ -e "$(call sysupname,$(1),$(2))" ]; then \
  304. wrt400n $(KDIR_TMP)/vmlinux-$(2).uImage $(KDIR)/root.$(1) $(call factoryname,$(1),$(2)); \
  305. fi
  306. endef
  307. define Image/Build/CameoAP94/buildkernel
  308. $(call MkuImageLzma,$(2),$(3) $(4))
  309. $(call MkuImageLzma,$(2)-fat,$(3) $(5))
  310. endef
  311. define Image/Build/CameoAP94
  312. $(eval fwsize=$(call mtdpartsize,firmware,$(4)))
  313. $(eval fwsize_fat=$(call mtdpartsize,firmware,$(5)))
  314. $(call Sysupgrade/KRuImage,$(1),$(2),0,$$$$(($(fwsize)-4*64*1024)),64)
  315. if [ -e "$(call sysupname,$(1),$(2))" ]; then \
  316. ( \
  317. dd if=$(call sysupname,$(1),$(2)); \
  318. echo -n "$(6)"; \
  319. ) > $(call imgname,$(1),$(2))-backup-loader.bin; \
  320. if [ `stat -c%s $(call sysupname,$(1),$(2))` -gt 4194304 ]; then \
  321. echo "Warning: $(call sysupname,$(1),$(2)) is too big" >&2; \
  322. else \
  323. ( \
  324. dd if=$(call sysupname,$(1),$(2)) bs=4096k conv=sync; \
  325. echo -n "$(7)"; \
  326. ) > $(call factoryname,$(1),$(2)); \
  327. fi; \
  328. fi
  329. $(call CatFiles,$(KDIR_TMP)/vmlinux-$(2)-fat.uImage,0,$(KDIR)/root.$(1),$$$$(($(fwsize_fat)-4*64*1024)),$(KDIR_TMP)/$(2)-fat.bin,64)
  330. if [ -e "$(KDIR_TMP)/$(2)-fat.bin" ]; then \
  331. echo -n "" > $(KDIR_TMP)/$(2)-fat.dummy; \
  332. sh $(TOPDIR)/scripts/combined-image.sh \
  333. "$(KDIR_TMP)/$(2)-fat.bin" \
  334. "$(KDIR_TMP)/$(2)-fat.dummy" \
  335. $(call sysupname,$(1),$(2)-fat); \
  336. fi
  337. endef
  338. define Image/Build/WZRHP
  339. $(call Sysupgrade/KRuImage,$(1),$(2),0,$$$$(($(3)-4*$(4)*1024)),$(4))
  340. if [ -e "$(call sysupname,$(1),$(2))" ]; then \
  341. ( \
  342. echo -n -e "# Airstation Public Fmt1\x00\x00\x00\x00\x00\x00\x00\x00"; \
  343. dd if=$(call sysupname,$(1),$(2)); \
  344. ) > $(call imgname,$(1),$(2))-tftp.bin; \
  345. buffalo-enc -p $(5) -v 1.99 \
  346. -i $(call sysupname,$(1),$(2)) \
  347. -o $(KDIR_TMP)/$(2).enc; \
  348. buffalo-tag -b $(5) -p $(5) -a ath -v 1.99 -m 1.01 -l mlang8 \
  349. -w 3 -c 0x80041000 -d 0x801e8000 -f 1 -r M_ \
  350. -i $(KDIR_TMP)/$(2).enc \
  351. -o $(call factoryname,$(1),$(2)); \
  352. fi
  353. endef
  354. Image/Build/WZRHP64K/buildkernel=$(call MkuImageLzma,$(2),$(3))
  355. Image/Build/WZRHP64K/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4))
  356. Image/Build/WZRHP64K=$(call Image/Build/WZRHP,$(1),$(2),33095680,64,$(4))
  357. Image/Build/WZRHP128K/buildkernel=$(call MkuImageLzma,$(2),$(3))
  358. Image/Build/WZRHP128K/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4))
  359. Image/Build/WZRHP128K=$(call Image/Build/WZRHP,$(1),$(2),33030144,128,$(4))
  360. Image/Build/WHRHPG300N/buildkernel=$(call MkuImageLzma,$(2),$(3) $(4))
  361. Image/Build/WHRHPG300N/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4))
  362. define Image/Build/WHRHPG300N
  363. $(eval fwsize=$(call mtdpartsize,firmware,$(4)))
  364. $(call Sysupgrade/KRuImage,$(1),$(2),0,$$$$(($(fwsize)-4*64*1024)),64)
  365. if [ -e "$(call sysupname,$(1),$(2))" ]; then \
  366. ( \
  367. echo -n -e "# Airstation Public Fmt1\x00\x00\x00\x00\x00\x00\x00\x00"; \
  368. dd if=$(call sysupname,$(1),$(2)); \
  369. ) > $(call imgname,$(1),$(2))-tftp.bin; \
  370. buffalo-enc -p $(5) -v 1.99 \
  371. -i $(call sysupname,$(1),$(2)) \
  372. -o $(KDIR_TMP)/$(2).enc; \
  373. buffalo-tag -b $(5) -p $(5) -a ath -v 1.99 -m 1.01 -l mlang8 \
  374. -w 3 -c 0x80041000 -d 0x801e8000 -f 1 -r M_ \
  375. -i $(KDIR_TMP)/$(2).enc \
  376. -o $(call factoryname,$(1),$(2)); \
  377. fi
  378. endef
  379. define Image/Build/Cameo
  380. $(eval fwsize=$(call mtdpartsize,firmware,$(4)))
  381. $(call Sysupgrade/KRuImage,$(1),$(2),0,$$$$(($(fwsize)-4*64*1024)),64)
  382. if [ -e "$(call sysupname,$(1),$(2))" ]; then \
  383. factory_size=$$$$(($(fwsize) - $(6))); \
  384. ( \
  385. dd if=$(call sysupname,$(1),$(2)) bs=$$$${factory_size} conv=sync; \
  386. echo -n $(5); \
  387. ) > $(call factoryname,$(1),$(2)); \
  388. fi
  389. endef
  390. Image/Build/CameoAP81/buildkernel=$(call MkuImageLzma,$(2),$(3) $(cameo_ap81_mtdlayout))
  391. Image/Build/CameoAP81=$(call Image/Build/Cameo,$(1),$(2),$(3),$(cameo_ap81_mtdlayout),$(4),65536)
  392. Image/Build/CameoAP81/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(cameo_ap81_mtdlayout))
  393. Image/Build/CameoAP91/buildkernel=$(call MkuImageLzma,$(2),$(3) $(cameo_ap91_mtdlayout))
  394. Image/Build/CameoAP91=$(call Image/Build/Cameo,$(1),$(2),$(3),$(cameo_ap91_mtdlayout),$(4),65536)
  395. Image/Build/CameoAP91/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(cameo_ap91_mtdlayout))
  396. Image/Build/CameoAP99/buildkernel=$(call MkuImageLzma,$(2),$(3) $(cameo_ap99_mtdlayout))
  397. Image/Build/CameoAP99=$(call Image/Build/Cameo,$(1),$(2),$(3),$(cameo_ap99_mtdlayout),$(4),65536)
  398. Image/Build/CameoAP99/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(cameo_ap99_mtdlayout))
  399. Image/Build/CameoAP135/buildkernel=$(call MkuImageLzma,$(2),$(3) $(4))
  400. Image/Build/CameoAP135=$(call Image/Build/Cameo,$(1),$(2),$(3),$(4),$(5),26)
  401. Image/Build/CameoAP135/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4))
  402. Image/Build/CameoDB120/buildkernel=$(call MkuImageLzma,$(2),$(3) $(cameo_db120_mtdlayout))
  403. Image/Build/CameoDB120=$(call Image/Build/Cameo,$(1),$(2),$(3),$(cameo_db120_mtdlayout),$(4),26)
  404. Image/Build/CameoDB120/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(cameo_db120_mtdlayout))
  405. Image/Build/CameoDB120_8M/buildkernel=$(call MkuImageLzma,$(2),$(3) $(cameo_db120_mtdlayout_8M))
  406. Image/Build/CameoDB120_8M=$(call Image/Build/Cameo,$(1),$(2),$(3),$(cameo_db120_mtdlayout_8M),$(4),26)
  407. Image/Build/CameoDB120_8M/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(cameo_db120_mtdlayout_8M))
  408. define Image/Build/CameoHornet
  409. $(eval fwsize=$(call mtdpartsize,firmware,$(4)))
  410. $(call Sysupgrade/KRuImage,$(1),$(2),0,$$$$(($(fwsize)-4*64*1024)),64)
  411. if [ -e "$(call sysupname,$(1),$(2))" ]; then \
  412. for r in $(7); do \
  413. [ -n "$$$$r" ] && dashr="-$$$$r" || dashr=; \
  414. [ -z "$$$$r" ] && r="DEF"; \
  415. mkcameofw -M HORNET -R "$$$$r" -S $(5) -V $(6) -c \
  416. -K $(8) -I $(fwsize) \
  417. -k "$(call sysupname,$(1),$(2))" \
  418. -o $(call imgname,$(1),$(2))-factory$$$$dashr.bin; \
  419. true; \
  420. done; \
  421. fi
  422. endef
  423. Image/Build/CameoAP121/buildkernel=$(call MkuImageLzma,$(2),$(3) $(cameo_ap121_mtdlayout))
  424. Image/Build/CameoAP121=$(call Image/Build/CameoHornet,$(1),$(2),$(3),$(cameo_ap121_mtdlayout),$(4),$(5),$(6),0xe0000)
  425. Image/Build/CameoAP121/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(cameo_ap121_mtdlayout))
  426. Image/Build/CameoAP121_8M/buildkernel=$(call MkuImageLzma,$(2),$(3) $(cameo_ap121_mtdlayout_8M))
  427. Image/Build/CameoAP121_8M=$(call Image/Build/CameoHornet,$(1),$(2),$(3),$(cameo_ap121_mtdlayout_8M),$(4),$(5),$(6),0x100000)
  428. Image/Build/CameoAP121_8M/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(cameo_ap121_mtdlayout_8M))
  429. define Image/Build/Ath
  430. $(eval fwsize=$(call mtdpartsize,firmware,$(4)))
  431. $(eval rootsize=$(call mtdpartsize,rootfs,$(4)))
  432. $(eval kernsize=$(call mtdpartsize,kernel,$(4)))
  433. $(call Sysupgrade/$(5),$(1),$(2),$(if $(6),$(6),$(kernsize)),$(if $(rootsize),$(rootsize),$(fwsize)))
  434. if [ -e "$(call sysupname,$(1),$(2))" ]; then \
  435. dd if=$(KDIR_TMP)/vmlinux-$(2).uImage \
  436. of=$(call imgname,kernel,$(2)).bin bs=64k conv=sync; \
  437. dd if=$(KDIR)/root.$(1) \
  438. of=$(call imgname,$(1),$(2)-rootfs).bin bs=128k conv=sync; \
  439. fi
  440. endef
  441. Image/Build/AthGzip/buildkernel=$(call MkuImageGzip,$(2),$(3) $(4))
  442. Image/Build/AthGzip=$(call Image/Build/Ath,$(1),$(2),$(3),$(4),$(5),$(6),$(7))
  443. Image/Build/AthGzip/initramfs=$(call MkuImageGzip/initramfs,$(2),$(3) $(4))
  444. Image/Build/AthLzma/buildkernel=$(call MkuImageLzma,$(2),$(3) $(4))
  445. Image/Build/AthLzma=$(call Image/Build/Ath,$(1),$(2),$(3),$(4),$(5),$(6),$(7))
  446. Image/Build/AthLzma/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4))
  447. define Image/Build/EnGenius
  448. $(eval fwsize=$(call mtdpartsize,firmware,$(4)))
  449. $(eval rootsize=$(call mtdpartsize,rootfs,$(4)))
  450. $(eval kernsize=$(call mtdpartsize,kernel,$(4)))
  451. $(call Sysupgrade/$(5),$(1),$(2),$(if $(6),$(6),$(kernsize)),$(if $(rootsize),$(rootsize),$(fwsize)))
  452. if [ -e "$(call sysupname,$(1),$(2))" ]; then \
  453. dd if=$(KDIR_TMP)/vmlinux-$(2).uImage \
  454. of=$(call imgname,kernel,$(2)).bin bs=64k conv=sync; \
  455. dd if=$(KDIR)/root.$(1) \
  456. of=$(call imgname,$(1),$(2)-rootfs).bin bs=128k conv=sync; \
  457. mksenaofw -e $(call sysupname,$(1),$(2)) \
  458. -o $(call imgname,$(1),$(2))-factory.dlf \
  459. -r 0x101 -p $(7) -t 2; \
  460. fi
  461. endef
  462. Image/Build/EnGenius/buildkernel=$(call MkuImageLzma,$(2),$(3) $(4))
  463. Image/Build/EnGenius/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4))
  464. define MkuImageHiWiFi
  465. # Field ih_name needs to start with "tw150v1"
  466. mkimage -A mips -O linux -T kernel -a 0x80060000 -C $(1) $(2) \
  467. -e 0x80060000 -n 'tw150v1 MIPS libreCMC Linux-$(LINUX_VERSION)' \
  468. -d $(3) $(4)
  469. endef
  470. define MkuImageLzmaHiWiFi
  471. $(call PatchKernelLzma,$(1),$(2),$(3),$(4))
  472. $(call MkuImageHiWiFi,lzma,$(5),$(KDIR_TMP)/vmlinux$(4)-$(1).bin.lzma,$(KDIR_TMP)/vmlinux$(4)-$(1).uImage)
  473. endef
  474. Image/Build/HiWiFi/buildkernel=$(call MkuImageLzmaHiWiFi,$(2),$(3) $(4))
  475. Image/Build/HiWiFi=$(call Image/Build/Ath,$(1),$(2),$(3),$(4),$(5),$(6),$(7))
  476. Image/Build/HiWiFi/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4))
  477. Image/Build/PB4X/buildkernel=$(call PatchKernelLzma,$(2),$(3))
  478. define Image/Build/PB4X
  479. dd if=$(KDIR_TMP)/vmlinux-$(2).bin.lzma \
  480. of=$(call imgname,kernel,$(2)).bin bs=64k conv=sync
  481. dd if=$(KDIR)/root.$(1) \
  482. of=$(call imgname,$(1),$(2)-rootfs).bin bs=128k conv=sync
  483. -sh $(TOPDIR)/scripts/combined-image.sh \
  484. "$(call imgname,kernel,$(2)).bin" \
  485. "$(call imgname,$(1),$(2)-rootfs).bin" \
  486. $(call sysupname,$(1),$(2))
  487. endef
  488. Image/Build/MyLoader/buildkernel=$(call PatchKernelLzma,$(2),$(3))
  489. Image/Build/MyLoader/initramfs=$(call PatchKernel/initramfs,$(2),$(3))
  490. define Image/Build/MyLoader
  491. $(eval fwsize=$(shell echo $$(($(4)-0x30000-4*64*1024))))
  492. $(eval fwimage=$(KDIR_TMP)/$(2)-$(5)-firmware.bin)
  493. $(call CatFiles,$(KDIR_TMP)/vmlinux-$(2).bin.lzma,65536,$(KDIR)/root.$(1),$(fwsize),$(fwimage))
  494. if [ -e "$(fwimage)" ]; then \
  495. $(STAGING_DIR_HOST)/bin/mkmylofw -B $(2) -s $(4) -v \
  496. -p0x00030000:0:al:0x80060000:firmware:$(fwimage) \
  497. $(call imgname,$(1),$(2))-$(5)-factory.img; \
  498. echo -n "" > $(KDIR_TMP)/empty.bin; \
  499. sh $(TOPDIR)/scripts/combined-image.sh \
  500. $(fwimage) $(KDIR_TMP)/empty.bin \
  501. $(call imgname,$(1),$(2))-$(5)-sysupgrade.bin; \
  502. fi
  503. endef
  504. Image/Build/UAPPRO/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(uap_pro_mtdlayout))
  505. define Image/Build/UAPPRO/buildkernel
  506. $(call MkuImageLzma,$(2),$(3) $(uap_pro_mtdlayout))
  507. -rm -rf $(KDIR_TMP)/$(2)
  508. mkdir -p $(KDIR_TMP)/$(2)/image
  509. cp $(KDIR_TMP)/vmlinux-$(2).uImage $(KDIR_TMP)/$(2)/image/kernel0
  510. $(STAGING_DIR_HOST)/bin/mkfs.jffs2 \
  511. --pad --big-endian --squash-uids -v -e 64KiB \
  512. -o $(KDIR_TMP)/$(2)-kernel.jffs2 \
  513. -d $(KDIR_TMP)/$(2)/image \
  514. 2>&1 1>/dev/null | awk '/^.+$$$$/'
  515. -rm -rf $(KDIR_TMP)/$(2)
  516. $(STAGING_DIR_HOST)/bin/padjffs2 $(KDIR_TMP)/$(2)-kernel.jffs2 -J 64
  517. endef
  518. define Image/Build/UAPPRO
  519. $(call CatFiles,$(KDIR_TMP)/$(2)-kernel.jffs2,1572864,$(KDIR)/root.$(1),14548992,$(call sysupname,$(1),$(2)))
  520. -$(STAGING_DIR_HOST)/bin/mkfwimage2 -f 0x9f000000 \
  521. -v $(5).$(6).v6.0.0-libreCMC-$(REVISION) \
  522. -p jffs2:0x50000:0xf60000:0:0:$(call sysupname,$(1),$(2)) \
  523. -o $(call factoryname,$(1),$(2))
  524. endef
  525. # $(4) = board (XS2, XS5, RS, XM)
  526. # $(5) = series (BZ, XM, XW)
  527. # $(6) = chip (ar7240, ar934x)
  528. define Image/Build/UBNT2
  529. $(eval fwsize=$(call mtdpartsize,firmware,$(3)))
  530. $(call Sysupgrade/KRuImage,$(1),$(2),0,$$$$(($(fwsize)-4*64*1024)),64)
  531. if [ -e "$(call sysupname,$(1),$(2))" ]; then \
  532. dd if=$(call sysupname,$(1),$(2)) of=$(KDIR_TMP)/$(2)-mtdpart-kernel.bin bs=1024k count=1; \
  533. dd if=$(call sysupname,$(1),$(2)) of=$(KDIR_TMP)/$(2)-mtdpart-rootfs.bin bs=1024k skip=1; \
  534. $(STAGING_DIR_HOST)/bin/mkfwimage \
  535. -B $(4) -v $(5).$(6).v6.0.0-libreCMC-$(REVISION) \
  536. -k $(KDIR_TMP)/$(2)-mtdpart-kernel.bin \
  537. -r $(KDIR_TMP)/$(2)-mtdpart-rootfs.bin \
  538. -o $(call factoryname,$(1),$(2)); \
  539. fi
  540. endef
  541. Image/Build/UBNTXM/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(ubntxm_mtdlayout))
  542. Image/Build/UBNTXM/buildkernel=$(call MkuImageLzma,$(2),$(3) $(ubntxm_mtdlayout))
  543. Image/Build/UBNTXM=$(call Image/Build/UBNT2,$(1),$(2),$(ubntxm_mtdlayout),$(4),$(5),$(6),$(7))
  544. Image/Build/UBDEV/buildkernel=$(call MkuImageLzma,$(2),$(3) $(ubdev_mtdlayout))
  545. Image/Build/UBDEV=$(call Image/Build/UBNT2,$(1),$(2),$(ubdev_mtdlayout),$(4),$(5),$(6),$(7))
  546. Image/Build/UBNT/buildkernel=$(call PatchKernelLzma,$(2),$(3))
  547. define Image/Build/UBNT
  548. dd if=$(KDIR_TMP)/vmlinux-$(2).bin.lzma of=$(KDIR_TMP)/vmlinux-$(2).lzma bs=64k conv=sync
  549. -$(STAGING_DIR_HOST)/bin/mkfwimage \
  550. -B $(4) -v $(5).$(6).libreCMC.$(REVISION) \
  551. -k $(KDIR_TMP)/vmlinux-$(2).lzma \
  552. -r $(BIN_DIR)/$(IMG_PREFIX)-root.$(1) \
  553. -o $(call factoryname,$(1),$(2))
  554. -sh $(TOPDIR)/scripts/combined-image.sh \
  555. "$(KDIR_TMP)/vmlinux-$(2).lzma" \
  556. "$(BIN_DIR)/$(IMG_PREFIX)-root.$(1)" \
  557. $(call sysupname,$(1),$(2))
  558. endef
  559. Image/Build/Planex/initramfs=$(call MkuImageGzip/initramfs,$(2),$(3) $(planex_mtdlayout))
  560. Image/Build/Planex/loader=$(call Image/BuildLoaderAlone,$(1),gz,$(2) $(planex_mtdlayout),0x52000,0)
  561. define Image/Build/Planex/buildkernel
  562. [ -e "$(KDIR)/loader-$(2).gz" ]
  563. $(call MkuImageOKLI,$(2))
  564. ( \
  565. dd if=$(KDIR)/loader-$(2).gz bs=8128 count=1 conv=sync; \
  566. dd if=$(KDIR_TMP)/vmlinux-$(2).okli; \
  567. ) > $(KDIR_TMP)/kernel-$(2).bin
  568. $(call MkuImage,gzip,,$(KDIR_TMP)/kernel-$(2).bin,$(KDIR_TMP)/vmlinux-$(2).uImage)
  569. endef
  570. define Image/Build/Planex
  571. $(eval fwsize=$(call mtdpartsize,firmware,$(planex_mtdlayout)))
  572. $(call Sysupgrade/KRuImage,$(1),$(2),0,$$$$(($(fwsize)-4*64*1024)),64)
  573. if [ -e "$(call sysupname,$(1),$(2))" ]; then \
  574. $(STAGING_DIR_HOST)/bin/mkplanexfw \
  575. -B $(2) \
  576. -v 2.00.00 \
  577. -i $(call sysupname,$(1),$(2)) \
  578. -o $(call factoryname,$(1),$(2)); \
  579. fi
  580. endef
  581. Image/Build/ALFA/buildkernel=$(call MkuImageLzma,$(2),$(3) $(4))
  582. Image/Build/ALFA/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4))
  583. define Image/Build/ALFA
  584. $(call Sysupgrade/RKuImage,$(1),$(2),$(5),$(6))
  585. if [ -e "$(call sysupname,$(1),$(2))" ]; then \
  586. rm -rf $(KDIR)/$(1); \
  587. mkdir -p $(KDIR)/$(1); \
  588. cd $(KDIR)/$(1); \
  589. cp $(KDIR_TMP)/vmlinux-$(2).uImage $(KDIR)/$(1)/$(7); \
  590. cp $(KDIR)/root.$(1) $(KDIR)/$(1)/$(8); \
  591. $(TAR) zcf $(call factoryname,$(1),$(2)) -C $(KDIR)/$(1) $(7) $(8); \
  592. ( \
  593. echo WRM7222C | dd bs=32 count=1 conv=sync; \
  594. echo -ne '\xfe'; \
  595. ) >> $(call factoryname,$(1),$(2)); \
  596. fi
  597. endef
  598. Image/Build/Seama/loader=$(call Image/BuildLoader,$(1),bin,$(2) $(3),0x80060000)
  599. define Image/Build/Seama
  600. [ -e "$(KDIR)/loader-$(2).bin" ]
  601. $(call CompressLzma,$(KDIR)/loader-$(2).bin,$(KDIR_TMP)/loader-$(2).bin.lzma)
  602. -rm -f $(KDIR_TMP)/image-$(2).tmp
  603. $(call CatFiles,$(KDIR_TMP)/loader-$(2).bin.lzma,$$$$(($(6) - 64)),$(KDIR)/root.$(1),$(7),$(KDIR_TMP)/image-$(2).tmp)
  604. [ -e "$(KDIR_TMP)/image-$(2).tmp" ] && { \
  605. head -c -4 "$(KDIR_TMP)/image-$(2).tmp" > "$(KDIR_TMP)/image-$(2).no-jffs2mark.tmp"; \
  606. $(STAGING_DIR_HOST)/bin/seama \
  607. -i $(KDIR_TMP)/image-$(2).no-jffs2mark.tmp \
  608. -m "dev=/dev/mtdblock/1" -m "type=firmware"; \
  609. $(STAGING_DIR_HOST)/bin/seama \
  610. -s $(call imgname,$(1),$(2))-factory.bin \
  611. -m "signature=$(5)" \
  612. -i $(KDIR_TMP)/image-$(2).no-jffs2mark.tmp.seama; \
  613. tail -c 4 "$(KDIR_TMP)/image-$(2).tmp" >> $(call imgname,$(1),$(2))-factory.bin; \
  614. }
  615. cat $(KDIR_TMP)/loader-$(2).bin.lzma > $(KDIR_TMP)/image-$(2)-sysupgrade.tmp
  616. $(STAGING_DIR_HOST)/bin/seama \
  617. -i $(KDIR_TMP)/image-$(2)-sysupgrade.tmp \
  618. -m "dev=/dev/mtdblock/1" -m "type=firmware"
  619. $(call CatFiles,$(KDIR_TMP)/image-$(2)-sysupgrade.tmp.seama,$(6),$(KDIR)/root.$(1),$(7),$(call sysupname,$(1),$(2)))
  620. endef
  621. define Image/Build/Seama/initramfs
  622. $(call PatchKernelLzma,$(2),$(3) $(4),,-initramfs)
  623. $(STAGING_DIR_HOST)/bin/seama \
  624. -i $(KDIR_TMP)/vmlinux-initramfs-$(2).bin.lzma \
  625. -m "dev=/dev/mtdblock/1" -m "type=firmware"
  626. cat $(KDIR_TMP)/vmlinux-initramfs-$(2).bin.lzma.seama > $(call imgname,initramfs,$(2))-seama.bin
  627. endef
  628. Image/Build/Senao/buildkernel=$(call MkuImageLzma,$(2),$(3) $(4))
  629. Image/Build/Senao/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4))
  630. define Image/Build/Senao
  631. mkdir -p $(KDIR_TMP)/$(2)/
  632. touch $(KDIR_TMP)/$(2)/FWINFO-libreCMC-$(REVISION)-$(2)
  633. -$(CP) ./$(2)/* $(KDIR_TMP)/$(2)/
  634. dd if=$(KDIR_TMP)/vmlinux-$(2).uImage \
  635. of=$(KDIR_TMP)/$(2)/librecmc-senao-$(2)-uImage-lzma.bin bs=64k conv=sync
  636. dd if=$(KDIR)/root.$(1) \
  637. of=$(KDIR_TMP)/$(2)/librecmc-senao-$(2)-root.$(1) bs=64k conv=sync
  638. ( \
  639. cd $(KDIR_TMP)/$(2)/; \
  640. $(TAR) -cz -f $(call factoryname,$(1),$(2)) * \
  641. )
  642. -rm -rf $(KDIR_TMP)/$(2)/
  643. -sh $(TOPDIR)/scripts/combined-image.sh \
  644. $(KDIR_TMP)/vmlinux-$(2).uImage \
  645. $(KDIR)/root.$(1) \
  646. $(call sysupname,$(1),$(2))
  647. endef
  648. Image/Build/TPLINKOLD/loader=$(call Image/BuildLoaderAlone,$(1),gz,$(2),0x22000,0)
  649. define Image/Build/TPLINKOLD
  650. [ -e "$(KDIR)/loader-$(2).gz" ]
  651. $(call MkuImageOKLI,$(2))
  652. ( \
  653. dd if=$(KDIR)/loader-$(2).gz bs=7680 count=1 conv=sync; \
  654. dd if=$(KDIR_TMP)/vmlinux-$(2).okli conv=sync; \
  655. ) > $(KDIR_TMP)/kernel-$(2).bin
  656. -$(STAGING_DIR_HOST)/bin/mktplinkfw \
  657. -H $(4) -W $(5) -F $(6) -N libreCMC -V $(REVISION)\
  658. -X 0x40000 \
  659. -k $(KDIR_TMP)/kernel-$(2).bin \
  660. -r $(KDIR)/root.$(1) \
  661. -o $(call factoryname,$(1),$(2))
  662. -$(STAGING_DIR_HOST)/bin/mktplinkfw \
  663. -H $(4) -W $(5) -F $(6) -N libreCMC -V $(REVISION) -s\
  664. -X 0x40000 \
  665. -k $(KDIR_TMP)/kernel-$(2).bin \
  666. -r $(KDIR)/root.$(1) \
  667. -o $(call sysupname,$(1),$(2))
  668. endef
  669. define Image/Build/TPLINKOLD/initramfs
  670. $(call Image/BuildLoader,$(2),gz,$(3),0x80060000,-initramfs)
  671. -$(STAGING_DIR_HOST)/bin/mktplinkfw -c \
  672. -H $(4) -W $(5) -F $(6) -N libreCMC -V $(REVISION) -s\
  673. -k $(KDIR)/loader-$(2)-initramfs.gz \
  674. -o $(call imgname,$(1),$(2))-initramfs-uImage.bin
  675. endef
  676. Image/Build/TPLINK/loader=$(call Image/BuildLoaderAlone,$(1),gz,$(2),0x22000,0)
  677. define Image/Build/TPLINK
  678. [ -e "$(KDIR)/loader-$(2).gz" ]
  679. $(call MkuImageOKLI,$(2))
  680. ( \
  681. dd if=$(KDIR)/loader-$(2).gz bs=7680 count=1 conv=sync; \
  682. dd if=$(KDIR_TMP)/vmlinux-$(2).okli conv=sync; \
  683. ) > $(KDIR_TMP)/kernel-$(2).bin
  684. -$(STAGING_DIR_HOST)/bin/mktplinkfw \
  685. -H $(4) -W $(5) -F $(6) -N libreCMC -V $(REVISION)\
  686. -X 0x40000 \
  687. -k $(KDIR_TMP)/kernel-$(2).bin \
  688. -r $(KDIR)/root.$(1) \
  689. -a $(call rootfs_align,$(1)) -j \
  690. -o $(call factoryname,$(1),$(2))
  691. -$(STAGING_DIR_HOST)/bin/mktplinkfw \
  692. -H $(4) -W $(5) -F $(6) -N libreCMC -V $(REVISION) -s\
  693. -X 0x40000 \
  694. -k $(KDIR_TMP)/kernel-$(2).bin \
  695. -r $(KDIR)/root.$(1) \
  696. -a $(call rootfs_align,$(1)) -j \
  697. -o $(call sysupname,$(1),$(2))
  698. endef
  699. define Image/Build/TPLINK/initramfs
  700. $(call Image/BuildLoader,$(2),gz,$(3),0x80060000,-initramfs)
  701. -$(STAGING_DIR_HOST)/bin/mktplinkfw -c \
  702. -H $(4) -W $(5) -F $(6) -N libreCMC -V $(REVISION) -s\
  703. -k $(KDIR)/loader-$(2)-initramfs.gz \
  704. -o $(call imgname,$(1),$(2))-uImage.bin
  705. endef
  706. Image/Build/TPLINK-LZMA/buildkernel=$(call PatchKernelLzma,$(2),$(3))
  707. define Image/Build/TPLINK-LZMA
  708. -$(STAGING_DIR_HOST)/bin/mktplinkfw \
  709. -H $(4) -W $(5) -F $(6) -N libreCMC -V $(REVISION) $(7) \
  710. -X 0x40000 \
  711. -k $(KDIR_TMP)/vmlinux-$(2).bin.lzma \
  712. -r $(KDIR)/root.$(1) \
  713. -a $(call rootfs_align,$(1)) -j \
  714. -o $(call factoryname,$(1),$(2))
  715. -$(STAGING_DIR_HOST)/bin/mktplinkfw \
  716. -H $(4) -W $(5) -F $(6) -N libreCMC -V $(REVISION) $(7) -s \
  717. -X 0x40000 \
  718. -k $(KDIR_TMP)/vmlinux-$(2).bin.lzma \
  719. -r $(KDIR)/root.$(1) \
  720. -a $(call rootfs_align,$(1)) -j \
  721. -o $(call sysupname,$(1),$(2))
  722. endef
  723. define Image/Build/TPLINK-LZMA/initramfs
  724. $(call PatchKernelLzma,$(2),$(3),,-initramfs)
  725. -$(STAGING_DIR_HOST)/bin/mktplinkfw -c \
  726. -H $(4) -W $(5) -F $(6) -N libreCMC -V $(REVISION) $(7) -s \
  727. -k $(KDIR_TMP)/vmlinux-initramfs-$(2).bin.lzma \
  728. -o $(call imgname,$(1),$(2))-uImage.bin
  729. endef
  730. Image/Build/TPLINK-SAFELOADER/buildkernel=$(call PatchKernelLzma,$(2),$(3) $(4))
  731. define Image/Build/TPLINK-SAFELOADER
  732. -rm -rf $(KDIR)/lzma-loader
  733. $(LOADER_MAKE) LOADER=loader-$(2).elf\
  734. LZMA_TEXT_START=0x80a00000 LOADADDR=0x80060000 \
  735. LOADER_DATA="$(KDIR_TMP)/vmlinux-$(2).bin.lzma" BOARD="$(2)" \
  736. compile loader.elf
  737. -$(STAGING_DIR_HOST)/bin/tplink-safeloader \
  738. -B $(5) \
  739. -k $(KDIR)/loader-$(2).elf \
  740. -r $(KDIR)/root.$(1) \
  741. -V $(REVISION) \
  742. -j \
  743. -o $(call factoryname,$(1),$(2))
  744. -$(STAGING_DIR_HOST)/bin/tplink-safeloader \
  745. -B $(5) \
  746. -k $(KDIR)/loader-$(2).elf \
  747. -r $(KDIR)/root.$(1) \
  748. -V $(REVISION) \
  749. -j -S \
  750. -o $(call sysupname,$(1),$(2))
  751. endef
  752. define Image/Build/CyberTAN
  753. echo -n '' > $(KDIR_TMP)/empty.bin
  754. $(STAGING_DIR_HOST)/bin/trx -o $(KDIR)/image.tmp \
  755. -f $(KDIR_TMP)/vmlinux-$(2).uImage -F $(KDIR_TMP)/empty.bin \
  756. -x 32 -a 0x10000 -x -32 -f $(KDIR)/root.$(1)
  757. -$(STAGING_DIR_HOST)/bin/addpattern -B $(2) -v v$(5) \
  758. -i $(KDIR)/image.tmp \
  759. -o $(call sysupname,$(1),$(2))
  760. $(STAGING_DIR_HOST)/bin/trx -o $(KDIR)/image.tmp -f $(KDIR_TMP)/vmlinux-$(2).uImage \
  761. -x 32 -a 0x10000 -x -32 -f $(KDIR)/root.$(1)
  762. -$(STAGING_DIR_HOST)/bin/addpattern -B $(2) -v v$(5) -g \
  763. -i $(KDIR)/image.tmp \
  764. -o $(call factoryname,$(1),$(2))
  765. rm $(KDIR)/image.tmp
  766. endef
  767. Image/Build/CyberTANGZIP/loader=$(call Image/BuildLoader,$(1),gz,$(2),0x80060000)
  768. Image/Build/CyberTANGZIP/buildkernel=$(call MkuImage,gzip,,$(KDIR)/loader-$(2).gz,$(KDIR_TMP)/vmlinux-$(2).uImage)
  769. Image/Build/CyberTANGZIP=$(call Image/Build/CyberTAN,$(1),$(2),$(3),$(4),$(5))
  770. Image/Build/CyberTANLZMA/buildkernel=$(call MkuImageLzma,$(2),$(3) $(4))
  771. Image/Build/CyberTANLZMA=$(call Image/Build/CyberTAN,$(1),$(2),$(3),$(4),$(5))
  772. Image/Build/Netgear/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4),,-M $(5))
  773. define Image/Build/Netgear/buildkernel
  774. $(call MkuImageLzma,$(2),$(3) $(4),-d20,,-M $(5))
  775. -rm -rf $(KDIR_TMP)/$(2)
  776. mkdir -p $(KDIR_TMP)/$(2)/image
  777. cat $(KDIR_TMP)/vmlinux-$(2).uImage > $(KDIR_TMP)/$(2)/image/uImage
  778. $(STAGING_DIR_HOST)/bin/mksquashfs-lzma \
  779. $(KDIR_TMP)/$(2) $(KDIR_TMP)/vmlinux-$(2).uImage.squashfs.tmp1 \
  780. -noappend -root-owned -be -b 65536
  781. ( \
  782. cat $(KDIR_TMP)/vmlinux-$(2).uImage.squashfs.tmp1; \
  783. dd if=/dev/zero bs=1k count=1 \
  784. ) > $(KDIR_TMP)/vmlinux-$(2).uImage.squashfs.tmp2
  785. mkimage -A mips -O linux -T filesystem -C none -M $(5) \
  786. -a 0xbf070000 -e 0xbf070000 \
  787. -n 'MIPS libreCMC Linux-$(LINUX_VERSION)' \
  788. -d $(KDIR_TMP)/vmlinux-$(2).uImage.squashfs.tmp2 \
  789. $(KDIR_TMP)/vmlinux-$(2).uImage.squashfs
  790. endef
  791. define Image/Build/Netgear
  792. $(eval fwsize=$(call mtdpartsize,firmware,$(4)))
  793. $(call CatFiles,$(KDIR_TMP)/vmlinux-$(2).uImage.squashfs,0,$(KDIR)/root.$(1),$(fwsize),$(call sysupname,$(1),$(2)),64)
  794. if [ -e $(call sysupname,$(1),$(2)) ]; then \
  795. for r in $(7) ; do \
  796. [ -n "$$$$r" ] && dashr="-$$$$r" || dashr= ; \
  797. $(STAGING_DIR_HOST)/bin/mkdniimg \
  798. -B $(6) -v libreCMC.$(REVISION) -r "$$$$r" $(8) \
  799. -i $(call sysupname,$(1),$(2)) \
  800. -o $(call imgname,$(1),$(2))-factory$$$$dashr.img; \
  801. done; \
  802. fi
  803. endef
  804. Image/Build/NetgearLzma/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4),,-M $(5))
  805. Image/Build/NetgearLzma/buildkernel=$(call MkuImageLzma,$(2),$(3) $(4),-d20,,-M $(5))
  806. define Image/Build/NetgearLzma
  807. $(eval fwsize=$(call mtdpartsize,firmware,$(4)))
  808. $(call CatFiles,$(KDIR_TMP)/vmlinux-$(2).uImage,0,$(KDIR)/root.$(1),$(fwsize),$(call sysupname,$(1),$(2)),64)
  809. endef
  810. Image/Build/NetgearNAND/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4),,-M $(5))
  811. # $(1): (empty)
  812. # $(2): Board name (small caps)
  813. # $(3): Kernel board specific cmdline
  814. # $(4): Kernel mtdparts definition
  815. # $(5): U-Boot magic
  816. define Image/Build/NetgearNAND/buildkernel
  817. $(eval kernelsize=$(call mtdpartsize,kernel,$(4)))
  818. $(call PatchKernelLzma,$(2),$(3) $(4),-d20)
  819. dd if=$(KDIR_TMP)/vmlinux-$(2).bin.lzma \
  820. of=$(KDIR_TMP)/vmlinux-$(2).bin.tmp \
  821. bs=$$$$(($(kernelsize)-131072-2*64-1)) \
  822. count=1 conv=sync
  823. $(call MkuImage,lzma,-M $(5),$(KDIR_TMP)/vmlinux-$(2).bin.tmp,$(KDIR_TMP)/vmlinux-$(2).uImage)
  824. echo -ne '\xff' >> $(KDIR_TMP)/vmlinux-$(2).uImage
  825. # create a fake rootfs image
  826. dd if=/dev/zero of=$(KDIR_TMP)/fakeroot-$(2) bs=131072 count=1
  827. mkimage -A mips -O linux -T filesystem -C none \
  828. -a 0xbf070000 -e 0xbf070000 \
  829. -n 'MIPS libreCMC fakeroot' \
  830. -d $(KDIR_TMP)/fakeroot-$(2) \
  831. -M $(5) \
  832. $(KDIR_TMP)/fakeroot-$(2).uImage
  833. # append the fake rootfs image to the kernel, it will reside in the last
  834. # erase block of the kernel partition
  835. cat $(KDIR_TMP)/fakeroot-$(2).uImage >> $(KDIR_TMP)/vmlinux-$(2).uImage
  836. endef
  837. # $(1): rootfs image suffix
  838. # $(2): Board name (small caps)
  839. # $(3): Kernel board specific cmdline
  840. # $(4): Kernel mtdparts definition
  841. # $(5): U-Boot magic
  842. # $(6): Board name (upper caps)
  843. # $(7): firmware region code (not used yet)
  844. # $(8): DNI Hardware version
  845. # $(9): suffix of the configuration file for ubinize
  846. define Image/Build/NetgearNAND
  847. $(eval firmwaresize=$(call mtdpartsize,firmware,$(4)))
  848. $(eval kernelsize=$(call mtdpartsize,kernel,$(4)))
  849. $(eval imageraw=$(KDIR_TMP)/$(2)-raw.img)
  850. $(CP) $(KDIR)/root.squashfs-raw $(KDIR_TMP)/root.squashfs
  851. echo -ne '\xde\xad\xc0\xde' > $(KDIR_TMP)/jffs2.eof
  852. $(call ubinize,ubinize-$(9).ini,$(KDIR_TMP),$(KDIR_TMP)/$(2)-root.ubi,128KiB,2048,-E 5)
  853. ( \
  854. dd if=$(KDIR_TMP)/vmlinux-$(2).uImage; \
  855. dd if=$(KDIR_TMP)/$(2)-root.ubi \
  856. ) > $(imageraw)
  857. $(STAGING_DIR_HOST)/bin/mkdniimg \
  858. -B $(6) -v libreCMC.$(REVISION) -r "$$$$r" $(8) \
  859. -i $(imageraw) \
  860. -o $(call imgname,ubi,$(2))-factory.img
  861. $(call Image/Build/SysupgradeNAND,$(2),squashfs,$(KDIR_TMP)/vmlinux-$(2).uImage)
  862. endef
  863. ifdef CONFIG_PACKAGE_uboot-ar71xx-nbg460n_550n_550nh
  864. Image/Build/ZyXEL/buildkernel=$(call MkuImageLzma,$(2),$(3))
  865. define Image/Build/ZyXEL
  866. $(call Sysupgrade/KRuImage,$(1),$(2),917504,2752512)
  867. if [ -e "$(call sysupname,$(1),$(2))" ]; then \
  868. if [ ! -f $(BIN_DIR)/$(IMG_PREFIX)-$(2)-u-boot.bin ]; then \
  869. echo "Warning: $(IMG_PREFIX)-$(2)-u-boot.bin not found" >&2; \
  870. else \
  871. $(STAGING_DIR_HOST)/bin/mkzynfw \
  872. -B $(4) \
  873. -b $(BIN_DIR)/$(IMG_PREFIX)-$(2)-u-boot.bin \
  874. -r $(call sysupname,$(1),$(2)):0x10000 \
  875. -o $(call factoryname,$(1),$(2)); \
  876. fi; fi
  877. endef
  878. endif
  879. define Image/Build/ZyXELNAND/buildkernel
  880. $(eval kernelsize=$(call mtdpartsize,kernel,$(5)))
  881. $(call MkuImageLzma,$(2),$(3) $(5) $(6))
  882. mkdir -p $(KDIR_TMP)/$(2)/image/boot
  883. cp $(KDIR_TMP)/vmlinux-$(2).uImage $(KDIR_TMP)/$(2)/image/boot/vmlinux.lzma.uImage
  884. $(STAGING_DIR_HOST)/bin/mkfs.jffs2 \
  885. --pad=$(kernelsize) --big-endian --squash-uids -v -e 128KiB \
  886. -o $(KDIR_TMP)/$(2)-kernel.jffs2 \
  887. -d $(KDIR_TMP)/$(2)/image \
  888. 2>&1 1>/dev/null | awk '/^.+$$$$/'
  889. -rm -rf $(KDIR_TMP)/$(2)
  890. endef
  891. define Image/Build/ZyXELNAND
  892. if [ "$(1)" != "squashfs" ]; then \
  893. echo Only squashfs is supported; \
  894. return 0; \
  895. fi
  896. $(eval firmwaresize=$(call mtdpartsize,firmware,$(4)))
  897. $(eval kernelsize=$(call mtdpartsize,kernel,$(4)))
  898. $(eval imageraw=$(KDIR_TMP)/$(2)-raw.img)
  899. $(CP) $(KDIR)/root.$(1) $(KDIR_TMP)/ubi_root.img
  900. $(call ubinize,ubinize-$(2).ini,$(KDIR_TMP),$(KDIR_TMP)/$(2)-root.ubi,128KiB,2048,-E 5)
  901. ( \
  902. dd if=$(KDIR_TMP)/$(2)-kernel.jffs2; \
  903. dd if=$(KDIR_TMP)/$(2)-root.ubi \
  904. ) > $(imageraw)
  905. dd if=$(imageraw) of=$(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1)-factory.bin \
  906. bs=128k conv=sync
  907. $(call Image/Build/SysupgradeNAND,$(2),squashfs,$(KDIR_TMP)/$(2)-kernel.jffs2)
  908. endef
  909. Image/Build/OpenMesh/buildkernel=$(call MkuImageLzma,$(2))
  910. define Image/Build/OpenMesh
  911. -sh $(TOPDIR)/scripts/om-fwupgradecfg-gen.sh \
  912. "$(4)" \
  913. "$(BUILD_DIR)/fwupgrade.cfg-$(4)" \
  914. "$(KDIR_TMP)/vmlinux-$(2).uImage" \
  915. "$(KDIR)/root.$(1)"
  916. -sh $(TOPDIR)/scripts/combined-ext-image.sh \
  917. "$(4)" "$(call factoryname,$(1),$(2))" \
  918. "$(BUILD_DIR)/fwupgrade.cfg-$(4)" "fwupgrade.cfg" \
  919. "$(KDIR_TMP)/vmlinux-$(2).uImage" "kernel" \
  920. "$(KDIR)/root.$(1)" "rootfs"
  921. endef
  922. Image/Build/Zcomax/buildkernel=$(call MkuImageLzma,$(2),$(3) $(4))
  923. Image/Build/Zcomax/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4))
  924. define Image/Build/Zcomax
  925. $(call Sysupgrade/RKuImage,$(1),$(2),1507328,6356992)
  926. if [ -e "$(call sysupname,$(1),$(2))" ]; then \
  927. $(STAGING_DIR_HOST)/bin/mkzcfw \
  928. -B $(2) \
  929. -k $(KDIR_TMP)/vmlinux-$(2).uImage \
  930. -r $(BIN_DIR)/$(IMG_PREFIX)-root.$(1) \
  931. -o $(call imgname,$(1),$(2))-factory.img; \
  932. fi
  933. endef
  934. # $(1): template name to be defined, etc. squashfs-only, 64k, 64kraw, etc.
  935. # $(2): jffs2 blocksize.
  936. define Jffs2Template
  937. define Image/Build/Template/$(1)/jffs2-$(2)
  938. $$(call Image/Build/$$(1),jffs2-$(2),$$(2),$$(3),$$(4),$$(5),$$(6),$$(7),$$(8),$$(9),$$(10))
  939. endef
  940. endef
  941. # $(1): template name to be defined.
  942. # $(2): squashfs suffix to be used.
  943. # $(3): jffs2 suffix to be used.
  944. define BuildTemplate
  945. # $(1) : name of build method.
  946. # $(2) : board name.
  947. # $(3) : kernel command line.
  948. # $(4)~$(8): extra arguments.
  949. define Image/Build/Template/$(1)/initramfs
  950. $$(call Image/Build/$$(1)/initramfs,initramfs,$$(2),$$(3),$$(4),$$(5),$$(6),$$(7),$$(8),$$(9),$$(10))
  951. endef
  952. define Image/Build/Template/$(1)/loader
  953. $$(call Image/Build/$$(1)/loader,$$(2),$$(3),$$(4),$$(5),$$(6),$$(7),$$(8),$$(9),$$(10))
  954. endef
  955. define Image/Build/Template/$(1)/buildkernel
  956. $$(call Image/Build/$$(1)/buildkernel,,$$(2),$$(3),$$(4),$$(5),$$(6),$$(7),$$(8),$$(9),$$(10))
  957. endef
  958. define Image/Build/Template/$(1)/squashfs
  959. $$(call Image/Build/$$(1),squashfs$(2),$$(2),$$(3),$$(4),$$(5),$$(6),$$(7),$$(8),$$(9),$$(10))
  960. endef
  961. $(if $(3),$(foreach bs,$(3),$(eval $(call Jffs2Template,$(1),$(bs)))))
  962. endef
  963. $(eval $(call BuildTemplate,squashfs-only))
  964. $(eval $(call BuildTemplate,64k,-64k,64k))
  965. $(eval $(call BuildTemplate,64kraw,-raw,64k))
  966. $(eval $(call BuildTemplate,64kraw-nojffs,-raw))
  967. $(eval $(call BuildTemplate,128k,,128k))
  968. $(eval $(call BuildTemplate,128kraw,-raw,128k))
  969. $(eval $(call BuildTemplate,256k,,256k))
  970. $(eval $(call BuildTemplate,all,,64k 128k 256k))
  971. ifeq ($(SUBTARGET),luci)
  972. #NETGEAR
  973. $(eval $(call SingleProfile,Netgear,64kraw,WNR2200,wnr2200,WNR2200,ttyS0,115200,$$(wnr2200_mtdlayout),0x32323030,WNR2200,"" NA,))
  974. $(eval $(call SingleProfile,Netgear,64kraw,WNDR3700V1,wndr3700,WNDR3700,ttyS0,115200,$$(wndr3700_mtdlayout),0x33373030,WNDR3700,"" NA,,7 864 320))
  975. $(eval $(call SingleProfile,Netgear,64kraw,WNDR3700V2,wndr3700v2,WNDR3700,ttyS0,115200,$$(wndr3700v2_mtdlayout),0x33373031,WNDR3700v2,"",-H 29763654+16+64))
  976. $(eval $(call SingleProfile,Netgear,64kraw,WNDR3800,wndr3800,WNDR3700,ttyS0,115200,$$(wndr3700v2_mtdlayout),0x33373031,WNDR3800,"",-H 29763654+16+128))
  977. $(eval $(call SingleProfile,Netgear,64kraw,WNDR3800CH,wndr3800ch,WNDR3700,ttyS0,115200,$$(wndr3700v2_mtdlayout),0x33373031,WNDR3800CH,"",-H 29763654+16+128))
  978. #TP-Link
  979. $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLMR3020,tl-mr3020-v1,TL-MR3020,ttyATH0,115200,0x30200001,1,4Mlzma))
  980. $(eval $(call SingleProfile,TPLINKOLD,squashfs-only,TLWR841NV15,tl-wr841nd-v1.5,TL-WR841N-v1.5,ttyS0,115200,0x08410002,2,4M))
  981. $(eval $(call SingleProfile,TPLINK,64kraw,TLWR741NV1,tl-wr741nd-v1,TL-WR741ND,ttyS0,115200,0x07410001,1,4M))
  982. $(eval $(call SingleProfile,TPLINK,64kraw,TLWR741NV2,tl-wr741nd-v2,TL-WR741ND,ttyS0,115200,0x07410001,1,4M))
  983. $(eval $(call SingleProfile,TPLINK,64kraw,TLWR741NV2,tl-wr741nd-v2,TL-WR741ND-luci,ttyS0,115200,0x07410001,1,4M))
  984. $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR741NV4,tl-wr741nd-v4,TL-WR741ND-v4,ttyATH0,115200,0x07410004,1,4Mlzma))
  985. $(eval $(call SingleProfile,TPLINK,64kraw,TLWR743NV1,tl-wr743nd-v1,TL-WR741ND-luci,ttyS0,115200,0x07430001,1,4M))
  986. $(eval $(call SingleProfile,TPLINK,64kraw,TLWR743NV1,tl-wr743nd-v1,TL-WR741ND,ttyS0,115200,0x07430001,1,4M))
  987. $(eval $(call SingleProfile,TPLINK,64kraw,TLWR841NV3,tl-wr841nd-v3,TL-WR941ND,ttyS0,115200,0x08410003,3,4M))
  988. $(eval $(call SingleProfile,TPLINK,64kraw,TLWR841NV5,tl-wr841nd-v5,TL-WR741ND,ttyS0,115200,0x08410005,1,4M))
  989. $(eval $(call SingleProfile,TPLINK,64kraw,TLWR841NV7,tl-wr841nd-v7,TL-WR841N-v7,ttyS0,115200,0x08410007,1,4M))
  990. $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR841NV8,tl-wr841n-v8,TL-WR841N-v8,ttyS0,115200,0x08410008,1,4Mlzma))
  991. $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR841NV9,tl-wr841n-v9,TL-WR841N-v9,ttyS0,115200,0x08410009,1,4Mlzma))
  992. $(eval $(call MultiProfile,TLWR741,TLWR741NV1 TLWR741NV2 TLWR741NV4))
  993. $(eval $(call MultiProfile,TLWR841,TLWR841NV15 TLWR841NV3 TLWR841NV5 TLWR841NV7 TLWR841NV8 TLWR841NV9 TLWR847NV8))
  994. $(eval $(call MultiProfile,WNDR3700-luci,WNDR3700V1 WNDR3700V2 WNDR3800 WNDR3800CH WNDRMAC WNDRMACV2))
  995. endif # ifeq ($(SUBTARGET),luci)
  996. ifeq ($(SUBTARGET),generic)
  997. #NETGEAR
  998. $(eval $(call SingleProfile,Netgear,64kraw,WNR2200,wnr2200,WNR2200,ttyS0,115200,$$(wnr2200_mtdlayout),0x32323030,WNR2200,"" NA,))
  999. $(eval $(call SingleProfile,Netgear,64kraw,WNDR3700V1,wndr3700,WNDR3700,ttyS0,115200,$$(wndr3700_mtdlayout),0x33373030,WNDR3700,"" NA,,7 864 320))
  1000. $(eval $(call SingleProfile,Netgear,64kraw,WNDR3700V2,wndr3700v2,WNDR3700,ttyS0,115200,$$(wndr3700v2_mtdlayout),0x33373031,WNDR3700v2,"",-H 29763654+16+64))
  1001. $(eval $(call SingleProfile,Netgear,64kraw,WNDR3800,wndr3800,WNDR3700,ttyS0,115200,$$(wndr3700v2_mtdlayout),0x33373031,WNDR3800,"",-H 29763654+16+128))
  1002. $(eval $(call SingleProfile,Netgear,64kraw,WNDR3800CH,wndr3800ch,WNDR3700,ttyS0,115200,$$(wndr3700v2_mtdlayout),0x33373031,WNDR3800CH,"",-H 29763654+16+128))
  1003. #TP-Link
  1004. $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLMR3020,tl-mr3020-v1,TL-MR3020,ttyATH0,115200,0x30200001,1,4Mlzma))
  1005. $(eval $(call SingleProfile,TPLINKOLD,squashfs-only,TLWR841NV15,tl-wr841nd-v1.5,TL-WR841N-v1.5,ttyS0,115200,0x08410002,2,4M))
  1006. $(eval $(call SingleProfile,TPLINK,64kraw,TLWR741NV1,tl-wr741nd-v1,TL-WR741ND,ttyS0,115200,0x07410001,1,4M))
  1007. $(eval $(call SingleProfile,TPLINK,64kraw,TLWR741NV2,tl-wr741nd-v2,TL-WR741ND,ttyS0,115200,0x07410001,1,4M))
  1008. $(eval $(call SingleProfile,TPLINK,64kraw,TLWR741NV2,tl-wr741nd-v2,TL-WR741ND-luci,ttyS0,115200,0x07410001,1,4M))
  1009. $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR741NV4,tl-wr741nd-v4,TL-WR741ND-v4,ttyATH0,115200,0x07410004,1,4Mlzma))
  1010. $(eval $(call SingleProfile,TPLINK,64kraw,TLWR743NV1,tl-wr743nd-v1,TL-WR741ND-luci,ttyS0,115200,0x07430001,1,4M))
  1011. $(eval $(call SingleProfile,TPLINK,64kraw,TLWR743NV1,tl-wr743nd-v1,TL-WR741ND,ttyS0,115200,0x07430001,1,4M))
  1012. $(eval $(call SingleProfile,TPLINK,64kraw,TLWR841NV3,tl-wr841nd-v3,TL-WR941ND,ttyS0,115200,0x08410003,3,4M))
  1013. $(eval $(call SingleProfile,TPLINK,64kraw,TLWR841NV5,tl-wr841nd-v5,TL-WR741ND,ttyS0,115200,0x08410005,1,4M))
  1014. $(eval $(call SingleProfile,TPLINK,64kraw,TLWR841NV7,tl-wr841nd-v7,TL-WR841N-v7,ttyS0,115200,0x08410007,1,4M))
  1015. $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR841NV8,tl-wr841n-v8,TL-WR841N-v8,ttyS0,115200,0x08410008,1,4Mlzma))
  1016. $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR841NV9,tl-wr841n-v9,TL-WR841N-v9,ttyS0,115200,0x08410009,1,4Mlzma))
  1017. $(eval $(call MultiProfile,TLWR741,TLWR741NV1 TLWR741NV2 TLWR741NV4))
  1018. $(eval $(call MultiProfile,TLWR841,TLWR841NV15 TLWR841NV3 TLWR841NV5 TLWR841NV7 TLWR841NV8 TLWR841NV9 TLWR847NV8))
  1019. $(eval $(call MultiProfile,WNDR3700,WNDR3700V1 WNDR3700V2 WNDR3800 WNDR3800CH WNDRMAC WNDRMACV2))
  1020. endif # ifeq ($(SUBTARGET),generic)
  1021. ifeq ($(SUBTARGET),nand)
  1022. $(eval $(call SingleProfile,NetgearNAND,64k,WNDR3700V4,wndr3700v4,WNDR3700_V4,ttyS0,115200,$$(wndr4300_mtdlayout),0x33373033,WNDR3700v4,"",-H 29763948+128+128,wndr4300))
  1023. $(eval $(call SingleProfile,NetgearNAND,64k,WNDR4300V1,wndr4300,WNDR4300,ttyS0,115200,$$(wndr4300_mtdlayout),0x33373033,WNDR4300,"",-H 29763948+0+128+128+2x2+3x3,wndr4300))
  1024. $(eval $(call SingleProfile,NetgearNAND,64k,R6100,r6100,R6100,ttyS0,115200,$$(r6100_mtdlayout),0x36303030,R6100,"",-H 29764434+0+128+128+2x2+2x2,wndr4300))
  1025. $(eval $(call SingleProfile,ZyXELNAND,128k,NBG6716,nbg6716,NBG6716,ttyS0,115200,NBG6716,$$(zyx_nbg6716_mtdlayout),mem=256M))
  1026. $(eval $(call MultiProfile,WNDR4300,WNDR3700V4 WNDR4300V1))
  1027. endif # ifeq ($(SUBTARGET),nand)
  1028. $(eval $(call MultiProfile,Default,$(SINGLE_PROFILES)))
  1029. define Image/Build/squashfs
  1030. cp $(KDIR)/root.squashfs $(KDIR)/root.squashfs-raw
  1031. cp $(KDIR)/root.squashfs $(KDIR)/root.squashfs-64k
  1032. $(STAGING_DIR_HOST)/bin/padjffs2 $(KDIR)/root.squashfs-64k 64
  1033. cp $(KDIR)/root.squashfs-64k $(BIN_DIR)/$(IMG_PREFIX)-root.squashfs-64k
  1034. $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
  1035. dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
  1036. endef
  1037. define Image/Build/jffs2
  1038. dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
  1039. endef
  1040. define Image/Build/Initramfs
  1041. $(call Image/Build/Profile/$(IMAGE_PROFILE),initramfs)
  1042. endef
  1043. define Image/Prepare
  1044. gzip -9 -c $(KDIR)/vmlinux > $(KDIR)/vmlinux.bin.gz
  1045. $(call CompressLzma,$(KDIR)/vmlinux,$(KDIR)/vmlinux.bin.lzma)
  1046. ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
  1047. gzip -9 -c $(KDIR)/vmlinux-initramfs > $(KDIR)/vmlinux-initramfs.bin.gz
  1048. $(call CompressLzma,$(KDIR)/vmlinux-initramfs,$(KDIR)/vmlinux-initramfs.bin.lzma)
  1049. $(call Image/BuildLoader,generic,elf,,,-initramfs)
  1050. endif
  1051. $(call Image/BuildLoader,generic,elf)
  1052. $(call Image/Build/Profile/$(if $(CONFIG_IB),Default,$(IMAGE_PROFILE)),loader)
  1053. endef
  1054. # $(1): filesystem type.
  1055. define Image/Build
  1056. $(call Image/Build/$(call rootfs_type,$(1)),$(1))
  1057. $(call Image/Build/Profile/$(IMAGE_PROFILE),$(1))
  1058. endef
  1059. $(eval $(call BuildImage))