1
0

Makefile 9.0 KB

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