Makefile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. # This file is part of the OpenADK project. OpenADK is copyrighted
  2. # material, please see the LICENCE file in the top-level directory.
  3. include $(ADK_TOPDIR)/rules.mk
  4. include $(ADK_TOPDIR)/mk/kernel-build.mk
  5. include $(ADK_TOPDIR)/mk/image.mk
  6. KERNEL:=$(LINUX_DIR)/$(ADK_TARGET_KERNEL)
  7. ifeq ($(ADK_TARGET_KERNEL_ZIMAGE),y)
  8. KERNEL:=$(LINUX_DIR)/arch/arm/boot/zImage
  9. endif
  10. ifeq ($(ADK_TARGET_KERNEL_UIMAGE),y)
  11. KERNEL:=$(LINUX_DIR)/arch/arm/boot/uImage
  12. endif
  13. ifeq ($(ADK_TARGET_KERNEL_XIPIMAGE),y)
  14. KERNEL:=$(LINUX_DIR)/arch/arm/boot/xipImage
  15. endif
  16. ifeq ($(ADK_TARGET_KERNEL_IMAGE),y)
  17. KERNEL:=$(LINUX_DIR)/arch/arm/boot/Image
  18. endif
  19. QEMU_ARGS:=${ADK_QEMU_ARGS}
  20. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_XILINX_ZYNQ),y)
  21. QEMU_ARGS+=-M xilinx-zynq-a9 -dtb $(FW_DIR)/zynq-zc702.dtb -serial null -serial mon:stdio
  22. endif
  23. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_SPITZ),y)
  24. QEMU_ARGS+=-M spitz
  25. endif
  26. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_TERRIER),y)
  27. QEMU_ARGS+=-M terrier
  28. endif
  29. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_REALVIEW_EB_MPCORE),y)
  30. QEMU_ARGS+=-M realview-eb-mpcore -net user -net nic -dtb $(FW_DIR)/arm-realview-eb-11mp-ctrevb.dtb
  31. endif
  32. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VERSATILEPB),y)
  33. QEMU_ARGS+=-M versatilepb -net user -net nic,model=smc91c111 -dtb $(FW_DIR)/versatile-pb.dtb
  34. endif
  35. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VEXPRESS_A9),y)
  36. QEMU_ARGS+=-M vexpress-a9 -cpu cortex-a9 -m 256 -net user -net nic,model=lan9118 -dtb $(FW_DIR)/vexpress-v2p-ca9.dtb
  37. ifeq ($(ADK_TARGET_ROOTFS_ARCHIVE),y)
  38. QEMU_ARGS+=-drive file=qemu-arm.img,if=sd,format=raw
  39. endif
  40. endif
  41. ifeq ($(ADK_TARGET_QEMU_WITH_VIRTIO),y)
  42. QEMU_ARGS+=-drive file=qemu-${ADK_TARGET_CPU_ARCH}.img,if=virtio,index=0 -net nic,model=virtio -net user
  43. endif
  44. # target helper text
  45. ifeq ($(ADK_TARGET_FS),archive)
  46. targethelp:
  47. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSTARBALL)"
  48. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VEXPRESS_A9)$(ADK_TARGET_SYSTEM_QEMU_ARM_VERSATILEPB)$(ADK_TARGET_SYSTEM_QEMU_ARM_TERRIER)$(ADK_TARGET_SYSTEM_QEMU_ARM_SPITZ),y)
  49. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  50. @echo "Use following command to create a QEMU Image:"
  51. @echo "./scripts/create.sh qemu-${ADK_TARGET_CPU_ARCH}.img $(FW_DIR)/$(ROOTFSTARBALL)"
  52. @echo "Start qemu with following options:"
  53. @echo 'qemu-system-${ADK_TARGET_CPU_ARCH} ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL) qemu-${ADK_TARGET_CPU_ARCH}.img'
  54. endif
  55. ifeq ($(ADK_TARGET_BOARD_BCM28XX)$(ADK_TARGET_SYSTEM_SOLIDRUN_IMX6)$(ADK_TARGET_SYSTEM_SOLIDRUN_CLEARFOG),y)
  56. ifeq ($(ADK_RUNTIME_DATA_PARTITION),y)
  57. @echo "Use following command to install with a writable data partition"
  58. @echo "sudo ./scripts/install.sh -d 256 $(ADK_TARGET_SYSTEM) /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  59. @echo "If you want to update a card without loosing existing data on the writable partition use:"
  60. @echo "sudo ./scripts/install.sh -k -d 256 $(ADK_TARGET_SYSTEM) /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  61. @echo "In both cases the cfgfs partition is _not_ removed!"
  62. else
  63. @echo "Use following command to install it on SD card:"
  64. @echo "sudo ./scripts/install.sh $(ADK_TARGET_SYSTEM) /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  65. endif
  66. endif
  67. ifeq ($(ADK_TARGET_SYSTEM_PHYTEC_WEGA),y)
  68. @echo "Use following command to install it on SD card:"
  69. @echo "sudo ./scripts/install.sh phytec-wega /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  70. @echo "Use following command to install with a writable data partition"
  71. @echo "sudo ./scripts/install.sh -d 256 phytec-wega /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  72. @echo
  73. @echo "To boot from SD card do following in barebox bootloader:"
  74. @echo "mount /dev/mmc0.0 /mnt"
  75. @echo "bootm -o /mnt/am335x-wega-rdk.dtb /mnt/kernel"
  76. @echo
  77. endif
  78. ifeq ($(ADK_TARGET_SYSTEM_PHYTEC_IMX6),y)
  79. @echo "Use following command to install it on SD card:"
  80. @echo "sudo ./scripts/install.sh phytec-mira /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  81. @echo
  82. endif
  83. ifeq ($(ADK_TARGET_SYSTEM_BANANA_PRO),y)
  84. @echo "Use following command to install it on SD card:"
  85. @echo "sudo ./scripts/install.sh banana-pro /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  86. @echo "Use following command to install with a writable data partition"
  87. @echo "sudo ./scripts/install.sh -d 256 banana-pro /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  88. endif
  89. ifeq ($(ADK_TARGET_SYSTEM_ORANGE_PI0),y)
  90. @echo "Use following command to install it on SD card:"
  91. @echo "sudo ./scripts/install.sh orange-pi0 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  92. @echo "Use following command to install with a writable data partition"
  93. @echo "sudo ./scripts/install.sh -d 256 orange-pi0 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  94. endif
  95. endif
  96. ifeq ($(ADK_TARGET_FS),initramfs)
  97. targethelp:
  98. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  99. @echo 'The initramfs image is: ${FW_DIR}/${INITRAMFS}'
  100. ifeq ($(ADK_TARGET_QEMU),y)
  101. @echo "Start qemu with following command line:"
  102. @echo 'qemu-system-arm ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL) -initrd ${FW_DIR}/${INITRAMFS}'
  103. endif
  104. endif
  105. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  106. targethelp:
  107. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  108. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSUSERTARBALL)"
  109. endif
  110. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  111. targethelp:
  112. @echo 'The kernel+initramfs file is: $(FW_DIR)/${TARGET_KERNEL}'
  113. ifeq ($(ADK_TARGET_QEMU),y)
  114. @echo "Start qemu with following command line:"
  115. @echo 'qemu-system-arm ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL)'
  116. endif
  117. endif
  118. ifeq ($(ADK_TARGET_FS),nfsroot)
  119. targethelp:
  120. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  121. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSUSERTARBALL)"
  122. ifeq ($(ADK_TARGET_SYSTEM_LINKSYS_NSLU2),y)
  123. @echo "Use following in RedBoot bootloader:"
  124. @echo "RedBoot> ip_address -l <localip> -h <serverip>; load -r -v -b 0x01d00000 ${TARGET_KERNEL}; exec 0x01d00000"
  125. endif
  126. endif
  127. ifeq ($(ADK_TARGET_FS),squashfs)
  128. targethelp:
  129. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  130. @echo "The RootFS image is: $(FW_DIR)/$(ROOTFSSQUASHFS)"
  131. ifeq ($(ADK_TARGET_QEMU),y)
  132. @echo "Start qemu with following options:"
  133. @echo 'qemu-system-arm $(QEMU_ARGS) -nographic -kernel $(FW_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(ROOTFSSQUASHFS)'
  134. endif
  135. endif
  136. ifeq ($(ADK_TARGET_FS),jffs2)
  137. targethelp:
  138. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  139. @echo "The RootFS image is: $(FW_DIR)/$(ROOTFSJFFS2)"
  140. ifeq ($(ADK_TARGET_QEMU),y)
  141. @echo "Start qemu with following options:"
  142. @echo 'qemu-system-arm $(QEMU_ARGS) -nographic -kernel $(FW_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(ROOTFSJFFS2)'
  143. endif
  144. endif
  145. ifeq ($(ADK_TARGET_FS),genimage)
  146. targethelp:
  147. @echo "The disk image is: $(FW_DIR)/disk.img"
  148. @echo "Use following command to install it on SD card:"
  149. @echo 'sudo dd if=$(FW_DIR)/disk.img of=/dev/sdX bs=2048k'
  150. endif
  151. kernel-strip:
  152. ifeq ($(ADK_TARGET_KERNEL_GIT_REPO_NAME),rpi)
  153. @echo adding DT trailer to kernel $(MAKE_TRACE)
  154. PATH='$(HOST_PATH)' perl $(LINUX_DIR)/scripts/mkknlimg $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL) $(MAKE_TRACE)
  155. else
  156. @cp $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL)
  157. endif
  158. kernel-install: kernel-strip
  159. @cp $(BUILD_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(TARGET_KERNEL)
  160. ifeq ($(ADK_TARGET_FS),squashfs)
  161. env PATH=$(HOST_PATH) qemu-img create -f raw $(FW_DIR)/$(ROOTFSSQUASHFS) $(ADK_TARGET_MTD_SIZE)
  162. dd conv=notrunc if=$(BUILD_DIR)/root.squashfs of=$(FW_DIR)/$(ROOTFSSQUASHFS)
  163. endif
  164. dtb-install:
  165. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_XILINX_ZYNQ),y)
  166. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  167. dtbs $(MAKE_TRACE)
  168. endif
  169. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VEXPRESS_A9),y)
  170. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  171. dtbs $(MAKE_TRACE)
  172. endif
  173. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_REALVIEW_EB_MPCORE),y)
  174. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  175. arm-realview-eb-11mp-ctrevb.dtb $(MAKE_TRACE)
  176. endif
  177. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VERSATILEPB),y)
  178. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  179. versatile-pb.dtb $(MAKE_TRACE)
  180. endif
  181. ifeq ($(ADK_TARGET_SYSTEM_PHYTEC_WEGA),y)
  182. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  183. am335x-wega-rdk.dtb
  184. cp $(LINUX_DIR)/arch/arm/boot/dts/am335x-wega-rdk.dtb ${TARGET_DIR}/boot
  185. endif
  186. ifeq ($(ADK_TARGET_SYSTEM_PHYTEC_IMX6),y)
  187. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  188. imx6q-phytec-pbab01.dtb
  189. cp $(LINUX_DIR)/arch/arm/boot/dts/imx6q-phytec-pbab01.dtb ${TARGET_DIR}/boot
  190. endif
  191. ifeq ($(ADK_TARGET_SYSTEM_BEAGLEBONE_BLACK),y)
  192. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  193. am335x-boneblack.dtb
  194. cp $(LINUX_DIR)/arch/arm/boot/dts/am335x-boneblack.dtb ${TARGET_DIR}/boot
  195. endif
  196. ifeq ($(ADK_TARGET_BOARD_BCM28XX),y)
  197. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  198. dtbs $(MAKE_TRACE)
  199. mkdir -p $(FW_DIR)/overlays
  200. for x in $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtbo; do \
  201. [[ -e "$$x" ]] && cp $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtbo $(FW_DIR)/overlays; \
  202. break; \
  203. done
  204. endif
  205. ifeq ($(ADK_TARGET_SYSTEM_BANANA_PRO),y)
  206. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  207. sun7i-a20-bananapro.dtb $(MAKE_TRACE)
  208. endif
  209. ifeq ($(ADK_TARGET_SYSTEM_ORANGE_PI0),y)
  210. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  211. sun8i-h2-plus-orangepi-zero.dtb $(MAKE_TRACE)
  212. endif
  213. ifeq ($(ADK_TARGET_SYSTEM_SOLIDRUN_IMX6),y)
  214. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  215. imx6q-cubox-i.dtb imx6dl-cubox-i.dtb imx6dl-hummingboard.dtb imx6q-hummingboard.dtb $(MAKE_TRACE)
  216. endif
  217. ifeq ($(ADK_TARGET_SYSTEM_SOLIDRUN_CLEARFOG),y)
  218. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  219. armada-388-clearfog.dtb $(MAKE_TRACE)
  220. endif
  221. ifeq ($(ADK_TARGET_SYSTEM_ST_STM32F769),y)
  222. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  223. dtbs $(MAKE_TRACE)
  224. endif
  225. for x in $(LINUX_DIR)/arch/arm/boot/dts/*.dtb; do \
  226. [[ -e "$$x" ]] && cp $(LINUX_DIR)/arch/arm/boot/dts/*.dtb $(FW_DIR); \
  227. break; \
  228. done
  229. # filesystem specific targets
  230. ifeq ($(ADK_TARGET_FS),archive)
  231. imageinstall: dtb-install $(FW_DIR)/$(ROOTFSTARBALL) targethelp
  232. endif
  233. ifeq ($(ADK_TARGET_FS),initramfs)
  234. imageinstall: kernel-install dtb-install $(FW_DIR)/$(INITRAMFS) targethelp
  235. endif
  236. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  237. imageinstall: kernel-install dtb-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  238. endif
  239. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  240. imageinstall: dtb-install createinitramfs targethelp
  241. endif
  242. ifeq (${ADK_TARGET_FS},genimage)
  243. imageinstall: dtb-install $(FW_DIR)/$(GENIMAGE) targethelp
  244. endif
  245. ifeq ($(ADK_TARGET_FS),nfsroot)
  246. imageinstall: kernel-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  247. endif
  248. ifeq ($(ADK_TARGET_FS),squashfs)
  249. imageinstall: $(BUILD_DIR)/root.squashfs kernel-install dtb-install targethelp
  250. endif
  251. ifeq ($(ADK_TARGET_FS),jffs2)
  252. imageinstall: kernel-install dtb-install $(FW_DIR)/$(ROOTFSJFFS2) targethelp
  253. endif
  254. ifeq ($(ADK_TARGET_FS),usb)
  255. imageinstall: $(FW_DIR)/$(ROOTFSTARBALL) targethelp
  256. endif