Makefile 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. QEMU_ARGS:=${ADK_QEMU_ARGS}
  14. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_SPITZ),y)
  15. QEMU_ARGS+=-M spitz
  16. endif
  17. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_TERRIER),y)
  18. QEMU_ARGS+=-M terrier
  19. endif
  20. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_REALVIEW_EB_MPCORE),y)
  21. QEMU_ARGS+=-M realview-eb-mpcore -net user -net nic
  22. endif
  23. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VERSATILEPB),y)
  24. QEMU_ARGS+=-M versatilepb -net user -net nic,model=smc91c111
  25. endif
  26. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VEXPRESS_A9),y)
  27. QEMU_ARGS+=-M vexpress-a9 -cpu cortex-a9 -m 256 -net user -net nic,model=lan9118 -dtb $(FW_DIR)/vexpress-v2p-ca9.dtb
  28. ifeq ($(ADK_TARGET_ROOTFS_ARCHIVE),y)
  29. QEMU_ARGS+=-drive file=qemu-arm.img,if=sd,format=raw
  30. endif
  31. endif
  32. ifeq ($(ADK_TARGET_QEMU_WITH_VIRTIO),y)
  33. QEMU_ARGS+=-drive file=qemu-${ADK_TARGET_CPU_ARCH}.img,if=virtio,index=0 -net nic,model=virtio -net user
  34. endif
  35. # target helper text
  36. ifeq ($(ADK_TARGET_FS),archive)
  37. targethelp:
  38. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSTARBALL)"
  39. 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)
  40. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  41. @echo "Use following command to create a QEMU Image:"
  42. @echo "./scripts/create.sh qemu-${ADK_TARGET_CPU_ARCH}.img $(FW_DIR)/$(ROOTFSTARBALL)"
  43. @echo "Start qemu with following options:"
  44. @echo 'qemu-system-${ADK_TARGET_CPU_ARCH} ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL) qemu-${ADK_TARGET_CPU_ARCH}.img'
  45. endif
  46. ifeq ($(ADK_TARGET_SYSTEM_RASPBERRY_PI),y)
  47. ifeq ($(ADK_APPLIANCE_KODI),y)
  48. @echo "Use following command to install with a writable data partition"
  49. @echo "sudo ./scripts/install.sh -d 256 raspberry-pi /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  50. @echo "If you want to update a card without loosing existing data on the writable partition use:"
  51. @echo "sudo ./scripts/install.sh -k -d 256 raspbrry-pi /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  52. @echo "In both cases the cfgfs partition is _not_ removed!"
  53. else
  54. @echo "Use following command to install it on SD card:"
  55. @echo "sudo ./scripts/install.sh raspberry-pi /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  56. endif
  57. endif
  58. ifeq ($(ADK_TARGET_SYSTEM_RASPBERRY_PI2),y)
  59. ifeq ($(ADK_APPLIANCE_KODI),y)
  60. @echo "Use following command to install with a writable data partition"
  61. @echo "sudo ./scripts/install.sh -d 256 raspberry-pi2 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  62. @echo "If you want to update a card without loosing existing data on the writable partition use:"
  63. @echo "sudo ./scripts/install.sh -k -d 256 raspberry-pi2 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  64. @echo "In both cases the cfgfs partition is _not_ removed!"
  65. else
  66. @echo "Use following command to install it on SD card:"
  67. @echo "sudo ./scripts/install.sh raspberry-pi2 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  68. @echo "Use following command to install with a writable data partition"
  69. @echo "sudo ./scripts/install.sh -d 256 raspberry-pi2 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  70. endif
  71. endif
  72. ifeq ($(ADK_TARGET_SYSTEM_BANANA_PRO),y)
  73. @echo "Use following command to install it on SD card:"
  74. @echo "sudo ./scripts/install.sh banana-pro /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  75. @echo "Use following command to install with a writable data partition"
  76. @echo "sudo ./scripts/install.sh -d 256 banana-pro /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  77. endif
  78. ifeq ($(ADK_TARGET_SYSTEM_SOLIDRUN_IMX6),y)
  79. ifeq ($(ADK_APPLIANCE_KODI),y)
  80. @echo "Use following command to install with a writable data partition"
  81. @echo "sudo ./scripts/install.sh -d 256 solidrun-imx6 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  82. @echo "If you want to update a card without loosing existing data on the writable partition use:"
  83. @echo "sudo ./scripts/install.sh -k -d 256 solidrun-imx6 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  84. @echo "In both cases the cfgfs partition is _not_ removed!"
  85. else
  86. @echo "Use following command to install it on SD card:"
  87. @echo "sudo ./scripts/install.sh solidrun-imx6 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  88. endif
  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-${ADK_TARGET_CPU_ARCH} ${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-${ADK_TARGET_CPU_ARCH} ${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. endif
  118. ifeq ($(ADK_TARGET_FS),squashfs)
  119. targethelp:
  120. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  121. @echo "The RootFS image is: $(FW_DIR)/$(ROOTFSSQUASHFS)"
  122. ifeq ($(ADK_TARGET_QEMU),y)
  123. @echo "Start qemu with following options:"
  124. @echo 'qemu-system-${ADK_TARGET_CPU_ARCH} $(QEMU_ARGS) -nographic -kernel $(FW_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(ROOTFSSQUASHFS)'
  125. endif
  126. endif
  127. ifeq ($(ADK_TARGET_FS),jffs2)
  128. targethelp:
  129. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  130. @echo "The RootFS image is: $(FW_DIR)/$(ROOTFSJFFS2)"
  131. ifeq ($(ADK_TARGET_QEMU),y)
  132. @echo "Start qemu with following options:"
  133. @echo 'qemu-system-${ADK_TARGET_CPU_ARCH} $(QEMU_ARGS) -nographic -kernel $(FW_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(ROOTFSJFFS2)'
  134. endif
  135. endif
  136. kernel-strip:
  137. @cp $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL)
  138. ifeq ($(ADK_TARGET_BOARD_BCM28XX),y)
  139. @echo adding DT trailer to kernel $(MAKE_TRACE)
  140. -rm $(BUILD_DIR)/$(TARGET_KERNEL)
  141. PATH='$(HOST_PATH)' $(ADK_TOPDIR)/scripts/mkknlimg --dtok $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL) $(MAKE_TRACE)
  142. endif
  143. kernel-install: kernel-strip
  144. @cp $(BUILD_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(TARGET_KERNEL)
  145. ifeq ($(ADK_TARGET_FS),squashfs)
  146. env PATH=$(HOST_PATH) qemu-img create -f raw $(FW_DIR)/$(ROOTFSSQUASHFS) $(ADK_TARGET_MTD_SIZE)
  147. dd conv=notrunc if=$(BUILD_DIR)/root.squashfs of=$(FW_DIR)/$(ROOTFSSQUASHFS)
  148. endif
  149. dtb-install:
  150. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VEXPRESS_A9),y)
  151. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  152. dtbs $(MAKE_TRACE)
  153. endif
  154. ifeq ($(ADK_TARGET_BOARD_BCM28XX),y)
  155. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  156. dtbs $(MAKE_TRACE)
  157. mkdir -p $(FW_DIR)/overlays
  158. for x in $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtb; do \
  159. [[ -e "$$x" ]] && cp $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtb $(FW_DIR)/overlays; \
  160. break; \
  161. done
  162. endif
  163. ifeq ($(ADK_TARGET_SYSTEM_BANANA_PRO),y)
  164. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  165. sun7i-a20-bananapro.dtb $(MAKE_TRACE)
  166. endif
  167. ifeq ($(ADK_TARGET_SYSTEM_SOLIDRUN_IMX6),y)
  168. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  169. imx6q-cubox-i.dtb imx6dl-cubox-i.dtb imx6dl-hummingboard.dtb imx6q-hummingboard.dtb $(MAKE_TRACE)
  170. endif
  171. for x in $(LINUX_DIR)/arch/arm/boot/dts/*.dtb; do \
  172. [[ -e "$$x" ]] && cp $(LINUX_DIR)/arch/arm/boot/dts/*.dtb $(FW_DIR); \
  173. break; \
  174. done
  175. # filesystem specific targets
  176. ifeq ($(ADK_TARGET_FS),archive)
  177. imageinstall: dtb-install $(FW_DIR)/$(ROOTFSTARBALL) targethelp
  178. endif
  179. ifeq ($(ADK_TARGET_FS),initramfs)
  180. imageinstall: kernel-install dtb-install $(FW_DIR)/$(INITRAMFS) targethelp
  181. endif
  182. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  183. imageinstall: kernel-install dtb-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  184. endif
  185. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  186. imageinstall: dtb-install createinitramfs targethelp
  187. endif
  188. ifeq ($(ADK_TARGET_FS),nfsroot)
  189. imageinstall: kernel-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  190. endif
  191. ifeq ($(ADK_TARGET_FS),squashfs)
  192. imageinstall: $(BUILD_DIR)/root.squashfs kernel-install dtb-install targethelp
  193. endif
  194. ifeq ($(ADK_TARGET_FS),jffs2)
  195. imageinstall: kernel-install dtb-install $(FW_DIR)/$(ROOTFSJFFS2) targethelp
  196. endif
  197. ifeq ($(ADK_TARGET_FS),usb)
  198. imageinstall: $(FW_DIR)/$(ROOTFSTARBALL) targethelp
  199. endif