Makefile 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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 -dtb $(FW_DIR)/arm-realview-eb-11mp-ctrevb.dtb
  31. endif
  32. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VERSATILEPB),y)
  33. QEMU_ARGS+=-M versatilepb -m 256 -net user -net nic,model=smc91c111 -dtb $(FW_DIR)/versatile-pb.dtb
  34. endif
  35. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VEXPRESS_A9),y)
  36. QEMU_ARGS+=-M vexpress-a9 -cpu cortex-a9 -m 256 -net user -net nic,model=lan9118 -dtb $(FW_DIR)/vexpress-v2p-ca9.dtb
  37. ifeq ($(ADK_TARGET_ROOTFS_ARCHIVE),y)
  38. QEMU_ARGS+=-drive file=qemu-arm.img,if=sd,format=raw
  39. endif
  40. endif
  41. ifeq ($(ADK_TARGET_QEMU_WITH_VIRTIO),y)
  42. QEMU_ARGS+=-drive file=qemu-${ADK_TARGET_CPU_ARCH}.img,if=virtio,index=0 -net nic,model=virtio -net user
  43. endif
  44. # target helper text
  45. ifeq ($(ADK_TARGET_FS),archive)
  46. targethelp:
  47. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSTARBALL)"
  48. 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)
  49. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  50. @echo "Use following command to create a QEMU Image:"
  51. @echo "./scripts/create.sh qemu-${ADK_TARGET_CPU_ARCH}.img $(FW_DIR)/$(ROOTFSTARBALL)"
  52. @echo "Start qemu with following options:"
  53. @echo 'qemu-system-${ADK_TARGET_CPU_ARCH} ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL) qemu-${ADK_TARGET_CPU_ARCH}.img'
  54. endif
  55. ifeq ($(ADK_TARGET_BOARD_BCM28XX)$(ADK_TARGET_SYSTEM_SOLIDRUN_IMX6)$(ADK_TARGET_SYSTEM_SOLIDRUN_CLEARFOG),y)
  56. ifeq ($(ADK_RUNTIME_DATA_PARTITION),y)
  57. @echo "Use following command to install with a writable data partition"
  58. @echo "sudo ./scripts/install.sh -d 256 $(ADK_TARGET_SYSTEM) /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 $(ADK_TARGET_SYSTEM) /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 $(ADK_TARGET_SYSTEM) /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  65. endif
  66. endif
  67. ifeq ($(ADK_TARGET_SYSTEM_PHYTEC_WEGA),y)
  68. @echo "Use following command to install it on SD card:"
  69. @echo "sudo ./scripts/install.sh phytec-wega /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  70. @echo "Use following command to install with a writable data partition"
  71. @echo "sudo ./scripts/install.sh -d 256 phytec-wega /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  72. @echo
  73. @echo "To boot from SD card do following in barebox bootloader:"
  74. @echo "mount /dev/mmc0.0 /mnt"
  75. @echo "bootm -o /mnt/am335x-wega-rdk.dtb /mnt/kernel"
  76. @echo
  77. endif
  78. ifeq ($(ADK_TARGET_SYSTEM_PHYTEC_IMX6),y)
  79. @echo "Use following command to install it on SD card:"
  80. @echo "sudo ./scripts/install.sh phytec-imx6 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  81. @echo
  82. endif
  83. ifeq ($(ADK_TARGET_SYSTEM_BANANA_PRO),y)
  84. @echo "Use following command to install it on SD card:"
  85. @echo "sudo ./scripts/install.sh banana-pro /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  86. @echo "Use following command to install with a writable data partition"
  87. @echo "sudo ./scripts/install.sh -d 256 banana-pro /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  88. endif
  89. ifeq ($(ADK_TARGET_SYSTEM_ORANGE_PI0),y)
  90. @echo "Use following command to install it on SD card:"
  91. @echo "sudo ./scripts/install.sh orange-pi0 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  92. @echo "Use following command to install with a writable data partition"
  93. @echo "sudo ./scripts/install.sh -d 256 orange-pi0 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  94. endif
  95. endif
  96. ifeq ($(ADK_TARGET_FS),initramfs)
  97. targethelp:
  98. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  99. @echo 'The initramfs image is: ${FW_DIR}/${INITRAMFS}'
  100. ifeq ($(ADK_TARGET_QEMU),y)
  101. @echo "Start qemu with following command line:"
  102. @echo 'qemu-system-arm ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL) -initrd ${FW_DIR}/${INITRAMFS}'
  103. endif
  104. endif
  105. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  106. targethelp:
  107. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  108. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSUSERTARBALL)"
  109. endif
  110. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  111. targethelp:
  112. @echo 'The kernel+initramfs file is: $(FW_DIR)/${TARGET_KERNEL}'
  113. ifeq ($(ADK_TARGET_QEMU),y)
  114. @echo "Start qemu with following command line:"
  115. @echo 'qemu-system-arm ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL)'
  116. endif
  117. endif
  118. ifeq ($(ADK_TARGET_FS),nfsroot)
  119. targethelp:
  120. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  121. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSUSERTARBALL)"
  122. ifeq ($(ADK_TARGET_SYSTEM_LINKSYS_NSLU2),y)
  123. @echo "Use following in RedBoot bootloader:"
  124. @echo "RedBoot> ip_address -l <localip> -h <serverip>; load -r -v -b 0x01d00000 ${TARGET_KERNEL}; exec 0x01d00000"
  125. endif
  126. endif
  127. ifeq ($(ADK_TARGET_FS),squashfs)
  128. targethelp:
  129. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  130. @echo "The RootFS image is: $(FW_DIR)/$(ROOTFSSQUASHFS)"
  131. ifeq ($(ADK_TARGET_QEMU),y)
  132. @echo "Start qemu with following options:"
  133. @echo 'qemu-system-arm $(QEMU_ARGS) -nographic -kernel $(FW_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(ROOTFSSQUASHFS)'
  134. endif
  135. endif
  136. ifeq ($(ADK_TARGET_FS),jffs2)
  137. targethelp:
  138. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  139. @echo "The RootFS image is: $(FW_DIR)/$(ROOTFSJFFS2)"
  140. ifeq ($(ADK_TARGET_QEMU),y)
  141. @echo "Start qemu with following options:"
  142. @echo 'qemu-system-arm $(QEMU_ARGS) -nographic -kernel $(FW_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(ROOTFSJFFS2)'
  143. endif
  144. endif
  145. ifeq ($(ADK_TARGET_FS),genimage)
  146. targethelp:
  147. @echo "The disk image is: $(FW_DIR)/disk.img"
  148. @echo "Use following command to install it on SD card:"
  149. @echo 'sudo dd if=$(FW_DIR)/disk.img of=/dev/sdX bs=2048k'
  150. endif
  151. kernel-strip:
  152. ifeq ($(ADK_TARGET_KERNEL_GIT_REPO_NAME),rpi)
  153. @echo adding DT trailer to kernel $(MAKE_TRACE)
  154. PATH='$(HOST_PATH)' perl $(LINUX_DIR)/scripts/mkknlimg $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL) $(MAKE_TRACE)
  155. else
  156. @cp $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL)
  157. endif
  158. kernel-install: kernel-strip
  159. @cp $(BUILD_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(TARGET_KERNEL)
  160. ifeq ($(ADK_TARGET_FS),squashfs)
  161. env PATH=$(HOST_PATH) qemu-img create -f raw $(FW_DIR)/$(ROOTFSSQUASHFS) $(ADK_TARGET_MTD_SIZE)
  162. dd conv=notrunc if=$(BUILD_DIR)/root.squashfs of=$(FW_DIR)/$(ROOTFSSQUASHFS)
  163. endif
  164. dtb-install:
  165. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_XILINX_ZYNQ),y)
  166. ${KERNEL_MAKE} dtbs $(MAKE_TRACE)
  167. endif
  168. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VEXPRESS_A9),y)
  169. ${KERNEL_MAKE} vexpress-v2p-ca9.dtb $(MAKE_TRACE)
  170. endif
  171. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_REALVIEW_EB_MPCORE),y)
  172. ${KERNEL_MAKE} arm-realview-eb-11mp-ctrevb.dtb $(MAKE_TRACE)
  173. endif
  174. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VERSATILEPB),y)
  175. ${KERNEL_MAKE} versatile-pb.dtb $(MAKE_TRACE)
  176. endif
  177. ifeq ($(ADK_TARGET_SYSTEM_PHYTEC_WEGA),y)
  178. ${KERNEL_MAKE} am335x-wega-rdk.dtb $(MAKE_TRACE)
  179. cp $(LINUX_DIR)/arch/arm/boot/dts/am335x-wega-rdk.dtb ${TARGET_DIR}/boot
  180. endif
  181. ifeq ($(ADK_TARGET_SYSTEM_PHYTEC_IMX6),y)
  182. ${KERNEL_MAKE} imx6q-phytec-pbab01.dtb $(MAKE_TRACE)
  183. cp $(LINUX_DIR)/arch/arm/boot/dts/imx6q-phytec-pbab01.dtb ${TARGET_DIR}/boot
  184. endif
  185. ifeq ($(ADK_TARGET_SYSTEM_BEAGLEBONE_BLACK),y)
  186. ${KERNEL_MAKE} am335x-boneblack.dtb $(MAKE_TRACE)
  187. cp $(LINUX_DIR)/arch/arm/boot/dts/am335x-boneblack.dtb ${TARGET_DIR}/boot
  188. endif
  189. ifeq ($(ADK_TARGET_BOARD_BCM28XX),y)
  190. ${KERNEL_MAKE} dtbs $(MAKE_TRACE)
  191. mkdir -p $(FW_DIR)/overlays
  192. for x in $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtbo; do \
  193. [[ -e "$$x" ]] && cp $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtbo $(FW_DIR)/overlays; \
  194. break; \
  195. done
  196. endif
  197. ifeq ($(ADK_TARGET_SYSTEM_BANANA_PRO),y)
  198. ${KERNEL_MAKE} sun7i-a20-bananapro.dtb $(MAKE_TRACE)
  199. endif
  200. ifeq ($(ADK_TARGET_SYSTEM_ORANGE_PI0),y)
  201. ${KERNEL_MAKE} sun8i-h2-plus-orangepi-zero.dtb $(MAKE_TRACE)
  202. endif
  203. ifeq ($(ADK_TARGET_SYSTEM_SOLIDRUN_IMX6),y)
  204. ${KERNEL_MAKE} imx6q-cubox-i.dtb imx6dl-cubox-i.dtb \
  205. imx6dl-hummingboard.dtb imx6q-hummingboard.dtb $(MAKE_TRACE)
  206. endif
  207. ifeq ($(ADK_TARGET_SYSTEM_SOLIDRUN_CLEARFOG),y)
  208. ${KERNEL_MAKE} armada-388-clearfog.dtb $(MAKE_TRACE)
  209. endif
  210. ifeq ($(ADK_TARGET_SYSTEM_ST_STM32F429),y)
  211. ${KERNEL_MAKE} dtbs $(MAKE_TRACE)
  212. endif
  213. ifeq ($(ADK_TARGET_SYSTEM_ST_STM32F769),y)
  214. ${KERNEL_MAKE} 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. # filesystem specific targets
  221. ifeq ($(ADK_TARGET_FS),archive)
  222. imageinstall: dtb-install $(FW_DIR)/$(ROOTFSTARBALL) targethelp
  223. endif
  224. ifeq ($(ADK_TARGET_FS),initramfs)
  225. imageinstall: kernel-install dtb-install $(FW_DIR)/$(INITRAMFS) targethelp
  226. endif
  227. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  228. imageinstall: kernel-install dtb-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  229. endif
  230. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  231. imageinstall: dtb-install createinitramfs targethelp
  232. endif
  233. ifeq (${ADK_TARGET_FS},genimage)
  234. imageinstall: dtb-install $(FW_DIR)/$(GENIMAGE) targethelp
  235. endif
  236. ifeq ($(ADK_TARGET_FS),nfsroot)
  237. imageinstall: kernel-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  238. endif
  239. ifeq ($(ADK_TARGET_FS),squashfs)
  240. imageinstall: $(BUILD_DIR)/root.squashfs kernel-install dtb-install targethelp
  241. endif
  242. ifeq ($(ADK_TARGET_FS),jffs2)
  243. imageinstall: kernel-install dtb-install $(FW_DIR)/$(ROOTFSJFFS2) targethelp
  244. endif
  245. ifeq ($(ADK_TARGET_FS),usb)
  246. imageinstall: $(FW_DIR)/$(ROOTFSTARBALL) targethelp
  247. endif