1
0

Makefile 10 KB

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