Makefile 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. #
  2. # Copyright (C) 2009-2018 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. define Build/copy-kernel.bin
  10. $(call locked,$(MAKE) -C copy-kernel CROSS_COMPILE=$(TARGET_CROSS) O=$(KDIR),gemini-copy-kernel.bin)
  11. endef
  12. # Cook a "WRGG" image, this board is apparently one in the D-Link
  13. # WRGG family and uses the exact same firmware format as other
  14. # D-Link devices.
  15. define Build/dir685-image
  16. mkwrggimg -i $@ \
  17. -o [email protected] \
  18. -d /dev/mtdblock/1 \
  19. -s wrgns01_dlwbr_dir685RBWW \
  20. -v 'N/A' \
  21. -m dir685 \
  22. -B 96bb
  23. mv [email protected] $@
  24. endef
  25. # Padding added after the rootfs to an even 128k boundary
  26. # as this is 128k eraseblocks flash.
  27. define Build/dir685-pad-rootfs
  28. $(STAGING_DIR_HOST)/bin/padjffs2 $(IMAGE_ROOTFS) -c 128 >>$@
  29. endef
  30. # Build D-Link DNS-313 images using the special header tool.
  31. # rootfs.tgz and rd.tgz contains nothing, we only need them
  32. # to satisfy the boot loader on the device. The zImage is
  33. # the only real content.
  34. define Build/dns313-images
  35. mkdir -p [email protected]/.boot
  36. chmod 755 [email protected]/.boot
  37. echo "dummy" > [email protected]/dummyfile
  38. dns313-header [email protected]/dummyfile \
  39. [email protected]/.boot/rootfs.tgz
  40. dns313-header [email protected]/dummyfile \
  41. [email protected]/.boot/rd.gz
  42. dns313-header $(IMAGE_KERNEL) \
  43. [email protected]/.boot/zImage
  44. rm [email protected]/dummyfile
  45. genext2fs --block-size $(BLOCKSIZE:%k=%Ki) \
  46. --size-in-blocks $$((1024 * $(CONFIG_TARGET_KERNEL_PARTSIZE))) \
  47. --squash-uids \
  48. --root [email protected] [email protected]
  49. # The device firmware needs revision 1 of EXT2
  50. tune2fs -O filetype [email protected]
  51. e2fsck -pDf [email protected] > /dev/null
  52. ./dns313_gen_hdd_img.sh $@ [email protected] $(IMAGE_ROOTFS) \
  53. $(CONFIG_TARGET_KERNEL_PARTSIZE) \
  54. $(CONFIG_TARGET_ROOTFS_PARTSIZE)
  55. rm -rf [email protected]
  56. endef
  57. define Build/wiligear-image
  58. $(STAGING_DIR_HOST)/bin/mkfwimage2 \
  59. -m GEOS -f 0x30000000 -z \
  60. -v $(1).v5.00.SL3512.OpenWrt.00000.000000.000000 \
  61. -p Kernel:0x020000:0x100000:0:0:$(IMAGE_KERNEL) \
  62. -p Ramdisk:0x120000:0x500000:0:0:$@ \
  63. -o [email protected]
  64. mv [email protected] $@
  65. endef
  66. # Create the default image format used by the StorLink reference design
  67. # SL93512r, Raidsonic NAS4220B and Itian Square One SQ201
  68. # with the squashfs and overlay inside the "application" partition.
  69. #
  70. # These devices have a hard-coded partition table that the boot loader
  71. # constantly reflashes back, so we need to work around it like this:
  72. #
  73. # 0x000000120000-0x000000320000 : "Kern" - small copy routine and first
  74. # part of the kernel goes here
  75. # 0x000000320000-0x000000920000 : "Ramdisk" - second part of the kernel and
  76. # some padding goes here
  77. # 0x000000920000-0x000000f20000 : "Application" - rootfs goes here
  78. define Build/storlink-default-images
  79. mkdir -p [email protected]
  80. # "App" partition is the rootfs
  81. mv $@ [email protected]/hddapp.tgz
  82. # 256 bytes copy routine
  83. dd if=$(KDIR)/copy-kernel.bin [email protected]/zImage
  84. $(call Image/pad-to,[email protected]/zImage,512)
  85. # Copy first part of the kernel into zImage
  86. dd if=$(IMAGE_KERNEL) [email protected]/zImage bs=1 seek=512 count=2096640
  87. # Put the rest of the kernel into the "ramdisk"
  88. dd if=$(IMAGE_KERNEL) [email protected]/rd.gz bs=1 skip=2096640 count=6144k conv=sync
  89. cp ./ImageInfo-$(1) [email protected]/ImageInfo
  90. sed -i -e "s/DATESTR/`date +%Y%m%d $(if $(SOURCE_DATE_EPOCH),--date "@$(SOURCE_DATE_EPOCH)")`/g" [email protected]/ImageInfo
  91. (cd [email protected]; tar --sort=name --owner=0 --group=0 --numeric-owner -czf $@ * \
  92. $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)"))
  93. rm -rf [email protected]
  94. endef
  95. # WBD-111 and WBD-222:
  96. # work around the bootloader's bug with extra nops
  97. # FIXME: is this really needed now that we no longer append the code
  98. # to change the machine ID number? Needs testing on Wiliboard.
  99. define Build/wbd-nops
  100. mv $@ [email protected]
  101. echo -en "\x00\x00\xa0\xe1\x00\x00\xa0\xe1\x00\x00\xa0\xe1\x00\x00\xa0\xe1" > $@
  102. cat [email protected] >> $@
  103. rm -f [email protected]
  104. endef
  105. # All DTB files are prefixed with "gemini-"
  106. define Device/Default
  107. PROFILES := Default
  108. KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
  109. KERNEL_NAME := zImage
  110. KERNEL := kernel-bin | append-dtb
  111. BLOCKSIZE := 128k
  112. SUPPORTED_DEVICES := $(subst _,$(comma),$(1))
  113. endef
  114. # A reasonable set of default packages handling the NAS type
  115. # of devices out of the box (former NAS42x0 IcyBox defaults)
  116. GEMINI_NAS_PACKAGES:=kmod-md-mod kmod-md-linear kmod-md-multipath \
  117. kmod-md-raid0 kmod-md-raid1 kmod-md-raid10 kmod-md-raid456 \
  118. kmod-fs-btrfs kmod-fs-cifs kmod-fs-nfs \
  119. kmod-fs-nfsd kmod-fs-ntfs kmod-fs-reiserfs kmod-fs-vfat \
  120. kmod-nls-utf8 kmod-usb-storage-extras \
  121. samba36-server mdadm cfdisk fdisk e2fsprogs badblocks \
  122. partx-utils
  123. # The DIR-685 flash layout is kernel in WRGG format, padded and followed
  124. # by the appended rootfs followed by some reasonable JFFS padding, the
  125. # remainder will be used by JFFS2 through overlayfs.
  126. #
  127. # - For the factory image, the WRGG image includes the rootfs so that the
  128. # default firmware will flash it properly as all it knows is WRGG format.
  129. # - For the sysupgrade, we do not include the rootfs in the kernel image
  130. # so it is not needelessly tossed into the RAM by the boot loader.
  131. # This will be flashed from OpenWrt userland anyways so we only need
  132. # the minimum to make the boot loader happy.
  133. define Device/dlink_dir-685
  134. DEVICE_VENDOR := D-Link
  135. DEVICE_MODEL := DIR-685 Xtreme N Storage Router
  136. DEVICE_DTS := gemini-dlink-dir-685
  137. DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) \
  138. kmod-rt2800-pci
  139. IMAGES := factory.bin sysupgrade.bin
  140. # Pad to 128k erase blocks with 160 bytes WRGG header
  141. IMAGE/factory.bin := append-kernel | pad-offset 128k 160 | append-rootfs | dir685-pad-rootfs | dir685-image
  142. IMAGE/sysupgrade.bin := append-kernel | pad-offset 128k 160 | dir685-image | append-rootfs | dir685-pad-rootfs | append-metadata
  143. endef
  144. TARGET_DEVICES += dlink_dir-685
  145. define Device/dlink_dns-313
  146. DEVICE_VENDOR := D-Link
  147. DEVICE_MODEL := DNS-313 1-Bay Network Storage Enclosure
  148. DEVICE_DTS := gemini-dlink-dns-313
  149. DEVICE_TYPE := nas
  150. DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES)
  151. BLOCKSIZE := 1k
  152. FILESYSTEMS := ext4
  153. IMAGES := factory.bin.gz
  154. IMAGE/factory.bin.gz := dns313-images | gzip
  155. endef
  156. TARGET_DEVICES += dlink_dns-313
  157. # Default images setup used by the StorLink reference designs
  158. define Device/storlink-reference
  159. COMPILE := copy-kernel-$(1).bin
  160. COMPILE/copy-kernel-$(1).bin := copy-kernel.bin
  161. IMAGES := factory.bin
  162. IMAGE/factory.bin := append-rootfs | pad-rootfs | pad-to 6144k | \
  163. storlink-default-images $(1)
  164. DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES)
  165. endef
  166. define Device/itian_sq201
  167. $(Device/storlink-reference)
  168. DEVICE_VENDOR := ITian
  169. DEVICE_MODEL := Square One SQ201
  170. DEVICE_DTS := gemini-sq201
  171. DEVICE_PACKAGES += kmod-rt61-pci kmod-usb2-pci
  172. endef
  173. TARGET_DEVICES += itian_sq201
  174. define Device/raidsonic_ib-4220-b
  175. $(Device/storlink-reference)
  176. DEVICE_VENDOR := Raidsonic
  177. DEVICE_MODEL := NAS IB-4220-B
  178. DEVICE_DTS := gemini-nas4220b
  179. DEVICE_TYPE := nas
  180. endef
  181. TARGET_DEVICES += raidsonic_ib-4220-b
  182. define Device/storlink_sl93512r
  183. $(Device/storlink-reference)
  184. DEVICE_VENDOR := StorLink
  185. DEVICE_MODEL := SL93512r
  186. DEVICE_DTS := gemini-sl93512r
  187. endef
  188. TARGET_DEVICES += storlink_sl93512r
  189. # The wiliboard images need some changes to be functional and buildable.
  190. #
  191. # The dts would need to use the ecoscentric,redboot-fis-partitions partition
  192. # parser to get the correct partition offsets and size.
  193. #
  194. # The mkfwimage2 call need to be adjusted to reflect the real size of kernel
  195. # and rootfs. It is expected that the OEM firmware adjusts the on flash
  196. # partition table with the values defined in the image header.
  197. define Device/wiliboard_wbd111
  198. DEVICE_VENDOR := Wiliboard
  199. DEVICE_MODEL := WBD-111
  200. DEVICE_DTS := gemini-wbd111
  201. KERNEL := kernel-bin | append-dtb | wbd-nops
  202. IMAGES := factory.bin
  203. IMAGE/factory.bin := append-rootfs | pad-rootfs | wiligear-image "WILI-S.WILIBOARD"
  204. endef
  205. define Device/wiliboard_wbd222
  206. DEVICE_VENDOR := Wiliboard
  207. DEVICE_MODEL := WBD-222
  208. DEVICE_DTS := gemini-wbd222
  209. KERNEL := kernel-bin | append-dtb | wbd-nops
  210. IMAGES := factory.bin
  211. IMAGE/factory.bin := append-rootfs | pad-rootfs | wiligear-image "WILI-S.WBD222"
  212. endef
  213. $(eval $(call BuildImage))