Naze32 clone with Frysky receiver
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

makefile 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. TARGET = rx
  2. AVR = 1
  3. EXTRAINCDIR = include
  4. CSTANDARD = gnu99
  5. CPPSTANDARD = gnu++98
  6. BUILDDIRBASE = build
  7. ifeq ($(AVR),1)
  8. MCU = attiny85
  9. F_CPU = 16000000
  10. BUILDDIR = $(BUILDDIRBASE)/avr
  11. else
  12. MCU = cortex-m3
  13. BUILDDIR = $(BUILDDIRBASE)/arm
  14. endif
  15. RM = rm -rf
  16. MKDIR = mkdir -p
  17. ifeq ($(AVR),1)
  18. GCC = avr-gcc
  19. SIZE = avr-size
  20. OBJCOPY = avr-objcopy
  21. OBJDUMP = avr-objdump
  22. AVRDUDE = avrdude
  23. else
  24. GCC_BIN = ~/bin/mbed/gcc-arm-none-eabi/bin
  25. GCC = $(GCC_BIN)/arm-none-eabi-gcc
  26. GPP = $(GCC_BIN)/arm-none-eabi-g++
  27. SIZE = $(GCC_BIN)/arm-none-eabi-size
  28. OBJCOPY = $(GCC_BIN)/arm-none-eabi-objcopy
  29. OBJDUMP = $(GCC_BIN)/arm-none-eabi-objdump
  30. endif
  31. SRC = src/main.c
  32. SRC += src/cc2500.c
  33. SRC += src/rx.c
  34. SRC += src/spi.c
  35. ifeq ($(AVR),1)
  36. SRC += src/avr/timer.c
  37. SRC += src/avr/cppm.c
  38. ifeq ($(DEBUG),1)
  39. SRC += src/avr/serial.c
  40. endif
  41. else
  42. CPPSRC += src/arm/cppm.cpp
  43. CPPSRC += src/arm/serial.cpp
  44. CPPSRC += src/arm/spi.cpp
  45. CPPSRC += src/arm/timer.cpp
  46. endif
  47. ifeq ($(AVR),1)
  48. CARGS = -I$(EXTRAINCDIR)
  49. CARGS += -Os
  50. CARGS += -std=$(CSTANDARD)
  51. CARGS += -Wall -Wextra -pedantic -Werror
  52. CARGS += -mmcu=$(MCU)
  53. CARGS += -funsigned-bitfields
  54. CARGS += -fpack-struct
  55. CARGS += -fshort-enums
  56. CARGS += -ffunction-sections
  57. CARGS += -Wshadow
  58. CARGS += -Wpointer-arith -Wcast-qual -Wstrict-prototypes
  59. CARGS += -Wno-main -Wno-write-strings -Wno-unused-parameter
  60. CARGS += -DF_CPU=$(F_CPU)
  61. LINKER = -Wl,--relax
  62. LINKER += -Wl,-Map -Wl,$(@:.elf=.map)
  63. else
  64. PRE_DEFS = -DTOOLCHAIN_GCC_ARM -DTOOLCHAIN_GCC -DARM_MATH_CM3
  65. PRE_DEFS += -DTARGET_LIKE_CORTEX_M3 -DTARGET_CORTEX_M
  66. PRE_DEFS += -DMBED_BUILD_TIMESTAMP=1462534374.34
  67. PRE_DEFS += -DTARGET_LIKE_MBED -DTARGET_LPC176X -DTARGET_NXP
  68. PRE_DEFS += -DTARGET_LPC1768 -D__CORTEX_M3 -DTARGET_M3
  69. PRE_DEFS += -DTARGET_MBED_LPC1768 -D__MBED__=1
  70. CARGS = -I$(EXTRAINCDIR)
  71. CARGS += -Ilib
  72. CARGS += -Os
  73. CARGS += -std=$(CSTANDARD)
  74. CARGS += -Wall -Wextra -pedantic -Werror
  75. CARGS += -Wno-main
  76. CARGS += -mcpu=$(MCU)
  77. CARGS += -mthumb
  78. CARGS += -fno-common -fmessage-length=0
  79. CARGS += -fno-exceptions -ffunction-sections -fdata-sections
  80. CARGS += -fomit-frame-pointer
  81. CARGS += $(PRE_DEFS)
  82. CPPARGS = -I$(EXTRAINCDIR)
  83. CPPARGS += -Ilib/mbed
  84. CPPARGS += -Ilib/mbed/TARGET_LPC1768
  85. CPPARGS += -Ilib/mbed/TARGET_LPC1768/TARGET_NXP
  86. CPPARGS += -Ilib/mbed/TARGET_LPC1768/TARGET_NXP/TARGET_LPC176X
  87. CPPARGS += -Ilib/mbed/TARGET_LPC1768/TARGET_NXP/TARGET_LPC176X/TARGET_MBED_LPC1768
  88. CPPARGS += -Ilib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM
  89. CPPARGS += -Os
  90. CPPARGS += -std=$(CPPSTANDARD)
  91. CPPARGS += -Wall -Wextra -pedantic -Werror
  92. CPPARGS += -Wno-main
  93. CPPARGS += -mcpu=$(MCU)
  94. CPPARGS += -mthumb
  95. CPPARGS += -fno-common -fmessage-length=0
  96. CPPARGS += -fno-exceptions -ffunction-sections -fdata-sections
  97. CPPARGS += -fomit-frame-pointer -fno-rtti
  98. CPPARGS += $(PRE_DEFS)
  99. LINKER = -mcpu=$(MCU)
  100. LINKER += -mthumb
  101. LINKER += -Wl,--gc-sections
  102. LINKER += --specs=nano.specs
  103. LINKER += -u _printf_float -u _scanf_float
  104. LINKER += -Wl,--wrap,main
  105. #LINKER += -Wl,--cref
  106. LINKER += -Tlib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/LPC1768.ld
  107. LINKER += -Llib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM
  108. LINKER += -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
  109. LINKER += -lmbed
  110. OBJ = lib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/board.o
  111. OBJ += lib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/cmsis_nvic.o
  112. OBJ += lib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/retarget.o
  113. OBJ += lib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/startup_LPC17xx.o
  114. OBJ += lib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/system_LPC17xx.o
  115. endif
  116. ifeq ($(DEBUG),1)
  117. CARGS += -DDEBUG
  118. endif
  119. ifeq ($(AVR),1)
  120. PROGRAMMER = arduino
  121. ISPPORT = /dev/tty.usbserial-A100OZQ1
  122. ISPBAUD = 57600
  123. else
  124. endif
  125. # -----------------------------------------------------------------------------
  126. OBJ += $(addprefix $(BUILDDIR)/, $(SRC:.c=.o))
  127. OBJ += $(addprefix $(BUILDDIR)/, $(CPPSRC:.cpp=.o))
  128. .PHONY: all
  129. all: $(BUILDDIR)/$(TARGET).hex $(BUILDDIR)/$(TARGET).bin
  130. .PHONY: debugArduino
  131. debugArduino:
  132. $(MAKE) BUILDDIR=build/avr/debug TARGET=debug MCU=atmega328 DEBUG=1 all
  133. .PHONY: debugProgramArduino
  134. debugProgramArduino:
  135. $(MAKE) BUILDDIR=build/avr/debug TARGET=debug MCU=atmega328p DEBUG=1 program
  136. .PHONY: debugMbed
  137. debugMbed:
  138. $(MAKE) BUILDDIR=build/arm/debug TARGET=debug AVR=0 DEBUG=1 all
  139. .PHONY: debugProgramMbed
  140. debugProgramMbed:
  141. $(MAKE) BUILDDIR=build/arm/debug TARGET=debug AVR=0 DEBUG=1 copy
  142. .PHONY: program
  143. program: $(BUILDDIR)/$(TARGET).hex
  144. $(AVRDUDE) -p $(MCU) -c $(PROGRAMMER) -b $(ISPBAUD) -P $(ISPPORT) -e -D -U $(BUILDDIR)/$(TARGET).hex
  145. .PHONY: copy
  146. copy: $(BUILDDIR)/$(TARGET).bin
  147. cp $(BUILDDIR)/$(TARGET).bin /Volumes/MBED/$(TARGET).bin
  148. .PHONY: clean
  149. clean:
  150. $(RM) $(BUILDDIRBASE)
  151. -include $(OBJ:.o=.d)
  152. $(BUILDDIR)/%.o: %.c
  153. @$(MKDIR) $(BUILDDIR)/$(dir $<)
  154. $(GCC) $(CARGS) -c $< -o $@
  155. @$(GCC) $(CARGS) -MM $*.c > $(BUILDDIR)/$*.d
  156. @mv -f $(BUILDDIR)/$*.d $(BUILDDIR)/$*.d.tmp
  157. @sed -e 's|.*:|$(BUILDDIR)/$*.o:|' < $(BUILDDIR)/$*.d.tmp > $(BUILDDIR)/$*.d
  158. @sed -e 's/.*://' < $(BUILDDIR)/$*.d.tmp | sed -e 's/\\$$//' | \
  159. fmt -1 | sed -e 's/^ *//' | sed -e 's/$$/:/' >> $(BUILDDIR)/$*.d
  160. @rm -f $(BUILDDIR)/$*.d.tmp
  161. $(BUILDDIR)/%.o: %.cpp
  162. @$(MKDIR) $(BUILDDIR)/$(dir $<)
  163. $(GPP) $(CPPARGS) -c $< -o $@
  164. @$(GPP) $(CPPARGS) -MM $*.cpp > $(BUILDDIR)/$*.d
  165. @mv -f $(BUILDDIR)/$*.d $(BUILDDIR)/$*.d.tmp
  166. @sed -e 's|.*:|$(BUILDDIR)/$*.o:|' < $(BUILDDIR)/$*.d.tmp > $(BUILDDIR)/$*.d
  167. @sed -e 's/.*://' < $(BUILDDIR)/$*.d.tmp | sed -e 's/\\$$//' | \
  168. fmt -1 | sed -e 's/^ *//' | sed -e 's/$$/:/' >> $(BUILDDIR)/$*.d
  169. @rm -f $(BUILDDIR)/$*.d.tmp
  170. $(BUILDDIR)/$(TARGET).elf: $(OBJ)
  171. $(GCC) $(CARGS) $(OBJ) $(LINKER) --output $@
  172. $(SIZE) $@
  173. $(BUILDDIR)/$(TARGET).hex: $(BUILDDIR)/$(TARGET).elf
  174. $(OBJCOPY) -O ihex $< $@
  175. $(OBJDUMP) -h -S $< > $(@:.hex=.lss)
  176. $(BUILDDIR)/$(TARGET).bin: $(BUILDDIR)/$(TARGET).elf
  177. $(OBJCOPY) -O binary $< $@