Makefile-arduino_mini.make 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. ##############################################################################
  2. #
  3. # @file Makefile.
  4. #
  5. # @brief AVR Make file, it can be use to build, and program an application to
  6. # an AVR MCU like atmega328p, atmega2560 and so on.
  7. #
  8. # @author Theodore Ateba, tf.ateba@gmail.com
  9. #
  10. ##############################################################################
  11. ##############################################################################
  12. # Building and programming global options.
  13. # NOTE: Can be overridden externally.
  14. #
  15. # Compiler options here.
  16. ifeq ($(USE_OPT),)
  17. USE_OPT = -O2
  18. endif
  19. # C specific options here (added to USE_OPT).
  20. ifeq ($(USE_COPT),)
  21. USE_COPT =
  22. endif
  23. # C++ specific options here (added to USE_OPT).
  24. ifeq ($(USE_CPPOPT),)
  25. USE_CPPOPT =
  26. endif
  27. # Enable this if you want to see the full log while compiling.
  28. ifeq ($(USE_VERBOSE_COMPILE),)
  29. USE_VERBOSE_COMPILE = no
  30. endif
  31. # If enabled, this option makes the build process faster by not compiling
  32. # modules not used in the current configuration.
  33. ifeq ($(USE_SMART_BUILD),)
  34. USE_SMART_BUILD = yes
  35. endif
  36. # If enable, this option arase the counter cycle after device programming.
  37. ifeq ($(USE_AVRDUDE_ERASE_COUNTER),)
  38. USE_AVRDUDE_ERASE_COUNTER = no
  39. endif
  40. # If enable, this option perform a verification after device programming.
  41. ifeq ($(USE_AVRDUDE_NO_VERIFY),)
  42. USE_AVRDUDE_NO_VERIFY = no
  43. endif
  44. # If enabled, this option increase the programming verbosity level.
  45. ifeq ($(USE_VERBOSE_PROGRAMMATION),)
  46. USE_VERBOSE_PROGRAMMATION = no
  47. endif
  48. #
  49. # Building and programming global options.
  50. ##############################################################################
  51. ##############################################################################
  52. # Project, sources and paths.
  53. #
  54. # Define project name here.
  55. PROJECT = ch
  56. # Imported source files and paths
  57. CHIBIOS = ../../../..
  58. CONFDIR := ./cfg/arduino_mini
  59. BUILDDIR := ./build/arduino_mini
  60. DEPDIR := ./.dep/arduino_mini
  61. # Licensing files.
  62. include $(CHIBIOS)/os/license/license.mk
  63. # HAL-OSAL files (optional).
  64. include $(CHIBIOS)/os/hal/hal.mk
  65. include $(CHIBIOS)/os/hal/boards/ARDUINO_MINI/board.mk
  66. include $(CHIBIOS)/os/hal/ports/AVR/MEGA/ATMEGAxx/platform.mk
  67. include $(CHIBIOS)/os/hal/osal/rt/osal.mk
  68. # RTOS files (optional).
  69. include $(CHIBIOS)/os/rt/rt.mk
  70. include $(CHIBIOS)/os/common/ports/AVR/compilers/GCC/mk/port.mk
  71. # List C source files here. (C dependencies are automatically generated.)
  72. CSRC = $(ALLCSRC) \
  73. $(CONFDIR)/portab.c \
  74. main.c
  75. # List C++ sources file here.
  76. CPPSRC = $(ALLCPPSRC)
  77. # Header files here.
  78. INCDIR = $(ALLINC) $(CONFDIR)
  79. #
  80. # Project, sources and paths.
  81. ##############################################################################
  82. ##############################################################################
  83. # Compiler settings.
  84. #
  85. # Micro-Controller Unit.
  86. MCU = atmega328p
  87. # MCU frequency (Hz).
  88. F_CPU = 16000000
  89. # Output format. (can be srec, ihex, binary)
  90. FORMAT = ihex
  91. # C and C++ Compiler name.
  92. TRGT = avr-
  93. CC = $(TRGT)gcc
  94. CPPC = $(TRGT)g++
  95. # Enable loading with g++ only if you need C++ runtime support.
  96. # NOTE: You can use C++ even without C++ support if you are careful. C++
  97. # runtime support makes code size explode.
  98. LD = $(TRGT)gcc
  99. CP = $(TRGT)objcopy
  100. AR = $(TRGT)ar rcs
  101. OD = $(TRGT)objdump
  102. NM = $(TRGT)nm
  103. SZ = $(TRGT)size
  104. HEX = $(CP) -O ihex
  105. BIN = $(CP) -O binary
  106. # AVR programming tool.
  107. AVRDUDE = avrdude
  108. # Size of the elf binary file.
  109. ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
  110. # MCU specific options here.
  111. MOPT =
  112. # Define C warning options here.
  113. CWARN = -Wall -Wstrict-prototypes
  114. # Define C++ warning options here.
  115. CPPWARN =
  116. #
  117. # Compiler settings.
  118. ##############################################################################
  119. ##############################################################################
  120. # Start of user section.
  121. #
  122. # List all user C define here, like -D_DEBUG=1.
  123. UDEFS =
  124. # Define ASM defines here.
  125. UADEFS =
  126. # List all user directories here.
  127. UINCDIR =
  128. # List the user directory to look for the libraries here.
  129. ULIBDIR =
  130. # List all user libraries here.
  131. ULIBS =
  132. #
  133. # End of user defines.
  134. ##############################################################################
  135. ##############################################################################
  136. # Start of programming Options (avrdude).
  137. #
  138. # TODO: Add the programmer for ATtiny, and for ATXmega.
  139. # AVR programmer.
  140. AVRDUDE_PROGRAMMER = arduino
  141. # AVR serial port.
  142. AVRDUDE_PORT = /dev/ttyUSB0
  143. AVRDUDE_WRITE_FLASH = -D -U flash:w:$(BUILDDIR)/$(PROJECT).hex
  144. #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(BUILDDIR)/$(PROJECT).eep
  145. # Check if the counter cycle erase must be performed after device programming.
  146. ifeq ($(USE_AVRDUDE_ERASE_COUNTER),yes)
  147. AVRDUDE_ERASE_COUNTER = -y
  148. endif
  149. # Check if a verification must be performed after device programming.
  150. ifeq ($(USE_AVRDUDE_NO_VERIFY),no)
  151. AVRDUDE_NO_VERIFY = -V
  152. endif
  153. # Check verbosity level activation.
  154. ifeq ($(USE_VERBOSE_PROGRAMMATION),yes)
  155. AVRDUDE_VERBOSE = -v -v
  156. endif
  157. # AVR programmer flags.
  158. AVRDUDE_FLAGS = -p $(MCU)
  159. AVRDUDE_FLAGS += -P $(AVRDUDE_PORT)
  160. AVRDUDE_FLAGS += -b 57600
  161. AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER)
  162. AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
  163. AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
  164. AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
  165. #
  166. # End of Programming Options (avrdude).
  167. ##############################################################################
  168. ##############################################################################
  169. # Include file.
  170. #
  171. RULESPATH = $(CHIBIOS)/os/common/ports/AVR/compilers/GCC
  172. include $(RULESPATH)/rules.mk
  173. #
  174. # End of include file.
  175. ##############################################################################
  176. # EOF