Makefile 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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
  31. endif
  32. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VERSATILEPB)$(ADK_TARGET_SYSTEM_QEMU_ARM_VERSATILEPB_NOMMU),y)
  33. ifeq ($(ADK_TARGET_WITH_DEVICETREE),y)
  34. QEMU_ARGS+=-M versatilepb -net user -net nic,model=smc91c111 -dtb $(FW_DIR)/versatile-pb.dtb
  35. else
  36. QEMU_ARGS+=-M versatilepb -net user -net nic,model=smc91c111
  37. endif
  38. endif
  39. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VEXPRESS_A9),y)
  40. QEMU_ARGS+=-M vexpress-a9 -cpu cortex-a9 -m 256 -net user -net nic,model=lan9118 -dtb $(FW_DIR)/vexpress-v2p-ca9.dtb
  41. ifeq ($(ADK_TARGET_ROOTFS_ARCHIVE),y)
  42. QEMU_ARGS+=-drive file=qemu-arm.img,if=sd,format=raw
  43. endif
  44. endif
  45. ifeq ($(ADK_TARGET_QEMU_WITH_VIRTIO),y)
  46. QEMU_ARGS+=-drive file=qemu-${ADK_TARGET_CPU_ARCH}.img,if=virtio,index=0 -net nic,model=virtio -net user
  47. endif
  48. # target helper text
  49. ifeq ($(ADK_TARGET_FS),archive)
  50. targethelp:
  51. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSTARBALL)"
  52. 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)
  53. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  54. @echo "Use following command to create a QEMU Image:"
  55. @echo "./scripts/create.sh qemu-${ADK_TARGET_CPU_ARCH}.img $(FW_DIR)/$(ROOTFSTARBALL)"
  56. @echo "Start qemu with following options:"
  57. @echo 'qemu-system-${ADK_TARGET_CPU_ARCH} ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL) qemu-${ADK_TARGET_CPU_ARCH}.img'
  58. endif
  59. ifeq ($(ADK_TARGET_BOARD_BCM28XX)$(ADK_TARGET_SYSTEM_SOLIDRUN_IMX6)$(ADK_TARGET_SYSTEM_SOLIDRUN_CLEARFOG),y)
  60. ifeq ($(ADK_RUNTIME_DATA_PARTITION),y)
  61. @echo "Use following command to install with a writable data partition"
  62. @echo "sudo ./scripts/install.sh -d 256 $(ADK_TARGET_SYSTEM) /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  63. @echo "If you want to update a card without loosing existing data on the writable partition use:"
  64. @echo "sudo ./scripts/install.sh -k -d 256 $(ADK_TARGET_SYSTEM) /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  65. @echo "In both cases the cfgfs partition is _not_ removed!"
  66. else
  67. @echo "Use following command to install it on SD card:"
  68. @echo "sudo ./scripts/install.sh $(ADK_TARGET_SYSTEM) /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  69. endif
  70. endif
  71. ifeq ($(ADK_TARGET_SYSTEM_BANANA_PRO),y)
  72. @echo "Use following command to install it on SD card:"
  73. @echo "sudo ./scripts/install.sh banana-pro /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  74. @echo "Use following command to install with a writable data partition"
  75. @echo "sudo ./scripts/install.sh -d 256 banana-pro /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  76. endif
  77. ifeq ($(ADK_TARGET_SYSTEM_ORANGE_PI0),y)
  78. @echo "Use following command to install it on SD card:"
  79. @echo "sudo ./scripts/install.sh orange-pi0 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  80. @echo "Use following command to install with a writable data partition"
  81. @echo "sudo ./scripts/install.sh -d 256 orange-pi0 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  82. endif
  83. endif
  84. ifeq ($(ADK_TARGET_FS),initramfs)
  85. targethelp:
  86. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  87. @echo 'The initramfs image is: ${FW_DIR}/${INITRAMFS}'
  88. ifeq ($(ADK_TARGET_QEMU),y)
  89. @echo "Start qemu with following command line:"
  90. @echo 'qemu-system-arm ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL) -initrd ${FW_DIR}/${INITRAMFS}'
  91. endif
  92. endif
  93. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  94. targethelp:
  95. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  96. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSUSERTARBALL)"
  97. endif
  98. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  99. targethelp:
  100. @echo 'The kernel+initramfs file is: $(FW_DIR)/${TARGET_KERNEL}'
  101. ifeq ($(ADK_TARGET_QEMU),y)
  102. @echo "Start qemu with following command line:"
  103. @echo 'qemu-system-arm ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL)'
  104. endif
  105. endif
  106. ifeq ($(ADK_TARGET_FS),nfsroot)
  107. targethelp:
  108. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  109. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSUSERTARBALL)"
  110. ifeq ($(ADK_TARGET_SYSTEM_LINKSYS_NSLU2),y)
  111. @echo "Use following in RedBoot bootloader:"
  112. @echo "RedBoot> ip_address -l <localip> -h <serverip>; load -r -v -b 0x01d00000 ${TARGET_KERNEL}; exec 0x01d00000"
  113. endif
  114. endif
  115. ifeq ($(ADK_TARGET_FS),squashfs)
  116. targethelp:
  117. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  118. @echo "The RootFS image is: $(FW_DIR)/$(ROOTFSSQUASHFS)"
  119. ifeq ($(ADK_TARGET_QEMU),y)
  120. @echo "Start qemu with following options:"
  121. @echo 'qemu-system-arm $(QEMU_ARGS) -nographic -kernel $(FW_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(ROOTFSSQUASHFS)'
  122. endif
  123. endif
  124. ifeq ($(ADK_TARGET_FS),jffs2)
  125. targethelp:
  126. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  127. @echo "The RootFS image is: $(FW_DIR)/$(ROOTFSJFFS2)"
  128. ifeq ($(ADK_TARGET_QEMU),y)
  129. @echo "Start qemu with following options:"
  130. @echo 'qemu-system-arm $(QEMU_ARGS) -nographic -kernel $(FW_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(ROOTFSJFFS2)'
  131. endif
  132. endif
  133. ifeq ($(ADK_TARGET_FS),genimage)
  134. targethelp:
  135. @echo "The disk image is: $(FW_DIR)/disk.img"
  136. @echo "Use following command to install it on SD card:"
  137. @echo 'sudo dd if=$(FW_DIR)/disk.img of=/dev/sdX bs=2048k'
  138. endif
  139. kernel-strip:
  140. ifeq ($(ADK_TARGET_KERNEL_GIT_REPO_NAME),rpi)
  141. @echo adding DT trailer to kernel $(MAKE_TRACE)
  142. PATH='$(HOST_PATH)' perl $(LINUX_DIR)/scripts/mkknlimg $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL) $(MAKE_TRACE)
  143. else
  144. @cp $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL)
  145. endif
  146. kernel-install: kernel-strip
  147. @cp $(BUILD_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(TARGET_KERNEL)
  148. ifeq ($(ADK_TARGET_FS),squashfs)
  149. env PATH=$(HOST_PATH) qemu-img create -f raw $(FW_DIR)/$(ROOTFSSQUASHFS) $(ADK_TARGET_MTD_SIZE)
  150. dd conv=notrunc if=$(BUILD_DIR)/root.squashfs of=$(FW_DIR)/$(ROOTFSSQUASHFS)
  151. endif
  152. dtb-install:
  153. ifeq ($(ADK_TARGET_WITH_DEVICETREE),y)
  154. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_XILINX_ZYNQ),y)
  155. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  156. dtbs $(MAKE_TRACE)
  157. endif
  158. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VEXPRESS_A9),y)
  159. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  160. dtbs $(MAKE_TRACE)
  161. endif
  162. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VERSATILEPB)$(ADK_TARGET_SYSTEM_QEMU_ARM_VERSATILEPB_NOMMU),y)
  163. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  164. dtbs $(MAKE_TRACE)
  165. endif
  166. ifeq ($(ADK_TARGET_SYSTEM_BEAGLEBONE_BLACK),y)
  167. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  168. am335x-boneblack.dtb
  169. cp $(LINUX_DIR)/arch/arm/boot/dts/am335x-boneblack.dtb ${TARGET_DIR}/boot
  170. endif
  171. ifeq ($(ADK_TARGET_BOARD_BCM28XX),y)
  172. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  173. dtbs $(MAKE_TRACE)
  174. mkdir -p $(FW_DIR)/overlays
  175. for x in $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtbo; do \
  176. [[ -e "$$x" ]] && cp $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtbo $(FW_DIR)/overlays; \
  177. break; \
  178. done
  179. endif
  180. ifeq ($(ADK_TARGET_SYSTEM_BANANA_PRO),y)
  181. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  182. sun7i-a20-bananapro.dtb $(MAKE_TRACE)
  183. endif
  184. ifeq ($(ADK_TARGET_SYSTEM_ORANGE_PI0),y)
  185. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  186. sun8i-h2-plus-orangepi-zero.dtb $(MAKE_TRACE)
  187. endif
  188. ifeq ($(ADK_TARGET_SYSTEM_SOLIDRUN_IMX6),y)
  189. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  190. imx6q-cubox-i.dtb imx6dl-cubox-i.dtb imx6dl-hummingboard.dtb imx6q-hummingboard.dtb $(MAKE_TRACE)
  191. endif
  192. ifeq ($(ADK_TARGET_SYSTEM_SOLIDRUN_CLEARFOG),y)
  193. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  194. armada-388-clearfog.dtb $(MAKE_TRACE)
  195. endif
  196. ifeq ($(ADK_TARGET_SYSTEM_ST_STM32F769),y)
  197. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  198. dtbs $(MAKE_TRACE)
  199. endif
  200. for x in $(LINUX_DIR)/arch/arm/boot/dts/*.dtb; do \
  201. [[ -e "$$x" ]] && cp $(LINUX_DIR)/arch/arm/boot/dts/*.dtb $(FW_DIR); \
  202. break; \
  203. done
  204. endif
  205. # filesystem specific targets
  206. ifeq ($(ADK_TARGET_FS),archive)
  207. imageinstall: dtb-install $(FW_DIR)/$(ROOTFSTARBALL) targethelp
  208. endif
  209. ifeq ($(ADK_TARGET_FS),initramfs)
  210. imageinstall: kernel-install dtb-install $(FW_DIR)/$(INITRAMFS) targethelp
  211. endif
  212. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  213. imageinstall: kernel-install dtb-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  214. endif
  215. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  216. imageinstall: dtb-install createinitramfs targethelp
  217. endif
  218. ifeq (${ADK_TARGET_FS},genimage)
  219. imageinstall: dtb-install $(FW_DIR)/$(GENIMAGE) targethelp
  220. endif
  221. ifeq ($(ADK_TARGET_FS),nfsroot)
  222. imageinstall: kernel-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  223. endif
  224. ifeq ($(ADK_TARGET_FS),squashfs)
  225. imageinstall: $(BUILD_DIR)/root.squashfs kernel-install dtb-install targethelp
  226. endif
  227. ifeq ($(ADK_TARGET_FS),jffs2)
  228. imageinstall: kernel-install dtb-install $(FW_DIR)/$(ROOTFSJFFS2) targethelp
  229. endif
  230. ifeq ($(ADK_TARGET_FS),usb)
  231. imageinstall: $(FW_DIR)/$(ROOTFSTARBALL) targethelp
  232. endif