1
0

Makefile 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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)$(ADK_TARGET_SYSTEM_QEMU_ARM_VERSATILEPB_NOMMU),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_BANANA_PRO),y)
  79. @echo "Use following command to install it on SD card:"
  80. @echo "sudo ./scripts/install.sh banana-pro /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  81. @echo "Use following command to install with a writable data partition"
  82. @echo "sudo ./scripts/install.sh -d 256 banana-pro /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  83. endif
  84. ifeq ($(ADK_TARGET_SYSTEM_ORANGE_PI0),y)
  85. @echo "Use following command to install it on SD card:"
  86. @echo "sudo ./scripts/install.sh orange-pi0 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  87. @echo "Use following command to install with a writable data partition"
  88. @echo "sudo ./scripts/install.sh -d 256 orange-pi0 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  89. endif
  90. endif
  91. ifeq ($(ADK_TARGET_FS),initramfs)
  92. targethelp:
  93. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  94. @echo 'The initramfs image is: ${FW_DIR}/${INITRAMFS}'
  95. ifeq ($(ADK_TARGET_QEMU),y)
  96. @echo "Start qemu with following command line:"
  97. @echo 'qemu-system-arm ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL) -initrd ${FW_DIR}/${INITRAMFS}'
  98. endif
  99. endif
  100. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  101. targethelp:
  102. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  103. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSUSERTARBALL)"
  104. endif
  105. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  106. targethelp:
  107. @echo 'The kernel+initramfs file is: $(FW_DIR)/${TARGET_KERNEL}'
  108. ifeq ($(ADK_TARGET_QEMU),y)
  109. @echo "Start qemu with following command line:"
  110. @echo 'qemu-system-arm ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL)'
  111. endif
  112. endif
  113. ifeq ($(ADK_TARGET_FS),nfsroot)
  114. targethelp:
  115. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  116. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSUSERTARBALL)"
  117. ifeq ($(ADK_TARGET_SYSTEM_LINKSYS_NSLU2),y)
  118. @echo "Use following in RedBoot bootloader:"
  119. @echo "RedBoot> ip_address -l <localip> -h <serverip>; load -r -v -b 0x01d00000 ${TARGET_KERNEL}; exec 0x01d00000"
  120. endif
  121. endif
  122. ifeq ($(ADK_TARGET_FS),squashfs)
  123. targethelp:
  124. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  125. @echo "The RootFS image is: $(FW_DIR)/$(ROOTFSSQUASHFS)"
  126. ifeq ($(ADK_TARGET_QEMU),y)
  127. @echo "Start qemu with following options:"
  128. @echo 'qemu-system-arm $(QEMU_ARGS) -nographic -kernel $(FW_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(ROOTFSSQUASHFS)'
  129. endif
  130. endif
  131. ifeq ($(ADK_TARGET_FS),jffs2)
  132. targethelp:
  133. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  134. @echo "The RootFS image is: $(FW_DIR)/$(ROOTFSJFFS2)"
  135. ifeq ($(ADK_TARGET_QEMU),y)
  136. @echo "Start qemu with following options:"
  137. @echo 'qemu-system-arm $(QEMU_ARGS) -nographic -kernel $(FW_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(ROOTFSJFFS2)'
  138. endif
  139. endif
  140. ifeq ($(ADK_TARGET_FS),genimage)
  141. targethelp:
  142. @echo "The disk image is: $(FW_DIR)/disk.img"
  143. @echo "Use following command to install it on SD card:"
  144. @echo 'sudo dd if=$(FW_DIR)/disk.img of=/dev/sdX bs=2048k'
  145. endif
  146. kernel-strip:
  147. ifeq ($(ADK_TARGET_KERNEL_GIT_REPO_NAME),rpi)
  148. @echo adding DT trailer to kernel $(MAKE_TRACE)
  149. PATH='$(HOST_PATH)' perl $(LINUX_DIR)/scripts/mkknlimg $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL) $(MAKE_TRACE)
  150. else
  151. @cp $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL)
  152. endif
  153. kernel-install: kernel-strip
  154. @cp $(BUILD_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(TARGET_KERNEL)
  155. ifeq ($(ADK_TARGET_FS),squashfs)
  156. env PATH=$(HOST_PATH) qemu-img create -f raw $(FW_DIR)/$(ROOTFSSQUASHFS) $(ADK_TARGET_MTD_SIZE)
  157. dd conv=notrunc if=$(BUILD_DIR)/root.squashfs of=$(FW_DIR)/$(ROOTFSSQUASHFS)
  158. endif
  159. dtb-install:
  160. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_XILINX_ZYNQ),y)
  161. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  162. dtbs $(MAKE_TRACE)
  163. endif
  164. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VEXPRESS_A9),y)
  165. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  166. dtbs $(MAKE_TRACE)
  167. endif
  168. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_REALVIEW_EB_MPCORE),y)
  169. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  170. arm-realview-eb-11mp-ctrevb.dtb $(MAKE_TRACE)
  171. endif
  172. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VERSATILEPB)$(ADK_TARGET_SYSTEM_QEMU_ARM_VERSATILEPB_NOMMU),y)
  173. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  174. versatile-pb.dtb $(MAKE_TRACE)
  175. endif
  176. ifeq ($(ADK_TARGET_SYSTEM_PHYTEC_WEGA),y)
  177. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  178. am335x-wega-rdk.dtb
  179. cp $(LINUX_DIR)/arch/arm/boot/dts/am335x-wega-rdk.dtb ${TARGET_DIR}/boot
  180. endif
  181. ifeq ($(ADK_TARGET_SYSTEM_BEAGLEBONE_BLACK),y)
  182. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  183. am335x-boneblack.dtb
  184. cp $(LINUX_DIR)/arch/arm/boot/dts/am335x-boneblack.dtb ${TARGET_DIR}/boot
  185. endif
  186. ifeq ($(ADK_TARGET_BOARD_BCM28XX),y)
  187. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  188. dtbs $(MAKE_TRACE)
  189. mkdir -p $(FW_DIR)/overlays
  190. for x in $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtbo; do \
  191. [[ -e "$$x" ]] && cp $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtbo $(FW_DIR)/overlays; \
  192. break; \
  193. done
  194. endif
  195. ifeq ($(ADK_TARGET_SYSTEM_BANANA_PRO),y)
  196. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  197. sun7i-a20-bananapro.dtb $(MAKE_TRACE)
  198. endif
  199. ifeq ($(ADK_TARGET_SYSTEM_ORANGE_PI0),y)
  200. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  201. sun8i-h2-plus-orangepi-zero.dtb $(MAKE_TRACE)
  202. endif
  203. ifeq ($(ADK_TARGET_SYSTEM_SOLIDRUN_IMX6),y)
  204. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  205. imx6q-cubox-i.dtb imx6dl-cubox-i.dtb imx6dl-hummingboard.dtb imx6q-hummingboard.dtb $(MAKE_TRACE)
  206. endif
  207. ifeq ($(ADK_TARGET_SYSTEM_SOLIDRUN_CLEARFOG),y)
  208. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  209. armada-388-clearfog.dtb $(MAKE_TRACE)
  210. endif
  211. ifeq ($(ADK_TARGET_SYSTEM_ST_STM32F769),y)
  212. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  213. dtbs $(MAKE_TRACE)
  214. endif
  215. for x in $(LINUX_DIR)/arch/arm/boot/dts/*.dtb; do \
  216. [[ -e "$$x" ]] && cp $(LINUX_DIR)/arch/arm/boot/dts/*.dtb $(FW_DIR); \
  217. break; \
  218. done
  219. # filesystem specific targets
  220. ifeq ($(ADK_TARGET_FS),archive)
  221. imageinstall: dtb-install $(FW_DIR)/$(ROOTFSTARBALL) targethelp
  222. endif
  223. ifeq ($(ADK_TARGET_FS),initramfs)
  224. imageinstall: kernel-install dtb-install $(FW_DIR)/$(INITRAMFS) targethelp
  225. endif
  226. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  227. imageinstall: kernel-install dtb-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  228. endif
  229. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  230. imageinstall: dtb-install createinitramfs targethelp
  231. endif
  232. ifeq (${ADK_TARGET_FS},genimage)
  233. imageinstall: dtb-install $(FW_DIR)/$(GENIMAGE) targethelp
  234. endif
  235. ifeq ($(ADK_TARGET_FS),nfsroot)
  236. imageinstall: kernel-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  237. endif
  238. ifeq ($(ADK_TARGET_FS),squashfs)
  239. imageinstall: $(BUILD_DIR)/root.squashfs kernel-install dtb-install targethelp
  240. endif
  241. ifeq ($(ADK_TARGET_FS),jffs2)
  242. imageinstall: kernel-install dtb-install $(FW_DIR)/$(ROOTFSJFFS2) targethelp
  243. endif
  244. ifeq ($(ADK_TARGET_FS),usb)
  245. imageinstall: $(FW_DIR)/$(ROOTFSTARBALL) targethelp
  246. endif