Makefile 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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_VERSATILEPB),y)
  21. QEMU_ARGS+=-M versatilepb -net user -net nic,model=smc91c111
  22. endif
  23. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VEXPRESS_A9),y)
  24. QEMU_ARGS+=-M vexpress-a9 -cpu cortex-a9 -m 256 -net user -net nic,model=lan9118 -dtb $(FW_DIR)/vexpress-v2p-ca9.dtb
  25. ifeq ($(ADK_TARGET_ROOTFS_ARCHIVE),y)
  26. QEMU_ARGS+=-drive file=qemu-arm.img,if=sd,format=raw
  27. endif
  28. endif
  29. ifeq ($(ADK_TARGET_QEMU_WITH_VIRTIO),y)
  30. QEMU_ARGS+=-drive file=qemu-${ADK_TARGET_CPU_ARCH}.img,if=virtio,index=0 -net nic,model=virtio -net user
  31. endif
  32. # target helper text
  33. ifeq ($(ADK_TARGET_FS),archive)
  34. targethelp:
  35. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSTARBALL)"
  36. 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)
  37. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  38. @echo "Use following command to create a QEMU Image:"
  39. @echo "./scripts/create.sh qemu-${ADK_TARGET_CPU_ARCH}.img $(FW_DIR)/$(ROOTFSTARBALL)"
  40. @echo "Start qemu with following options:"
  41. @echo 'qemu-system-${ADK_TARGET_CPU_ARCH} ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL) qemu-${ADK_TARGET_CPU_ARCH}.img'
  42. endif
  43. ifeq ($(ADK_TARGET_SYSTEM_RASPBERRY_PI),y)
  44. ifeq ($(ADK_APPLIANCE_KODI),y)
  45. @echo "Use following command to install with a writable data partition"
  46. @echo "sudo ./scripts/install.sh -d 256 raspberry-pi /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  47. @echo "If you want to update a card without loosing existing data on the writable partition use:"
  48. @echo "sudo ./scripts/install.sh -k -d 256 raspbrry-pi /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  49. @echo "In both cases the cfgfs partition is _not_ removed!"
  50. else
  51. @echo "Use following command to install it on SD card:"
  52. @echo "sudo ./scripts/install.sh raspberry-pi /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  53. endif
  54. endif
  55. ifeq ($(ADK_TARGET_SYSTEM_RASPBERRY_PI2),y)
  56. ifeq ($(ADK_APPLIANCE_KODI),y)
  57. @echo "Use following command to install with a writable data partition"
  58. @echo "sudo ./scripts/install.sh -d 256 raspberry-pi2 /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 raspberry-pi2 /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 raspberry-pi2 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  65. @echo "Use following command to install with a writable data partition"
  66. @echo "sudo ./scripts/install.sh -d 256 raspberry-pi2 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  67. endif
  68. endif
  69. ifeq ($(ADK_TARGET_SYSTEM_BANANA_PRO),y)
  70. @echo "Use following command to install it on SD card:"
  71. @echo "sudo ./scripts/install.sh banana-pro /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  72. @echo "Use following command to install with a writable data partition"
  73. @echo "sudo ./scripts/install.sh -d 256 banana-pro /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  74. endif
  75. ifeq ($(ADK_TARGET_SYSTEM_SOLIDRUN_IMX6),y)
  76. ifeq ($(ADK_APPLIANCE_KODI),y)
  77. @echo "Use following command to install with a writable data partition"
  78. @echo "sudo ./scripts/install.sh -d 256 solidrun-imx6 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  79. @echo "If you want to update a card without loosing existing data on the writable partition use:"
  80. @echo "sudo ./scripts/install.sh -k -d 256 solidrun-imx6 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  81. @echo "In both cases the cfgfs partition is _not_ removed!"
  82. else
  83. @echo "Use following command to install it on SD card:"
  84. @echo "sudo ./scripts/install.sh solidrun-imx6 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  85. endif
  86. endif
  87. endif
  88. ifeq ($(ADK_TARGET_FS),initramfs)
  89. targethelp:
  90. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  91. @echo 'The initramfs image is: ${FW_DIR}/${INITRAMFS}'
  92. ifeq ($(ADK_TARGET_QEMU),y)
  93. @echo "Start qemu with following command line:"
  94. @echo 'qemu-system-${ADK_TARGET_CPU_ARCH} ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL) -initrd ${FW_DIR}/${INITRAMFS}'
  95. endif
  96. endif
  97. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  98. targethelp:
  99. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  100. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSUSERTARBALL)"
  101. endif
  102. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  103. targethelp:
  104. @echo 'The kernel+initramfs file is: $(FW_DIR)/${TARGET_KERNEL}'
  105. ifeq ($(ADK_TARGET_QEMU),y)
  106. @echo "Start qemu with following command line:"
  107. @echo 'qemu-system-${ADK_TARGET_CPU_ARCH} ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL)'
  108. endif
  109. endif
  110. ifeq ($(ADK_TARGET_FS),nfsroot)
  111. targethelp:
  112. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  113. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSUSERTARBALL)"
  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-${ADK_TARGET_CPU_ARCH} $(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-${ADK_TARGET_CPU_ARCH} $(QEMU_ARGS) -nographic -kernel $(FW_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(ROOTFSJFFS2)'
  131. endif
  132. endif
  133. kernel-strip:
  134. @cp $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL)
  135. ifeq ($(ADK_TARGET_BOARD_BCM28XX),y)
  136. @echo adding DT trailer to kernel $(MAKE_TRACE)
  137. -rm $(BUILD_DIR)/$(TARGET_KERNEL)
  138. PATH='$(HOST_PATH)' $(ADK_TOPDIR)/scripts/mkknlimg --dtok $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL) $(MAKE_TRACE)
  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_VEXPRESS_A9),y)
  148. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  149. dtbs $(MAKE_TRACE)
  150. endif
  151. ifeq ($(ADK_TARGET_BOARD_BCM28XX),y)
  152. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  153. dtbs $(MAKE_TRACE)
  154. mkdir -p $(FW_DIR)/overlays
  155. for x in $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtb; do \
  156. [[ -e "$$x" ]] && cp $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtb $(FW_DIR)/overlays; \
  157. break; \
  158. done
  159. endif
  160. ifeq ($(ADK_TARGET_SYSTEM_BANANA_PRO),y)
  161. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  162. sun7i-a20-bananapro.dtb $(MAKE_TRACE)
  163. endif
  164. ifeq ($(ADK_TARGET_SYSTEM_SOLIDRUN_IMX6),y)
  165. env $(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
  166. imx6q-cubox-i.dtb imx6dl-cubox-i.dtb imx6dl-hummingboard.dtb imx6q-hummingboard.dtb $(MAKE_TRACE)
  167. endif
  168. for x in $(LINUX_DIR)/arch/arm/boot/dts/*.dtb; do \
  169. [[ -e "$$x" ]] && cp $(LINUX_DIR)/arch/arm/boot/dts/*.dtb $(FW_DIR); \
  170. break; \
  171. done
  172. # filesystem specific targets
  173. ifeq ($(ADK_TARGET_FS),archive)
  174. imageinstall: dtb-install $(FW_DIR)/$(ROOTFSTARBALL) targethelp
  175. endif
  176. ifeq ($(ADK_TARGET_FS),initramfs)
  177. imageinstall: kernel-install dtb-install $(FW_DIR)/$(INITRAMFS) targethelp
  178. endif
  179. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  180. imageinstall: kernel-install dtb-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  181. endif
  182. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  183. imageinstall: dtb-install createinitramfs targethelp
  184. endif
  185. ifeq ($(ADK_TARGET_FS),nfsroot)
  186. imageinstall: kernel-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  187. endif
  188. ifeq ($(ADK_TARGET_FS),squashfs)
  189. imageinstall: $(BUILD_DIR)/root.squashfs kernel-install dtb-install targethelp
  190. endif
  191. ifeq ($(ADK_TARGET_FS),jffs2)
  192. imageinstall: kernel-install dtb-install $(FW_DIR)/$(ROOTFSJFFS2) targethelp
  193. endif
  194. ifeq ($(ADK_TARGET_FS),usb)
  195. imageinstall: $(FW_DIR)/$(ROOTFSTARBALL) targethelp
  196. endif