build.mk 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. ##### Put your SoC build configurations below #####
  2. CORE := n300fd
  3. ARCH_EXT ?= _zba_zbb_zbc_zbs_xxldspn1x
  4. DOWNLOAD ?= flashxip
  5. BOARD ?= gd32vw553h_eval
  6. # Variant for Board or SoC
  7. VARIANT ?=
  8. # Please overwrite following variable in Makefile of your application
  9. # System Clock Frequency
  10. # 16Mhz or 48Mhz or 160MHz in pure int value such as 160000000
  11. # leave empty will use default 160MHz
  12. SYSCLK ?=
  13. # Clock source
  14. ## hxtal: using high speed crystal oscillator (HXTAL)
  15. ## irc16m: using internal 16MHz RC oscillator (IRC16M)
  16. ## leave empty will use default settings in system_gd32vw55x.c
  17. CLKSRC ?=
  18. # Don't set HXTAL_VALUE unless you know what you are doing
  19. # when not empty it will define macro HXTAL_VALUE
  20. # see gd32vw55x.h
  21. HXTAL_VALUE ?=
  22. # even though it was set with a command argument
  23. DEFAULT_BOARD := gd32vw553h_eval
  24. NUCLEI_SDK_SOC_BOARD := $(NUCLEI_SDK_SOC)/Board/$(BOARD)
  25. NUCLEI_SDK_SOC_COMMON := $(NUCLEI_SDK_SOC)/Common
  26. VALID_NUCLEI_SDK_SOC_BOARD := $(wildcard $(NUCLEI_SDK_SOC_BOARD))
  27. ifeq ($(VALID_NUCLEI_SDK_SOC_BOARD),)
  28. $(warning $(BOARD) for $(SOC) doesn't exist, change it to default $(DEFAULT_BOARD)!)
  29. override NUCLEI_SDK_SOC_BOARD := $(NUCLEI_SDK_SOC)/Board/$(DEFAULT_BOARD)
  30. override VALID_NUCLEI_SDK_SOC_BOARD := $(NUCLEI_SDK_SOC_BOARD)
  31. endif
  32. # If DOWNLOAD passed is ilm, force it to sram
  33. ifeq ($(DOWNLOAD),ilm)
  34. override DOWNLOAD := sram
  35. endif
  36. OPENOCD_CFG ?= $(NUCLEI_SDK_SOC_BOARD)/openocd_gd32vw55x.cfg
  37. LINKER_SCRIPT ?= $(NUCLEI_SDK_SOC_BOARD)/Source/GCC/gcc_gd32vw55x_$(DOWNLOAD).ld
  38. # File existence check for OPENOCD_CFG and LINKER_SCRIPT
  39. ifeq ($(wildcard $(OPENOCD_CFG)),)
  40. $(error The openocd configuration file $(OPENOCD_CFG) for $(SOC) doesn't exist, please check!)
  41. endif
  42. # Allow non-existance of LINKER_SCRIPT, it might be generated
  43. ifeq ($(wildcard $(LINKER_SCRIPT)),)
  44. $(warning The link script file $(LINKER_SCRIPT) for $(SOC) doesn't exist, please check!)
  45. endif
  46. # if JTAGSN is not empty, pass it via openocd command
  47. ifneq ($(JTAGSN),)
  48. OPENOCD_CMD_ARGS += set JTAGSN $(JTAGSN);
  49. endif
  50. # Set RISCV_ARCH and RISCV_ABI
  51. CORE_UPPER := $(call uc, $(CORE))
  52. include $(NUCLEI_SDK_BUILD)/Makefile.core
  53. # you can override SUPPORTED_CORES defined in Makefile.core to limit the COREs used in this SoC
  54. # eg. override SUPPORTED_CORES := n300 n300f
  55. CORE_ARCH_ABI := $($(CORE_UPPER)_CORE_ARCH_ABI)
  56. # Check whether CORE is in SUPPORTED_CORES
  57. ifeq ($(filter $(CORE), $(SUPPORTED_CORES)),)
  58. $(error Here we only support these cores: $(SUPPORTED_CORES))
  59. endif
  60. # Check whether CORE_ARCH_ABI is presented for CORE
  61. ifneq ($(words $(wordlist 1, 2, $(CORE_ARCH_ABI))), 2)
  62. $(error No correct CORE_ARCH_ABI setting for CORE=$(CORE) found in $(realpath $(NUCLEI_SDK_BUILD)/Makefile.core))
  63. endif
  64. # Handle Nuclei RISC-V ARCH/ABI/CMODEL/TUNE
  65. ## ARCH_EXT could be combination of in order of bkpv, legal combination is list as below:
  66. ## bp: Bitmanip and Packed SIMD Extension present
  67. ## bpv: Bitmanip, Packed SIMD and Vector Extension present
  68. ## bkpv: Bitmanip, Packed SIMD, Scalar Cryptography and Vector Extension present
  69. ### If zc extension passed in ARCH_EXT, remove c in ARCH
  70. TEMP_RISCV_ARCH := $(word 1, $(CORE_ARCH_ABI))
  71. RISCV_ARCH ?= $(TEMP_RISCV_ARCH)$(ARCH_EXT)
  72. RISCV_ABI ?= $(word 2, $(CORE_ARCH_ABI))
  73. RISCV_TUNE ?= $(word 3, $(CORE_ARCH_ABI))
  74. ##### Extra compiler options
  75. ifneq ($(SYSCLK),)
  76. COMMON_FLAGS += -DSYSTEM_CLOCK=$(SYSCLK)
  77. endif
  78. ifneq ($(CLKSRC),)
  79. COMMON_FLAGS += -DSYSCLK_USING_$(call uc, $(CLKSRC))
  80. endif
  81. ifneq ($(HXTAL_VALUE),)
  82. COMMON_FLAGS += -DHXTAL_VALUE=$(HXTAL_VALUE)
  83. endif
  84. ##### Put your Source code Management configurations below #####
  85. INCDIRS += $(NUCLEI_SDK_SOC_COMMON)/Include
  86. C_SRCDIRS += $(NUCLEI_SDK_SOC_COMMON)/Source $(NUCLEI_SDK_SOC_COMMON)/Source/Drivers
  87. # If semihosting is enabled, no stub function is needed
  88. ifeq ($(SEMIHOST),)
  89. ifneq ($(findstring libncrt,$(STDCLIB)),)
  90. # semihosting currently not ported to support libncrt
  91. C_SRCDIRS += $(NUCLEI_SDK_SOC_COMMON)/Source/Stubs/libncrt
  92. else ifneq ($(findstring newlib,$(STDCLIB)),)
  93. C_SRCDIRS += $(NUCLEI_SDK_SOC_COMMON)/Source/Stubs/newlib
  94. else
  95. # no stubs will be used
  96. endif
  97. endif
  98. ASM_SRCS += $(NUCLEI_SDK_SOC_COMMON)/Source/GCC/startup_gd32vw55x.S \
  99. $(NUCLEI_SDK_SOC_COMMON)/Source/GCC/intexc_gd32vw55x.S
  100. # Add extra board related source files and header files
  101. ifneq ($(VALID_NUCLEI_SDK_SOC_BOARD),)
  102. INCDIRS += $(VALID_NUCLEI_SDK_SOC_BOARD)/Include
  103. C_SRCDIRS += $(VALID_NUCLEI_SDK_SOC_BOARD)/Source
  104. endif