Makefile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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. ifeq ($(ADK_TARGET_SYSTEM_ST_STM32F746G),y)
  185. VENDOR:=st/
  186. endif
  187. endif
  188. dtb-install:
  189. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_XILINX_ZYNQ),y)
  190. ${KERNEL_MAKE} dtbs $(MAKE_TRACE)
  191. endif
  192. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VEXPRESS_A9),y)
  193. ${KERNEL_MAKE} $(VENDOR)vexpress-v2p-ca9.dtb $(MAKE_TRACE)
  194. endif
  195. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_REALVIEW_EB_MPCORE),y)
  196. ${KERNEL_MAKE} $(VENDOR)arm-realview-eb-11mp-ctrevb.dtb $(MAKE_TRACE)
  197. endif
  198. ifeq ($(ADK_TARGET_SYSTEM_QEMU_ARM_VERSATILEPB),y)
  199. ${KERNEL_MAKE} $(VENDOR)versatile-pb.dtb $(MAKE_TRACE)
  200. endif
  201. ifeq ($(ADK_TARGET_SYSTEM_PHYTEC_WEGA),y)
  202. ${KERNEL_MAKE} am335x-wega-rdk.dtb $(MAKE_TRACE)
  203. cp $(LINUX_DIR)/arch/arm/boot/dts/am335x-wega-rdk.dtb ${TARGET_DIR}/boot
  204. endif
  205. ifeq ($(ADK_TARGET_SYSTEM_PHYTEC_IMX6),y)
  206. ${KERNEL_MAKE} imx6q-phytec-pbab01.dtb $(MAKE_TRACE)
  207. cp $(LINUX_DIR)/arch/arm/boot/dts/imx6q-phytec-pbab01.dtb ${TARGET_DIR}/boot
  208. endif
  209. ifeq ($(ADK_TARGET_SYSTEM_BEAGLEBONE_BLACK),y)
  210. ${KERNEL_MAKE} am335x-boneblack.dtb $(MAKE_TRACE)
  211. cp $(LINUX_DIR)/arch/arm/boot/dts/am335x-boneblack.dtb ${TARGET_DIR}/boot
  212. endif
  213. ifeq ($(ADK_TARGET_BOARD_BCM28XX),y)
  214. ${KERNEL_MAKE} dtbs $(MAKE_TRACE)
  215. mkdir -p $(FW_DIR)/overlays
  216. for x in $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtbo; do \
  217. [[ -e "$$x" ]] && cp $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtbo $(FW_DIR)/overlays; \
  218. break; \
  219. done
  220. for x in $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtb; do \
  221. [[ -e "$$x" ]] && cp $(LINUX_DIR)/arch/arm/boot/dts/overlays/*.dtb $(FW_DIR)/overlays; \
  222. break; \
  223. done
  224. endif
  225. ifeq ($(ADK_TARGET_SYSTEM_BANANA_PRO),y)
  226. ${KERNEL_MAKE} sun7i-a20-bananapro.dtb $(MAKE_TRACE)
  227. endif
  228. ifeq ($(ADK_TARGET_SYSTEM_ORANGE_PI0),y)
  229. ${KERNEL_MAKE} sun8i-h2-plus-orangepi-zero.dtb $(MAKE_TRACE)
  230. endif
  231. ifeq ($(ADK_TARGET_SYSTEM_BANANA_P2_ZERO),y)
  232. ${KERNEL_MAKE} sun8i-h2-plus-bananapi-m2-zero.dtb $(MAKE_TRACE)
  233. endif
  234. ifeq ($(ADK_TARGET_SYSTEM_SOLIDRUN_IMX6),y)
  235. ${KERNEL_MAKE} imx6q-cubox-i.dtb imx6dl-cubox-i.dtb \
  236. imx6dl-hummingboard.dtb imx6q-hummingboard.dtb $(MAKE_TRACE)
  237. endif
  238. ifeq ($(ADK_TARGET_SYSTEM_SOLIDRUN_CLEARFOG),y)
  239. ${KERNEL_MAKE} armada-388-clearfog.dtb $(MAKE_TRACE)
  240. endif
  241. ifeq ($(ADK_TARGET_SYSTEM_ST_STM32F429),y)
  242. ${KERNEL_MAKE} dtbs $(MAKE_TRACE)
  243. endif
  244. ifeq ($(ADK_TARGET_SYSTEM_ST_STM32F769),y)
  245. ${KERNEL_MAKE} dtbs $(MAKE_TRACE)
  246. endif
  247. ifeq ($(ADK_TARGET_SYSTEM_ST_STM32F746G),y)
  248. ${KERNEL_MAKE} $(VENDOR)stm32f746-disco.dtb $(MAKE_TRACE)
  249. endif
  250. for x in $(LINUX_DIR)/arch/arm/boot/dts/$(VENDOR)*.dtb; do \
  251. [[ -e "$$x" ]] && cp $(LINUX_DIR)/arch/arm/boot/dts/$(VENDOR)*.dtb $(FW_DIR); \
  252. break; \
  253. done
  254. # filesystem specific targets
  255. ifeq ($(ADK_TARGET_FS),archive)
  256. imageinstall: dtb-install $(FW_DIR)/$(ROOTFSTARBALL) targethelp
  257. endif
  258. ifeq ($(ADK_TARGET_FS),initramfs)
  259. imageinstall: kernel-install dtb-install $(FW_DIR)/$(INITRAMFS) targethelp
  260. endif
  261. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  262. imageinstall: kernel-install dtb-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  263. endif
  264. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  265. imageinstall: dtb-install createinitramfs targethelp
  266. endif
  267. ifeq (${ADK_TARGET_FS},genimage)
  268. imageinstall: dtb-install $(FW_DIR)/$(GENIMAGE) targethelp
  269. endif
  270. ifeq ($(ADK_TARGET_FS),nfsroot)
  271. imageinstall: kernel-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  272. endif
  273. ifeq ($(ADK_TARGET_FS),squashfs)
  274. imageinstall: $(BUILD_DIR)/root.squashfs kernel-install dtb-install targethelp
  275. endif
  276. ifeq ($(ADK_TARGET_FS),jffs2)
  277. imageinstall: kernel-install dtb-install $(FW_DIR)/$(ROOTFSJFFS2) targethelp
  278. endif
  279. ifeq ($(ADK_TARGET_FS),usb)
  280. imageinstall: $(FW_DIR)/$(ROOTFSTARBALL) targethelp
  281. endif