Makefile 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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_BEAGEBONE_BLACK),y)
  85. @echo "Use following command to install it on SD card:"
  86. @echo "sudo ./scripts/install.sh beaglebone-black /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  87. @echo
  88. endif
  89. ifeq ($(ADK_TARGET_SYSTEM_BANANA_PRO),y)
  90. @echo "Use following command to install it on SD card:"
  91. @echo "sudo ./scripts/install.sh banana-pro /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 banana-pro /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  94. endif
  95. ifeq ($(ADK_TARGET_SYSTEM_BANANA_P2_ZERO),y)
  96. @echo "Use following command to install it on SD card:"
  97. @echo "sudo ./scripts/install.sh banana-pro-zero /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  98. @echo "Use following command to install with a writable data partition"
  99. @echo "sudo ./scripts/install.sh -d 256 banana-pro-zero /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  100. endif
  101. ifeq ($(ADK_TARGET_SYSTEM_ORANGE_PI0),y)
  102. @echo "Use following command to install it on SD card:"
  103. @echo "sudo ./scripts/install.sh orange-pi0 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  104. @echo "Use following command to install with a writable data partition"
  105. @echo "sudo ./scripts/install.sh -d 256 orange-pi0 /dev/sdX $(FW_DIR)/$(ROOTFSTARBALL)"
  106. endif
  107. endif
  108. ifeq ($(ADK_TARGET_FS),initramfs)
  109. targethelp:
  110. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  111. @echo 'The initramfs image is: ${FW_DIR}/${INITRAMFS}'
  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) -initrd ${FW_DIR}/${INITRAMFS}'
  115. endif
  116. endif
  117. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  118. targethelp:
  119. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  120. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSUSERTARBALL)"
  121. endif
  122. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  123. targethelp:
  124. @echo 'The kernel+initramfs file is: $(FW_DIR)/${TARGET_KERNEL}'
  125. ifeq ($(ADK_TARGET_QEMU),y)
  126. @echo "Start qemu with following command line:"
  127. @echo 'qemu-system-arm ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL)'
  128. endif
  129. endif
  130. ifeq ($(ADK_TARGET_FS),nfsroot)
  131. targethelp:
  132. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  133. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSUSERTARBALL)"
  134. ifeq ($(ADK_TARGET_SYSTEM_LINKSYS_NSLU2),y)
  135. @echo "Use following in RedBoot bootloader:"
  136. @echo "RedBoot> ip_address -l <localip> -h <serverip>; load -r -v -b 0x01d00000 ${TARGET_KERNEL}; exec 0x01d00000"
  137. endif
  138. endif
  139. ifeq ($(ADK_TARGET_FS),squashfs)
  140. targethelp:
  141. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  142. @echo "The RootFS image is: $(FW_DIR)/$(ROOTFSSQUASHFS)"
  143. ifeq ($(ADK_TARGET_QEMU),y)
  144. @echo "Start qemu with following options:"
  145. @echo 'qemu-system-arm $(QEMU_ARGS) -nographic -kernel $(FW_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(ROOTFSSQUASHFS)'
  146. endif
  147. endif
  148. ifeq ($(ADK_TARGET_FS),jffs2)
  149. targethelp:
  150. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  151. @echo "The RootFS image is: $(FW_DIR)/$(ROOTFSJFFS2)"
  152. ifeq ($(ADK_TARGET_QEMU),y)
  153. @echo "Start qemu with following options:"
  154. @echo 'qemu-system-arm $(QEMU_ARGS) -nographic -kernel $(FW_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(ROOTFSJFFS2)'
  155. endif
  156. endif
  157. ifeq ($(ADK_TARGET_FS),genimage)
  158. targethelp:
  159. @echo "The disk image is: $(FW_DIR)/sdcard.img"
  160. @echo "Use following command to install it on SD card:"
  161. @echo 'sudo dd if=$(FW_DIR)/sdcard.img of=/dev/sdX bs=32M'
  162. endif
  163. kernel-strip:
  164. ifeq ($(ADK_TARGET_KERNEL_GIT_REPO_NAME),rpi)
  165. @echo adding DT trailer to kernel $(MAKE_TRACE)
  166. PATH='$(HOST_PATH)' perl $(LINUX_DIR)/scripts/mkknlimg $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL) $(MAKE_TRACE)
  167. else
  168. @cp $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL)
  169. endif
  170. kernel-install: kernel-strip
  171. @cp $(BUILD_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(TARGET_KERNEL)
  172. ifeq ($(ADK_TARGET_FS),squashfs)
  173. env PATH=$(HOST_PATH) qemu-img create -f raw $(FW_DIR)/$(ROOTFSSQUASHFS) $(ADK_TARGET_MTD_SIZE)
  174. dd conv=notrunc if=$(BUILD_DIR)/root.squashfs of=$(FW_DIR)/$(ROOTFSSQUASHFS)
  175. endif
  176. ifeq ($(ADK_TARGET_LINUX_KERNEL_VERSION_6_6)$(ADK_TARGET_LINUX_KERNEL_VERSION_6_9)$(ADK_TARGET_LINUX_KERNEL_VERSION_GIT),y)
  177. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VERSATILEPB),y)
  178. VENDOR:=arm/
  179. endif
  180. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_REALVIEW_EB_MPCORE),y)
  181. VENDOR:=arm/
  182. endif
  183. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VEXPRESS_A9),y)
  184. VENDOR:=arm/
  185. endif
  186. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_XILINX_ZYNQ),y)
  187. VENDOR:=xilinx/
  188. endif
  189. ifeq ($(ADK_TARGET_SYSTEM_SOLIDRUN_CLEARFOG),y)
  190. VENDOR:=marvell/
  191. endif
  192. ifeq ($(ADK_TARGET_SYSTEM_ST_STM32F746G),y)
  193. VENDOR:=st/
  194. endif
  195. ifeq ($(ADK_TARGET_SYSTEM_SOLIDRUN_IMX6),y)
  196. VENDOR:=nxp/imx/
  197. endif
  198. ifeq ($(ADK_TARGET_SYSTEM_BEAGLEBONE_BLACK),y)
  199. VENDOR:=ti/omap/
  200. endif
  201. ifeq ($(ADK_TARGET_SYSTEM_BANANA_PRO),y)
  202. VENDOR:=allwinner/
  203. endif
  204. endif
  205. dtb-install:
  206. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_XILINX_ZYNQ),y)
  207. ${KERNEL_MAKE} dtbs $(MAKE_TRACE)
  208. endif
  209. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VEXPRESS_A9),y)
  210. ${KERNEL_MAKE} $(VENDOR)vexpress-v2p-ca9.dtb $(MAKE_TRACE)
  211. endif
  212. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_REALVIEW_EB_MPCORE),y)
  213. ${KERNEL_MAKE} $(VENDOR)arm-realview-eb-11mp-ctrevb.dtb $(MAKE_TRACE)
  214. endif
  215. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VERSATILEPB),y)
  216. ${KERNEL_MAKE} $(VENDOR)versatile-pb.dtb $(MAKE_TRACE)
  217. endif
  218. ifeq ($(ADK_TARGET_SYSTEM_PHYTEC_WEGA),y)
  219. ${KERNEL_MAKE} am335x-wega-rdk.dtb $(MAKE_TRACE)
  220. cp $(LINUX_DIR)/arch/arm/boot/dts/am335x-wega-rdk.dtb ${TARGET_DIR}/boot
  221. endif
  222. ifeq ($(ADK_TARGET_SYSTEM_PHYTEC_IMX6),y)
  223. ${KERNEL_MAKE} imx6q-phytec-pbab01.dtb $(MAKE_TRACE)
  224. cp $(LINUX_DIR)/arch/arm/boot/dts/imx6q-phytec-pbab01.dtb ${TARGET_DIR}/boot
  225. endif
  226. ifeq ($(ADK_TARGET_SYSTEM_BEAGLEBONE_BLACK),y)
  227. ${KERNEL_MAKE} $(VENDOR)am335x-boneblack.dtb $(MAKE_TRACE)
  228. cp $(LINUX_DIR)/arch/arm/boot/dts/$(VENDOR)am335x-boneblack.dtb ${TARGET_DIR}/boot
  229. endif
  230. ifeq ($(ADK_TARGET_BOARD_BCM28XX),y)
  231. ${KERNEL_MAKE} dtbs $(MAKE_TRACE)
  232. mkdir -p $(FW_DIR)/overlays
  233. for x in $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtbo; do \
  234. [[ -e "$$x" ]] && cp $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtbo $(FW_DIR)/overlays; \
  235. break; \
  236. done
  237. for x in $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtb; do \
  238. [[ -e "$$x" ]] && cp $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtb $(FW_DIR)/overlays; \
  239. break; \
  240. done
  241. endif
  242. ifeq ($(ADK_TARGET_SYSTEM_BANANA_PRO),y)
  243. ${KERNEL_MAKE} $(VENDOR)sun7i-a20-bananapro.dtb $(MAKE_TRACE)
  244. endif
  245. ifeq ($(ADK_TARGET_SYSTEM_ORANGE_PI0),y)
  246. ${KERNEL_MAKE} sun8i-h2-plus-orangepi-zero.dtb $(MAKE_TRACE)
  247. endif
  248. ifeq ($(ADK_TARGET_SYSTEM_BANANA_P2_ZERO),y)
  249. ${KERNEL_MAKE} sun8i-h2-plus-bananapi-m2-zero.dtb $(MAKE_TRACE)
  250. endif
  251. ifeq ($(ADK_TARGET_SYSTEM_SOLIDRUN_IMX6),y)
  252. ${KERNEL_MAKE} $(VENDOR)imx6q-cubox-i.dtb $(VENDOR)imx6dl-cubox-i.dtb \
  253. $(VENDOR)imx6dl-hummingboard.dtb $(VENDOR)imx6q-hummingboard.dtb $(MAKE_TRACE)
  254. endif
  255. ifeq ($(ADK_TARGET_SYSTEM_SOLIDRUN_CLEARFOG),y)
  256. ${KERNEL_MAKE} $(VENDOR)armada-388-clearfog.dtb $(MAKE_TRACE)
  257. endif
  258. ifeq ($(ADK_TARGET_SYSTEM_ST_STM32F429),y)
  259. ${KERNEL_MAKE} dtbs $(MAKE_TRACE)
  260. endif
  261. ifeq ($(ADK_TARGET_SYSTEM_ST_STM32F769),y)
  262. ${KERNEL_MAKE} dtbs $(MAKE_TRACE)
  263. endif
  264. ifeq ($(ADK_TARGET_SYSTEM_ST_STM32F746G),y)
  265. ${KERNEL_MAKE} $(VENDOR)stm32f746-disco.dtb $(MAKE_TRACE)
  266. endif
  267. for x in $(LINUX_DIR)/arch/arm/boot/dts/$(VENDOR)*.dtb; do \
  268. [[ -e "$$x" ]] && cp $(LINUX_DIR)/arch/arm/boot/dts/$(VENDOR)*.dtb $(FW_DIR); \
  269. break; \
  270. done
  271. # filesystem specific targets
  272. ifeq ($(ADK_TARGET_FS),archive)
  273. imageinstall: dtb-install $(FW_DIR)/$(ROOTFSTARBALL) targethelp
  274. endif
  275. ifeq ($(ADK_TARGET_FS),initramfs)
  276. imageinstall: kernel-install dtb-install $(FW_DIR)/$(INITRAMFS) targethelp
  277. endif
  278. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  279. imageinstall: kernel-install dtb-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  280. endif
  281. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  282. imageinstall: dtb-install createinitramfs targethelp
  283. endif
  284. ifeq (${ADK_TARGET_FS},genimage)
  285. imageinstall: dtb-install $(FW_DIR)/$(GENIMAGE) targethelp
  286. endif
  287. ifeq ($(ADK_TARGET_FS),nfsroot)
  288. imageinstall: kernel-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  289. endif
  290. ifeq ($(ADK_TARGET_FS),squashfs)
  291. imageinstall: $(BUILD_DIR)/root.squashfs kernel-install dtb-install targethelp
  292. endif
  293. ifeq ($(ADK_TARGET_FS),jffs2)
  294. imageinstall: kernel-install dtb-install $(FW_DIR)/$(ROOTFSJFFS2) targethelp
  295. endif
  296. ifeq ($(ADK_TARGET_FS),usb)
  297. imageinstall: $(FW_DIR)/$(ROOTFSTARBALL) targethelp
  298. endif