Makefile 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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)/arch/riscv/boot/Image
  7. QEMU_ARGS:=-M virt -m 256 -nographic -device loader,file=$(FW_DIR)/$(TARGET_KERNEL),addr=0x80200000
  8. ifeq ($(ADK_TARGET_QEMU_WITH_VIRTIO),y)
  9. QEMU_ARGS+=-netdev user,id=eth0 -device virtio-net-device,netdev=eth0
  10. endif
  11. ifeq ($(ADK_TARGET_FS),archive)
  12. QEMU_ARGS+=-device virtio-blk-device,drive=vda -drive file=qemu-${ADK_TARGET_CPU_ARCH}.img,if=none,id=vda,format=raw
  13. endif
  14. # target helper text
  15. ifeq ($(ADK_TARGET_FS),archive)
  16. targethelp:
  17. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSTARBALL)"
  18. ifeq ($(ADK_TARGET_QEMU),y)
  19. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  20. @echo "Use following command to create a QEMU Image:"
  21. @echo "./scripts/create.sh qemu-${ADK_TARGET_CPU_ARCH}.img $(FW_DIR)/$(ROOTFSTARBALL)"
  22. @echo "Start qemu with following options:"
  23. @echo 'qemu-system-${ADK_TARGET_CPU_ARCH} ${QEMU_ARGS} -kernel $(FW_DIR)/fw_jump.elf'
  24. endif
  25. endif
  26. ifeq ($(ADK_TARGET_FS),initramfs)
  27. targethelp:
  28. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  29. @echo 'The initramfs image is: ${FW_DIR}/${INITRAMFS}'
  30. ifeq ($(ADK_TARGET_QEMU),y)
  31. @echo "Start qemu with following command line:"
  32. @echo 'qemu-system-riscv32 ${QEMU_ARGS} -kernel $(FW_DIR)/fw_jump.elf -initrd ${FW_DIR}/${INITRAMFS}'
  33. endif
  34. endif
  35. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  36. targethelp:
  37. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  38. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSUSERTARBALL)"
  39. endif
  40. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  41. targethelp:
  42. @echo 'The kernel+initramfs file is: $(FW_DIR)/${TARGET_KERNEL}'
  43. ifeq ($(ADK_TARGET_QEMU),y)
  44. @echo "Start qemu with following command line:"
  45. @echo 'qemu-system-riscv32 ${QEMU_ARGS} -kernel $(FW_DIR)/fw_jump.elf'
  46. endif
  47. endif
  48. kernel-strip:
  49. kernel-install: kernel-strip
  50. @cp $(KERNEL) $(FW_DIR)/$(TARGET_KERNEL)
  51. bbl:
  52. @rm -rf $(BUILD_DIR)/opensbi
  53. (cd $(BUILD_DIR)/ && git clone https://github.com/riscv/opensbi.git)
  54. (cd $(BUILD_DIR)/opensbi && PATH='$(HOST_PATH)' \
  55. CROSS_COMPILE=$(GNU_TARGET_NAME)- \
  56. PLATFORM=qemu/virt make)
  57. cp $(BUILD_DIR)/opensbi/build/platform/qemu/virt/firmware/fw_jump.elf $(FW_DIR)
  58. # filesystem specific targets
  59. ifeq ($(ADK_TARGET_FS),initramfs)
  60. imageinstall: kernel-install bbl $(FW_DIR)/$(INITRAMFS) targethelp
  61. endif
  62. ifeq ($(ADK_TARGET_FS),initramfsarchive)
  63. imageinstall: kernel-install bbl $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
  64. endif
  65. ifeq ($(ADK_TARGET_FS),initramfspiggyback)
  66. imageinstall: createinitramfs bbl targethelp
  67. endif