Makefile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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 "#################################################"
  48. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSTARBALL)"
  49. 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)
  50. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  51. @echo "Use following command to create a QEMU Image:"
  52. @echo "./scripts/create.sh qemu-${ADK_TARGET_CPU_ARCH}.img $(FW_DIR)/$(ROOTFSTARBALL)"
  53. @echo "Start qemu with following options:"
  54. @echo 'qemu-system-${ADK_TARGET_CPU_ARCH} ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL) qemu-${ADK_TARGET_CPU_ARCH}.img'
  55. endif
  56. ifeq ($(ADK_TARGET_BOARD_BCM28XX)$(ADK_TARGET_SYSTEM_SOLIDRUN_IMX6)$(ADK_TARGET_SYSTEM_SOLIDRUN_CLEARFOG),y)
  57. ifeq ($(ADK_RUNTIME_DATA_PARTITION),y)
  58. @echo "Use following command to install with a writable data partition"
  59. @echo "sudo ./scripts/install.sh -d 256 $(ADK_TARGET_SYSTEM) /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  60. @echo "If you want to update a card without loosing existing data on the writable partition use:"
  61. @echo "sudo ./scripts/install.sh -k -d 256 $(ADK_TARGET_SYSTEM) /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  62. @echo "In both cases the cfgfs partition is _not_ removed!"
  63. else
  64. @echo "Use following command to install it on SD card:"
  65. @echo "sudo ./scripts/install.sh $(ADK_TARGET_SYSTEM) /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  66. endif
  67. endif
  68. ifeq ($(ADK_TARGET_SYSTEM_PHYTEC_WEGA),y)
  69. @echo "Use following command to install it on SD card:"
  70. @echo "sudo ./scripts/install.sh phytec-wega /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  71. @echo "Use following command to install with a writable data partition"
  72. @echo "sudo ./scripts/install.sh -d 256 phytec-wega /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  73. @echo
  74. @echo "To boot from SD card do following in barebox bootloader:"
  75. @echo "mount /dev/mmc0.0 /mnt"
  76. @echo "bootm -o /mnt/am335x-wega-rdk.dtb /mnt/kernel"
  77. @echo
  78. endif
  79. ifeq ($(ADK_TARGET_SYSTEM_PHYTEC_IMX6),y)
  80. @echo "Use following command to install it on SD card:"
  81. @echo "sudo ./scripts/install.sh phytec-imx6 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  82. @echo
  83. endif
  84. ifeq ($(ADK_TARGET_SYSTEM_BANANA_PRO),y)
  85. @echo "Use following command to install it on SD card:"
  86. @echo "sudo ./scripts/install.sh banana-pro /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  87. @echo "Use following command to install with a writable data partition"
  88. @echo "sudo ./scripts/install.sh -d 256 banana-pro /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  89. endif
  90. ifeq ($(ADK_TARGET_SYSTEM_BANANA_P2_ZERO),y)
  91. @echo "Use following command to install it on SD card:"
  92. @echo "sudo ./scripts/install.sh banana-pro-zero /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  93. @echo "Use following command to install with a writable data partition"
  94. @echo "sudo ./scripts/install.sh -d 256 banana-pro-zero /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  95. endif
  96. ifeq ($(ADK_TARGET_SYSTEM_ORANGE_PI0),y)
  97. @echo "Use following command to install it on SD card:"
  98. @echo "sudo ./scripts/install.sh orange-pi0 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  99. @echo "Use following command to install with a writable data partition"
  100. @echo "sudo ./scripts/install.sh -d 256 orange-pi0 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  101. endif
  102. endif
  103. ifeq ($(ADK_TARGET_FS),initramfs)
  104. targethelp:
  105. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  106. @echo 'The initramfs image is: ${FW_DIR}/${INITRAMFS}'
  107. ifeq ($(ADK_TARGET_QEMU),y)
  108. @echo "Start qemu with following command line:"
  109. @echo 'qemu-system-arm ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL) -initrd ${FW_DIR}/${INITRAMFS}'
  110. endif
  111. endif
  112. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  113. targethelp:
  114. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  115. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSUSERTARBALL)"
  116. endif
  117. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  118. targethelp:
  119. @echo 'The kernel+initramfs file is: $(FW_DIR)/${TARGET_KERNEL}'
  120. ifeq ($(ADK_TARGET_QEMU),y)
  121. @echo "Start qemu with following command line:"
  122. @echo 'qemu-system-arm ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL)'
  123. endif
  124. endif
  125. ifeq ($(ADK_TARGET_FS),nfsroot)
  126. targethelp:
  127. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  128. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSUSERTARBALL)"
  129. ifeq ($(ADK_TARGET_SYSTEM_LINKSYS_NSLU2),y)
  130. @echo "Use following in RedBoot bootloader:"
  131. @echo "RedBoot> ip_address -l <localip> -h <serverip>; load -r -v -b 0x01d00000 ${TARGET_KERNEL}; exec 0x01d00000"
  132. endif
  133. endif
  134. ifeq ($(ADK_TARGET_FS),squashfs)
  135. targethelp:
  136. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  137. @echo "The RootFS image is: $(FW_DIR)/$(ROOTFSSQUASHFS)"
  138. ifeq ($(ADK_TARGET_QEMU),y)
  139. @echo "Start qemu with following options:"
  140. @echo 'qemu-system-arm $(QEMU_ARGS) -nographic -kernel $(FW_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(ROOTFSSQUASHFS)'
  141. endif
  142. endif
  143. ifeq ($(ADK_TARGET_FS),jffs2)
  144. targethelp:
  145. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  146. @echo "The RootFS image is: $(FW_DIR)/$(ROOTFSJFFS2)"
  147. ifeq ($(ADK_TARGET_QEMU),y)
  148. @echo "Start qemu with following options:"
  149. @echo 'qemu-system-arm $(QEMU_ARGS) -nographic -kernel $(FW_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(ROOTFSJFFS2)'
  150. endif
  151. endif
  152. ifeq ($(ADK_TARGET_FS),genimage)
  153. targethelp:
  154. @echo "The disk image is: $(FW_DIR)/sdcard.img"
  155. @echo "Use following command to install it on SD card:"
  156. @echo 'sudo dd if=$(FW_DIR)/sdcard.img of=/dev/sdX bs=2048k'
  157. endif
  158. kernel-strip:
  159. ifeq ($(ADK_TARGET_KERNEL_GIT_REPO_NAME),rpi)
  160. @echo adding DT trailer to kernel $(MAKE_TRACE)
  161. PATH='$(HOST_PATH)' perl $(LINUX_DIR)/scripts/mkknlimg $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL) $(MAKE_TRACE)
  162. else
  163. @cp $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL)
  164. endif
  165. kernel-install: kernel-strip
  166. @cp $(BUILD_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(TARGET_KERNEL)
  167. ifeq ($(ADK_TARGET_FS),squashfs)
  168. env PATH=$(HOST_PATH) qemu-img create -f raw $(FW_DIR)/$(ROOTFSSQUASHFS) $(ADK_TARGET_MTD_SIZE)
  169. dd conv=notrunc if=$(BUILD_DIR)/root.squashfs of=$(FW_DIR)/$(ROOTFSSQUASHFS)
  170. endif
  171. ifeq ($(ADK_TARGET_LINUX_KERNEL_VERSION_6_6),y)
  172. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VERSATILEPB),y)
  173. VENDOR:=arm/
  174. endif
  175. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_REALVIEW_EB_MPCORE),y)
  176. VENDOR:=arm/
  177. endif
  178. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VEXPRESS_A9),y)
  179. VENDOR:=arm/
  180. endif
  181. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_XILINX_ZYNQ),y)
  182. VENDOR:=xilinx/
  183. endif
  184. endif
  185. dtb-install:
  186. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_XILINX_ZYNQ),y)
  187. ${KERNEL_MAKE} dtbs $(MAKE_TRACE)
  188. endif
  189. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VEXPRESS_A9),y)
  190. ${KERNEL_MAKE} $(VENDOR)vexpress-v2p-ca9.dtb $(MAKE_TRACE)
  191. endif
  192. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_REALVIEW_EB_MPCORE),y)
  193. ${KERNEL_MAKE} $(VENDOR)arm-realview-eb-11mp-ctrevb.dtb $(MAKE_TRACE)
  194. endif
  195. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VERSATILEPB),y)
  196. ${KERNEL_MAKE} $(VENDOR)versatile-pb.dtb $(MAKE_TRACE)
  197. endif
  198. ifeq ($(ADK_TARGET_SYSTEM_PHYTEC_WEGA),y)
  199. ${KERNEL_MAKE} am335x-wega-rdk.dtb $(MAKE_TRACE)
  200. cp $(LINUX_DIR)/arch/arm/boot/dts/am335x-wega-rdk.dtb ${TARGET_DIR}/boot
  201. endif
  202. ifeq ($(ADK_TARGET_SYSTEM_PHYTEC_IMX6),y)
  203. ${KERNEL_MAKE} imx6q-phytec-pbab01.dtb $(MAKE_TRACE)
  204. cp $(LINUX_DIR)/arch/arm/boot/dts/imx6q-phytec-pbab01.dtb ${TARGET_DIR}/boot
  205. endif
  206. ifeq ($(ADK_TARGET_SYSTEM_BEAGLEBONE_BLACK),y)
  207. ${KERNEL_MAKE} am335x-boneblack.dtb $(MAKE_TRACE)
  208. cp $(LINUX_DIR)/arch/arm/boot/dts/am335x-boneblack.dtb ${TARGET_DIR}/boot
  209. endif
  210. ifeq ($(ADK_TARGET_BOARD_BCM28XX),y)
  211. ${KERNEL_MAKE} dtbs $(MAKE_TRACE)
  212. mkdir -p $(FW_DIR)/overlays
  213. for x in $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtbo; do \
  214. [[ -e "$$x" ]] && cp $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtbo $(FW_DIR)/overlays; \
  215. break; \
  216. done
  217. for x in $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtb; do \
  218. [[ -e "$$x" ]] && cp $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtb $(FW_DIR)/overlays; \
  219. break; \
  220. done
  221. endif
  222. ifeq ($(ADK_TARGET_SYSTEM_BANANA_PRO),y)
  223. ${KERNEL_MAKE} sun7i-a20-bananapro.dtb $(MAKE_TRACE)
  224. endif
  225. ifeq ($(ADK_TARGET_SYSTEM_ORANGE_PI0),y)
  226. ${KERNEL_MAKE} sun8i-h2-plus-orangepi-zero.dtb $(MAKE_TRACE)
  227. endif
  228. ifeq ($(ADK_TARGET_SYSTEM_BANANA_P2_ZERO),y)
  229. ${KERNEL_MAKE} sun8i-h2-plus-bananapi-m2-zero.dtb $(MAKE_TRACE)
  230. endif
  231. ifeq ($(ADK_TARGET_SYSTEM_SOLIDRUN_IMX6),y)
  232. ${KERNEL_MAKE} imx6q-cubox-i.dtb imx6dl-cubox-i.dtb \
  233. imx6dl-hummingboard.dtb imx6q-hummingboard.dtb $(MAKE_TRACE)
  234. endif
  235. ifeq ($(ADK_TARGET_SYSTEM_SOLIDRUN_CLEARFOG),y)
  236. ${KERNEL_MAKE} armada-388-clearfog.dtb $(MAKE_TRACE)
  237. endif
  238. ifeq ($(ADK_TARGET_SYSTEM_ST_STM32F429),y)
  239. ${KERNEL_MAKE} dtbs $(MAKE_TRACE)
  240. endif
  241. ifeq ($(ADK_TARGET_SYSTEM_ST_STM32F769),y)
  242. ${KERNEL_MAKE} dtbs $(MAKE_TRACE)
  243. endif
  244. ifeq ($(ADK_TARGET_SYSTEM_ST_STM32F746G),y)
  245. ${KERNEL_MAKE} dtbs $(MAKE_TRACE)
  246. endif
  247. for x in $(LINUX_DIR)/arch/arm/boot/dts/$(VENDOR)*.dtb; do \
  248. [[ -e "$$x" ]] && cp $(LINUX_DIR)/arch/arm/boot/dts/$(VENDOR)*.dtb $(FW_DIR); \
  249. break; \
  250. done
  251. # filesystem specific targets
  252. ifeq ($(ADK_TARGET_FS),archive)
  253. imageinstall: dtb-install $(FW_DIR)/$(ROOTFSTARBALL) targethelp
  254. endif
  255. ifeq ($(ADK_TARGET_FS),initramfs)
  256. imageinstall: kernel-install dtb-install $(FW_DIR)/$(INITRAMFS) targethelp
  257. endif
  258. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  259. imageinstall: kernel-install dtb-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  260. endif
  261. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  262. imageinstall: dtb-install createinitramfs targethelp
  263. endif
  264. ifeq (${ADK_TARGET_FS},genimage)
  265. imageinstall: dtb-install $(FW_DIR)/$(GENIMAGE) targethelp
  266. endif
  267. ifeq ($(ADK_TARGET_FS),nfsroot)
  268. imageinstall: kernel-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  269. endif
  270. ifeq ($(ADK_TARGET_FS),squashfs)
  271. imageinstall: $(BUILD_DIR)/root.squashfs kernel-install dtb-install targethelp
  272. endif
  273. ifeq ($(ADK_TARGET_FS),jffs2)
  274. imageinstall: kernel-install dtb-install $(FW_DIR)/$(ROOTFSJFFS2) targethelp
  275. endif
  276. ifeq ($(ADK_TARGET_FS),usb)
  277. imageinstall: $(FW_DIR)/$(ROOTFSTARBALL) targethelp
  278. endif