Makefile 6.6 KB

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