PD Buddy Sink Firmware
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. ##############################################################################
  2. # Build global options
  3. # NOTE: Can be overridden externally.
  4. #
  5. # Compiler options here.
  6. ifeq ($(USE_OPT),)
  7. USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
  8. endif
  9. # C specific options here (added to USE_OPT).
  10. ifeq ($(USE_COPT),)
  11. USE_COPT = -std=gnu11
  12. endif
  13. # C++ specific options here (added to USE_OPT).
  14. ifeq ($(USE_CPPOPT),)
  15. USE_CPPOPT = -fno-rtti
  16. endif
  17. # Enable this if you want the linker to remove unused code and data
  18. ifeq ($(USE_LINK_GC),)
  19. USE_LINK_GC = yes
  20. endif
  21. # Linker extra options here.
  22. ifeq ($(USE_LDOPT),)
  23. USE_LDOPT =
  24. endif
  25. # Enable this if you want link time optimizations (LTO)
  26. ifeq ($(USE_LTO),)
  27. USE_LTO = no
  28. endif
  29. # If enabled, this option allows to compile the application in THUMB mode.
  30. ifeq ($(USE_THUMB),)
  31. USE_THUMB = yes
  32. endif
  33. # Enable this if you want to see the full log while compiling.
  34. ifeq ($(USE_VERBOSE_COMPILE),)
  35. USE_VERBOSE_COMPILE = no
  36. endif
  37. # If enabled, this option makes the build process faster by not compiling
  38. # modules not used in the current configuration.
  39. ifeq ($(USE_SMART_BUILD),)
  40. USE_SMART_BUILD = yes
  41. endif
  42. #
  43. # Build global options
  44. ##############################################################################
  45. ##############################################################################
  46. # Architecture or project specific options
  47. #
  48. # Stack size to be allocated to the Cortex-M process stack. This stack is
  49. # the stack used by the main() thread.
  50. ifeq ($(USE_PROCESS_STACKSIZE),)
  51. USE_PROCESS_STACKSIZE = 0x200
  52. endif
  53. # Stack size to the allocated to the Cortex-M main/exceptions stack. This
  54. # stack is used for processing interrupts and exceptions.
  55. ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
  56. USE_EXCEPTIONS_STACKSIZE = 0x400
  57. endif
  58. # Enables the use of FPU (no, softfp, hard).
  59. ifeq ($(USE_FPU),)
  60. USE_FPU = no
  61. endif
  62. #
  63. # Architecture or project specific options
  64. ##############################################################################
  65. ##############################################################################
  66. # Project, sources and paths
  67. #
  68. # Define project name here
  69. PROJECT = pd-buddy-firmware
  70. # Imported source files and paths
  71. CHIBIOS = ChibiOS
  72. PDBLIB = lib
  73. # Licensing files.
  74. include $(CHIBIOS)/os/license/license.mk
  75. # Startup files.
  76. include $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32f0xx.mk
  77. # HAL-OSAL files (optional).
  78. include $(CHIBIOS)/os/hal/hal.mk
  79. include $(CHIBIOS)/os/hal/ports/STM32/STM32F0xx/platform.mk
  80. include $(CHIBIOS)/../boards/PD_BUDDY_SINK/board.mk
  81. include $(CHIBIOS)/os/hal/osal/rt/osal.mk
  82. include $(CHIBIOS)/os/hal/lib/streams/streams.mk
  83. # RTOS files (optional).
  84. include $(CHIBIOS)/os/rt/rt.mk
  85. include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v6m.mk
  86. # Other files (optional).
  87. include $(CHIBIOS)/test/lib/test.mk
  88. include $(CHIBIOS)/test/rt/rt_test.mk
  89. include $(CHIBIOS)/test/oslib/oslib_test.mk
  90. include $(PDBLIB)/pd-buddy.mk
  91. # Define linker script file here
  92. LDSCRIPT=$(CHIBIOS)/../ld/STM32F072x8.ld
  93. # C sources that can be compiled in ARM or THUMB mode depending on the global
  94. # setting.
  95. CSRC = $(ALLCSRC) \
  96. $(TESTSRC) \
  97. $(wildcard src/*.c)
  98. # C++ sources that can be compiled in ARM or THUMB mode depending on the global
  99. # setting.
  100. CPPSRC = $(ALLCPPSRC)
  101. # C sources to be compiled in ARM mode regardless of the global setting.
  102. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  103. # option that results in lower performance and larger code size.
  104. ACSRC =
  105. # C++ sources to be compiled in ARM mode regardless of the global setting.
  106. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  107. # option that results in lower performance and larger code size.
  108. ACPPSRC =
  109. # C sources to be compiled in THUMB mode regardless of the global setting.
  110. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  111. # option that results in lower performance and larger code size.
  112. TCSRC =
  113. # C sources to be compiled in THUMB mode regardless of the global setting.
  114. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  115. # option that results in lower performance and larger code size.
  116. TCPPSRC =
  117. # List ASM source files here
  118. ASMSRC = $(ALLASMSRC)
  119. ASMXSRC = $(ALLXASMSRC)
  120. INCDIR = $(ALLINC) $(TESTINC)
  121. #
  122. # Project, sources and paths
  123. ##############################################################################
  124. ##############################################################################
  125. # Compiler settings
  126. #
  127. MCU = cortex-m0
  128. #TRGT = arm-elf-
  129. TRGT = arm-none-eabi-
  130. CC = $(TRGT)gcc
  131. CPPC = $(TRGT)g++
  132. # Enable loading with g++ only if you need C++ runtime support.
  133. # NOTE: You can use C++ even without C++ support if you are careful. C++
  134. # runtime support makes code size explode.
  135. LD = $(TRGT)gcc
  136. #LD = $(TRGT)g++
  137. CP = $(TRGT)objcopy
  138. AS = $(TRGT)gcc -x assembler-with-cpp
  139. AR = $(TRGT)ar
  140. OD = $(TRGT)objdump
  141. SZ = $(TRGT)size
  142. HEX = $(CP) -O ihex
  143. BIN = $(CP) -O binary
  144. # ARM-specific options here
  145. AOPT =
  146. # THUMB-specific options here
  147. TOPT = -mthumb -DTHUMB
  148. # Define C warning options here
  149. CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes
  150. # Define C++ warning options here
  151. CPPWARN = -Wall -Wextra -Wundef
  152. #
  153. # Compiler settings
  154. ##############################################################################
  155. ##############################################################################
  156. # Start of user section
  157. #
  158. # List all user C define here, like -D_DEBUG=1
  159. UDEFS = -DPDBS_CONFIG_BASE=0x0800F800
  160. # Define ASM defines here
  161. UADEFS =
  162. # List all user directories here
  163. UINCDIR =
  164. # List the user directory to look for the libraries here
  165. ULIBDIR =
  166. # List all user libraries here
  167. ULIBS =
  168. #
  169. # End of user defines
  170. ##############################################################################
  171. RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC
  172. include $(RULESPATH)/rules.mk
  173. # Special rules follow
  174. flash-openocd-stlink: $(BUILDDIR)/$(PROJECT).elf
  175. openocd -f interface/stlink-v2.cfg -c "transport select hla_swd" -f target/stm32f0x.cfg -c "program $(BUILDDIR)/$(PROJECT).elf verify reset exit"
  176. GDB ?= $(TRGT)gdb
  177. ifeq ($(BMP_PORT),)
  178. BMP_PORT_CANDIDATES := $(wildcard \
  179. /dev/serial/by-id/usb-Black_Sphere_Technologies_Black_Magic_Probe_*-if00 \
  180. /dev/cu.usbmodem*1)
  181. ifeq ($(words $(BMP_PORT_CANDIDATES)),1)
  182. BMP_PORT := $(BMP_PORT_CANDIDATES)
  183. else
  184. BMP_PORT = $(error Black Magic Probe gdb serial port not found, please provide the device name via the BMP_PORT variable parameter$(if \
  185. $(BMP_PORT_CANDIDATES), (found $(BMP_PORT_CANDIDATES))))
  186. endif
  187. endif
  188. flash-bmp: $(BUILDDIR)/$(PROJECT).elf
  189. $(GDB) -nx --batch \
  190. -ex 'target extended-remote $(BMP_PORT)' \
  191. -ex 'monitor swdp_scan' \
  192. -ex 'attach 1' \
  193. -ex 'load' \
  194. -ex 'compare-sections' \
  195. -ex 'kill' \
  196. $(BUILDDIR)/$(PROJECT).elf