Naze32 clone with Frysky receiver
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

makefile 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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/timer.cpp
  45. endif
  46. ifeq ($(AVR),1)
  47. CARGS = -I$(EXTRAINCDIR)
  48. CARGS += -Os
  49. CARGS += -std=$(CSTANDARD)
  50. CARGS += -Wall -Wextra -pedantic -Werror
  51. CARGS += -mmcu=$(MCU)
  52. CARGS += -funsigned-bitfields
  53. CARGS += -fpack-struct
  54. CARGS += -fshort-enums
  55. CARGS += -ffunction-sections
  56. CARGS += -Wshadow
  57. CARGS += -Wpointer-arith -Wcast-qual -Wstrict-prototypes
  58. CARGS += -Wno-main -Wno-write-strings -Wno-unused-parameter
  59. CARGS += -DF_CPU=$(F_CPU)
  60. LINKER = -Wl,--relax
  61. LINKER += -Wl,-Map -Wl,$(@:.elf=.map)
  62. else
  63. PRE_DEFS = -DTOOLCHAIN_GCC_ARM -DTOOLCHAIN_GCC -DARM_MATH_CM3
  64. PRE_DEFS += -DTARGET_LIKE_CORTEX_M3 -DTARGET_CORTEX_M
  65. PRE_DEFS += -DMBED_BUILD_TIMESTAMP=1462534374.34
  66. PRE_DEFS += -DTARGET_LIKE_MBED -DTARGET_LPC176X -DTARGET_NXP
  67. PRE_DEFS += -DTARGET_LPC1768 -D__CORTEX_M3 -DTARGET_M3
  68. PRE_DEFS += -DTARGET_MBED_LPC1768 -D__MBED__=1
  69. CARGS = -I$(EXTRAINCDIR)
  70. CARGS += -Ilib
  71. CARGS += -Os
  72. CARGS += -std=$(CSTANDARD)
  73. CARGS += -Wall -Wextra -pedantic #-Werror
  74. CARGS += -Wno-main
  75. CARGS += -mcpu=$(MCU)
  76. CARGS += -mthumb
  77. CARGS += -fno-common -fmessage-length=0
  78. CARGS += -fno-exceptions -ffunction-sections -fdata-sections
  79. CARGS += -fomit-frame-pointer
  80. CARGS += $(PRE_DEFS)
  81. CPPARGS = -I$(EXTRAINCDIR)
  82. CPPARGS += -Ilib
  83. CPPARGS += -Ilib/mbed/TARGET_LPC1768
  84. CPPARGS += -Ilib/mbed/TARGET_LPC1768/TARGET_NXP
  85. CPPARGS += -Ilib/mbed/TARGET_LPC1768/TARGET_NXP/TARGET_LPC176X
  86. CPPARGS += -Ilib/mbed/TARGET_LPC1768/TARGET_NXP/TARGET_LPC176X/TARGET_MBED_LPC1768
  87. CPPARGS += -Ilib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM
  88. CPPARGS += -Os
  89. CPPARGS += -std=$(CPPSTANDARD)
  90. CPPARGS += -Wall -Wextra -pedantic #-Werror
  91. CPPARGS += -Wno-main
  92. CPPARGS += -mcpu=$(MCU)
  93. CPPARGS += -mthumb
  94. CPPARGS += -fno-common -fmessage-length=0
  95. CPPARGS += -fno-exceptions -ffunction-sections -fdata-sections
  96. CPPARGS += -fomit-frame-pointer -fno-rtti
  97. CPPARGS += $(PRE_DEFS)
  98. LINKER = -mcpu=$(MCU)
  99. LINKER += -mthumb
  100. LINKER += -Wl,--gc-sections
  101. LINKER += --specs=nano.specs
  102. LINKER += -u _printf_float -u _scanf_float
  103. LINKER += -Wl,--wrap,main
  104. #LINKER += -Wl,--cref
  105. LINKER += -Tlib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/LPC1768.ld
  106. LINKER += -Llib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM
  107. LINKER += -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
  108. LINKER += -lmbed
  109. OBJ = lib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/board.o
  110. OBJ += lib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/cmsis_nvic.o
  111. OBJ += lib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/retarget.o
  112. OBJ += lib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/startup_LPC17xx.o
  113. OBJ += lib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/system_LPC17xx.o
  114. endif
  115. ifeq ($(DEBUG),1)
  116. CARGS += -DDEBUG
  117. endif
  118. ifeq ($(AVR),1)
  119. PROGRAMMER = arduino
  120. ISPPORT = /dev/tty.usbserial-A100OZQ1
  121. ISPBAUD = 57600
  122. else
  123. endif
  124. # -----------------------------------------------------------------------------
  125. OBJ += $(addprefix $(BUILDDIR)/, $(SRC:.c=.o))
  126. OBJ += $(addprefix $(BUILDDIR)/, $(CPPSRC:.cpp=.o))
  127. .PHONY: all
  128. all: $(BUILDDIR)/$(TARGET).hex $(BUILDDIR)/$(TARGET).bin
  129. .PHONY: debugArduino
  130. debugArduino:
  131. $(MAKE) BUILDDIR=build/avr/debug TARGET=debug MCU=atmega328 DEBUG=1 all
  132. .PHONY: debugProgramArduino
  133. debugProgramArduino:
  134. $(MAKE) BUILDDIR=build/avr/debug TARGET=debug MCU=atmega328p DEBUG=1 program
  135. .PHONY: debugMbed
  136. debugMbed:
  137. $(MAKE) BUILDDIR=build/arm/debug TARGET=debug AVR=0 DEBUG=1 all
  138. .PHONY: debugProgramMbed
  139. debugProgramMbed:
  140. $(MAKE) BUILDDIR=build/arm/debug TARGET=debug AVR=0 DEBUG=1 copy
  141. .PHONY: program
  142. program: $(BUILDDIR)/$(TARGET).hex
  143. $(AVRDUDE) -p $(MCU) -c $(PROGRAMMER) -b $(ISPBAUD) -P $(ISPPORT) -e -D -U $(BUILDDIR)/$(TARGET).hex
  144. .PHONY: copy
  145. copy: $(BUILDDIR)/$(TARGET).bin
  146. cp $(BUILDDIR)/$(TARGET).bin /Volumes/MBED/$(TARGET).bin
  147. .PHONY: clean
  148. clean:
  149. $(RM) $(BUILDDIRBASE)
  150. -include $(OBJ:.o=.d)
  151. $(BUILDDIR)/%.o: %.c
  152. @$(MKDIR) $(BUILDDIR)/$(dir $<)
  153. $(GCC) $(CARGS) -c $< -o $@
  154. @$(GCC) $(CARGS) -MM $*.c > $(BUILDDIR)/$*.d
  155. @mv -f $(BUILDDIR)/$*.d $(BUILDDIR)/$*.d.tmp
  156. @sed -e 's|.*:|$(BUILDDIR)/$*.o:|' < $(BUILDDIR)/$*.d.tmp > $(BUILDDIR)/$*.d
  157. @sed -e 's/.*://' < $(BUILDDIR)/$*.d.tmp | sed -e 's/\\$$//' | \
  158. fmt -1 | sed -e 's/^ *//' | sed -e 's/$$/:/' >> $(BUILDDIR)/$*.d
  159. @rm -f $(BUILDDIR)/$*.d.tmp
  160. $(BUILDDIR)/%.o: %.cpp
  161. @$(MKDIR) $(BUILDDIR)/$(dir $<)
  162. $(GPP) $(CPPARGS) -c $< -o $@
  163. @$(GPP) $(CPPARGS) -MM $*.cpp > $(BUILDDIR)/$*.d
  164. @mv -f $(BUILDDIR)/$*.d $(BUILDDIR)/$*.d.tmp
  165. @sed -e 's|.*:|$(BUILDDIR)/$*.o:|' < $(BUILDDIR)/$*.d.tmp > $(BUILDDIR)/$*.d
  166. @sed -e 's/.*://' < $(BUILDDIR)/$*.d.tmp | sed -e 's/\\$$//' | \
  167. fmt -1 | sed -e 's/^ *//' | sed -e 's/$$/:/' >> $(BUILDDIR)/$*.d
  168. @rm -f $(BUILDDIR)/$*.d.tmp
  169. $(BUILDDIR)/$(TARGET).elf: $(OBJ)
  170. $(GCC) $(CARGS) $(OBJ) $(LINKER) --output $@
  171. $(SIZE) $@
  172. $(BUILDDIR)/$(TARGET).hex: $(BUILDDIR)/$(TARGET).elf
  173. $(OBJCOPY) -O ihex $< $@
  174. $(OBJDUMP) -h -S $< > $(@:.hex=.lss)
  175. @echo "*****"
  176. @echo "***** You must modify vector checksum value in *.bin and *.hex files."
  177. @echo "*****"
  178. $(BUILDDIR)/$(TARGET).bin: $(BUILDDIR)/$(TARGET).elf
  179. $(OBJCOPY) -O binary $< $@
  180. @echo "*****"
  181. @echo "***** You must modify vector checksum value in *.bin and *.hex files."
  182. @echo "*****"