1
0

Makefile 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. ##########################################################################
  2. # User configuration and firmware specific object files
  3. ##########################################################################
  4. FILENAME=firmware
  5. # See projectconfig.h for a list of valid BOARD options!
  6. BOARD=CFG_BRD_REFORM2
  7. # Set TARGET to 'lpc11u' or 'lpc13u' depending on the target MCU
  8. TARGET = lpc11u
  9. ifeq (lpc11u,$(TARGET))
  10. CORE = cortex-m0
  11. LDSCRIPT = cmsis/lpc11u24.ld
  12. # LDSCRIPT = cmsis/lpc11u37.ld
  13. else
  14. CORE = cortex-m3
  15. LDSCRIPT = cmsis/lpc1347.ld
  16. endif
  17. # Set OPTIMIZATION to '0', '1', '2', '3' or 's'
  18. OPTIMIZATION = s
  19. ##########################################################################
  20. # Output directories
  21. ##########################################################################
  22. BIN_PATH = bin
  23. OBJ_PATH = bin/obj
  24. ##########################################################################
  25. # Source Files
  26. ##########################################################################
  27. VPATH = cmsis
  28. ifeq (lpc11u,$(TARGET))
  29. OBJS = $(OBJ_PATH)/startup_lpc11u_gnumake.o
  30. OBJS += $(OBJ_PATH)/system_LPC11Uxx.o
  31. else
  32. OBJS = $(OBJ_PATH)/startup_lpc13u_gnumake.o
  33. OBJS += $(OBJ_PATH)/system_LPC13Uxx.o
  34. endif
  35. OBJS += $(OBJ_PATH)/math_helper.o
  36. OBJS += $(OBJ_PATH)/RTX_hook.o
  37. VPATH += src
  38. OBJS += $(OBJ_PATH)/printf-retarget.o
  39. VPATH += src/boards/lpcnfc
  40. OBJS += $(OBJ_PATH)/board_lpcnfc.o
  41. VPATH += src/boards/reform2
  42. OBJS += $(OBJ_PATH)/board_reform2.o
  43. VPATH += src/boards/rf1ghzusb
  44. OBJS += $(OBJ_PATH)/board_rf1ghzusb.o
  45. VPATH += src/boards/rf1ghznode
  46. OBJS += $(OBJ_PATH)/board_rf1ghznode.o
  47. VPATH += src/cli
  48. OBJS += $(OBJ_PATH)/cli.o
  49. OBJS += $(OBJ_PATH)/commands.o
  50. VPATH += src/cli/commands
  51. OBJS += $(OBJ_PATH)/cmd_chibi_addr.o
  52. OBJS += $(OBJ_PATH)/cmd_chibi_tx.o
  53. OBJS += $(OBJ_PATH)/cmd_dbg_memrd.o
  54. OBJS += $(OBJ_PATH)/cmd_eeprom_read.o
  55. OBJS += $(OBJ_PATH)/cmd_eeprom_write.o
  56. OBJS += $(OBJ_PATH)/cmd_i2c_read.o
  57. OBJS += $(OBJ_PATH)/cmd_i2c_scan.o
  58. OBJS += $(OBJ_PATH)/cmd_i2c_write.o
  59. OBJS += $(OBJ_PATH)/cmd_nfc_mfc_ndef.o
  60. OBJS += $(OBJ_PATH)/cmd_nfc_mifareclassic_memdump.o
  61. OBJS += $(OBJ_PATH)/cmd_nfc_mifareclassic_valueblock.o
  62. OBJS += $(OBJ_PATH)/cmd_nfc_mifareultralight_memdump.o
  63. OBJS += $(OBJ_PATH)/cmd_rtc_read.o
  64. OBJS += $(OBJ_PATH)/cmd_rtc_write.o
  65. OBJS += $(OBJ_PATH)/cmd_sd_dir.o
  66. OBJS += $(OBJ_PATH)/cmd_sysinfo.o
  67. OBJS += $(OBJ_PATH)/cmd_wifi.o
  68. VPATH += src/core/adc
  69. OBJS += $(OBJ_PATH)/adc.o
  70. VPATH += src/core/delay
  71. OBJS += $(OBJ_PATH)/delay.o
  72. VPATH += src/core/debug
  73. OBJS += $(OBJ_PATH)/debug.o
  74. VPATH += src/core/eeprom
  75. OBJS += $(OBJ_PATH)/eeprom.o
  76. VPATH += src/core/fifo
  77. OBJS += $(OBJ_PATH)/fifo.o
  78. VPATH += src/core/gpio
  79. OBJS += $(OBJ_PATH)/gpio.o
  80. VPATH += src/core/i2c
  81. OBJS += $(OBJ_PATH)/i2c.o
  82. VPATH += src/core/iap
  83. OBJS += $(OBJ_PATH)/iap.o
  84. VPATH += src/core/libc
  85. OBJS += $(OBJ_PATH)/stdio.o
  86. OBJS += $(OBJ_PATH)/string.o
  87. VPATH += src/core/pmu
  88. OBJS += $(OBJ_PATH)/pmu.o
  89. VPATH += src/core/ssp0
  90. OBJS += $(OBJ_PATH)/ssp0.o
  91. VPATH += src/core/ssp1
  92. OBJS += $(OBJ_PATH)/ssp1.o
  93. VPATH += src/core/timer16
  94. OBJS += $(OBJ_PATH)/timer16.o
  95. VPATH += src/core/timer32
  96. OBJS += $(OBJ_PATH)/timer32.o
  97. VPATH += src/core/uart
  98. OBJS += $(OBJ_PATH)/uart.o
  99. OBJS += $(OBJ_PATH)/uart_buf.o
  100. VPATH += src/core/usb
  101. OBJS += $(OBJ_PATH)/descriptors.o
  102. OBJS += $(OBJ_PATH)/usb_cdc.o
  103. OBJS += $(OBJ_PATH)/usb_custom_class.o
  104. OBJS += $(OBJ_PATH)/usb_hid.o
  105. OBJS += $(OBJ_PATH)/usb_msc.o
  106. OBJS += $(OBJ_PATH)/usbd.o
  107. VPATH += src/drivers
  108. OBJS += $(OBJ_PATH)/timespan.o
  109. VPATH += src/drivers/displays
  110. OBJS += $(OBJ_PATH)/smallfonts.o
  111. VPATH += src/drivers/displays/bitmap/ssd1306
  112. OBJS += $(OBJ_PATH)/ssd1306_i2c.o
  113. VPATH += src/drivers/displays/graphic
  114. OBJS += $(OBJ_PATH)/aafonts.o
  115. OBJS += $(OBJ_PATH)/colors.o
  116. OBJS += $(OBJ_PATH)/drawing.o
  117. OBJS += $(OBJ_PATH)/fonts.o
  118. OBJS += $(OBJ_PATH)/theme.o
  119. VPATH += src/drivers/displays/graphic/aafonts/aa2
  120. OBJS += $(OBJ_PATH)/DejaVuSansCondensed14_AA2.o
  121. OBJS += $(OBJ_PATH)/DejaVuSansCondensedBold14_AA2.o
  122. OBJS += $(OBJ_PATH)/DejaVuSansMono10_AA2.o
  123. OBJS += $(OBJ_PATH)/DejaVuSansMono13_AA2.o
  124. OBJS += $(OBJ_PATH)/DejaVuSansMono14_AA2.o
  125. OBJS += $(OBJ_PATH)/FontCalibri18_AA2.o
  126. OBJS += $(OBJ_PATH)/FontCalibriBold18_AA2.o
  127. OBJS += $(OBJ_PATH)/FontCalibriItalic18_AA2.o
  128. OBJS += $(OBJ_PATH)/FontFranklinGothicBold99_Numbers_AA2.o
  129. VPATH += src/drivers/displays/graphic/aafonts/aa4
  130. OBJS += $(OBJ_PATH)/FontCalibri18_AA4.o
  131. VPATH += src/drivers/displays/graphic/fonts
  132. OBJS += $(OBJ_PATH)/dejavusans9.o
  133. OBJS += $(OBJ_PATH)/dejavusansbold9.o
  134. OBJS += $(OBJ_PATH)/dejavusanscondensed9.o
  135. OBJS += $(OBJ_PATH)/dejavusansmono8.o
  136. OBJS += $(OBJ_PATH)/dejavusansmonobold8.o
  137. OBJS += $(OBJ_PATH)/veramono9.o
  138. OBJS += $(OBJ_PATH)/veramono11.o
  139. OBJS += $(OBJ_PATH)/veramonobold9.o
  140. OBJS += $(OBJ_PATH)/veramonobold11.o
  141. OBJS += $(OBJ_PATH)/verdana9.o
  142. OBJS += $(OBJ_PATH)/verdana14.o
  143. OBJS += $(OBJ_PATH)/verdanabold14.o
  144. VPATH += src/drivers/displays/graphic/hw
  145. OBJS += $(OBJ_PATH)/hx8340b.o
  146. # OBJS += $(OBJ_PATH)/hx8347g.o
  147. VPATH += src/drivers/displays/segment/ht16k33
  148. OBJS += $(OBJ_PATH)/ht16k33.o
  149. VPATH += src/drivers/filters/iir
  150. OBJS += $(OBJ_PATH)/iir_f.o
  151. OBJS += $(OBJ_PATH)/iir_i.o
  152. OBJS += $(OBJ_PATH)/iir_u16.o
  153. VPATH += src/drivers/filters/ma
  154. OBJS += $(OBJ_PATH)/sma_f.o
  155. OBJS += $(OBJ_PATH)/sma_i.o
  156. OBJS += $(OBJ_PATH)/sma_u16.o
  157. OBJS += $(OBJ_PATH)/wma_f.o
  158. OBJS += $(OBJ_PATH)/wma_i.o
  159. OBJS += $(OBJ_PATH)/wma_u16.o
  160. VPATH += src/drivers/motor/stepper
  161. OBJS += $(OBJ_PATH)/stepper.o
  162. VPATH += src/drivers/pwm/pca9685
  163. OBJS += $(OBJ_PATH)/pca9685.o
  164. VPATH += src/drivers/rf/802.15.4/chibi
  165. OBJS += $(OBJ_PATH)/chb.o
  166. OBJS += $(OBJ_PATH)/chb_buf.o
  167. OBJS += $(OBJ_PATH)/chb_drvr.o
  168. OBJS += $(OBJ_PATH)/chb_eeprom.o
  169. OBJS += $(OBJ_PATH)/chb_spi.o
  170. OBJS += $(OBJ_PATH)/messages.o
  171. VPATH += src/drivers/rf/nfc/pn532
  172. OBJS += $(OBJ_PATH)/pn532.o
  173. OBJS += $(OBJ_PATH)/pn532_bus_i2c.o
  174. OBJS += $(OBJ_PATH)/pn532_bus_uart.o
  175. VPATH += src/drivers/rf/nfc/pn532/helpers
  176. OBJS += $(OBJ_PATH)/pn532_config.o
  177. OBJS += $(OBJ_PATH)/pn532_gpio.o
  178. OBJS += $(OBJ_PATH)/pn532_mifare_classic.o
  179. OBJS += $(OBJ_PATH)/pn532_mifare_ultralight.o
  180. OBJS += $(OBJ_PATH)/pn532_ndef.o
  181. OBJS += $(OBJ_PATH)/pn532_ndef_cards.o
  182. VPATH += src/drivers/rf/wifi/cc3000
  183. OBJS += $(OBJ_PATH)/spi.o
  184. OBJS += $(OBJ_PATH)/wifi.o
  185. VPATH += src/drivers/rf/wifi/cc3000/hostdriver
  186. OBJS += $(OBJ_PATH)/cc3000_common.o
  187. OBJS += $(OBJ_PATH)/evnt_handler.o
  188. OBJS += $(OBJ_PATH)/hci.o
  189. OBJS += $(OBJ_PATH)/netapp.o
  190. OBJS += $(OBJ_PATH)/nvmem.o
  191. OBJS += $(OBJ_PATH)/security.o
  192. OBJS += $(OBJ_PATH)/socket.o
  193. OBJS += $(OBJ_PATH)/wlan.o
  194. VPATH += src/drivers/rf/nfc/pn532/mem_allocator
  195. OBJS += $(OBJ_PATH)/bget.o
  196. OBJS += $(OBJ_PATH)/pn532_mem.o
  197. VPATH += src/drivers/rtc
  198. OBJS += $(OBJ_PATH)/rtc.o
  199. VPATH += src/drivers/rtc/pcf2129
  200. OBJS += $(OBJ_PATH)/pcf2129.o
  201. VPATH += src/drivers/sensors
  202. OBJS += $(OBJ_PATH)/sensors.o
  203. OBJS += $(OBJ_PATH)/sensorpoll.o
  204. VPATH += src/drivers/sensors/accelerometers
  205. OBJS += $(OBJ_PATH)/accelerometers.o
  206. OBJS += $(OBJ_PATH)/adxl345.o
  207. OBJS += $(OBJ_PATH)/lis3dh.o
  208. OBJS += $(OBJ_PATH)/lsm303accel.o
  209. VPATH += src/drivers/sensors/gyroscopes
  210. OBJS += $(OBJ_PATH)/l3gd20.o
  211. VPATH += src/drivers/sensors/light
  212. OBJS += $(OBJ_PATH)/tsl2561.o
  213. VPATH += src/drivers/sensors/magnetometers
  214. OBJS += $(OBJ_PATH)/magnetometers.o
  215. OBJS += $(OBJ_PATH)/lsm303mag.o
  216. VPATH += src/drivers/sensors/pressure
  217. OBJS += $(OBJ_PATH)/pressure.o
  218. OBJS += $(OBJ_PATH)/bmp085.o
  219. OBJS += $(OBJ_PATH)/mpl115a2.o
  220. VPATH += src/drivers/sensors/temperature
  221. OBJS += $(OBJ_PATH)/lm75b.o
  222. VPATH += src/drivers/storage
  223. OBJS += $(OBJ_PATH)/logger.o
  224. VPATH += src/drivers/storage/fatfs
  225. OBJS += $(OBJ_PATH)/ff.o
  226. OBJS += $(OBJ_PATH)/mmc.o
  227. VPATH += src/localisation
  228. OBJS += $(OBJ_PATH)/localisation.o
  229. VPATH += src/protocol
  230. OBJS += $(OBJ_PATH)/protocol.o
  231. VPATH += src/protocol/commands
  232. OBJS += $(OBJ_PATH)/protocol_cmd_led.o
  233. OBJS += $(OBJ_PATH)/protocol_cmd_sysinfo.o
  234. ##########################################################################
  235. # Include paths
  236. ##########################################################################
  237. ROOT_PATH = src
  238. INCLUDE_PATHS = -I$(ROOT_PATH) -Icmsis
  239. ##########################################################################
  240. # GNU GCC compiler prefix
  241. ##########################################################################
  242. # Use the default toolchain (based on the PATH variable, etc.)
  243. CROSS_COMPILE ?= arm-none-eabi-
  244. # OR ... use a toolchain at a specific location
  245. # CROSS_COMPILE = C:/code_red/RedSuiteNXP_5.0.12_1048/redsuite/tools/bin/arm-none-eabi-
  246. # CROSS_COMPILE = C:/arm/gnu4.7.2012.q4/bin/arm-none-eabi-
  247. AS = $(CROSS_COMPILE)gcc
  248. CC = $(CROSS_COMPILE)gcc
  249. LD = $(CROSS_COMPILE)gcc
  250. SIZE = $(CROSS_COMPILE)size
  251. OBJCOPY = $(CROSS_COMPILE)objcopy
  252. OBJDUMP = $(CROSS_COMPILE)objdump
  253. OUTFILE = $(BIN_PATH)/$(FILENAME)
  254. LPCRC ?= tools/lpcrc/lpcrc
  255. REMOVE = rm -f
  256. MOUNT_POINT ?= /media/CRP DISABLD
  257. ##########################################################################
  258. # Compiler settings, parameters and flags
  259. ##########################################################################
  260. # Compiler Options
  261. GCFLAGS = -c
  262. GCFLAGS += -std=gnu99
  263. GCFLAGS += -g
  264. GCFLAGS += -O$(OPTIMIZATION)
  265. GCFLAGS += $(INCLUDE_PATHS)
  266. GCFLAGS += -Wall
  267. GCFLAGS += -mthumb
  268. GCFLAGS += -ffunction-sections
  269. GCFLAGS += -fdata-sections
  270. GCFLAGS += -fmessage-length=0
  271. GCFLAGS += -fno-builtin
  272. GCFLAGS += -mcpu=$(CORE)
  273. GCFLAGS += -DTARGET=$(TARGET)
  274. GCFLAGS += -D$(BOARD)
  275. # CMSIS DSP Flags
  276. ifeq (lpc11u,$(TARGET))
  277. GCFLAGS += -DARM_MATH_CM0
  278. else
  279. GCFLAGS += -DARM_MATH_CM3
  280. endif
  281. # For use with the GCC ARM Embedded toolchain
  282. # GCFLAGS += --specs=nano.specs
  283. # For use with the LPCXpresso toolchain
  284. # GCFLAGS += -D__REDLIB__ -D__CODE_RED
  285. # Assembler Options
  286. ASFLAGS = -c
  287. ASFLAGS += -g
  288. ASFLAGS += -O$(OPTIMIZATION)
  289. ASFLAGS += $(INCLUDE_PATHS)
  290. ASFLAGS += -Wall
  291. ASFLAGS += -mthumb
  292. ASFLAGS += -ffunction-sections
  293. ASFLAGS += -fdata-sections
  294. ASFLAGS += -fmessage-length=0
  295. ASFLAGS += -mcpu=$(CORE)
  296. ASFLAGS += -D__ASSEMBLY__
  297. ASFLAGS += -x assembler-with-cpp
  298. # Linker Options
  299. LDFLAGS = -nostartfiles
  300. LDFLAGS += -mcpu=$(CORE)
  301. LDFLAGS += -mthumb
  302. LDFLAGS += -O$(OPTIMIZATION)
  303. LDFLAGS += -Wl,--gc-sections
  304. LDFLAGS += -T $(LDSCRIPT)
  305. LDFLAGS += -Xlinker -Map=bin/firmware.map
  306. # CMSIS Libraries
  307. LDFLAGS += -L./cmsis/libs
  308. ifeq (lpc11u,$(TARGET))
  309. LDLIBS = -larm_cortexM0l_math -lRTX_CM0
  310. else
  311. LDLIBS = -larm_cortexM3l_math -lRTX_CM3
  312. endif
  313. # External Libraries
  314. LDLIBS += -lm
  315. # The following libraries are required with the LPCXpresso toolchain
  316. # LDLIBS += -lcr_c -lcr_eabihelpers
  317. OCFLAGS = --strip-unneeded
  318. ##########################################################################
  319. # Rules
  320. ##########################################################################
  321. all: firmware
  322. $(OBJ_PATH)/%.o : %.c
  323. @mkdir -p $(dir $@)
  324. -@echo "COMPILING $(@F)"
  325. @$(CC) $(GCFLAGS) -o $@ $<
  326. $(OBJ_PATH)/%.o : %.s
  327. @mkdir -p $(dir $@)
  328. -@echo "ASSEMBLING $(@F)"
  329. @$(AS) $(ASFLAGS) -o $@ $<
  330. firmware: $(OBJS) $(SYS_OBJS)
  331. @mkdir -p $(BIN_PATH)
  332. -@echo ""
  333. -@echo "LINKING $(OUTFILE).elf ($(CORE) -O$(OPTIMIZATION) $(BOARD))"
  334. @$(LD) $(LDFLAGS) -o $(OUTFILE).elf $(LDLIBS) $(OBJS) $(LDLIBS)
  335. -@echo ""
  336. @$(SIZE) $(OUTFILE).elf
  337. -@echo ""
  338. -@echo "Generating $(OUTFILE).hex"
  339. @$(OBJCOPY) $(OCFLAGS) -O ihex $(OUTFILE).elf $(OUTFILE).hex
  340. -@echo "Generating $(OUTFILE).bin"
  341. @$(OBJCOPY) $(OCFLAGS) -O binary $(OUTFILE).elf $(OUTFILE).bin
  342. -@echo ""
  343. @$(LPCRC) $(OUTFILE).bin
  344. flash: firmware
  345. -@echo ""
  346. -@echo "Flashing device ..."
  347. -@[ -e "$(MOUNT_POINT)/firmware.bin" ] && dd if=bin/firmware.bin of="$(MOUNT_POINT)/firmware.bin" conv=nocreat,notrunc && umount "$(MOUNT_POINT)" || echo "Error, no device?!"
  348. lpcrc:
  349. -@echo ""
  350. -@echo "Building lpcrc (checksum tool) ..."
  351. @make -C tools/lpcrc
  352. clean:
  353. @$(REMOVE) $(OBJS) $(OUTFILE).elf $(OUTFILE).bin $(OUTFILE).hex
  354. #########################################################################