Makefile 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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),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_VERSION_RPI),y)
  135. @echo adding DT trailer to kernel $(MAKE_TRACE)
  136. PATH='$(HOST_PATH)' perl $(LINUX_DIR)/scripts/mkknlimg $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL)
  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_SYSTEM_QEMU_ARM_XILINX_ZYNQ),y)
  148. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  149. dtbs $(MAKE_TRACE)
  150. endif
  151. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VEXPRESS_A9),y)
  152. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  153. dtbs $(MAKE_TRACE)
  154. endif
  155. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VERSATILEPB)$(ADK_TARGET_SYSTEM_QEMU_ARM_VERSATILEPB_NOMMU),y)
  156. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  157. dtbs $(MAKE_TRACE)
  158. endif
  159. ifeq ($(ADK_TARGET_SYSTEM_BEAGLEBONE_BLACK),y)
  160. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  161. am335x-boneblack.dtb
  162. cp $(LINUX_DIR)/arch/arm/boot/dts/am335x-boneblack.dtb ${TARGET_DIR}/boot
  163. endif
  164. ifeq ($(ADK_TARGET_BOARD_BCM28XX),y)
  165. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  166. dtbs $(MAKE_TRACE)
  167. mkdir -p $(FW_DIR)/overlays
  168. for x in $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtb; do \
  169. [[ -e "$$x" ]] && cp $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtb $(FW_DIR)/overlays; \
  170. break; \
  171. done
  172. endif
  173. ifeq ($(ADK_TARGET_SYSTEM_BANANA_PRO),y)
  174. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  175. sun7i-a20-bananapro.dtb $(MAKE_TRACE)
  176. endif
  177. ifeq ($(ADK_TARGET_SYSTEM_SOLIDRUN_IMX6),y)
  178. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  179. imx6q-cubox-i.dtb imx6dl-cubox-i.dtb imx6dl-hummingboard.dtb imx6q-hummingboard.dtb $(MAKE_TRACE)
  180. endif
  181. for x in $(LINUX_DIR)/arch/arm/boot/dts/*.dtb; do \
  182. [[ -e "$$x" ]] && cp $(LINUX_DIR)/arch/arm/boot/dts/*.dtb $(FW_DIR); \
  183. break; \
  184. done
  185. # filesystem specific targets
  186. ifeq ($(ADK_TARGET_FS),archive)
  187. imageinstall: dtb-install $(FW_DIR)/$(ROOTFSTARBALL) targethelp
  188. endif
  189. ifeq ($(ADK_TARGET_FS),initramfs)
  190. imageinstall: kernel-install dtb-install $(FW_DIR)/$(INITRAMFS) targethelp
  191. endif
  192. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  193. imageinstall: kernel-install dtb-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  194. endif
  195. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  196. imageinstall: dtb-install createinitramfs targethelp
  197. endif
  198. ifeq (${ADK_TARGET_FS},genimage)
  199. imageinstall: dtb-install $(FW_DIR)/$(GENIMAGE) targethelp
  200. endif
  201. ifeq ($(ADK_TARGET_FS),nfsroot)
  202. imageinstall: kernel-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  203. endif
  204. ifeq ($(ADK_TARGET_FS),squashfs)
  205. imageinstall: $(BUILD_DIR)/root.squashfs kernel-install dtb-install targethelp
  206. endif
  207. ifeq ($(ADK_TARGET_FS),jffs2)
  208. imageinstall: kernel-install dtb-install $(FW_DIR)/$(ROOTFSJFFS2) targethelp
  209. endif
  210. ifeq ($(ADK_TARGET_FS),usb)
  211. imageinstall: $(FW_DIR)/$(ROOTFSTARBALL) targethelp
  212. endif